13 Коммиты 7c9f4708ed ... d6129d4249

Автор SHA1 Сообщение Дата
  sunxbiao d6129d4249 Merge branch 'refs/heads/master' into dev месяцев назад: 4
  shichen f33ab1e5bd feat(order): 添加订单导出功能并优化Excel处理逻辑 месяцев назад: 4
  sunxbiao c45d8da737 平台后台-订单列表-增加PV关联查询 месяцев назад: 4
  sunxbiao ef29065216 Merge remote-tracking branch 'origin/dev' into dev месяцев назад: 4
  sunxbiao d8822abf60 平台后台-订单列表-增加PV关联查询 месяцев назад: 4
  shichen a37d4a667d fix(finance): 修复共富团数据查询中的键映射错误 месяцев назад: 4
  shichen bc2b55c7f3 Merge remote-tracking branch 'origin/dev' into dev месяцев назад: 4
  shichen 4adab3891e Merge branch 'dev-sc-260204' into dev месяцев назад: 4
  shichen 31239721ce feat(finance): 添加共富团队数据统计功能 месяцев назад: 4
  sunxbiao 00f48bd88b 共富区用户升级,增加升级条件,购买58635商品的普通用户升级为1星合伙人 месяцев назад: 4
  sunxbiao c4ff882089 修改注释 месяцев назад: 4
  shichen ba2a594a5c refactor(product): 重构产品价格更新命令中的数据结构 месяцев назад: 4
  shichen 1539a0e0aa refactor(product): 重构商品价格更新命令逻辑 месяцев назад: 4

+ 93 - 26
app/command/ProductPriceUpdate.php

@@ -2,8 +2,7 @@
2 2
 
3 3
 namespace app\command;
4 4
 
5
-use app\common\model\shared\SharedProsperityPartnerConsumeUpdateLog;
6
-use app\common\repositories\shared\SharedProsperityRecommendConfigRepository;
5
+use app\common\repositories\store\product\ProductRepository;
7 6
 use think\console\Command;
8 7
 use think\console\Input;
9 8
 use think\console\Output;
@@ -16,6 +15,8 @@ class ProductPriceUpdate extends Command
16 15
 
17 16
     const PRODUCT_IDS = [31053, 32171];
18 17
 
18
+    const MER_ID = 3447;
19
+
19 20
     protected function configure()
