Browse Source

Merge branch 'dev' into dev-sxb

# Conflicts:
#	app/common/repositories/user/UserRepository.php
sunxbiao 11 months ago
parent
commit
b037bd9c6f

+ 4 - 24
app/common/dao/store/product/ProductDao.php

@@ -124,20 +124,9 @@ class ProductDao extends BaseDao
124
         $query -> where("type != 7");
124
         $query -> where("type != 7");
125
         $query->withSearch($keyArray, $whereArr);
125
         $query->withSearch($keyArray, $whereArr);
126
 
126
 
127
-        if($mer_type==1 && $merId==324){
128
-            $merIds=Db::name('merchant')->where('mer_type',1)->column('mer_id');
129
-            //一壶茶会员专区
130
-            $query->when($merIds, function ($query) use ($merIds) {
131
-                $query->whereIn('mer_id', $merIds);
132
-            });
133
-        }else{
134
-            $query->when(($merId !== null), function ($query) use ($merId) {
135
-                $query->where('mer_id', $merId);
136
-            });
137
-        }
138
-
139
-
140
-        $query->when(isset($where['hot_type']) && $where['hot_type'] !== '', function ($query) use ($where) {
127
+        $query->when(!empty($merId), function ($query) use ($merId) {
128
+            $query->where('mer_id', $merId);
129
+        })->when(isset($where['hot_type']) && $where['hot_type'] !== '', function ($query) use ($where) {
141
             if ($where['hot_type'] == 'new')
130
             if ($where['hot_type'] == 'new')
142
                 $query->where('is_new', 1);
131
                 $query->where('is_new', 1);
143
             else if ($where['hot_type'] == 'hot')
132
             else if ($where['hot_type'] == 'hot')
@@ -165,16 +154,7 @@ class ProductDao extends BaseDao
165
             unset($where['keyword']);
154
             unset($where['keyword']);
166
         })->when(isset($where['volunteer']),function ($query) use ($where){
155
         })->when(isset($where['volunteer']),function ($query) use ($where){
167
             $query-> where('volunteer',$where['volunteer']);
156
             $query-> where('volunteer',$where['volunteer']);
168
-        });
169
-        $source = request()->header('source');
170
-        $merId= request()->header('merId');
171
-        if($source=='yhc' && $merId){
172
-//            $query->where('spu_id = "" || spu_id is null');
173
-//            $query->where('type',17);
174
-            $query->where('is_good',1);
175
-        }
176
-
177
-        $query->when(isset($where['order']),function($query)use($where){
157
+        })->when(isset($where['order']),function($query)use($where){
178
             $query->when(in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales', 'create_time']), function ($query) use ($where) {
158
             $query->when(in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales', 'create_time']), function ($query) use ($where) {
179
                 if ($where['order'] == 'price_asc') {
159
                 if ($where['order'] == 'price_asc') {
180
                     $where['order'] = 'price ASC';
160
                     $where['order'] = 'price ASC';

+ 1 - 1
app/common/middleware/UserTokenMiddleware.php

@@ -42,11 +42,11 @@ class UserTokenMiddleware extends BaseMiddleware
42
              * @var UserRepository $repository
42
              * @var UserRepository $repository
43
              */
43
              */
44
             $repository = app()->make(UserRepository::class);
44
             $repository = app()->make(UserRepository::class);
45
+            $repository->checkToken($token);
45
             $service = new JwtTokenService();
46
             $service = new JwtTokenService();
46
             try {
47
             try {
47
                 $payload = $service->parseToken($token);
48
                 $payload = $service->parseToken($token);
48
             } catch (ExpiredException $e) {
49
             } catch (ExpiredException $e) {
49
-                $repository->checkToken($token);
50
                 $payload = $service->decode($token);
50
                 $payload = $service->decode($token);
51
             } catch (Throwable $e) {//Token 过期
51
             } catch (Throwable $e) {//Token 过期
52
                 throw new AuthException('token 已过期');
52
                 throw new AuthException('token 已过期');

+ 1 - 1
app/common/repositories/store/order/StoreOrderRepository.php

@@ -3852,7 +3852,7 @@ class StoreOrderRepository extends BaseRepository
3852
 
3852
 
3853
         $order_sn = $order["order_sn"];
3853
         $order_sn = $order["order_sn"];
3854
         log::info("进入添加养老金{$order['order_sn']}");
3854
         log::info("进入添加养老金{$order['order_sn']}");
3855
-        $tongji = Db::name("user_bill")->where("order_sn", $order_sn)->count();
3855
+        $tongji = Db::name("user_bill")->where("order_sn", $order_sn)->where('type_shop', $type_shop)->count();
3856
         if ($tongji) {
3856
         if ($tongji) {
3857
             //第三方订单状态修改
3857
             //第三方订单状态修改
3858
             log::info("tongji");
3858
             log::info("tongji");

+ 4 - 3
app/common/repositories/system/merchant/MerchantRepository.php

@@ -426,6 +426,7 @@ class MerchantRepository extends BaseRepository
426
         $arr=[];
426
         $arr=[];
427
         foreach ($list["list"] as $v){
427
         foreach ($list["list"] as $v){
428
             $k= app()->make(ProductRepository::class)->pvParm($v['product_id']);
428
             $k= app()->make(ProductRepository::class)->pvParm($v['product_id']);
429
+            $productMerId = $v['mer_id'] ?? 0;
429
 //            $v['special_merchant']= merchantConfig($v['mer_id'], 'special_merchant');
430
 //            $v['special_merchant']= merchantConfig($v['mer_id'], 'special_merchant');
430
 
431
 
431
             log::info("==========yang= {$k['yanglao']} ");
432
             log::info("==========yang= {$k['yanglao']} ");
@@ -454,7 +455,7 @@ class MerchantRepository extends BaseRepository
454
                 $num_yl = 8000;
455
                 $num_yl = 8000;
455
             }
456
             }
456
 
457
 
457
-            if($merId == 496){
458
+            if($productMerId == 496){
458
 
459
 
459
                 $v['yanglao'] = bcmul($num_yl, 0.035, 2);
460
                 $v['yanglao'] = bcmul($num_yl, 0.035, 2);
460
                 $v['pv'] = bcmul($num_yl, 0.7, 2);
461
                 $v['pv'] = bcmul($num_yl, 0.7, 2);
@@ -468,7 +469,7 @@ class MerchantRepository extends BaseRepository
468
                     ]
469
                     ]
469
                 ];
470
                 ];
470
 
471
 
471
-            }else if($merId == 439 || $is_commercetrade){
472
+            }else if($productMerId == 439 || $is_commercetrade){
472
                 //精彩生活和商贸区
473
                 //精彩生活和商贸区
473
                 $jf = $v['price'] - bcmul($v['concession_pri'],0.3, 2) . ' + ' . bcmul($v['concession_pri'],0.3, 2);
474
                 $jf = $v['price'] - bcmul($v['concession_pri'],0.3, 2) . ' + ' . bcmul($v['concession_pri'],0.3, 2);
474
                 $jd = $v['price'] - bcmul($v['concession_pri'],0.35, 2) . ' + ' . bcmul($v['concession_pri'],0.35, 2);
475
                 $jd = $v['price'] - bcmul($v['concession_pri'],0.35, 2) . ' + ' . bcmul($v['concession_pri'],0.35, 2);
@@ -480,7 +481,7 @@ class MerchantRepository extends BaseRepository
480
                     $v['jifen'] = bcmul($v['concession_pri'], 0.35, 2);
481
                     $v['jifen'] = bcmul($v['concession_pri'], 0.35, 2);
481
                     $v['gongxian'] = bcmul($v['concession_pri'], 0.35, 2);
482
                     $v['gongxian'] = bcmul($v['concession_pri'], 0.35, 2);
482
                 }
483
                 }
483
-            }else if($merId == 491){
484
+            }else if($productMerId == 491){
484
                 // 获取商品sku
485
                 // 获取商品sku
485
                 $productSku = Db::name('store_product_attr_value')->where('product_id', $v['product_id'])->order('price asc')->find();
486
                 $productSku = Db::name('store_product_attr_value')->where('product_id', $v['product_id'])->order('price asc')->find();
486
                 $pv = $productSku['plate_mer_profit']??0.00;
487
                 $pv = $productSku['plate_mer_profit']??0.00;

+ 21 - 1
app/common/repositories/user/UserRepository.php

@@ -1443,7 +1443,7 @@ class UserRepository extends BaseRepository
1443
         if (!$has)
1443
         if (!$has)
1444
             throw new AuthException('无效的token');
1444
             throw new AuthException('无效的token');
1445
         $lastTime = Cache::get('user_' . $token);
1445
         $lastTime = Cache::get('user_' . $token);
1446
-        if (($lastTime + intval(Config::get('admin.token_valid_exp', 15)) * 60) > time())
1446
+        if (($lastTime + intval(Config::get('admin.token_valid_exp', 15)) * 60) < time())
1447
             throw new AuthException('token 已过期');
1447
             throw new AuthException('token 已过期');
1448
     }
1448
     }
1449
 
1449
 
@@ -4486,6 +4486,26 @@ class UserRepository extends BaseRepository
4486
     }
4486
     }
4487
 
4487
 
4488
     /**
4488
     /**
4489
+     * 添加用户操作记录
4490
+     * @param $uid
4491
+     * @param $model
4492
+     * @param $type
4493
+     * @param $mark
4494
+     * @return void
4495
+     */
4496
+    public function createUserOperatingRecord($uid, $model, $type, $mark)
4497
+    {
4498
+        Db::name('user_operating_record')->insert([
4499
+            'uid' => $uid,
4500
+            'operation_model' => $model,
4501
+            'operation_type' => $type,
4502
+            'mark' => $mark,
4503
+            'operation_time' => date('Y-m-d H:i:s')
4504
+        ]);
4505
+    }
4506
+
4507
+
4508
+    /**
4489
      * @param int $uid
4509
      * @param int $uid
4490
      * @return UserEntity
4510
      * @return UserEntity
4491
      */
4511
      */

+ 1 - 0
app/common/repositories/user/UserThirdRepository.php

@@ -232,6 +232,7 @@ class UserThirdRepository extends BaseRepository
232
                 "table"=>$table
232
                 "table"=>$table
233
             ];
233
             ];
234
 
234
 
235
+            /** @var StoreOrderRepository $StoreOrderRepository */
235
             $StoreOrderRepository = app()->make(StoreOrderRepository::class);
236
             $StoreOrderRepository = app()->make(StoreOrderRepository::class);
236
 //            $StoreOrderRepository->yugu_rebate($order);
237
 //            $StoreOrderRepository->yugu_rebate($order);
237
             log::info("===待进入养老金22222222222");
238
             log::info("===待进入养老金22222222222");

+ 204 - 87
app/controller/api/Auth.php

@@ -472,7 +472,10 @@ class Auth extends BaseController
472
         $tokenInfo = $repository->createToken($user);
472
         $tokenInfo = $repository->createToken($user);
473
 
473
 
474
         $repository->loginAfter($user);
474
         $repository->loginAfter($user);
475
-
475
+        $useragree = Db::name('user_operating_record')->where('uid', $user['id'])->where('operation_model', 1)->where('operation_type', 1)->find();
476
+        if (!$useragree){
477
+            $repository->createUserOperatingRecord($user->uid, 1, 1, '用户同意用户协议记录');
478
+        }
476
         return app('json')->success($repository->returnToken($user, $tokenInfo));
479
         return app('json')->success($repository->returnToken($user, $tokenInfo));
477
     }
480
     }
478
 
481
 
@@ -502,6 +505,8 @@ class Auth extends BaseController
502
             return app('json')->fail('验证码不正确');
505
             return app('json')->fail('验证码不正确');
503
         }
506
         }
504
 
507
 
508
+        cache()->set("sms_verified_" . $data['phone'], true, 60);
509
+
505
         $user = $repository->accountByUser($data['phone']);
510
         $user = $repository->accountByUser($data['phone']);
506
         if ($user)
511
         if ($user)
507
             return app('json')->fail('手机号已存在');
512
             return app('json')->fail('手机号已存在');
@@ -514,7 +519,7 @@ class Auth extends BaseController
514
             }
519
             }
515
         }
520
         }
516
         // Log::info($data);
521
         // Log::info($data);
517
-        $user = $repository->registr($data['phone'], $data['password'],'APP',"","",1,$data['spread']);
522
+        $user = $repository->registr($data['phone'], $data['password'],'APP',"","",1,0);
518
         // $repository->registr($data['phone'], $data['password'],'APP',$data['spread']);
523
         // $repository->registr($data['phone'], $data['password'],'APP',$data['spread']);
519
         $repository->addagent($user);
524
         $repository->addagent($user);
520
         $user = $repository->mainUser($user);
525
         $user = $repository->mainUser($user);
@@ -538,26 +543,66 @@ class Auth extends BaseController
538
 //                }
543
 //                }
539
 //            }
544
 //            }
540
 //        }
545
 //        }
