10 İşlemeler cfbb0b97f6 ... d8d0ad6a02

Yazar SHA1 Mesaj Tarih
  hehao d8d0ad6a02 Merge remote-tracking branch 'origin/master' 1 yıl önce
  hehao 3bdcd33d79 fix 1 yıl önce
  hehao bccba4d938 fix 1 yıl önce
  hehao b56cf4e85f fix 1 yıl önce
  hehao 19c7df5649 fix 1 yıl önce
  hehao b191214597 fix 1 yıl önce
  hehao 7b8977e046 fix 1 yıl önce
  hehao eb47f7938e 忽略文件 1 yıl önce
  hehao c3d8c00941 让他能注册 1 yıl önce
  hehao 6e2cf2800e 下单预扣积分/京豆,取消订单返还,支付成功修改状态 1 yıl önce

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
1
+public/
2
+.idea/
3
+.env

+ 58 - 0
app/common/repositories/store/order/StoreGroupOrderRepository.php

@@ -159,8 +159,66 @@ class StoreGroupOrderRepository extends BaseRepository
159 159
                 // 取消订单时 删除限制合伙人商品代理限制
160 160
                 $key ='area_manage_order:'.$order['area_manage_address_ids'];
161 161
                 $redis->del($key);
162
+
163
+                //取消订单,返还京豆和积分
164
+                $orderId = $order->order_id;
165
+                $userSignScoreInfo = Db::name('user_sign_score')->where('order_id', $orderId)->where('status',-1)->where('order_type','store_order')->find();
166
+                if($userSignScoreInfo){
167
+                    $userDecScore = $userSignScoreInfo['reward_socre'];
168
+                    Db::name('user_sign_score')
169
+                        ->where('id', $userSignScoreInfo['id'])
170
+                        ->update([
171
+                            'status' => 0,
172
+                        ]);
173
+
174
+                    //返还扣除积分
175
+                    $user = Db::name('user')->where('uid', $uid)->find();
176
+                    $userScore = $user['score'];
177
+                    $ins_data['uid'] = $uid;
178
+                    $ins_data['reward_socre'] = $userDecScore;
179
+                    $ins_data['addtime'] = time();
180
+                    $ins_data['status'] = 1;//京豆状态1-有效 0-失效 -1待确认 创建的时候-1待确认 取消订单返还积分变为0 支付成功变为1
181
+                    $ins_data['order_type'] = 'cancel_order';
182
+                    $ins_data['order_id'] = $orderId;
183
+                    $ins_data['mark'] = "取消订单返还预扣积分";
184
+                    $ins_data['desc'] = '取消订单返还预扣积分';
185
+                    $ins_data['surplus'] = $userScore + $userDecScore;
186
+                    $ins_data['type'] = 4;//没用
187
+                    $ins_data['pm'] = 1;
188
+                    Db::name('user_sign_score')->insertGetId($ins_data);
189
+                    Db::name('user')->where('uid', $uid)->inc('score', $userDecScore)->update();
190
+                }
191
+
192
+                $userSignJingdouInfo = Db::name('user_sign_jingdou')->where('order_id', $orderId)->where('status',-1)->where('order_type','store_order')->find();
193
+                if($userSignJingdouInfo){
194
+                    $userDecJingScore = $userSignJingdouInfo['number'];
195
+                    Db::name('user_sign_jingdou')
196
+                        ->where('id',$userSignJingdouInfo['id'])
197
+                        ->update([
198
+                            'status' => 0,
199
+                        ]);
200
+
201
+                    //返还扣除京豆
202
+                    $user = Db::name('user')->where('uid', $uid)->find();
203
+                    $userJingdou = $user['jingdou'];
204
+                    $ins_data['uid'] = $uid;
205
+                    $ins_data['number'] = $userDecJingScore;
206
+                    $ins_data['status'] = 1;
207
+                    $ins_data['mark'] = "取消订单返还预扣京豆";
208
+                    $ins_data['desc'] = "取消订单返还预扣京豆";
209
+                    $ins_data['order_id'] = $orderId;
210
+                    $ins_data['surplus'] = $userJingdou + $userDecJingScore;
211
+                    $ins_data['order_type'] = 'cancel_order';
212
+                    $ins_data['type'] = 1;
213
+                    $ins_data['addtime'] = time();
214
+                    Db::name('user_sign_jingdou')
215
+                        ->insertGetId($ins_data);
216
+                    Db::name('user')->where('uid', $uid)->inc('jingdou', $userDecJingScore)->update();
217
+                }
218
+
162 219
             }
163 220
             $groupOrder->save();
221
+
164 222
             app()->make(StoreOrderStatusRepository::class)->insertAll($orderStatus);
165 223
 
166 224
         });

+ 82 - 10
app/common/repositories/store/order/StoreOrderRepository.php

