|
|
@@ -812,7 +812,7 @@ class OrderClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//添加订单 ssh 2019.12.5
|
|
|
- public static function addOrder($data)
|
|
|
+ public static function addOrder($data, $custom = [])
|
|
|
{
|
|
|
$shopId = $data['shopId'] ?? 0;
|
|
|
$mainId = $data['mainId'] ?? 0;
|
|
|
@@ -860,6 +860,7 @@ class OrderClass extends BaseClass
|
|
|
$data['bigNum'] = $respond['bigNum'] ?? 0;
|
|
|
$data['smallNum'] = $respond['smallNum'] ?? 0;
|
|
|
$data['itemNum'] = $respond['totalItemNum'] ?? 0;
|
|
|
+ //这个字段记录每个花材满多少扎减掉的金额,并汇总金额,区别于整单满减的 $cutAmount。保存起来应该是在哪里有用,$totalReachDiscount在这边不影响actPrice,估计因为取花材的价格里::getFinalPrice()已经使用了优惠后的价格,有多处,关键词 reachDiscountPrice_explain ssh 20260116
|
|
|
$data['reachDiscountPrice'] = $respond['totalReachDiscount'] ?? 0;
|
|
|
|
|
|
//记录订单的总成本
|
|
|
@@ -885,7 +886,7 @@ class OrderClass extends BaseClass
|
|
|
if ($book == 1) {
|
|
|
$kiloFee = $shop->kiloFee ?? 0;
|
|
|
$miniKilo = $shop->miniKilo ?? 0;
|
|
|
- $calcWeight = $weight > $miniKilo ? $weight : $miniKilo;
|
|
|
+ $calcWeight = max($weight, $miniKilo);
|
|
|
$allKiloFee = bcmul($calcWeight, $kiloFee, 2);
|
|
|
$currentPrice = bcadd($currentPrice, $allKiloFee, 2);
|
|
|
$data['allKiloFee'] = $allKiloFee;
|
|
|
@@ -941,6 +942,28 @@ class OrderClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //如果有设置指定客户涨价百分之几,然后又设置了涨价的幅度。【这个功能主要用于客户不收他运费,门店不赚钱,收他运费客户不乐意,所以把运费加到花材里】,多处同步修改,关键词rise_percent_rang
|
|
|
+ if (isset($data['itemPrice']) && $actPrice >= $data['itemPrice']) {
|
|
|
+ if (isset($custom['risePercent']) && $custom['risePercent'] > 0) {
|
|
|
+ if (isset($custom['riseRange']) && $custom['riseRange'] > 0) {
|
|
|
+ $risePercent = $custom['risePercent'];
|
|
|
+ $riseRange = $custom['riseRange'];
|
|
|
+ // 计算涨价金额:涨价后金额 * (涨价百分比 / (100 + 涨价百分比))
|
|
|
+ $riseAmount = bcmul($data['itemPrice'], bcdiv($risePercent, bcadd(100, $risePercent, 0), 4), 2);
|
|
|
+ if($riseAmount>$riseRange){
|
|
|
+ //应该退回的金额
|
|
|
+ $backAmount = bcsub($riseAmount, $riseRange, 2);
|
|
|
+ $actPrice = bcsub($actPrice, $backAmount, 2);
|
|
|
+ if(isset($data['orderReachDiscountPrice'])){
|
|
|
+ $data['orderReachDiscountPrice'] = bcadd($data['orderReachDiscountPrice'], $backAmount, 2);
|
|
|
+ }else{
|
|
|
+ $data['orderReachDiscountPrice'] = $backAmount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//客户采购时使用红包时
|
|
|
if (isset($data['discountType']) && $data['discountType'] == dict::getDict('discountType', 'hb')) {
|
|
|
$discountAmount = $data['discountAmount'] ?? 0;
|