20 21
     {
21 22
         // 指令配置
@@ -34,32 +35,98 @@ class ProductPriceUpdate extends Command
34 35
 
35 36
     private function priceUpdate()
36 37
     {
37
-        // 获取当前数据
38
-        $productData = Db::name('store_product')->where(['product_id' => self::PRODUCT_IDS])->field('product_id,price')->select()->toArray();
39
-        $attrData = Db::name('store_product_attr_value')->where(['product_id' => self::PRODUCT_IDS])->field('product_id,price')->select()->toArray();
40
-        Db::startTrans();
41
-        try {
42
-            foreach ($productData as $product) {
43
-                $log = [
44
-                    'product_id' => $product['product_id'],
45
-                    'old_price' => $product['price'],
46
-                    'number' => self::NUMBER,
47
-                    'new_price' => $product['price'] + self::NUMBER,
48
-                ];
49
-                Db::name('product_price_update_log')->insert($log);
50
-
51
-                Db::name('store_product')->where(['product_id' => $product['product_id']])->inc('price', self::NUMBER)->update();
52
-                Db::name('store_product_attr_value')->where(['product_id' => $product['product_id']])->inc('price', self::NUMBER)->update();
53
-            }
54
-
55
-;
56
-            Db::commit();
57
-            return true;
58
-        } catch (\Exception $e) {
59
-            Db::rollback();
60
-            throw $e;
38
+        // 获取商品数据
39
+        $productData = Db::name('store_product')->where(['product_id' => self::PRODUCT_IDS])->select()->toArray();
40
+
41
+
42
+        /** @var ProductRepository $repository */
43
+        $repository = app()->make(ProductRepository::class);
44
+        foreach ($productData as $product) {
45
+            $log = [
46
+                'product_id' => $product['product_id'],
47
+                'old_price' => $product['price'],
48
+                'number' => self::NUMBER,
49
+                'new_price' => $product['price'] + self::NUMBER,
50
+            ];
51
+            Db::name('product_price_update_log')->insert($log);
52
+
53
+            $attrValue = Db::name('store_product_attr_value')->where(['product_id' => $product['product_id']])->select()->toArray();
54
+            $attrValue[0]['price'] = $attrValue[0]['price'] + self::NUMBER;
55
+            $content = Db::name('store_product_content')->where(['product_id' => $product['product_id']])->field('content')->find();
56
+
57
+            // $update = [
58
+            //
59
+            //     'couponData' => [],
60
+            //
61
+            //     'is_gift_bag' => $product['is_gift_bag'],
62
+            // ];
63
+
64
+
65
+
66
+            $update = [
67
+                'image' => $product['image'],
68
+                'slider_image' => explode(',',$product['slider_image']),
69
+                'store_name' => $product['store_name'],
70
+                'store_info' => $product['store_info'],
71
+                'keyword' => $product['keyword'],
72
+                'bar_code' => 0,
73
+                'brand_id' => $product['brand_id'],
74
+                'cate_id' => $product['cate_id'],
75
+                'mer_cate_id' => [],
76
+                'unit_name' => $product['unit_name'],
77
+                'sort' => $product['sort'],
78
+                'is_good' => $product['is_good'],
79
+                'video_link' => '',
80
+                'temp_id' => $product['temp_id'],
81
+                'content' => $content['content'],
82
+                'spec_type' => $product['spec_type'],
83
+                'extension_type' => $product['extension_type'],
84
+                'attr' => [],
85
+                'attrValue' => $attrValue,
86
+                'give_coupon_ids' => [],
87
+                'volunteer' => $product['volunteer'],
88
+                'type' => $product['type'],
89
+                'pension' => $product['pension'],
90
+                'commission' => $product['commission'],
91
+                'pension_is' => $product['pension_is'],
92
+                'share_is' => $product['share_is'],
93
+                'ficti' => $product['ficti'],
94
+                'icon_type' => [],
95
+                'status' => $product['status']
96
+            ];
97
+
98
+            $repository->update($product['product_id'],$update,self::MER_ID);
99
+            Db::name('product_share')->where('product_id',$product['product_id'])->where('share_channel',1)->update(['url'=>'']);
61 100
         }
62 101
 
102
+
103
+
104
+        // // 获取当前数据
105
+        // $productData = Db::name('store_product')->where(['product_id' => self::PRODUCT_IDS])->field('product_id,price')->select()->toArray();
106
+        // $attrData = Db::name('store_product_attr_value')->where(['product_id' => self::PRODUCT_IDS])->field('product_id,price')->select()->toArray();
107
+        // Db::startTrans();
108
+        // try {
109
+        //     foreach ($productData as $product) {
110
+        //         $log = [
111
+        //             'product_id' => $product['product_id'],
112
+        //             'old_price' => $product['price'],
113
+        //             'number' => self::NUMBER,
114
+        //             'new_price' => $product['price'] + self::NUMBER,
115
+        //         ];
116
+        //         Db::name('product_price_update_log')->insert($log);
117
+        //
118
+        //         Db::name('store_product')->where(['product_id' => $product['product_id']])->inc('price', self::NUMBER)->update();
119
+        //         Db::name('store_product_attr_value')->where(['product_id' => $product['product_id']])->inc('price', self::NUMBER)->update();
120
+        //     }
121
+        //
122
+        //     ;
123
+        //     Db::commit();
124
+        //     return true;
125
+        // } catch (\Exception $e) {
126
+        //     Db::rollback();
127
+        //     throw $e;
128
+        // }
129
+
63 130
     }
64 131
 
65 132
 }

+ 28 - 0
app/common/dao/store/order/StoreCartDao.php

@@ -218,4 +218,32 @@ class StoreCartDao extends BaseDao
218 218
             ->whereIn('cart_id', $cartIdList)
219 219
             ->update(['is_pay' => $isPay]);
220 220
     }
