|
@@ -108,6 +108,7 @@ class OrderCreate
|
|
|
'goods_old_amount' => '0',
|
|
|
'goods_amount' => '0',
|
|
|
'goods_bean_amount' => '0',
|
|
|
+ 'goods_back_amount' => '0',
|
|
|
'coupon_discount_fee' => '0',
|
|
|
'promo_discount_fee' => 0,
|
|
|
'total_discount_fee' => 0,
|
|
@@ -322,6 +323,12 @@ class OrderCreate
|
|
|
$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);
|
|
|
|
|
|
+
|
|
|
+ $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);
|
|
|
+ $this->orderData['goods_back_amount'] = bcadd($this->orderData['goods_back_amount'],$current_goods_back_amount,2);
|
|
|
+
|
|
|
|
|
|
$current_goods_old_amount = $current_goods_amount;
|
|
|
if ($this->activity['activity']) {
|
|
@@ -344,6 +351,7 @@ class OrderCreate
|
|
|
$buyInfo['goods_original_amount'] = $current_goods_original_amount;
|
|
|
$buyInfo['goods_amount'] = $current_goods_amount;
|
|
|
$buyInfo['goods_bean_amount'] = $current_goods_bean_amount;
|
|
|
+ $buyInfo['goods_back_amount'] = $current_goods_back_amount;
|
|
|
$buyInfo['score_amount'] = $current_score_amount;
|
|
|
$buyInfo['weight'] = $current_weight;
|
|
|
$buyInfo['original_dispatch_amount'] = 0;
|
|
@@ -987,6 +995,7 @@ class OrderCreate
|
|
|
'goods_amount' => $this->orderData['goods_amount'],
|
|
|
|
|
|
'goods_bean_amount' => $this->orderData['goods_bean_amount'],
|
|
|
+ 'goods_back_amount' => $this->orderData['goods_back_amount'],
|
|
|
'user_bean_amount' => $user_bean,
|
|
|
'min_bean_amount' => config('site.shopro_min_bean_amount'),
|
|
|
|
|
@@ -1130,6 +1139,7 @@ class OrderCreate
|
|
|
$orderData['goods_original_amount'] = $result['goods_original_amount'];
|
|
|
$orderData['goods_amount'] = $result['goods_amount'];
|
|
|
$orderData['goods_bean_amount'] = $result['goods_bean_amount'];
|
|
|
+ $orderData['goods_back_amount'] = $result['goods_back_amount'];
|
|
|
$orderData['dispatch_amount'] = $result['dispatch_amount'];
|
|
|
$orderData['remark'] = $this->remark;
|
|
|
$orderData['order_amount'] = $result['order_amount'];
|
|
@@ -1194,6 +1204,9 @@ class OrderCreate
|
|
|
$order = new Order();
|
|
|
$order->save($orderData);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
if ($result['user_address']) {
|
|
|
$this->createOrderAddress($order, $result);
|
|
@@ -1211,9 +1224,13 @@ class OrderCreate
|
|
|
$result['coupon']->allowField(true)->save();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ $bill_args = [];
|
|
|
+
|
|
|
|
|
|
foreach ($result['goods_list'] as $key => $buyInfo) {
|
|
|
$goods = $buyInfo['goods'];
|
|
|
+
|
|
|
$current_sku_price = $buyInfo['current_sku_price'];
|
|
|
|
|
|
$orderItem = new OrderItem();
|
|
@@ -1248,6 +1265,9 @@ class OrderCreate
|
|
|
$orderItem->comment_status = 0;
|
|
|
$orderItem->refund_status = 0;
|
|
|
|
|
|
+ $orderItem->back_rate = floatval($goods->back_rate) > 0 ? $goods->back_rate : 0;
|
|
|
+ $orderItem->goods_back_amount = $buyInfo['goods_back_amount'];
|
|
|
+
|
|
|
$orderItem->room_id = $orderData['room_id'];
|
|
|
$orderItem->room_log_id = $orderData['room_log_id'];
|
|
|
|
|
@@ -1263,10 +1283,24 @@ class OrderCreate
|
|
|
$ext['is_commission'] = $buyInfo['is_commission'];
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ $bill_args[] = [
|
|
|
+ 'goods_sku_price_id' => $orderItem->goods_sku_price_id,
|
|
|
+ 'goods_title' => $orderItem->goods_title,
|
|
|
+ 'goods_image' => $orderItem->goods_image,
|
|
|
+ 'goods_price' => $orderItem->goods_price,
|
|
|
+ 'goods_num' => $orderItem->goods_num,
|
|
|
+ 'goods_sku_text' => $orderItem->goods_sku_text,
|
|
|
+ 'goods_amount' => $buyInfo['goods_amount'],
|
|
|
+ ];
|
|
|
+
|
|
|
$orderItem->ext = $ext;
|
|
|
$orderItem->save();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ $this->createBill($order->id,$orderData,$bill_args);
|
|
|
+
|
|
|
|
|
|
$hookData = [
|
|
|
'order' => $order,
|
|
@@ -1280,6 +1314,31 @@ class OrderCreate
|
|
|
return $order;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public function createBill($order_id,$orderData,$bill_args){
|
|
|
+
|
|
|
+ $num_sum = array_sum(array_column($bill_args,'goods_num'));
|
|
|
+
|
|
|
+ $bill = [
|
|
|
+ 'user_id' => $orderData['user_id'],
|
|
|
+ 'order_no' => $orderData['order_sn'],
|
|
|
+ 'num' => $num_sum,
|
|
|
+ 'pay_amount' => $orderData['pay_fee'],
|
|
|
+ 'table_id' => $order_id,
|
|
|
+ 'table_name' => 'shopro_order',
|
|
|
+
|
|
|
+ 'shop_name' => '商城',
|
|
|
+ 'shop_logo' => '',
|
|
|
+ 'args' => json_encode($bill_args,JSON_UNESCAPED_UNICODE),
|
|
|
+ 'total_amount' => $orderData['order_amount'],
|
|
|
+
|
|
|
+ 'back_amount' => $orderData['goods_back_amount'],
|
|
|
+ 'createtime' => time(),
|
|
|
+ ];
|
|
|
+
|
|
|
+ Db::name('bill')->insertGetId($bill);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
* 添加收货地址信息
|