Explorar o código

1113更新,商品采集,会员的3355制

conner hai 1 ano
pai
achega
bde5a57780

+ 17 - 10
app/common/repositories/user/UserRepository.php

@@ -941,15 +941,15 @@ class UserRepository extends BaseRepository
941 941
      * @author xaboy
942 942
      * @day 2020-04-28
943 943
      */
944
-    public function create(string $type, array $userInfo, $url=0)
944
+    public function create(string $type, array $userInfo, $url=0,$spread_uid=null)
945 945
     {
946 946
         $userInfo['user_type'] = $type;
947 947
         Db::startTrans();
948 948
         try {
949 949
 
950 950
 
951
-            $user = $this->dao->create($userInfo);
952
-//            $this -> insterUser($user->uid, $url);
951
+            $user = $this->dao->create($userInfo); //创建用户
952
+            $this -> insterUser($user->uid, $spread_uid);
953 953
             //唯品会pid
954 954
 //            $vip = app()->make(Vip::class);
955 955
 //            $vip->create_pid($user->uid);
@@ -965,6 +965,7 @@ class UserRepository extends BaseRepository
965 965
             Db::commit();
966 966
             return $user;
967 967
         } catch (\Exception $e) {
968
+            Log::info($userInfo);
968 969
             Db::rollback();
969 970
             log::info("注册失败".$e->getFile().':'.$e->getLine().'【'.$e->getMessage().'】');
970 971
             throw new AuthException('注册失败');
@@ -998,22 +999,26 @@ class UserRepository extends BaseRepository
998 999
 
999 1000
 
1000 1001
         }
1002
+        // Log::info("userCount:::");
1003
+        // Log::info($userCount);
1004
+        // Log::info($spread_uid);
1005
+
1001 1006
         Db::name('log')->insert(['data'=>'uid:'.$uid.'公排注册:'.json_encode($userCount)]);
1002 1007
         if (!$userCount){
1003 1008
             //没有直推上级 大公排
1004
-//            $userCount = Db::name('user_count') -> where('level_number >= 0') -> find();
1009
+            $userCount = Db::name('user_count') -> where('level_number >= 0') -> find();
1005 1010
             //增加一个只查询新账户大公排下的用户
1006
-            $userCount = Db::name('user_count') -> where('level_number >= 0')->whereIn('uid',$this->getUserLevelId(11112)) -> find();
1011
+            // $userCount = Db::name('user_count') -> where('level_number >= 0')->whereIn('uid',$this->getUserLevelId(11112)) -> find();
1007 1012
         }
1008 1013
         if ($userCount) {
1009
-            if ($userCount['level_number'] + 1 == 5) {
1014
+            if ($userCount['level_number'] + 1 == systemConfig( 'max_level_number')) {  //(33制或者55制)下级最大人数systemConfig( 'max_level_number')
1010 1015
                 Db::name('user_count') -> where('uid',$userCount['uid'])->delete();
1011 1016
             } else {
1012 1017
                 $level_number = $userCount['level_number'] + 1;
1013 1018
                 Db::name('user_count') -> where('uid',$userCount['uid']) -> update(['level_number'=>$level_number]);
1014 1019
             }
1015 1020
         }
1016
-
1021
+        // dd($spread_uid);
1017 1022
         Db::name('user') -> where('uid',$uid)->update(['level_id'=>$userCount['uid'],'level'=>$this->level()]);
1018 1023
         Db::name('user_count') -> insert(['uid'=>$uid]);
1019 1024
     }
@@ -1174,7 +1179,8 @@ class UserRepository extends BaseRepository
1174 1179
         return $key;
1175 1180
     }
1176 1181
 
1177
-    public function registr(string $phone, ?string $pwd, $user_type = 'h5',$url="",$nickname="",$external=1)
1182
+    //$repository->registr($data['phone'], $data['password'],'APP',"","",$data['spread']);
1183
+    public function registr(string $phone, ?string $pwd, $user_type = 'h5',$url="",$nickname="",$external=1,$spread_uid=null)
1178 1184
     {
1179 1185
 
1180 1186
         $pwd = $pwd ? $this->encodePassword($pwd) : $this->encodePassword($this->dao->defaultPwd());
@@ -1186,9 +1192,10 @@ class UserRepository extends BaseRepository
1186 1192
             'phone' => $phone,
1187 1193
             'last_ip' => app('request')->ip(),
1188 1194
             "identity"=>5,
1189
-            "external"=>$external
1195
+            "external"=>$external,
1196
+            "spread_uid"=>$spread_uid
1190 1197
         ];
