|
@@ -121,14 +121,14 @@ class StoreOrder extends BaseController
|
|
121
|
$distribution_mode = $this->request->param('distribution_mode','1');//配送方式
|
121
|
$distribution_mode = $this->request->param('distribution_mode','1');//配送方式
|
|
122
|
$ziti_address = $this->request->param('distribution_address','');//自提地址
|
122
|
$ziti_address = $this->request->param('distribution_address','');//自提地址
|
|
123
|
$youhui_price_key = $this->request->param('youhui_price_key','');//优惠key
|
123
|
$youhui_price_key = $this->request->param('youhui_price_key','');//优惠key
|
|
124
|
- $decScore = $this->request->param('decScore','');//消耗积分值
|
|
|
|
125
|
- $decJingScore = $this->request->param('decJingScore','');//消耗京豆值
|
|
|
|
126
|
$uid = $this->request->uid();
|
124
|
$uid = $this->request->uid();
|
|
127
|
$gong = app()->make(ProductAttrValueRepository::class);
|
125
|
$gong = app()->make(ProductAttrValueRepository::class);
|
|
128
|
|
126
|
|
|
129
|
- \think\facade\Log::info("createOrder params".json_encode(input()));
|
|
|
|
130
|
-// $payType = 6;
|
|
|
|
131
|
-// $decJingScore = 100;
|
|
|
|
|
|
127
|
+ $allParams = input();
|
|
|
|
128
|
+ \think\facade\Log::info("createOrder params".json_encode($allParams));
|
|
|
|
129
|
+
|
|
|
|
130
|
+ $cartId = $allParams['cart_id'];
|
|
|
|
131
|
+ \think\facade\Log::info("createOrder cart_id".json_encode($cartId));
|
|
132
|
|
132
|
|
|
133
|
// Db::name('log')->insert(['data'=>'购物车ID---'.$cartId[0]]);
|
133
|
// Db::name('log')->insert(['data'=>'购物车ID---'.$cartId[0]]);
|
|
134
|
$price=0;
|
134
|
$price=0;
|
|
@@ -149,20 +149,38 @@ class StoreOrder extends BaseController
|
|
149
|
if (!in_array($payType, [5, 6])) {
|
149
|
if (!in_array($payType, [5, 6])) {
|
|
150
|
return app('json')->fail('支付方式不正确');
|
150
|
return app('json')->fail('支付方式不正确');
|
|
151
|
}
|
151
|
}
|
|
152
|
- if (!$decScore && !$decJingScore) {
|
|
|
|
153
|
- return app('json')->fail('必须消耗京豆或积分');
|
|
|
|
154
|
- }
|
|
|
|
155
|
|
152
|
|
|
156
|
$user_group = (int)Db::name('user') -> where('uid',$uid)->value('user_group');
|
153
|
$user_group = (int)Db::name('user') -> where('uid',$uid)->value('user_group');
|
|
157
|
|
154
|
|
|
158
|
|
155
|
|
|
159
|
$cartIds=Db::name('store_cart')->where('cart_id','in',$cartId)->select()->toArray();
|
156
|
$cartIds=Db::name('store_cart')->where('cart_id','in',$cartId)->select()->toArray();
|
|
160
|
- $price = 0;
|
|
|
|
|
|
157
|
+ $price = $decScore = $decJingScore = 0;
|
|
161
|
foreach ($cartIds as $k=>$item){
|
158
|
foreach ($cartIds as $k=>$item){
|
|
162
|
$checkGong = $gong -> checkGong($item['product_id'],$item['product_attr_unique'],$item['cart_num'],$uid,$addressId);
|
159
|
$checkGong = $gong -> checkGong($item['product_id'],$item['product_attr_unique'],$item['cart_num'],$uid,$addressId);
|
|
163
|
if(isset($checkGong['code']) && $checkGong['code'] == -1) return app('json')->fail($checkGong['message']);
|
160
|
if(isset($checkGong['code']) && $checkGong['code'] == -1) return app('json')->fail($checkGong['message']);
|
|
164
|
$money=Db::name('store_product_attr_value')->where('unique',$item['product_attr_unique'])->value('price');
|
161
|
$money=Db::name('store_product_attr_value')->where('unique',$item['product_attr_unique'])->value('price');
|
|
165
|
- $price+=bcmul($money,$item['cart_num'],2);
|
|
|
|
|
|
162
|
+ $price += bcmul($money, $item['cart_num'], 2);
|
|
|
|
163
|
+
|
|
|
|
164
|
+ $storeProduct = Db::name('store_product')->where('product_id', $item['product_id'])->find();
|
|
|
|
165
|
+ $productDecScore = $storeProduct['score'];
|
|
|
|
166
|
+ $productDecJingdou = $storeProduct['jingdou'];
|
|
|
|
167
|
+
|
|
|
|
168
|
+ if ($payType == 5) {
|
|
|
|
169
|
+ //积分支付的话
|
|
|
|
170
|
+ if ($productDecScore == 0) {
|
|
|
|
171
|
+ return app('json')->fail($storeProduct['store_name'] . '必须消耗积分');
|
|
|
|
172
|
+ }
|
|
|
|
173
|
+ $decScore += $productDecScore;
|
|
|
|
174
|
+ } else if ($payType == 6) {
|
|
|
|
175
|
+ //京豆支付的话
|
|
|
|
176
|
+ if ($productDecJingdou == 0) {
|
|
|
|
177
|
+ return app('json')->fail($storeProduct['store_name'] . '必须消耗京豆');
|
|
|
|
178
|
+ }
|
|
|
|
179
|
+ $decJingScore += $productDecJingdou;
|
|
|
|
180
|
+ }
|
|
|
|
181
|
+ }
|
|
|
|
182
|
+ if (!$decScore && !$decJingScore) {
|
|
|
|
183
|
+ return app('json')->fail('必须消耗京豆或积分');
|
|
166
|
}
|
184
|
}
|
|
167
|
if ($payType == '5') {
|
185
|
if ($payType == '5') {
|
|
168
|
if (!$decScore) {
|
186
|
if (!$decScore) {
|