| | |
| | | use app\api\model\plus\coupon\UserCoupon as UserCouponModel; |
| | | use app\api\model\product\Category; |
| | | use app\api\service\consumption\ConsumptionDeductService; |
| | | use app\api\service\points\PointsDeductService; |
| | | use app\common\enum\order\OrderPayTypeEnum; |
| | | use app\common\enum\order\OrderSourceEnum; |
| | | use app\common\enum\order\OrderTypeEnum; |
| | |
| | | $totalConsumptionMoney = 0; |
| | | $totalConsumption = 0; |
| | | $totalProductReduce = 0; |
| | | $settlementPrice=0; |
| | | $this->commonOrderData = $this->getCommonOrderData(); |
| | | // 供应商 |
| | | foreach ($this->supplierData as &$supplier) { |
| | |
| | | // 设置订单商品总金额(不含优惠折扣) |
| | | $this->setOrderTotalPrice($supplier['productList']); |
| | | $orderTotalPrice += $this->orderData['order_total_price']; |
| | | // 设置订单商品总结算金额 |
| | | $this->setOrderSettlementPrice($supplier['productList']); |
| | | $settlementPrice += $this->orderData['settlement_price']; |
| | | // 先计算商品满减 |
| | | $this->setProductReduce($supplier['productList']); |
| | | $totalProductReduce += $this->orderData['product_reduce_money']; |
| | |
| | | $this->commonOrderData = array_merge([ |
| | | 'order_total_num' => $orderTotalNum, // 商品总数量 |
| | | 'order_total_price' => helper::number2($orderTotalPrice), // 商品总价 |
| | | 'settlement_price' => helper::number2($settlementPrice), // 商品总结算价 |
| | | 'order_pay_price' => helper::number2($orderPayPrice), // 商品总价,最终支付 |
| | | 'coupon_list' => $couponList, |
| | | 'coupon_id_sys' => $coupon_id, |
| | |
| | | // 订单商品的总金额(不含优惠券折扣) |
| | | $this->orderData['order_total_price'] = helper::number2(helper::getArrayColumnSum($productList, 'total_price')); |
| | | } |
| | | /** |
| | | * 设置订单的商品总结算金额(不含优惠折扣) |
| | | */ |
| | | private function setOrderSettlementPrice($productList) |
| | | { |
| | | // 订单商品的总金额(不含优惠券折扣) |
| | | $this->orderData['settlement_price'] = helper::number2(helper::getArrayColumnSum($productList, 'total_settlement_price')); |
| | | } |
| | | |
| | | /** |
| | | * 当前用户可用的优惠券列表 |
| | |
| | | if ($this->orderData['is_allow_points'] && $this->commonOrderData['is_use_points'] && !$this->settledRule['force_points']) { |
| | | $value = helper::bcsub($value, $product['points_money']); |
| | | } |
| | | // 减去积分抵扣金额 |
| | | // 减去消费券抵扣金额 |
| | | if ($this->orderData['is_allow_consumption'] && $this->commonOrderData['is_use_consumption'] && !$this->settledRule['force_points']) { |
| | | $value = helper::bcsub($value, $product['consumption_money']); |
| | | } |
| | |
| | | 'user_id' => $this->user['user_id'], |
| | | 'order_no' => $this->model->orderNo(), |
| | | 'total_price' => $order['order_total_price'], |
| | | 'settlement_price' => $order['settlement_price'], |
| | | 'order_price' => $order['order_price'], |
| | | 'coupon_id' => $supplier['orderData']['coupon_id'], |
| | | 'coupon_money' => $supplier['orderData']['coupon_money'], |
| | |
| | | 'product_no' => $product['product_sku']['product_no'], |
| | | 'product_price' => $product['product_sku']['product_price'], |
| | | 'line_price' => $product['product_sku']['line_price'], |
| | | 'settlement_price' => $product['product_sku']['settlement_price'], |
| | | 'product_weight' => $product['product_sku']['product_weight'], |
| | | 'is_user_grade' => (int)$product['is_user_grade'], |
| | | 'grade_ratio' => $product['grade_ratio'], |
| | |
| | | 'consumption_bonus' => isset($product['consumption_bonus'])?$product['consumption_bonus']:0, |
| | | 'total_num' => $product['total_num'], |
| | | 'total_price' => $product['total_price'], |
| | | 'total_settlement_price' => $product['total_settlement_price'], |
| | | 'total_pay_price' => $product['total_pay_price'], |
| | | 'supplier_money' => $product['supplier_money'], |
| | | 'is_agent' => $product['is_agent'], |
| | |
| | | return false; |
| | | } |
| | | // 计算订单商品实际抵扣的积分数量和金额 |
| | | $ProductDeduct = new ConsumptionDeductService($productList); |
| | | $ProductDeduct = new PointsDeductService($productList); |
| | | $ProductDeduct->setProductPoints($maxPointsNumCount, $actualPointsNum); |
| | | // 积分抵扣总金额 |
| | | $orderPointsMoney = helper::getArrayColumnSum($productList, 'points_money'); |
| | |
| | | $product['max_points_num'] = $product['points_num']; |
| | | } else { |
| | | // 商品不允许积分抵扣 |
| | | if (!$product['is_points_discount']) continue; |
| | | if (!$product['is_points_discount']||$product['is_vip']||$product['is_newcomer']||$product['is_repurchase']) continue; |
| | | // 积分抵扣比例 |
| | | $deductionRatio = helper::bcdiv($setting['discount']['max_money_ratio'], 100); |
| | | // 最多可抵扣的金额 |