221
+
222
+    /**
223
+     * 获取 购物车实体 根基用户ID 商品ID列表 查询 已下单的(这里并非表示已支付) 购物车实体
224
+     * @param int $uid
225
+     * @param array $productIdList
226
+     * @return CartEntity[]
227
+     */
228
+    public function getCartEntityListByUidAndProductIdListAndIsPay(int $uid, array $productIdList): array
229
+    {
230
+        $entityList = [];
231
+        try {
232
+            /** @var StoreCart $model */
233
+            $model = $this->getModel();
234
+            $dataListRes = $model::getDB()
235
+                ->where('uid', '=', $uid)
236
+                ->whereIn('product_id', $productIdList)
237
+                ->where('is_pay', '=', CartEnum::IS_PAY['Yes']['code'])
238
+                ->select()
239
+                ->toArray();
240
+            if (!empty($dataListRes)) {
241
+                foreach ($dataListRes as $data) {
242
+                    $entityList[] = CartEntity::newInstance($data);
243
+                }
244
+            }
245
+        } catch (\Exception $e) {
246
+        }
247
+        return $entityList;
248
+    }
221 249
 }

+ 26 - 0
app/common/dao/store/order/StoreOrderDao.php

@@ -723,6 +723,32 @@ class StoreOrderDao extends BaseDao
723 723
     }
724 724
 