@@ -117,7 +117,7 @@ class StoreOrderRepository extends BaseRepository
117 117
      * @author xaboy
118 118
      * @day 2020/8/1
119 119
      */
120
-    public function createOrder(User $user, int $pay_type, array $cartId, int $addressId, array $coupons, array $takes, array $mark, bool $psType = true, $table_id = null, $share_id = 0, $payType, $mer_id = 0, $dacang_id = 0, $distribution_mode = 1, $ziti_address = '', $area_manage_address_ids = '',$youhui_price_key='')
120
+    public function createOrder(User $user, int $pay_type, array $cartId, int $addressId, array $coupons, array $takes, array $mark, bool $psType = true, $table_id = null, $share_id = 0, $payType, $mer_id = 0, $dacang_id = 0, $distribution_mode = 1, $ziti_address = '', $area_manage_address_ids = '',$youhui_price_key='',$cartIdAndPayTypMap)
121 121
     {
122 122
         $test_user = $user['test_user'] ?? 0;
123 123
         $address = Db::name('user_address')->field('code_list,village_id')->where('address_id', $addressId)->find();
@@ -129,7 +129,7 @@ class StoreOrderRepository extends BaseRepository
129 129
             $share_uid = Db::name('product_share')->where('id',$share_id)->value('uid');
130 130
             Log::info("商品分享,uid:".$user->uid.",share_uid:".$share_uid." cartId:".json_encode($cartId));
131 131
         }