1191
-        return $this->create($user_type, $data, $url);
1198
+        return $this->create($user_type, $data, $url,$spread_uid);
1192 1199
     }
1193 1200
     public function addregistr($data)
1194 1201
     {

+ 1 - 1
app/controller/admin/user/User.php

@@ -1281,7 +1281,7 @@ class User extends BaseController
1281 1281
             if($v['b'] && $v['b']!=null && $v['b']!=''){
1282 1282
                 $pid=Db::name('user')->where('account',$v['b'])->value('uid');
1283 1283
                 if($pid){
1284
-                    $repository->bindSpread($user, intval($pid));
1284
+                    $repository->bindSpread($user, intval($pid)); //绑定上下级关系
1285 1285
                     $spread_uid=$pid;
1286 1286
                 }
1287 1287
             }

+ 7 - 2
app/controller/api/Auth.php

@@ -479,6 +479,10 @@ echo '导入成功';
479 479
      */
480 480
     public function register(UserAuthValidate $validate, UserRepository $repository)
481 481
     {
482
+
483
+        // $repository->insterUser(16328, 14395);
484
+
485
+        // return "=====";
482 486
         $data = $this->request->params(['phone', 'sms_code', 'spread', 'password',"spread_phone","type","mer_id"]);
483 487
         $type=$data['type']??'';
484 488
         unset($data['type']);
@@ -502,8 +506,9 @@ echo '导入成功';
502 506
                 return app('json')->fail('推荐人手机号填写错误');
503 507
             }
504 508
         }
505
-
506
-        $user = $repository->registr($data['phone'], $data['password'],'APP',$data['spread']);
509
+        // Log::info($data);
510
+        $user = $repository->registr($data['phone'], $data['password'],'APP',"","",1,$data['spread']);
511
+        // $repository->registr($data['phone'], $data['password'],'APP',$data['spread']);
507 512
         $repository->addagent($user);
508 513
         $user = $repository->mainUser($user);
509 514
 

+ 3 - 3
app/controller/api/store/product/Douyin.php

@@ -76,9 +76,9 @@ class Douyin extends BaseController
76 76
 
77 77
 
78 78
                     // $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
79
-                    if ($yanglaojin < 0.1) {
80
-                        continue;
81
-                    }
79
+                    // if ($yanglaojin < 0.1) {
80
+                    //     continue;
81
+                    // }
82 82
                     Log::info($value);
83 83
                     // $yanglaojin = bcmul($yanglaojin, 0.8, 2);
