13 次代碼提交 67ba2235e4 ... 206e2d5ecf

作者 SHA1 備註 提交日期
  shichen 206e2d5ecf fix(store): 激活购物车实体检查逻辑 8 月之前
  shichen fbd04f825c Merge remote-tracking branch 'origin/dev' into dev 8 月之前
  shichen 0aaf1cfbd5 fix(repository): 修复用户签到xfb查询逻辑 8 月之前
  xupuyuan 846c9415d8 Merge remote-tracking branch 'origin/dev' into dev 8 月之前
  xupuyuan 34cb776af0 商品分类-取消硬编码-修复错误 8 月之前
  shichen 4594e52949 refactor(user): 更新用户签到xfb仓库依赖注入 8 月之前
  shichen 6738ca7a6a Merge remote-tracking branch 'origin/dev' into dev 8 月之前
  shichen cb9a176683 fix(order): test 8 月之前
  xupuyuan c4c048cdd9 Merge branch 'master' into dev 8 月之前
  shichen 1d4b245f71 feat(store): 添加购物车商品ID列表查询功能并优化订单幸福币发放逻辑 8 月之前
  shichen a4aa2386b6 feat(order): 添加共富区订单幸福币发放和结算功能 8 月之前
  shichen 645c5465a4 fix(user): 添加参数验证防止空类型查询 8 月之前
  shichen 364a6415ce feat(api): 添加幸福币记录功能 8 月之前

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

@@ -246,4 +246,26 @@ class StoreCartDao extends BaseDao
246 246
         }
247 247
         return $entityList;
248 248
     }
249
+
250
+    public function getCartEntityListByUidAndProductIdList(int $uid, array $productIdList): array
251
+    {
252
+        $entityList = [];
253
+        try {
254
+            /** @var StoreCart $model */
255
+            $model = $this->getModel();
256
+            $dataListRes = $model::getDB()
257
+                ->where('uid', '=', $uid)
258
+                ->whereIn('product_id', $productIdList)
259
+                ->select()
260
+                ->toArray();
261
+            if (!empty($dataListRes)) {
262
+                foreach ($dataListRes as $data) {
263
+                    $entityList[] = CartEntity::newInstance($data);
264
+                }
265
+            }
266
+        } catch (\Exception $e) {
267
+        }
268
+        return $entityList;
269
+    }
270
+
249 271
 }

+ 20 - 0
app/common/dao/user/UserSignXfbDao.php

@@ -0,0 +1,20 @@
1
+<?php
2
+
3
+namespace app\common\dao\user;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\BaseModel;
7
+use app\common\model\user\UserSignVr;
8
+use app\entity\CommonEntity;
9
+use app\entity\data\user\UserSignVrEntity;
10
+
11
+class UserSignXfbDao extends BaseDao
12
+{
13
+    /**
14
+     * @return BaseModel
15
+     */
16
+    protected function getModel(): string
17
+    {
18
+        return UserSignVr::class;
19
+    }
20
+}

+ 19 - 0
app/common/model/user/UserSignXfb.php

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

+ 2 - 2
app/common/repositories/store/StoreCategoryRepository.php

@@ -92,10 +92,10 @@ class StoreCategoryRepository extends BaseRepository
92 92
      * @Date: 2020/5/16
93 93
      * @return mixed
94 94
      */
95
-    public function getList()
95
+    public function getList($merId)
96 96
     {
97 97
         //$menus = $this->dao->getAllOptions(0);取消硬编码
98
-        $menus = $this->dao->getAllOptions( $this->request->merId());
98
+        $menus = $this->dao->getAllOptions($merId);
99 99
         $menus = formatCascaderData($menus, 'cate_name', 3);
100 100
         return $menus;
101 101
     }

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

@@ -166,4 +166,9 @@ class StoreCartRepository extends BaseRepository
166 166
     {
167 167
         return $this->dao->getCartEntityListByUidAndProductIdListAndIsPay($uid, $productIdList);
168 168
     }
169
+
170
+    public function getCartEntityListByUidAndProductIdList(int $uid, array $productIdList): array
171
+    {
172
+        return $this->dao->getCartEntityListByUidAndProductIdList($uid, $productIdList);
173
+    }
169 174
 }

+ 30 - 0
app/common/repositories/store/order/StoreOrderRepository.php

@@ -86,6 +86,7 @@ use app\common\repositories\user\UserSignHongbaoRepository;
86 86
 use app\common\repositories\user\UserSignJingdouRepository;
87 87
 use app\common\repositories\user\UserSignScoreRepository;
88 88
 use app\common\repositories\user\UserSignVrRepository;
89
+use app\common\repositories\user\UserSignXfbRepository;
89 90
 use app\common\repositories\user\UserThirdRepository;
90 91
 use app\common\repositories\user\UserWithdrawalLimitRecordRepository;
91 92
 use app\common\repositories\wechat\RoutineQrcodeRepository;
@@ -11735,6 +11736,29 @@ class StoreOrderRepository extends BaseRepository
11735 11736
                 '购买共富区商品获得PV'
11736 11737
             );
11737 11738
 
