|
|
@@ -1039,8 +1039,12 @@ class PurchaseController extends BaseController
|
|
|
noticeUtil::push('注意花店买花更换单号:' . $oldOrderSn . ',关单没有成功(收银台-支付宝),' . $msg, '15280215347');
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- $newOrderSn = orderSn::getPurchaseSn();
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ $mainId = $order->mainId ?? 0;
|
|
|
+ $customId = $order->customId ?? 0;
|
|
|
+ $ghsId = $order->ghsId ?? 0;
|
|
|
+ $snData = ['shopId' => $shopId, 'mainId' => $mainId, 'customId' => $customId, 'ghsId' => $ghsId];
|
|
|
+ $newOrderSn = orderSn::getPurchaseSn($snData);
|
|
|
$orderSn = $newOrderSn;
|
|
|
$order->orderSn = $newOrderSn;
|
|
|
$order->save();
|
|
|
@@ -1171,7 +1175,11 @@ class PurchaseController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $newOrderSn = orderSn::getPurchaseSn();
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ $mainId = $order->mainId ?? 0;
|
|
|
+ $customId = $order->customId ?? 0;
|
|
|
+ $snData = ['shopId' => $shopId, 'mainId' => $mainId, 'customId' => $customId, 'ghsId' => $ghsId];
|
|
|
+ $newOrderSn = orderSn::getPurchaseSn($snData);
|
|
|
$orderSn = $newOrderSn;
|
|
|
$order->orderSn = $newOrderSn;
|
|
|
$order->save();
|
|
|
@@ -1303,102 +1311,6 @@ class PurchaseController extends BaseController
|
|
|
{
|
|
|
//lqh 2021.6.25 运费固定返回0
|
|
|
util::success(['sedCost' => 0]);
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $ghsId = $post['ghsId'] ?? 0;
|
|
|
- //供货商
|
|
|
- $ghsInfo = GhsClass::getById($ghsId);
|
|
|
-
|
|
|
- if (empty($ghsInfo)) {
|
|
|
- util::fail('没有找到供货商');
|
|
|
- }
|
|
|
- //花材信息
|
|
|
- $productJson = $post['product'] ?? '';
|
|
|
- // $productJson = '[{"productId":31993,"bigNum":1,"smallNum":0}]';
|
|
|
- if (empty($productJson)) {
|
|
|
- util::fail('请选择花材');
|
|
|
- }
|
|
|
- $productList = json_decode($productJson, true);
|
|
|
- if (empty($productList)) {
|
|
|
- util::fail('请选择花材25');
|
|
|
- }
|
|
|
-
|
|
|
- $productList = PurchaseClass::mergeItemInfo($productList);
|
|
|
- $weight = 0;
|
|
|
- $price = 0;
|
|
|
- $productData = ProductClass::getProductMapData($productList);
|
|
|
- $bigNum = 0;
|
|
|
- foreach ($productList as $key => $val) {
|
|
|
- $productId = $val['productId'];
|
|
|
- $w = ProductClass::getWeight($val['productId'], $val['bigNum'], $val['smallNum']);
|
|
|
- $bigNum += $val['bigNum'];
|
|
|
- $weight = bcadd($w, $weight, 2);
|
|
|
- $ratio = $productData[$productId]['ratio'] ?? 0;
|
|
|
- //大小数量合并多少扎
|
|
|
- $itemNum = ProductClass::mergeItemNum($val['bigNum'], $val['smallNum'], $ratio);
|
|
|
- //售卖价格
|
|
|
- $itemPrice = $productData[$productId]['price'] ?? 0;
|
|
|
- //合计价格
|
|
|
- $price = bcadd($price, bcmul($itemNum, $itemPrice, 2), 2);
|
|
|
- }
|
|
|
- $ghsShopId = $ghsInfo['shopId'] ?? 0;
|
|
|
- $ghsSjId = $ghsInfo['sjId'] ?? 0;
|
|
|
-
|
|
|
- $sendTime = $post['sendTime'] ?? '';
|
|
|
- if (!empty($sendTime)) {
|
|
|
- //配送时间不为空
|
|
|
- // 预约发单时间(预约时间unix时间戳(10位),精确到分;整分钟为间隔,并且需要至少提前5分钟预约
|
|
|
- $sendTimeInt = strtotime($sendTime);
|
|
|
- $now = time();
|
|
|
- $diff = $sendTimeInt - $now;
|
|
|
- //因服务器写入时间,改为至少提前6分钟
|
|
|
- if ($diff <= 360) {
|
|
|
- util::fail('配送时间至少提前6分钟');
|
|
|
- }
|
|
|
- $sendTime = date('Y-m-d H:i', strtotime($sendTime));
|
|
|
- } else {
|
|
|
- $sendTime = date('Y-m-d H:i', strtotime("+30 minute"));
|
|
|
- }
|
|
|
-
|
|
|
- //找供货商的客户信息,用里面的配送相关地址信息
|
|
|
- $customId = $ghsInfo['customId'] ?? 0;
|
|
|
- $customInfo = CustomClass::getById($customId);
|
|
|
- if (empty($customInfo)) {
|
|
|
- util::fail('没有找到客户');
|
|
|
- }
|
|
|
-
|
|
|
- //判断商家是否开启达达,若未开启,则使用自定义运费计算
|
|
|
- $shopNo = ShopExpressClass::getShopNo($ghsSjId, $ghsShopId);
|
|
|
- if (!$shopNo) {
|
|
|
- //使用自定义运费
|
|
|
- //util::fail('供货商暂未开通配送');
|
|
|
- $cost = freight::getCost($ghsInfo['lat'], $ghsInfo['long'], $customInfo['lat'], $customInfo['long'], $weight);
|
|
|
- util::success(['sedCost' => $cost]);
|
|
|
- }
|
|
|
- //组装订单信息
|
|
|
- $info = [];
|
|
|
- //发送放的商家信息,即供货商的相关信息
|
|
|
- $info['sjId'] = $ghsSjId;
|
|
|
- $info['shopId'] = $ghsShopId;
|
|
|
- $info['actPrice'] = $price;//价格
|
|
|
- $info['weight'] = $weight;
|
|
|
- $info['orderSn'] = \common\components\orderSn::getGhsOrderSn();
|
|
|
- $info['bigNum'] = $bigNum;
|
|
|
-
|
|
|
- //配送地址,当前零售端的门店地址
|
|
|
- $info['customName'] = $customInfo['name'] ?? '';
|
|
|
- $info['customMobile'] = $customInfo['mobile'] ?? '';
|
|
|
- $info['province'] = $customInfo['province'] ?? '';
|
|
|
- $info['city'] = $customInfo['city'] ?? '';;
|
|
|
- $info['address'] = $customInfo['address'] ?? '';;
|
|
|
- $info['floor'] = $customInfo['floor'] ?? '';;
|
|
|
- $info['fullAddress'] = $customInfo['fullAddress'] ?? '';;
|
|
|
- $info['lat'] = $customInfo['lat'] ?? '';;
|
|
|
- $info['long'] = $customInfo['long'] ?? '';;
|
|
|
- $info['sendTime'] = $sendTime;
|
|
|
-
|
|
|
- $res = DadaExpressServices::queryDeliverFee($info);
|
|
|
- util::success(['sedCost' => $res['fee']]);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|