|
@@ -77,7 +77,7 @@ class StoreOrder extends BaseModel
|
|
|
* @param $cartInfo
|
|
|
* @return array
|
|
|
*/
|
|
|
- public static function getOrderPriceGroup($cartInfo, $addr)
|
|
|
+ public static function getOrderPriceGroup($cartInfo, $addr, $store_id = 0)
|
|
|
{
|
|
|
$storeFreePostage = floatval(sys_config('store_free_postage')) ?: 0;
|
|
|
$totalPrice = self::getOrderSumPrice($cartInfo, 'truePrice');
|
|
@@ -154,7 +154,20 @@ class StoreOrder extends BaseModel
|
|
|
}
|
|
|
if ($storeFreePostage <= $totalPrice) $storePostage = 0;
|
|
|
}
|
|
|
- return compact('totalDeposit', 'storePostage', 'storeFreePostage', 'totalPrice', 'costPrice', 'vipPrice', 'totalIntegral');
|
|
|
+ if (!$store_id || !$addr) {
|
|
|
+ $storePostageSh = 0;
|
|
|
+ } else {
|
|
|
+ $store = SystemStore::verificWhere()->find($store_id);
|
|
|
+ $distance = getDistance($addr['latitude'], $addr['longitude'], $store['latitude'], $store['longitude']);
|
|
|
+
|
|
|
+ if (!$distance) {
|
|
|
+ $storePostageSh = 0;
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return compact('storePostageSh', 'totalDeposit', 'storePostage', 'storeFreePostage', 'totalPrice', 'costPrice', 'vipPrice', 'totalIntegral');
|
|
|
}
|
|
|
|
|
|
|
|
@@ -296,6 +309,7 @@ class StoreOrder extends BaseModel
|
|
|
$cartInfo = $cartGroup['cartInfo'];
|
|
|
$priceGroup = $cartGroup['priceGroup'];
|
|
|
$other = $cartGroup['other'];
|
|
|
+ $distance = 0;
|
|
|
if ($other['store_id'] != $storeId && !$store_order && !$free_check && !$test) {
|
|
|
self::clearCacheOrderInfo($uid, $key);
|
|
|
return self::setErrorInfo('所选门店改变,请刷新当前页面!', true);
|
|
@@ -320,7 +334,9 @@ class StoreOrder extends BaseModel
|
|
|
if (!$store && !$free_check && !$store_order && !$test) {
|
|
|
return self::setErrorInfo('门店错误!', true);
|
|
|
}
|
|
|
- if (!$test && !$free_check && !$store_order && getDistance($addr['latitude'], $addr['longitude'], $store['latitude'], $store['longitude']) > $store['radius']) return self::setErrorInfo('地址在派送范围外!', true);
|
|
|
+ $distance = getDistance($addr['latitude'], $addr['longitude'], $store['latitude'], $store['longitude']);
|
|
|
+ if (!$test && !$free_check && !$store_order && $distance > $store['radius']) return self::setErrorInfo('地址在派送范围外!', true);
|
|
|
+
|
|
|
} else {
|
|
|
if ((!$real_name || !$phone) && !$test) return self::setErrorInfo('请填写姓名和电话', true);
|
|
|
$addressInfo['real_name'] = $real_name;
|
|
@@ -334,6 +350,12 @@ class StoreOrder extends BaseModel
|
|
|
if (!$storeId && !$test && !$free_check) return self::setErrorInfo('请选择下单门店!', true);
|
|
|
if (!SystemStore::verificWhere()->find($storeId) && !$test && !$free_check) return self::setErrorInfo('请选择正确的下单门店!', true);
|
|
|
|
|
|
+ if ($payType == 'offline' && sys_config('offline_postage') == 1) {
|
|
|
+ $payPostageSh = 0;
|
|
|
+ } else {
|
|
|
+ $payPostageSh = self::getOrderPriceGroup($cartInfo, $addr, $storeId)['storePostageSh'];
|
|
|
+ }
|
|
|
+ $payPrice = bcadd($payPrice, $payPostageSh);
|
|
|
$cartIds = [];
|
|
|
$totalNum = 0;
|
|
|
$gainIntegral = 0;
|
|
@@ -444,7 +466,9 @@ class StoreOrder extends BaseModel
|
|
|
'coupon_price' => $couponPrice,
|
|
|
'deduction_price' => $deductionPrice,
|
|
|
'SurplusIntegral' => $SurplusIntegral,
|
|
|
+ 'pay_postage_sh' => $payPostageSh,
|
|
|
'deposit' => $deposit,
|
|
|
+ 'distance' => $distance,
|
|
|
];
|
|
|
}
|
|
|
$orderInfo = [
|
|
@@ -461,6 +485,8 @@ class StoreOrder extends BaseModel
|
|
|
'coupon_price' => $couponPrice,
|
|
|
'pay_price' => $payPrice,
|
|
|
'pay_postage' => $payPostage,
|
|
|
+ 'pay_postage_sh' => $payPostageSh,
|
|
|
+ 'distance' => $distance,
|
|
|
'deduction_price' => $deductionPrice,
|
|
|
'paid' => 0,
|
|
|
'pay_type' => $payType,
|