11739
+            // 特定商品发放幸福币
11740
+            /** @var StoreCartRepository $storeCartRepository */
11741
+            $storeCartRepository = app()->make(StoreCartRepository::class);
11742
+            $storeCartEntity = $storeCartRepository->getCartEntityListByUidAndProductIdList($storeOrderEntity->getUid(), [90619]);
11743
+            if (!empty($storeCartEntity)) {
11744
+                $xfbData = [
11745
+                    'uid' => $sharedProsperityUserEntity->getUserId(),
11746
+                    'before' => 0,
11747
+                    'number' => $storeOrderEntity->getPayPrice(),
11748
+                    'after' => 0,
11749
+                    'mark' => '购买共富区商品获得幸福币:' . $storeOrderEntity->getPayPrice(),
11750
+                    'desc' => '购买共富区商品获得幸福币',
11751
+                    'order_sn' => $storeOrderEntity->getOrderSn(),
11752
+                    'order_type' => $storeOrderEntity->getOrderType(),
11753
+                    'type' => 1,
11754
+                    'addtime' => time()
11755
+                ];
11756
+            }
11757
+            /** @var UserSignXfbRepository $xfbRepository */
11758
+            $xfbRepository = app()->make(UserSignXfbRepository::class);
11759
+            $xfbRepository->create($xfbData);
11760
+
11761
+
11738 11762
             if (!empty($sharedProsperityUserEntity->getParentId())) {
11739 11763
                 // 如果 共富区推荐人 不是平台,则为 推荐人发放 推荐奖励
11740 11764
                 $sharedProsperityUserEntityByParent = $sharedProsperityUserRepository->getSharedProsperityUserEntityByUserId($sharedProsperityUserEntity->getParentId());
@@ -12210,6 +12234,12 @@ class StoreOrderRepository extends BaseRepository
12210 12234
                     }, $userWithdrawalLimitRecordEntityList);
12211 12235
                     $userWithdrawalLimitRecordRepository->executeByIdList($userWithdrawalLimitRecordIdList);
12212 12236
                 }
12237
+
12238
+                // 结算幸福币
12239
+                /** @var UserSignXfbRepository $xfbRepository */
12240
+                $xfbRepository = app()->make(UserSignXfbRepository::class);
12241
+                // 结算
12242
+                $xfbRepository->settlement($unsettledOrderSnList);
12213 12243
             } catch (DbException $e) {
12214 12244
                 throw new ValidateException('订单结算失败');
12215 12245
             }

+ 43 - 0
app/common/repositories/user/UserSignXfbRepository.php

@@ -0,0 +1,43 @@
1
+<?php
2
+
3
+namespace app\common\repositories\user;
4
+
5
+use app\common\dao\user\UserDao;
6
+use app\common\model\user\UserSignXfb;
7
+use app\common\repositories\BaseRepository;
8
+
9
+class UserSignXfbRepository extends BaseRepository
10
+{
11
+    public function __construct(UserSignXfb $dao)
12
+    {
13
+        $this->dao = $dao;
14
+    }
15
+
16
+    public function create($data)
17
+    {
18
+        return $this->dao->create($data);
19
+    }
20
+
21
+    // 结算
22
+    public function settlement($orderSn)
23
+    {
24
+        foreach ($orderSn as $item) {
25
+            // 日志模型
26
+            $logModel = $this->dao->where(['order_sn'=>$item])->find();
27
+            // 用户模型
28
+            $userDao = new UserDao();
29
+            $userModel = $userDao->getWhere(['uid'=>$logModel->uid]);
30
+
31
+            // 修改日志表字段
32
+            $logModel->before = $userModel->xfb;
33
+            $logModel->after = $userModel->xfb + $logModel->number;;
34
+            $logModel->settlement_time = date('Y-m-d H:i:s');
35
+            $logModel->save();
36
+
37
+            // 修改用户表字段
38
+            $userModel->xfb = $userModel->xfb + $logModel->number;
39
+            $userModel->save();
40
+        }
41
+    }
42
+
43
+}

+ 2 - 1
app/controller/admin/store/StoreCategory.php

@@ -187,7 +187,8 @@ class StoreCategory extends BaseController
187 187
      */
188 188
     public function getList()
189 189
     {
190
-        return app('json')->success($this->repository->getList());
190
+        $merId = $this->request->merId();
191
+        return app('json')->success($this->repository->getList($merId));
191 192
     }
192 193
 
193 194
     /**

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

@@ -616,6 +616,31 @@ class User extends BaseController
616 616
     }
617 617
 
618 618
 
619
+    /**
620
+     * @return mixed
621
+     * @throws \think\db\exception\DataNotFoundException
622
+     * @throws \think\db\exception\DbException
623
+     * @throws \think\db\exception\ModelNotFoundException
624
+     * @author 史晨
625
+     * @date 2026/4/9 14:16
626
+     * 幸福币列表
627
+     */
628
+    public function xfb_list()
629
+    {
630
+        $type = $this->request->param('type');
631
+        if (!$type) {
632
+            return app('json')->fail('参数错误');
633
+        }
634
+        [$page, $limit] = $this->getPage();
635
+        $uid = $this->request->uid();
636
+        $where['uid'] = $uid;
637
+        $list = DB::name('user_sign_xfb')->where($where)->where('type', $type)->page($page, $limit)->order("id desc")->select();
638
+        $obtain = Db::name('user_sign_xfb')->where($where)->where('type', 1)->sum('number');
639
+        $consume = Db::name('user_sign_xfb')->where($where)->where('type', 2)->sum('number');
640
+        return app("json")->success(['list' => $list, 'obtain' => $obtain, 'consume' => $consume]);
641
+    }
642
+
643
+
619 644
     public function spread_info_yhc()
620 645
     {
621 646
         log::info("============ddddddddd");

+ 1 - 0
route/api.php

@@ -356,6 +356,7 @@ Route::group('api/', function () {
356 356
             Route::get('vr_name','User/vr_name');//VR名称
357 357
             Route::post('un_bind', 'User/unBindVxOrAli');//解绑微信或支付宝
358 358
 
359
+            Route::get('xfb_list','User/xfb_list');//购物金记录
359 360
         })->prefix('api.user.');
360 361
 
361 362
         // 共富区