84 84
                     $goods = [

+ 40 - 11
app/controller/api/store/product/Jt.php

@@ -67,12 +67,41 @@ class Jt extends BaseController
67 67
         if ($type == 1){
68 68
             $limit = 100;
69 69
         }
70
-        $list = Db::name('third_party_goods')
71
-            -> where('type',2)
72
-            -> page($page,$limit)
73
-            -> field('json')
74
-            -> select()
75
-            -> toArray();
70
+
71
+        $keyword = request()->param('keyword', '');
72
+        $_cid = request()->param('cid', '');
73
+
74
+        [$page, $limit] = $this->getPage();
75
+        
76
+
77
+        $goods_obj = Db::name('third_party_goods')
78
+        -> where('type',2);
79
+        // -> when(!empty($keyword),function($query) use ($keyword) {
80
+        //     $query -> where('json',"like",'%'.$keyword.'%');
81
+        // })
82
+        // -> page($page,$limit)
83
+        // -> field('json')
84
+        // -> select()
85
+        // -> toArray();
86
+    
87
+        if($keyword){
88
+            $goods_obj=$goods_obj->where('json', 'like', '%' . $keyword . '%');
89
+        }
90
+        if($_cid){
91
+            $goods_obj=$goods_obj->where('cid', $_cid);
92
+        }
93
+        $list=$goods_obj->page($page, $limit)
94
+            ->select()->toArray();
95
+
96
+
97
+
98
+
99
+        // $list = Db::name('third_party_goods')
100
+        //     -> where('type',2)
101
+        //     -> page($page,$limit)
102
+        //     -> field('json')
103
+        //     -> select()
104
+        //     -> toArray();
76 105
         $formatList = [];
77 106
         foreach ($list as $value){
78 107
             $json = json_decode($value['json'],true);
@@ -233,12 +262,12 @@ class Jt extends BaseController
233 262
             $commissionMoney = sprintf('%.2f', ($finalPrice * $commissionRate / 100)); // 商品最终价格 * 京推推商品佣金比率 /100 =最终佣金
234 263
 
235 264
             $pv=$commissionMoney* 0.5;  //PV
236
-            $oldMoney=$pv*0.05; //新的养老金
265
+            $yanglaojin=$pv*0.05; //新的养老金
237 266
 
238 267
             
239 268
             //养老金
240 269
             // $oldMoney = app()->make(ProductRepository::class)->yanglaojin(0, $commissionMoney);
241
-            if ($oldMoney < 0.1) continue;
270
+            // if ($yanglaojin < 0.1) continue;
242 271
             $couponMoney = [
243 272
                 [
244 273
                     'discount' => $value['discount_price'],//优惠券金额
@@ -259,7 +288,7 @@ class Jt extends BaseController
259 288
                 'yanglaojin'=>$yanglaojin,
260 289
 
261 290
 
262
-                'commission' => $oldMoney,//养老金
291
+                'commission' => $yanglaojin,//养老金
263 292
                 'commission_rate' => $commissionRate,
264 293
                 // 'sales' => $value['inOrderCount30Days'],
265 294
                 'coupon_money' => $couponMoney,//优惠券相关信息
@@ -291,9 +320,9 @@ class Jt extends BaseController
291 320
 
292 321
             Db::name("third_party_goods") -> insert([
293 322
                 'json'=>json_encode($formatList,JSON_UNESCAPED_UNICODE),
294
-                'pension'=>$oldMoney,
323
+                'pension'=>$yanglaojin,
295 324
                 'type'=>2,                
296
-                'cid'=>cid //一级分类
325
+                'cid'=>$cid //一级分类
297 326
             ]);  //20250110 增加cid字段,json中增加 shopName,monthSales by Conner
298 327
         }
299 328
 //        return $formatList;

+ 6 - 6
app/controller/api/store/product/Su.php

@@ -169,13 +169,13 @@ class Su extends BaseController
169 169
                     // $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $goods['commodityInfo']['commodityPrice'] * $goods['commodityInfo']['rate'] / 100 ?? '');
170 170
                     
171 171
                     $commission=$goods['commodityInfo']['commodityPrice'] * $goods['commodityInfo']['rate'] / 100; //佣金
172
-                    $pv=$commission* 0.5;  //PV
173
-                    $yanglaojin=$pv*0.05; //新的养老金
172
+                    $pv=round($commission* 0.5,2);  //PV
173
+                    $yanglaojin=round($pv*0.05,2); //新的养老金
174 174
 
175 175
 
176
-                    if($yanglaojin < 0.1) {
177
-                        continue;
178
-                    }
176
+                    // if($yanglaojin < 0.1) {
177
+                    //     continue;
178
+                    // }
179 179
 
180 180
                     //记录分类id到本地数据库
181 181
                     $cid=$goods['categoryInfo']['firstSaleCategoryId'];
@@ -195,7 +195,7 @@ class Su extends BaseController
195 195
                         'yanglaojin' => $yanglaojin,//养老金
196 196
 
197 197
 
198
-                        'commission' => $yanglaojin,//养老
198
+                        'commission' => $commission,//佣
199 199
 
200 200
                         'commission_rate' => $goods['commodityInfo']['rate'] ?? '',//佣金比例
201 201
                         'sales' => $goods['commodityInfo']["monthSales"],

+ 63 - 38
app/controller/api/store/product/TaoKe.php

@@ -175,6 +175,7 @@ class TaoKe extends BaseController
175 175
             return app('json')->success('未查询到商品', []);
176 176
         }
177 177
 
178
+        Log::info($params);
178 179
 
179 180
         $apiName = 'pdd.ddk.goods.search';
180 181
         $result = $this->getUrlResult($apiName, $params);
@@ -182,7 +183,13 @@ class TaoKe extends BaseController
182 183
         if (!$goodsResult) {
183 184
             return app('json')->success('未查询到商品', []);
184 185
         }
186
+
187
+
188
+
185 189
         $goodsList = [];
190
+
191
+        // Log::info($goodsResult);
192
+        
186 193
         foreach ($goodsResult as $goods) {
187 194
             //var_dump($goods);
188 195
             $min_normal_price = sprintf('%.2f', $goods['min_normal_price'] / 100);
@@ -200,47 +207,54 @@ class TaoKe extends BaseController
200 207
 
201 208
             $pv=$commission* 0.5;  //PV
202 209
             $yanglaojin=$pv*0.05; //新的养老金
203
-
204
-            if($yanglaojin < 0.1) {
205
-                continue;
206
-            }
210
+            Log::info("养老金:".$yanglaojin);
211
+            // if($yanglaojin < 0.1) {
212
+            //     continue;
213
+            // }
207 214
 
208 215
             
216
+            try {
217
+                $current_goods= [
218
+                    'type' => 1,//拼多多商品
219
+                    'id' => $goods['goods_sign'] ?? $goods['goods_id'],
220
+                    'thumb' => $goods['goods_thumbnail_url'],//商品缩略图
221
+                    'name' => $goods['goods_name'],
222
+                    'commission' => $yanglaojin, //养老金  //app()->make(ProductRepository::class)->thirdYanglaojin(0, $commission),
223
+                    'commission_' => $commission,
224
+    
225
+                    'yanglaojin' => $yanglaojin,
226
+                    'pv' => $pv,
227
+                    'gongxian'=>$pv,
228
+                    'jifen'=>$pv,
229
+                    
230
+    
231
+                    'commission_rate' => $commissionRate,
232
+                    'sales' => $goods['sales_tip'],
233
+                    //'desc' => $goods['goods_desc'],
234
+                    'coupon_money' => $couponMoney,
235
+                    //'market_price' => $groupPrice,
236
+                    'market_price' => set_price_rtrim(sprintf('%.2f', $groupPrice - $couponMoney)),
237
+                    'price' => set_price_rtrim(sprintf('%.2f', $min_normal_price - $couponMoney)),
238
+    
239
+                    'shopName'=>$goods['mall_name'], //店铺名称
240
+                    'monthSales'=>$goods['sales_tip']>0?$goods['sales_tip']:mt_rand(100,10000) //月销量
241
+                ];
242
+                Log::info($current_goods);
243
+                $goodsList[] =$current_goods;
244
+                $cid=isset($goods['cat_ids'][0])?$goods['cat_ids'][0]:0;
245
+                // Db::name("third_party_goods")->insert([
246
+                //     'json' => json_encode($current_goods, JSON_UNESCAPED_UNICODE),
247
+                //     'type' => 3,
248
+                //     'pension' => $yanglaojin,
249
+                //     'cid'=>$cid //一级分类
250
+                // ]);
251
+            } catch (\Throwable $th) {
252
+                Log::error($th->getMessage());
253
+            }
209 254
             
210
-            $this_goods= [
211
-                'type' => 1,//拼多多商品
212
-                'id' => $goods['goods_sign'] ?? $goods['goods_id'],
213
-                'thumb' => $goods['goods_thumbnail_url'],//商品缩略图
214
-                'name' => $goods['goods_name'],
215
-                'commission' => $yanglaojin, //养老金  //app()->make(ProductRepository::class)->thirdYanglaojin(0, $commission),
216
-                'commission_' => $commission,
217
-
218
-                'yanglaojin' => $yanglaojin,
219
-                'pv' => $pv,
220
-                'gongxian'=>$pv,
221
-                'jifen'=>$pv,
222
-
223
-                'commission_rate' => $commissionRate,
224
-                'sales' => $goods['sales_tip'],
225
-                //'desc' => $goods['goods_desc'],
226
-                'coupon_money' => $couponMoney,
227
-//                'market_price' => $groupPrice,
228
-                'market_price' => set_price_rtrim(sprintf('%.2f', $groupPrice - $couponMoney)),
229
-                'price' => set_price_rtrim(sprintf('%.2f', $min_normal_price - $couponMoney)),
230
-
231
-                'shopName'=>$goods['mall_name'], //店铺名称
232
-                'monthSales'=>$goods['sales_tip']>0?$goods['sales_tip']:mt_rand(100,10000) //月销量
233
-            ];
234
-            $goodsList[] =$this_goods;
235
-            $cid=isset($goods['cat_ids'][0])?$goods['cat_ids'][0]:0;
236
-            Db::name("third_party_goods")->insert([
237
-                'json' => json_encode($this_goods, JSON_UNESCAPED_UNICODE),
238
-                'type' => 3,
239
-                'pension' => $yanglaojin,
240
-                'cid'=>$cid //一级分类
241
-            ]);
242 255
 
243 256
         }
257
+        
244 258
         shuffle($goodsList);
245 259
         return app('json')->success('获取拼多多商品列表成功', $goodsList);
246 260
     }
@@ -395,8 +409,19 @@ class TaoKe extends BaseController
395 409
             return ['code' => 0, 'data' => $result];
396 410
         }
