|
|
@@ -121,6 +121,10 @@ class StoreOrder extends BaseController
|
|
121
|
121
|
$distribution_mode = $this->request->param('distribution_mode','1');//配送方式
|
|
122
|
122
|
$ziti_address = $this->request->param('distribution_address','');//自提地址
|
|
123
|
123
|
$youhui_price_key = $this->request->param('youhui_price_key','');//优惠key
|
|
|
124
|
+ $cartIdAndPayTypMap = (array)$this->request->param('cartIdAndPayTypMap', []);
|
|
|
125
|
+ if(!$cartIdAndPayTypMap){
|
|
|
126
|
+ return app('json')->fail('支付方式不正确');
|
|
|
127
|
+ }
|
|
124
|
128
|
$uid = $this->request->uid();
|
|
125
|
129
|
$gong = app()->make(ProductAttrValueRepository::class);
|
|
126
|
130
|
|
|
|
@@ -152,26 +156,41 @@ class StoreOrder extends BaseController
|
|
152
|
156
|
|
|
153
|
157
|
$user_group = (int)Db::name('user') -> where('uid',$uid)->value('user_group');
|
|
154
|
158
|
|
|
155
|
|
-
|
|
156
|
|
- $cartIds=Db::name('store_cart')->where('cart_id','in',$cartId)->select()->toArray();
|
|
157
|
|
- $price = $decScore = $decJingScore = 0;
|
|
158
|
|
- foreach ($cartIds as $k=>$item){
|
|
159
|
|
- $checkGong = $gong -> checkGong($item['product_id'],$item['product_attr_unique'],$item['cart_num'],$uid,$addressId);
|
|
|
159
|
+// $cartIdAndPayTypMap = [
|
|
|
160
|
+// 13662 => 'score',
|
|
|
161
|
+// 13663 => 'jingdou',
|
|
|
162
|
+// 13664 => 'jingdou',
|
|
|
163
|
+// ];
|
|
|
164
|
+// $cartId = [
|
|
|
165
|
+// 13662,
|
|
|
166
|
+// 13663,
|
|
|
167
|
+// 13664
|
|
|
168
|
+// ];
|
|
|
169
|
+
|
|
|
170
|
+ // 商品A 后台设置是扣除60积分 或者 扣除120京豆
|
|
|
171
|
+ // 商品B 后台设置是扣除20积分 或者 扣除40京豆
|
|
|
172
|
+ // payType=5 积分支付的时候
|
|
|
173
|
+ //
|
|
|
174
|
+ $cartList=Db::name('store_cart')->where('cart_id','in',$cartId)->select()->toArray();
|
|
|
175
|
+ $price = $decScore = $decJingScore = 0;//总消耗积分和京豆
|
|
|
176
|
+ foreach ($cartList as $cartInfo){
|
|
|
177
|
+ $checkGong = $gong -> checkGong($cartInfo['product_id'],$cartInfo['product_attr_unique'],$cartInfo['cart_num'],$uid,$addressId);
|
|
160
|
178
|
if(isset($checkGong['code']) && $checkGong['code'] == -1) return app('json')->fail($checkGong['message']);
|
|
161
|
|
- $money=Db::name('store_product_attr_value')->where('unique',$item['product_attr_unique'])->value('price');
|
|
162
|
|
- $price += bcmul($money, $item['cart_num'], 2);
|
|
|
179
|
+ $money=Db::name('store_product_attr_value')->where('unique',$cartInfo['product_attr_unique'])->value('price');
|
|
|
180
|
+ $price += bcmul($money, $cartInfo['cart_num'], 2);
|
|
163
|
181
|
|
|
164
|
|
- $storeProduct = Db::name('store_product')->where('product_id', $item['product_id'])->find();
|
|
|
182
|
+ $storeProduct = Db::name('store_product')->where('product_id', $cartInfo['product_id'])->find();
|
|
165
|
183
|
$productDecScore = $storeProduct['score'];
|
|
166
|
184
|
$productDecJingdou = $storeProduct['jingdou'];
|
|
167
|
185
|
|
|
168
|
|
- if ($payType == 5) {
|
|
|
186
|
+ $itemCartId = $cartInfo['cart_id'];
|
|
|
187
|
+ if ($cartIdAndPayTypMap[$itemCartId] == 'score') {
|
|
169
|
188
|
//积分支付的话
|
|
170
|
189
|
if ($productDecScore == 0) {
|
|
171
|
190
|
return app('json')->fail($storeProduct['store_name'] . '必须消耗积分');
|
|
172
|
191
|
}
|
|
173
|
192
|
$decScore += $productDecScore;
|
|
174
|
|
- } else if ($payType == 6) {
|
|
|
193
|
+ } else if ($cartIdAndPayTypMap[$itemCartId] == 'jingdou') {
|
|
175
|
194
|
//京豆支付的话
|
|
176
|
195
|
if ($productDecJingdou == 0) {
|
|
177
|
196
|
return app('json')->fail($storeProduct['store_name'] . '必须消耗京豆');
|
|
|
@@ -182,25 +201,16 @@ class StoreOrder extends BaseController
|
|
182
|
201
|
if (!$decScore && !$decJingScore) {
|
|
183
|
202
|
return app('json')->fail('必须消耗京豆或积分');
|
|
184
|
203
|
}
|
|
185
|
|
- if ($payType == '5') {
|
|
186
|
|
- if (!$decScore) {
|
|
187
|
|
- return app('json')->fail('扣除积分不正确');
|
|
188
|
|
- }
|
|
189
|
|
- //积分兑换
|
|
190
|
|
- $haveScore = Db::name('user')->where('uid', $uid)->value('score');
|
|
191
|
|
- if ($haveScore < $decScore) {
|
|
192
|
|
- return app('json')->fail('积分不足');
|
|
193
|
|
- }
|
|
194
|
|
- } else if ($payType == '6') {
|
|
195
|
|
- if (!$decJingScore) {
|
|
196
|
|
- return app('json')->fail('扣除京豆不正确');
|
|
197
|
|
- }
|
|
198
|
|
- //京豆兑换
|
|
199
|
|
- $haveJingScore = Db::name('user')->where('uid', $uid)->value('jingdou');
|
|
200
|
|
- if ($haveJingScore < $decJingScore) {
|
|
201
|
|
- return app('json')->fail('京豆不足');
|
|
202
|
|
- }
|
|
|
204
|
+ $userInfo = Db::name('user')->where('uid', $uid)->find();
|
|
|
205
|
+ $haveScore = $userInfo['score'];
|
|
|
206
|
+ if ($haveScore < $decScore) {
|
|
|
207
|
+ return app('json')->fail('积分不足');
|
|
203
|
208
|
}
|
|
|
209
|
+ $haveJingScore = $userInfo['jingdou'];
|
|
|
210
|
+ if ($haveJingScore < $decJingScore) {
|
|
|
211
|
+ return app('json')->fail('京豆不足');
|
|
|
212
|
+ }
|
|
|
213
|
+
|
|
204
|
214
|
$cartIds=Db::name('store_cart')->where('cart_id','in',$cartId)->select()->toArray();
|
|
205
|
215
|
// $count=count($cartIds);
|
|
206
|
216
|
$product_id=explode('=',systemConfig('product_ids'));
|