Просмотр исходного кода

Merge branch 'dev-sc-260204' into dev

shichen месяцев назад: 4
Родитель
Сommit
09e702d5ff

+ 40 - 0
app/command/DeleteApiLog.php

@@ -0,0 +1,40 @@
1
+<?php
2
+
3
+namespace app\command;
4
+
5
+use app\common\model\shared\SharedProsperityPartnerConsumeUpdateLog;
6
+use app\common\repositories\shared\SharedProsperityRecommendConfigRepository;
7
+use think\console\Command;
8
+use think\console\Input;
9
+use think\console\Output;
10
+use think\facade\Db;
11
+
12
+class DeleteApiLog extends Command
13
+{
14
+    // 上级
15
+    const DAY = 7;
16
+
17
+    protected function configure()
18
+    {
19
+        // 指令配置
20
+        $this->setName('deleteApiLog')
21
+            ->setDescription('定时删除api日志');
22
+    }
23
+
24
+    protected function execute(Input $input, Output $output)
25
+    {
26
+        $output->writeln('定时任务执行中...');
27
+
28
+        $this->delete();
29
+
30
+        $output->writeln('定时任务执行完成');
31
+    }
32
+
33
+    private function delete()
34
+    {
35
+        $time = time() - self::DAY * 24 * 60 * 60;
36
+        $time = date('Y-m-d', $time);
37
+        Db::name('api_request_log')->where('create_time', '<', $time)->limit(1000)->delete();
38
+    }
39
+
40
+}

+ 2 - 2
app/common/dao/shared/SharedProsperityUserDao.php

@@ -161,9 +161,9 @@ class SharedProsperityUserDao extends BaseDao
161
      * @param int $userId
161
      * @param int $userId
162
      * @return float
162
      * @return float
163
      */
163
      */
164
-    public function getTeamPvSum(int $userId, int $hierarchy = CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Hierarchy']['code']): float
164
+    public function getTeamPvSum(int $userId, int $hierarchy = CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Hierarchy']['code'], $includeSelf = false): float
165
     {
165
     {
166
-        $userIds = $this->getAllSubordinateUserIds($userId, false, $hierarchy);
166
+        $userIds = $this->getAllSubordinateUserIds($userId, $includeSelf, $hierarchy);
167
         if (empty($userIds)) {
167
         if (empty($userIds)) {
168
             return 0.0;
168
             return 0.0;
169
         }
169
         }

+ 14 - 0
app/common/dao/shared/SharedProsperityUserParentLogDao.php

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

+ 1 - 1
app/common/dao/store/order/StoreOrderDao.php

@@ -733,7 +733,7 @@ class StoreOrderDao extends BaseDao
733
             /** @var StoreOrder $model */
733
             /** @var StoreOrder $model */
734
             $model = $this->getModel();
734
             $model = $this->getModel();
735
             $dataRes = $model::getDB()
735
             $dataRes = $model::getDB()
736
-                ->whereIn('card_id', $cartIdList)
736
+                ->whereIn('cart_id', $cartIdList)
737
                 ->where('paid', '=', StoreOrderEnum::PAID['YES']['code'])
737
                 ->where('paid', '=', StoreOrderEnum::PAID['YES']['code'])
738
                 ->select()
738
                 ->select()
739
                 ->toArray();
739
                 ->toArray();

+ 18 - 0
app/common/model/shared/SharedProsperityUserParentLog.php

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

+ 19 - 8
app/common/repositories/finance/FinanceRepository.php

@@ -491,17 +491,28 @@ class FinanceRepository extends BaseRepository
491
         $dayWhere .= " and DATE(create_time) = '" . $todayFormatted . "'";
491
         $dayWhere .= " and DATE(create_time) = '" . $todayFormatted . "'";
492
         $sharedUserCount = Db::name('shared_prosperity_user')->count(); //共富会员总人数
492
         $sharedUserCount = Db::name('shared_prosperity_user')->count(); //共富会员总人数
493
         $sharedUserDayCount = Db::name('shared_prosperity_user')->where($dayWhere)->count(); //共富今日新增会员
493
         $sharedUserDayCount = Db::name('shared_prosperity_user')->where($dayWhere)->count(); //共富今日新增会员
494
-        $sharedUserPvCount = Db::name('shared_prosperity_reward_record')->where(['type'=>SharedProsperityRewardRecordEnum::TYPE['PV']['code']])->sum('number'); // 共富会员专区总业绩
495
-        $sharedUserLastWeekPv = Db::name('shared_prosperity_reward_record')->where($sWeekWhere)->where(['type'=>SharedProsperityRewardRecordEnum::TYPE['PV']['code']])->sum('number'); // 共富会员专区上周总业绩
496
-        $sharedUserWeekPv = Db::name('shared_prosperity_reward_record')->where($weekWhere)->where(['type'=>SharedProsperityRewardRecordEnum::TYPE['PV']['code']])->sum('number'); // 共富会员专区本周总业绩
497
-        $sharedUserTodayPv = Db::name('shared_prosperity_reward_record')->where($dayWhere)->where(['type'=>SharedProsperityRewardRecordEnum::TYPE['PV']['code']])->sum('number'); // 共富会员专区今日总业绩
494
+        $sharedUserPvCount = Db::name('shared_prosperity_reward_record')
495
+            ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
496
+            ->sum('number'); // 共富会员专区总业绩
497
+        $sharedUserLastWeekPv = Db::name('shared_prosperity_reward_record')
498
+            ->where($sWeekWhere)
499
+            ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
500
+            ->sum('number'); // 共富会员专区上周总业绩
501
+        $sharedUserWeekPv = Db::name('shared_prosperity_reward_record')
502
+            ->where($weekWhere)
503
+            ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
504
+            ->sum('number'); // 共富会员专区本周总业绩
505
+        $sharedUserTodayPv = Db::name('shared_prosperity_reward_record')
506
+            ->where($dayWhere)
507
+            ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
508
+            ->sum('number'); // 共富会员专区今日总业绩
498
 
509
 
499
         $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserCount, 'name' => '共富会员总人数'];
510
         $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserCount, 'name' => '共富会员总人数'];
500
         $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserDayCount, 'name' => '共富今日新增会员'];
511
         $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserDayCount, 'name' => '共富今日新增会员'];