541
-        if ($type == "marketing"){
542
-            $spread = Db::name("User") -> alias("u") -> leftjoin("MarketingUser mu","u.uid = mu.uid") ->  where("u.uid",$data['spread']) -> field("u.uid,mu.spread_list") -> find();
543
-            $spread_list = explode(',',$spread['spread_list']);
544
-            if (!empty($spread_list)){
545
-                $spread_list[] = "[" . $spread['uid'] . "]";
546
-            }else{
547
-                array_push($spread_list,"[".$spread['uid']."]");
548
-            }
549
-            $spread_list = array_filter($spread_list);
550
-            $data = [
551
-                "uid" => $user->uid,
552
-                "spread_uid" => $spread['uid'],
553
-                "spread_list" => implode(",",$spread_list)
554
-            ];
555
-            Db::name("MarketingUser") -> insert($data);
546
+//        if ($type == "marketing"){
547
+//            $spread = Db::name("User") -> alias("u") -> leftjoin("MarketingUser mu","u.uid = mu.uid") ->  where("u.uid",$data['spread']) -> field("u.uid,mu.spread_list") -> find();
548
+//            $spread_list = explode(',',$spread['spread_list']);
549
+//            if (!empty($spread_list)){
550
+//                $spread_list[] = "[" . $spread['uid'] . "]";
551
+//            }else{
552
+//                array_push($spread_list,"[".$spread['uid']."]");
553
+//            }
554
+//            $spread_list = array_filter($spread_list);
555
+//                    $data = [
556
+//                "uid" => $user->uid,
557
+//                "spread_uid" => $spread['uid'],
558
+//                "spread_list" => implode(",",$spread_list)
559
+//            ];
560
+//            Db::name("MarketingUser") -> insert($data);
561
+//        }
562
+
563
+        $result = $repository->returnToken($user, $tokenInfo);
564
+        $result['uid'] = $user->uid;
565
+        $repository->createUserOperatingRecord($user->uid, 1, 1, '用户同意用户协议记录');
566
+        return app('json')->success($result);
567
+
568
+    }
569
+
570
+    /**
571
+     * 用户注册后绑定邀请人
572
+     */
573
+    public function registerBindSpread(UserRepository $repository)
574
+    {
575
+        $data = $this->request->params(['uid', 'spread_phone']);
576
+        $user = Db::name('user')->where('uid', $data['uid'])->field('uid,spread_uid')->find();
577
+        if (!$user) {
578
+            return app('json')->fail('注册失败,用户不存在');
579
+        }
580
+        if (empty($data['spread_phone'])) {
581
+            return app('json')->fail('推荐人手机号不能为空');
582
+        }
583
+        $spread_user = Db::name('user')->where('phone', $data['spread_phone'])->field('uid')->find();
584
+        if (!$spread_user) {
585
+            return app('json')->fail('推荐人手机号不存在');
586
+        }
587
+        if(empty($data['uid'])==$user['uid']){
588
+            return app('json')->fail('不能绑定自己为推荐人');
556
         }
589
         }
557
 
590
 
558
-        return app('json')->success($repository->returnToken($user, $tokenInfo));
591
+        $spreadUid = $spread_user['uid'];//绑定推荐人
592
+        Db::name('user')->where('uid', $user['uid'])->update(['spread_uid'  => $spreadUid, 'spread_time' => date('Y-m-d H:i:s')]);
593
+
594
+        //给推荐人下级+1
595
+        Db::name('user')->where('uid', $spreadUid)->update(['spread_count' => Db::raw('spread_count + 1')]);
596
+        //积分表更新
597
+        $this->sign_add($spreadUid, 30,1,'邀请好友注册奖励积分','','', '', 1, '', 2);
598
+
599
+        Cache::zincrby('s_top_' . date('Y-m'), 1, $spreadUid);
600
+        Cache::zincrby('s_top_' . monday(), 1, $spreadUid);
601
+        return app('json')->success('绑定成功');
602
+
559
     }
603
     }
560
 
604
 
605
+
561
     /**
606
     /**
562
      * 手机号找回密码
607
      * 手机号找回密码
563
      * @param UserRepository $repository
608
      * @param UserRepository $repository
@@ -1361,28 +1406,48 @@ class Auth extends BaseController
1361
 
1406
 
1362
     public function verify(UserAuthValidate $validate)
1407
     public function verify(UserAuthValidate $validate)
1363
     {
1408
     {
1364
-        $data = $this->request->params(['phone', 'code', 'key',"type", 'areaCode']);
1409
+        $data = $this->request->params(['phone', 'code', 'key',"type"]);
1365
         $validate->sceneVerify()->check($data);
1410
         $validate->sceneVerify()->check($data);
1366
         log::info("发送短信方法");
1411
         log::info("发送短信方法");
1412
+        if ($data['type']=="login"){
1413
+            $count=Db::name("user")->where("phone", $data["phone"])->count();
1414
+            if (!$count){
1415
+                return app('json')->make(405, '该手机号未注册,请去注册');
1416
+            }
1417
+            $sms_num_key = 'api.auth.num.' . $data['phone'];
1418
+            $num = Cache::get($sms_num_key) ?: 0;
1419
+            log::info("num{$num}");
1420
+
1421
+            if ($num > 9) {
1422
+                if (!$data['code'])
1423
+                    return app('json')->make(402, '操作过于频繁,请稍后重试~');
1424
+                if (!$this->smslogin($data['phone'], $data['code'])) {
1425
+                    return app('json')->fail('登录验证码输入有误');
1426
+                }
1427
+            }
1428
+        }
1429
+
1367
         if ($data['type']=="register"){
1430
         if ($data['type']=="register"){
1368
             $count=Db::name("user")->where("phone", $data["phone"])->count();
1431
             $count=Db::name("user")->where("phone", $data["phone"])->count();
1369
             if ($count){
1432
             if ($count){
1370
-                return app('json')->make(405, '该手机号已注册');
1433
+                return app('json')->make(405, '该手机号已注册,请直接登录');
1434
+            }
1435
+            $sms_num_key = 'api.auth.num.' . $data['phone'];
1436
+            $num = Cache::get($sms_num_key) ?: 0;
1437
+            log::info("num{$num}");
1438
+
1439
+            if ($num > 9) {
1440
+                if (!$data['code'])
1441
+                    return app('json')->make(402, '操作过于频繁,请稍后重试~');
1442
+                if (!$this->registersmscode($data['phone'], $data['code'])) {
1443
+                    return app('json')->fail('注册验证码输入有误');
1444
+                }
1371
             }
1445
             }
1372
         }
1446
         }
1373
-        $sms_num_key = 'api.auth.num.' . $data['phone'];
1374
         $sms_key = 'api.auth.sms.' . $data['phone'];
1447
         $sms_key = 'api.auth.sms.' . $data['phone'];
1375
-        $num = Cache::get($sms_num_key) ? Cache::get($sms_num_key) : 0;
1376
-        log::info("num{$num}" );
1377
-        if ($num > 9) {
1378
-            if (!$data['code'])
1379
-                return app('json')->make(402, '操作过于频繁,请稍后重试~');
1380
-            if (!$this->checkCaptcha($data['key'], $data['code']))
1381
-                return app('json')->fail('验证码输入有误');
1382
-        }
1383
         $sms_code = str_pad(random_int(1, 9999), 4, 0, STR_PAD_LEFT);
1448
         $sms_code = str_pad(random_int(1, 9999), 4, 0, STR_PAD_LEFT);
1384
         $sms_time = systemConfig('sms_time') ? systemConfig('sms_time') : 30 ;
1449
         $sms_time = systemConfig('sms_time') ? systemConfig('sms_time') : 30 ;
1385
-        $res = app()->make(AliYunSmsService::class)->send(($data['areaCode'] ?? '') . $data['phone'],  $sms_code);
1450
+        $res = app()->make(AliYunSmsService::class)->send($data['phone'],  $sms_code);
1386
         if($res['Code']!='OK'){
1451
         if($res['Code']!='OK'){
1387
             Db::name('log')->insert(['data'=>'幸福保短信发送失败:'.json_encode($res,256)]);
1452
             Db::name('log')->insert(['data'=>'幸福保短信发送失败:'.json_encode($res,256)]);
1388
             return app('json')->fail('操作过于频繁,请稍后重试~');
1453
             return app('json')->fail('操作过于频繁,请稍后重试~');
@@ -1533,14 +1598,8 @@ class Auth extends BaseController
1533
 
1598
 
1534
         $user = $repository->accountByUser($data['phone']);
1599
         $user = $repository->accountByUser($data['phone']);
1535
         if (!$user){
1600
         if (!$user){
1536
-            $data['spread_uid'] = 0;
1537
-            if (intval($data['share_id'])) {
1538
-                $spread_uid = Db::name('product_share')->where('id', $data['share_id'])->value('uid');
1539
-                $data['spread_uid'] = $spread_uid;
1540
-            }
1541
-            $user = $repository->registr($data['phone'], null, 'h5', '','',1, $data['spread_uid']);
1601
+            return app('json')->fail('手机号未注册,请先注册');
1542
         }
1602
         }
1543
-        $user = $repository->mainUser($user);
1544
 
1603
 
1545
         // if($this->source=='yhc' && $this->merId){
1604
         // if($this->source=='yhc' && $this->merId){
1546
         //     $where=['mer_id'=>$this->merId,'uid'=>$user->uid];
1605
         //     $where=['mer_id'=>$this->merId,'uid'=>$user->uid];
@@ -1566,9 +1625,36 @@ class Auth extends BaseController
1566
         // $repository->bindSpread($user, intval($data['spread']));
1625
         // $repository->bindSpread($user, intval($data['spread']));
1567
         $tokenInfo = $repository->createToken($user);
1626
         $tokenInfo = $repository->createToken($user);
1568
         $repository->loginAfter($user);
1627
         $repository->loginAfter($user);
1628
+        $useragree = Db::name('user_operating_record')->where('uid', $user->uid)->where('operation_model', 1)->where('operation_type', 1)->find();
1629
+        if (!$useragree){
1630
+            $repository->createUserOperatingRecord($user->uid, 1, 1, '用户同意用户协议记录');
1631
+        }
1569
         return app('json')->success($repository->returnToken($user, $tokenInfo));
1632
         return app('json')->success($repository->returnToken($user, $tokenInfo));
1570
     }
1633
     }
1571
 
1634
 
1635
+    public function registerSmscode(UserAuthValidate $validate, UserRepository $repository)
1636
+    {
1637
+        $data = $this->request->params(['phone', 'sms_code', 'spread_uid']);
1638
+        $validate->sceneSmslogin()->check($data);
1639
+
1640
+        $count = Db::name('user')->where('phone', $data['phone'])->count();
1641
+        if ($count > 0) {
1642
+            return app('json')->fail('手机号已注册,请直接登录');
1643
+        }
1644
+
1645
+        if (!$this->checkSmsCode($data['phone'], $data['sms_code'])) {
1646
+            return app('json')->fail('验证码不正确');
1647
+        }
1648
+
1649
+        cache()->set("sms_verified_" . $data['phone'], true, 60);
1650
+        return app('json')->success([
1651
+            'msg' => '验证码验证通过,请填写推荐人手机号完成注册',
1652
+            'phone' => $data['phone']
1653
+        ]);
1654
+
1655
+    }
1656
+
1657
+
1572
     public function merJavaRegister(UserRepository $repository){
1658
     public function merJavaRegister(UserRepository $repository){
1573
         $data = $this->request->params(['phone', 'spread','token','sign']);
1659
         $data = $this->request->params(['phone', 'spread','token','sign']);
1574
         Log::channel("gong")->info("供应链取消商品数据:" . json_encode($data));
1660
         Log::channel("gong")->info("供应链取消商品数据:" . json_encode($data));
@@ -1605,7 +1691,7 @@ class Auth extends BaseController
1605
         //log::info("页面传值==={$code}");
1691
         //log::info("页面传值==={$code}");
1606
         if (!$cache_code = Cache::get($sms_key)) return false;
1692
         if (!$cache_code = Cache::get($sms_key)) return false;
1607
         if ($code != $cache_code) return false;
1693
         if ($code != $cache_code) return false;
1608
-        Cache::delete($sms_key);
1694
+        //Cache::delete($sms_key);
1609
         return true;
1695
         return true;
1610
     }
1696
     }
1611
     //批量生产100个账号
1697
     //批量生产100个账号
@@ -1684,31 +1770,37 @@ class Auth extends BaseController
1684
     }
1770
     }
1685
 
1771
 
1686
 
1772
 
1687
-    /**
1688
-     * 微信授权登录 一键登录
1689
-     * @return mixed
1690
-     * @throws DataNotFoundException
1691
-     * @throws DbException
1692
-     * @throws ModelNotFoundException
1693
-     */
1694
-    public function wechatCheck()
1695
-    {
1696
-        $data = $this->request->params(['openid']);
1773
+    /*微信授权登录*/
1774
+    public function wechatCheck(){
1775
+        $data =  $this->request->params(['openid']);
1776
+        // , 'nickname', 'avatar'
1697
         $data['nickname'] = $this->request->param('nickname', null);
1777
         $data['nickname'] = $this->request->param('nickname', null);
1698
         $data['avatar'] = $this->request->param('avatar', null);
1778
         $data['avatar'] = $this->request->param('avatar', null);
1699
 
1779
 
1700
-        if (!$data['openid'] || $data['openid'] == '' || $data['openid'] == 'undefined') {
1780
+        if(!$data['openid'] || $data['openid'] == '' || $data['openid'] =='undefined'){
1701
             return app('json')->fail("openid参数缺失");
1781
             return app('json')->fail("openid参数缺失");
1702
         }
1782
         }
1703
 
1783
 
1704
-        /** @var UserRepository $repository */
1705
         $repository = app()->make(UserRepository::class);
1784
         $repository = app()->make(UserRepository::class);
1706
-        $result = $repository->wechatCheck($data['openid'], $data['nickname'], $data['avatar']);
1707
-
1708
-        if (isset($result['code']) && $result['code'] == 200) {
1785
+        if($this->source=='yhc'){
1786
+            $result =  $repository ->wechatCheckYhc($data['openid']);
1787
+        }else{
1788
+            $result =  $repository ->wechatCheck($data['openid'], $data['nickname'], $data['avatar']);
1789
+        }
1790
+        if(isset($result['code']) && $result['code'] == 200){
1709
             $user = $repository->accountByUser($result['user']['account']);
1791
             $user = $repository->accountByUser($result['user']['account']);
1792
+            $useragree = Db::name('user_operating_record')->where('uid', $user->uid)->where('operation_model', 1)->where('operation_type', 1)->find();
1793
+            if (!$useragree){
1794
+                $repository->createUserOperatingRecord($user->uid, 1, 1, '用户同意用户协议记录');
1795
+            }
1710
             $tokenInfo = $repository->createToken($user);
1796
             $tokenInfo = $repository->createToken($user);
1711
             $repository->loginAfter($user);
1797
             $repository->loginAfter($user);
1798
+            if($this->source=='yhc'){
1799
+//                $user=$user->toArray();
1800
+                $user->avatar=Db::name('enterprise_user')->where('mer_id',$this->merId)->where('uid',$user['uid'])->value('avatar');
1801
+            }
1802
+
1803
+
1712
             return app('json')->success($repository->returnToken($user, $tokenInfo));
1804
             return app('json')->success($repository->returnToken($user, $tokenInfo));
1713
         }
1805
         }
1714
         return app("json")->fail($result['msg']);
1806
         return app("json")->fail($result['msg']);
@@ -1832,7 +1924,10 @@ class Auth extends BaseController
1832
 
1924
 
1833
             $tokenInfo = $repository->createToken($user);
1925
             $tokenInfo = $repository->createToken($user);
1834
             $repository->loginAfter($user);
1926
             $repository->loginAfter($user);
1835
-
1927
+            $useragree = Db::name('user_operating_record')->where('uid', $user->uid)->where('operation_type', 1)->where('operation_model', 1)->find();
1928
+            if (!$useragree){
1929
+                $repository->createUserOperatingRecord($user->uid, 1, 1, '用户同意用户协议记录');
1930
+            }
1836
             return app('json')->success($repository->returnToken($user, $tokenInfo));
1931
             return app('json')->success($repository->returnToken($user, $tokenInfo));
1837
         }else{
1932
         }else{
1838
             return app('json')->fail("绑定失败");
1933
             return app('json')->fail("绑定失败");
@@ -1902,7 +1997,7 @@ class Auth extends BaseController
1902
         $ins_data['addtime'] = time();
1997
         $ins_data['addtime'] = time();
1903
         $ins_data['status'] = $status;
1998
         $ins_data['status'] = $status;
1904
         $ins_data['mark'] = $mark;
1999
         $ins_data['mark'] = $mark;
1905
-        $ins_data['type'] = $type;
2000
+        $ins_data['source_type'] = $type;
1906
         $ins_data['settlement_time'] = $settlement_time;// 结算时间 真正到了结算时间会结算
2001
         $ins_data['settlement_time'] = $settlement_time;// 结算时间 真正到了结算时间会结算
1907
         $ins_data['order_id'] = $order_id;
2002
         $ins_data['order_id'] = $order_id;
1908
         $ins_data['pm'] = $pm;
2003
         $ins_data['pm'] = $pm;
@@ -2015,47 +2110,50 @@ class Auth extends BaseController
2015
             }
2110
             }
