Преглед изворни кода

Merge branch 'master' into huangfamily

family пре 1 година
родитељ
комит
ee04d0b007

+ 47 - 49
app/common/repositories/merchant/order/OrderMerchantRepository.php

@@ -836,65 +836,63 @@ class OrderMerchantRepository extends BaseRepository
836 836
         $unionUser = $unionUsersRepository->getWhere(['unionid' => $order->pay_user_id]);
837 837
         $userOfflineRechargeRepository = app()->make(UserOfflineRechargeRepository::class);
838 838
         if ($user) {
839
-//            $order->binds = 1;
840
-//            $order->uid = $user->uid;
841
-//            $order->save();
842 839
             Db::name('order_merchant')->where('id', $order->id)->update(['binds' => 1, 'uid' => $user->uid]);
843 840
             //锁定商户
844 841
             if (!$user->mer_id || !$user->locktime) {
845
-                // $user->mer_id = $order->mer_id;
846
-                // $user->save();
842
+                //锁住
847 843
                 Db::name('user')->where('uid', $user->uid)->update(['mer_id' => $order->mer_id, 'locktime' => date('Y-m-d H:i:s')]);
848 844
 
849
-                $mer_fanyongbili = merchantConfig($order->mer_id, 'base_commission');
850
-                //如果商户返佣比例设置的是0怎查系统设设置的分佣比例
851
-                if ($mer_fanyongbili == 0) {
852
-                    $mer_fanyongbili = merchantConfig(0, 'extension_one_rate');
853
-                }
854
-                //如果系统设置的是0就不执行!
855
-                if ($mer_fanyongbili == 0) {
856
-                    Db::name('log')->insert(['data' => '订单号:' . $order->order_sn . ' 订单因商家、平台没有设置返佣比例无任何奖励特此记录!']);
857
-                    return '';
858
-                }
859
-                $order_sn = $order->order_sn ?? '';
860
-                $order_id = $order->order_id ?? '';
861
-                //可分总佣金
862
-                $divisible_commission = bcmul($order->money, bcdiv($mer_fanyongbili, '100', 2), 2);//让利部分
863
-                $pv = bcmul($divisible_commission, '0.7', 2);//商家让利部分30%给消费者做养老金,70%做业绩PV
864
-
865
-                //商户锁客收益:PV的5%==14元X5%=0.7元 (加入到用户佣金,可以从用户佣金中提现,商户显示锁客收益总额)
845
+                //获取锁客商户的uid
866 846
                 $mer_data = Db::name('merchant')->where('mer_id', $order->mer_id)->field('uid,mer_id')->find();
867 847
                 $merchant_user = $userRepository->getOne(['uid' => $mer_data["uid"]]);
868 848
 
869
-                $suo_commission = bcmul($pv, '0.5', 2);
870
-                if ($suo_commission >= 0.01) {
871
-                    $mark = "用户获得商户锁客收益" . $suo_commission . '佣金';
872
-                    $title = "佣金";
873
-                    $source = 1;
874
-                    $commission_type = 3;
875
-                    $this->add_bill($title, $suo_commission, $merchant_user->uid, $mark, $commission_type, $order_sn, $order_id, $order->mer_id, $source, 1);
876
-                } else {
877
-                    Db::name('log')->insert(['data' => '订单号:' . $order->order_sn . '付款额度较低或 商家、平台设置的返佣比例较低,佣金低于0.01无法入库 特此记录!']);
849
+                //跨店锁客分发
850
+                $orders = OrderMerchant::getDB()->where('pay_user_id', $unionUser->unionid)->where('status', 1) ->whereNotIn('mer_id', [$order->mer_id])->where('binds',0)->select();
851
+                foreach ($orders as $kd_order) {
852
+                    $pv = Db::name('user_sign_gongxian')->where('mer_id', $kd_order->mer_id)->where('order_id', $kd_order->id)->value('pv');//拿到原来的pv值记录
853
+                    //商户锁客收益:PV的5%==14元X5%=0.7元 (加入到用户佣金,可以从用户佣金中提现,商户显示锁客收益总额)
854
+                    $suo_commission = bcmul($pv, '0.5', 2);
855
+                    if ($suo_commission >= 0.01 && $pv) {
856
+                        $mark = "用户获得商户锁客跨店收益" . $suo_commission . '佣金';
857
+                        $title = "商户跨店佣金";
858
+                        $source = 1;
859
+                        $commission_type = 3;
860
+                        $this->add_bill($title, $suo_commission, $merchant_user->uid, $mark, $commission_type, $kd_order->order_sn, $kd_order->id, $kd_order->mer_id, $source, 1);
861
+                    } else {
862
+                        Db::name('log')->insert(['data' => '订单号:' . $kd_order->order_sn . '付款额度较低或 商家、平台设置的返佣比例较低,商户锁客跨店佣金低于0.01无法入库 特此记录!']);
863
+                    }
878 864
                 }
879
-        
880
-
881
-    
882
-
883
-                // $mer_uid = Db::name('merchant')->where('mer_id', $order->mer_id)->value('uid');
884
-                //商户每锁定一个顾客获得300积分
885
-                // $userRepository->sign_add($mer_uid, systemConfig('mer_score'), 1, '到店锁定一个顾客赠送积分', '', '', $order->id,1,'order_merchant');
886
-//                Db::name('user')->where('uid',$mer_uid)->inc('score', systemConfig('mer_score'))->update();
887
-//                $ins_data['uid'] = $mer_uid;
888
-//                $ins_data['reward_socre'] = systemConfig('mer_score');
889
-//                $ins_data['addtime'] = time();
890
-//                $ins_data['status'] = 1;
891
-//                $ins_data['order_id'] = $order->id;
892
-//                $ins_data['mark'] = '到店锁定一个顾客赠送积分';
893
-//                Db::name('user_sign_score')->insert($ins_data);
894
-
895 865
 
896
-                //环信im处理
897
-//                $this->hxim($user->uid,$order->mer_id);
866
+                // $mer_fanyongbili = merchantConfig($order->mer_id, 'base_commission');
867
+                // //如果商户返佣比例设置的是0怎查系统设设置的分佣比例
868
+                // if ($mer_fanyongbili == 0) {
869
+                //     $mer_fanyongbili = merchantConfig(0, 'extension_one_rate');
870
+                // }
871
+                // //如果系统设置的是0就不执行!
872
+                // if ($mer_fanyongbili == 0) {
873
+                //     Db::name('log')->insert(['data' => '订单号:' . $order->order_sn . ' 订单因商家、平台没有设置返佣比例无任何奖励特此记录!']);
874
+                //     return '';
875
+                // }
876
+                // $order_sn = $order->order_sn ?? '';
877
+                // $order_id = $order->order_id ?? '';
878
+                // //可分总佣金
879
+                // $divisible_commission = bcmul($order->money, bcdiv($mer_fanyongbili, '100', 2), 2);//让利部分
880
+                // $pv = bcmul($divisible_commission, '0.7', 2);//商家让利部分30%给消费者做养老金,70%做业绩PV
881
+
882
+                // //商户锁客收益:PV的5%==14元X5%=0.7元 (加入到用户佣金,可以从用户佣金中提现,商户显示锁客收益总额)
883
+                // $mer_data = Db::name('merchant')->where('mer_id', $order->mer_id)->field('uid,mer_id')->find();
884
+                // $merchant_user = $userRepository->getOne(['uid' => $mer_data["uid"]]);
885
+
886
+                // $suo_commission = bcmul($pv, '0.5', 2);
887
+                // if ($suo_commission >= 0.01) {
888
+                //     $mark = "用户获得商户锁客跨店收益" . $suo_commission . '佣金';
889
+                //     $title = "商户跨店佣金";
890
+                //     $source = 1;
891
+                //     $commission_type = 3;
892
+                //     $this->add_bill($title, $suo_commission, $merchant_user->uid, $mark, $commission_type, $order_sn, $order_id, $order->mer_id, $source, 1);
893
+                // } else {
894
+                //     Db::name('log')->insert(['data' => '订单号:' . $order->order_sn . '付款额度较低或 商家、平台设置的返佣比例较低,佣金低于0.01无法入库 特此记录!']);
895
+                // }
898 896
             }
899 897
 
900 898
             $userOfflineRechargeRepository->paySuccess($order->id, $order->out_trade_no, $user->uid, $order->mer_id, $order->money, $order->give_money, $order->pension, $order->available, $order->pay_user_id);

+ 11 - 16
app/common/repositories/store/product/ProductAttrValueRepository.php

@@ -113,32 +113,29 @@ class ProductAttrValueRepository extends BaseRepository
113 113
             $address_id = explode(',',$address_code_list);
114 114
             log::info($address_id);
115 115
             $address_id = end($address_id);
116
-//            $address_id = $address_id[0];
117 116
         }
118 117
         $sku = [[
119 118
             'sku_id'=>$sku_id,
120 119
             'num'=>$num
121 120
         ]];
122 121
         //查询商品是否有货
123
-        $stock = GongApiRequest::stock($sku_id,$address_id,$num);
124
-        if($stock != '有货'){
125
-            Db::name('store_product')->where('product_id',$product_id)->update(['is_show' => 0, 'argument' => '此商品无货']);
126
-            if($delivery){
127
-                return false;
128
-            }else{
129
-                return ['code'=>-1,'message'=>'此商品无货'];
130
-//                throw new AuthException('此商品无货');
131
-            }
132
-        }
122
+        // $stock = GongApiRequest::stock($sku_id,$address_id,$num);
123
+        // if($stock != '有货'){
124
+        //     // Db::name('store_product')->where('product_id',$product_id)->update(['is_show' => 0, 'argument' => '此商品无货']);
125
+        //     if($delivery){
126
+        //         return false;
127
+        //     }else{
128
+        //         return ['code'=>-1,'message'=>'此商品无货'];
129
+        //     }
130
+        // }
133 131
         //查询商品上下架
134 132
         $goods_status = GongApiRequest::goods_status($spu_id);
135
-        if(!isset($goods_status[0]['status']) || $goods_status[0]['status'] != 1){
133
+        if(!isset($goods_status['status']) || $goods_status['status'] != 1){
136 134
             Db::name('store_product')->where('product_id',$product_id)->update(['is_show' => 0, 'argument' => '此商品已下架'.json_encode($goods_status)]);
137 135
             if($delivery){
138 136
                 return false;
139 137
             }else{
140 138
                 return ['code'=>-1,'message'=>'此商品已下架'];
141
-//                throw new AuthException('此商品已下架');
142 139
             }
143 140
         }
144 141
         //查询库存
@@ -149,7 +146,6 @@ class ProductAttrValueRepository extends BaseRepository
149 146
                 return false;
150 147
             }else {
151 148
                 return ['code'=>-1,'message'=>'此商品规格无货'];
152
-//                throw new AuthException('此商品规格无货');
153 149
             }
154 150
         }
