|
@@ -320,12 +320,14 @@ class OrderCreate
|
|
$bean_rate = floatval($bean_rate) > 0 ? $bean_rate : 0;
|
|
$bean_rate = floatval($bean_rate) > 0 ? $bean_rate : 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //善豆理论最大金额
|
|
$current_goods_bean_amount = bcdiv(bcmul($current_goods_amount,$bean_rate,2),100,2);
|
|
$current_goods_bean_amount = bcdiv(bcmul($current_goods_amount,$bean_rate,2),100,2);
|
|
$this->orderData['goods_bean_amount'] = bcadd($this->orderData['goods_bean_amount'],$current_goods_bean_amount,2);
|
|
$this->orderData['goods_bean_amount'] = bcadd($this->orderData['goods_bean_amount'],$current_goods_bean_amount,2);
|
|
|
|
|
|
//能让利百分比
|
|
//能让利百分比
|
|
$back_rate = floatval($goods->back_rate) > 0 ? $goods->back_rate : 0;
|
|
$back_rate = floatval($goods->back_rate) > 0 ? $goods->back_rate : 0;
|
|
|
|
|
|
|
|
+ //让利金额
|
|
$current_goods_back_amount = bcdiv(bcmul($current_goods_amount,$back_rate,2),100,2);
|
|
$current_goods_back_amount = bcdiv(bcmul($current_goods_amount,$back_rate,2),100,2);
|
|
$this->orderData['goods_back_amount'] = bcadd($this->orderData['goods_back_amount'],$current_goods_back_amount,2);
|
|
$this->orderData['goods_back_amount'] = bcadd($this->orderData['goods_back_amount'],$current_goods_back_amount,2);
|
|
|
|
|
|
@@ -350,7 +352,7 @@ class OrderCreate
|
|
// 将计算好的属性记录下来,插入订单 item 表使用
|
|
// 将计算好的属性记录下来,插入订单 item 表使用
|
|
$buyInfo['goods_original_amount'] = $current_goods_original_amount; // 当前商品原始总金额(原价 * 数量)
|
|
$buyInfo['goods_original_amount'] = $current_goods_original_amount; // 当前商品原始总金额(原价 * 数量)
|
|
$buyInfo['goods_amount'] = $current_goods_amount; // 当前商品总金额(价格 * 数量)
|
|
$buyInfo['goods_amount'] = $current_goods_amount; // 当前商品总金额(价格 * 数量)
|
|
- $buyInfo['goods_bean_amount'] = $current_goods_bean_amount; // 当前商品可抵扣最高总金额(当前商品总金额 * 比例)
|
|
|
|
|
|
+ $buyInfo['goods_bean_amount'] = $current_goods_bean_amount; // 当前商品善豆可抵扣最高总金额(当前商品总金额 * 比例)
|
|
$buyInfo['goods_back_amount'] = $current_goods_back_amount; // 当前商品让利总金额(当前商品总金额 * 比例)
|
|
$buyInfo['goods_back_amount'] = $current_goods_back_amount; // 当前商品让利总金额(当前商品总金额 * 比例)
|
|
$buyInfo['score_amount'] = $current_score_amount; // 商品所需积分(积分商城)
|
|
$buyInfo['score_amount'] = $current_score_amount; // 商品所需积分(积分商城)
|
|
$buyInfo['weight'] = $current_weight; // 当前商品总重量
|
|
$buyInfo['weight'] = $current_weight; // 当前商品总重量
|
|
@@ -986,9 +988,18 @@ class OrderCreate
|
|
|
|
|
|
//$temp_remain_pay_fee = bcsub($this->orderData['pay_fee'], $this->money, 2);
|
|
//$temp_remain_pay_fee = bcsub($this->orderData['pay_fee'], $this->money, 2);
|
|
|
|
|
|
|
|
+ //输入的善豆不能高于最高可用
|
|
$this->bean = $this->bean > $this->orderData['goods_bean_amount'] ? $this->orderData['goods_bean_amount'] : $this->bean;
|
|
$this->bean = $this->bean > $this->orderData['goods_bean_amount'] ? $this->orderData['goods_bean_amount'] : $this->bean;
|
|
|
|
+
|
|
|
|
+ //最终使用善豆
|
|
|
|
+ $this->orderData['goods_bean_amount'] = $this->bean;
|
|
$temp_remain_pay_fee = bcsub($this->orderData['pay_fee'], $this->bean, 2);
|
|
$temp_remain_pay_fee = bcsub($this->orderData['pay_fee'], $this->bean, 2);
|
|
|
|
|
|
|
|
+ //商品里的善豆也要等比例修改,方便售后退回
|
|
|
|
+ foreach ($this->goodsList as $key => &$buyInfo) {
|
|
|
|
+ $buyInfo['goods_bean_amount'] = bcmul($this->orderData['goods_bean_amount'],bcdiv($buyInfo['goods_amount'],$this->orderData['goods_amount'],4),2);
|
|
|
|
+ }
|
|
|
|
+
|
|
$result = [
|
|
$result = [
|
|
'goods_original_amount' => $this->orderData['goods_original_amount'],
|
|
'goods_original_amount' => $this->orderData['goods_original_amount'],
|
|
'goods_old_amount' => $this->orderData['goods_old_amount'],
|
|
'goods_old_amount' => $this->orderData['goods_old_amount'],
|
|
@@ -1266,7 +1277,9 @@ class OrderCreate
|
|
$orderItem->refund_status = 0;
|
|
$orderItem->refund_status = 0;
|
|
|
|
|
|
$orderItem->back_rate = floatval($goods->back_rate) > 0 ? $goods->back_rate : 0; //让利比例
|
|
$orderItem->back_rate = floatval($goods->back_rate) > 0 ? $goods->back_rate : 0; //让利比例
|
|
- $orderItem->goods_back_amount = $buyInfo['goods_back_amount']; //让利总额
|
|
|
|
|
|
+ $orderItem->goods_back_amount = $buyInfo['goods_back_amount']; //让利额
|
|
|
|
+
|
|
|
|
+ $orderItem->goods_bean_amount = $buyInfo['goods_bean_amount']; //使用善豆额
|
|
|
|
|
|
$orderItem->room_id = $orderData['room_id'];
|
|
$orderItem->room_id = $orderData['room_id'];
|
|
$orderItem->room_log_id = $orderData['room_log_id'];
|
|
$orderItem->room_log_id = $orderData['room_log_id'];
|
|
@@ -1298,7 +1311,7 @@ class OrderCreate
|
|
$orderItem->save();
|
|
$orderItem->save();
|
|
}
|
|
}
|
|
|
|
|
|
- //冗余到bill
|
|
|
|
|
|
+ //商城,下单,冗余到bill表
|
|
$this->createBill($order->id,$orderData,$bill_args);
|
|
$this->createBill($order->id,$orderData,$bill_args);
|
|
|
|
|
|
// 订单创建后
|
|
// 订单创建后
|