397 411
         $commission = ($detail['min_group_price'] * $detail['promotion_rate']) / 1000 / 100;
398
-        $detail['yanglao'] = app()->make(ProductRepository::class)
399
-            ->thirdYanglaojin(0, sprintf('%.2f', $commission));
412
+        // $detail['yanglao'] = app()->make(ProductRepository::class)
413
+        //     ->thirdYanglaojin(0, sprintf('%.2f', $commission));
414
+        
415
+            $pv=$commission* 0.5;  //PV
416
+            $yanglaojin=$pv*0.05; //新的养老金
417
+        
418
+        $gongxian=$pv;
419
+        $jifen=$pv;
420
+        $detail['yanglaojin'] =$yanglaojin;
421
+        $detail['pv'] =$pv;
422
+        $detail['gongxian'] =$gongxian;
423
+        $detail['jifen'] =$jifen;
424
+
400 425
         $detail['pddlink'] = $this->pdd_promotelink($goodsId, $thirdInfo);
401 426
         $detail['min_normal_price'] = $detail['min_normal_price'] - $detail['coupon_discount'];
402 427
         $detail['min_group_price'] = $detail['min_group_price'] - $detail['coupon_discount'];

+ 23 - 4
app/controller/api/store/product/Vip.php

@@ -175,9 +175,9 @@ class Vip extends BaseController
175 175
 