501
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserPvCount, 'name' => '共富会员专区总业绩'];
502
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserLastWeekPv, 'name' => '共富会员专区上周总业绩'];
503
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserWeekPv, 'name' => '共富会员专区本周总业绩'];
504
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserTodayPv, 'name' => '共富会员专区今日总业绩'];
512
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserPvCount, 'name' => '共富专区总业绩'];
513
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserLastWeekPv, 'name' => '共富专区上周总业绩'];
514
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserWeekPv, 'name' => '共富专区本周总业绩'];
515
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserTodayPv, 'name' => '共富专区今日总业绩'];
505
 
516
 
506
         $res['left'][] = $data;
517
         $res['left'][] = $data;
507
         return $res;
518
         return $res;

+ 46 - 1
app/common/repositories/shared/SharedProsperityUserRepository.php

@@ -6,6 +6,7 @@ use app\common\dao\shared\SharedProsperityGroupUserDao;
6
 use app\common\dao\shared\SharedProsperityRewardRecordDao;
6
 use app\common\dao\shared\SharedProsperityRewardRecordDao;
7
 use app\common\dao\shared\SharedProsperityUserDao;
7
 use app\common\dao\shared\SharedProsperityUserDao;
8
 use app\common\dao\shared\SharedProsperityUserLevelLogDao;
8
 use app\common\dao\shared\SharedProsperityUserLevelLogDao;
9
+use app\common\dao\shared\SharedProsperityUserParentLogDao;
9
 use app\common\dao\user\UserDao;
10
 use app\common\dao\user\UserDao;
10
 use app\common\dao\user\UserWithdrawalLimitRecordDao;
11
 use app\common\dao\user\UserWithdrawalLimitRecordDao;
11
 use app\common\enum\CommonEnum;
12
 use app\common\enum\CommonEnum;
