|
|
@@ -197,9 +197,10 @@ class ShMethodClass extends BaseClass
|
|
|
* @param float $sendCost 已写入采购单的运费
|
|
|
* @param string $wlName 物流公司名称(style=3 时必填)
|
|
|
* @param int $customId 客户ID,用于判断当天是否已收过
|
|
|
+ * @param array|object $ghsInfo 客户与该供货商的关系信息(xhGhs)
|
|
|
* @return string 空字符串表示通过,否则为需提示用户的错误文案
|
|
|
*/
|
|
|
- public static function checkLimit($shopId, $mainId, $sendType, $actPrice, $bigNum, $packCost = 0, $sendCost = 0, $wlName = '', $customId = 0)
|
|
|
+ public static function checkLimit($shopId, $mainId, $sendType, $actPrice, $bigNum, $packCost = 0, $sendCost = 0, $wlName = '', $customId = 0, $ghsInfo = [])
|
|
|
{
|
|
|
$style = (int)$sendType;
|
|
|
if ($style < 0 || $style > 4) {
|
|
|
@@ -207,10 +208,20 @@ class ShMethodClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
$config = self::getConfig($shopId, $mainId, $style);
|
|
|
+
|
|
|
if (empty($config)) {
|
|
|
return '配送方式配置异常';
|
|
|
}
|
|
|
|
|
|
+ if ($style === 0 && !empty($ghsInfo) && isset($ghsInfo['homeRule']) && $ghsInfo['homeRule'] == 1) {
|
|
|
+ // 如果 homeRule == 1,特定字段取xhGhs的设置(优先级最高),其余(如name)保留原配置
|
|
|
+ $config['status'] = $ghsInfo['home'] ?? 0;
|
|
|
+ $config['minAmount'] = $ghsInfo['homeAmount'] ?? 0;
|
|
|
+ $config['minNum'] = $ghsInfo['homeNum'] ?? 0;
|
|
|
+ $config['unMeet'] = $ghsInfo['homeUnMeet'] ?? 0;
|
|
|
+ $config['unMeetFee'] = $ghsInfo['homeUnFee'] ?? 0;
|
|
|
+ }
|
|
|
+
|
|
|
$methodName = !empty($config['name']) ? $config['name'] : '该配送方式';
|
|
|
|
|
|
// 配送方式已禁用,对齐旧逻辑「暂不支持送货上门,请选其它配送方式」
|
|
|
@@ -321,9 +332,10 @@ class ShMethodClass extends BaseClass
|
|
|
* @param float $itemTotalAmount 花材合计金额(下单前,与前端 commodityPrice 一致)
|
|
|
* @param int|float $bigNum 下单扎数
|
|
|
* @param int $customId 客户ID,用于判断当天是否已收过
|
|
|
+ * @param array|object $ghsInfo 客户与该供货商的关系信息(xhGhs)
|
|
|
* @return array ['sendCost' => 运费, 'packCost' => 包装费]
|
|
|
*/
|
|
|
- public static function calcFee($shopId, $mainId, $sendType, $itemTotalAmount, $bigNum, $customId = 0)
|
|
|
+ public static function calcFee($shopId, $mainId, $sendType, $itemTotalAmount, $bigNum, $customId = 0, $ghsInfo = [])
|
|
|
{
|
|
|
$costs = ['sendCost' => 0, 'packCost' => 0];
|
|
|
|
|
|
@@ -333,10 +345,20 @@ class ShMethodClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
$config = self::getConfig($shopId, $mainId, $style);
|
|
|
+
|
|
|
if (empty($config)) {
|
|
|
return $costs;
|
|
|
}
|
|
|
|
|
|
+ if ($style === 0 && !empty($ghsInfo) && isset($ghsInfo['homeRule']) && $ghsInfo['homeRule'] == 1) {
|
|
|
+ // 如果 homeRule == 1,特定字段取xhGhs的设置(优先级最高),其余(如name)保留原配置
|
|
|
+ $config['status'] = $ghsInfo['home'] ?? 0;
|
|
|
+ $config['minAmount'] = $ghsInfo['homeAmount'] ?? 0;
|
|
|
+ $config['minNum'] = $ghsInfo['homeNum'] ?? 0;
|
|
|
+ $config['unMeet'] = $ghsInfo['homeUnMeet'] ?? 0;
|
|
|
+ $config['unMeetFee'] = $ghsInfo['homeUnFee'] ?? 0;
|
|
|
+ }
|
|
|
+
|
|
|
// 直接合并 isBelowMinimum 的逻辑,方便理解,不再套用额外的方法
|
|
|
$minAmount = isset($config['minAmount']) ? (float)$config['minAmount'] : 0.00;
|
|
|
$minNum = isset($config['minNum']) ? (int)$config['minNum'] : 0;
|