155 151
         //查询运费
@@ -158,8 +154,7 @@ class ProductAttrValueRepository extends BaseRepository
158 154
             if($delivery){
159 155
                 return false;
160 156
             }else {
161
-                return ['code'=>-1,'message'=>'此商品下架'];
162
-//                throw new AuthException('此商品下架');
157
+                return ['code'=>-1,'message'=>'此商品不支持该地区'];
163 158
             }
164 159
         }
165 160
         return true;

+ 10 - 3
app/common/repositories/user/UserOfflineRechargeRepository.php

@@ -177,7 +177,7 @@ class UserOfflineRechargeRepository extends BaseRepository
177 177
 
178 178
 
179 179
                     //同步后返佣
180
-                    $userRepository = app()->make(OrderMerchantRepository::class);
180
+                    $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
181 181
                     $order_data = [
182 182
                         'order_sn' => $order->out_trade_no,
183 183
                         'order_id' => $order->id,
@@ -186,8 +186,15 @@ class UserOfflineRechargeRepository extends BaseRepository
186 186
                         'mer_id' => $order->mer_id
187 187
                     ];
188 188
                     $user = Db::name('user')->where('uid', $unionUser->uid)->find();
189
-                    $userRepository->feidacang_fenyong($user, $order_data, 0);
190
-                    $userRepository->feidacang_fenyong_mer($user, $order_data, 0);
189
+                    $OrderMerchantRepository->feidacang_fenyong($user, $order_data, 0);
190
+                    $OrderMerchantRepository->feidacang_fenyong_mer($user, $order_data, 0);
191
+
192
+                    //锁客
193
+                    $flag = 1;
194
+                    $order = (object)$order;
195
+                    $userRepository = app()->make(UserRepository::class);
196
+                    $user = $userRepository->getOne(['uid' => $unionUser->uid]);
197
+                    $userRepository->doBind($user, $order, $flag);
191 198
 
