|
|
@@ -19,6 +19,7 @@ use bizMall\saas\services\RegionService;
|
|
|
use bizMall\shop\classes\ShopExtClass;
|
|
|
use bizMall\user\services\UserService;
|
|
|
use common\components\dateUtil;
|
|
|
+use common\components\delivery\util\DeliveryQuoteUtil;
|
|
|
use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
use common\components\noticeUtil;
|
|
|
@@ -334,12 +335,12 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
$originalLng = doubleval($post['long']);
|
|
|
$originalLat = doubleval($post['lat']);
|
|
|
- $city = $post['city'] ?? '';
|
|
|
- $dist = $post['dist'] ?? '';
|
|
|
- $address = $post['address'] ?? '';
|
|
|
- $showAddress = $post['showAddress'] ?? '';
|
|
|
- $userAddress = $city . $dist . $address . "({$showAddress})";
|
|
|
- $main = $this->main;
|
|
|
+ // $city = $post['city'] ?? '';
|
|
|
+ // $dist = $post['dist'] ?? '';
|
|
|
+ // $address = $post['address'] ?? '';
|
|
|
+ // $showAddress = $post['showAddress'] ?? '';
|
|
|
+ // $userAddress = $city . $dist . $address . "({$showAddress})";
|
|
|
+ // $main = $this->main;
|
|
|
$shop = $this->shop;
|
|
|
$shopLat = $shop->lat ?? '';
|
|
|
$shopLong = $shop->long ?? '';
|
|
|
@@ -347,29 +348,61 @@ class OrderController extends BaseController
|
|
|
util::fail('商家门店地址定位未设置,编号263');
|
|
|
}
|
|
|
|
|
|
- $wxStoreId = $main->wxStoreId ?? 0;
|
|
|
- if (empty($wxStoreId)) {
|
|
|
- util::fail('商家还没有开通跑腿功能');
|
|
|
+ // $wxStoreId = $main->wxStoreId ?? 0;
|
|
|
+ // if (empty($wxStoreId)) {
|
|
|
+ // util::fail('商家还没有开通跑腿功能');
|
|
|
+ // }
|
|
|
+ // $orderData = [
|
|
|
+ // 'wx_store_id' => $wxStoreId,
|
|
|
+ // 'user_name' => $customName,
|
|
|
+ // 'user_phone' => $customMobile,
|
|
|
+ // 'user_lng' => $originalLng,
|
|
|
+ // 'user_lat' => $originalLat,
|
|
|
+ // 'user_address' => $userAddress,
|
|
|
+ // 'cargo' => $cargo,
|
|
|
+ // ];
|
|
|
+ // //多处有用到这个方法,需修改请同步修改,搜索关键词 intra_city_express_pre_add
|
|
|
+ // $result = IntraCityExpress::preAddOrder($orderData);
|
|
|
+ // $errCode = $result['errcode'] ?? 1;
|
|
|
+ // if ($errCode != 0) {
|
|
|
+ // $errMsg = $result['errmsg'] ?? '';
|
|
|
+ // util::fail('获取运费错误:' . $errMsg);
|
|
|
+ // }
|
|
|
+ // $fee = $result['est_fee'] ?? 0;
|
|
|
+ // $distance = $result['distance'] ?? 0;
|
|
|
+ // $sendCost = bcdiv($fee, 100, 2);
|
|
|
+
|
|
|
+ $distance = 0;
|
|
|
+ $sendCost = 0;
|
|
|
+
|
|
|
+ $prefix = 'XSD_CS-' . $this->mainId . '-';
|
|
|
+ $orderSn = $prefix . round(microtime(true) * 1000);
|
|
|
+
|
|
|
+ $ghsInfo = ['mainId'=>$this->mainId, 'shopId'=>$this->shopId];
|
|
|
+
|
|
|
+ // 这儿要调用跑腿接口计算运费和距离
|
|
|
+ try {
|
|
|
+ $quoteResult = DeliveryQuoteUtil::getDeliveryQuote([
|
|
|
+ 'productList' => $productList,
|
|
|
+ 'deliveryPlatform' => $post['deliveryPlatform'],
|
|
|
+ 'deliveryBracketContent' => $post['deliveryBracketContent'], // 平台多报价识别id
|
|
|
+ 'ghsInfo' => $ghsInfo,
|
|
|
+ 'custom' => $this->user, // $custom 数据有问题,要是 user
|
|
|
+ 'order' => [
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'itemTotalAmount' => $post['itemTotalAmount'] ?? 0,
|
|
|
+ 'remark' => $post['remark'] ?? '',
|
|
|
+ ],
|
|
|
+ 'mainId' => $this->mainId,
|
|
|
+ 'productCount' => $totalNum,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $sendCost = $quoteResult['sendCost'];
|
|
|
+ $distance = $quoteResult['sendDistance'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ util::fail($e->getMessage());
|
|
|
}
|
|
|
- $orderData = [
|
|
|
- 'wx_store_id' => $wxStoreId,
|
|
|
- 'user_name' => $customName,
|
|
|
- 'user_phone' => $customMobile,
|
|
|
- 'user_lng' => $originalLng,
|
|
|
- 'user_lat' => $originalLat,
|
|
|
- 'user_address' => $userAddress,
|
|
|
- 'cargo' => $cargo,
|
|
|
- ];
|
|
|
- //多处有用到这个方法,需修改请同步修改,搜索关键词 intra_city_express_pre_add
|
|
|
- $result = IntraCityExpress::preAddOrder($orderData);
|
|
|
- $errCode = $result['errcode'] ?? 1;
|
|
|
- if ($errCode != 0) {
|
|
|
- $errMsg = $result['errmsg'] ?? '';
|
|
|
- util::fail('获取运费错误:' . $errMsg);
|
|
|
- }
|
|
|
- $fee = $result['est_fee'] ?? 0;
|
|
|
- $distance = $result['distance'] ?? 0;
|
|
|
- $sendCost = bcdiv($fee, 100, 2);
|
|
|
+
|
|
|
$post['sendCost'] = $sendCost;
|
|
|
$post['sendDistance'] = $distance;
|
|
|
noticeUtil::push("零售订单,获取运费:{$sendCost} 重量:{$totalWeight} 距离:{$distance} 姓名:{$customName} 手机号 {$customMobile} 经纬 {$originalLng} {$originalLat} 金额:{$modifyPrice} 数量:{$totalNum}", '15280215347');
|
|
|
@@ -492,86 +525,126 @@ class OrderController extends BaseController
|
|
|
$sendCost = 0;
|
|
|
|
|
|
if ($sendType == dict::getDict('sendType', 'thirdSend')) {
|
|
|
- if (dict::getDict('hasMap') == 0) {
|
|
|
- util::fail('不能使用跑腿,请选其它方式');
|
|
|
- }
|
|
|
- $lat = $post['lat'] ?? '';
|
|
|
- $lng = $post['long'] ?? '';
|
|
|
- if ((empty($lat) || empty($lng))) { // 当 hasMap 为1时,经纬数据是必要的
|
|
|
- util::fail('请填写正确地址');
|
|
|
- }
|
|
|
- $address = $post['address'] ?? '';
|
|
|
- $floor = $post['floor'] ?? '';
|
|
|
- $fullAddress = $address . $floor;
|
|
|
- $post['fullAddress'] = $fullAddress;
|
|
|
-
|
|
|
- $shopLat = $shop->lat ?? '';
|
|
|
- $shopLong = $shop->long ?? '';
|
|
|
- if (empty($shopLat) || empty($shopLong)) {
|
|
|
- util::fail('商家门店地址定位未设置,编号8966');
|
|
|
- }
|
|
|
-
|
|
|
- $weight = $goodsInfo->weight ?? 0;
|
|
|
- if ($weight <= 0) {
|
|
|
- util::fail('商品没有重量');
|
|
|
- }
|
|
|
- $totalWeight = bcmul($weight, $goodsNum, 2);
|
|
|
- $cargoName = '鲜花'; // 商品名称
|
|
|
- $cargo = [
|
|
|
- 'cargo_name' => $cargoName, // 商品名称
|
|
|
- 'cargo_weight' => intval($totalWeight * 1000), // 单位:克 -- 把千克转换为克 ---- 重量(用户未知)-- 大概
|
|
|
- 'cargo_price' => intval($goodsPrice * 100), // 单位:分 -- 把元转换为分
|
|
|
- 'cargo_type' => IntraCityExpress::GOODS_TYPE_FLOWER,
|
|
|
- 'cargo_num' => $goodsNum
|
|
|
+ // if (dict::getDict('hasMap') == 0) {
|
|
|
+ // util::fail('不能使用跑腿,请选其它方式');
|
|
|
+ // }
|
|
|
+ // $lat = $post['lat'] ?? '';
|
|
|
+ // $lng = $post['long'] ?? '';
|
|
|
+ // if ((empty($lat) || empty($lng))) { // 当 hasMap 为1时,经纬数据是必要的
|
|
|
+ // util::fail('请填写正确地址');
|
|
|
+ // }
|
|
|
+ // $address = $post['address'] ?? '';
|
|
|
+ // $floor = $post['floor'] ?? '';
|
|
|
+ // $fullAddress = $address . $floor;
|
|
|
+ // $post['fullAddress'] = $fullAddress;
|
|
|
+
|
|
|
+ // $shopLat = $shop->lat ?? '';
|
|
|
+ // $shopLong = $shop->long ?? '';
|
|
|
+ // if (empty($shopLat) || empty($shopLong)) {
|
|
|
+ // util::fail('商家门店地址定位未设置,编号8966');
|
|
|
+ // }
|
|
|
+
|
|
|
+ // $weight = $goodsInfo->weight ?? 0;
|
|
|
+ // if ($weight <= 0) {
|
|
|
+ // util::fail('商品没有重量');
|
|
|
+ // }
|
|
|
+ // $totalWeight = bcmul($weight, $goodsNum, 2);
|
|
|
+ // $cargoName = '鲜花'; // 商品名称
|
|
|
+ // $cargo = [
|
|
|
+ // 'cargo_name' => $cargoName, // 商品名称
|
|
|
+ // 'cargo_weight' => intval($totalWeight * 1000), // 单位:克 -- 把千克转换为克 ---- 重量(用户未知)-- 大概
|
|
|
+ // 'cargo_price' => intval($goodsPrice * 100), // 单位:分 -- 把元转换为分
|
|
|
+ // 'cargo_type' => IntraCityExpress::GOODS_TYPE_FLOWER,
|
|
|
+ // 'cargo_num' => $goodsNum
|
|
|
+ // ];
|
|
|
+ // $customName = $custom->name;
|
|
|
+ // $customMobile = $custom->mobile;
|
|
|
+ // if (empty($post['long']) || empty($post['lat'])) {
|
|
|
+ // util::fail('位置错误');
|
|
|
+ // }
|
|
|
+ // $originalLng = doubleval($post['long']);
|
|
|
+ // $originalLat = doubleval($post['lat']);
|
|
|
+ // $city = $post['city'] ?? '';
|
|
|
+ // $dist = $post['dist'] ?? '';
|
|
|
+ // $address = $post['address'] ?? '';
|
|
|
+ // $showAddress = $post['showAddress'] ?? '';
|
|
|
+ // $userAddress = $city . $dist . $address . "({$showAddress})";
|
|
|
+ // $main = $this->main;
|
|
|
+
|
|
|
+ // $shopLat = $shop->lat ?? '';
|
|
|
+ // $shopLong = $shop->long ?? '';
|
|
|
+ // if (empty($shopLat) || empty($shopLong)) {
|
|
|
+ // util::fail('商家门店地址定位未设置,编号6880');
|
|
|
+ // }
|
|
|
+
|
|
|
+ // $wxStoreId = $main->wxStoreId ?? 0;
|
|
|
+ // if (empty($wxStoreId)) {
|
|
|
+ // util::fail('商家还没有开通跑腿功能');
|
|
|
+ // }
|
|
|
+ // $orderData = [
|
|
|
+ // 'wx_store_id' => $wxStoreId,
|
|
|
+ // 'user_name' => $customName,
|
|
|
+ // 'user_phone' => $customMobile,
|
|
|
+ // 'user_lng' => $originalLng,
|
|
|
+ // 'user_lat' => $originalLat,
|
|
|
+ // 'user_address' => $userAddress,
|
|
|
+ // 'cargo' => $cargo,
|
|
|
+ // ];
|
|
|
+ // //多处有用到这个方法,需修改请同步修改,搜索关键词 intra_city_express_pre_add
|
|
|
+ // $result = IntraCityExpress::preAddOrder($orderData);
|
|
|
+ // $errCode = $result['errcode'] ?? 1;
|
|
|
+ // if ($errCode != 0) {
|
|
|
+ // $errMsg = $result['errmsg'] ?? '';
|
|
|
+ // util::fail('获取运费错误:' . $errMsg);
|
|
|
+ // }
|
|
|
+ // $fee = $result['est_fee'] ?? 0;
|
|
|
+ // $sendDistance = $result['distance'] ?? 0;
|
|
|
+ // $sendCost = bcdiv($fee, 100, 2);
|
|
|
+ // //免运费的不收运费
|
|
|
+ // if ($goodsInfo->freightType == 1) {
|
|
|
+ // $sendCost = 0;
|
|
|
+ // }
|
|
|
+ // noticeUtil::push("零售订单!获取运费:{$sendCost} 重量:{$totalWeight} 距离:{$sendDistance} 姓名:{$customName} 手机号 {$customMobile} 经纬 {$originalLng} {$originalLat} 金额:{$goodsPrice} 数量:{$goodsNum}", '15280215347');
|
|
|
+
|
|
|
+ $cutomInfo = [
|
|
|
+ 'name' => $post['receiveUserName'],
|
|
|
+ 'mobile' => $post['receiveMobile'],
|
|
|
+ 'fullAddress' => $post['address'],
|
|
|
+ 'floor' => $post['floor'],
|
|
|
+ 'dist' => $post[''] ?? '',
|
|
|
+ 'lat' => $post['lat'],
|
|
|
+ 'long' => $post['long'],
|
|
|
+ 'address' => $post['address'],
|
|
|
+ 'city' => $post['city'],
|
|
|
];
|
|
|
- $customName = $custom->name;
|
|
|
- $customMobile = $custom->mobile;
|
|
|
- if (empty($post['long']) || empty($post['lat'])) {
|
|
|
- util::fail('位置错误');
|
|
|
- }
|
|
|
- $originalLng = doubleval($post['long']);
|
|
|
- $originalLat = doubleval($post['lat']);
|
|
|
- $city = $post['city'] ?? '';
|
|
|
- $dist = $post['dist'] ?? '';
|
|
|
- $address = $post['address'] ?? '';
|
|
|
- $showAddress = $post['showAddress'] ?? '';
|
|
|
- $userAddress = $city . $dist . $address . "({$showAddress})";
|
|
|
- $main = $this->main;
|
|
|
-
|
|
|
- $shopLat = $shop->lat ?? '';
|
|
|
- $shopLong = $shop->long ?? '';
|
|
|
- if (empty($shopLat) || empty($shopLong)) {
|
|
|
- util::fail('商家门店地址定位未设置,编号6880');
|
|
|
- }
|
|
|
-
|
|
|
- $wxStoreId = $main->wxStoreId ?? 0;
|
|
|
- if (empty($wxStoreId)) {
|
|
|
- util::fail('商家还没有开通跑腿功能');
|
|
|
- }
|
|
|
- $orderData = [
|
|
|
- 'wx_store_id' => $wxStoreId,
|
|
|
- 'user_name' => $customName,
|
|
|
- 'user_phone' => $customMobile,
|
|
|
- 'user_lng' => $originalLng,
|
|
|
- 'user_lat' => $originalLat,
|
|
|
- 'user_address' => $userAddress,
|
|
|
- 'cargo' => $cargo,
|
|
|
- ];
|
|
|
- //多处有用到这个方法,需修改请同步修改,搜索关键词 intra_city_express_pre_add
|
|
|
- $result = IntraCityExpress::preAddOrder($orderData);
|
|
|
- $errCode = $result['errcode'] ?? 1;
|
|
|
- if ($errCode != 0) {
|
|
|
- $errMsg = $result['errmsg'] ?? '';
|
|
|
- util::fail('获取运费错误:' . $errMsg);
|
|
|
- }
|
|
|
- $fee = $result['est_fee'] ?? 0;
|
|
|
- $sendDistance = $result['distance'] ?? 0;
|
|
|
- $sendCost = bcdiv($fee, 100, 2);
|
|
|
- //免运费的不收运费
|
|
|
- if ($goodsInfo->freightType == 1) {
|
|
|
- $sendCost = 0;
|
|
|
+ $cutomInfo = (object)$cutomInfo;
|
|
|
+
|
|
|
+ // 生成随机订单号
|
|
|
+ $prefix = 'XSD_CS-' . $this->mainId . '-';
|
|
|
+ $orderSn = $prefix . round(microtime(true) * 1000);
|
|
|
+
|
|
|
+ // 使用 DeliveryQuoteUtil 获取配送报价
|
|
|
+ try {
|
|
|
+ $quoteResult = DeliveryQuoteUtil::getDeliveryQuote([
|
|
|
+ 'productList' => [['bigNum' => $goodsNum, 'weight' => $goodsInfo->weight]],
|
|
|
+ 'deliveryPlatform' => $post['deliveryPlatform'],
|
|
|
+ 'deliveryBracketContent' => $post['deliveryBracketContent'], // 平台多报价识别id
|
|
|
+ 'ghsInfo' => ['mainId' => $mainId, 'shopId' => $this->shopId],
|
|
|
+ 'custom' => $cutomInfo,
|
|
|
+ 'order' => [
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'itemTotalAmount' => $post['itemTotalAmount'] ?? 0,
|
|
|
+ 'remark' => $post['remark'] ?? '',
|
|
|
+ ],
|
|
|
+ 'mainId' => $this->mainId,
|
|
|
+ 'productCount' => $goodsNum,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $sendCost = $quoteResult['sendCost'];
|
|
|
+ $sendDistance = $quoteResult['sendDistance'];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ util::fail($e->getMessage());
|
|
|
}
|
|
|
- noticeUtil::push("零售订单!获取运费:{$sendCost} 重量:{$totalWeight} 距离:{$sendDistance} 姓名:{$customName} 手机号 {$customMobile} 经纬 {$originalLng} {$originalLat} 金额:{$goodsPrice} 数量:{$goodsNum}", '15280215347');
|
|
|
}
|
|
|
$post['sendDistance'] = $sendDistance;
|
|
|
$post['sendCost'] = $sendCost;
|