|
|
@@ -11,6 +11,7 @@ use bizGhs\custom\classes\AccountMoneyClass;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
use bizGhs\express\classes\GhsDeliveryOrderClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
+use bizGhs\order\classes\ShMethodClass;
|
|
|
use bizHd\cg\classes\CgMergeSnClass;
|
|
|
use bizHd\purchase\classes\PurchaseClass;
|
|
|
use bizHd\purchase\classes\PurchaseItemClass;
|
|
|
@@ -520,6 +521,9 @@ class PurchaseController extends BaseController
|
|
|
|
|
|
$post['product'] = $productList;
|
|
|
|
|
|
+ // xhShMethod 门店下单前保留花材合计,供后续 packCost 计算(pfLevel==0 分支会 unset itemTotalAmount)
|
|
|
+ $shMethodItemAmount = $post['itemTotalAmount'] ?? 0;
|
|
|
+
|
|
|
$sendType = $post['sendType'] ?? 0;
|
|
|
$transType = $post['transType'] ?? 0;
|
|
|
if ($sendType == dict::getDict('sendType', 'thirdSend')) {
|
|
|
@@ -696,142 +700,153 @@ class PurchaseController extends BaseController
|
|
|
noticeUtil::push("包装费:" . $packCost, '15280215347');
|
|
|
}
|
|
|
|
|
|
+ // xhShMethod 门店:下单前按配置写入不满最低消费时的附加包装费/运费
|
|
|
+ if (in_array($ghsShopId, [36523, 0])) {
|
|
|
+ $shMethodBigNum = 0;
|
|
|
+ foreach ($productList as $itemData) {
|
|
|
+ $shMethodBigNum += floatval($itemData['bigNum'] ?? 0);
|
|
|
+ }
|
|
|
+ $post['packCost'] = ShMethodClass::resolvePurchasePackCost(
|
|
|
+ $ghsShopId,
|
|
|
+ $ghsMainId,
|
|
|
+ $sendType,
|
|
|
+ $shMethodItemAmount,
|
|
|
+ $shMethodBigNum
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
$respond = PurchaseService::createPurchase($post, $ghsInfo);
|
|
|
|
|
|
- if ($sendType == 0) {
|
|
|
- if (getenv('YII_ENV') == 'production') {
|
|
|
- //杭州斗南鲜花批发部,满500,10公里内免费配送,满1000,20公里免费配送
|
|
|
- if ($ghsShopId == 4608) {
|
|
|
- if ($respond->actPrice < 500) {
|
|
|
- $transaction->rollBack();
|
|
|
- util::fail('满500元支持免费配送');
|
|
|
+ if (in_array($ghsShopId, [36523, 0])) {
|
|
|
+ // 使用 xhShMethod 配置校验配送限制,替代旧版门店硬编码规则
|
|
|
+ $shMethodError = ShMethodClass::validatePurchaseOrder(
|
|
|
+ $ghsShopId,
|
|
|
+ $ghsMainId,
|
|
|
+ $sendType,
|
|
|
+ $respond->actPrice ?? 0,
|
|
|
+ $respond->bigNum ?? 0,
|
|
|
+ $respond->packCost ?? 0,
|
|
|
+ $post['wlName'] ?? ''
|
|
|
+ );
|
|
|
+ if ($shMethodError !== '') {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::fail($shMethodError);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if ($sendType == 0) {
|
|
|
+ if (getenv('YII_ENV') == 'production') {
|
|
|
+ //杭州斗南鲜花批发部,满500,10公里内免费配送,满1000,20公里免费配送
|
|
|
+ if ($ghsShopId == 4608) {
|
|
|
+ if ($respond->actPrice < 500) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::fail('满500元支持免费配送');
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //叶上花,满500元市区免费配送
|
|
|
- if ($ghsShopId == 4804) {
|
|
|
- if ($respond->actPrice < 500) {
|
|
|
- $transaction->rollBack();
|
|
|
- util::fail('满500元支持免费配送');
|
|
|
+ //叶上花,满500元市区免费配送
|
|
|
+ if ($ghsShopId == 4804) {
|
|
|
+ if ($respond->actPrice < 500) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::fail('满500元支持免费配送');
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //花悠星 国恋 勇记 万丽 陆丰暂时不支持免费配送
|
|
|
- if ($ghsShopId == 7687 || $ghsShopId == 7831 || $ghsShopId == 7778 || $ghsShopId == 12003 || $ghsShopId == 38128) {
|
|
|
- util::fail('暂不支持送货上门,请选其它配送方式!');
|
|
|
- }
|
|
|
-
|
|
|
- //广州鑫源花卉,选择送货上门必须选必选商品
|
|
|
- if ($ghsShopId == 12439) {
|
|
|
- $hasMust = array_intersect($ids, [3446945, 3446970, 3446973, 3446979, 3446995, 3447010, 3447023, 3459983, 4333184, 4317745, 1585738]);
|
|
|
- if (empty($hasMust)) {
|
|
|
- util::fail('请返回选择 必选商品');
|
|
|
+ //花悠星 国恋 勇记 万丽 陆丰暂时不支持免费配送
|
|
|
+ if ($ghsShopId == 7687 || $ghsShopId == 7831 || $ghsShopId == 7778 || $ghsShopId == 12003 || $ghsShopId == 38128) {
|
|
|
+ util::fail('暂不支持送货上门,请选其它配送方式!');
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //三明易批花
|
|
|
- if ($ghsShopId == 82200) {
|
|
|
- if ($respond->actPrice < 100 || $respond->bigNum < 15) {
|
|
|
- $hasMust = array_intersect($ids, [4283478]);
|
|
|
+ //广州鑫源花卉,选择送货上门必须选必选商品
|
|
|
+ if ($ghsShopId == 12439) {
|
|
|
+ $hasMust = array_intersect($ids, [3446945, 3446970, 3446973, 3446979, 3446995, 3447010, 3447023, 3459983, 4333184, 4317745, 1585738]);
|
|
|
if (empty($hasMust)) {
|
|
|
- util::fail('没满100元且15扎,请返回选运费');
|
|
|
+ util::fail('请返回选择 必选商品');
|
|
|
}
|
|
|
}
|
|
|
- // 按当天计时,把 sendTimeWant 要限制在两天的时间范围之内
|
|
|
- $future = date("Y-m-d", strtotime('+2 day'));
|
|
|
- if (strtotime($respond->sendTimeWant) > strtotime($future)) {
|
|
|
- util::fail('配送日期只能选最近二天');
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if ($ghsShopId == 77703) {
|
|
|
- //天天鲜花思明店,暂时关闭送货上门
|
|
|
- if ($respond->sendType == 0) {
|
|
|
- //util::fail('节日暂停送货上门,请选到店自取');
|
|
|
+ //三明易批花
|
|
|
+ if ($ghsShopId == 82200) {
|
|
|
+ if ($respond->actPrice < 100 || $respond->bigNum < 15) {
|
|
|
+ $hasMust = array_intersect($ids, [4283478]);
|
|
|
+ if (empty($hasMust)) {
|
|
|
+ util::fail('没满100元且15扎,请返回选运费');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 按当天计时,把 sendTimeWant 要限制在两天的时间范围之内
|
|
|
+ $future = date("Y-m-d", strtotime('+2 day'));
|
|
|
+ if (strtotime($respond->sendTimeWant) > strtotime($future)) {
|
|
|
+ util::fail('配送日期只能选最近二天');
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if ($ghsShopId == 86726) {
|
|
|
- //藏花林
|
|
|
- if ($respond->transType != 4 && $respond->transType != 5) {
|
|
|
- util::fail('请选同城配送或到店自取');
|
|
|
+ if ($ghsShopId == 77703) {
|
|
|
+ //天天鲜花思明店,暂时关闭送货上门
|
|
|
+ if ($respond->sendType == 0) {
|
|
|
+ //util::fail('节日暂停送货上门,请选到店自取');
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- //好运鲜花批发,选择送货上门必须选必选商品
|
|
|
-// if ($ghsShopId == 36523) {
|
|
|
-// if ($respond->transType != 4 && $respond->transType != 5) {
|
|
|
-// util::fail('请选同城配送或到店自取');
|
|
|
-// }
|
|
|
-// }
|
|
|
|
|
|
-// if ($ghsShopId == 36523) {
|
|
|
-// if ($respond->actPrice < 50 || $respond->bigNum < 10) {
|
|
|
-// $hasMust = array_intersect($ids, [85295]);
|
|
|
-// if (empty($hasMust)) {
|
|
|
-// util::fail('没满50元且满10扎,请运费必选商品');
|
|
|
-// }
|
|
|
-// }
|
|
|
-// // 按当天计时,把 sendTimeWant 要限制在两天的时间范围之内
|
|
|
-// $future = date("Y-m-d", strtotime('+2 day'));
|
|
|
-// if (strtotime($respond->sendTimeWant) > strtotime($future)) {
|
|
|
-// util::fail('配送日期只能选最近二天');
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
- }
|
|
|
+ if ($ghsShopId == 86726) {
|
|
|
+ //藏花林
|
|
|
+ if ($respond->transType != 4 && $respond->transType != 5) {
|
|
|
+ util::fail('请选同城配送或到店自取');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (isset($ghsInfo['home'])) {
|
|
|
- if ($ghsInfo['home'] == 0) {
|
|
|
- util::fail('暂不支持送货上门,请选其它配送方式');
|
|
|
- }
|
|
|
- $homeAmount = $ghsInfo['homeAmount'] ? floatval($ghsInfo['homeAmount']) : 0;
|
|
|
- $homeNum = $ghsInfo['homeNum'] ? floatval($ghsInfo['homeNum']) : 0;
|
|
|
- if ($homeAmount > 0 && $homeAmount > $respond->actPrice) {
|
|
|
- util::fail("满{$homeAmount}元 可送货上门");
|
|
|
}
|
|
|
- if ($homeNum > 0 && $homeNum > $respond->bigNum) {
|
|
|
- util::fail("满{$homeNum}扎 可送货上门");
|
|
|
+
|
|
|
+ if (isset($ghsInfo['home'])) {
|
|
|
+ if ($ghsInfo['home'] == 0) {
|
|
|
+ util::fail('暂不支持送货上门,请选其它配送方式');
|
|
|
+ }
|
|
|
+ $homeAmount = $ghsInfo['homeAmount'] ? floatval($ghsInfo['homeAmount']) : 0;
|
|
|
+ $homeNum = $ghsInfo['homeNum'] ? floatval($ghsInfo['homeNum']) : 0;
|
|
|
+ if ($homeAmount > 0 && $homeAmount > $respond->actPrice) {
|
|
|
+ util::fail("满{$homeAmount}元 可送货上门");
|
|
|
+ }
|
|
|
+ if ($homeNum > 0 && $homeNum > $respond->bigNum) {
|
|
|
+ util::fail("满{$homeNum}扎 可送货上门");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- if ($sendType == 2) {
|
|
|
- //温州易批花,跑腿,不满100,要选10元的补运费商品
|
|
|
- if ($ghsShopId == 91115) {
|
|
|
- if ($respond->actPrice < 100) {
|
|
|
- $transaction->rollBack();
|
|
|
- $hasMust = array_intersect($ids, [4449812, 4449811]);
|
|
|
- if (empty($hasMust)) {
|
|
|
- util::fail('不满100,必选商品 补运费10元');
|
|
|
+ if ($sendType == 2) {
|
|
|
+ //温州易批花,跑腿,不满100,要选10元的补运费商品
|
|
|
+ if ($ghsShopId == 91115) {
|
|
|
+ if ($respond->actPrice < 100) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $hasMust = array_intersect($ids, [4449812, 4449811]);
|
|
|
+ if (empty($hasMust)) {
|
|
|
+ util::fail('不满100,必选商品 补运费10元');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if ($sendType == 4) {
|
|
|
- //温州易批花,快递,不满100,要选10元的补运费商品
|
|
|
- if ($ghsShopId == 91115) {
|
|
|
- if ($respond->actPrice < 100) {
|
|
|
- $transaction->rollBack();
|
|
|
- $hasMust = array_intersect($ids, [4449812, 4449811]);
|
|
|
- if (empty($hasMust)) {
|
|
|
- util::fail('不满100,必选商品 补运费10元');
|
|
|
+ if ($sendType == 4) {
|
|
|
+ //温州易批花,快递,不满100,要选10元的补运费商品
|
|
|
+ if ($ghsShopId == 91115) {
|
|
|
+ if ($respond->actPrice < 100) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $hasMust = array_intersect($ids, [4449812, 4449811]);
|
|
|
+ if (empty($hasMust)) {
|
|
|
+ util::fail('不满100,必选商品 补运费10元');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if ($sendType == 3) {
|
|
|
- //温州易批花,物流,不满200,要选10元的补运费商品
|
|
|
- if ($ghsShopId == 91115) {
|
|
|
- if ($respond->actPrice < 200) {
|
|
|
- $transaction->rollBack();
|
|
|
- $hasMust = array_intersect($ids, [4449812, 4449811]);
|
|
|
- if (empty($hasMust)) {
|
|
|
- util::fail('不满200,必选商品 补运费10元');
|
|
|
+ if ($sendType == 3) {
|
|
|
+ //温州易批花,物流,不满200,要选10元的补运费商品
|
|
|
+ if ($ghsShopId == 91115) {
|
|
|
+ if ($respond->actPrice < 200) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $hasMust = array_intersect($ids, [4449812, 4449811]);
|
|
|
+ if (empty($hasMust)) {
|
|
|
+ util::fail('不满200,必选商品 补运费10元');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
$transaction->commit();
|