192 199
                     OrderMerchant::getDB()->where('pay_user_id', $unionUser->unionid)->update(['uid' => $unionUser->uid, 'binds' => 1]);
193 200
                 }

+ 2 - 2
app/controller/admin/gong/Goods.php

@@ -319,7 +319,7 @@ class Goods extends BaseController
319 319
                     'stock'=>100,
320 320
                     'cost_price'=>$v['cost_price'],
321 321
                     'extension_one'=>5,
322
-                    'gong_sku_id'=>$v['sku_sn'],
322
+                    'gong_sku_id'=>$v['sku_id'],
323 323
                     'gong_mer_profit' => $v['profit'],
324 324
                     'gong_pension' => $v['yanglaojin'],
325 325
                     'gong_market_price' => $v['market_price'],
@@ -356,7 +356,7 @@ class Goods extends BaseController
356 356
                     'stock'=>100,
357 357
                     'cost_price'=>$v['cost_price'],
358 358
                     'extension_one'=>5,
359
-                    'gong_sku_id'=>$v['sku_sn'],
359
+                    'gong_sku_id'=>$v['sku_id'],
360 360
                     'gong_mer_profit' => $v['profit'],
361 361
                     'gong_pension' => $v['yanglaojin'],
362 362
                     'gong_market_price' => $v['market_price'],