132
-        if ($payType == 5) {
132
+        if (false) {
133 133
             $uid = $user->uid;
134 134
             $couponUserRepository = app()->make(StoreCouponUserRepository::class);
135 135
             foreach ($coupons as $merId => $coupon) {
@@ -371,7 +371,7 @@ class StoreOrderRepository extends BaseRepository
371 371
             $productRepository = app()->make(ProductRepository::class);
372 372
             $storeOrderProductRepository = app()->make(StoreOrderProductRepository::class);
373 373
 
374
-            $group = Db::transaction(function () use ($topUid, $spreadUid, $uid, $productCouponList, $storeCouponList, $allUseCoupon, $couponUserRepository, $storeOrderProductRepository, $productRepository, $attrValueRepository, $storeCartRepository, $storeGroupOrderRepository, $groupOrder, $orderList, $orderInfo, $totalPayPrice) {
374
+            $group = Db::transaction(function () use ($topUid, $spreadUid, $uid, $productCouponList, $storeCouponList, $allUseCoupon, $couponUserRepository, $storeOrderProductRepository, $productRepository, $attrValueRepository, $storeCartRepository, $storeGroupOrderRepository, $groupOrder, $orderList, $orderInfo, $totalPayPrice, $decScore) {
375 375
                 $cartIds = [];
376 376
                 $uniqueList = [];
377 377
                 //更新库存
@@ -474,21 +474,20 @@ class StoreOrderRepository extends BaseRepository
474 474
                     }
475 475
                     //更新用户积分
476 476
                     $user = Db::name('user')->where('uid', $uid)->find();
477
-                    $deduct_score = $totalPayPrice * 30;
478 477
                     $user_score = $user['score'];
479 478
                     $ins_data['uid'] = $uid;
480
-                    $ins_data['reward_socre'] = $deduct_score;
479
+                    $ins_data['reward_socre'] = $decScore;
481 480
                     $ins_data['addtime'] = time();
482
-                    $ins_data['status'] = 1;
481
+                    $ins_data['status'] = -1;//京豆状态1-有效 0-失效 -1待确认 创建的时候-1待确认 取消订单返还积分变为0 支付成功变为1
483 482
                     $ins_data['order_type'] = 'store_order';
484 483
                     $ins_data['order_id'] = $_order->order_id;
485
-                    $ins_data['mark'] = "兑换商品扣积分";
484
+                    $ins_data['mark'] = "兑换商品扣积分";
486 485
                     $ins_data['desc'] = '';
487
-                    $ins_data['surplus'] = $user_score - $deduct_score;
486
+                    $ins_data['surplus'] = $user_score - $decScore;
488 487
                     $ins_data['type'] = 4;
489 488
                     $ins_data['pm'] = 2;
490 489
                     Db::name('user_sign_score')->insertGetId($ins_data);
491
-                    Db::name('user')->where('uid', $uid)->dec('score', $deduct_score)->update();
490
+                    Db::name('user')->where('uid', $uid)->dec('score', $decScore)->update();
492 491
                 }
493 492
                 $storeOrderStatusRepository->insertAll($orderStatus);
494 493
                 $storeOrderProductRepository->insertAll($orderProduct);
@@ -785,7 +784,7 @@ class StoreOrderRepository extends BaseRepository
785 784
             $productRepository = app()->make(ProductRepository::class);
786 785
             $storeOrderProductRepository = app()->make(StoreOrderProductRepository::class);
787 786
 
788
-            $group = Db::transaction(function () use ($topUid, $spreadUid, $uid, $productCouponList, $storeCouponList, $allUseCoupon, $couponUserRepository, $storeOrderProductRepository, $productRepository, $attrValueRepository, $storeCartRepository, $storeGroupOrderRepository, $groupOrder, $orderList, $orderInfo) {
787
+            $group = Db::transaction(function () use ($topUid, $spreadUid, $uid, $productCouponList, $storeCouponList, $allUseCoupon, $couponUserRepository, $storeOrderProductRepository, $productRepository, $attrValueRepository, $storeCartRepository, $storeGroupOrderRepository, $groupOrder, $orderList, $orderInfo ,$cartIdAndPayTypMap) {
789 788
                 $cartIds = [];
790 789
                 $uniqueList = [];
791 790
                 //更新库存
@@ -828,6 +827,8 @@ class StoreOrderRepository extends BaseRepository
828 827
                     $_orderInfo = $order['orderInfo'];
829 828
                     unset($order['cartInfo'], $order['orderInfo']);
830 829
                     $_order = $this->dao->create($order);
830
+
831
+                    $decScore = $decJingScore = 0;
831 832
                     foreach ($cartInfo as $k => $cart) {
832 833
 //                        $is_dacang=Db::name('da_cang_user')->where('status',1)->where('uid',$uid)->find();
833 834
 //                        $is_dacang_product = Db::name('store_product')->where('product_id',$cart['product_id'])->field('type,seckill')->find();
@@ -893,8 +894,57 @@ class StoreOrderRepository extends BaseRepository
893 894
                                 'product_type' => $cart['product_type']
894 895
                             ])
895 896
                         ];
897
+
898
+                        $cartId = $cart['cart_id'];
899
+                        $storeProduct = Db::name('store_product')->where('product_id', $cartInfo['product_id'])->find();
900
+                        $productDecScore = $storeProduct['score'];
901
+                        $productDecJingdou = $storeProduct['jingdou'];
902
+                        if ($cartIdAndPayTypMap[$cartId] == 'score') {
903
+                            $decScore += $productDecScore;
904
+                        } else if ($cartIdAndPayTypMap[$cartId] == 'jingdou') {
905
+                            $decJingScore += $productDecJingdou;
906
+                        }
907
+                    }
908
+
909
+
910
+                    if ($decScore) {
911
+                        $decScore = $productDecScore;
912
+                        //更新用户积分
913
+                        $user = Db::name('user')->where('uid', $uid)->find();
914
+                        $user_score = $user['score'];
915
+                        $ins_data['uid'] = $uid;
916
+                        $ins_data['reward_socre'] = $decScore;
917
+                        $ins_data['addtime'] = time();
918
+                        $ins_data['status'] = -1;//京豆状态1-有效 0-失效 -1待确认 创建的时候-1待确认 取消订单返还积分变为0 支付成功变为1
919
+                        $ins_data['order_type'] = 'store_order';
920
+                        $ins_data['order_id'] = $_order->order_id;
921
+                        $ins_data['mark'] = "兑换商品预扣积分";
922
+                        $ins_data['desc'] = '';
923
+                        $ins_data['surplus'] = $user_score - $decScore;
924
+                        $ins_data['type'] = 4;
925
+                        $ins_data['pm'] = 2;
926
+                        Db::name('user_sign_score')->insertGetId($ins_data);
927
+                        Db::name('user')->where('uid', $uid)->dec('score', $decScore)->update();
928
+                    }
929
+                    if ($decJingScore) {
930
+                        //更新用户京豆
931
+                        $user = Db::name('user')->where('uid', $uid)->find();
932
+                        $userJingdou = $user['jingdou'];
933
+                        $ins_data['uid'] = $uid;
934
+                        $ins_data['number'] = $decJingScore;
935
+                        $ins_data['status'] = -1;//京豆状态1-有效 0-失效 -1待确认 创建的时候-1待确认 取消订单返还积分变为0 支付成功变为1
936
+                        $ins_data['mark'] = "购买商品预扣京豆";
937
+                        $ins_data['desc'] = "购买商品预扣京豆";
938
+                        $ins_data['order_id'] = $_order->order_id;
939
+                        $ins_data['surplus'] = $userJingdou - $decJingScore;
940
+                        $ins_data['order_type'] = 'store_order';
941
+                        $ins_data['type'] = 2;
942
+                        $ins_data['addtime'] = time();
943
+                        Db::name('user_sign_jingdou')->insertGetId($ins_data);
944
+                        Db::name('user')->where('uid', $uid)->dec('jingdou', $decJingScore)->update();
896 945
                     }
897 946
                 }
947
+
898 948
                 $storeOrderStatusRepository->insertAll($orderStatus);
899 949
                 $storeOrderProductRepository->insertAll($orderProduct);
900 950
                 return $groupOrder;
@@ -1197,6 +1247,28 @@ class StoreOrderRepository extends BaseRepository
1197 1247
                                 ]);
1198 1248
                         }
1199 1249
                     }
1250
+
1251
+
1252
+                    //支付成功 修改账单状态为1
1253
+                    $orderId = $order->order_id;
1254
+                    $userSignScoreInfo = Db::name('user_sign_score')->where('order_id', $orderId)->where('status',-1)->where('order_type','store_order')->find();
1255
+                    if($userSignScoreInfo){
1256
+                        Db::name('user_sign_score')
1257
+                            ->where('id', $userSignScoreInfo['id'])
1258
+                            ->update([
1259
+                                'status' => 1,
1260
+                            ]);
1261
+                    }
1262
+
1263
+                    $userSignJingdouInfo = Db::name('user_sign_jingdou')->where('order_id', $orderId)->where('status',-1)->where('order_type','store_order')->find();
1264
+                    if($userSignJingdouInfo){
1265
+                        Db::name('user_sign_jingdou')
1266
+                            ->where('id',$userSignJingdouInfo['id'])
1267
+                            ->update([
1268
+                                'status' => 1,
1269
+                            ]);
1270
+                    }
1271
+
1200 1272
                 }
