|
|
@@ -26,6 +26,7 @@ use bizHd\stat\classes\StatIncomeClass;
|
|
|
use bizHd\wx\classes\WxOpenClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
+use common\components\mapUtil;
|
|
|
use common\components\orderSn;
|
|
|
use common\components\util;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
@@ -58,6 +59,42 @@ class PurchaseClass extends BaseClass
|
|
|
const REFUND_NO = 1;
|
|
|
const REFUND_YES = 2;
|
|
|
|
|
|
+ //计算距离和运费 ssh 20221003
|
|
|
+ public static function getDistanceFee($shop, $ghsShop, $weight)
|
|
|
+ {
|
|
|
+ $shopLat = isset($shop->lat) ? $shop->lat : '';
|
|
|
+ $shopLong = isset($shop->long) ? $shop->long : '';
|
|
|
+
|
|
|
+ $ghsShopLat = isset($ghsShop->lat) ? $ghsShop->lat : '';
|
|
|
+ $ghsShopLong = isset($ghsShop->long) ? $ghsShop->long : '';
|
|
|
+
|
|
|
+ //跑腿费用设置,基础费用8—10元,3—100公里每公里增加2元,超过5公斤,5—21公斤每公斤增加2元
|
|
|
+
|
|
|
+ //起步价
|
|
|
+ $baseFee = 9;
|
|
|
+ $distance = mapUtil::calculateDistance($shopLong, $shopLat, $ghsShopLong, $ghsShopLat);
|
|
|
+ //每公里增加多少元
|
|
|
+ $perKmFee = 2;
|
|
|
+ //每公斤增加多少元
|
|
|
+ $perKiloFee = 2;
|
|
|
+ //免费距离
|
|
|
+ $freeDistance = 2;
|
|
|
+ $freeKm = 5;
|
|
|
+
|
|
|
+ $addDistanceFee = 0;
|
|
|
+ if ($distance > $freeDistance * 1000) {
|
|
|
+ $addDistanceFee = ceil(($distance - $freeDistance * 1000) / 1000) * $perKmFee;
|
|
|
+ }
|
|
|
+ $addWeightFee = 0;
|
|
|
+ if ($weight > $freeKm) {
|
|
|
+ $addWeightFee = ceil(bcsub($weight, $freeKm, 2)) * $perKiloFee;
|
|
|
+ }
|
|
|
+ $addFee = bcadd($addDistanceFee, $addWeightFee, 2);
|
|
|
+ $totalFee = bcadd($baseFee, $addFee, 2);
|
|
|
+ $showDistance = sprintf("%.1f", ($distance / 1000));
|
|
|
+ return ['distance' => $distance, 'showDistance' => $showDistance, 'fee' => $totalFee];
|
|
|
+ }
|
|
|
+
|
|
|
//到货之后 ssh 20220321
|
|
|
public static function arrival($cg, $data)
|
|
|
{
|
|
|
@@ -371,7 +408,7 @@ class PurchaseClass extends BaseClass
|
|
|
$bigPrice = $price;
|
|
|
|
|
|
if ($currentSmallNum > 0) {
|
|
|
- //如果是小单位数量,则传过来的就是小单位价格,无需转换
|
|
|
+ //如果是小单位数量,则传过来的就是小单位价格,无需转换
|
|
|
if (empty($changePrice)) {
|
|
|
$ghsRatio = $currentProduct['ratio'] ?? 0;
|
|
|
$ghsSmallRatio = $currentProduct['smallRatio'] ?? 1;
|