2016
             $user_res=Db::name('user')->where('account',$phone)->find();
2111
             $user_res=Db::name('user')->where('account',$phone)->find();
2017
 
2112
 
2113
+            $isnew = false;
2114
+
2018
             if(!$user_res){
2115
             if(!$user_res){
2019
                 $spread_uid=Db::name('product_share')->where('id',$share_id['share_id'])->value('uid');
2116
                 $spread_uid=Db::name('product_share')->where('id',$share_id['share_id'])->value('uid');
2020
                 if (!intval($spread_uid)) {
2117
                 if (!intval($spread_uid)) {
2021
                     $spread_uid = 0;
2118
                     $spread_uid = 0;
2022
                 }
2119
                 }
2023
                 $repository->registr($phone, 123456,'APP','','','',$spread_uid);
2120
                 $repository->registr($phone, 123456,'APP','','','',$spread_uid);
2121
+
2122
+                $isnew = true;
2024
             }
2123
             }
2025
             $user = $repository->accountByUser($phone);
2124
             $user = $repository->accountByUser($phone);
2026
-            // if($this->source=='yhc' && $this->merId){
2027
-            //     $where=['mer_id'=>$this->merId,'uid'=>$user['uid']];
2028
-            //     $count=Db::name('enterprise_user')->where($where)->count();
2029
-            //     if($count<1){
2030
-            //         $insert=['mer_id'=>$this->merId,'uid'=>$user['uid']];
2031
-            //         $data = $this->request->params(['spread', 'share_id']);
2032
-            //
2033
-            //         if(isset($data['spread']) && $data['spread']){
2034
-            //             $insert['puid']= $data['spread'];
2035
-            //             $insert['node_uid']= $data['spread'];
2036
-            //         }else if(isset($data['share_id']) && $data['share_id']){
2037
-            //             $spread_uid = Db::name('product_share')->where('id', $data['share_id'])->value('uid');
2038
-            //             $insert['puid']= $spread_uid;
2039
-            //             $insert['node_uid']= $spread_uid;
2040
-            //         }
2041
-            //         if(!isset($insert['node_uid']) || !$insert['node_uid']){
2042
-            //             return app('json')->fail('必须要有邀请人才能注册',['is'=>1]);
2043
-            //         }
2044
-            //
2045
-            //         if(isset($data['spread']) && isset($zhuce)){
2046
-            //             $insert['puid']= $data['spread'];
2047
-            //             $insert['node_uid']= $data['spread'];
2048
-            //         }
2049
-            //         Db::name('enterprise_user')->insert($insert);
2050
-            //     }
2051
-            // }
2052
-            if (!empty($user) && $user instanceof User) {
2053
-                $user = $repository->mainUser($user);
2054
-                $tokenInfo = $repository->createToken($user);
2055
-                return app('json')->success($repository->returnToken($user, $tokenInfo));
2056
-            } else {
2057
-                return app('json')->fail('未查询到用户信息');
2125
+            if($this->source=='yhc' && $this->merId){
2126
+                $where=['mer_id'=>$this->merId,'uid'=>$user['uid']];
2127
+                $count=Db::name('enterprise_user')->where($where)->count();
2128
+                if($count<1){
2129
+                    $insert=['mer_id'=>$this->merId,'uid'=>$user['uid']];
2130
+                    $data = $this->request->params(['spread', 'share_id']);
2131
+
2132
+                    if(isset($data['spread']) && $data['spread']){
2133
+                        $insert['puid']= $data['spread'];
2134
+                        $insert['node_uid']= $data['spread'];
2135
+                    }else if(isset($data['share_id']) && $data['share_id']){
2136
+                        $spread_uid = Db::name('product_share')->where('id', $data['share_id'])->value('uid');
2137
+                        $insert['puid']= $spread_uid;
2138
+                        $insert['node_uid']= $spread_uid;
2139
+                    }
2140
+                    if(!isset($insert['node_uid']) || !$insert['node_uid']){
2141
+                        return app('json')->fail('必须要有邀请人才能注册',['is'=>1]);
2142
+                    }
2143
+
2144
+                    if(isset($data['spread']) && isset($zhuce)){
2145
+                        $insert['puid']= $data['spread'];
2146
+                        $insert['node_uid']= $data['spread'];
2147
+                    }
2148
+                    Db::name('enterprise_user')->insert($insert);
2149
+                }
2058
             }
2150
             }
2151
+            $user = $repository->mainUser($user);
2152
+
2153
+            $tokenInfo = $repository->createToken($user);
2154
+
2155
+            return app('json')->success(array_merge($repository->returnToken($user, $tokenInfo), ['is_new' => $isnew ? 1 : 0]));//如果是注册用户,isnew=1
2156
+
2059
         }catch (Exception $exception){
2157
         }catch (Exception $exception){
2060
             Db::name('log')->insert(['data'=>'获取手机号失败--'.$exception->getFile().':'.$exception->getLine().'【'.$exception->getMessage().'】']);
2158
             Db::name('log')->insert(['data'=>'获取手机号失败--'.$exception->getFile().':'.$exception->getLine().'【'.$exception->getMessage().'】']);
2061
         }
2159
         }
@@ -2802,5 +2900,24 @@ class Auth extends BaseController
2802
     
2900
     
2803
     }
2901
     }
2804
 
2902
 
2903
+    /**
2904
+     * 将 所有用户 令牌设置为失效
2905
+     * @return \think\response\Json
2906
+     */
2907
+    public function invalidateAllTokens(): \think\response\Json
2908
+    {
2909
+        // 获取所有用户token键(可能需要使用Redis的keys命令或scan)
2910
+        $userTokens = Cache::store('redis')->keys('user_*');
2911
+        $javaTokens = Cache::store('redis')->keys('java_*');
2805
 
2912
 
2913
+        // 批量删除所有token
2914
+        foreach ($userTokens as $token) {
2915
+            Cache::delete($token);
2916
+        }
2917
+        foreach ($javaTokens as $token) {
2918
+            Cache::delete($token);
2919
+        }
2920
+
2921
+        return app('json')->success($userTokens);
2922
+    }
2806
 }
2923
 }

+ 44 - 0
app/controller/api/store/merchant/Merchant.php

@@ -142,6 +142,50 @@ class Merchant extends BaseController
142
     }
142
     }
143
 
143
 
144
     /**
144
     /**
145
+     * 获取商户上架的商品列表
146
+     * @return mixed
147
+     */
148
+    public function getProductList()
149
+    {
150
+        $params = request()->only(['pageNum', 'pageSize', 'mer_id']);
151
+        $merId = $params['mer_id'] ?? 0;
152
+
153
+        [$page, $limit] = $this->getPage();
154
+        $where = request()->only(['keyword']);
155
+        $where['is_gift_bag'] = 0;
156
+        $where['is_used'] = 1;
157
+        $where['product_type'] = 0;
158
+        $where['is_hide'] = 0;
159
+        $result = $this->repository->productList($merId, $where, $page, $limit, $this->userInfo);
160
+        $formatList = [];
161
+        foreach ($result['list'] as $productInfo) {
162
+            $formatList[] = [
163
+                'type' => 0,//京东商品
164
+                'skuId' => '',//itemId 京东官方 已不返回skuId , 使用 联盟商品ID 代替skuId
165
+                'id' => $productInfo['product_id'] ?? '', //id
166
+                'name' => $productInfo['store_name'],//名称
167
+                'thumb' => $productInfo['image'] ?? '',//商品缩略图
168
+
169
+                'pv' => $productInfo['pv'],//PV金额
170
+                'gongxian' => $productInfo['gongxian'],
171
+                'jifen' => $productInfo['jifen'],
172
+                'yanglaojin' => $productInfo['yanglao'],
173
+
174
+                'commission' => $productInfo['concession_pri'],//佣金
175
+                'commission_rate' => null,//佣金比例
176
+                'coupon_money' => [],
177
+                'coupon_link' => '',
178
+                'lowestCouponPrice' => $productInfo['price'],
179
+                'price' => $productInfo['ot_price'], //价格
180
+                'imageList' => $productInfo['slider_image'], //图片合集
181
+                'materialUrl' => ''
182
+            ];
183
+        }
184
+        return app('json')->success($formatList);
185
+    }
186
+
187
+
188
+    /**
145
      * 商贸区店铺商品列表
189
      * 商贸区店铺商品列表
146
      * @return mixed
190
      * @return mixed
147
      * @throws \think\db\exception\DataNotFoundException
191
      * @throws \think\db\exception\DataNotFoundException

+ 30 - 26
app/controller/api/store/merchant/Taskorderguquan.php

@@ -19,58 +19,62 @@ class Taskorderguquan
19
 
19
 
20
         /**
20
         /**
21
         补贴下面人员
21
         补贴下面人员
22
-        13231658486周行体1000
23
-        13333069689魏惠新1000
24
-        13959100621周金花500
25
-        13701061395李素红500
22
+        13231658486周行体800
23
+        13333069689魏   新800
24
+        13959100621周金花400
25
+        13701061395李素红300
26
         17501006833邢艳丽300
26
         17501006833邢艳丽300
27
         15631982690魏震洪300
27
         15631982690魏震洪300
28
-        18603401312黄金花400
28
+        18603401312黄金花200
29
         13521438652徐立苹400
29
         13521438652徐立苹400
30
         15832971815孟晓玮300
30
         15832971815孟晓玮300
31
         18600200909陈冠霖300
31
         18600200909陈冠霖300
32
-        15810064711 王   玲 400
33
-        13932925303会强400
34
-        13901074090陈玉刚400
35
-        13381085923王建军50
32
+        15810064711 王   玲 300
33
+        13932925303会强300
34
+        13901074090陈玉刚300
35
+        13381085923王建军100
36
         13601071082隋彩云300
36
         13601071082隋彩云300
37
         18001316701闫旭300
37
         18001316701闫旭300
38
         13601179856陈瑞元50
38
         13601179856陈瑞元50
39
         13161909228刘银霞100
39
         13161909228刘银霞100
40
-        18760167163刘春梅50
41
-        13215917919李小秋50
42
-        15321221558李伟50
40
+        18760167163刘春梅100
41
+        13215917919李小秋100
42
+        13801358713金波50
43
+        15321221558李伟 200
43
         15332507711张传莲50
44
         15332507711张传莲50
44
         15960349667吕丽娣50
45
         15960349667吕丽娣50
45
-        18612051372李金俭50
46
+        13231658486周军市场补贴500
47
+        18612051372李金俭 50
48
+        15803242611王志敏50
46
         18715313601大饼400
49
         18715313601大饼400
47
-        其余部分做分红
48
         */