1201 1273
 
1202 1274
                 app()->make(UserRepository::class)->update($groupOrder->uid, [

Dosya farkı çok büyük olduğundan ihmal edildi
+ 12 - 11
app/controller/api/Auth.php


+ 3 - 3
app/controller/api/merchant/sxy/Access.php

@@ -682,8 +682,8 @@ class Access
682 682
 
683 683
     public function test1111()
684 684
     {
685
-        $domain = $this->request->domain();
686
-        if(strpos($domain, 'test.hebeiyhc.com') !== false){
685
+//        $domain = $this->request->domain();
686
+//        if(strpos($domain, 'test.hebeiyhc.com') !== false){
687 687
             $requestId[0]=input('order_sn');
688 688
 //        $pay_type=5;
689 689
             Db::name('store_group_order') -> where('group_order_sn',$requestId[0]) -> update(['rand'=>mt_rand(1000,9999)]);
@@ -695,7 +695,7 @@ class Access
695 695
 //        event('pay_success_order', ['order_sn' => $requestId[0],'pay_type'=>$pay_type]);
696 696
             dump('成功');
697 697
 //        dump($this->randomFromDev(20));
698
-        }
698
+//        }
699 699
     }
700 700
 
701 701
 

+ 143 - 159
app/controller/api/store/order/StoreOrder.php

@@ -12,6 +12,7 @@ namespace app\controller\api\store\order;
12 12
 
13 13
 
14 14
 use app\common\model\store\order\StoreRefundOrder;
15
+use app\common\model\system\admin\Log;
15 16
 use app\common\repositories\merchant\MerchantRepository;
16 17
 use app\common\repositories\store\product\ProductAttrValueRepository;
17 18
 use app\common\repositories\user\UserAddressRepository;
@@ -110,7 +111,7 @@ class StoreOrder extends BaseController
110 111
         $coupon = (array)$this->request->param('coupon', []);
111 112
         $take = (array)$this->request->param('take', []);
112 113
         $mark = (array)$this->request->param('mark', []);
113
-        $payType = $this->request->param('pay_type');
114
+        $payType = $this->request->param('pay_type');// 5积分 6京豆
114 115
         $share_id = $this->request->param('share_id','');//分享id
115 116
         $mer_id = $this->request->param('mer_id','');//分享id
116 117
         $psType = $this->request->param('type',true);//是否需要地址Boolean
@@ -120,8 +121,20 @@ class StoreOrder extends BaseController
120 121
         $distribution_mode = $this->request->param('distribution_mode','1');//配送方式
121 122
         $ziti_address = $this->request->param('distribution_address','');//自提地址
122 123
         $youhui_price_key = $this->request->param('youhui_price_key','');//优惠key
124
+        $cartIdAndPayTypMap = (array)$this->request->param('cartIdAndPayTypMap', []);
125
+
126
+        if(!$cartIdAndPayTypMap){
127
+            return app('json')->fail('支付方式不正确');
128
+        }
123 129
         $uid = $this->request->uid();
124 130
         $gong = app()->make(ProductAttrValueRepository::class);
131
+
132
+        $allParams = input();
133
+        \think\facade\Log::info("createOrder params".json_encode($allParams));
134
+
135
+        $cartId = $allParams['cart_id'];
136
+        \think\facade\Log::info("createOrder cart_id".json_encode($cartId));
137
+
125 138
 //        Db::name('log')->insert(['data'=>'购物车ID---'.$cartId[0]]);
126 139
         $price=0;
127 140
 //        if (!in_array($payType, StoreOrderRepository::PAY_TYPE))
@@ -132,102 +145,73 @@ class StoreOrder extends BaseController
132 145
         $special_merchant = merchantConfig($product_mer_id, 'special_merchant');
133 146
         $member_settings=merchantConfig($product_mer_id, 'member_settings');
134 147
 
135
-        return app('json')->fail('正在升级');
136 148
         // 增加锁,防止同一用户重读点击
137 149
         $redis = Cache::store('redis')->handler();
138 150
         $key = 'createOrder'.$uid;
139 151
         if (!$redis->setnx($key, 1))
140 152
             return app('json')->fail('请勿重复下单');
141 153
         $redis->expire($key, 3);
154
+        if (!in_array($payType, [5, 6])) {
155
+            return app('json')->fail('支付方式不正确');
156
+        }
142 157
 
143 158
         $user_group = (int)Db::name('user') -> where('uid',$uid)->value('user_group');
144
-        if($payType=='5'){
145
-            //$product_mer_id!=148&&$product_mer_id!==290&&
146
-
147 159
 
148
-            if(empty($mer_id) || ($product_mer_id!=148 && $special_merchant != "beishengtang")) {
149
-                return app('json')->fail('此商户/商品不支持积分支付');
150
-            }
151
-
152
-//            Db::name('log')->insert(['data'=>'购物车ID'.json_encode($cartId)]);
153
-            $cartIds=Db::name('store_cart')->where('cart_id','in',$cartId)->select()->toArray();
154
-
155
-//            Db::name('log')->insert(['data'=>'购物车数据'.json_encode($cartIds)]);
156
-            foreach ($cartIds as $k=>$item){
157
-                $checkGong = $gong -> checkGong($item['product_id'],$item['product_attr_unique'],$item['cart_num'],$uid,$addressId);
158
-                if(isset($checkGong['code']) && $checkGong['code'] == -1) return app('json')->fail($checkGong['message']);
159
-                $money=Db::name('store_product_attr_value')->where('unique',$item['product_attr_unique'])->value('price');
160
-                $price+=bcmul($money,$item['cart_num'],2);
161
-            }
162
-//            $have_money=Db::name('entropy_barter_user_'.$mer_id)->where('uid',$uid)->value('integral');
163
-            if ($special_merchant == "beishengtang"){
164
-                $have_money = Db::name('user') -> where('uid',$uid) -> value('score_beishengtang');
165
-                if($have_money<$price){
166
-                    return app('json')->fail('积分不足无法支付');
167
-                }
168
-            }else{
169
-
170
-                $have_money = Db::name('user') -> where('uid',$uid) -> value('score');
171
-                if($have_money<$price*30){
172
-                    return app('json')->fail('积分不足无法支付');
160
+//        $cartIdAndPayTypMap = [
161
+//            13662 => 'score',
162
+//            13663 => 'jingdou',
163
+//            13664 => 'jingdou',
164
+//        ];
165
+//        $cartId = [
166
+//            13662, 订单1
167
+//            13663, 订单1
168
+//            13664  订单2
169
+//        ];
170
+
171
+        // 商品A 后台设置是扣除60积分 或者 扣除120京豆
172
+        // 商品B 后台设置是扣除20积分 或者 扣除40京豆
173
+        // payType=5 积分支付的时候
174
+        //
175
+        $cartList=Db::name('store_cart')->where('cart_id','in',$cartId)->select()->toArray();
176
+        $price = $decScore = $decJingScore =  0;//总消耗积分和京豆
177
+        foreach ($cartList as $cartInfo){
178
+            $checkGong = $gong -> checkGong($cartInfo['product_id'],$cartInfo['product_attr_unique'],$cartInfo['cart_num'],$uid,$addressId);
179
+            if(isset($checkGong['code']) && $checkGong['code'] == -1) return app('json')->fail($checkGong['message']);
180
+            $money=Db::name('store_product_attr_value')->where('unique',$cartInfo['product_attr_unique'])->value('price');
181
+            $price += bcmul($money, $cartInfo['cart_num'], 2);
182
+
183
+            $storeProduct = Db::name('store_product')->where('product_id', $cartInfo['product_id'])->find();
184
+            $productDecScore = $storeProduct['score'];
185
+            $productDecJingdou = $storeProduct['jingdou'];
186
+
187
+            $itemCartId = $cartInfo['cart_id'];
188
+            if ($cartIdAndPayTypMap[$itemCartId] == 'score') {
189
+                //积分支付的话
190
+                if ($productDecScore == 0) {
191
+                    return app('json')->fail($storeProduct['store_name'] . '必须消耗积分');
173 192
                 }
174
-            }
175
-
176
-
177
-        }else if($payType==6){
178
-            //一壶茶红积分兑换
179
-            $cartIds=Db::name('store_cart')->where('cart_id','in',$cartId)->select()->toArray();
180
-            $red_jifen=0;
181
-            foreach ($cartIds as $k=>$item){
182
-                $s_type = Db::name('store_product') -> where('product_id', $item['product_id']) -> value('type');
183
-                if($s_type!=17){
184
-                    return app('json')->fail('只有会员商品才能使用积分');
193
+                $decScore += $productDecScore;
194
+            } else if ($cartIdAndPayTypMap[$itemCartId] == 'jingdou') {
195
+                //京豆支付的话
196
+                if ($productDecJingdou == 0) {
197
+                    return app('json')->fail($storeProduct['store_name'] . '必须消耗京豆');
185 198
                 }
186
-
187
-                $checkGong = $gong -> checkGong($item['product_id'],$item['product_attr_unique'],$item['cart_num'],$uid,$addressId);
188
-                if(isset($checkGong['code']) && $checkGong['code'] == -1) return app('json')->fail($checkGong['message']);
189
-                $money=Db::name('store_product_attr_value')->where('unique',$item['product_attr_unique'])->value('price');
190
-                $red_jifen+=bcmul($money,$item['cart_num'],2);
191
-            }
192
-            $red_jifen=ceil($red_jifen);
193
-
194
-            $enterprise_user_data = Db::name('enterprise_user') -> where('uid',$uid)-> where('mer_id',$this->merId) ->find();
195
-            $green_integral = $enterprise_user_data['green_integral'];
196
-            if(!$green_integral || $green_integral < $red_jifen){
197
-                return app('json')->fail('用户红积分不足,请刷新后再试');
198
-            }
199
-            if($enterprise_user_data['identity'] < 100){
200
-                return app('json')->fail('需要您升级为合伙人');
201
-            }
202
-
203
-
204
-            $exchange_phone = $this->request->param('phone','');
205
-            if(!$exchange_phone || !preg_match("/^1[3456789]{1}\d{9}$/", $exchange_phone)){
206
-                return app('json')->fail('请正确输入开通账号');
199
+                $decJingScore += $productDecJingdou;
207 200
             }
208
-            $ex_user=Db::name('user')->where('account',$exchange_phone)->find();
209
-            if(!$ex_user){
210
-                $userRepository = app()->make(UserRepository::class);
211
-                $ex_user = $userRepository->registr($exchange_phone,'123456','APP',$uid);
212
-                Db::name('user')->where('uid',$ex_user['uid'])->update(['spread_uid'=>$uid,'spread_time'=>date('Y-m-d H:i:s')]);
213
-            }
214
-            $enterprise_user_ex_user=Db::name('enterprise_user')->where('uid',$ex_user['uid'])-> where('mer_id',$this->merId)->find();
215
-            if(!$enterprise_user_ex_user){
216
-                $inset['uid']=$ex_user['uid'];
217
-                $inset['mer_id']=$this->merId;
218
-                $inset['puid']=$uid;
219
-                $inset['node_uid']=$uid;
220
-                Db::name('enterprise_user')->insert($inset);
221
-                $enterprise_user_ex_user['identity']=0;
222
-            }else if($enterprise_user_ex_user['node_uid']!=$uid){
223
-                return app('json')->fail('红积分只能用于本人和直推用户使用');
224
-            }
225
-            if($enterprise_user_ex_user && in_array($enterprise_user_ex_user['identity'],[100,101,102,103,104,105])){
226
-                return app('json')->fail('此用户已经是合伙人');
227
-            }
228
-
229
-
230 201
         }
202
+        if (!$decScore && !$decJingScore) {
203
+            return app('json')->fail('必须消耗京豆或积分');
204
+        }
205
+        $userInfo = Db::name('user')->where('uid', $uid)->find();
206
+        $haveScore = $userInfo['score'];
207
+        if ($haveScore < $decScore) {
208
+            return app('json')->fail('积分不足');
209
+        }
210
+        $haveJingScore = $userInfo['jingdou'];
211
+        if ($haveJingScore < $decJingScore) {
212
+            return app('json')->fail('京豆不足');
213
+        }
214
+
231 215
         $cartIds=Db::name('store_cart')->where('cart_id','in',$cartId)->select()->toArray();
232 216
 //        $count=count($cartIds);
233 217
         $product_id=explode('=',systemConfig('product_ids'));
@@ -431,7 +415,7 @@ class StoreOrder extends BaseController
431 415
 
432 416
         makeLock()->lock();
433 417
         try {
434
-            $groupOrder = $this->repository->createOrder($this->request->userInfo(), array_search($payType, StoreOrderRepository::PAY_TYPE), $cartId, $addressId, $coupon, $take, $mark,$psType,$table_id,$share_id,$payType,$mer_id,$dacang_id,$distribution_mode,$ziti_address,$area_manage_address_ids,$youhui_price_key);
418
+            $groupOrder = $this->repository->createOrder($this->request->userInfo(), array_search($payType, StoreOrderRepository::PAY_TYPE), $cartId, $addressId, $coupon, $take, $mark,$psType,$table_id,$share_id,$payType,$mer_id,$dacang_id,$distribution_mode,$ziti_address,$area_manage_address_ids,$youhui_price_key,$cartIdAndPayTypMap);
435 419
         } catch (\Throwable $e) {
436 420
             makeLock()->unlock();
437 421
             throw $e;
@@ -442,19 +426,19 @@ class StoreOrder extends BaseController
442 426
         //删除缓存的优惠价格
443 427
         Cache::delete($uid.'_youhui_price_'.$product_type_id);
444 428
 
445
-        if($payType==5){
446
-
447
-
448
-            $this->repository->integralPaySuccess($groupOrder,5);
449
-            //积分商品
450
-            $order_id=Db::name('store_order')->where('group_order_id',$groupOrder['group_order_id'])->value('order_id');
451
-
452
-            $userRepository = app()->make(UserRepository::class);
453
-            if ($special_merchant == "beishengtang"){
454
-                $userRepository -> sign_add($uid,$price,1,'积分消费','','',$order_id,2,"store_order_beishengtang");
455
-            }else{
456
-                $userRepository -> sign_add($uid,$price*30,1,'积分消费','','',$order_id,2,'store_order');
457
-            }
429
+//        if($payType==5){
430
+//
431
+//
432
+//            $this->repository->integralPaySuccess($groupOrder,5);
433
+//            //积分商品
434
+//            $order_id=Db::name('store_order')->where('group_order_id',$groupOrder['group_order_id'])->value('order_id');
435
+//
436
+//            $userRepository = app()->make(UserRepository::class);
437
+//            if ($special_merchant == "beishengtang"){
438
+//                $userRepository -> sign_add($uid,$price,1,'积分消费','','',$order_id,2,"store_order_beishengtang");
439
+//            }else{
440
+//                $userRepository -> sign_add($uid,$price*30,1,'积分消费','','',$order_id,2,'store_order');
441
+//            }
458 442
 
459 443
 
460 444
 //            Db::name('user') -> where('uid',$uid) -> dec('score', $price*30)->update();
@@ -496,67 +480,67 @@ class StoreOrder extends BaseController
496 480
 //            Db::name('entropy_barter_bill')->insert($insert);
497 481
             return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);
498 482
 //
499
-        }else if($payType==6){
500
-            //积分商品
501
-            $userRepository = app()->make(UserRepository::class);
502
-            $order_id=Db::name('store_order')->where('group_order_id',$groupOrder['group_order_id'])->value('order_id');
503
-            $hongjifen_kou=$userRepository -> sign_yhc_add($uid,$this->merId,$red_jifen,'兑换合伙人商品('.$ex_user['nickname'].')',$order_id,2,$ex_user['uid']);
504
-            if(!$hongjifen_kou){
505
-                return app('json')->fail('用户红积分不足,请刷新后再试');
506
-            }
507
-
508
-
509
-            Db::name('store_order')->where('group_order_id',$groupOrder['group_order_id'])->update(['exchange_phone'=>$exchange_phone]);
510
-
511
-            $this->repository->integralPaySuccess($groupOrder,5);
512
-
513
-
514
-            $enterprise_user=Db::name('enterprise_user')->where('uid',$ex_user['uid'])-> where('mer_id',$this->merId)->find();
515
-            if($enterprise_user && $enterprise_user['identity']<100){ //不是合伙人就升级为合伙人
516
-                Db::name('enterprise_user')->where('uid',$enterprise_user['uid'])->where('mer_id',$enterprise_user['mer_id'])->update(['identity'=>100,'exchange'=>100]);
517
-            }
518
-
519
-
520
-
521
-            $order=Db::name('store_order')->where('order_id',$order_id)->find();
522
-            $store_order_product =Db::name('store_order_product')->where('order_id',$order_id)->where('type',17)->find();
523
-            $cart_info=json_decode($store_order_product['cart_info'],true);
524
-            $pay_price =$order['pay_price'];
525
-            $unique=isset($cart_info['productAttr']['unique'])?$cart_info['productAttr']['unique']:'';
526
-            $product_id=isset($cart_info['product']['product_id'])?$cart_info['product']['product_id']:'';
527
-            if($unique){
528
-                $store_product_attr_value=Db::name('store_product_attr_value')->where('unique',$unique)->find();
529
-            }
530
-            if($product_id && isset($store_product_attr_value)){
531
-                $product_data=Db::name('store_product')->where('product_id',$product_id)->find();
532
-                if($product_data && $product_data['pension_is']==1 && isset($store_product_attr_value['pension_num']) ){
533
-                    $member_settings['ylj']=$store_product_attr_value['pension_num'];//养老金比例单独设置
534
-                }
535
-
536
-                Db::name('enterprise_user')->where('uid',$enterprise_user['uid'])->inc('stock_right',$store_product_attr_value['stock_num'])->inc('stock_num',$store_product_attr_value['shares_num'])->update();
537
-
538
-            }
539
-
540
-
541
-            $user_yanglaojin=decimal2($member_settings['ylj']/100*$pay_price);//养老金 一壶茶会员商户从2后台设置比例
542
-
543
-
544
-
545
-
546
-
547
-
548
-            $StoreOrderRepository = app()->make(StoreOrderRepository::class);
549
-
550
-
551
-
552
-            if($user_yanglaojin>=0.01) {
553
-                $order_sn=Db::name('store_order')->where('group_order_id',$groupOrder['group_order_id'])->value('order_sn');
554
-                $StoreOrderRepository->add_bill_gongfu("养老金", $user_yanglaojin, $enterprise_user['uid'], "商城消费获得养老金" . $user_yanglaojin, 5, $order_sn, $order_id, $enterprise_user['mer_id'], 0, 0);
555
-            }
556
-
557
-
558
-            return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);
559
-        }
483
+//        }else if($payType==6){
484
+//            //积分商品
485
+//            $userRepository = app()->make(UserRepository::class);
486
+//            $order_id=Db::name('store_order')->where('group_order_id',$groupOrder['group_order_id'])->value('order_id');
487
+//            $hongjifen_kou=$userRepository -> sign_yhc_add($uid,$this->merId,$red_jifen,'兑换合伙人商品('.$ex_user['nickname'].')',$order_id,2,$ex_user['uid']);
488
+//            if(!$hongjifen_kou){
489
+//                return app('json')->fail('用户红积分不足,请刷新后再试');
490
+//            }
491
+//
492
+//
493
+//            Db::name('store_order')->where('group_order_id',$groupOrder['group_order_id'])->update(['exchange_phone'=>$exchange_phone]);
494
+//
495
+//            $this->repository->integralPaySuccess($groupOrder,5);
496
+//
497
+//
498
+//            $enterprise_user=Db::name('enterprise_user')->where('uid',$ex_user['uid'])-> where('mer_id',$this->merId)->find();
499
+//            if($enterprise_user && $enterprise_user['identity']<100){ //不是合伙人就升级为合伙人
500
+//                Db::name('enterprise_user')->where('uid',$enterprise_user['uid'])->where('mer_id',$enterprise_user['mer_id'])->update(['identity'=>100,'exchange'=>100]);
501
+//            }
502
+//
503
+//
504
+//
505
+//            $order=Db::name('store_order')->where('order_id',$order_id)->find();
506
+//            $store_order_product =Db::name('store_order_product')->where('order_id',$order_id)->where('type',17)->find();
507
+//            $cart_info=json_decode($store_order_product['cart_info'],true);
508
+//            $pay_price =$order['pay_price'];
509
+//            $unique=isset($cart_info['productAttr']['unique'])?$cart_info['productAttr']['unique']:'';
510
+//            $product_id=isset($cart_info['product']['product_id'])?$cart_info['product']['product_id']:'';
511
+//            if($unique){
512
+//                $store_product_attr_value=Db::name('store_product_attr_value')->where('unique',$unique)->find();
513
+//            }
514
+//            if($product_id && isset($store_product_attr_value)){
515
+//                $product_data=Db::name('store_product')->where('product_id',$product_id)->find();
516
+//                if($product_data && $product_data['pension_is']==1 && isset($store_product_attr_value['pension_num']) ){
517
+//                    $member_settings['ylj']=$store_product_attr_value['pension_num'];//养老金比例单独设置
518
+//                }
519
+//
520
+//                Db::name('enterprise_user')->where('uid',$enterprise_user['uid'])->inc('stock_right',$store_product_attr_value['stock_num'])->inc('stock_num',$store_product_attr_value['shares_num'])->update();
521
+//
522
+//            }
523
+//
524
+//
525
+//            $user_yanglaojin=decimal2($member_settings['ylj']/100*$pay_price);//养老金 一壶茶会员商户从2后台设置比例
526
+//
527
+//
528
+//
529
+//
530
+//
531
+//
532
+//            $StoreOrderRepository = app()->make(StoreOrderRepository::class);
533
+//
534
+//
535
+//
536
+//            if($user_yanglaojin>=0.01) {
537
+//                $order_sn=Db::name('store_order')->where('group_order_id',$groupOrder['group_order_id'])->value('order_sn');
538
+//                $StoreOrderRepository->add_bill_gongfu("养老金", $user_yanglaojin, $enterprise_user['uid'], "商城消费获得养老金" . $user_yanglaojin, 5, $order_sn, $order_id, $enterprise_user['mer_id'], 0, 0);
539
+//            }
540
+//
541
+//
542
+//            return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);
543
+//        }
560 544
         if ($groupOrder['pay_price'] == 0) {
561 545
             $this->repository->paySuccess($groupOrder);
562 546
             return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);