conner hai 1 ano
pai
achega
e96d06b706

+ 16 - 0
app/common/dao/merchant/apply/MerchantContributeDao.php

@@ -0,0 +1,16 @@
1
+<?php
2
+namespace app\common\dao\merchant\apply;
3
+
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\merchant\apply\MerchantContribute;
7
+
8
+class MerchantContributeDao extends BaseDao
9
+{
10
+    protected function getModel(): string
11
+    {
12
+        return MerchantContribute::class;
13
+    }
14
+
15
+}
16
+

+ 2 - 0
app/common/middleware/AdminTokenMiddleware.php

@@ -17,6 +17,7 @@ use crmeb\services\JwtTokenService;
17 17
 use Firebase\JWT\ExpiredException;
18 18
 use think\exception\ValidateException;
19 19
 use think\facade\Route;
20
+use think\Log;
20 21
 use think\Response;
21 22
 use Throwable;
22 23
 
@@ -31,6 +32,7 @@ class AdminTokenMiddleware extends BaseMiddleware
31 32
      */
32 33
     public function before(Request $request)
33 34
     {
35
+        \think\facade\Log::info('Midd_ko=>'.\GuzzleHttp\json_encode($request));
34 36
         $force = $this->getArg(0, true);
35 37
         try {
36 38
             $token = trim($request->header('X-Token'));

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

@@ -29,7 +29,7 @@ class IpCheckMiddleware extends BaseMiddleware
29 29
         Log::info("IP".$ip);
30 30
         //判断是否在列表中
31 31
         if(!in_array($ip,$this->ipList)){
32
-            throw new ValidateException('IP非法');
32
+            throw new ValidateException('IP非法23');
33 33
         }
34 34
 
35 35
     }

+ 18 - 0
app/common/model/merchant/apply/MerchantContribute.php

@@ -0,0 +1,18 @@
1
+
2
+<?php
3
+namespace app\common\model\merchant\apply;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class MerchantContribute extends BaseModel
8
+{
9
+    public static function tablePk(): ?string
10
+    {
11
+        return 'id';
12
+    }
13
+
14
+    public static function tableName(): string
15
+    {
16
+        return 'merchant_contribute';
17
+    }
18
+}

+ 40 - 0
app/common/model/user/TeamValue.php

@@ -0,0 +1,40 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-05-07
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\common\model\user;
12
+
13
+
14
+use app\common\model\BaseModel;
15
+
16
+class TeamValue extends BaseModel
17
+{
18
+
19
+    /**
20
+     * @return string
21
+     * @author xaboy
22
+     * @day 2020-03-30
23
+     */
24
+    public static function tablePk(): string
25
+    {
26
+        return 'id';
27
+    }
28
+
29
+    /**
30
+     * @return string
31
+     * @author xaboy
32
+     * @day 2020-03-30
33
+     */
34
+    public static function tableName(): string
35
+    {
36
+        return 'team_value';
37
+    }
38
+
39
+
40
+}

+ 69 - 0
app/common/repositories/merchant/apply/MerchantContributeRepository.php

@@ -0,0 +1,69 @@
1
+<?php
2
+ 
3
+namespace app\common\repositories\merchant\apply;
4
+
5
+use app\common\dao\merchant\apply\MerchantContributeDao;
6
+use app\common\repositories\BaseRepository;
7
+use think\facade\Db;
8
+
9
+/**
10
+ * Class MerchantContributeRepository
11
+ * @package app\common\repositories\merchant\apply
12
+ * @author php迷途小书童
13
+ * @created 2021/1/30 17:42
14
+ */
15
+class MerchantContributeRepository extends BaseRepository
16
+{
17
+    /**
18
+     * MerchantRepository constructor.
19
+     * @param MerchantContributeDao $dao
20
+     */
21
+    public function __construct(MerchantContributeDao $dao)
22
+    {
23
+        $this->dao = $dao;
24
+    }
25
+    /**  
26
+     * 获取单条信息
27
+     * @return array|\think\Model|null
28
+     * @author php迷途小书童
29
+     * @created 2021/1/16 10:45
30
+     */
31
+    public function getOne($where)
32
+    {
33
+        return ($this->dao->getWhere($where));
34
+    }
35
+
36
+    /**
37
+     * 查询列表
38
+     * 
39
+    */
40
+    public function queryList()
41
+    {
42
+        return Db::name('merchant_contribute')
43
+            ->field("id,contribute_name,ratio_start,ratio_end,jing_dou,contribute_value")
44
+            ->where('del_yn', 0)
45
+            ->order('id', 'ASC')
46
+            ->select();
47
+    }
48
+
49
+    public function deleteById($id)
50
+    {
51
+        return Db::name('merchant_contribute')
52
+            ->where('id', $id)
53
+            ->update(['del_yn'=>1]);
54
+    }
55
+
56
+    public function updateById($data, $id)
57
+    {
58
+        return Db::name('merchant_contribute')
59
+            ->where('id', $id)
60
+            ->update($data);
61
+    }
62
+
63
+    public function add($data)
64
+    {
65
+        return Db::name('merchant_contribute')
66
+            ->insert($data);
67
+    }
68
+}
69
+

+ 164 - 0
app/common/repositories/store/product/ThirdPartyCategoryRepository.php

@@ -0,0 +1,164 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ * @Author: Conner
5
+ * @Date: 2025/1/10
6
+ */
7
+namespace app\common\repositories\store\product;
8
+
9
+use app\common\repositories\BaseRepository;
10
+use app\common\dao\store\product\ProductAttrValueDao as dao;
11
+use app\traits\GongApiRequest;
12
+use think\exception\ValidateException;
13
+use crmeb\exceptions\AuthException;
14
+use think\facade\Db;
15
+use think\facade\Log;
16
+
17
+/**
18
+ * Class ThirdPartyCategoryRepository
19
+ * @package app\common\repositories\store\product
20
+ * @Conner
21
+ */
22
+class ThirdPartyCategoryRepository extends BaseRepository
23
+{
24
+
25
+    protected $dao;
26
+
27
+    /**
28
+     * ProductRepository constructor.
29
+     * @param dao $dao
30
+     */
31
+    public function __construct(dao $dao)
32
+    {
33
+        $this->dao = $dao;
34
+    }
35
+
36
+    /**
37
+     * @Author:Qinii
38
+     * @Date: 2020/5/30
39
+     * @param int $id
40
+     * @return mixed
41
+     */
42
+    public function priceCount(int $id)
43
+    {
44
+       return  min($this->dao->getFieldColumnt('product_id',$id,'price'));
45
+    }
46
+
47
+    /**
48
+     * @Author:Qinii
49
+     * @Date: 2020/5/30
50
+     * @param int $id
51
+     * @return mixed
52
+     */
53
+    public function stockCount(int $id)
54
+    {
55
+        return  $this->dao->getFieldSum('product_id',$id,'stock');
56
+    }
57
+
58
+    /**
59
+     * @Author:Qinii
60
+     * @Date: 2020/5/30
61
+     * @param int|null $merId
62
+     * @param string $value
63
+     * @return bool
64
+     */
65
+    public function merUniqueExists(?int $merId,string $value)
66
+    {
67
+        return $this->dao->merFieldExists($merId,'unique',$value);
68
+    }
69
+
70
+    /**
71
+     * TODO
72
+     * @param $unique
73
+     * @return mixed
74
+     * @author Qinii
75
+     * @day 2020-08-05
76
+     */
77
+    public function getOptionByUnique($unique)
78
+    {
79
+        return  $this->dao->getFieldExists(null,'unique',$unique)->find();
80
+    }
81
+
82
+    /**
83
+     * TODO
84
+     * @param $productId
85
+     * @return mixed
86
+     * @author Lin
87
+     * @day 2021-04-14
88
+     */
89
+    public function getOptionByProductId($productId)
90
+    {
91
+        return  $this->dao->getFieldExists(null,'product_id',$productId)->select();
92
+    }
93
+
94
+    public function checkGong($product_id,$unique,$num,$uid,$addressId=0,$debug=false,$delivery=false){
95
+        if($debug){
96
+            return true;
97
+        }
98
+        $spu_id = Db::name('store_product') -> where('product_id',$product_id)->value('spu_id');
99
+
100
+        if($spu_id == ''){
101
+            return true;
102
+        }
103
+        $sku_id = Db::name('store_product_attr_value') -> where('unique',$unique) -> value('gong_sku_id');
104
+        $query = Db::name('user_address') -> where('uid',$uid);
105
+        if($addressId != 0){
106
+            $query -> where('address_id',$addressId);
107
+        }else{
108
+            $query -> where('is_default',1);
109
+        }
110
+        $address_code_list = $query -> value('code_list');
111
+        $address_id = '809';
112
+        if($address_code_list){
113
+            $address_id = explode(',',$address_code_list);
114
+            log::info($address_id);
115
+            $address_id = end($address_id);
116
+//            $address_id = $address_id[0];
117
+        }
118
+        $sku = [[
119
+            'sku_id'=>$sku_id,
120
+            'num'=>$num
121
+        ]];
122
+        //查询商品是否有货
123
+        $stock = GongApiRequest::stock($sku_id,$address_id,$num);
124
+        if($stock != '有货'){
125
+            if($delivery){
126
+                return false;
127
+            }else{
128
+                return ['code'=>-1,'message'=>'此商品无货'];
129
+//                throw new AuthException('此商品无货');
130
+            }
131
+        }
132
+        //查询商品上下架
133
+        $goods_status = GongApiRequest::goods_status($spu_id);
134
+        if(!isset($goods_status[0]['status']) || $goods_status[0]['status'] != 1){
135
+            if($delivery){
136
+                return false;
137
+            }else{
138
+                return ['code'=>-1,'message'=>'此商品已下架'];
139
+//                throw new AuthException('此商品已下架');
140
+            }
141
+        }
142
+        //查询库存
143
+        $sku_stock = GongApiRequest::sku_stock(json_encode($sku),$address_id);
144
+        if(!isset($sku_stock[0]['stock']) || $sku_stock[0]['stock'] != '有货'){
145
+            if($delivery){
146
+                return false;
147
+            }else {
148
+                return ['code'=>-1,'message'=>'此商品规格无货'];
149
+//                throw new AuthException('此商品规格无货');
150
+            }
151
+        }
152
+        //查询运费
153
+        $sku_freight = GongApiRequest::freight($address_id,$sku);
154
+        if(!isset($sku_freight['freight'])){
155
+            if($delivery){
156
+                return false;
157
+            }else {
158
+                return ['code'=>-1,'message'=>'此商品下架'];
159
+//                throw new AuthException('此商品下架');
160
+            }
161
+        }
162
+        return true;
163
+    }
164
+}

+ 74 - 0
app/controller/admin/merchant/MerchantContribute.php

@@ -0,0 +1,74 @@
1
+<?php
2
+
3
+namespace app\controller\admin\merchant;
4
+use crmeb\basic\BaseController;
5
+use think\App;
6
+use app\common\repositories\merchant\apply\MerchantContributeRepository;
7
+
8
+class MerchantContribute extends BaseController
9
+{
10
+    /**
11
+     * @var MerchantContributeRepository
12
+     */
13
+    protected $repository;
14
+
15
+    /**
16
+     * MerchantContribute constructor.
17
+     * @param MerchantContributeRepository $repository
18
+     */
19
+    public function __construct(App $app,MerchantContributeRepository $repository)
20
+    {
21
+        parent::__construct($app);
22
+        $this->repository = $repository;
23
+    }
24
+
25
+
26
+    /**
27
+     * @return mixed
28
+     * @author Qinii
29
+     */
30
+    public function list()
31
+    {
32
+        return app('json')->success($this->repository->queryList());
33
+    }
34
+
35
+    public function add()
36
+    {
37
+        $data = $this->request->params([
38
+            'contribute_name', 
39
+            'ratio_start', 
40
+            'ratio_end', 
41
+            'jing_dou',
42
+            'contribute_value'
43
+            ]);
44
+        $this->repository->add($data);
45
+        return  app('json')->success('添加成功');
46
+    }
47
+
48
+    public function edit()
49
+    {
50
+        $id = $this->request->id();
51
+        if(empty($id)){
52
+            return app('json')->fail('参数ID缺失');
53
+        }
54
+        $data = $this->request->params([
55
+            'contribute_name', 
56
+            'ratio_start', 
57
+            'ratio_end', 
58
+            'jing_dou',
59
+            'contribute_value'
60
+            ]);
61
+        $this->repository->updateById($data, $id);
62
+        return  app('json')->success('更新成功');
63
+    }
64
+
65
+    public function delete()
66
+    {
67
+        $id = $this->request->id();
68
+        if(empty($id)){
69
+            return app('json')->fail('参数ID缺失');
70
+        }
71
+        $this->repository->deleteById($data, $id);
72
+        return  app('json')->success('删除成功');
73
+    }
74
+}

+ 177 - 0
app/controller/admin/user/TeamValue.php

@@ -0,0 +1,177 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020/6/23
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\controller\admin\user;
12
+
13
+
14
+
15
+use app\common\dao\BaseDao;
16
+use app\common\model\system\admin\Log;
17
+use crmeb\basic\BaseController;
18
+
19
+use app\common\repositories\user\UserBillRepository;
20
+use think\console\command\make\Controller;
21
+use think\Request;
22
+
23
+class TeamValue extends  Controller
24
+{
25
+    protected $repository;
26
+    protected $request;
27
+
28
+    public function __construct(Request $request)
29
+    {
30
+        parent::__construct();
31
+        $this->request = $request;
32
+    }
33
+
34
+    /**
35
+     * 团队设置信息
36
+     * @return mixed
37
+     * @throws \think\db\exception\DataNotFoundException
38
+     * @throws \think\db\exception\DbException
39
+     * @throws \think\db\exception\ModelNotFoundException
40
+     *
41
+     *
42
+     */
43
+    public function getInfo()
44
+    {
45
+        $where = ['create_time'];
46
+        $info=\app\common\model\user\TeamValue::where('create_time >0')->find();
47
+      //  \think\facade\Log::info('ddddd');
48
+        $msg='成功';
49
+
50
+        return app('json')->success('',$info);
51
+       // echo 'eeeee';
52
+    }
53
+
54
+    /**
55
+     * 编辑团队设置信息
56
+     * @return mixed
57
+     * @throws \think\db\exception\DataNotFoundException
58
+     * @throws \think\db\exception\DbException
59
+     * @throws \think\db\exception\ModelNotFoundException
60
+     */
61
+    public function editInfo(){
62
+        $params=$this->request->params(['id','sum']);;
63
+        $info=\app\common\model\user\TeamValue::where('create_time >0')->find();
64
+        $res=$info->save(['sum'=>$params['sum']]);
65
+        if($res){
66
+            $msg='成功';
67
+        }else{
68
+            $msg="失败";
69
+        }
70
+        return app('json')->success($msg,$res);
71
+    }
72
+
73
+    public function type()
74
+    {
75
+        return app('json')->success($this->repository->type());
76
+    }
77
+
78
+
79
+    /*平台记录*/
80
+    public  function adminList(){
81
+        [$page, $limit] = $this->getPage();
82
+        $where = $this->request->params(['keyword', 'date', 'type']);
83
+        return app('json')->success($this->repository->getAdminList($where, $page, $limit));
84
+//        return app('json')->success($this->repository->getAdminList($where, $page, $limit));
85
+    }
86
+
87
+    public function excel()
88
+    {
89
+        $where = request()->params(['date']);
90
+        $params = request()->params(['commission_type', 'uid', 'status', 'phone', 'user_group', 'status']);
91
+        $commission_type_desc = '佣金统计';
92
+        if ($params['commission_type'] ?? 0 == 5) {
93
+            $commission_type_desc = '养老金统计';
94
+        }
95
+        $data = [];
96
+        //商户ID
97
+        $mer_id = 0;
98
+        $query = Db::name('user_bill')
99
+            ->alias('ub')
100
+            ->leftJoin('user u', 'u.uid=ub.uid')
101
+            ->when($mer_id, function ($query) use ($mer_id) {
102
+                $query->where('ub.mer_id', $mer_id);
103
+            })
104
+            ->when(isset($params['commission_type']) && $params['commission_type'] == 5, function ($query) use ($params) {
105
+                // 养老金
106
+                $query->where('ub.commission_type', 5);
107
+            }, function ($query) use ($params) {
108
+                // 非养老金
109
+                $query->whereIn('ub.commission_type', [3, 16, 14, 10, 12, 20, 15, 7, 19]);
110
+            })
111
+            ->when(isset($params['uid']) && $params['uid'] != '', function ($query) use ($params) {
112
+                $query->where('ub.uid', $params['uid']);
113
+            })
114
+            ->when(isset($params['commission_type']) && $params['commission_type'] != '', function ($query) use ($params) {
115
+                $query->where('ub.commission_type', $params['commission_type']);
116
+            })
117
+            ->when(isset($params['status']) && $params['status'] != '', function ($query) use ($params) {
118
+                $query->where('ub.status', $params['status']);
119
+            })
120
+            ->when(isset($params['phone']) && $params['phone'] != '', function ($query) use ($params) {
121
+                $query->whereLike('u.phone', '%' . $params['phone'] . '%');
122
+            })
123
+            ->when(isset($params['user_group']) && $params['user_group'] != '', function ($query) use ($params) {
124
+                $query->where('u.user_group', $params['user_group']);
125
+            });
126
+        $financeRepository = app()->make(FinanceRepository::class);
127
+        $list = $financeRepository->date_where($query, $where['date'], 'ub.create_time')
128
+            ->field('ub.bill_id,ub.title,ub.number,ub.take_time,ub.commission_type,u.uid,u.phone,u.nickname,u.user_group,ub.order_sn,ub.take_time,ub.status,ub.create_time')
129
+            ->order('ub.bill_id', 'desc')
130
+            ->select()
131
+            ->each(function ($item) {
132
+                if($item['take_time'])
133
+                    $item['take_time'] = date('Y-m-d H:i:s', $item['take_time']);
134
+                return $item;
135
+            });
136
+        foreach ($list as $k => $v) {
137
+            $temp = array(
138
+                $v['bill_id'],
139
+                $v['create_time'],
140
+                $v['nickname'],
141
+                $v['phone'],
142
+                $v['title'],
143
+                $v['number'],
144
+                $v['status'] == 1 ? '已结算': '未结算',
145
+                $v['order_sn'] ?? '',
146
+            );
147
+            $arr[] = $temp;
148
+        }
149
+        $header = [
150
+            'ID', '创建时间', '用户昵称', '用户手机号', '名称', '金额', '状态', '订单号'
151
+        ];
152
+        $filename = $commission_type_desc . date('YmdHis') . '_' . rand(10000, 99999);
153
+        $title = $commission_type_desc;
154
+        $name = $commission_type_desc;
155
+        $info = '生成时间:' . date('Y-m-d H:i:s', time());
156
+        $suffix = 'xlsx';
157
+        $path = 'extract';
158
+        unset($_instance);
159
+
160
+        $_instance = SpreadsheetExcelService::instance_xin();
161
+
162
+        $_path = $_instance
163
+            ->createOrActive()
164
+            ->setExcelHeader($header)
165
+            ->setExcelTile($title, $name, $info)
166
+            ->setExcelContent($arr)
167
+            ->excelSave($filename, $suffix, $path);
168
+
169
+        $data = [
170
+            'name' => $filename . '.' . $suffix,
171
+            'status' => 1,
172
+            'path' => '/' . $_path
173
+        ];
174
+
175
+        return app('json')->success('ok', $data);
176
+    }
177
+}

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

@@ -35,8 +35,10 @@ use think\App;
35 35
 use think\db\exception\DataNotFoundException;
36 36
 use think\db\exception\DbException;
37 37
 use think\db\exception\ModelNotFoundException;
38
+use think\Exception;
38 39
 use think\facade\Cache;
39 40
 use think\facade\Db;
41
+use think\Log;
40 42
 
41 43
 /**
42 44
  * Class User
@@ -176,6 +178,9 @@ class User extends BaseController
176 178
     }
177 179
     public function get_info($id)
178 180
     {
181
+//                ini_set('display_errors','On');
182
+//
183
+//        error_reporting(E_ALL);
179 184
         if (!$this->repository->exists($id))
180 185
             return app('json')->fail('数据不存在');
181 186
         $user=Db::name('user')->find($id);
@@ -256,7 +261,14 @@ class User extends BaseController
256 261
 
257 262
         //查询当前团队的用户列表
258 263
         $sql = "select getUserSpreadId($id) as uids";
259
-        $spread_user_list = Db::query($sql);
264
+        //\think\facade\Log::info("lplpDB".$sql);
265
+        try{
266
+            $spread_user_list = Db::query($sql);
267
+        }catch (Exception $exception){
268
+           return app('json')->success($exception);
269
+        }
270
+
271
+
260 272
         $spread_user_list = array_diff(explode(",", trim($spread_user_list[0]['uids'],'$,')), [$id]);
261 273
 
262 274
         //查询创客手机号

+ 34 - 33
app/controller/api/Auth.php

@@ -655,8 +655,8 @@ echo '导入成功';
655 655
     {
656 656
         $user = $this->request->userInfo()
657 657
             ->hidden(['account','label_id', 'group_id', 'pwd', 'card_id', 'last_time', 'last_ip', 'status', 'spread_time', 'real_name', 'brokerage_price']);
658
-        $user->append(['service', 'total_consume', 'total_collect_product', 'total_collect_store', 'total_coupon', 'total_visit_product', 'total_unread']);
659
-        $data=$user->toArray();
658
+        $user->append(['service', 'total_consume', 'total_collect_product', 'total_collect_store', 'total_coupon', 'total_visit_product', 'total_unread']);     
659
+$data=$user->toArray();
660 660
 
661 661
 
662 662
         $is_merchant=Db::name("merchant_intention")->where(["uid"=>$user["uid"],"is_branch"=>0])->order("mer_intention_id desc")->value("status");
@@ -700,7 +700,6 @@ echo '导入成功';
700 700
         }
701 701
         $data['team_number'] = $this->getBreak($user['uid']);
702 702
 
703
-
704 703
         $data['is_bangfu'] = Db::name('user_bangfu') -> where('uid',$user["uid"])->value('status')==1;
705 704
 
706 705
 //        $data['area_manage'] = Db::name('area_manage')->field('type,code_list')->where('uid',$user["uid"])->find();
@@ -1060,7 +1059,9 @@ echo '导入成功';
1060 1059
     }
1061 1060
     public function smsLogin(UserAuthValidate $validate, UserRepository $repository)
1062 1061
     {
1063
-        $data = $this->request->params(['phone', 'sms_code', 'spread', 'share_id']);
1062
+        // $data = $this->request->params(['phone', 'sms_code', 'spread', 'share_id']);
1063
+        $data = $this->request->params(['phone', 'sms_code']);
1064
+
1064 1065
         $validate->sceneSmslogin()->check($data);
1065 1066
 
1066 1067
         $domain = $this->request->domain();
@@ -1076,37 +1077,37 @@ echo '导入成功';
1076 1077
         }
1077 1078
 
1078 1079
         $user = $repository->accountByUser($data['phone']);
1079
-        if (!$user){
1080
-            if (!intval($data['spread'])) {
1081
-                $spread_uid = Db::name('product_share')->where('id', $data['share_id'])->value('uid');
1082
-                $data['spread'] = $spread_uid;
1083
-            }
1084
-            $user = $repository->registr($data['phone'], null, 'h5', $data['spread']);
1085
-        }
1080
+        // if (!$user){
1081
+        //    if (!intval($data['spread'])) {
1082
+        //        $spread_uid = Db::name('product_share')->where('id', $data['share_id'])->value('uid');
1083
+        //        $data['spread'] = $spread_uid;
1084
+        //    }
1085
+        //    $user = $repository->registr($data['phone'], null, 'h5', $data['spread']);
1086
+        // }
1086 1087
         $user = $repository->mainUser($user);
1087 1088
 
1088
-        if($this->source=='yhc' && $this->merId){
1089
-            $where=['mer_id'=>$this->merId,'uid'=>$user->uid];
1090
-            $count=Db::name('enterprise_user')->where($where)->count();
1091
-            if($count<1){
1092
-                $insert=['mer_id'=>$this->merId,'uid'=>$user->uid];
1093
-                if (!intval($data['spread'])) {
1094
-                    $spread_uid = Db::name('product_share')->where('id', $data['share_id'])->value('uid');
1095
-                }else{
1096
-                    $spread_uid=$data['spread'];
1097
-                }
1098
-                if($this->inviter_verification(2,$spread_uid)==false){
1099
-                    return app('json')->fail('请输入正确邀请人手机号');
1100
-                }
1101
-
1102
-
1103
-                $insert['puid']= $spread_uid;
1104
-                $insert['node_uid']= $spread_uid;
1105
-                Db::name('enterprise_user')->insert($insert);
1106
-            }
1107
-        }
1108
-
1109
-        $repository->bindSpread($user, intval($data['spread']));
1089
+        // if($this->source=='yhc' && $this->merId){
1090
+        //     $where=['mer_id'=>$this->merId,'uid'=>$user->uid];
1091
+        //     $count=Db::name('enterprise_user')->where($where)->count();
1092
+        //     if($count<1){
1093
+        //         $insert=['mer_id'=>$this->merId,'uid'=>$user->uid];
1094
+        //         if (!intval($data['spread'])) {
1095
+        //             $spread_uid = Db::name('product_share')->where('id', $data['share_id'])->value('uid');
1096
+        //         }else{
1097
+        //             $spread_uid=$data['spread'];
1098
+        //         }
1099
+        //         if($this->inviter_verification(2,$spread_uid)==false){
1100
+        //             return app('json')->fail('请输入正确邀请人手机号');
1101
+        //         }
1102
+
1103
+
1104
+       //          $insert['puid']= $spread_uid;
1105
+       //          $insert['node_uid']= $spread_uid;
1106
+       //          Db::name('enterprise_user')->insert($insert);
1107
+       //      }
1108
+       //  }
1109
+
1110
+        // $repository->bindSpread($user, intval($data['spread']));
1110 1111
         $tokenInfo = $repository->createToken($user);
1111 1112
         $repository->loginAfter($user);
1112 1113
         return app('json')->success($repository->returnToken($user, $tokenInfo));

+ 3 - 0
app/controller/api/YiJia.php

@@ -44,6 +44,9 @@ class YiJia extends BaseController
44 44
         return app('json')->success('短信发送成功');
45 45
 
46 46
     }
47
+    public  function lp(){
48
+        echo 'lplplplp';
49
+    }
47 50
 
48 51
     public function Auth(UserRepository $repository){
49 52
         $data = $this->request->params(['phone', 'sms_code', 'source']);

+ 1 - 0
app/controller/api/store/order/StoreOrder.php

@@ -132,6 +132,7 @@ class StoreOrder extends BaseController
132 132
         $special_merchant = merchantConfig($product_mer_id, 'special_merchant');
133 133
         $member_settings=merchantConfig($product_mer_id, 'member_settings');
134 134
 
135
+        return app('json')->fail('正在升级');
135 136
         // 增加锁,防止同一用户重读点击
136 137
         $redis = Cache::store('redis')->handler();
137 138
         $key = 'createOrder'.$uid;

+ 13 - 3
app/controller/api/store/product/DaTaoKe.php

@@ -587,6 +587,7 @@ class DaTaoKe
587 587
 
588 588
                 $pddGoodsList = $response['data']['goodsList'] ?? [];
589 589
                 return json($response);
590
+                
590 591
                 $total += count($pddGoodsList);
591 592
                 foreach ($pddGoodsList as $goods) {
592 593
 
@@ -597,10 +598,13 @@ class DaTaoKe
597 598
                     $commissionRate = $goods['promotionRate'];
598 599
                     //券后价
599 600
                     $price = sprintf('%.2f', $groupPrice - $couponMoney);
600
-                    //养老金
601
-                    $commission = sprintf('%.2f', (($price * $commissionRate) / 1000));
601
+                    
602
+                    $commission = sprintf('%.2f', (($price * $commissionRate) / 1000)); //佣金
602 603
 
603
-                    $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
604
+                    //养老金
605
+                    $pv=$commission* 0.5;  //PV
606
+                    $yanglaojin=$pv*0.05; //新的养老金
607
+                    // $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
604 608
                      if ($yanglaojin < 0.5) {
605 609
                         continue;
606 610
                      }
@@ -609,6 +613,12 @@ class DaTaoKe
609 613
                         'id' => $goods['goodsSign'],
610 614
                         'thumb' => $goods['goodsThumbnailUrl'],//商品缩略图
611 615
                         'name' => $goods['goodsName'],
616
+                        
617
+                        'pv'=>$pv,
618
+                        'gongxian'=>$pv,
619
+                        'jifen'=>$pv,
620
+                        'yanglaojin' => $yanglaojin,
621
+                        
612 622
                         'commission' => $yanglaojin,
613 623
                         'commission_rate' => ($commissionRate / 10) . '%',
614 624
                         'sales' => $goods['salesTip'],

+ 74 - 12
app/controller/api/store/product/Douyin.php

@@ -14,6 +14,7 @@ use think\Exception;
14 14
 use think\facade\Db;
15 15
 use think\facade\Log;
16 16
 use crmeb\basic\BaseController;
17
+use app\controller\api\store\service\ThirdPartyCategory;
17 18
 
18 19
 class Douyin extends BaseController
19 20
 {
@@ -65,19 +66,29 @@ class Douyin extends BaseController
65 66
                 $total += count($goodsList);
66 67
                 foreach ($goodsList as $value) {
67 68
                     $price = $value['couponPrice'] ?: $value['price'];
68
-                    //养老
69
+                    //
69 70
                     $commissionRate = $value['cosRatio'];
70 71
                     $commission = $value['cosFee'];
71
-                    $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
72
+
73
+                    //养老金
74
+                    $pv=$commission* 0.5;  //PV
75
+                    $yanglaojin=$pv*0.05; //新的养老金
76
+
77
+
78
+                    // $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
72 79
                     if ($yanglaojin < 0.1) {
73 80
                         continue;
74 81
                     }
75
-                    $yanglaojin = bcmul($yanglaojin, 0.8, 2);
82
+                    Log::info($value);
83
+                    // $yanglaojin = bcmul($yanglaojin, 0.8, 2);
76 84
                     $goods = [
77 85
                         'type' => 9,
78 86
                         'id' => $value['id'],
79
-                        'thumb' => $value['cover'],
87
+                        'thumb' => $value['cover'],                        
80 88
                         'name' => $value['title'],
89
+                        'pv' => $pv,
90
+                        'gongxian'=>$pv,
91
+                        'jifen'=>$pv,
81 92
                         'commission' => $yanglaojin,
82 93
                         'commission_rate' => $commissionRate,
83 94
                         'price' => $price,
@@ -89,6 +100,12 @@ class Douyin extends BaseController
89 100
                          'type' => 9,
90 101
                          'pension' => $yanglaojin
91 102
                      ];
103
+
104
+                    // //  use app\controller\api\store\service\ThirdPartyCategory;
105
+                    // $cid=$goods['cat1stId'];
106
+                    // $c_name=$goods['cat1stName'];
107
+                    // (new ThirdPartyCategory())->addOrUpdateCategory($cid,$c_name , 5);
108
+
92 109
                 }
93 110
                 if(isset($insert_all)){
94 111
                     Db::name("third_party_goods")->insertAll($insert_all);
@@ -117,6 +134,17 @@ class Douyin extends BaseController
117 134
                 $json['commission'] = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
118 135
                 $json['commission'] = bcmul($json['commission'], 0.8, 2);
119 136
                 $json['commission']=set_price_rtrim($json['commission']);
137
+
138
+                $json['pension'] = $json['pension']??'0';
139
+                $json['pv'] = $json['pension']*0.5;
140
+                $json['yanglaojin'] = $json['pv']*0.05;
141
+
142
+                $json['shopName'] = isset($json['shopName'])?$json['shopName']:"";
143
+                $json['monthSales'] = isset($json['monthSales'])?$json['monthSales']:0;
144
+                $json['cid'] = isset($value['cid'])?$value['cid']:0;
145
+                // $json['shopName'] = "";
146
+                // $json['monthSales'] = "0";
147
+                // $json['cid'] = "0";
120 148
                 $goodslist[] = $json;
121 149
             }
122 150
         }
@@ -128,18 +156,38 @@ class Douyin extends BaseController
128 156
         $page = request()->param('page', 1);
129 157
         $limit = request()->param('limit', 10);
130 158
         $keyword = $this->request->param('keyword');
159
+        $_cid = $this->request->param('cid');
160
+
131 161
         $userId = $this->request->uid();
132 162
         TaoKe::set_third_history($userId,$keyword);
133 163
 
134
-        $goods = Db::name('third_party_goods')
135
-            ->where('type', 9)
136
-            ->where('json', 'like', '%' . $keyword . '%')
137
-            ->page($page, $limit)
164
+        $goods_obj = Db::name('third_party_goods')
165
+            ->where('type', 5);
166
+        if($keyword){
167
+            $goods_obj=$goods_obj->where('json', 'like', '%' . $keyword . '%');
168
+        }
169
+        if($_cid){
170
+            $goods_obj=$goods_obj->where('cid', $_cid);
171
+        }
172
+        $goods=$goods_obj->page($page, $limit)
138 173
             ->select()->toArray();
174
+
175
+        // $goods = Db::name('third_party_goods')
176
+        //     ->where('type', 9)
177
+        //     ->where('json', 'like', '%' . $keyword . '%')
178
+        //     ->page($page, $limit)
179
+        //     ->select()->toArray();
139 180
         $goodsList = [];
140 181
         if(!empty($goods)) {
141 182
             foreach ($goods as $value) {
142
-                $goodsList[] = json_decode($value['json'], true);
183
+                $json = json_decode($value['json'], true);
184
+                $json['pension'] = $json['pension']??'0';
185
+                $json['pv'] = $json['pension']*0.5;
186
+                $json['yanglaojin'] = $json['pv']*0.05;
187
+                $json['shopName'] = "";
188
+                $json['monthSales'] = "0";
189
+                $json['cid'] = "0";
190
+                $goodsList[] = $json;
143 191
             }
144 192
         }
145 193
         return app('json')->success('获取抖音商品列表成功', $goodsList);
@@ -167,9 +215,23 @@ class Douyin extends BaseController
167 215
             return app('json')->fail('商品下架不存在', null, 401);
168 216
         }
169 217
         $detail = $detail[0];
170
-        $commission = $detail['cosFee'];
171
-        $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
172
-        $detail['yanglao'] = bcmul($yanglaojin, 0.8, 2);
218
+        // $commission = $detail['cosFee'];
219
+
220
+        $commission=$detail['cosFee'] ; //佣金(预估)
221
+        $pv=$commission* 0.5;  //PV
222
+        $yanglaojin=$pv*0.05; //新的养老金
223
+
224
+        $gongxian=$pv; //新的养老金
225
+        $jifen=$pv; //新的养老金
226
+        
227
+
228
+        $result['pv']=round($pv,2);
229
+        $result['yanglaojin']=round($yanglaojin,2);
230
+        $result['gongxian']=round($gongxian,2);
231
+        $result['jifen']=round($jifen,2);
232
+
233
+        // $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
234
+        // $detail['yanglao'] = bcmul($yanglaojin, 0.8, 2);
173 235
         $linkInfo = $this->dy_transfer($detail['detailUrl'], $uid);
174 236
         $detail['dyZlink'] = empty($linkInfo['dyZlink']) ? (empty($linkInfo['shareLink']) ? '' : $linkInfo['shareLink']) : $linkInfo['dyZlink'];
175 237
         $detail['dyDeeplink'] = $linkInfo['dyDeeplink'] ?? '';

+ 21 - 2
app/controller/api/store/product/Jd.php

@@ -9,6 +9,7 @@ use crmeb\basic\BaseController;
9 9
 use think\Exception;
10 10
 use think\exception\ValidateException;
11 11
 use think\facade\Db;
12
+use think\facade\Log;
12 13
 
13 14
 class Jd extends BaseController
14 15
 {
@@ -187,6 +188,16 @@ class Jd extends BaseController
187 188
         $formatList = [];
188 189
         foreach ($list as $value) {
189 190
             $json = json_decode($value['json'], true);
191
+            $json['pension'] = $json['pension']??'0';
192
+            $json['pv'] = $json['pension']*0.5;
193
+            $json['yanglaojin'] = $json['pv']*0.05;
194
+
195
+            // $json['shopName'] = "";
196
+            // $json['monthSales'] = "0";
197
+            // $json['cid'] = "0";
198
+            $json['shopName'] = isset($json['shopName'])?$json['shopName']:"";
199
+            $json['monthSales'] = isset($json['monthSales'])?$json['monthSales']:0;
200
+            $json['cid'] = isset($value['cid'])?$json['cid']:0;
190 201
             $formatList[] = $json;
191 202
         }
192 203
         shuffle($formatList);
@@ -247,7 +258,15 @@ class Jd extends BaseController
247 258
             ->toArray();
248 259
         $formatList = [];
249 260
         foreach ($list as $value) {
250
-            $formatList[] = json_decode($value['json'], true);
261
+	    $json = json_decode($value['json'], true);
262
+            $json['pension'] = $json['pension']??'0';
263
+            $json['pv'] = $json['pension']*0.5;
264
+            $json['yanglaojin'] = $json['pv']*0.05;
265
+
266
+            $json['shopName'] = "";
267
+            $json['monthSales'] = "0";
268
+            $json['cid'] = "0";
269
+            $formatList[] = $json;
251 270
         }
252 271
         return app("json")->success($formatList);
253 272
     }
@@ -381,7 +400,7 @@ class Jd extends BaseController
381 400
             '12318', //便宜包邮
382 401
             '12339', //超市卡
383 402
         ];
384
-
403
+        Log::info("===============get_jd_goods_list===================");
385 404
 //        $eliteIdList = [1];
386 405
         foreach ($eliteIdList as $eliteId) {
387 406
             $jq_query=$this->jd_query($eliteId,1);

+ 143 - 54
app/controller/api/store/product/Jt.php

@@ -14,7 +14,8 @@ use app\model\common\JdOrderModel;
14 14
 use think\App;
15 15
 use crmeb\basic\BaseController;
16 16
 use think\facade\Db;
17
-
17
+use think\facade\Log;
18
+use app\controller\api\store\service\ThirdPartyCategory;
18 19
 /**
19 20
  * Class Jt  使用京推推平台引入京东商品列表
20 21
  * @package app\api\controller\v1
@@ -80,6 +81,11 @@ class Jt extends BaseController
80 81
             $json['commission_'] = $commission;
81 82
             $json['lowestCouponPrice']=set_price_rtrim($json['lowestCouponPrice']);
82 83
             $json['price']=set_price_rtrim($json['price']);
84
+
85
+            $json['shopName'] = isset($json['shopName'])?$json['shopName']:"";
86
+            $json['monthSales'] = isset($json['monthSales'])?$json['monthSales']:0;
87
+            $json['cid'] = isset($value['cid'])?$value['cid']:0;
88
+
83 89
             $formatList[] = $json;
84 90
         }
85 91
         shuffle($formatList);
@@ -91,47 +97,56 @@ class Jt extends BaseController
91 97
 //        return app("json")->success($formatList);
92 98
     }
93 99
 
94
-    public function get_jd_goods_list(){
100
+    public function get_jd_goods_list() {
95 101
         set_time_limit(0);
96
-
102
+      
97 103
         $url = "http://japi.jingtuitui.com/api/get_goods_list";
98 104
         $params = [
99
-            'appid' => $this->jttAppId,
100
-            'appkey' => $this->jttAppKey,
101
-            'v' => 'v2',
102
-            'pageIndex' => 1,
103
-            'pageSize' => 1,
104
-            'sortName'=>'brokerage',
105
-            'sort'=>'desc'
105
+          'appid' => $this->jttAppId,
106
+          'appkey' => $this->jttAppKey,
107
+          'v' => 'v2',
108
+          'pageIndex' => 1,
109
+          'pageSize' => 100,
110
+          'sortName' => 'brokerage',
111
+          'sort' => 'desc',
106 112
         ];
107
-        $response2 = self::curlPost($url, $params);
108
-        if (isset($response2['result']['total_count'])){
109
-            $totel=$response2['result']['total_count'];
110
-            $pageNum=ceil($totel/100);
111
-        }else{
112
-            $this->get_jd_goods_list();
113
-            return 'ok';
113
+      
114
+        // 尝试从缓存获取数据
115
+        $cachedData = cache('jd_goods_list');
116
+        if ($cachedData) {
117
+          return $cachedData;
114 118
         }
115
-
116
-        for($i=1;$i<=$pageNum;$i++){
117
-            $url = "http://japi.jingtuitui.com/api/get_goods_list";
118
-            $params = [
119
-                'appid' => $this->jttAppId,
120
-                'appkey' => $this->jttAppKey,
121
-                'v' => 'v2',
122
-                'pageIndex' => $i,
123
-                'pageSize' => 100,
124
-//                'eliteId' => 'sift',
125
-                'sortName'=>'brokerage',
126
-                'sort'=>'desc'
127
-            ];
128
-            $response = self::curlPost($url, $params);
129
-            if (!isset($response['result']['data']) || count($response['result']['data']) < 1)break;
130
-            $this->formatGoodsList($response['result']['data'] ?? []);
131
-
119
+      
120
+        $response = self::curlPost($url, $params);
121
+      
122
+        if (isset($response['result']['total_count'])) {
123
+          $totalCount = $response['result']['total_count'];
124
+          $totalPages = ceil($totalCount / $params['pageSize']);
125
+        } else {
126
+          // 处理错误或返回合适信息
127
+          return 'Error: 无法获取总数量';
132 128
         }
133
-        return 'ok';
134
-    }
129
+      
130
+        $allGoods = [];
131
+        for ($i = 1; $i <= $totalPages; $i++) {
132
+          $params['pageIndex'] = $i;
133
+          $response = self::curlPost($url, $params);
134
+      
135
+          if (!isset($response['result']['data']) || count($response['result']['data']) < 1) {
136
+            break;
137
+          }
138
+      
139
+          $allGoods = array_merge($allGoods, $response['result']['data']);
140
+        }
141
+      
142
+        // 格式化并处理商品列表
143
+        $formattedGoods = $this->formatGoodsList($allGoods);
144
+      
145
+        // 缓存数据 (根据需求调整过期时间)
146
+        cache('jd_goods_list', $formattedGoods, 3600);
147
+      
148
+        return $formattedGoods;
149
+      }
135 150
 
136 151
 
137 152
 
@@ -139,19 +154,31 @@ class Jt extends BaseController
139 154
     public function search()
140 155
     {
141 156
         $keyword = request()->param('keyword', '');
157
+        $_cid = request()->param('cid', '');
158
+
142 159
         [$page, $limit] = $this->getPage();
143 160
         $uid = $this->request->uid();
144 161
         TaoKe::set_third_history($uid,$keyword);
145 162
 
146
-        $list = Db::name('third_party_goods')
147
-            -> where('type',2)
148
-            -> when(!empty($keyword),function($query) use ($keyword) {
149
-                $query -> where('json',"like",'%'.$keyword.'%');
150
-            })
151
-            -> page($page,$limit)
152
-            -> field('json')
153
-            -> select()
154
-            -> toArray();
163
+        $goods_obj = Db::name('third_party_goods')
164
+        -> where('type',2);
165
+        // -> when(!empty($keyword),function($query) use ($keyword) {
166
+        //     $query -> where('json',"like",'%'.$keyword.'%');
167
+        // })
168
+        // -> page($page,$limit)
169
+        // -> field('json')
170
+        // -> select()
171
+        // -> toArray();
172
+    
173
+        if($keyword){
174
+            $goods_obj=$goods_obj->where('json', 'like', '%' . $keyword . '%');
175
+        }
176
+        if($_cid){
177
+            $goods_obj=$goods_obj->where('cid', $_cid);
178
+        }
179
+        $list=$goods_obj->page($page, $limit)
180
+            ->select()->toArray();
181
+
155 182
         $formatList = [];
156 183
         foreach ($list as $value){
157 184
             $formatList[] = json_decode($value['json'],true);
@@ -201,11 +228,16 @@ class Jt extends BaseController
201 228
     {
202 229
 //        $formatList = [];
203 230
         foreach ($goodsList as $value) {
204
-            $finalPrice = $value['final_price'];
205
-            $commissionRate = $value['commissionShare'];
206
-            $commissionMoney = sprintf('%.2f', ($finalPrice * $commissionRate / 100));
231
+            $finalPrice = $value['final_price']; //商品最终价格(使用优惠券后的商品最终价格)
232
+            $commissionRate = $value['commissionShare'];  //京推推商品佣金比率
233
+            $commissionMoney = sprintf('%.2f', ($finalPrice * $commissionRate / 100)); // 商品最终价格 * 京推推商品佣金比率 /100 =最终佣金
234
+
235
+            $pv=$commissionMoney* 0.5;  //PV
236
+            $oldMoney=$pv*0.05; //新的养老金
237
+
238
+            
207 239
             //养老金
208
-            $oldMoney = app()->make(ProductRepository::class)->yanglaojin(0, $commissionMoney);
240
+            // $oldMoney = app()->make(ProductRepository::class)->yanglaojin(0, $commissionMoney);
209 241
             if ($oldMoney < 0.1) continue;
210 242
             $couponMoney = [
211 243
                 [
@@ -220,15 +252,49 @@ class Jt extends BaseController
220 252
                 'id' => $value['brandCode'],//品牌编号
221 253
                 'name' => $value['short_name'],
222 254
                 'thumb' => $value['goods_img'],
255
+
256
+                'pv' => $pv,//PV金额
257
+                'gongxian'=>$pv,
258
+                'jifen'=>$pv,
259
+                'yanglaojin'=>$yanglaojin,
260
+
261
+
223 262
                 'commission' => $oldMoney,//养老金
224 263
                 'commission_rate' => $commissionRate,
225
-                'sales' => $value['inOrderCount30Days'],
264
+                // 'sales' => $value['inOrderCount30Days'],
226 265
                 'coupon_money' => $couponMoney,//优惠券相关信息
227 266
                 'coupon_link' => $value['discount_link'],//优惠券链接
228 267
                 'lowestCouponPrice' => $finalPrice,//券后价
229 268
                 'price' => $value['goods_price'],//商品原价
269
+                'shopName'=>$value['shop_name'],
270
+                'monthSales'=>$value['inOrderCount30Days']>0?$value['inOrderCount30Days']:mt_rand(100,10000) //月销量
230 271
             ];
231
-            Db::name("third_party_goods") -> insert(['json'=>json_encode($formatList,JSON_UNESCAPED_UNICODE),'pension'=>$oldMoney,'type'=>2]);
272
+
273
+            //  use app\controller\api\store\service\ThirdPartyCategory;
274
+            // 1居家日用;
275
+            // 2食品;
276
+            // 3生鲜;
277
+            // 4图书;
278
+            // 5美妆个护;
279
+            // 6母婴;
280
+            // 7数码家电;
281
+            // 8内衣;
282
+            // 9配饰;
283
+            // 10女装;
284
+            // 11男装;
285
+            // 12鞋品;
286
+            // 13家装家纺;
287
+            // 14文娱车品;15箱包;16户外运动
288
+            $cid=$value['goods_type'];
289
+            // $c_name=$value['cid1Name'];
290
+            // (new ThirdPartyCategory())->addOrUpdateCategory($cid,$c_name , 2);
291
+
292
+            Db::name("third_party_goods") -> insert([
293
+                'json'=>json_encode($formatList,JSON_UNESCAPED_UNICODE),
294
+                'pension'=>$oldMoney,
295
+                'type'=>2,                
296
+                'cid'=>cid //一级分类
297
+            ]);  //20250110 增加cid字段,json中增加 shopName,monthSales by Conner
232 298
         }
233 299
 //        return $formatList;
234 300
     }
@@ -420,8 +486,19 @@ class Jt extends BaseController
420 486
             $commissionRate = $detail['commissionInfo']['commissionShare'];
421 487
             //目前京东联盟等级只返回90%的收益,后续调整0.9即可
422 488
             $commissionMoney = sprintf('%.2f', ($finalPrice * $commissionRate * 0.9 / 100));
489
+
490
+            $commission=$commissionMoney; //佣金(预估)
491
+            $pv=$commission* 0.5;  //PV
492
+            $yanglaojin=$pv*0.05; //新的养老金
493
+
494
+            $gongxian=$pv; //新的养老金
495
+            $jifen=$pv; //新的养老金
496
+            
497
+
498
+            
499
+
423 500
             //养老金
424
-            $yanglao = app()->make(ProductRepository::class)->thirdYanglaojin(0, $commissionMoney);
501
+            // $yanglao = app()->make(ProductRepository::class)->thirdYanglaojin(0, $commissionMoney);
425 502
 
426 503
             //经推推商品详情
427 504
             $detailImg = $detail['imageInfo']['imageList'];
@@ -434,9 +511,21 @@ class Jt extends BaseController
434 511
                 'couMoney' => $discount_price,
435 512
                 'nowPrice' => $finalPrice,//现价
436 513
                 'detail' => $formatDetailImg,
437
-                'yanglao' => $yanglao,
438
-                'yanglao_' => $commissionMoney,
514
+
515
+                'commission' => $commission,
516
+                'pv' => $pv,
517
+                'yanglaojin' => $yanglaojin,
518
+                'gongxian' => $gongxian,
519
+                'jifen' => $jifen,
520
+
521
+                // 'yanglao' => $yanglao,
522
+                // 'yanglao_' => $commissionMoney,
439 523
             ];
524
+            $formatData['pv']=round($pv,2);
525
+            $formatData['yanglaojin']=round($yanglaojin,2);
526
+            $formatData['gongxian']=round($gongxian,2);
527
+            $formatData['jifen']=round($jifen,2);
528
+
440 529
             $formatData['materialUrl'] = '';
441 530
             if($userId!=''){
442 531
             //加入转链地址

+ 131 - 12
app/controller/api/store/product/Su.php

@@ -13,6 +13,7 @@ use think\exception\ValidateException;
13 13
 use think\facade\Db;
14 14
 use SuNing;
15 15
 use think\facade\Log;
16
+use app\controller\api\store\service\ThirdPartyCategory;
16 17
 
17 18
 class Su extends BaseController
18 19
 {
@@ -25,8 +26,8 @@ class Su extends BaseController
25 26
     {
26 27
 
27 28
         parent::__construct($app);
28
-        $this->appKey = 'a5565f117bec762b45dead9514a00fce';
29
-        $this->secretKey = '6b12c8424cb7879ef9ec385cb03b341e';
29
+        $this->appKey = '8349fdf89e7c46ff8ba28752093dfd09';
30
+        $this->secretKey = '7c386c01da509065febddde9f87d4821';
30 31
         $this->channel = '';
31 32
         $this->userThird = app()->make(UserThirdRepository::class);
32 33
     }
@@ -130,6 +131,21 @@ class Su extends BaseController
130 131
         return $xml;
131 132
     }
132 133
 
134
+    // public function su_get_category(){
135
+    //     $apiName = 'suning.netalliance.commoditycategory.query';
136
+    //     $name = "queryInverstmentcommodity";
137
+    //     $request = [
138
+    //         'commoditycategoryList' => [
139
+    //             "saleCategoryId"=>1,
140
+    //             "saleGrade"=>1
141
+    //         ]
142
+    //     ];
143
+    //     $result = $this->getUrlResult($apiName, $request, $name);
144
+    //     $result = $result['sn_responseContent']['sn_body']['queryInverstmentcommodity'] ?? [];
145
+    //     Log::info($result);
146
+    //     // return json_encode($result);
147
+    // }
148
+
133 149
     public function su_cron()
134 150
     {
135 151
         try{
@@ -143,31 +159,69 @@ class Su extends BaseController
143 159
                     'couponMark' => 1,
144 160
                 ];
145 161
                 $result = $this->getUrlResult($apiName, $request, $name);
162
+                
146 163
                 $result = $result['sn_responseContent']['sn_body']['queryInverstmentcommodity'] ?? [];
147 164
                 $total += count($result);
165
+                // Log::info("===============su_cron===================");
166
+                // Log::info($result);
148 167
                 foreach ($result as $k => $goods) {
149
-                    $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $goods['commodityInfo']['commodityPrice'] * $goods['commodityInfo']['rate'] / 100 ?? '');
168
+                    
169
+                    // $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $goods['commodityInfo']['commodityPrice'] * $goods['commodityInfo']['rate'] / 100 ?? '');
170
+                    
171
+                    $commission=$goods['commodityInfo']['commodityPrice'] * $goods['commodityInfo']['rate'] / 100; //佣金
172
+                    $pv=$commission* 0.5;  //PV
173
+                    $yanglaojin=$pv*0.05; //新的养老金
174
+
175
+
150 176
                     if($yanglaojin < 0.1) {
151 177
                         continue;
152 178
                     }
179
+
180
+                    //记录分类id到本地数据库
181
+                    $cid=$goods['categoryInfo']['firstSaleCategoryId'];
182
+                    $c_name=$goods['categoryInfo']['firstSaleCategoryName'];
183
+                    (new ThirdPartyCategory())->addOrUpdateCategory($cid,$c_name , 4);
184
+
185
+
153 186
                     $goods = [
154 187
                         'type' => 3,//苏宁商品
155 188
                         'id' => $goods['commodityInfo']['commodityCode'] ?? '', //id
156 189
                         'thumb' => $goods['commodityInfo']['pictureUrl'][0]['picUrl'] ?? '',//商品缩略图
157 190
                         'name' => $goods['commodityInfo']['commodityName'],//名称
158
-                        'commission' => $yanglaojin,//佣金
191
+                        
192
+                        'pv' => $pv,//佣金
193
+                        'gongxian'=>$pv, //贡献
194
+                        'jifen'=>$pv, //积分
195
+                        'yanglaojin' => $yanglaojin,//养老金
196
+
197
+
198
+                        'commission' => $yanglaojin,//养老金
199
+
159 200
                         'commission_rate' => $goods['commodityInfo']['rate'] ?? '',//佣金比例
160 201
                         'sales' => $goods['commodityInfo']["monthSales"],
161 202
                         'coupon_money' => $goods['couponInfo'] ?? [],
162 203
                         'market_price' => $goods['commodityInfo']['snPrice'],//苏宁价
163 204
                         'price' => $goods['commodityInfo']['commodityPrice'] ?? '', //价格
205
+
206
+                        'shopName'=>$goods['commodityInfo']['supplierName'], //店铺名称
207
+                        'monthSales'=>$goods['commodityInfo']['monthSales']>0?$goods['commodityInfo']['monthSales']:mt_rand(100,10000) //月销量
164 208
                     ];
165 209
 
210
+                    // Log::info([
211
+                    //     'json' => json_encode($goods, JSON_UNESCAPED_UNICODE),
212
+                    //     'type' => 4,
213
+                    //     'pension' => $yanglaojin,
214
+                    //     'cid'=>$cid //一级分类
215
+                    // ]);
216
+
166 217
                     Db::name("third_party_goods")->insert([
167 218
                         'json' => json_encode($goods, JSON_UNESCAPED_UNICODE),
168 219
                         'type' => 4,
169
-                        'pension' => $yanglaojin
220
+                        'pension' => $yanglaojin,
221
+                        'cid'=>$cid //一级分类
170 222
                     ]);
223
+                    
224
+                    // Log::info($yanglaojin);
171 225
                 }
172 226
             }
173 227
             Log::info('苏宁获取的商品总数:' . $total);
@@ -180,8 +234,27 @@ class Su extends BaseController
180 234
     public function GoodList()
181 235
     {
182 236
         [$page, $limit] = $this->getPage();
237
+
238
+        $_cid = $this->request->param('cid');
239
+        $keyword = $this->request->param('keyword');
240
+
241
+        // $goods_obj = Db::name('third_party_goods')->where('type', 4)->page($page, $limit)->select()->toArray();
242
+        $goods_obj = Db::name('third_party_goods')->where('type', 4);
243
+        if($keyword){
244
+            $goods_obj=$goods_obj->where('json', 'like', '%' . $keyword . '%');
245
+        }
246
+        if($_cid){
247
+            $goods_obj=$goods_obj->where('cid', $_cid);
248
+        }
249
+
250
+        $data=$goods_obj->page($page, $limit)
251
+        ->select()->toArray();
252
+        
253
+
254
+
255
+
183 256
         // 获取列表数据
184
-        $data = Db::name('third_party_goods')->where('type', 4)->page($page, $limit)->select()->toArray();
257
+        
185 258
         $goodslist = [];
186 259
         if(!empty($data)) {
187 260
             foreach ($data as $value) {
@@ -189,6 +262,17 @@ class Su extends BaseController
189 262
                 $json['market_price']=set_price_rtrim($json['market_price']);
190 263
                 $json['price']=set_price_rtrim($json['price']);
191 264
                 $json['commission']=set_price_rtrim($json['commission']);
265
+
266
+                $json['pension'] = $json['pension']??'0';
267
+
268
+                $json['pv'] = isset($json['pv'])?$json['pv']:0;
269
+                $json['gongxian'] = isset($json['gongxian'])?$json['gongxian']:0;
270
+                $json['jifen'] = isset($json['jifen'])?$json['jifen']:0;
271
+                $json['yanglaojin'] =isset($json['yanglaojin'])?$json['yanglaojin']:0;
272
+
273
+                $json['shopName'] = isset($json['shopName'])?$json['shopName']:"";
274
+                $json['monthSales'] = isset($json['monthSales'])?$json['monthSales']:0;
275
+                $json['cid'] = isset($value['cid'])?$value['cid']:0;
192 276
                 $goodslist[] = $json;
193 277
 
194 278
             }
@@ -306,20 +390,39 @@ class Su extends BaseController
306 390
     public function search()
307 391
     {
308 392
         [$page, $limit] = $this->getPage();
309
-        $keyword = $this->request->param(['keyword']);
393
+        $keyword = $this->request->param('keyword');
394
+        $_cid = $this->request->param('cid');
395
+        // dd($_cid);
310 396
         $userId = $this->request->uid();
311 397
         TaoKe::set_third_history($userId,$keyword['keyword']);
312 398
 
313
-        $goods = Db::name('third_party_goods')
314
-            ->where('type', 4)
315
-            ->where('json', 'like', '%' . $keyword['keyword'] . '%')
316
-            ->page($page, $limit)
399
+        $goods_obj = Db::name('third_party_goods')
400
+            ->where('type', 4);
401
+        if($keyword){
402
+            $goods_obj=$goods_obj->where('json', 'like', '%' . $keyword . '%');
403
+        }
404
+        if($_cid){
405
+            $goods_obj=$goods_obj->where('cid', $_cid);
406
+        }
407
+        $goods=$goods_obj->page($page, $limit)
317 408
             ->select()->toArray();
318 409
         $goodsList = [];
319 410
 
320 411
         if(!empty($goods)) {
321 412
             foreach ($goods as $value) {
322
-                $goodsList[] = json_decode($value['json'], true);
413
+                $json = json_decode($value['json'], true);
414
+                $json['pension'] = $json['pension']??'0';
415
+                $json['pv'] = $json['pension']*0.5;
416
+
417
+                $json['pv'] = isset($json['pv'])?$json['pv']:0;
418
+                $json['gongxian'] = isset($json['gongxian'])?$json['gongxian']:0;
419
+                $json['jifen'] = isset($json['jifen'])?$json['jifen']:0;
420
+                $json['yanglaojin'] =isset($json['yanglaojin'])?$json['yanglaojin']:0;
421
+
422
+                $json['shopName'] = isset($json['shopName'])?$json['shopName']:"";
423
+                $json['monthSales'] = isset($json['monthSales'])?$json['monthSales']:0;
424
+                $json['cid'] = isset($value['cid'])?$value['cid']:0;
425
+                $goodsList[] = $json;
323 426
             }
324 427
         }
325 428
         return app('json')->success('搜索苏宁商品列表成功', $goodsList);
@@ -418,6 +521,22 @@ class Su extends BaseController
418 521
         $result = $result['sn_responseContent']['sn_body']['getUnionInfomation'][0] ?? [];
419 522
         //获取商品的图文详情
420 523
         $detail = $this->goodImgDetail($result['mertCode'] ?? '', $result['goodsCode'] ?? '');
524
+
525
+
526
+        $commission=$result['wapPrePayCommission'] ; //佣金(预估)
527
+        $pv=$commission* 0.5;  //PV
528
+        $yanglaojin=$pv*0.05; //新的养老金
529
+
530
+        $gongxian=$pv; //新的养老金
531
+        $jifen=$pv; //新的养老金
532
+        
533
+
534
+        $result['pv']=round($pv,2);
535
+        $result['yanglaojin']=round($yanglaojin,2);
536
+        $result['gongxian']=round($gongxian,2);
537
+        $result['jifen']=round($jifen,2);
538
+
539
+        // Log::info($result);
421 540
         $result['detail'] = $detail;
422 541
         //商品和券二合一
423 542
         $result['url'] = $this->toOneUrl($uid, $result['productUrl'], $url['couponUrl'] ?? '');

+ 34 - 4
app/controller/api/store/product/TaoKe.php

@@ -184,7 +184,7 @@ class TaoKe extends BaseController
184 184
         }
185 185
         $goodsList = [];
186 186
         foreach ($goodsResult as $goods) {
187
-            // var_dump($goods);
187
+            //var_dump($goods);
188 188
             $min_normal_price = sprintf('%.2f', $goods['min_normal_price'] / 100);
189 189
             $groupPrice = sprintf('%.2f', $goods['min_group_price'] / 100);
190 190
             //优惠券面额,单位为分
@@ -192,16 +192,34 @@ class TaoKe extends BaseController
192 192
             //佣金比例,千分比
193 193
             $commissionRate = $goods['promotion_rate'];
194 194
 
195
-            $commission = sprintf('%.2f', (($groupPrice * $commissionRate) / 1000));
195
+            $commission = sprintf('%.2f', (($groupPrice * $commissionRate) / 1000));  //佣金
196 196
             //将佣金根据用户等级转成积分
197 197
             //$userCommissionIntegral = getCommission($userLevel, $commission);
198
-            $goodsList[] = [
198
+
199
+            // $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
200
+
201
+            $pv=$commission* 0.5;  //PV
202
+            $yanglaojin=$pv*0.05; //新的养老金
203
+
204
+            if($yanglaojin < 0.1) {
205
+                continue;
206
+            }
207
+
208
+            
209
+            
210
+            $this_goods= [
199 211
                 'type' => 1,//拼多多商品
200 212
                 'id' => $goods['goods_sign'] ?? $goods['goods_id'],
201 213
                 'thumb' => $goods['goods_thumbnail_url'],//商品缩略图
202 214
                 'name' => $goods['goods_name'],
203
-                'commission' => app()->make(ProductRepository::class)->thirdYanglaojin(0, $commission),
215
+                'commission' => $yanglaojin, //养老金  //app()->make(ProductRepository::class)->thirdYanglaojin(0, $commission),
204 216
                 'commission_' => $commission,
217
+
218
+                'yanglaojin' => $yanglaojin,
219
+                'pv' => $pv,
220
+                'gongxian'=>$pv,
221
+                'jifen'=>$pv,
222
+
205 223
                 'commission_rate' => $commissionRate,
206 224
                 'sales' => $goods['sales_tip'],
207 225
                 //'desc' => $goods['goods_desc'],
@@ -209,7 +227,19 @@ class TaoKe extends BaseController
209 227
 //                'market_price' => $groupPrice,
210 228
                 'market_price' => set_price_rtrim(sprintf('%.2f', $groupPrice - $couponMoney)),
211 229
                 'price' => set_price_rtrim(sprintf('%.2f', $min_normal_price - $couponMoney)),
230
+
231
+                'shopName'=>$goods['mall_name'], //店铺名称
232
+                'monthSales'=>$goods['sales_tip']>0?$goods['sales_tip']:mt_rand(100,10000) //月销量
212 233
             ];
234
+            $goodsList[] =$this_goods;
235
+            $cid=isset($goods['cat_ids'][0])?$goods['cat_ids'][0]:0;
236
+            Db::name("third_party_goods")->insert([
237
+                'json' => json_encode($this_goods, JSON_UNESCAPED_UNICODE),
238
+                'type' => 3,
239
+                'pension' => $yanglaojin,
240
+                'cid'=>$cid //一级分类
241
+            ]);
242
+
213 243
         }
214 244
         shuffle($goodsList);
215 245
         return app('json')->success('获取拼多多商品列表成功', $goodsList);

+ 58 - 0
app/controller/api/store/product/ThirdCategory.php

@@ -0,0 +1,58 @@
1
+<?php
2
+
3
+namespace app\controller\api\store\product;
4
+
5
+use app\common\model\system\admin\Log;
6
+use app\common\model\user\User;
7
+use app\common\model\user\UserThird;
8
+use app\common\model\user\UserThirdOrder;
9
+use app\common\repositories\store\product\ProductRepository;
10
+use app\common\repositories\user\UserRepository;
11
+use app\common\repositories\user\UserThirdRepository;
12
+use app\model\common\JdOrderModel;
13
+use app\model\common\TbOrderModel;
14
+use app\model\common\VipOrderModel;
15
+use think\App;
16
+use crmeb\basic\BaseController;
17
+use think\Collection;
18
+use think\facade\Db;
19
+use think\Exception;
20
+use think\exception\ValidateException;
21
+use app\controller\api\store\service\ThirdPartyCategory;
22
+
23
+//第三方分类
24
+class ThirdCategory extends BaseController
25
+{
26
+
27
+    protected $app = null;
28
+    /**
29
+     * @var
30
+     */
31
+    protected $uid;
32
+    protected $userThird;
33
+
34
+
35
+    /**
36
+     * StoreCoupon constructor.
37
+     * @param App $app
38
+     */
39
+    public function __construct(App $app)
40
+    {
41
+        $this->app = $app;
42
+        parent::__construct($app);
43
+        $this->userThird = app()->make(UserThirdRepository::class);
44
+
45
+    }
46
+
47
+    public function get_category(){
48
+        $type = $this->request->param('type');
49
+        $obj=Db::name("third_party_category");
50
+        if($type){
51
+            $obj->where('type',$type);
52
+        }
53
+        $category=$obj->select()->toArray();
54
+        return app('json')->success('获取成功', $category);
55
+    }
56
+    
57
+
58
+}