50
         */
49
         $data = [
51
         $data = [
50
-            '13231658486' => 1000,
51
-            '13333069689' => 1000,
52
-            '13959100621' => 500,
53
-            '13701061395' => 500,
52
+            '13231658486' => 1300,
53
+            '13333069689' => 800,
54
+            '13959100621' => 400,
55
+            '13701061395' => 300,
54
             '17501006833' => 300,
56
             '17501006833' => 300,
55
             '15631982690' => 300,
57
             '15631982690' => 300,
56
-            '18603401312' => 400,
58
+            '18603401312' => 200,
57
             '13521438652' => 400,
59
             '13521438652' => 400,
58
             '15832971815' => 300,
60
             '15832971815' => 300,
59
             '18600200909' => 300,
61
             '18600200909' => 300,
60
-            '15810064711' => 400,
61
-            '13932925303' => 400,
62
-            '13901074090' => 400,
63
-            '13381085923' => 50,
62
+            '15810064711' => 300,
63
+            '13932925303' => 300,
64
+            '13901074090' => 300,
65
+            '13381085923' => 100,
64
             '13601071082' => 300,
66
             '13601071082' => 300,
65
             '18001316701' => 300,
67
             '18001316701' => 300,
66
             '13601179856' => 50,
68
             '13601179856' => 50,
67
             '13161909228' => 100,
69
             '13161909228' => 100,
68
-            '18760167163' => 50,
69
-            '13215917919' => 50,
70
-            '15321221558' => 50,
70
+            '18760167163' => 100,
71
+            '13215917919' => 100,
72
+            '13801358713' => 50,
73
+            '15321221558' => 200,
71
             '15332507711' => 50,
74
             '15332507711' => 50,
72
             '15960349667' => 50,
75
             '15960349667' => 50,
73
             '18612051372' => 50,
76
             '18612051372' => 50,
77
+            '15803242611' => 50,
74
             '18715313601' => 400
78
             '18715313601' => 400
75
         ];
79
         ];
76
 
80
 

+ 513 - 279
app/controller/api/store/product/Jd.php

@@ -4,8 +4,11 @@ namespace app\controller\api\store\product;
4
 
4
 
5
 use app\common\repositories\store\product\ProductRepository;
5
 use app\common\repositories\store\product\ProductRepository;
6
 use app\common\repositories\user\UserThirdRepository;
6
 use app\common\repositories\user\UserThirdRepository;
7
+use app\model\common\JdOrderModel;
8
+use DateTime;
7
 use think\App;
9
 use think\App;
8
 use crmeb\basic\BaseController;
10
 use crmeb\basic\BaseController;
11
+use think\db\exception\DbException;
9
 use think\Exception;
12
 use think\Exception;
10
 use think\exception\ValidateException;
13
 use think\exception\ValidateException;
11
 use think\facade\Db;
14
 use think\facade\Db;
@@ -24,10 +27,14 @@ class Jd extends BaseController
24
     {
27
     {
25
 
28
 
26
         parent::__construct($app);
29
         parent::__construct($app);
27
-        $this->appid = '4100076550';
28
-        $this->key = '5ce3da55dc739b6e7d9021d59618c5faa3b4030f41c5699658c7ca30cfd19f09b4046d606d196f1d';
29
-        $this->appKey = 'a2ad5078501e928b991cd8aaeb0446dc';
30
-        $this->secretKey = 'fd8aab59e9b94d9e889cb22838c03f2a';
30
+        $this->appid = '4101490811';
31
+        $this->key = 'a7c43c21f3e156d2fd41dfbe884b9f62592ceb03b9f199c0811c82e35be53c0580a2638a7af39e74';
32
+        $this->appKey = 'e99703d01cbb6a2e48a8a34f19af9d87';
33
+        $this->secretKey = 'cea7578d5a314ef88086daa4ee3a5b4d';
34
+        // $this->appid = '4100076550';
35
+        // $this->key = '5ce3da55dc739b6e7d9021d59618c5faa3b4030f41c5699658c7ca30cfd19f09b4046d606d196f1d';
36
+        // $this->appKey = 'a2ad5078501e928b991cd8aaeb0446dc';
37
+        // $this->secretKey = 'fd8aab59e9b94d9e889cb22838c03f2a';
31
         $this->userThird = app()->make(UserThirdRepository::class);
38
         $this->userThird = app()->make(UserThirdRepository::class);
32
         $this->url = 'https://api.jd.com/routerjson';
39
         $this->url = 'https://api.jd.com/routerjson';
33
     }
40
     }
@@ -150,57 +157,73 @@ class Jd extends BaseController
150
     /*京粉精选商品查询接口*/
157
     /*京粉精选商品查询接口*/
151
     public function jdList()
158
     public function jdList()
152
     {
159
     {
153
-//         [$page, $limit] = $this->getPage();
154
-//         $apiName = 'jd.union.open.goods.jingfen.query';
155
-//         $params = [
156
-//             'goodsReq'=>[
157
-//                 'eliteId'=>2,
158
-//                 'pageIndex'=>$page??1,
159
-//                 'pageSize' =>20,
160
-//             ]
161
-//         ];
162
-//         $result = $this->getUrlResult($apiName,$params);
163
-//         $result =  json_decode($result,true);
164
-//         $result =  json_decode($result['jd_union_open_goods_jingfen_query_responce']['result'],true);
165
-//         $result =$result['data']??[];
166
-//         $goodsList = [];
167
-//
168
-//         foreach ($result as $k=> $goods) {
169
-//             $goodsList[] = [
170
-//                 'type' => 6,//京东商品
171
-//                 'skuId' =>$goods['skuId'],//skuid
172
-//                 'id' => $goods['brandCode']??'', //id
173
-//                 'thumb' => $goods['imageInfo']['imageList'][0]['url']??'',//商品缩略图
174
-//                 'name' => $goods['skuName'],//名称
175
-//                 'commission' =>app()->make(ProductRepository::class)->yanglaojin(0,$goods['commissionInfo']['commission']??''),//佣金
176
-//                 'commission_rate' => $goods['commissionInfo']['commissionShare']??'',//佣金比例
177
-//                 'sales' => "",
178
-//                 'coupon_money' => $goods['couponInfo']['couponList'] ?? [],
179
-//                 'lowestCouponPrice' => $goods['priceInfo']['price']??'', //券后价lowestCouponPrice
180
-//                 'price' => $goods['priceInfo']['price']??'', //价格
181
-//             ];
182
-//         }
160
+        $keyword = request()->param('keyword', '');
161
+        $_cid = request()->param('cid', '');
183
 
162
 
184
         [$page, $limit] = $this->getPage();
163
         [$page, $limit] = $this->getPage();
185
-        $list = Db::name('third_party_goods')
186
-            ->where('type', 2)
187
-            ->page($page, $limit)
188
-            ->field('json')
189
-            ->select()
190
-            ->toArray();
164
+
165
+
166
+        $goods_obj = Db::name('third_party_goods')
167
+            ->where('type', 2);
168
+        if ($keyword) {
169
+            $goods_obj = $goods_obj->where('json', 'like', '%' . $keyword . '%');
170
+        }
171
+        if ($_cid) {
172
+            /**
173
+             * 旧品类标识到新品类eliteId的映射关系
174
+             *
175
+             * 映射规则:
176
+             * 1. 精品(0) -> 精选卖场(2) + 自营热卖榜(41)
177
+             * 2. 其他品类按最接近的京东新分类映射
178
+             * 3. 未明确对应的品类映射到通用分类(好券商品+京东好物)
179
+             */
180
+            $oldToNewMapping = [
181
+                // 精品 -> 精选卖场 + 自营热卖榜
182
+                0 => [2, 41],
183
+                // 居家日用 -> 家具日用
184
+                1 => [27],
185
+                // 食品 -> 超市
186
+                2 => [25],
187
+                // 生鲜 -> 超市
188
+                3 => [25],
189
+                // 图书 -> 图书文具
190
+                4 => [30],
191
+                // 美妆个护 -> 美妆穿搭
192
+                5 => [28],
193
+                // 母婴 -> 母婴玩具
194
+                6 => [26],
195
+                // 数码家电 -> 数码家电 + 3C新品 + 3C长尾商品
196
+                7 => [24, 341, 343],
197
+                // 内衣 -> 京东好物(通用分类)
198
+                8 => [32],
199
+                // 配饰 -> 京东好物(通用分类)
200
+                9 => [32],
201
+                // 女装 -> 美妆穿搭(服装相关)
202
+                10 => [28],
203
+                // 男装 -> 京东好物(通用分类)
204
+                11 => [32],
205
+                // 鞋品 -> 京东好物(通用分类)
206
+                12 => [32],
207
+                // 家装家纺 -> 家具日用
208
+                13 => [27],
209
+                // 文娱车品 -> 图书文具 + 京东好物
210
+                14 => [30, 32],
211
+                // 箱包 -> 京东好物(通用分类)
212
+                15 => [32],
213
+                // 户外运动 -> 京东好物(通用分类)
214
+                16 => [32],
215
+            ];
216
+            $goods_obj = $goods_obj->whereIn('cid', $oldToNewMapping[$_cid]);
217
+        }
218
+        $list = $goods_obj->page($page, $limit)
219
+            ->select()->toArray();
220
+
191
         $formatList = [];
221
         $formatList = [];
192
         foreach ($list as $value) {
222
         foreach ($list as $value) {
193
             $json = json_decode($value['json'], true);
223
             $json = json_decode($value['json'], true);
194
-            $json['pension'] = $json['pension']??'0';
195
-            $json['pv'] = $json['pension'];
196
-            $json['yanglaojin'] = $json['pension'];
197
-
198
-            // $json['shopName'] = "";
199
-            // $json['monthSales'] = "0";
200
-            // $json['cid'] = "0";
201
-            $json['shopName'] = isset($json['shopName'])?$json['shopName']:"";
202
-            $json['monthSales'] = isset($json['monthSales'])?$json['monthSales']:0;
203
-            $json['cid'] = isset($value['cid'])?$json['cid']:0;
224
+            $json['commission_'] = $json['lowestCouponPrice'];
225
+            $json['monthSales'] = 0;
226
+            $json['cid'] = $value['cid'] ?? 0;
204
             $formatList[] = $json;
227
             $formatList[] = $json;
205
         }
228
         }
206
         shuffle($formatList);
229
         shuffle($formatList);
@@ -210,7 +233,44 @@ class Jd extends BaseController
210
     /*京粉精选商品查询接口*/
233
     /*京粉精选商品查询接口*/
211
     public function search()
234
     public function search()
212
     {
235
     {
213
-//        [$page, $limit] = $this->getPage();
236
+        $keyword = request()->param('keyword', '');
237
+        $_cid = request()->param('cid', '');
238
+
239
+        [$page, $limit] = $this->getPage();
240
+        try {
241
+            $uid = $this->request->uid();
242
+            TaoKe::set_third_history($uid, $keyword);
243
+        } catch (\Exception $exception) {
244
+
245
+        }
246
+
247
+        $goods_obj = Db::name('third_party_goods')
248
+            -> where('type',2);
249
+        // -> when(!empty($keyword),function($query) use ($keyword) {
250
+        //     $query -> where('json',"like",'%'.$keyword.'%');
251
+        // })
252
+        // -> page($page,$limit)
253
+        // -> field('json')
254
+        // -> select()
255
+        // -> toArray();
256
+
257
+        if($keyword){
258
+            $goods_obj=$goods_obj->where('json', 'like', '%' . $keyword . '%');
259
+        }
260
+        if($_cid){
261
+            $goods_obj=$goods_obj->where('cid', $_cid);
262
+        }
263
+        $list=$goods_obj->page($page, $limit)
264
+            ->select()->toArray();
265
+
266
+        $formatList = [];
267
+        foreach ($list as $value){
268
+            $formatList[] = json_decode($value['json'],true);
269
+        }
270
+        return app("json")->success($formatList);
271
+
272
+
273
+        //        [$page, $limit] = $this->getPage();
214
 //        $apiName = 'jd.union.open.goods.query';
274
 //        $apiName = 'jd.union.open.goods.query';
215
 //        $keyword = $this->request->param(['keyword']);
275
 //        $keyword = $this->request->param(['keyword']);
216
 //        $params = [
276
 //        $params = [
@@ -245,55 +305,79 @@ class Jd extends BaseController
245
 //            ];
305
 //            ];
246
 //        }
306
 //        }
247
 
307
 
248
-        $keyword = request()->param('keyword', '');
249
-        [$page, $limit] = $this->getPage();
250
-        $uid = $this->request->uid();
251
-        TaoKe::set_third_history($uid, $keyword);
252
-
253
-        $list = Db::name('third_party_goods')
254
-            ->where('type', 2)
255
-            ->when(!empty($keyword), function ($query) use ($keyword) {
256
-                $query->where('json', "like", '%' . $keyword . '%');
257
-            })
258
-            ->page($page, $limit)
259
-            ->field('json')
260
-            ->select()
261
-            ->toArray();
262
-        $formatList = [];
263
-        foreach ($list as $value) {
264
-	    $json = json_decode($value['json'], true);
265
-            $json['pension'] = $json['pension']??'0';
266
-            $json['pv'] = $json['pension']*0.5;
267
-            $json['yanglaojin'] = $json['pv']*0.05;
268
-
269
-            $json['shopName'] = "";
270
-            $json['monthSales'] = "0";
271
-            $json['cid'] = "0";
272
-            $formatList[] = $json;
273
-        }
274
-        return app("json")->success($formatList);
308
+        // $keyword = request()->param('keyword', '');
309
+        // [$page, $limit] = $this->getPage();
310
+        // $uid = $this->request->uid();
311
+        // TaoKe::set_third_history($uid, $keyword);
312
+        //
313
+        // $list = Db::name('third_party_goods')
314
+        //     ->where('type', 2)
315
+        //     ->when(!empty($keyword), function ($query) use ($keyword) {
316
+        //         $query->where('json', "like", '%' . $keyword . '%');
317
+        //     })
318
+        //     ->page($page, $limit)
319
+        //     ->field('json')
320
+        //     ->select()
321
+        //     ->toArray();
322
+        // $formatList = [];
323
+        // foreach ($list as $value) {
324
+	    // $json = json_decode($value['json'], true);
325
+        //     $json['pension'] = $json['pension']??'0';
326
+        //     $json['pv'] = $json['pension']*0.5;
327
+        //     $json['yanglaojin'] = $json['pv']*0.05;
328
+        //
329
+        //     $json['shopName'] = "";
330
+        //     $json['monthSales'] = "0";
331
+        //     $json['cid'] = "0";
332
+        //     $formatList[] = $json;
333
+        // }
334
+        // return app("json")->success($formatList);
275
     }
335
     }
276
 
336
 
277
 
337
 
278
     /*京东商品详情*/
338
     /*京东商品详情*/
279
     public function jdDetail()
339
     public function jdDetail()
280
     {
340
     {
281
-
282
         try {
341
         try {
283
-            $sku = $this->request->param(['skuId']);
284
-            $apiName = 'jd.union.open.goods.promotiongoodsinfo.query';
285
-            $params = [
286
-                'skuIds' => $sku['skuId'],
342
+            $sku = request()->param('skuId', '');
343
+            if (empty($sku)) {
344
+                return app('json')->fail('商品下架不存在', null, 401);
345
+            }
346
+            // 老版本
347
+            // $apiName = 'jd.union.open.goods.promotiongoodsinfo.query';
348
+            // $params = [
349
+            //     'skuIds' => $sku['skuId'],
350
+            // ];
351
+            // $result = $this->getUrlResult($apiName, $params);
352
+            // $result = json_decode($result, true);
353
+            // $result = json_decode($result['jd_union_open_goods_promotiongoodsinfo_query_responce']['queryResult'], true);
354
+            // $result = $result['data'][0] ?? [];
355
+            // $goodsDetail = $this->doGetJtDetail($result);
356
+
357
+            $third_party_goods_detail = Db::name('third_party_goods')
358
+                ->whereLike('json', '%' . $sku . '%')
359
+                ->find();
360
+            $third_party_goods_json_detail = json_decode($third_party_goods_detail['json'], true);
361
+            $formatData = [
362
+                'goodsName' => $third_party_goods_json_detail['name'],
363
+                'imgUrl' => $third_party_goods_json_detail['imageList'][0],
364
+                'unitPrice' => $third_party_goods_json_detail['price'],//原价
365
+                'wlUnitPrice' => $third_party_goods_json_detail['lowestCouponPrice'],
366
+                'couMoney' => $third_party_goods_json_detail['coupon_money'][0]['discount'],
367
+                'nowPrice' => $third_party_goods_json_detail['lowestCouponPrice'],//现价
368
+                'detail' => $third_party_goods_json_detail['imageList'],
369
+
370
+                'commission' => $third_party_goods_json_detail['commission'],
371
+                'pv' => $third_party_goods_json_detail['pv'],
372
+                'yanglaojin' => $third_party_goods_json_detail['yanglaojin'],
373
+                'gongxian' => $third_party_goods_json_detail['gongxian'],
374
+                'jifen' => $third_party_goods_json_detail['jifen'],
375
+                'discount_link' => $third_party_goods_json_detail['coupon_link'],
376
+                'materialUrl' => ''
287
             ];
377
             ];
288
-            $result = $this->getUrlResult($apiName, $params);
289
-            $result = json_decode($result, true);
290
-            $result = json_decode($result['jd_union_open_goods_promotiongoodsinfo_query_responce']['queryResult'], true);
291
-            $result = $result['data'][0] ?? [];
292
-            $goodsDetail = $this->doGetJtDetail($result);
293
-            return app("json")->success($goodsDetail);
294
-        } catch (\Exception $e) {
295
-            Db::name('log')->insert(['data'=>'微信审核------'.$e->getMessage().$e->getFile().$e->getLine()]);
296
 
378
 
379
+            return app("json")->success([$formatData]);
380
+        } catch (\Exception $e) {
297
             return app('json')->fail('商品下架不存在', null, 401);
381
             return app('json')->fail('商品下架不存在', null, 401);
298
         }
382
         }
299
     }
383
     }
@@ -323,13 +407,32 @@ class Jd extends BaseController
323
         ];
407
         ];