@@ -233,7 +234,7 @@ class SharedProsperityUserRepository extends BaseRepository
233
         foreach ($list as $index => &$item) {
234
         foreach ($list as $index => &$item) {
234
             $teamUserIds = $this->dao->getAllSubordinateUserIds($item['user_id'], false, 4);
235
             $teamUserIds = $this->dao->getAllSubordinateUserIds($item['user_id'], false, 4);
235
             $teamTotalCount = count($teamUserIds);
236
             $teamTotalCount = count($teamUserIds);
236
-            $teamPvSum = $this->dao->getTeamPvSum($item['user_id'], 4);
237
+            $teamPvSum = $this->dao->getTeamPvSum($item['user_id'], 4, true);
237
             $item['team_total_count'] = $teamTotalCount;
238
             $item['team_total_count'] = $teamTotalCount;
238
             $item['team_pv_sum'] = $teamPvSum;
239
             $item['team_pv_sum'] = $teamPvSum;
239
             // 补充用户信息
240
             // 补充用户信息
@@ -807,6 +808,50 @@ class SharedProsperityUserRepository extends BaseRepository
807
 
808
 
808
     /**
809
     /**
809
      * @param $userId
810
      * @param $userId
811
+     * @param $parentId
812
+     * @param $remark
813
+     * @param $operator
814
+     * @return string|void
815
+     * @throws DbException
816
+     * @throws \think\db\exception\DataNotFoundException
817
+     * @throws \think\db\exception\ModelNotFoundException
818
+     * @author 史晨
819
+     * @date 2026/3/16 09:35
820
+     * 更新用户上级
821
+     */
822
+    public function updateParent($userId, $parentId, $remark, $operator)
823
+    {
824
+        if ($userId == $parentId) {
825
+            return '不能设置自己为上级';
826
+        }
827
+        $userInfo = $this->dao->getWhere(['user_id' => $userId]);
828
+        if ($parentId == $userInfo->parent_id) {
829
+            return '上级未发生变化';
830
+        }
831
+        Db::startTrans();
832
+        try {
833
+            // 变更等级
834
+            $this->dao->updateByUserId($userId, ['parent_id' => $parentId]);
835
+            // 记录日志
836
+            /** @var SharedProsperityUserParentLogDao $logDao */
837
+            $logDao = app()->make(SharedProsperityUserParentLogDao::class);
838
+            $logDao->create([
839
+                'user_id' => $userId,
840
+                'old_parent' => $userInfo->parent_id,
841
+                'new_parent' => $parentId,
842
+                'operator' => $operator,
843
+                'remark' => $remark
844
+            ]);
845
+            Db::commit();
846
+        } catch (\Exception $e) {
847
+            Db::rollback();
848
+            return $e->getMessage();
849
+        }
850
+    }
851
+
852
+
853
+    /**
854
+     * @param $userId
810
      * @param $type
855
      * @param $type
811
      * @param $number
856
      * @param $number
812
      * @return bool
857
      * @return bool

+ 21 - 0
app/controller/admin/system/sharedProsperity/SharedProsperityUser.php

@@ -61,4 +61,25 @@ class SharedProsperityUser
61
         }
61
         }
62
         return app('json')->success('更新成功');
62
         return app('json')->success('更新成功');
63
     }
63
     }
64
+
65
+    /**
66
+     * @return mixed
67
+     * @author 史晨
68
+     * @date 2026/3/16 09:30
69
+     * 更新用户上级
70
+     */
71
+    public function updateParent()
72
+    {
73
+        /** @var SharedProsperityUserRepository $repository */
74
+        $repository = app()->make(SharedProsperityUserRepository::class);
75
+        $params = app('request')->params(['user_id', 'parent_id', 'remark']);
76
+        if (empty($params['user_id']) || empty($params['parent_id'] || empty($params['remark']))) {
77
+            return app('json')->fail('参数错误');
78
+        }
79
+        $res = $repository->updateParent($params['user_id'], $params['parent_id'], $params['remark'], request()->adminId());
80
+        if (is_string($res)) {
81
+            return app('json')->fail($res);
82
+        }
83
+        return app('json')->success('更新成功');
84
+    }
64
 }
85
 }

+ 8 - 0
app/controller/api/Auth.php

@@ -1695,6 +1695,14 @@ class Auth extends BaseController
1695
             return app('json')->fail('手机号未注册,请先注册');
1695
             return app('json')->fail('手机号未注册,请先注册');
1696
         }
1696
         }
1697
 
1697
 
1698
+        // 获取实名状态
1699
+        $ertification = Db::name("user_certification")->where("uid", $user["uid"])->where(['status'=>1])->find();
1700
+        $is_ertification = 1;
1701
+        if (!$ertification){
1702
+            $is_ertification = -1;
1703
+        }
1704
+        $user["is_ertification"] = $is_ertification;
1705
+
1698
         // if($this->source=='yhc' && $this->merId){
1706
         // if($this->source=='yhc' && $this->merId){
1699
         //     $where=['mer_id'=>$this->merId,'uid'=>$user->uid];
1707
         //     $where=['mer_id'=>$this->merId,'uid'=>$user->uid];
1700
         //     $count=Db::name('enterprise_user')->where($where)->count();
1708
         //     $count=Db::name('enterprise_user')->where($where)->count();

+ 1 - 0
config/console.php

@@ -36,5 +36,6 @@ return [
36
         'wiwibaoproductsync' => 'app\command\WiwibaoProductSync',
36
         'wiwibaoproductsync' => 'app\command\WiwibaoProductSync',
37
         'sharedPartnerConsumeUpdate' => 'app\command\SharedPartnerConsumeUpdate',
37
         'sharedPartnerConsumeUpdate' => 'app\command\SharedPartnerConsumeUpdate',
38
         'productPriceUpdate' => 'app\command\ProductPriceUpdate',
38
         'productPriceUpdate' => 'app\command\ProductPriceUpdate',
39
+        'deleteApiLog' => 'app\command\DeleteApiLog',
39
     ],
40
     ],
40
 ];
41
 ];

+ 2 - 0
route/admin.php

@@ -124,6 +124,8 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
124
         Route::get('sharedProsperity/user/updateLevel', 'admin.system.sharedProsperity.SharedProsperityUser/updateLevel');
124
         Route::get('sharedProsperity/user/updateLevel', 'admin.system.sharedProsperity.SharedProsperityUser/updateLevel');
125
         // 修改共富会员奖励
125
         // 修改共富会员奖励
126
         Route::get('sharedProsperity/user/updateReward', 'admin.system.sharedProsperity.SharedProsperityUser/updateReward');
126
         Route::get('sharedProsperity/user/updateReward', 'admin.system.sharedProsperity.SharedProsperityUser/updateReward');
127
+        // 修改共富会员上级
128
+        Route::get('sharedProsperity/user/updateParent', 'admin.system.sharedProsperity.SharedProsperityUser/updateParent');
127
 
129
 
128
         //组合数据
130
         //组合数据
129
         Route::group('group', function () {
131
         Route::group('group', function () {