+ 87 - 10
app/controller/api/store/product/Vip.php

@@ -18,6 +18,7 @@ use think\Collection;
18 18
 use think\facade\Db;
19 19
 use think\Exception;
20 20
 use think\exception\ValidateException;
21
+use app\controller\api\store\service\ThirdPartyCategory;
21 22
 
22 23
 class Vip extends BaseController
23 24
 {
@@ -168,29 +169,54 @@ class Vip extends BaseController
168 169
                     $couponMoney = $couponInfo ? $couponInfo['fav'] : 0;
169 170
                     $commissionRate = $goods['commissionRate'];
170 171
                     $commission = $goods['commission'];
171
-                    $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
172
+
173
+                    $pv=$commission* 0.5;  //PV
174
+                    $yanglaojin=$pv*0.05; //新的养老金
175
+
176
+
177
+                    // $yanglaojin = app()->make(ProductRepository::class)->yanglaojin(0, $commission);
172 178
                     if($yanglaojin < 0.1) {
173 179
                         continue;
174 180
                     }
181
+
182
+                    
183
+                    //记录分类id到本地数据库
184
+                    $cid=$goods['cat1stId'];
185
+                    $c_name=$goods['cat1stName'];
186
+                    (new ThirdPartyCategory())->addOrUpdateCategory($cid,$c_name , 5);
187
+
188
+
175 189
                     $goods = [
176 190
                         'type' => 2,//唯品会商品
177 191
                         'id' => $goods['goodsId'],
178 192
                         'thumb' => $goods['goodsThumbUrl'],//商品缩略图
179 193
                         'name' => $goods['goodsName'],
180
-                        'commission' => app()->make(ProductRepository::class)->yanglaojin(0, $commission),//佣金
194
+
195
+                        'pv'=>$pv, //PV金
196
+                        'gongxian'=>$pv,
197
+                        'jifen'=>$pv,
198
+                        'yanglaojin' => $yanglaojin,
199
+
200
+                        'commission' => $yanglaojin, //养老金 //app()->make(ProductRepository::class)->yanglaojin(0, $commission),//佣金
181 201
                         'commission_rate' => $commissionRate,
182 202
                         'sales' => "",
183 203
                         'coupon_money' => $couponMoney,
184 204
                         'market_price' => $goods['marketPrice'],
185 205
                         'price' => $goods['vipPrice'],
186 206
                         'coupon_info' => $couponInfo,
207
+
208
+                        'shopName'=>$goods['storeInfo']['storeName'], //店铺名称
209
+                        'monthSales'=>$goods['productSales']>0?$goods['productSales']:mt_rand(100,10000) //月销量
187 210
                     ];
188 211
 
189 212
                     Db::name("third_party_goods")->insert([
190 213
                         'json' => json_encode($goods, JSON_UNESCAPED_UNICODE),
191 214
                         'type' => 5,
192
-                        'pension' => $yanglaojin
215
+                        'pension' => $yanglaojin,
216
+                        'cid'=>$cid //一级分类
193 217
                     ]);
218
+
219
+
194 220
                 }