324
 //        var_dump($third_party_goods_json_detail['coupon_money'][0]['link']);
408
 //        var_dump($third_party_goods_json_detail['coupon_money'][0]['link']);
325
         //加入转链地址
409
         //加入转链地址
326
-        $formatData['materialUrl'] = $this->linkChange($goodsDetail['materialUrl'], $this->request->uid(), $third_party_goods_json_detail['coupon_money'][0]['link'] ?? '');;
410
+        $formatData['materialUrl'] = $this->linkChange($goodsDetail['materialUrl'], $this->request->uid(), $third_party_goods_json_detail['coupon_money'][0]['link'] ?? '');
327
         $return[] = $formatData;
411
         $return[] = $formatData;
328
         return $return;
412
         return $return;
329
     }
413
     }
330
 
414
 
415
+    public function changLinkApi()
416
+    {
417
+        $skuId = request()->param('skuId', '');
418
+        if (empty($skuId)) {
419
+            return app('json')->fail('商品下架不存在', null, 401);
420
+        }
421
+        $uid = $this->request->uid();
422
+        if (empty($uid)) {
423
+            return app('json')->fail('请重新登录', null, 401);
424
+        }
425
+        $third_party_goods_detail = Db::name('third_party_goods')->where('type', '=', 2)->whereLike('json', '%' . $skuId . '%')->find();
426
+        $third_party_goods_json_detail = json_decode($third_party_goods_detail['json'], true);
427
+
428
+        $subUnionId = (int)($third_party_goods_json_detail['commission'] * 1000) . '_' . (int)($third_party_goods_json_detail['yanglaojin'] * 1000);
429
+        $url = $this->linkChange($third_party_goods_json_detail['materialUrl'], $uid, $third_party_goods_json_detail['coupon_link'] ?? '', $subUnionId);
430
+
431
+        return app("json")->success(['url' => $url]);
432
+    }
433
+
331
     /*转链*/
434
     /*转链*/
332
-    public function linkChange($url, $uid,$couponUrl)
435
+    public function linkChange($url, $uid,$couponUrl, $subUnionId)
333
     {
436
     {
334
 
437
 
335
         if (!$uid) {
438
         if (!$uid) {
@@ -347,8 +450,10 @@ class Jd extends BaseController
347
             'promotionCodeReq' => [
450
             'promotionCodeReq' => [
348
                 'materialId' => $url,
451
                 'materialId' => $url,
349
                 'siteId'     => $this->appid,
452
                 'siteId'     => $this->appid,
350
-                'positionId' => pow(11, 5) + $uid, //自定义,和订单关联
351
-                'couponUrl'  => $couponUrl
453
+                'positionId' => $uid, //自定义,和订单关联
454
+                'couponUrl'  => $couponUrl,
455
+                'sceneId' => 1,
456
+                'subUnionId' => $subUnionId
352
             ],
457
             ],
353
         ];
458
         ];
354
         $result = $this->getUrlResult($apiName, $params);
459
         $result = $this->getUrlResult($apiName, $params);
@@ -366,169 +471,255 @@ class Jd extends BaseController
366
 
471
 
367
         $eliteIdList = [
472
         $eliteIdList = [
368
             '1', //好券商品
473
             '1', //好券商品
369
-            '2', //精选卖场
370
-            '10', //9.9包邮
371
-            '15', //京东配送
372
-            '22', //实时热销榜
373
-//            '23', //为你推荐
374
-            '24', //数码家电
375
-            '25', //超市
376
-            '26', //母婴玩具
377
-            '27', //家具日用
378
-            '28', //美妆穿搭
379
-            '30', //图书文具
380
-            '31', //今日必推
381
-            '32', //京东好物
382
-            '33', //京东秒杀
383
-            '34', //拼购商品
384
-            '40', //高收益榜
385
-            '41', //自营热卖榜
386
-//            '108', //秒杀进行中
387
-            '109', //新品首发
388
-            '110', //自营
389
-            '112', //京东爆品
390
-            '125', //首购商品
391
-            '129', //高佣榜单
392
-//            '130', //视频商品
393
-//            '153', //历史最低价商品榜
394
-//            '238', //新人价商品
395
-//            '315', //秒杀未开始
396
-            '341', //3C新品
397
-            '342', //智能新品
398
-            '343', //3C长尾商品
399
-            '345', //时尚新品
400
-            '346', //时尚爆品
401
-//            '1001', //选品库
402
-//            '515', //订单接龙商品
403
-//            '519', //官方活动
404
-            '12254', //超级补贴
405
-            '12318', //便宜包邮
406
-            '12339', //超市卡
474
+            // '2', //精选卖场
475
+            // '10', //9.9包邮
476
+            // '15', //京东配送
477
+            // '22', //实时热销榜
478
+            // //            '23', //为你推荐
479
+            // '24', //数码家电
480
+            // '25', //超市
481
+            // '26', //母婴玩具
482
+            // '27', //家具日用
483
+            // '28', //美妆穿搭
484
+            // '30', //图书文具
485
+            // '31', //今日必推
486
+            // '32', //京东好物
487
+            // '33', //京东秒杀
488
+            // '34', //拼购商品
489
+            // '40', //高收益榜
490
+            // '41', //自营热卖榜
491
+            // //            '108', //秒杀进行中
492
+            // '109', //新品首发
493
+            // '110', //自营
494
+            // '112', //京东爆品
495
+            // // '125', //首购商品
496
+            // '129', //高佣榜单
497
+            // //            '130', //视频商品
498
+            // //            '153', //历史最低价商品榜
499
+            // //            '238', //新人价商品
500
+            // //            '315', //秒杀未开始
501
+            // '341', //3C新品
502
+            // // '342', //智能新品
503
+            // '343', //3C长尾商品
504
+            // // '345', //时尚新品
505
+            // // '346', //时尚爆品
506
+            // //            '1001', //选品库
507
+            // //            '515', //订单接龙商品
508
+            // //            '519', //官方活动
509
+            // '12254', //超级补贴
510
+            // // '12318', //便宜包邮
511
+            // '12339', //超市卡
407
         ];
512
         ];
408
-        Log::info("===============get_jd_goods_list===================");
409
-//        $eliteIdList = [1];
513
+        $maxExecutionTime = 1800; // 最大执行时间5分钟
514
+        $startTime = time();
515
+
410
         foreach ($eliteIdList as $eliteId) {
516
         foreach ($eliteIdList as $eliteId) {
411
-            $jq_query=$this->jd_query($eliteId,1);
412
-            $yema=(int)ceil($jq_query['totalCount']/50);
413
-            for ($page = 1; $page <= $yema; $page++) {
414
-                $result=$this->jd_query($eliteId,$page);
415
-                if(isset($result['data']) && $result['data']){
416
-                    $this->formatGoodsList($result['data']);
417
-                }
517
+            // 检查是否超时
518
+            if (time() - $startTime > $maxExecutionTime) {
519
+                log::info("JD API error (eliteId:{$eliteId}): timeout");
520
+                break; // 或记录日志
521
+            }
522
+
523
+            $page = 1;
524
+            $maxPage = 1; // 默认值
525
+
526
+            Db::startTrans();
527
+            try {
528
+                // 清除数据
529
+                Db::name("third_party_goods")->where('type', '=', 2)->where('cid', '=', $eliteId)->delete();
530
+                do {
531
+                    try {
532
+                        $result = $this->jd_query($eliteId, $page);
533
+                        // 安全退出条件
534
+                        if (empty($result) || !is_array($result)) {
535
+                            break;
536
+                        }
537
+                        // 首次请求获取总页数
538
+                        if ($page === 1 && isset($result['totalCount'])) {
539
+                            // $maxPage = max(1, (int)ceil($result['totalCount'] / 50));
540
+                        }
541
+                        // 处理数据
542
+                        if (!empty($result['data'])) {
543
+                            // 写入数据
544
+                            $this->formatGoodsList($result['data'], $eliteId);
545
+                        }
546
+                        $page++;
547
+                    } catch (\Exception $e) {
548
+                        // 记录错误并继续下一个分类
549
+                        log::info("JD API error (eliteId:{$eliteId}, page:{$page}): " . $e->getMessage());
550
+                        break;
551
+                    }
552
+                } while ($page <= $maxPage);
553
+                Db::commit();
554
+            } catch (DbException $e) {
555
+                Db::startTrans();
418
             }
556
             }
419
         }
557
         }
558
+
420
         return 'ok';
559
         return 'ok';
421
     }
560
     }
422
     //请求京东联盟接口描述:京东联盟精选优质商品,每日更新,可通过频道ID查询各个频道下的精选商品。用获取的优惠券链接调用转链接口时,需传入搜索接口link字段返回的原始优惠券链接,切勿对链接进行任何encode、decode操作,否则将导致转链二合一推广链接时校验失败。
561
     //请求京东联盟接口描述:京东联盟精选优质商品,每日更新,可通过频道ID查询各个频道下的精选商品。用获取的优惠券链接调用转链接口时,需传入搜索接口link字段返回的原始优惠券链接,切勿对链接进行任何encode、decode操作,否则将导致转链二合一推广链接时校验失败。