725 725
     /**
726
+     * @param array $cartIdList
727
+     * @return StoreOrderEntity[]
728
+     */
729
+    public function getStoreOrderEntityListByCartIdListAndIsPay(array $cartIdList): array
730
+    {
731
+        $entityList = [];
732
+        try {
733
+            /** @var StoreOrder $model */
734
+            $model = $this->getModel();
735
+            $dataRes = $model::getDB()
736
+                ->whereIn('card_id', $cartIdList)
737
+                ->where('paid', '=', StoreOrderEnum::PAID['YES']['code'])
738
+                ->select()
739
+                ->toArray();
740
+            if (!empty($dataRes)) {
741
+                $entityList = array_map(function ($data) {
742
+                    return StoreOrderEntity::newInstance($data);
743
+                }, $dataRes);
744
+            }
745
+        } catch (\Exception $e) {
746
+
747
+        }
748
+        return $entityList;
749
+    }
750
+
751
+    /**
726 752
      * 订单支付成功 更新订单状态
727 753
      * @param StoreOrderEntity[] $storeOrderEntityList
728 754
      * @return StoreOrderEntity[]

+ 17 - 0
app/common/model/store/order/StoreOrder.php

@@ -11,10 +11,14 @@
11 11
 namespace app\common\model\store\order;
12 12
 
13 13
 
14
+use app\common\enum\CommonEnum;
15
+use app\common\enum\shared\SharedProsperityRewardRecordEnum;
14 16
 use app\common\model\BaseModel;
17
+use app\common\model\shared\SharedProsperityRewardRecord;
15 18
 use app\common\model\store\service\StoreService;
16 19
 use app\common\model\system\merchant\Merchant;
17 20
 use app\common\model\user\User;
21
+use app\common\model\user\UserPvLog;
18 22
 use app\common\repositories\store\MerchantTakeRepository;
19 23
 
20 24
 class StoreOrder extends BaseModel
@@ -71,4 +75,17 @@ class StoreOrder extends BaseModel
71 75
     {
72 76
         return getModelTime($query, $value);
73 77
     }
78
+
79
+    public function userPvLog()
80
+    {
81
+        return $this->hasOne(UserPvLog::class, 'order_id', 'order_id')->where('order_type', '=', CommonEnum::ORDER_TYPE['Platform']['code']);
82
+    }
83
+
84
+    public function sharedProsperityRewardRecord()
85
+    {
86
+        return $this->hasOne(SharedProsperityRewardRecord::class, 'order_sn', 'order_sn')
87
+            ->where('type_shop', '=', SharedProsperityRewardRecordEnum::TYPE_SHOP['Platform']['code'])
88
+            ->where('type', '=', SharedProsperityRewardRecordEnum::TYPE['PV']['code'])
89
+            ->where('pm', '=', SharedProsperityRewardRecordEnum::PM['INCOME']['code']);
90
+    }
74 91
 }

+ 7 - 0
app/common/repositories/finance/FinanceRepository.php

@@ -398,6 +398,13 @@ class FinanceRepository extends BaseRepository
398 398
             $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[5] ?? 0), 'name' => '总裁合伙人', 'partner_level' => 5];
399 399
             $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[6] ?? 0), 'name' => '联席主席团', 'partner_level' => 6];
400 400
 
401
+            // 共富百人团、千人团、万人团数据
402
+            $sharedGroupUserDataQuery = Db::query("SELECT group_id,count(user_id) count FROM `rrx_shared_prosperity_group_user` group by group_id");
403
+            $sharedGroupUserDataQuery = array_column($sharedGroupUserDataQuery, 'count', 'group_id');
404
+            $data['four'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedGroupUserDataQuery[1] ?? 0), 'name' => '万人团', 'group_id' => 1];
405
+            $data['four'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedGroupUserDataQuery[2] ?? 0), 'name' => '千人团', 'group_id' => 2];
406
+            $data['four'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedGroupUserDataQuery[3] ?? 0), 'name' => '百人团', 'group_id' => 3];
407
+
401 408
             $res['left'] = $data;
402 409
         }
403 410
         return $res;

+ 32 - 11
app/common/repositories/shared/SharedProsperityUserRepository.php

@@ -9,6 +9,7 @@ use app\common\enum\CommonEnum;
9 9
 use app\common\enum\shared\SharedProsperityRewardRecordEnum;
10 10
 use app\common\enum\shared\SharedProsperityUserEnum;
11 11
 use app\common\repositories\BaseRepository;
12
+use app\common\repositories\store\order\StoreCartRepository;
12 13
 use app\common\repositories\store\order\StoreOrderRepository;
13 14
 use app\entity\data\shared\SharedProsperityGroupUserEntity;
14 15
 use app\entity\data\shared\SharedProsperityRecommendConfigEntity;
@@ -366,14 +367,33 @@ class SharedProsperityUserRepository extends BaseRepository
366 367
             // }
367 368
 
368 369
 
369
-            // 暂时新增加逻辑 用户购买 298 商品后,自动升级为1星合伙人,目前只有消费者 能够获得PV值,在奖励结算时,判断订单金额 是否大于 298 并且 用户身份为 用户,则升级为一星合伙人
370
-            // 逻辑修改,如果用户的身份 是普通用户,则统计他在共富区内 所有消费的金额,是否超 每天自增的 升级限制金额,如果超过则升级为1星合伙人
371 370
             if ($sharedProsperityUserEntity->getPartnerLevel() == 0) {
371
+                // 记录用户当前的 用户等级
372
+                $partnerLevel = $sharedProsperityUserEntity->getPartnerLevel();
373
+
374
+                // 新增需求 凡是 共富区,购买过商品ID 58635 的 ‘普通用户’ 升级为 ‘1星合伙人’
375
+                /** @var StoreCartRepository $storeCartRepository */
376
+                $storeCartRepository = app()->make(StoreCartRepository::class);
377
+                $storeCartEntityList = $storeCartRepository->getCartEntityListByUidAndProductIdListAndIsPay($sharedProsperityUserEntity->getUserId(), [58635]);
378
+                if (!empty($storeCartEntityList)) {
379
+                    $cartIdList = array_column($storeCartEntityList, 'cartId');
380
+                    if (!empty($cartIdList)) {
381
+                        /** @var StoreOrderRepository $storeOrderRepository */
382
+                        $storeOrderRepository = app()->make(StoreOrderRepository::class);
383
+                        $storeOrderEntityList = $storeOrderRepository->getStoreOrderEntityListByCartIdListAndIsPay($cartIdList);
384
+                        if (!empty($storeOrderEntityList)) {
385
+                            // 修改用户的等级
386
+                            $sharedProsperityUserEntity->setPartnerLevel(1);
387
+                        }
388
+                    }
389
+                }
390
+
391
+                // 暂时新增加逻辑 用户购买 298 商品后,自动升级为1星合伙人,目前只有消费者 能够获得PV值,在奖励结算时,判断订单金额 是否大于 298 并且 用户身份为 用户,则升级为一星合伙人
392
+                // 逻辑修改,如果用户的身份 是普通用户,则统计他在共富区内 所有消费的金额,是否超 每天自增的 升级限制金额,如果超过则升级为1星合伙人
372 393
                 /** @var StoreOrderRepository $storeOrderRepository */