195 221
                 if(!isset($result['result']['lastPage']) || $result['result']['lastPage']) {
196 222
                     return;
@@ -273,6 +299,18 @@ class Vip extends BaseController
273 299
                 $json['market_price']=set_price_rtrim($json['market_price']);
274 300
                 $json['price']=set_price_rtrim($json['price']);
275 301
 
302
+                $json['pension'] = $json['pension']??'0';
303
+                
304
+                $json['pv'] = isset($json['pv'])?$json['pv']:0;
305
+                $json['gongxian'] = isset($json['gongxian'])?$json['gongxian']:0;
306
+                $json['jifen'] = isset($json['jifen'])?$json['jifen']:0;
307
+                $json['yanglaojin'] =isset($json['yanglaojin'])?$json['yanglaojin']:0;
308
+
309
+
310
+                
311
+                $json['shopName'] = isset($json['shopName'])?$json['shopName']:"";
312
+                $json['monthSales'] = isset($json['monthSales'])?$json['monthSales']:0;
313
+                $json['cid'] = isset($value['cid'])?$value['cid']:0;
276 314
                 $goodslist[] = $json;
277 315
             }
278 316
         }
@@ -338,18 +376,42 @@ class Vip extends BaseController
338 376
     {
339 377
         [$page, $limit] = $this->getPage();
340 378
         $keyword = $this->request->param('keyword');
379
+        $_cid = $this->request->param('cid');
380
+
341 381
         $userId = $this->request->uid();
342 382
         TaoKe::set_third_history($userId,$keyword);
343 383
 
344
-        $goods = Db::name('third_party_goods')
345
-            ->where('type', 5)
346
-            ->where('json', 'like', '%' . $keyword . '%')
347
-            ->page($page, $limit)
384
+        // $goods = Db::name('third_party_goods')
385
+        //     ->where('type', 5)
386
+        //     ->where('json', 'like', '%' . $keyword . '%')
387
+        //     ->page($page, $limit)
388
+        //     ->select()->toArray();
389
+
390
+        
391
+        $goods_obj = Db::name('third_party_goods')
392
+            ->where('type', 5);
393
+        if($keyword){
394
+            $goods_obj=$goods_obj->where('json', 'like', '%' . $keyword . '%');
395
+        }
396
+        if($_cid){
397
+            $goods_obj=$goods_obj->where('cid', $_cid);
398
+        }
399
+        $goods=$goods_obj->page($page, $limit)
348 400
             ->select()->toArray();
401
+
402
+
349 403
         $goodsList = [];
350 404
         if(!empty($goods)) {
351 405
             foreach ($goods as $value) {
352
-                $goodsList[] = json_decode($value['json'], true);
406
+                $json = json_decode($value['json'], true);
407
+                $json['pension'] = $json['pension']??'0';
408
+                $json['pv'] = $json['pension']*0.5;
409
+                $json['yanglaojin'] = $json['pv']*0.05;
410
+
411
+                $json['shopName'] = "";
412
+                $json['monthSales'] = "0";
413
+                $json['cid'] = "0";
414
+                $goodsList[] = $json;
353 415
             }
354 416
         }
355 417
         return app('json')->success('获取唯品会商品列表成功', $goodsList);
@@ -448,8 +510,23 @@ class Vip extends BaseController
448 510
         $result = $this->getUrlResult($apiName, "getByGoodsIds", $params);
449 511
         if(empty($result))
450 512
             return app('json')->fail('商品下架不存在', null, 401);
451
-        $result['yanglao'] = app()->make(ProductRepository::class)
452
-            ->yanglaojin(0, $result['result'][0]['vipPrice'] * $result['result'][0]['commissionRate'] / 100);
513
+        // $result['yanglao'] = app()->make(ProductRepository::class)
514
+        //     ->yanglaojin(0, $result['result'][0]['vipPrice'] * $result['result'][0]['commissionRate'] / 100);
515
+
516
+        $commission=$result['result'][0]['vipPrice'] * $result['result'][0]['commissionRate'] / 100 ; //佣金(预估)
517
+        $pv=$commission* 0.5;  //PV
518
+        $yanglaojin=$pv*0.05; //新的养老金
519
+
520
+        $gongxian=$pv; //新的养老金
521
+        $jifen=$pv; //新的养老金
522
+        
523
+
524
+        $result['pv']=round($pv,2);
525
+        $result['yanglaojin']=round($yanglaojin,2);
526
+        $result['gongxian']=round($gongxian,2);
527
+        $result['jifen']=round($jifen,2);
528
+
529
+
453 530
         $result['wphlink'] = $this->vip_link($param['goodsId'], $chanTag['pid']);//获取唯品会联盟链接
454 531
         return app('json')->success($result);
455 532
     }