423
-    public function jd_query($eliteId,$page){
562
+    public function jd_query($eliteId, $page)
563
+    {
424
         $apiName = 'jd.union.open.goods.jingfen.query';
564
         $apiName = 'jd.union.open.goods.jingfen.query';
425
         $params = [
565
         $params = [
426
             'goodsReq' => [
566
             'goodsReq' => [
427
-                'eliteId'   => $eliteId,
567
+                'eliteId' => $eliteId,
428
                 'pageIndex' => $page ?? 1,
568
                 'pageIndex' => $page ?? 1,
429
-                'pageSize'  => 50,
569
+                'pageSize' => 10,
430
             ]
570
             ]
431
         ];
571
         ];
432
         $result = $this->getUrlResult($apiName, $params);
572
         $result = $this->getUrlResult($apiName, $params);
433
         $result = json_decode($result, true);
573
         $result = json_decode($result, true);
434
 
574
 
435
         $result = json_decode($result['jd_union_open_goods_jingfen_query_responce']['queryResult'], true);
575
         $result = json_decode($result['jd_union_open_goods_jingfen_query_responce']['queryResult'], true);
436
-//        $result = $result['data'] ?? [];
576
+        //        $result = $result['data'] ?? [];
437
         return $result;
577
         return $result;
438
     }
578
     }
439
 
579
 
440
     //格式化从京东联盟获取到的商品列表
580
     //格式化从京东联盟获取到的商品列表
441
-    public function formatGoodsList($goodsList)
581
+    public function formatGoodsList($goodsList, $eliteId)
442
     {
582
     {
443
         $install = [];
583
         $install = [];
444
         foreach ($goodsList as $goods) {
584
         foreach ($goodsList as $goods) {
445
-            $commissionMoney = $goods['commissionInfo']['couponCommission'] ?? 0;
446
-            //养老金
447
-            $oldMoney = app()->make(ProductRepository::class)->yanglaojin(0, $commissionMoney);
448
-//            var_dump($goods);
449
-//            return;
450
-            if ($oldMoney < 0.1) continue;
451
-            if (!isset($goods['couponInfo']['couponList'][0])) continue;
452
-            foreach ($goods['couponInfo']['couponList'] as $coupon){
585
+            // 售价
586
+            if (!isset($goods['priceInfo']['price'])) {
587
+                continue;
588
+            }
453
 
589
 
590
+            // 获取最优优惠券信息
591
+            // 优惠券信息
592
+            $maxCoupon = [];
593
+            if (!empty($goods['couponInfo']['couponList'])) {
594
+                foreach ($goods['couponInfo']['couponList'] as $coupon) {
595
+                    // isBest 最优 优惠券
596
+                    if ($coupon['isBest'] == 1) {
597
+                        $maxCoupon = [
598
+                            'discount' => $coupon['discount'],//优惠券金额
599
+                            'getStartTime' => date('Y-m-d', intval($coupon['getStartTime'] / 1000)),
600
+                            'getEndTime' => date('Y-m-d', intval($coupon['getEndTime'] / 1000)),
601
+                            'link' => $coupon['link'],
602
+                            'useStartTime' => date('Y-m-d', intval($coupon['useStartTime'] / 1000)),
603
+                            'useEndTime' => date('Y-m-d', intval($coupon['useEndTime'] / 1000)),
604
+                        ];
605
+                        break;
606
+                    }
607
+                }
608
+            }
609
+
610
+            // 最低到手价
611
+            $purchasePrice = $goods['priceInfo']['price'];
612
+            // 券后价
613
+            if (!empty($maxCoupon['discount'])) {
614
+                // 拥有优惠券
615
+                $purchasePrice = bcsub($goods['priceInfo']['price'], $maxCoupon['discount'], 2);
616
+            }
617
+            // 到手价
618
+            if (!empty($goods['purchasePriceInfo']['purchasePrice']) && $goods['purchasePriceInfo']['purchasePrice'] < $purchasePrice) {
619
+                $purchasePrice = $goods['purchasePriceInfo']['purchasePrice'];
454
             }
620
             }
455
-            $goods['couponInfo']['couponList'][0]['getStartTime'] = date('Y-m-d', intval($goods['couponInfo']['couponList'][0]['getStartTime'] / 1000));
456
-            $goods['couponInfo']['couponList'][0]['getEndTime'] = date('Y-m-d', intval($goods['couponInfo']['couponList'][0]['getEndTime'] / 1000));
621
+
622
+            // 券后佣金,(促销价-优惠券面额)*佣金比例
623
+            $commissionMoney = bcmul($purchasePrice, bcdiv($goods['commissionInfo']['commissionShare'] ?? 0.00, 100, 5), 2);
624
+            $commissionMoney = bcmul($commissionMoney, 0.8, 2);
625
+
457
             $formatList = [
626
             $formatList = [
458
-                'type'              => 6,//京东商品
459
-                'skuId'             => $goods['skuId'],//skuid
460
-                'id'                => $goods['brandCode'] ?? '', //id
461
-                'thumb'             => $goods['imageInfo']['imageList'][0]['url'] ?? '',//商品缩略图
462
-                'name'              => $goods['skuName'],//名称
463
-                'commission'        => $oldMoney,//佣金
464
-                'commission_rate'   => $goods['commissionInfo']['commissionShare'] ?? '',//佣金比例
465
-                'sales'             => "",
466
-                'coupon_money'      => $goods['couponInfo']['couponList'] ?? [],
467
-                'lowestCouponPrice' => decimal2($goods['priceInfo']['lowestCouponPrice']), //券后价lowestCouponPrice
468
-                'price'             => $goods['priceInfo']['price'], //价格
469
-                'imageList'         => array_column($goods['imageInfo']['imageList'], 'url'), //图片合集
627
+                'type' => 6,//京东商品
628
+                'skuId' => $goods['itemId'] ?? '',//itemId 京东官方 已不返回skuId , 使用 联盟商品ID 代替skuId
629
+                'id' => $goods['brandCode'] ?? '', //id
630
+                'name' => $goods['skuName'],//名称
631
+                'thumb' => $goods['imageInfo']['imageList'][0]['url'] ?? '',//商品缩略图
632
+
633
+                'pv' => bcmul($commissionMoney, 0.7, 2),//PV金额
634
+                'gongxian' => bcmul($commissionMoney, 0.7, 2),
635
+                'jifen' => bcmul($commissionMoney, 0.7, 2),
636
+                'yanglaojin' => bcmul($commissionMoney, 0.3, 2),
637
+
638
+                'commission' => $commissionMoney,//佣金
639
+                'commission_rate' => $goods['commissionInfo']['commissionShare'] ?? 0.00,//佣金比例
640
+                'coupon_money' => empty($maxCoupon) ? [] : [$maxCoupon],
641
+                'coupon_link' => $maxCoupon['link'] ?? '',
642
+                'lowestCouponPrice' => $purchasePrice,
643
+                'price' => $goods['priceInfo']['price'], //价格
644
+                'imageList' => array_column($goods['imageInfo']['imageList'], 'url'), //图片合集
645
+                'materialUrl' => $goods['materialUrl']
470
             ];
646
             ];
471
-            $install[]=['json' => json_encode($formatList, JSON_UNESCAPED_UNICODE), 'pension' => $oldMoney, 'type' => 2];
472
-//            Db::name("third_party_goods")->insert(['json' => json_encode($formatList, JSON_UNESCAPED_UNICODE), 'pension' => $oldMoney, 'type' => 2]);
647
+            $install[] = ['json' => json_encode($formatList, JSON_UNESCAPED_UNICODE), 'pension' => $commissionMoney, 'type' => 2, 'cid' => $eliteId];
473
         }
648
         }
474
-        if($install){
649
+        if ($install) {
475
             Db::name("third_party_goods")->insertAll($install);
650
             Db::name("third_party_goods")->insertAll($install);
476
         }
651
         }
477
-
478
-//        return $formatList;
479
     }
652
     }
480
 
653
 
481
     /*订单获取(时间段,时间不能超过一小时)*/
654
     /*订单获取(时间段,时间不能超过一小时)*/
482
     public function orderList()
655
     public function orderList()