176 176
 
177 177
                     // $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
178
-                    if($yanglaojin < 0.1) {
179
-                        continue;
180
-                    }
178
+                    // if($yanglaojin < 0.1) {
179
+                    //     continue;
180
+                    // }
181 181
 
182 182
                     
183 183
                     //记录分类id到本地数据库
@@ -288,8 +288,27 @@ class Vip extends BaseController
288 288
     public function vip_goods()
289 289
     {
290 290
         [$page, $limit] = $this->getPage();
291
+
292
+        $keyword = $this->request->param('keyword');
293
+        $_cid = $this->request->param('cid');
294
+
295
+
296
+        
297
+        $goods_obj = Db::name('third_party_goods')
298
+            ->where('type', 5);
299
+        if($keyword){
300
+            $goods_obj=$goods_obj->where('json', 'like', '%' . $keyword . '%');
301
+        }
302
+        if($_cid){
303
+            $goods_obj=$goods_obj->where('cid', $_cid);
304
+        }
305
+        $data=$goods_obj->page($page, $limit)
306
+            ->select()->toArray();
307
+
308
+
309
+
291 310
         // 获取列表数据
292
-        $data = Db::name('third_party_goods')->where('type', 5)->page($page, $limit)->select()->toArray();
311
+        // $data = Db::name('third_party_goods')->where('type', 5)->page($page, $limit)->select()->toArray();
293 312
         $goodslist = [];
294 313
         if (!empty($data)) {
295 314
             foreach ($data as $value) {