+ 135 - 0
app/controller/api/store/service/ThirdPartyCategory.php

@@ -0,0 +1,135 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020/5/29
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\controller\api\store\service;
12
+
13
+
14
+use crmeb\basic\BaseController;
15
+use app\common\repositories\store\service\StoreServiceLogRepository;
16
+use app\common\repositories\store\service\StoreServiceRepository;
17
+use think\App;
18
+use think\db\exception\DataNotFoundException;
19
+use think\db\exception\DbException;
20
+use think\db\exception\ModelNotFoundException;
21
+
22
+use think\facade\Db;
23
+use think\facade\Log;
24
+use think\facade\Cache;
25
+
26
+/**
27
+ * Class Service
28
+ * @package app\controller\api\store\service
29
+ * @author xaboy
30
+ * @day 2020/5/29
31
+ */
32
+class ThirdPartyCategory extends BaseController
33
+{
34
+    /**
35
+     * @var StoreServiceRepository
36
+     */
37
+    // protected $model; // 模型
38
+
39
+    /**
40
+     * Service constructor.
41
+     * @param App $app
42
+     * @param StoreServiceRepository $repository
43
+     */
44
+    public function __construct()
45
+    {
46
+        
47
+        
48
+        // $this->model=Db::name("third_party_category");
49
+    }
50
+
51
+    
52
+
53
+    /**
54
+     * 添加或更新分类数据,并更新缓存
55
+     * @param int $cid 分类ID
56
+     * @param string $c_name 分类名称
57
+     * @param int $type 平台类型
58
+     * @return bool|int|string 成功返回ID或true,失败返回错误信息字符串
59
+     */
60
+    public function addOrUpdateCategory(int $cid, string $c_name, int $type)
61
+    {
62
+        // 1. 尝试从缓存中获取数据
63
+        $cacheKey = $this->getCacheKey($cid, $type);
64
+        $cachedData = Cache::get($cacheKey);
65
+
66
+        if ($cachedData) {
67
+            return true; // 缓存命中,说明已存在,直接返回 true
68
+        }
69
+
70
+        // 2. 查询数据库
71
+        $existingRecord = Db::name("third_party_category")
72
+            ->where('cid', $cid)
73
+            ->where('type', $type)
74
+            ->find();
75
+        
76
+        if ($existingRecord) {
77
+            // 3. 数据库中已存在,更新缓存并返回true
78
+            Cache::set($cacheKey, $existingRecord, 3600); // 缓存 1 小时
79
+            return true;
80
+        }
81
+
82
+        // 4. 数据库中不存在,写入新记录
83
+        $data = [
84
+            'cid' => $cid,
85
+            'c_name' => $c_name,
86
+            'type' => $type,
87
+        ];
88
+
89
+        try {
90
+            $result = Db::name("third_party_category")->save($data);
91
+            if ($result === false){
92
+                Log::info('Error: Database save failed.');
93
+                return 'Error: Database save failed.';
94
+            }
95
+        } catch (\Exception $e) {
96
+            Log::info('Error: Database exception - ' . $e->getMessage());
97
+            return 'Error: Database exception - ' . $e->getMessage();
98
+        }
99
+
100
+        if ($result) {
101
+            // 5. 写入成功,更新缓存
102
+            Cache::set($cacheKey, $data, 3600); // 缓存 1 小时
103
+            // return $this->model->id; //返回新插入的ID
104
+        } else {
105
+            Log::info('Error: Unknown database error.');
106
+            // return 'Error: Unknown database error.';
107
+        }
108
+    }
109
+
110
+        /**
111
+     * 生成缓存键
112
+     * @param int $cid 分类ID
113
+     * @param int $type 平台类型
114
+     * @return string
115
+     */
116
+    private function getCacheKey(int $cid, int $type): string
117
+    {
118
+        return 'category_' . $cid . '_' . $type;
119
+    }
120
+
121
+    /**
122
+     * 清除指定或所有分类缓存
123
+     * @param int|null $cid 可选,分类ID,如果为null则清除所有分类缓存
124
+     * @param int|null $type 可选,平台类型,如果cid为null则忽略此参数
125
+     */
126
+    public function clearCategoryCache(int $cid = null, int $type=null)
127
+    {
128
+        if ($cid === null) {
129
+            Cache::clear(); // 清除所有缓存
130
+        } else {
131
+            $cacheKey = $this->getCacheKey($cid, $type);
132
+            Cache::delete($cacheKey);
133
+        }
134
+    }
135
+}