483
     {
656
     {
484
-        $time = $this->request->params([
485
-            'startTime',
486
-            'endTime'
487
-        ]);
488
-        //自定义时间  每20分钟执行一次查询前半小时的数据
657
+        // $time = $this->request->params([
658
+        //     'startTime',
659
+        //     'endTime'
660
+        // ]);
661
+        $time['startTime'] = request()->param('startTime', '');
662
+        $time['endTime'] = request()->param('endTime', '');
489
         if (!$time['startTime'] && !$time['endTime']) {
663
         if (!$time['startTime'] && !$time['endTime']) {
490
-            $time['startTime'] = date("Y-m-d H:i:s", strtotime("-200 minute"));
491
-            $time['endTime'] = date('Y-m-d H:i:s');
664
+            // $time['startTime'] = date("Y-m-d H:i:s", strtotime("-1 hour"));
665
+            // $time['endTime'] = date('Y-m-d H:i:s');
666
+            // 获取当前时间
667
+            $currentTime = new DateTime();
668
+
669
+            // 生成时间范围数组
670
+            $timeRanges = [];
671
+            for ($i = 0; $i < 30 * 24; $i++) {
672
+                $endTime = clone $currentTime;
673
+                $endTime->modify("-$i hour");
674
+
675
+                $startTime = clone $endTime;
676
+                $startTime->modify("-1 hour");
677
+                $startTime->modify("+1 second");
678
+
679
+                $timeRanges[] = [
680
+                    'startTime' => $startTime->format('Y-m-d H:i:s'),
681
+                    'endTime' => $endTime->format('Y-m-d H:i:s')
682
+                ];
683
+            }
684
+        } else {
685
+            $timeRanges[] = $time;
492
         }
686
         }
493
-//        var_dump($time);
494
         try {
687
         try {
495
-            $orderLists = [];
496
-            $page = 1;
497
-            $pageSize = 40;
498
-            $apiName = 'jd.union.open.order.row.query';
499
-            do {
500
-                $params = [
501
-                    'orderReq' => [
502
-                        'pageNo'    => $page,
503
-                        'pageSize'  => $pageSize,
504
-                        'type'      => 3,//(1:下单时间,2:完成时间(购买用户确认收货时间),3:更新时间
505
-                        'startTime' => $time['startTime'],//格式2020-01-02 21:23:00
506
-                        'endTime'   => $time['endTime'] //格式2020-01-02 21:24:00
507
-                    ],
508
-                ];
509
-                $result = $this->getUrlResult($apiName, $params);
510
-//                var_dump($result);
511
-                $result = json_decode($result, true);
512
-                $result = json_decode($result['jd_union_open_order_row_query_responce']['queryResult'], true);
513
-                $lists = $result['data'];
514
-                $countList = count($lists);
515
-                if (!empty($countList)) {
516
-                    $orderLists = array_merge($orderLists, $lists);
517
-                }
688
+            foreach ($timeRanges as $time) {
689
+                $orderLists = [];
690
+                $page = 1;
691
+                $pageSize = 200;
692
+                $apiName = 'jd.union.open.order.row.query';
693
+                do {
694
+                    $params = [
695
+                        'orderReq' => [
696
+                            'pageIndex' => $page,
697
+                            'pageSize' => $pageSize,
698
+                            'type' => 3,//(1:下单时间,2:完成时间(购买用户确认收货时间),3:更新时间
699
+                            'startTime' => $time['startTime'],//格式2020-01-02 21:23:00
700
+                            'endTime' => $time['endTime'], //格式2020-01-02 21:24:00
701
+                            'fields' => 'goodsInfo'
702
+                        ],
703
+                    ];
704
+                    $result = $this->getUrlResult($apiName, $params);
705
+                    $result = json_decode($result, true);
706
+                    $result = json_decode($result['jd_union_open_order_row_query_responce']['queryResult'], true);
707
+                    $lists = $result['data'] ?? [];
708
+                    $countList = count($lists);
709
+                    if (!empty($countList)) {
710
+                        $orderLists = array_merge($orderLists, $lists);
711
+                    }
518
 
712
 
519
-//                var_dump($result);
520
-                $page++;
521
-            } while ($countList == $pageSize);
522
-            if (!empty($orderLists)) {
523
-                //格式化从京东拉取的订单列表
524
-                $formatLists = $this->formatOrderList($orderLists);
525
-//                var_dump($formatLists);
526
-                //将京东订单列表中的订单进行处理
527
-                $this->operatePinOrder($formatLists);
528
-                return app("json")->success("京东订单写入成功");
529
-            } else {
530
-                return app("json")->success("暂无最新数据");
713
+                    $page++;
714
+                } while ($countList == $pageSize && $result['hasMore'] ?? false);
715
+                if (!empty($orderLists)) {
716
+                    //格式化从京东拉取的订单列表
717
+                    $formatLists = $this->formatOrderList($orderLists);
718
+                    //将京东订单列表中的订单进行处理
719
+                    $this->operatePinOrder($formatLists);
720
+                }
531
             }
721
             }
722
+            return app("json")->success("京东订单写入成功");
532
         } catch (\Exception $e) {
723
         } catch (\Exception $e) {
533
             return app("json")->fail($e->getMessage());
724
             return app("json")->fail($e->getMessage());
534
         }
725
         }
@@ -538,8 +729,7 @@ class Jd extends BaseController
538
     //格式化从京东拉取的订单列表
729
     //格式化从京东拉取的订单列表
539
     public function formatOrderList($orderLists)
730
     public function formatOrderList($orderLists)
540
     {
731
     {
541
-//        $user = app()->make(UserThirdRepository::class);
542
-        $formatLists = [];
732
+        $formatList = [];
543
         foreach ($orderLists as $order) {
733
         foreach ($orderLists as $order) {
544
             switch ($order['validCode']) {
734
             switch ($order['validCode']) {
545
                 case 15://待付款订单
735
                 case 15://待付款订单
@@ -554,92 +744,136 @@ class Jd extends BaseController
554
                 default://失效订单
744
                 default://失效订单
555
                     $billStatus = 2;
745
                     $billStatus = 2;
556
             }
746
             }
557
-            if($order['validCode']==15){ //未支付的不处理
747
+            if ($order['validCode'] == 15) { //未支付的不处理
558
                 continue;
748
                 continue;
559
             }
749
             }
560
             //通过订单关联
750
             //通过订单关联
561
             $positionId = $order['positionId'];
751
             $positionId = $order['positionId'];
562
-            $userId = $positionId - pow(11, 5);
563
-            //订单关联推广位ID
564
-//            $pid = $order['subUnionId'] ?: '';
565
-            // if (empty($pid)) continue;
566
-            //订单关联推广位ID
567
-//            $chanTag = $user->getDetail(['pid' => $order['subUnionId'], 'type' => 6], 'uid,pid');
568
-            //if(!$chanTag){continue;}
569
-            $formatLists[] = [
570
-                'uid'              => $userId,
571
-                'sku_id'           => $order['skuId'],
572
-                'jd_id'            => $order['id'],
573
-                'order_sn'         => $order['orderId'],                              //订单编号
574
-                'sku_num'          => $order['skuNum'],                               //购买商品的数量
575
-                'image_url'        => $order['goodsInfo']['imageUrl'] ?? '',
576
-                'sku_name'         => $order['skuName'],
577
-                //订单中sku的单件价格,单位为分
578
-                'price'            => $order['price'],
579
-                //未知,2.无效-拆单,3.无效-取消,4.无效-京东帮帮主订单,5.无效-账号异常,6.无效-赠品类目不返佣,7.无效-校园订单,
580
-                //8.无效-企业订单,9.无效-团购订单,11.无效-乡村推广员下单,13.无效-违规订单,14.无效-来源与备案网址不符,
581
-                //15.待付款,16.已付款,17.已完成(购买用户确认收货),20.无效-此复购订单对应的首购订单无效,21.无效-云店订单',
582
-                'status'           => $order['validCode'],
583
-                //商家信息
584
-                'shop_id'          => $order['goodsInfo']['shopId'],
585
-                //订单生成时间
586
-                'create_time'      => $order['orderTime'] ? $order['orderTime'] : 0,  //下单时间
587
-                'finish_time'      => $order['finishTime'] ? $order['finishTime'] : 0,//完成时间
588
-                'modify_time'      => $order['modifyTime'] ? $order['modifyTime'] : 0,//更新时间
589
-                'sub_union_id'     => $order['subUnionId'],                           //订单关联推广位ID
590
-                //佣金比例
591
-                'commission_share' => $order['finalRate'],                            //最终分佣比例
592
-                //实际佣金
593
-                'commission'       => $order['estimateFee'],
594
-                'bill_status'      => $billStatus,        //平台是否结算
595
-                'type'             => 2
752
+            $userId = $positionId;
753
+            if ($userId <= 0) {//拉取的订单没有匹配到用户
754
+                continue;
755
+            }
756
+
757
+            //订单实际计算佣金的金额(订单完成时,会将误扣除的运费券金额更正,如订单完成后发生退款,此金额会更新)
758
+            $goodsInfo = $order['goodsInfo'] ?? [];
759
+            $createTime = strtotime($order['orderTime']);
760
+            //平台可以进行结算的时间戳=订单创建时间+系统设置的间隔时间
761
+            $billEndTime = $this->userThird->getSettleTime($createTime);
762
+
763
+            $address = Db::name('user_address')->field('code_list,village_id')->where('uid', $userId)->where('is_default', 1)->find();
764
+
765
+            $commission = $order['actualFee'] ?: $order['estimateFee'];
766
+            // 生成推广链接时自定义放里边的参数(佣金_养老金)
767
+            if (!empty($order['subUnionId'])) {
768
+                $subUnionIdList = explode('_', $order['subUnionId']);
769
+                if (!empty($subUnionIdList[0])) {
770
+                    $commission = bcdiv($subUnionIdList[0], 1000, 2);
771
+                }
772
+            }
773
+            $formatList[] = [
774
+                'uid' => $userId,
775
+                'commission' => $commission,//佣金
776
+                'commission_share' => $order['finalRate'],
777
+                'order_sn' => $order['orderId'],
778
+                'pay_money' => $order['actualCosPrice'] ?: $order['estimateCosPrice'],
779
+                'jd_id' => $order['id'],
780
+                'create_time' => $order['orderTime'],
781
+                'finish_time' => $order['finishTime'],//用户确认收货时间
782
+                'modify_time' => $order['modifyTime'],//更新时间
783
+                'sku_num' => $order['skuNum'],
784
+                'sku_id' => $order['itemId'] ?? '', // 目前京东官方不返回 skuId
785
+                'sku_name' => $order['skuName'],
786
+                'price' => $order['price'],//原价
787
+                'sub_union_id' => $order['positionId'],
788
+                'image_url' => $goodsInfo['imageUrl'] ?? '',
789
+                'shop_name' => $goodsInfo['shopName'] ?? '京东',
790
+                'shop_id' => $goodsInfo['shopId'] ?? 0,
791
+                'status' => $order['validCode'],//订单状态
792
+                'bill_status' => $billStatus,        //平台是否结算
793
+                'bill_end_time' => $billEndTime,
794
+                'user_address_ids' => !empty($address) ? $address['code_list'] . ',' . $address['village_id'] : '',
795
+                'type' => 1
596
             ];
796
             ];
597
         }
797
         }
598
-        return $formatLists;
798
+        return $formatList;
599
     }
799
     }
600
 
800
 
601
     //将拼多多订单列表中的订单写入第三方平台订单表
801
     //将拼多多订单列表中的订单写入第三方平台订单表
602
     public function operatePinOrder($orderLists)
802
     public function operatePinOrder($orderLists)
603
     {
803
     {
804
+        /** @var UserThirdRepository $orderThird */
604
         $orderThird = app()->make(UserThirdRepository::class);
805
         $orderThird = app()->make(UserThirdRepository::class);
806
+        $type_shop = 6;
605
         foreach ($orderLists as $k => $order) {
807
         foreach ($orderLists as $k => $order) {
606
             if (empty($order)) continue;
808
             if (empty($order)) continue;
607
             //判断数据库有无此订单
809
             //判断数据库有无此订单
608
-            $orderVip = $orderThird->getOrderDetail("order_jd", ['order_sn' => $order['order_sn'], 'sub_union_id' => $order['sub_union_id']]);
609
-            if (!$orderVip) {
610
-                // 读取商品详情 拿到商品图
611
-                $third_party_goods_detail = Db::name('third_party_goods')->whereLike('json', '%' . $order['sku_id'] . '%')->find();
612
-                $third_party_goods_json_detail = json_decode($third_party_goods_detail['json'], true);
613
-                $order['image_url'] =  $third_party_goods_json_detail['thumb']??'';
614
-
615
-                $orderThird->createOrder('order_jd', $order, strtotime($order['create_time'])); //订单写入数据库
810
+            $localOrder = JdOrderModel::getInstance()->getOne(['order_sn' => $order['order_sn']]);
811
+            if (empty($localOrder)) {
812
+                //订单写入数据库,bill_end_time再格式化订单的时候已经加入,所以写入订单的时候就不需要在计算了
813
+                $localOrder = JdOrderModel::create($order);
616
                 //预估养老金
814
                 //预估养老金
617
                 $orderThird->yuguOrder(
815
                 $orderThird->yuguOrder(
618
-                    $order['jd_id'],
619
-                    $order['commission'],
620
-                    $order['uid'],
621
-                    $order['order_sn'],
622
-                    6,
816
+                    $localOrder['order_jd_id'],
817
+                    $localOrder['commission'],
818
+                    $localOrder['uid'],
819
+                    $localOrder['order_sn'],
820
+                    $type_shop,
623
                     'order_jd');
821
                     'order_jd');
624
                 //预估积分
822
                 //预估积分
625
                 $orderThird->yuguJifen(
823
                 $orderThird->yuguJifen(
626
-                    $order['jd_id'],
627
-                    $order['commission'],
628
-                    $order['uid'],
629
-                    $order['order_sn'],
630
-                    6
824
+                    $localOrder['order_jd_id'],
825
+                    $localOrder['commission'],
826
+                    $localOrder['uid'],
827
+                    $localOrder['order_sn'],
828
+                    $type_shop
631
                 );
829
                 );
632
             } else {
830
             } else {
633
-                //更新
634
-                if ($orderVip['status'] != $order['status']) {
635
-                    $saveOrderPdd['status'] = $order['status'];
636
-                    if(isset($order['bill_status'])){
637
-                        $saveOrderPdd['bill_status'] = $order['bill_status'];
831
+                if($localOrder['status']!=$order['status']) {
832
+                    $localOrder->save($order);//更新订单信息
833
+                    if(!in_array($order['status'],[15,16,17])){
834
+                        //修改积分和贡献,yanglaojin值记录
835
+                        $orderThird->updateJilu(
836
+                            $localOrder['uid'],
837
+                            $localOrder['order_jd_id'],
838
+                            $type_shop);
638
                     }
839
                     }
639
-                    $orderThird->saveOrder("order_jd", ['order_jd_id' => $orderVip['order_jd_id']], $saveOrderPdd); //修改订单
640
                 }
840
                 }
641
             }
841
             }
642
 
842
 
843
+            // $orderVip = $orderThird->getOrderDetail("order_jd", ['order_sn' => $order['order_sn'], 'sub_union_id' => $order['sub_union_id']]);
844
+            // if (!$orderVip) {
845
+            //     // 读取商品详情 拿到商品图
846
+            //     $third_party_goods_detail = Db::name('third_party_goods')->whereLike('json', '%' . $order['sku_id'] . '%')->find();
847
+            //     $third_party_goods_json_detail = json_decode($third_party_goods_detail['json'], true);
848
+            //     $order['image_url'] =  $third_party_goods_json_detail['thumb']??'';
849
+            //
850
+            //     $orderThird->createOrder('order_jd', $order, strtotime($order['create_time'])); //订单写入数据库
851
+            //     //预估养老金
852
+            //     $orderThird->yuguOrder(
853
+            //         $order['jd_id'],
854
+            //         $order['commission'],
855
+            //         $order['uid'],
856
+            //         $order['order_sn'],
857
+            //         6,
858
+            //         'order_jd');
859
+            //     //预估积分
860
+            //     $orderThird->yuguJifen(
861
+            //         $order['jd_id'],
862
+            //         $order['commission'],
863
+            //         $order['uid'],
864
+            //         $order['order_sn'],
865
+            //         6
866
+            //     );
867
+            // } else {
868
+            //     //更新
869
+            //     if ($orderVip['status'] != $order['status']) {
870
+            //         $saveOrderPdd['status'] = $order['status'];
871
+            //         if(isset($order['bill_status'])){
872
+            //             $saveOrderPdd['bill_status'] = $order['bill_status'];
873
+            //         }
874
+            //         $orderThird->saveOrder("order_jd", ['order_jd_id' => $orderVip['order_jd_id']], $saveOrderPdd); //修改订单
875
+            //     }
876
+            // }
643
         }
877
         }
644
     }
878
     }
645
 
879
 

+ 1 - 1
app/controller/api/store/product/TaoKe.php

@@ -178,7 +178,7 @@ class TaoKe extends BaseController
178
         if($keyword && !isset($params['pid'])){
178
         if($keyword && !isset($params['pid'])){
179
             $params['keyword']=$keyword;
179
             $params['keyword']=$keyword;
180
             $params['custom_parameters']="{'new':1}";
180
             $params['custom_parameters']="{'new':1}";
181
-            return app('json')->success('未查询到商品', []);
181
+            // return app('json')->success('未查询到商品', []);
182
         }
182
         }
183
 
183
 
184
         $params['cat_id'] = $cat_id;
184
         $params['cat_id'] = $cat_id;

+ 32 - 0
app/controller/api/user/User.php

@@ -857,6 +857,28 @@ class User extends BaseController
857
     }
857
     }
858
 
858
 