373 394
                 $storeOrderRepository = app()->make(StoreOrderRepository::class);
374 395
                 $sumTotalPrice = $storeOrderRepository->getSumTotalPriceByUidAndMerId($sharedProsperityUserEntity->getUserId(), CommonEnum::DESIGN_MERCHANT_ID['SharedProsperity']['code']);
375 396
                 if (!empty($sumTotalPrice)) {
376
-                    $partnerLevel = $sharedProsperityUserEntity->getPartnerLevel();
377 397
                     /** @var SharedProsperityRecommendConfigRepository $sharedProsperityRecommendConfigRepository */
378 398
                     $sharedProsperityRecommendConfigRepository = app()->make(SharedProsperityRecommendConfigRepository::class);
379 399
                     $sharedProsperityRecommendConfigEntityList = $sharedProsperityRecommendConfigRepository->getList();
@@ -389,14 +409,15 @@ class SharedProsperityUserRepository extends BaseRepository
389 409
                             $sharedProsperityUserEntity->setPartnerLevel($sharedProsperityRecommendConfigEntity->getLevel());
390 410
                         }
391 411
                     }
392
-                    // 也就是说 升级了 保存到数据库
393
-                    if ($partnerLevel != $sharedProsperityUserEntity->getPartnerLevel()) {
394
-                        $this->updateByEntity(
395
-                            SharedProsperityUserEntity::newInstance()
396
-                                ->setId($sharedProsperityUserEntity->getId())
397
-                                ->setPartnerLevel($sharedProsperityUserEntity->getPartnerLevel())
398
-                        );
399
-                    }
412
+                }
413
+
414
+                // 也就是说 升级了 保存到数据库
415
+                if ($partnerLevel != $sharedProsperityUserEntity->getPartnerLevel()) {
416
+                    $this->updateByEntity(
417
+                        SharedProsperityUserEntity::newInstance()
418
+                            ->setId($sharedProsperityUserEntity->getId())
419
+                            ->setPartnerLevel($sharedProsperityUserEntity->getPartnerLevel())
420
+                    );
400 421
                 }
401 422
             }
402 423
 

+ 18 - 0
app/common/repositories/store/ExcelRepository.php

@@ -56,6 +56,24 @@ class ExcelRepository extends BaseRepository
56 56
     }
57 57
 
58 58
     /**
59
+     * @param array $where
60
+     * @param int $admin_id
61
+     * @param string $type
62
+     * @param int $merId
63
+     * @return \app\common\dao\BaseDao|\think\Model
64
+     * @author 史晨
65
+     * @date 2026/3/10 14:48
66
+     */
67
+    public function createNoJob(array $where ,int $admin_id, string $type,int $merId)
68
+    {
69
+        return $this->dao->create([
70
+            'mer_id'    => $merId,
71
+            'admin_id'  => $admin_id,
72
+            'type'      => $type
73
+        ]);
74
+    }
75
+
76
+    /**
59 77
      * TODO
60 78
      * @param array $where
61 79
      * @param int $page

+ 10 - 0
app/common/repositories/store/order/StoreCartRepository.php

@@ -156,4 +156,14 @@ class StoreCartRepository extends BaseRepository
156 156
     {
157 157
         return $this->dao->updateIsPayByCartIdList($cartIdList, $isPay);
158 158
     }
159
+
160
+    /**
161
+     * @param int $uid
162
+     * @param array $productIdList
163
+     * @return CartEntity[]
164
+     */
165
+    public function getCartEntityListByUidAndProductIdListAndIsPay(int $uid, array $productIdList): array
166
+    {
167
+        return $this->dao->getCartEntityListByUidAndProductIdListAndIsPay($uid, $productIdList);
168
+    }
159 169
 }