+ 4 - 4
app/controller/merchant/gong/Goods.php

@@ -315,11 +315,11 @@ class Goods extends BaseController
315 315
                     'cost'=>$v['cost_price'],
316 316
                     'ot_price'=>$v['retail_price'],
317 317
                     'price'=>$v['market_price'],
318
-                    'unique'=>$ProductRepository->setUnique($id,$v['sku_sn'],0),
318
+                    'unique'=>$ProductRepository->setUnique($id,$v['sku_id'],0),
319 319
                     'stock'=>100,
320 320
                     'cost_price'=>$v['cost_price'],
321 321
                     'extension_one'=>5,
322
-                    'gong_sku_id'=>$v['sku_sn'],
322
+                    'gong_sku_id'=>$v['sku_id'],
323 323
                     'gong_mer_profit' => $v['profit'],
324 324
                     'gong_pension' => $v['yanglaojin'],
325 325
                     'gong_market_price' => $v['market_price'],
@@ -352,11 +352,11 @@ class Goods extends BaseController
352 352
                     'cost'=>$v['cost_price'],
353 353
                     'ot_price'=>$v['retail_price'],
354 354
                     'price'=>$v['market_price'],
355
-                    'unique'=>$ProductRepository->setUnique($id,$v['sku_sn'],0),
355
+                    'unique'=>$ProductRepository->setUnique($id,$v['sku_id'],0),
356 356
                     'stock'=>100,
357 357
                     'cost_price'=>$v['cost_price'],
358 358
                     'extension_one'=>5,
359
-                    'gong_sku_id'=>$v['sku_sn'],
359
+                    'gong_sku_id'=>$v['sku_id'],
360 360
                     'gong_mer_profit' => $v['profit'],
361 361
                     'gong_pension' => $v['yanglaojin'],
362 362
                     'gong_market_price' => $v['market_price'],

+ 6 - 3
app/traits/GongApiRequest.php

@@ -198,19 +198,22 @@ trait GongApiRequest
198 198
     }
199 199
 
200 200
     /**
201
-     * 查询商品上下架(未更改)
201
+     * 查询商品上下架
202 202
      * @param string $spu_id 商品spu_id
203 203
      * @return array|boolean
204 204
      * @author lin
205 205
      * @created 2022年5月19日11:46:54
206 206
      * */
207 207
     public static function goods_status($spu_id){
208
-        $url = '/api/goods/status';
208
+        $url = '/api_v2/Goods/getGoodsDetail';
209 209
         $body = [
210 210
             'access_token' => self::access_token(),
211
-            'spu_id' => $spu_id
211
+            'goods_id' => $spu_id,
212 212
         ];
213 213
         $res = self::curl_post(self::$path.$url,$body);
214
+        if ($res['error_code'] == 2001) {
215
+            return $res;
216
+        }
214 217
         if($res['error_code'] == 0){
215 218
             return $res['result'];
216 219
         }