859
     /**
859
     /**
860
+     * 查询商品浏览记录以及删除
861
+     */
862
+    public function productHistory(){
863
+        $uid = $this->request->uid();
864
+        $list = Db::name('third_history')->where('uid', $uid)->order('create_time', 'desc')->limit(20)->column('keyword','id');
865
+        return app('json')->success(['count' => count($list), 'list'  => $list]);
866
+    }
867
+    public function deleteProductHistory(){
868
+        $uid = $this->request->uid();
869
+        $id = $this->request->post('id');
870
+        $deleted = Db::name('third_history')
871
+            ->where('id', $id)
872
+            ->where('uid', $uid)
873
+            ->delete();
874
+        if ($deleted) {
875
+            return app('json')->success('删除成功');
876
+        } else {
877
+            return app('json')->fail('删除失败');
878
+        }
879
+    }
880
+
881
+    /**
860
      * 签到  获取积分
882
      * 签到  获取积分
861
      * @return mixed
883
      * @return mixed
862
      * @throws \think\db\exception\DataNotFoundException
884
      * @throws \think\db\exception\DataNotFoundException
@@ -2996,9 +3018,19 @@ class User extends BaseController
2996
             'yanglao_a' => round($this->num($dy, 'yanglao_a'), 2),
3018
             'yanglao_a' => round($this->num($dy, 'yanglao_a'), 2),
2997
         );
3019
         );
2998
 
3020
 
3021
+        // 扣减
3022
+
3023
+        $kouchu = \think\facade\Db::name('user_bill')
3024
+            ->where('pm', '=', 0)
3025
+            ->where('status', '<>', '-1')
3026
+            ->where(['uid' => $uid, 'commission_type' => '5', 'source' => 0])
3027
+            ->sum('number');
3028
+
2999
         $data['all_num'] = $data['offLine']['num'] +$data['onLine_take_no']['num'] + $data['onLine']['num'] + $data['tb']['num'] + $data['jd']['num'] + $data['su']['num'] + $data['pdd']['num'] + $data['vip']['num'] + $data['dy']['num'];
3029
         $data['all_num'] = $data['offLine']['num'] +$data['onLine_take_no']['num'] + $data['onLine']['num'] + $data['tb']['num'] + $data['jd']['num'] + $data['su']['num'] + $data['pdd']['num'] + $data['vip']['num'] + $data['dy']['num'];
3000
         $data['all_yanglao'] = round($data['offLine']['yanglao']+$data['onLine']['yanglao'] + $data['onLine_take_no']['yanglao'] + $data['tb']['yanglao'] + $data['jd']['yanglao'] + $data['su']['yanglao'] + $data['pdd']['yanglao'] + $data['vip']['yanglao'] + $data['dy']['yanglao'], 2);
3030
         $data['all_yanglao'] = round($data['offLine']['yanglao']+$data['onLine']['yanglao'] + $data['onLine_take_no']['yanglao'] + $data['tb']['yanglao'] + $data['jd']['yanglao'] + $data['su']['yanglao'] + $data['pdd']['yanglao'] + $data['vip']['yanglao'] + $data['dy']['yanglao'], 2);
3031
+        $data['all_yanglao'] -= $kouchu;
3001
         $data['all_yanglao_a'] = round($data['offLine']['yanglao'] + $data['onLine']['yanglao'] + $data['tb']['yanglao_a'] + $data['jd']['yanglao_a'] + $data['su']['yanglao_a'] + $data['pdd']['yanglao_a'] + $data['vip']['yanglao_a'] + $data['dy']['yanglao_a'], 2);
3032
         $data['all_yanglao_a'] = round($data['offLine']['yanglao'] + $data['onLine']['yanglao'] + $data['tb']['yanglao_a'] + $data['jd']['yanglao_a'] + $data['su']['yanglao_a'] + $data['pdd']['yanglao_a'] + $data['vip']['yanglao_a'] + $data['dy']['yanglao_a'], 2);
3033
+        $data['all_yanglao_a'] -= $kouchu;
3002
         $data['third_party_num']=['all_num'=>$data['tb']['num']+$data['jd']['num']+$data['su']['num']+ $data['pdd']['num'] + $data['vip']['num']+ $data['dy']['num']];
3034
         $data['third_party_num']=['all_num'=>$data['tb']['num']+$data['jd']['num']+$data['su']['num']+ $data['pdd']['num'] + $data['vip']['num']+ $data['dy']['num']];
3003
         $data['third_party_num_a']=['all_num_a'=>$data['tb']['num_a']+$data['jd']['num_a']+$data['su']['num_a']+ $data['pdd']['num_a'] + $data['vip']['num_a']+ $data['dy']['num_a']];
3035
         $data['third_party_num_a']=['all_num_a'=>$data['tb']['num_a']+$data['jd']['num_a']+$data['su']['num_a']+ $data['pdd']['num_a'] + $data['vip']['num_a']+ $data['dy']['num_a']];
3004
         $data['third_party_num_n']=['all_num_n'=>$data['third_party_num']['all_num']-$data['third_party_num_a']['all_num_a']];
3036
         $data['third_party_num_n']=['all_num_n'=>$data['third_party_num']['all_num']-$data['third_party_num_a']['all_num_a']];

+ 1 - 1
config/admin.php

@@ -8,7 +8,7 @@
8
 
8
 
9
 return [
9
 return [
10
     //token 有效期
10
     //token 有效期
11
-    'token_exp' => 30000, //三小时
11
+    'token_exp' => 720, //三小时
12
     //token超时多久可自动续期
12
     //token超时多久可自动续期
13
     'token_valid_exp' => 15, //15分钟
13
     'token_valid_exp' => 15, //15分钟
14
     //登录验证码有效期
14
     //登录验证码有效期

+ 2 - 2
crmeb/services/JwtTokenService.php

@@ -33,7 +33,7 @@ class JwtTokenService
33
     {
33
     {
34
         $time = time();
34
         $time = time();
35
         $host = app('request')->host();
35
         $host = app('request')->host();
36
-        $exp = intval(Config::get('admin.token_ext', 3000));
36
+        $exp = intval(Config::get('admin.token_exp', 720));
37
         $params += [
37
         $params += [
38
             'iss' => $host,
38
             'iss' => $host,
39
             'aud' => $host,
39
             'aud' => $host,
@@ -44,7 +44,7 @@ class JwtTokenService
44
         $params['jti'] = [$id, $type];
44
         $params['jti'] = [$id, $type];
45
         $token = JWT::encode($params, Config::get('app.app_key', 'default'));
45
         $token = JWT::encode($params, Config::get('app.app_key', 'default'));
46
         $params['token'] = $token;
46
         $params['token'] = $token;
47
-        $params['out'] = 3000 * 60 * 60;
47
+        $params['out'] = $time + (720 * 60 * 60);
48
         return $params;
48
         return $params;
49
     }
49
     }
50
 
50
 

+ 26 - 23
route/api.php

@@ -227,6 +227,9 @@ Route::group('api/', function () {
227
             //浏览记录
227
             //浏览记录
228
             Route::get('history', 'User/history');
228
             Route::get('history', 'User/history');
229
             Route::post('history/delete/:id', 'User/deleteHistory');
229
             Route::post('history/delete/:id', 'User/deleteHistory');
230
+            //商品浏览记录以及删除
231
+            Route::post('productHistory', 'User/productHistory');
232
+            Route::post('deleteProductHistory', 'User/deleteProductHistory');
230
             //获取用户签到记录
233
             //获取用户签到记录
231
             Route::get('get_signin', 'User/get_signin');
234
             Route::get('get_signin', 'User/get_signin');
232
             //签到
235
             //签到
@@ -378,18 +381,6 @@ Route::group('api/', function () {
378
         //筛选
381
         //筛选
379
         Route::get('pdd/search', 'api.store.product.TaoKe/search');
382
         Route::get('pdd/search', 'api.store.product.TaoKe/search');
380
 
383
 
381
-        // 京东
382
-        if(false){
383
-            // 京东联盟
384
-            Route::get('jd/detail', 'api.store.product.Jd/jdDetail');
385
-            Route::get('jd/search', 'api.store.product.Jd/search');
386
-        }else{
387
-            /*京东商品详情*/
388
-            Route::get('jd/detail', 'api.store.product.Jt/goodsDetail')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);//京推推
389
-            Route::get('jd/chang_link', 'api.store.product.Jt/changLinkApi')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);//京推推
390
-            Route::get('jd/search', 'api.store.product.Jt/search');//京推推
391
-        }
392
-
393
         /*淘宝详情*/
384
         /*淘宝详情*/
394
         Route::get('tb/detail/:id', 'api.store.product.TaoBao/goodsDetail');
385
         Route::get('tb/detail/:id', 'api.store.product.TaoBao/goodsDetail');
395
         //淘宝详情立即购买
386
         //淘宝详情立即购买
@@ -644,6 +635,8 @@ Route::group('api/', function () {
644
 
635
 
645
     //非强制登录
636
     //非强制登录
646
     Route::group(function () {
637
     Route::group(function () {
638
+        // 将 所有用户 令牌设置为失效
639
+        Route::get('invalidateAllTokens', 'api.Auth/invalidateAllTokens');
647
 
640
 
648
         //商学院管理
641
         //商学院管理
649
         Route::group('business_school', function () {
642
         Route::group('business_school', function () {
@@ -736,6 +729,7 @@ Route::group('api/', function () {
736
             //店铺列表
729
             //店铺列表
737
             Route::get('listindex', 'Merchant/listindex');
730
             Route::get('listindex', 'Merchant/listindex');
738
             Route::get('/product/lst/:id', 'Merchant/productList');
731
             Route::get('/product/lst/:id', 'Merchant/productList');
732
+            Route::get('/product/getProductList', 'Merchant/getProductList');
739
             Route::get('/product/type_lst', 'Merchant/productTypeList');//特殊-根据商户查询商品
733
             Route::get('/product/type_lst', 'Merchant/productTypeList');//特殊-根据商户查询商品
740
             Route::get('/product/commerce_list', 'Merchant/commerceProductList');//特殊-根据商户查询商品
734
             Route::get('/product/commerce_list', 'Merchant/commerceProductList');//特殊-根据商户查询商品
741
             Route::get('/areaProduct/lst', 'Merchant/areaProductList');
735
             Route::get('/areaProduct/lst', 'Merchant/areaProductList');
@@ -944,6 +938,8 @@ Route::group('api/', function () {
944
     Route::post('auth/yijianlogin', 'api.Auth/yijianlogin');
938
     Route::post('auth/yijianlogin', 'api.Auth/yijianlogin');
945
     //短信注册
939
     //短信注册
946
     Route::post('auth/register', 'api.Auth/register');
940
     Route::post('auth/register', 'api.Auth/register');
941
+    //注册后绑定邀请人
942
+    Route::post('auth/registerBindSpread', 'api.Auth/registerBindSpread');
947
     //测试账号
943
     //测试账号
948
     Route::post('auth/register_all', 'api.Auth/register_all');
944
     Route::post('auth/register_all', 'api.Auth/register_all');
949
     //java商户端调用用户注册
945
     //java商户端调用用户注册
@@ -1025,23 +1021,30 @@ Route::group('api/', function () {
1025
     Route::any('vip/order_update', 'api.store.product.Vip/updateVipOrder');
1021
     Route::any('vip/order_update', 'api.store.product.Vip/updateVipOrder');
1026
 
1022
 
1027
     // 京东
1023
     // 京东
1028
-    if(false){
1024
+    // if(true){
1029
         // 京东联盟
1025
         // 京东联盟
1030
         Route::any('get_jd_goods_list','api.store.product.Jd/get_jd_goods_list');//获取京东联盟商品入库,定时任务
1026
         Route::any('get_jd_goods_list','api.store.product.Jd/get_jd_goods_list');//获取京东联盟商品入库,定时任务
1031
         /*京东列表*/
1027
         /*京东列表*/
1032
         Route::get('jd/list', 'api.store.product.Jd/jdList'); // 京东联盟
1028
         Route::get('jd/list', 'api.store.product.Jd/jdList'); // 京东联盟
1033
         Route::get('jd/orderlist', 'api.store.product.Jd/orderList');// 京东联盟
1029
         Route::get('jd/orderlist', 'api.store.product.Jd/orderList');// 京东联盟
1034
         Route::get('jd/JdMoney', 'api.store.product.JD/JdMoney');
1030
         Route::get('jd/JdMoney', 'api.store.product.JD/JdMoney');
1035
-    }else{
1036
-        /*京东商品详情*/
1037
-        Route::any('get_jd_goods_list','api.store.product.Jt/get_jd_goods_list');//获取京东商品入库,定时任务
1038
-        Route::get('jd/list', 'api.store.product.Jt/goodsList');//京推推
1039
-        Route::get('jd/orderlist', 'api.store.product.Jt/orderRowList');//京推推
1040
-        Route::get('jd/old_jd_order', 'api.store.product.Jt/old_jd_order');//京推推旧订单
1041
-        //京东返利
1042
-        Route::get('jd/JdMoney', 'api.store.product.Jt/JdMoney');
1043
-    }
1044
-
1031
+        // 京东联盟
1032
+        Route::get('jd/detail', 'api.store.product.Jd/jdDetail')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);;
1033
+        Route::get('jd/search', 'api.store.product.Jd/search');
1034
+        Route::get('jd/chang_link', 'api.store.product.Jd/changLinkApi')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);//京推推
1035
+    // }else{
1036
+    //     /*京东商品详情*/
1037
+    //     Route::any('get_jd_goods_list','api.store.product.Jt/get_jd_goods_list');//获取京东商品入库,定时任务
1038
+    //     Route::get('jd/list', 'api.store.product.Jt/goodsList');//京推推
1039
+    //     Route::get('jd/orderlist', 'api.store.product.Jt/orderRowList');//京推推
1040
+    //     Route::get('jd/old_jd_order', 'api.store.product.Jt/old_jd_order');//京推推旧订单
1041
+    //     //京东返利
1042
+    //     Route::get('jd/JdMoney', 'api.store.product.Jt/JdMoney');
1043
+    //     /*京东商品详情*/
1044
+    //     Route::get('jd/detail', 'api.store.product.Jt/goodsDetail')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);//京推推
1045
+    //     Route::get('jd/chang_link', 'api.store.product.Jt/changLinkApi')->middleware(\app\common\middleware\UserTokenMiddleware::class, false);//京推推
1046
+    //     Route::get('jd/search', 'api.store.product.Jt/search');//京推推
1047
+    // }
1045
 
1048
 
1046
 
1049
 
1047
     Route::get('tb/material', 'api.store.product.TaoBao/getMaterial');
1050
     Route::get('tb/material', 'api.store.product.TaoBao/getMaterial');