|
|
@@ -631,105 +631,104 @@ class PurchaseController extends BaseController
|
|
|
//标记为昆明到地方订单
|
|
|
$post['localOrder'] = 1;
|
|
|
} else {
|
|
|
- //同城发货包装费和运费的计算
|
|
|
- $sendCost = 0;
|
|
|
- $sendDistance = 0;
|
|
|
- //特别注意,这边取供货商的shop信息
|
|
|
- $mapSet = ShopClass::hasIntraCity($ghsShopInfo);
|
|
|
- $openIntraCity = $mapSet['openIntraCity'] ?? 0;
|
|
|
- if ($sendType == dict::getDict('sendType', 'thirdSend')) {
|
|
|
- if ($openIntraCity == 2) {
|
|
|
- util::fail('不能使用跑腿');
|
|
|
- }
|
|
|
- if ($openIntraCity == 1) {
|
|
|
- // 生成随机订单号,不要跟原来的混起来,跑腿-销售单-
|
|
|
- $prefix = 'PT-XSD-' . $this->mainId . '-';
|
|
|
- $orderSn = $prefix . round(microtime(true) * 1000);
|
|
|
|
|
|
- // 使用 DeliveryQuoteUtil 获取配送报价
|
|
|
- try {
|
|
|
+ // xhShMethod 门店:下单前按配置写入不满最低消费时的附加包装费/运费,关键词sh_method_area
|
|
|
+ if (in_array($ghsShopId, [36523])) {
|
|
|
+ $shMethodBigNum = 0;
|
|
|
+ foreach ($productList as $itemData) {
|
|
|
+ $shMethodBigNum += floatval($itemData['bigNum'] ?? 0);
|
|
|
+ }
|
|
|
+ $additionalCosts = ShMethodClass::calcFee(
|
|
|
+ $ghsShopId,
|
|
|
+ $ghsMainId,
|
|
|
+ $sendType,
|
|
|
+ $shMethodItemAmount,
|
|
|
+ $shMethodBigNum,
|
|
|
+ $customId,
|
|
|
+ $ghsInfo
|
|
|
+ );
|
|
|
+
|
|
|
+ // 如果产生了附加运费,与前面可能产生的 sendCost 进行累加或覆盖
|
|
|
+ if ($additionalCosts['sendCost'] > 0) {
|
|
|
+ $post['sendCost'] = bcadd($post['sendCost'] ?? 0, $additionalCosts['sendCost'], 2);
|
|
|
+ }
|
|
|
|
|
|
- if (empty($post['deliveryPlatform'])) {
|
|
|
- util::fail('请选择跑腿');
|
|
|
- }
|
|
|
+ // 如果产生了附加包装费,覆盖前面赋值的 packCost
|
|
|
+ if ($additionalCosts['packCost'] > 0) {
|
|
|
+ $post['packCost'] = $additionalCosts['packCost'];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
|
|
|
- $quoteResult = DeliveryQuoteUtil::getDeliveryQuote([
|
|
|
- 'productList' => $productList,
|
|
|
- 'deliveryPlatform' => $post['deliveryPlatform'],
|
|
|
- 'deliveryBracketContent' => $post['deliveryBracketContent'], // 平台多报价识别id
|
|
|
- 'ghsInfo' => $ghsInfo,
|
|
|
- 'custom' => $custom,
|
|
|
- 'order' => [
|
|
|
- 'orderSn' => $orderSn,
|
|
|
- 'goodsType' => 1, //商品类型:0花束 1花材
|
|
|
- 'itemTotalAmount' => $post['itemTotalAmount'] ?? 0,
|
|
|
- 'remark' => $post['remark'] ?? '',
|
|
|
- ],
|
|
|
- 'mainId' => $this->mainId,
|
|
|
- 'productCount' => $productCount,
|
|
|
- ]);
|
|
|
-
|
|
|
- $sendCost = $quoteResult['sendCost'];
|
|
|
- $sendDistance = $quoteResult['sendDistance'];
|
|
|
- } catch (\Exception $e) {
|
|
|
- util::fail($e->getMessage());
|
|
|
+ //同城发货包装费和运费的计算
|
|
|
+ $sendCost = 0;
|
|
|
+ $sendDistance = 0;
|
|
|
+ //特别注意,这边取供货商的shop信息
|
|
|
+ $mapSet = ShopClass::hasIntraCity($ghsShopInfo);
|
|
|
+ $openIntraCity = $mapSet['openIntraCity'] ?? 0;
|
|
|
+ if ($sendType == dict::getDict('sendType', 'thirdSend')) {
|
|
|
+ if ($openIntraCity == 2) {
|
|
|
+ util::fail('不能使用跑腿');
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
+ if ($openIntraCity == 1) {
|
|
|
+ // 生成随机订单号,不要跟原来的混起来,跑腿-销售单-
|
|
|
+ $prefix = 'PT-XSD-' . $this->mainId . '-';
|
|
|
+ $orderSn = $prefix . round(microtime(true) * 1000);
|
|
|
|
|
|
- $post['sendCost'] = $sendCost;
|
|
|
- $post['sendDistance'] = $sendDistance;
|
|
|
+ // 使用 DeliveryQuoteUtil 获取配送报价
|
|
|
+ try {
|
|
|
|
|
|
- //出车、发快递、发物流可以算包装费
|
|
|
- $packCost = 0;
|
|
|
- if (isset($ghsInfo['mainId']) && $ghsInfo['mainId'] == 14499) {
|
|
|
- noticeUtil::push("走的pfLevel=0", '15280215347');
|
|
|
- }
|
|
|
- $itemTotalAmount = $post['itemTotalAmount'] ?? 0;
|
|
|
- unset($post['itemTotalAmount']);
|
|
|
- if ($sendType == dict::getDict('sendType', 'express')) {
|
|
|
- $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId, $itemTotalAmount);
|
|
|
- if ($needAdd) {
|
|
|
- $packCost = $ghsShopInfo->packCost ?? 0;
|
|
|
- }
|
|
|
- }
|
|
|
- $post['packCost'] = $packCost;
|
|
|
- }
|
|
|
+ if (empty($post['deliveryPlatform'])) {
|
|
|
+ util::fail('请选择跑腿');
|
|
|
+ }
|
|
|
|
|
|
- if (isset($ghsInfo['mainId']) && $ghsInfo['mainId'] == 14499) {
|
|
|
- noticeUtil::push("包装费:" . $packCost, '15280215347');
|
|
|
- }
|
|
|
+ $quoteResult = DeliveryQuoteUtil::getDeliveryQuote([
|
|
|
+ 'productList' => $productList,
|
|
|
+ 'deliveryPlatform' => $post['deliveryPlatform'],
|
|
|
+ 'deliveryBracketContent' => $post['deliveryBracketContent'], // 平台多报价识别id
|
|
|
+ 'ghsInfo' => $ghsInfo,
|
|
|
+ 'custom' => $custom,
|
|
|
+ 'order' => [
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'goodsType' => 1, //商品类型:0花束 1花材
|
|
|
+ 'itemTotalAmount' => $post['itemTotalAmount'] ?? 0,
|
|
|
+ 'remark' => $post['remark'] ?? '',
|
|
|
+ ],
|
|
|
+ 'mainId' => $this->mainId,
|
|
|
+ 'productCount' => $productCount,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $sendCost = $quoteResult['sendCost'];
|
|
|
+ $sendDistance = $quoteResult['sendDistance'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ util::fail($e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // xhShMethod 门店:下单前按配置写入不满最低消费时的附加包装费/运费,关键词sh_method_area
|
|
|
- if (in_array($ghsShopId, [36523, 0])) {
|
|
|
- $shMethodBigNum = 0;
|
|
|
- foreach ($productList as $itemData) {
|
|
|
- $shMethodBigNum += floatval($itemData['bigNum'] ?? 0);
|
|
|
- }
|
|
|
- $additionalCosts = ShMethodClass::calcFee(
|
|
|
- $ghsShopId,
|
|
|
- $ghsMainId,
|
|
|
- $sendType,
|
|
|
- $shMethodItemAmount,
|
|
|
- $shMethodBigNum,
|
|
|
- $customId,
|
|
|
- $ghsInfo
|
|
|
- );
|
|
|
+ $post['sendCost'] = $sendCost;
|
|
|
+ $post['sendDistance'] = $sendDistance;
|
|
|
|
|
|
- // 如果产生了附加运费,与前面可能产生的 sendCost 进行累加或覆盖
|
|
|
- if ($additionalCosts['sendCost'] > 0) {
|
|
|
- $post['sendCost'] = bcadd($post['sendCost'] ?? 0, $additionalCosts['sendCost'], 2);
|
|
|
- }
|
|
|
+ //出车、发快递、发物流可以算包装费
|
|
|
+ $packCost = 0;
|
|
|
+ if (isset($ghsInfo['mainId']) && $ghsInfo['mainId'] == 14499) {
|
|
|
+ noticeUtil::push("走的pfLevel=0", '15280215347');
|
|
|
+ }
|
|
|
+ $itemTotalAmount = $post['itemTotalAmount'] ?? 0;
|
|
|
+ unset($post['itemTotalAmount']);
|
|
|
+ if ($sendType == dict::getDict('sendType', 'express')) {
|
|
|
+ $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId, $itemTotalAmount);
|
|
|
+ if ($needAdd) {
|
|
|
+ $packCost = $ghsShopInfo->packCost ?? 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $post['packCost'] = $packCost;
|
|
|
|
|
|
- // 如果产生了附加包装费,覆盖前面赋值的 packCost
|
|
|
- if ($additionalCosts['packCost'] > 0) {
|
|
|
- $post['packCost'] = $additionalCosts['packCost'];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$respond = PurchaseService::createPurchase($post, $ghsInfo);
|
|
|
|
|
|
- if (in_array($ghsShopId, [36523, 0])) {
|
|
|
+ if (in_array($ghsShopId, [36523])) {
|
|
|
// 使用 xhShMethod 配置校验配送限制,替代旧版门店硬编码规则,关键词sh_method_area
|
|
|
$shMethodError = ShMethodClass::checkLimit(
|
|
|
$ghsShopId,
|