+ 11 - 1
route/admin.php

@@ -495,7 +495,14 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
495 495
             Route::post('upload/image', '/uploadImage')->name('wechatUploadImage');
496 496
             Route::post('upload/voice', '/uploadVoice')->name('wechatUploadVoice');
497 497
         })->prefix('admin.wechat.WechatReply');
498
-
498
+	
499
+	// 商家管理
500
+        Route::group('merchant/contribute', function () {
501
+            Route::post("list","admin.merchant.MerchantContribute/list");//图片列表
502
+            Route::post("add","admin.merchant.MerchantContribute/add");//新增
503
+            Route::post("edit","admin.merchant.MerchantContribute/edit");//更新
504
+            Route::post("delete","admin.merchant.MerchantContribute/delete");//删除
505
+        });
499 506
 
500 507
         /*//微信用户标签
501 508
         Route::group('wechat/user/tag',function(){
@@ -953,6 +960,9 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
953 960
         }) -> prefix('admin.order.Statistics');
954 961
 
955 962
     })->middleware(\app\common\middleware\AllowOriginMiddleware::class);
963
+    //Route::group('lplp',function (){
964
+//    Route::get('teamValue',"admin.user.TeamValue/getInfo");
965
+//});
956 966
 
957 967
     Route::miss(function () {
958 968
         return app('json')->fail('接口不存在');

+ 18 - 4
route/api.php

@@ -16,13 +16,19 @@ Route::miss(function () {
16 16
 //    return "接口不存在";
17 17
 //});
18 18
 Route::group('cxb/',function(){
19
-    Route::post('auth', 'api.YiJia/Auth');
19
+    Route::post('auth', 'api.YiJia/lp');
20 20
     Route::post('pension', 'api.YiJia/pension');
21 21
 })
22 22
     ->middleware(\app\common\middleware\IpCheckMiddleware::class)
23
-    ->middleware(\app\common\middleware\CheckYiJiaMiddleware::class)
24
-;
23
+    ->middleware(\app\common\middleware\CheckYiJiaMiddleware::class);
25 24
 
25
+Route::group('lplplp',function (){
26
+    // Route::get('teamValue',"Admin/User/TeamValue/getInfo");
27
+    Route::get('teamValue/info', 'admin.user.TeamValue/getInfo');
28
+    Route::post('teamValue/edit', 'admin.user.TeamValue/editInfo');
29
+})->middleware(\app\common\middleware\AllowOriginMiddleware::class)
30
+    ->middleware(\app\common\middleware\InstallMiddleware::class)
31
+    ->middleware(\app\common\middleware\CheckSiteOpenMiddleware::class);
26 32
 Route::group('api/', function () {
27 33
     Route::any('huiFuSettleIn','admin.system.merchant.MerchantIntention/huiFuSettleIn');//汇付入驻测试
28 34
     Route::any('test', 'api.Auth/test');
@@ -907,8 +913,12 @@ Route::group('api/', function () {
907 913
     Route::get('wechat/config', 'api.Wechat/jsConfig');
908 914
     //图片验证码
909 915
     Route::get('captcha', 'api.Auth/getCaptcha');
916
+
917
+
918
+    //返回第三方分类
919
+    Route::get('get_third_category','api.store.product.ThirdCategory/get_category');
910 920
     // 定时获取拼多多商品
911
-    //Route::get('get_pdd_list','api.store.product.DaTaoKe/pdd_cron');
921
+    // Route::get('get_pdd_list','api.store.product.DaTaoKe/pdd_cron');
912 922
     //获取拼多多商品
913 923
     Route::get('pdd/list', 'api.store.product.TaoKe/pdd_list');
914 924
     Route::get('pdd/orderlist', 'api.store.product.TaoKe/getOrder');
@@ -972,9 +982,13 @@ Route::group('api/', function () {
972 982
 
973 983
     /*苏宁商品*/
974 984
     Route::get('su/get_su_list', 'api.store.product.Su/su_cron');
985
+    Route::get('su/get_su_category', 'api.store.product.Su/su_get_category');
975 986
     Route::get('su/list', 'api.store.product.Su/GoodList');
976 987
     Route::get('su/order', 'api.store.product.Su/orderList');
977 988
     Route::get('su/SuMoney', 'api.store.product.Su/SuMoney');
989
+    Route::get('su/search2', 'api.store.product.Su/search');
990
+    Route::get('su/detail2/:id', 'api.store.product.Su/goodsDetail');
991
+    
978 992
 
979 993
 
980 994
     //云选联盟