+ 23 - 7
app/common/repositories/store/order/StoreOrderRepository.php

@@ -5180,7 +5180,7 @@ class StoreOrderRepository extends BaseRepository
5180 5180
                     return $query->field('service_id,nickname');
5181 5181
                 }, 'user' => function ($query) {
5182 5182
                     return $query->field('uid,phone,nickname');
5183
-                }
5183
+                }, 'userPvLog', 'sharedProsperityRewardRecord'
5184 5184
             ]);
5185 5185
         $query1 = clone ($query);
5186 5186
         $query2 = clone ($query);
@@ -5214,6 +5214,13 @@ class StoreOrderRepository extends BaseRepository
5214 5214
             } else {
5215 5215
                 $list[$key]['fzone_paytype'] = null;
5216 5216
             }
5217
+            $list[$key]['pv'] = 0.00;
5218
+            if ($item['userPvLog']) {
5219
+                $list[$key]['pv'] = $item['userPvLog']['pv'];
5220
+            }
5221
+            if ($item['sharedProsperityRewardRecord']) {
5222
+                $list[$key]['pv'] = $item['sharedProsperityRewardRecord']['number'];
5223
+            }
5217 5224
         }
5218 5225
 
5219 5226
         $list1[] = ['count' => $fzone_pay_price, 'name' => '现金'];
@@ -10863,6 +10870,16 @@ class StoreOrderRepository extends BaseRepository
10863 10870
         return $this->dao->getStoreOrderEntityListByGroupOrderIdList($groupOrderIdList);
10864 10871
     }
10865 10872
 
10873
+    /**
10874
+     * 根据 购物车ID 获取 已下单的 并且 支付的 订单
10875
+     * @param array $cartIdList
10876
+     * @return StoreOrderEntity[]
10877
+     */
10878
+    public function getStoreOrderEntityListByCartIdListAndIsPay(array $cartIdList): array
10879
+    {
10880
+        return $this->dao->getStoreOrderEntityListByCartIdListAndIsPay($cartIdList);
10881
+    }
10882
+
10866 10883
     public function create($data)
10867 10884
     {
10868 10885
         return $this->dao->create($data);
@@ -12587,13 +12604,12 @@ class StoreOrderRepository extends BaseRepository
12587 12604
 
12588 12605
     /**
12589 12606
      * 共富区订单分账
12590
-     *
12591
-     * @param $merId
12592
-     * @param $timeLimit
12607
+     * @param $orderSn
12608
+     * @param $payType
12593 12609
      * @return void
12594
-     * @throws \think\db\exception\DataNotFoundException
12595
-     * @throws \think\db\exception\DbException
12596
-     * @throws \think\db\exception\ModelNotFoundException
12610
+     * @throws DataNotFoundException
12611
+     * @throws DbException
12612
+     * @throws ModelNotFoundException
12597 12613
      */
12598 12614
     private function sharedProsperityOrderIndependentAccount($orderSn, $payType)
12599 12615
     {

+ 7 - 3
app/controller/merchant/store/order/Order.php

@@ -337,10 +337,14 @@ class Order extends BaseController
337 337
         if($data['count']<1){
338 338
             return app('json')->fail('没有数据');
339 339
         }
340
-        $list=$this->orderList2($data['list']->toArray());
341
-//        var_dump($list);die;
340
+        $list = $this->orderList2($data['list']->toArray());
341
+
342
+        // app()->make(ExcelRepository::class)->create($list, $this->request->adminId(), 'order', $this->request->merId());
343
+        $adminId = $this->request->adminId();
344
+        $excelLog = app()->make(ExcelRepository::class)->createNoJob($list, $adminId, 'order', $where['mer_id']);
345
+
346
+        app()->make(ExcelService::class)->order($list,$excelLog->excel_id);
342 347
 
343
-        app()->make(ExcelRepository::class)->create($list, $this->request->adminId(), 'order', $this->request->merId());
344 348
         return app('json')->success('开始导出数据');
345 349
     }
346 350
     public function orderList2(array $data){