瀏覽代碼

Merge branch 'dev'

sunxiaobiao 1 年之前
父節點
當前提交
2926d73f05
共有 100 個文件被更改,包括 6700 次插入 和 129 次删除
  1. 14 0
      app/common/dao/gzc/GzcLogDao.php
  2. 45 0
      app/common/dao/product/ProductSeckillDao.php
  3. 42 0
      app/common/dao/product/ShareDao.php
  4. 29 1
      app/common/dao/store/StoreSeckillActiveDao.php
  5. 25 0
      app/common/dao/store/coupon/StoreCouponProductDao.php
  6. 33 0
      app/common/dao/store/coupon/StoreCouponUserDao.php
  7. 63 0
      app/common/dao/store/order/StoreCartDao.php
  8. 48 2
      app/common/dao/store/order/StoreGroupOrderDao.php
  9. 27 0
      app/common/dao/store/order/StoreOrderDao.php
  10. 27 0
      app/common/dao/store/product/ProductAttrValueDao.php
  11. 33 0
      app/common/dao/store/product/ProductDao.php
  12. 24 0
      app/common/dao/store/shipping/ShippingTemplateDao.php
  13. 26 0
      app/common/dao/store/shipping/ShippingTemplateFreeDao.php
  14. 25 0
      app/common/dao/store/shipping/ShippingTemplateRegionDao.php
  15. 25 0
      app/common/dao/store/shipping/ShippingTemplateUndeliveryDao.php
  16. 45 0
      app/common/dao/system/merchant/MerchantContributionDao.php
  17. 52 0
      app/common/dao/system/merchant/MerchantDao.php
  18. 27 0
      app/common/dao/user/UserAddressDao.php
  19. 68 0
      app/common/dao/user/UserBillDao.php
  20. 0 40
      app/common/dao/user/UserCertification.php
  21. 102 0
      app/common/dao/user/UserCertificationDao.php
  22. 50 0
      app/common/dao/user/UserDao.php
  23. 89 0
      app/common/dao/user/UserPvLogDao.php
  24. 14 0
      app/common/dao/user/UserSignFenrunDao.php
  25. 91 0
      app/common/dao/user/UserSignFugouDao.php
  26. 89 0
      app/common/dao/user/UserSignGongxianDao.php
  27. 89 0
      app/common/dao/user/UserSignHongbaoDao.php
  28. 41 0
      app/common/dao/user/UserSignJingdouDao.php
  29. 90 0
      app/common/dao/user/UserSignScoreDao.php
  30. 59 0
      app/common/dao/user/UserSignVrDao.php
  31. 30 0
      app/common/dao/user/ZeroUserLineDao.php
  32. 255 0
      app/common/enum/CommonEnum.php
  33. 27 0
      app/common/enum/gzc/GzcLogEnum.php
  34. 64 0
      app/common/enum/merchant/MerchantEnum.php
  35. 14 0
      app/common/enum/product/SeckillEnum.php
  36. 33 0
      app/common/enum/shipping/ShippingTemplateEnum.php
  37. 23 0
      app/common/enum/store/CartEnum.php
  38. 39 0
      app/common/enum/store/ProductEnum.php
  39. 13 0
      app/common/enum/store/SeckillActiveEnum.php
  40. 22 0
      app/common/enum/store/StoreCouponUserEnum.php
  41. 42 0
      app/common/enum/store/StoreGroupOrderEnum.php
  42. 116 0
      app/common/enum/store/StoreOrderEnum.php
  43. 68 0
      app/common/enum/user/UserBillEnum.php
  44. 15 0
      app/common/enum/user/UserCertificationEnum.php
  45. 15 0
      app/common/enum/user/UserEnum.php
  46. 17 0
      app/common/enum/user/UserPvLogEnum.php
  47. 18 0
      app/common/enum/user/UserSignFenrunEnum.php
  48. 26 0
      app/common/enum/user/UserSignFugouEnum.php
  49. 24 0
      app/common/enum/user/UserSignGongxianEnum.php
  50. 24 0
      app/common/enum/user/UserSignHongbaoEnum.php
  51. 23 0
      app/common/enum/user/UserSignJingdouEnum.php
  52. 32 0
      app/common/enum/user/UserSignScoreEnum.php
  53. 16 0
      app/common/enum/user/UserSignVrEnum.php
  54. 31 0
      app/common/enum/user/ZeroUserEnum.php
  55. 18 0
      app/common/model/Region.php
  56. 27 0
      app/common/model/gzc/GzcLog.php
  57. 19 0
      app/common/model/product/ProductSeckillModel.php
  58. 19 0
      app/common/model/product/ShareModel.php
  59. 3 1
      app/common/model/store/shipping/ShippingTemplateFree.php
  60. 3 1
      app/common/model/store/shipping/ShippingTemplateRegion.php
  61. 3 1
      app/common/model/store/shipping/ShippingTemplateUndelivery.php
  62. 128 0
      app/common/model/system/ApiRequestLog.php
  63. 20 0
      app/common/model/system/merchant/MerchantContribution.php
  64. 19 0
      app/common/model/user/UserPvLog.php
  65. 19 0
      app/common/model/user/UserSignFenrun.php
  66. 19 0
      app/common/model/user/UserSignFugou.php
  67. 19 0
      app/common/model/user/UserSignGongxian.php
  68. 19 0
      app/common/model/user/UserSignHongbao.php
  69. 19 0
      app/common/model/user/UserSignJingdou.php
  70. 19 0
      app/common/model/user/UserSignScore.php
  71. 19 0
      app/common/model/user/UserSignVr.php
  72. 28 0
      app/common/model/user/ZeroUserLine.php
  73. 20 24
      app/common/repositories/finance/FinanceRepository.php
  74. 88 0
      app/common/repositories/gzc/GzcLogRepository.php
  75. 26 0
      app/common/repositories/product/ProductSeckillRepository.php
  76. 26 0
      app/common/repositories/product/ShareRepository.php
  77. 13 2
      app/common/repositories/store/StoreSeckillActiveRepository.php
  78. 10 0
      app/common/repositories/store/coupon/StoreCouponProductRepository.php
  79. 10 0
      app/common/repositories/store/coupon/StoreCouponUserRepository.php
  80. 36 0
      app/common/repositories/store/order/StoreCartRepository.php
  81. 60 6
      app/common/repositories/store/order/StoreGroupOrderRepository.php
  82. 1788 26
      app/common/repositories/store/order/StoreOrderRepository.php
  83. 26 0
      app/common/repositories/store/product/ProductAttrValueRepository.php
  84. 26 0
      app/common/repositories/store/product/ProductRepository.php
  85. 10 0
      app/common/repositories/store/shipping/ShippingTemplateFreeRepository.php
  86. 9 0
      app/common/repositories/store/shipping/ShippingTemplateRegionRepository.php
  87. 11 0
      app/common/repositories/store/shipping/ShippingTemplateRepository.php
  88. 9 1
      app/common/repositories/store/shipping/ShippingTemplateUndeliveRepository.php
  89. 35 0
      app/common/repositories/system/merchant/MerchantContributionRepository.php
  90. 25 0
      app/common/repositories/system/merchant/MerchantRepository.php
  91. 14 0
      app/common/repositories/user/UserAddressRepository.php
  92. 275 5
      app/common/repositories/user/UserBillRepository.php
  93. 86 0
      app/common/repositories/user/UserCertificationRepository.php
  94. 208 0
      app/common/repositories/user/UserPvLogRepository.php
  95. 327 19
      app/common/repositories/user/UserRepository.php
  96. 73 0
      app/common/repositories/user/UserSignFenrunRepository.php
  97. 236 0
      app/common/repositories/user/UserSignFugouRepository.php
  98. 236 0
      app/common/repositories/user/UserSignGongxianRepository.php
  99. 218 0
      app/common/repositories/user/UserSignHongbaoRepository.php
  100. 0 0
      app/common/repositories/user/UserSignJingdouRepository.php

+ 14 - 0
app/common/dao/gzc/GzcLogDao.php

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

+ 45 - 0
app/common/dao/product/ProductSeckillDao.php

@@ -0,0 +1,45 @@
1
+<?php
2
+
3
+namespace app\common\dao\product;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\enum\product\SeckillEnum;
7
+use app\common\model\product\ProductSeckillModel;
8
+use app\entity\CommonEntity;
9
+use app\entity\data\product\ProductSeckillEntity;
10
+
11
+class ProductSeckillDao extends BaseDao
12
+{
13
+    /**
14
+     * @return string
15
+     */
16
+    protected function getModel(): string
17
+    {
18
+        return ProductSeckillModel::class;
19
+    }
20
+
21
+    /**
22
+     * 根据 shareId 获取分享实体
23
+     * @param int $productId
24
+     * @return CommonEntity
25
+     */
26
+    public function getProductSeckillEntityByProductId(int $productId): CommonEntity
27
+    {
28
+        $data = [];
29
+        try {
30
+            /** @var ProductSeckillModel $model */
31
+            $model = $this->getModel();
32
+            $dataRes = $model::getDB()
33
+                ->where('product_id', '=', $productId)
34
+                ->where("`seckill_date` <= '" . date('Y-m-d H:i:s') . "'")
35
+                ->where("status", '=', SeckillEnum::STATUS['Open']['code'])
36
+                ->find();
37
+            if (!empty($dataRes)) {
38
+                $data = $dataRes->toArray();
39
+            }
40
+        } catch (\Exception $e) {
41
+
42
+        }
43
+        return ProductSeckillEntity::newInstance($data);
44
+    }
45
+}

+ 42 - 0
app/common/dao/product/ShareDao.php

@@ -0,0 +1,42 @@
1
+<?php
2
+
3
+namespace app\common\dao\product;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\product\ShareModel;
7
+use app\entity\CommonEntity;
8
+use app\entity\data\product\ShareEntity;
9
+
10
+class ShareDao extends BaseDao
11
+{
12
+    /**
13
+     * @return string
14
+     */
15
+    protected function getModel(): string
16
+    {
17
+        return ShareModel::class;
18
+    }
19
+
20
+    /**
21
+     * 根据 shareId 获取分享实体
22
+     * @param int $shareId
23
+     * @return CommonEntity
24
+     */
25
+    public function getShareEntityByShareId(int $shareId): CommonEntity
26
+    {
27
+        $shareData = [];
28
+        try {
29
+            /** @var ShareModel $model */
30
+            $model = $this->getModel();
31
+            $shareDataRes = $model::getDB()
32
+                ->where('id', '=', $shareId)
33
+                ->find();
34
+            if (!empty($shareDataRes)) {
35
+                $shareData = $shareDataRes->toArray();
36
+            }
37
+        } catch (\Exception $e) {
38
+
39
+        }
40
+        return ShareEntity::newInstance($shareData);
41
+    }
42
+}

+ 29 - 1
app/common/dao/store/StoreSeckillActiveDao.php

@@ -5,12 +5,14 @@
5
  * @author Qinii
5
  * @author Qinii
6
  * @day 2020-07-30
6
  * @day 2020-07-30
7
  *
7
  *
8
- * 
8
+ *
9
  */
9
  */
10
 namespace app\common\dao\store;
10
 namespace app\common\dao\store;
11
 
11
 
12
+use app\common\enum\store\SeckillActiveEnum;
12
 use app\common\model\store\StoreSeckillActive;
13
 use app\common\model\store\StoreSeckillActive;
13
 use app\common\dao\BaseDao;
14
 use app\common\dao\BaseDao;
15
+use app\entity\data\store\SeckillActiveEntity;
14
 
16
 
15
 class StoreSeckillActiveDao extends BaseDao
17
 class StoreSeckillActiveDao extends BaseDao
16
 {
18
 {
@@ -129,4 +131,30 @@ class StoreSeckillActiveDao extends BaseDao
129
             });
131
             });
130
         return $query;
132
         return $query;
131
     }
133
     }
134
+
135
+    /**
136
+     * 根据 商品ID 获取当前生效的 活动记录
137
+     * @param int $productId
138
+     * @return \app\entity\CommonEntity
139
+     */
140
+    public function getSeckillActiveEntityByProductIdInActive(int $productId): \app\entity\CommonEntity
141
+    {
142
+        $data = [];
143
+        try {
144
+            /** @var StoreSeckillActive $model */
145
+            $model = $this->getModel();
146
+            $dataRes = $model::getDB()
147
+                ->where('product_id', '=', $productId)
148
+                ->where("`start_time` <= '" . time() . "'")
149
+                ->where("`end_time` >= '" . time() . "'")
150
+                ->where("status", '=', SeckillActiveEnum::STATUS['Active']['code'])
151
+                ->find();
152
+            if (!empty($dataRes)) {
153
+                $data = $dataRes->toArray();
154
+            }
155
+        } catch (\Exception $e) {
156
+
157
+        }
158
+        return SeckillActiveEntity::newInstance($data);
159
+    }
132
 }
160
 }

+ 25 - 0
app/common/dao/store/coupon/StoreCouponProductDao.php

@@ -14,6 +14,7 @@ namespace app\common\dao\store\coupon;
14
 use app\common\dao\BaseDao;
14
 use app\common\dao\BaseDao;
15
 use app\common\model\BaseModel;
15
 use app\common\model\BaseModel;
16
 use app\common\model\store\coupon\StoreCouponProduct;
16
 use app\common\model\store\coupon\StoreCouponProduct;
17
+use app\entity\data\store\StoreCouponProductEntity;
17
 use think\Collection;
18
 use think\Collection;
18
 use think\db\exception\DataNotFoundException;
19
 use think\db\exception\DataNotFoundException;
19
 use think\db\exception\DbException;
20
 use think\db\exception\DbException;
@@ -71,4 +72,28 @@ class StoreCouponProductDao extends BaseDao
71
     {
72
     {
72
         return StoreCouponProduct::getDB()->whereIn('product_id', $productId)->column('coupon_id');
73
         return StoreCouponProduct::getDB()->whereIn('product_id', $productId)->column('coupon_id');
73
     }
74
     }
75
+
76
+    /**
77
+     * @param int $couponId
78
+     * @return StoreCouponProductEntity[]
79
+     */
80
+    public function getStoreCouponProductEntityListByCouponId(int $couponId): array
81
+    {
82
+        $entityList = [];
83
+        try {
84
+            /** @var StoreCouponProduct $model */
85
+            $model = $this->getModel();
86
+            $dataListRes = $model::getDB()
87
+                ->where('coupon_id', '=', $couponId)
88
+                ->select()
89
+                ->toArray();
90
+            if (!empty($dataListRes)) {
91
+                foreach ($dataListRes as $data) {
92
+                    $entityList[] = StoreCouponProductEntity::newInstance($data);
93
+                }
94
+            }
95
+        } catch (\Exception $e) {
96
+        }
97
+        return $entityList;
98
+    }
74
 }
99
 }

+ 33 - 0
app/common/dao/store/coupon/StoreCouponUserDao.php

@@ -12,8 +12,10 @@ namespace app\common\dao\store\coupon;
12
 
12
 
13
 
13
 
14
 use app\common\dao\BaseDao;
14
 use app\common\dao\BaseDao;
15
+use app\common\enum\store\StoreCouponUserEnum;
15
 use app\common\model\BaseModel;
16
 use app\common\model\BaseModel;
16
 use app\common\model\store\coupon\StoreCouponUser;
17
 use app\common\model\store\coupon\StoreCouponUser;
18
+use app\entity\data\store\StoreCouponUserEntity;
17
 
19
 
18
 /**
20
 /**
19
  * Class StoreCouponUserDao
21
  * Class StoreCouponUserDao
@@ -86,4 +88,35 @@ class StoreCouponUserDao extends BaseDao
86
     {
88
     {
87
         return StoreCouponUser::getDB()->where('coupon_id', $couponId)->count();
89
         return StoreCouponUser::getDB()->where('coupon_id', $couponId)->count();
88
     }
90
     }
91
+
92
+    /**
93
+     * @param int $merId
94
+     * @param int $uid
95
+     * @return StoreCouponUserEntity[]
96
+     */
97
+    public function getValidStoreCouponUserEntityListByMerIdAndUid(int $merId, int $uid): array
98
+    {
99
+        $entityList = [];
100
+        try {
101
+            $dateTime = date('Y-m-d H:i:s');
102
+            /** @var StoreCouponUser $model */
103
+            $model = $this->getModel();
104
+            $dataListRes = $model::getDB()
105
+                ->where('mer_id', '=', $merId)
106
+                ->where('uid', '=', $uid)
107
+                ->where('status', '=', StoreCouponUserEnum::STATUS['Unused']['code'])
108
+                ->where('is_fail', '=', StoreCouponUserEnum::IS_FAIL['No']['code'])
109
+                ->where('start_time', '<=', $dateTime)
110
+                ->where('end_time', '>=', $dateTime)
111
+                ->select()
112
+                ->toArray();
113
+            if (!empty($dataListRes)) {
114
+                foreach ($dataListRes as $data) {
115
+                    $entityList[] = StoreCouponUserEntity::newInstance($data);
116
+                }
117
+            }
118
+        } catch (\Exception $e) {
119
+        }
120
+        return $entityList;
121
+    }
89
 }
122
 }

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

@@ -12,8 +12,11 @@ namespace app\common\dao\store\order;
12
 
12
 
13
 
13
 
14
 use app\common\dao\BaseDao;
14
 use app\common\dao\BaseDao;
15
+use app\common\enum\store\CartEnum;
15
 use app\common\model\BaseModel;
16
 use app\common\model\BaseModel;
16
 use app\common\model\store\order\StoreCart;
17
 use app\common\model\store\order\StoreCart;
18
+use app\entity\CommonEntity;
19
+use app\entity\data\store\CartEntity;
17
 use think\Collection;
20
 use think\Collection;
18
 use think\db\exception\DataNotFoundException;
21
 use think\db\exception\DataNotFoundException;
19
 use think\db\exception\DbException;
22
 use think\db\exception\DbException;
@@ -155,4 +158,64 @@ class StoreCartDao extends BaseDao
155
         })->leftJoin('StoreOrderProduct B', 'A.cart_id = B.cart_id')
158
         })->leftJoin('StoreOrderProduct B', 'A.cart_id = B.cart_id')
156
             ->field('sum(B.product_num) as pay_num,sum(B.product_price) as pay_price,A.source_id')->group('A.source_id')->select();
159
             ->field('sum(B.product_num) as pay_num,sum(B.product_price) as pay_price,A.source_id')->group('A.source_id')->select();
157
     }
160
     }
161
+
162
+    /**
163
+     * @param int $cartId
164
+     * @return CommonEntity
165
+     */
166
+    public function getCartEntityByCartId(int $cartId): CommonEntity
167
+    {
168
+        $storeCartData = [];
169
+        try {
170
+            /** @var StoreCart  $model */
171
+            $model = $this->getModel();
172
+            $storeCartDataRes = $model::getDB()
173
+                ->where('cart_id', $cartId)
174
+                ->find();
175
+            if (!empty($storeCartDataRes)) {
176
+                $storeCartData = $storeCartDataRes->toArray();
177
+            }
178
+        } catch (\Exception $e) {
179
+        }
180
+        return CartEntity::newInstance($storeCartData);
181
+    }
182
+
183
+    /**
184
+     * @param array $cartIdList
185
+     * @return CartEntity[]
186
+     */
187
+    public function getCartEntityListByCartIdList(array $cartIdList): array
188
+    {
189
+        $entityList = [];
190
+        try {
191
+            /** @var StoreCart  $model */
192
+            $model = $this->getModel();
193
+            $dataListRes = $model::getDB()
194
+                ->whereIn('cart_id', $cartIdList)
195
+                ->select()
196
+                ->toArray();
197
+            if (!empty($dataListRes)) {
198
+                foreach ($dataListRes as $data) {
199
+                    $entityList[] = CartEntity::newInstance($data);
200
+                }
201
+            }
202
+        } catch (\Exception $e) {
203
+        }
204
+        return $entityList;
205
+    }
206
+
207
+    /**
208
+     * @param array $cartIdList
209
+     * @param int $isPay
210
+     * @return int
211
+     * @throws DbException
212
+     */
213
+    public function updateIsPayByCartIdList(array $cartIdList, int $isPay = CartEnum::IS_PAY['Yes']['code']): int
214
+    {
215
+        /** @var StoreCart $model */
216
+        $model = $this->getModel();
217
+        return $model::getDB()
218
+            ->whereIn('cart_id', $cartIdList)
219
+            ->update(['is_pay' => $isPay]);
220
+    }
158
 }
221
 }

+ 48 - 2
app/common/dao/store/order/StoreGroupOrderDao.php

@@ -5,14 +5,18 @@
5
  * @author xaboy
5
  * @author xaboy
6
  * @day 2020/6/8
6
  * @day 2020/6/8
7
  *
7
  *
8
- * 
8
+ *
9
  */
9
  */
10
 
10
 
11
 namespace app\common\dao\store\order;
11
 namespace app\common\dao\store\order;
12
 
12
 
13
 
13
 
14
 use app\common\dao\BaseDao;
14
 use app\common\dao\BaseDao;
15
+use app\common\enum\store\StoreGroupOrderEnum;
15
 use app\common\model\store\order\StoreGroupOrder;
16
 use app\common\model\store\order\StoreGroupOrder;
17
+use app\entity\CommonEntity;
18
+use app\entity\data\store\StoreGroupOrderEntity;
19
+use think\db\exception\DbException;
16
 
20
 
17
 /**
21
 /**
18
  * Class StoreGroupOrderDao
22
  * Class StoreGroupOrderDao
@@ -43,7 +47,7 @@ class StoreGroupOrderDao extends BaseDao
43
     {
47
     {
44
         return StoreGroupOrder::when($uid, function ($query, $uid) {
48
         return StoreGroupOrder::when($uid, function ($query, $uid) {
45
             $query->where('uid', $uid);
49
             $query->where('uid', $uid);
46
-        })->where('is_del', 0)->where('test_order',0)->where('paid', 0)->count();
50
+        })->where('is_del', 0)->where('test_order', 0)->where('paid', 0)->count();
47
     }
51
     }
48
 
52
 
49
     /**
53
     /**
@@ -89,4 +93,46 @@ class StoreGroupOrderDao extends BaseDao
89
     {
93
     {
90
         return StoreGroupOrder::getDB()->where('pay_type', 0)->where('uid', $uid)->sum('pay_price') ?: 0;
94
         return StoreGroupOrder::getDB()->where('pay_type', 0)->where('uid', $uid)->sum('pay_price') ?: 0;
91
     }
95
     }
96
+
97
+    /**
98
+     * @param array $groupOrderIdList
99
+     * @return CommonEntity[]
100
+     */
101
+    public function getStoreGroupOrderEntityListByGroupOrderIdList(array $groupOrderIdList): array
102
+    {
103
+        $entityList = [];
104
+        try {
105
+            /** @var StoreGroupOrder $model */
106
+            $model = $this->getModel();
107
+            $dataRes = $model::getDB()
108
+                ->whereIn('group_order_id', $groupOrderIdList)
109
+                ->select()
110
+                ->toArray();
111
+            if (!empty($dataRes)) {
112
+                $entityList = array_map(function ($data) {
113
+                    return StoreGroupOrderEntity::newInstance($data);
114
+                }, $dataRes);
115
+            }
116
+        } catch (\Exception $e) {
117
+
118
+        }
119
+        return $entityList;
120
+    }
121
+
122
+    /**
123
+     * @param $groupOrderId
124
+     * @return int
125
+     * @throws DbException
126
+     */
127
+    public function paySuccess($groupOrderId): int
128
+    {
129
+        /** @var StoreGroupOrder $model */
130
+        $model = $this->getModel();
131
+        return $model::getDB()
132
+            ->where('group_order_id', '=', $groupOrderId)
133
+            ->update([
134
+                'paid' => StoreGroupOrderEnum::PAID['YES']['code'],
135
+                'pay_time' => date('Y-m-d H:i:s')
136
+            ]);
137
+    }
92
 }
138
 }

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

@@ -16,6 +16,8 @@ use app\common\model\BaseModel;
16
 use app\common\model\store\order\StoreOrder;
16
 use app\common\model\store\order\StoreOrder;
17
 use app\common\model\user\User;
17
 use app\common\model\user\User;
18
 use app\common\repositories\user\UserRepository;
18
 use app\common\repositories\user\UserRepository;
19
+use app\entity\CommonEntity;
20
+use app\entity\data\store\StoreOrderEntity;
19
 use think\facade\Db;
21
 use think\facade\Db;
20
 
22
 
21
 /**
23
 /**
@@ -603,4 +605,29 @@ class StoreOrderDao extends BaseDao
603
         $userData = Db::query($sql);
605
         $userData = Db::query($sql);
604
         return array_column($userData, 'amount', 'uid');
606
         return array_column($userData, 'amount', 'uid');
605
     }
607
     }
608
+
609
+    /**
610
+     * @param array $orderIdList
611
+     * @return CommonEntity[]
612
+     */
613
+    public function getStoreOrderEntityListByOrderIdList(array $orderIdList): array
614
+    {
615
+        $entityList = [];
616
+        try {
617
+            /** @var StoreOrder $model */
618
+            $model = $this->getModel();
619
+            $dataRes = $model::getDB()
620
+                ->whereIn('order_id', $orderIdList)
621
+                ->select()
622
+                ->toArray();
623
+            if (!empty($dataRes)) {
624
+                $entityList = array_map(function ($data) {
625
+                    return StoreOrderEntity::newInstance($data);
626
+                }, $dataRes);
627
+            }
628
+        } catch (\Exception $e) {
629
+
630
+        }
631
+        return $entityList;
632
+    }
606
 }
633
 }

+ 27 - 0
app/common/dao/store/product/ProductAttrValueDao.php

@@ -9,6 +9,8 @@ namespace app\common\dao\store\product;
9
 
9
 
10
 use app\common\dao\BaseDao;
10
 use app\common\dao\BaseDao;
11
 use app\common\model\store\product\ProductAttrValue as model;
11
 use app\common\model\store\product\ProductAttrValue as model;
12
+use app\entity\CommonEntity;
13
+use app\entity\data\store\StoreProductAttrValueEntity;
12
 use think\facade\Db;
14
 use think\facade\Db;
13
 
15
 
14
 /**
16
 /**
@@ -256,4 +258,29 @@ class ProductAttrValueDao extends BaseDao
256
             });
258
             });
257
         return $query;
259
         return $query;
258
     }
260
     }
261
+
262
+    /**
263
+     * @param array $uniqueList
264
+     * @return CommonEntity[]
265
+     */
266
+    public function getStoreProductAttrValueEntityListByUniqueList(array $uniqueList): array
267
+    {
268
+        $entityList = [];
269
+        try {
270
+            /** @var model $model */
271
+            $model = $this->getModel();
272
+            $dataRes = $model::getDB()
273
+                ->whereIn('unique', $uniqueList)
274
+                ->select()
275
+                ->toArray();
276
+            if (!empty($dataRes)) {
277
+                $entityList = array_map(function ($data) {
278
+                    return StoreProductAttrValueEntity::newInstance($data);
279
+                }, $dataRes);
280
+            }
281
+        } catch (\Exception $e) {
282
+
283
+        }
284
+        return $entityList;
285
+    }
259
 }
286
 }

+ 33 - 0
app/common/dao/store/product/ProductDao.php

@@ -8,8 +8,11 @@
8
 namespace app\common\dao\store\product;
8
 namespace app\common\dao\store\product;
9
 
9
 
10
 use app\common\dao\BaseDao;
10
 use app\common\dao\BaseDao;
11
+use app\common\enum\store\ProductEnum;
11
 use app\common\model\store\product\Product as model;
12
 use app\common\model\store\product\Product as model;
12
 use app\common\repositories\store\StoreCategoryRepository;
13
 use app\common\repositories\store\StoreCategoryRepository;
14
+use app\entity\CommonEntity;
15
+use app\entity\data\store\StoreProductEntity;
13
 use think\Exception;
16
 use think\Exception;
14
 use think\facade\Db;
17
 use think\facade\Db;
15
 
18
 
@@ -415,4 +418,34 @@ class ProductDao extends BaseDao
415
             'is_gift_bag'   => 0,
418
             'is_gift_bag'   => 0,
416
         ];
419
         ];
417
     }
420
     }
421
+
422
+    /**
423
+     * @param array $idList
424
+     * @return CommonEntity[]
425
+     */
426
+    public function getUserSignGongxianEntityListByIdList(array $idList): array
427
+    {
428
+        $entityList = [];
429
+        try {
430
+            /** @var model $model */
431
+            $model = $this->getModel();
432
+            $dataRes = $model::getDB()
433
+                ->whereIn('product_id', $idList)
434
+                ->where('is_del', '=', ProductEnum::IS_DEL['No']['code'])
435
+                ->where('status', '=', ProductEnum::STATUS['Approved']['code'])
436
+                ->where('is_used', '=', ProductEnum::IS_USED['Yes']['code'])
437
+                ->where('is_show', '=', ProductEnum::IS_SHOW['Yes']['code'])
438
+                ->where('mer_status', '=', ProductEnum::MER_STATUS['Yes']['code'])
439
+                ->select()
440
+                ->toArray();
441
+            if (!empty($dataRes)) {
442
+                $entityList = array_map(function ($data) {
443
+                    return StoreProductEntity::newInstance($data);
444
+                }, $dataRes);
445
+            }
446
+        } catch (\Exception $e) {
447
+
448
+        }
449
+        return $entityList;
450
+    }
418
 }
451
 }

+ 24 - 0
app/common/dao/store/shipping/ShippingTemplateDao.php

@@ -7,6 +7,8 @@
7
  */
7
  */
8
 namespace app\common\dao\store\shipping;
8
 namespace app\common\dao\store\shipping;
9
 
9
 
10
+use app\common\model\store\shipping\ShippingTemplate;
11
+use app\entity\data\shipping\ShippingTemplateEntity;
10
 use think\facade\Db;
12
 use think\facade\Db;
11
 use app\common\dao\BaseDao;
13
 use app\common\dao\BaseDao;
12
 use app\common\model\store\shipping\ShippingTemplate as model;
14
 use app\common\model\store\shipping\ShippingTemplate as model;
@@ -86,4 +88,26 @@ class ShippingTemplateDao  extends BaseDao
86
     {
88
     {
87
         return ($this->getModel())::getDB()->where('mer_id',$merId)->field('shipping_template_id,name')->select();
89
         return ($this->getModel())::getDB()->where('mer_id',$merId)->field('shipping_template_id,name')->select();
88
     }
90
     }
91
+
92
+    /**
93
+     * @param int $shippingTemplateId
94
+     * @return \app\entity\CommonEntity
95
+     */
96
+    public function getShippingTemplateEntityByShippingTemplateId(int $shippingTemplateId): \app\entity\CommonEntity
97
+    {
98
+        $data = [];
99
+        try {
100
+            /** @var ShippingTemplate $model */
101
+            $model = $this->getModel();
102
+            $dataRes = $model::getDB()
103
+                ->where('shipping_template_id', '=', $shippingTemplateId)
104
+                ->find();
105
+            if (!empty($dataRes)) {
106
+                $data = $dataRes->toArray();
107
+            }
108
+        } catch (\Exception $e) {
109
+
110
+        }
111
+        return ShippingTemplateEntity::newInstance($data);
112
+    }
89
 }
113
 }

+ 26 - 0
app/common/dao/store/shipping/ShippingTemplateFreeDao.php

@@ -7,6 +7,7 @@
7
  */
7
  */
8
 namespace app\common\dao\store\shipping;
8
 namespace app\common\dao\store\shipping;
9
 
9
 
10
+use app\entity\data\shipping\ShippingTemplateFreeEntity;
10
 use think\facade\Db;
11
 use think\facade\Db;
11
 use app\common\dao\BaseDao;
12
 use app\common\dao\BaseDao;
12
 use app\common\model\store\shipping\ShippingTemplateFree as model;
13
 use app\common\model\store\shipping\ShippingTemplateFree as model;
@@ -64,4 +65,29 @@ class ShippingTemplateFreeDao  extends BaseDao
64
     {
65
     {
65
         return ($this->getModel()::getDB())->insertAll($data);
66
         return ($this->getModel()::getDB())->insertAll($data);
66
     }
67
     }
68
+
69
+    /**
70
+     * @param int $tempId
71
+     * @return ShippingTemplateFreeEntity[]
72
+     */
73
+    public function getShippingTemplateFreeEntityListByTempId(int $tempId): array
74
+    {
75
+        $entityList = [];
76
+        try {
77
+            /** @var model $model */
78
+            $model = $this->getModel();
79
+            $dataListRes = $model::getDB()
80
+                ->where('temp_id', '=', $tempId)
81
+                ->order('shipping_template_free_id DESC')
82
+                ->select()
83
+                ->toArray();
84
+            if (!empty($dataListRes)) {
85
+                foreach ($dataListRes as $data) {
86
+                    $entityList[] = ShippingTemplateFreeEntity::newInstance($data);
87
+                }
88
+            }
89
+        } catch (\Exception $e) {
90
+        }
91
+        return $entityList;
92
+    }
67
 }
93
 }

+ 25 - 0
app/common/dao/store/shipping/ShippingTemplateRegionDao.php

@@ -7,6 +7,7 @@
7
  */
7
  */
8
 namespace app\common\dao\store\shipping;
8
 namespace app\common\dao\store\shipping;
9
 
9
 
10
+use app\entity\data\shipping\ShippingTemplateRegionEntity;
10
 use think\facade\Db;
11
 use think\facade\Db;
11
 use app\common\dao\BaseDao;
12
 use app\common\dao\BaseDao;
12
 use app\common\model\store\shipping\ShippingTemplateRegion as model;
13
 use app\common\model\store\shipping\ShippingTemplateRegion as model;
@@ -64,4 +65,28 @@ class ShippingTemplateRegionDao  extends BaseDao
64
         return ($this->getModel()::getDB())->insertAll($data);
65
         return ($this->getModel()::getDB())->insertAll($data);
65
     }
66
     }
66
 
67
 
68
+    /**
69
+     * @param int $tempId
70
+     * @return ShippingTemplateRegionEntity[]
71
+     */
72
+    public function getShippingTemplateRegionEntityListByTempId(int $tempId): array
73
+    {
74
+        $entityList = [];
75
+        try {
76
+            /** @var model $model */
77
+            $model = $this->getModel();
78
+            $dataListRes = $model::getDB()
79
+                ->where('temp_id', '=', $tempId)
80
+                ->order('shipping_template_region_id DESC')
81
+                ->select()
82
+                ->toArray();
83
+            if (!empty($dataListRes)) {
84
+                foreach ($dataListRes as $data) {
85
+                    $entityList[] = ShippingTemplateRegionEntity::newInstance($data);
86
+                }
87
+            }
88
+        } catch (\Exception $e) {
89
+        }
90
+        return $entityList;
91
+    }
67
 }
92
 }

+ 25 - 0
app/common/dao/store/shipping/ShippingTemplateUndeliveryDao.php

@@ -8,6 +8,7 @@ namespace app\common\dao\store\shipping;
8
 
8
 
9
 use app\common\dao\BaseDao;
9
 use app\common\dao\BaseDao;
10
 use app\common\model\store\shipping\ShippingTemplateUndelivery as model;
10
 use app\common\model\store\shipping\ShippingTemplateUndelivery as model;
11
+use app\entity\data\shipping\ShippingTemplateUndeliveryEntity;
11
 
12
 
12
 class ShippingTemplateUndeliveryDao  extends BaseDao
13
 class ShippingTemplateUndeliveryDao  extends BaseDao
13
 {
14
 {
@@ -51,4 +52,28 @@ class ShippingTemplateUndeliveryDao  extends BaseDao
51
         if($temp_id)
52
         if($temp_id)
52
             ($this->getModel())::getDB()->where('temp_id','in',$temp_id)->delete();
53
             ($this->getModel())::getDB()->where('temp_id','in',$temp_id)->delete();
53
     }
54
     }
55
+
56
+    /**
57
+     * @param int $tempId
58
+     * @return ShippingTemplateUndeliveryEntity[]
59
+     */
60
+    public function getShippingTemplateUndeliveryEntityListByTempId(int $tempId): array
61
+    {
62
+        $entityList = [];
63
+        try {
64
+            /** @var model $model */
65
+            $model = $this->getModel();
66
+            $dataListRes = $model::getDB()
67
+                ->where('temp_id', '=', $tempId)
68
+                ->select()
69
+                ->toArray();
70
+            if (!empty($dataListRes)) {
71
+                foreach ($dataListRes as $data) {
72
+                    $entityList[] = ShippingTemplateUndeliveryEntity::newInstance($data);
73
+                }
74
+            }
75
+        } catch (\Exception $e) {
76
+        }
77
+        return $entityList;
78
+    }
54
 }
79
 }

+ 45 - 0
app/common/dao/system/merchant/MerchantContributionDao.php

@@ -0,0 +1,45 @@
1
+<?php
2
+
3
+namespace app\common\dao\system\merchant;
4
+
5
+
6
+use app\common\dao\BaseDao;
7
+use app\common\model\system\merchant\MerchantContribution;
8
+use app\entity\CommonEntity;
9
+use app\entity\data\merchant\MerchantContributionEntity;
10
+
11
+
12
+class MerchantContributionDao extends BaseDao
13
+{
14
+
15
+    protected function getModel(): string
16
+    {
17
+        return MerchantContribution::class;
18
+    }
19
+
20
+    /**
21
+     * 根据商家的让利比例 获取对应的 配置信息
22
+     * @param float $profitSharing
23
+     * @return CommonEntity
24
+     */
25
+    public function getMerchantContributionEntityByProfitSharing(float $profitSharing): CommonEntity
26
+    {
27
+        $data = [];
28
+        try {
29
+            /** @var MerchantContribution $model */
30
+            $model = $this->getModel();
31
+            $dataRes = $model::getDB()->select()->toArray();
32
+            if (!empty($dataRes)) {
33
+                foreach ($dataRes as $item) {
34
+                    if ($item['start'] <= $profitSharing && $item['end'] >= $profitSharing) {
35
+                        $data = $item;
36
+                        break;
37
+                    }
38
+                }
39
+            }
40
+        } catch (\Exception $e) {
41
+
42
+        }
43
+        return MerchantContributionEntity::newInstance($data);
44
+    }
45
+}

+ 52 - 0
app/common/dao/system/merchant/MerchantDao.php

@@ -12,8 +12,11 @@ namespace app\common\dao\system\merchant;
12
 
12
 
13
 
13
 
14
 use app\common\dao\BaseDao;
14
 use app\common\dao\BaseDao;
15
+use app\common\enum\merchant\MerchantEnum;
15
 use app\common\model\system\merchant\Merchant;
16
 use app\common\model\system\merchant\Merchant;
16
 use app\common\model\user\User;
17
 use app\common\model\user\User;
18
+use app\entity\CommonEntity;
19
+use app\entity\data\merchant\MerchantEntity;
17
 use think\db\BaseQuery;
20
 use think\db\BaseQuery;
18
 use think\db\exception\DataNotFoundException;
21
 use think\db\exception\DataNotFoundException;
19
 use think\db\exception\DbException;
22
 use think\db\exception\DbException;
@@ -226,4 +229,53 @@ class MerchantDao extends BaseDao
226
     }
229
     }
227
 
230
 
228
 
231
 
232
+    /**
233
+     * 根据 商户ID 获取 未删除的 商户信息
234
+     * @param int $merId
235
+     * @return \app\entity\CommonEntity
236
+     */
237
+    public function getMerchantEntityByMerchantId(int $merId): \app\entity\CommonEntity
238
+    {
239
+        $data = [];
240
+        try {
241
+            /** @var Merchant $model */
242
+            $model = $this->getModel();
243
+            $dataRes = $model::getDB()
244
+                ->where('mer_id', '=', $merId)
245
+                ->where('is_del', '=', MerchantEnum::IS_DEL['No']['code'])
246
+                ->find();
247
+            if (!empty($dataRes)) {
248
+                $data = $dataRes->toArray();
249
+            }
250
+        } catch (\Exception $e) {
251
+
252
+        }
253
+        return MerchantEntity::newInstance($data);
254
+    }
255
+
256
+    /**
257
+     * @param array $idList
258
+     * @return CommonEntity[]
259
+     */
260
+    public function getMerchantEntityListByMerchantIdList(array $idList): array
261
+    {
262
+        $entityList = [];
263
+        try {
264
+            /** @var Merchant $model */
265
+            $model = $this->getModel();
266
+            $dataRes = $model::getDB()
267
+                ->whereIn('mer_id', $idList)
268
+                ->where('is_del', '=', MerchantEnum::IS_DEL['No']['code'])
269
+                ->select()
270
+                ->toArray();
271
+            if (!empty($dataRes)) {
272
+                $entityList = array_map(function ($data) {
273
+                    return MerchantEntity::newInstance($data);
274
+                }, $dataRes);
275
+            }
276
+        } catch (\Exception $e) {
277
+
278
+        }
279
+        return $entityList;
280
+    }
229
 }
281
 }

+ 27 - 0
app/common/dao/user/UserAddressDao.php

@@ -12,7 +12,10 @@ namespace app\common\dao\user;
12
 
12
 
13
 
13
 
14
 use app\common\dao\BaseDao;
14
 use app\common\dao\BaseDao;
15
+use app\common\enum\CommonEnum;
15
 use app\common\model\user\UserAddress as model;
16
 use app\common\model\user\UserAddress as model;
17
+use app\entity\CommonEntity;
18
+use app\entity\data\user\UserAddressEntity;
16
 
19
 
17
 class UserAddressDao extends BaseDao
20
 class UserAddressDao extends BaseDao
18
 {
21
 {
@@ -42,4 +45,28 @@ class UserAddressDao extends BaseDao
42
     {
45
     {
43
         return (($this->getModel()::getDB())->where('uid',$uid));
46
         return (($this->getModel()::getDB())->where('uid',$uid));
44
     }
47
     }
48
+
49
+    /**
50
+     * 根据 地址ID 获取地址实体
51
+     * @param int $addressId
52
+     * @return CommonEntity
53
+     */
54
+    public function getAddressEntityByAddressId(int $addressId): CommonEntity
55
+    {
56
+        $addressData = [];
57
+        try {
58
+            /** @var model $model */
59
+            $model = $this->getModel();
60
+            $addressDataRes = $model::getDB()
61
+                ->where('address_id', '=', $addressId)
62
+                ->where('is_del', '=', CommonEnum::IS_DEL['No']['code'])
63
+                ->find();
64
+            if (!empty($addressDataRes)) {
65
+                $addressData = $addressDataRes->toArray();
66
+            }
67
+        } catch (\Exception $e) {
68
+
69
+        }
70
+        return UserAddressEntity::newInstance($addressData);
71
+    }
45
 }
72
 }

+ 68 - 0
app/common/dao/user/UserBillDao.php

@@ -12,8 +12,14 @@ namespace app\common\dao\user;
12
 
12
 
13
 
13
 
14
 use app\common\dao\BaseDao;
14
 use app\common\dao\BaseDao;
15
+use app\common\enum\user\UserBillEnum;
15
 use app\common\model\BaseModel;
16
 use app\common\model\BaseModel;
16
 use app\common\model\user\UserBill;
17
 use app\common\model\user\UserBill;
18
+use app\entity\CommonEntity;
19
+use app\entity\data\user\UserBillEntity;
20
+use think\db\exception\DataNotFoundException;
21
+use think\db\exception\DbException;
22
+use think\db\exception\ModelNotFoundException;
17
 
23
 
18
 /**
24
 /**
19
  * Class UserBillDao
25
  * Class UserBillDao
@@ -186,4 +192,66 @@ class UserBillDao extends BaseDao
186
         return UserBill::getDB()->group('type')->column('title,type');
192
         return UserBill::getDB()->group('type')->column('title,type');
187
     }
193
     }
188
 
194
 
195
+    /**
196
+     * @param array $billIdList
197
+     * @return UserBillEntity[]
198
+     */
199
+    public function getUserBillEntityListByBillIdList(array $billIdList): array
200
+    {
201
+        $entityList = [];
202
+        try {
203
+            $dataList = UserBill::getDB()
204
+                ->whereIn('bill_id', $billIdList)
205
+                ->select()
206
+                ->toArray();
207
+            if (!empty($dataList)) {
208
+                $entityList = array_map(function ($data) {
209
+                    return UserBillEntity::newInstance($data);
210
+                }, $dataList);
211
+            }
212
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
213
+
214
+        }
215
+        return $entityList;
216
+    }
217
+
218
+    /**
219
+     * @param string $typeShop
220
+     * @param array $orderIdList
221
+     * @return UserBillEntity[]
222
+     */
223
+    public function getUserBillEntityListByOrderIdListAndPending(string $typeShop, array $orderIdList): array
224
+    {
225
+        $entityList = [];
226
+        try {
227
+            $dataList = UserBill::getDB()
228
+                ->where('type_shop', '=', $typeShop)
229
+                ->whereIn('link_id', $orderIdList)
230
+                ->where('status', '=', UserBillEnum::STATUS['PENDING']['code'])
231
+                ->select()
232
+                ->toArray();
233
+            if (!empty($dataList)) {
234
+                $entityList = array_map(function ($data) {
235
+                    return UserBillEntity::newInstance($data);
236
+                }, $dataList);
237
+            }
238
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
239
+
240
+        }
241
+        return $entityList;
242
+    }
243
+
244
+    /**
245
+     * 批量更新
246
+     * @param $dataList
247
+     * @return array
248
+     */
249
+    public function saveAll($dataList): array
250
+    {
251
+        try {
252
+            return $this->getModel()::getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray();
253
+        } catch (\Exception $e) {
254
+            return [];
255
+        }
256
+    }
189
 }
257
 }

+ 0 - 40
app/common/dao/user/UserCertification.php

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

+ 102 - 0
app/common/dao/user/UserCertificationDao.php

@@ -0,0 +1,102 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-04-28
7
+ *
8
+ *
9
+ */
10
+
11
+namespace app\common\dao\user;
12
+
13
+
14
+use app\common\dao\BaseDao;
15
+use app\common\model\BaseModel;
16
+use app\common\model\user\UserCertification;
17
+use app\entity\data\user\UserCertificationEntity;
18
+use think\db\exception\DataNotFoundException;
19
+use think\db\exception\DbException;
20
+use think\db\exception\ModelNotFoundException;
21
+
22
+
23
+/**
24
+ * Class UserDao
25
+ * @package app\common\dao\user
26
+ * @author xaboy
27
+ * @day 2020-04-28
28
+ */
29
+class UserCertificationDao extends BaseDao
30
+{
31
+
32
+    /**
33
+     * @return BaseModel
34
+     * @author xaboy
35
+     * @day 2020-03-30
36
+     */
37
+    protected function getModel(): string
38
+    {
39
+        return UserCertification::class;
40
+    }
41
+
42
+    /**
43
+     * @param array $idList
44
+     * @return UserCertificationEntity[]
45
+     */
46
+    public function getUserCertificationEntityListByIdList(array $idList): array
47
+    {
48
+        $entityList = [];
49
+        try {
50
+            $dataList = UserCertification::getDB()
51
+                ->whereIn('id', $idList)
52
+                ->select()
53
+                ->toArray();
54
+            if (!empty($dataList)) {
55
+                $entityList = array_map(function ($data) {
56
+                    return UserCertificationEntity::newInstance($data);
57
+                }, $dataList);
58
+            }
59
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
60
+
61
+        }
62
+        return $entityList;
63
+    }
64
+
65
+    /**
66
+     * @param array $uidList
67
+     * @return UserCertificationEntity[]
68
+     */
69
+    public function getUserCertificationEntityListByUidList(array $uidList): array
70
+    {
71
+        $entityList = [];
72
+        try {
73
+            $dataList = UserCertification::getDB()
74
+                ->whereIn('uid', $uidList)
75
+                ->select()
76
+                ->toArray();
77
+            if (!empty($dataList)) {
78
+                $entityList = array_map(function ($data) {
79
+                    return UserCertificationEntity::newInstance($data);
80
+                }, $dataList);
81
+            }
82
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
83
+
84
+        }
85
+        return $entityList;
86
+    }
87
+
88
+    /**
89
+     * @param $mobile
90
+     * @return array|\think\db\BaseQuery|\think\Model|null
91
+     * @throws DataNotFoundException
92
+     * @throws DbException
93
+     * @throws ModelNotFoundException
94
+     * @author 史晨
95
+     * @date 2025/10/20 17:21
96
+     * 获取用户实名信息
97
+     */
98
+    public function getUserCertification($mobile)
99
+    {
100
+        return $this->getModel()::getDB()->where('mobile', $mobile)->find();
101
+    }
102
+}

+ 50 - 0
app/common/dao/user/UserDao.php

@@ -12,9 +12,12 @@ namespace app\common\dao\user;
12
 
12
 
13
 
13
 
14
 use app\common\dao\BaseDao;
14
 use app\common\dao\BaseDao;
15
+use app\common\enum\user\UserEnum;
15
 use app\common\model\BaseModel;
16
 use app\common\model\BaseModel;
16
 use app\common\model\user\User;
17
 use app\common\model\user\User;
17
 use app\common\repositories\user\UserRepository;
18
 use app\common\repositories\user\UserRepository;
19
+use app\entity\CommonEntity;
20
+use app\entity\data\user\UserEntity;
18
 use think\db\BaseQuery;
21
 use think\db\BaseQuery;
19
 use think\db\exception\DataNotFoundException;
22
 use think\db\exception\DataNotFoundException;
20
 use think\db\exception\DbException;
23
 use think\db\exception\DbException;
@@ -406,4 +409,51 @@ class UserDao extends BaseDao
406
         return $this::getModel()::getDB()->where('test_user', '=', 1)->whereOr('is_del', '=', 1)->column('uid');
409
         return $this::getModel()::getDB()->where('test_user', '=', 1)->whereOr('is_del', '=', 1)->column('uid');
407
     }
410
     }
408
 
411
 
412
+    /**
413
+     * @param array $uidList
414
+     * @return UserEntity[]
415
+     */
416
+    public function getUserEntityListByUidList(array $uidList): array
417
+    {
418
+        $entityList = [];
419
+        try {
420
+            $dataList = User::getDB()
421
+                ->whereIn('uid', $uidList)
422
+                ->where('is_del', '=', UserEnum::IS_DEL['No']['code'])
423
+                ->select()
424
+                ->toArray();
425
+            if (!empty($dataList)) {
426
+                $entityList = array_map(function ($data) {
427
+                    return UserEntity::newInstance($data);
428
+                }, $dataList);
429
+            }
430
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
431
+
432
+        }
433
+        return $entityList;
434
+    }
435
+
436
+    /**
437
+     * 批量更新
438
+     * @param $dataList
439
+     * @return array
440
+     */
441
+    public function saveAll($dataList): array
442
+    {
443
+        try {
444
+            return $this->getModel()::getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray();
445
+        } catch (\Exception $e) {
446
+            return [];
447
+        }
448
+    }
449
+
450
+    /**
451
+     * @param $userId
452
+     * @return array
453
+     * 获取直推用户ID
454
+     */
455
+    public function getDirectUserIds($userId)
456
+    {
457
+        return $this::getModel()::getDB()->where('level_id', '=', $userId)->column('uid');
458
+    }
409
 }
459
 }

+ 89 - 0
app/common/dao/user/UserPvLogDao.php

@@ -0,0 +1,89 @@
1
+<?php
2
+
3
+namespace app\common\dao\user;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\enum\user\UserPvLogEnum;
7
+use app\common\model\BaseModel;
8
+use app\common\model\user\UserPvLog;
9
+use app\entity\CommonEntity;
10
+use app\entity\data\user\UserPvLogEntity;
11
+use think\db\exception\DataNotFoundException;
12
+use think\db\exception\DbException;
13
+use think\db\exception\ModelNotFoundException;
14
+
15
+class UserPvLogDao extends BaseDao
16
+{
17
+    /**
18
+     * @return BaseModel
19
+     */
20
+    protected function getModel(): string
21
+    {
22
+        return UserPvLog::class;
23
+    }
24
+
25
+    /**
26
+     * @param array $idList
27
+     * @return CommonEntity[]
28
+     */
29
+    public function getUserPvLogEntityListByIdList(array $idList): array
30
+    {
31
+        $entityList = [];
32
+        try {
33
+            /** @var UserPvLog $model */
34
+            $model = $this->getModel();
35
+            $dataRes = $model::getDB()
36
+                ->whereIn('id', $idList)
37
+                ->select()
38
+                ->toArray();
39
+            if (!empty($dataRes)) {
40
+                $entityList = array_map(function ($data) {
41
+                    return UserPvLogEntity::newInstance($data);
42
+                }, $dataRes);
43
+            }
44
+        } catch (\Exception $e) {
45
+
46
+        }
47
+        return $entityList;
48
+    }
49
+
50
+    /**
51
+     * @param string $orderType
52
+     * @param array $orderIdList
53
+     * @return UserPvLogEntity[]
54
+     */
55
+    public function getUserPvLogEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
56
+    {
57
+        $entityList = [];
58
+        try {
59
+            $dataList = UserPvLog::getDB()
60
+                ->where('order_type', '=', $orderType)
61
+                ->whereIn('order_id', $orderIdList)
62
+                ->where('status', '=', UserPvLogEnum::STATUS['PendingConfirmation']['code'])
63
+                ->select()
64
+                ->toArray();
65
+            if (!empty($dataList)) {
66
+                $entityList = array_map(function ($data) {
67
+                    return UserPvLogEntity::newInstance($data);
68
+                }, $dataList);
69
+            }
70
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
71
+
72
+        }
73
+        return $entityList;
74
+    }
75
+
76
+    /**
77
+     * 批量更新
78
+     * @param $dataList
79
+     * @return array
80
+     */
81
+    public function saveAll($dataList): array
82
+    {
83
+        try {
84
+            return $this->getModel()::getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray();
85
+        } catch (\Exception $e) {
86
+            return [];
87
+        }
88
+    }
89
+}

+ 14 - 0
app/common/dao/user/UserSignFenrunDao.php

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

+ 91 - 0
app/common/dao/user/UserSignFugouDao.php

@@ -0,0 +1,91 @@
1
+<?php
2
+
3
+namespace app\common\dao\user;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\enum\user\UserSignFugouEnum;
7
+use app\common\model\BaseModel;
8
+use app\common\model\user\UserSignFugou;
9
+use app\entity\CommonEntity;
10
+use app\entity\data\user\UserSignFugouEntity;
11
+use think\db\exception\DataNotFoundException;
12
+use think\db\exception\DbException;
13
+use think\db\exception\ModelNotFoundException;
14
+
15
+class UserSignFugouDao extends BaseDao
16
+{
17
+    /**
18
+     * @return BaseModel
19
+     */
20
+    protected function getModel(): string
21
+    {
22
+        return UserSignFugou::class;
23
+    }
24
+
25
+    /**
26
+     * @param array $idList
27
+     * @return CommonEntity[]
28
+     */
29
+    public function getUserSignFugouEntityListByIdList(array $idList): array
30
+    {
31
+        $entityList = [];
32
+        try {
33
+            /** @var UserSignFugou $model */
34
+            $model = $this->getModel();
35
+            $dataRes = $model::getDB()
36
+                ->whereIn('id', $idList)
37
+                ->select()
38
+                ->toArray();
39
+            if (!empty($dataRes)) {
40
+                $entityList = array_map(function ($data) {
41
+                    return UserSignFugouEntity::newInstance($data);
42
+                }, $dataRes);
43
+            }
44
+        } catch (\Exception $e) {
45
+
46
+        }
47
+        return $entityList;
48
+    }
49
+
50
+    /**
51
+     * @param string $orderType
52
+     * @param array $orderIdList
53
+     * @return UserSignFugouEntity[]
54
+     */
55
+    public function getUserSignFugouEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
56
+    {
57
+        $entityList = [];
58
+        try {
59
+            /** @var UserSignFugou $model */
60
+            $model = $this->getModel();
61
+            $dataList = $model::getDB()
62
+                ->where('order_type', '=', $orderType)
63
+                ->whereIn('order_id', $orderIdList)
64
+                ->where('status', '=', UserSignFugouEnum::STATUS['Pending']['code'])
65
+                ->select()
66
+                ->toArray();
67
+            if (!empty($dataList)) {
68
+                $entityList = array_map(function ($data) {
69
+                    return UserSignFugouEntity::newInstance($data);
70
+                }, $dataList);
71
+            }
72
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
73
+
74
+        }
75
+        return $entityList;
76
+    }
77
+
78
+    /**
79
+     * 批量更新
80
+     * @param $dataList
81
+     * @return array
82
+     */
83
+    public function saveAll($dataList): array
84
+    {
85
+        try {
86
+            return $this->getModel()::getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray();
87
+        } catch (\Exception $e) {
88
+            return [];
89
+        }
90
+    }
91
+}

+ 89 - 0
app/common/dao/user/UserSignGongxianDao.php

@@ -0,0 +1,89 @@
1
+<?php
2
+
3
+namespace app\common\dao\user;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\enum\user\UserSignGongxianEnum;
7
+use app\common\model\BaseModel;
8
+use app\common\model\user\UserSignGongxian;
9
+use app\entity\CommonEntity;
10
+use app\entity\data\user\UserSignGongxianEntity;
11
+use think\db\exception\DataNotFoundException;
12
+use think\db\exception\DbException;
13
+use think\db\exception\ModelNotFoundException;
14
+
15
+class UserSignGongxianDao extends BaseDao
16
+{
17
+    /**
18
+     * @return BaseModel
19
+     */
20
+    protected function getModel(): string
21
+    {
22
+        return UserSignGongxian::class;
23
+    }
24
+
25
+    /**
26
+     * @param array $idList
27
+     * @return CommonEntity[]
28
+     */
29
+    public function getUserSignGongxianEntityListByIdList(array $idList): array
30
+    {
31
+        $entityList = [];
32
+        try {
33
+            /** @var UserSignGongxian $model */
34
+            $model = $this->getModel();
35
+            $dataRes = $model::getDB()
36
+                ->whereIn('id', $idList)
37
+                ->select()
38
+                ->toArray();
39
+            if (!empty($dataRes)) {
40
+                $entityList = array_map(function ($data) {
41
+                    return UserSignGongxianEntity::newInstance($data);
42
+                }, $dataRes);
43
+            }
44
+        } catch (\Exception $e) {
45
+
46
+        }
47
+        return $entityList;
48
+    }
49
+
50
+    /**
51
+     * @param string $orderType
52
+     * @param array $orderIdList
53
+     * @return UserSignGongxianEntity[]
54
+     */
55
+    public function getUserSignGongxianEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
56
+    {
57
+        $entityList = [];
58
+        try {
59
+            $dataList = UserSignGongxian::getDB()
60
+                ->where('order_type', '=', $orderType)
61
+                ->whereIn('order_id', $orderIdList)
62
+                ->where('status', '=', UserSignGongxianEnum::STATUS['PendingConfirmation']['code'])
63
+                ->select()
64
+                ->toArray();
65
+            if (!empty($dataList)) {
66
+                $entityList = array_map(function ($data) {
67
+                    return UserSignGongxianEntity::newInstance($data);
68
+                }, $dataList);
69
+            }
70
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
71
+
72
+        }
73
+        return $entityList;
74
+    }
75
+
76
+    /**
77
+     * 批量更新
78
+     * @param $dataList
79
+     * @return array
80
+     */
81
+    public function saveAll($dataList): array
82
+    {
83
+        try {
84
+            return $this->getModel()::getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray();
85
+        } catch (\Exception $e) {
86
+            return [];
87
+        }
88
+    }
89
+}

+ 89 - 0
app/common/dao/user/UserSignHongbaoDao.php

@@ -0,0 +1,89 @@
1
+<?php
2
+
3
+namespace app\common\dao\user;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\enum\user\UserSignHongbaoEnum;
7
+use app\common\model\BaseModel;
8
+use app\common\model\user\UserSignHongbao;
9
+use app\entity\CommonEntity;
10
+use app\entity\data\user\UserSignHongbaoEntity;
11
+use think\db\exception\DataNotFoundException;
12
+use think\db\exception\DbException;
13
+use think\db\exception\ModelNotFoundException;
14
+
15
+class UserSignHongbaoDao extends BaseDao
16
+{
17
+    /**
18
+     * @return BaseModel
19
+     */
20
+    protected function getModel(): string
21
+    {
22
+        return UserSignHongbao::class;
23
+    }
24
+
25
+    /**
26
+     * @param array $idList
27
+     * @return CommonEntity[]
28
+     */
29
+    public function getUserSignHongbaoEntityListByIdList(array $idList): array
30
+    {
31
+        $entityList = [];
32
+        try {
33
+            /** @var UserSignHongbao $model */
34
+            $model = $this->getModel();
35
+            $dataRes = $model::getDB()
36
+                ->whereIn('id', $idList)
37
+                ->select()
38
+                ->toArray();
39
+            if (!empty($dataRes)) {
40
+                $entityList = array_map(function ($data) {
41
+                    return UserSignHongbaoEntity::newInstance($data);
42
+                }, $dataRes);
43
+            }
44
+        } catch (\Exception $e) {
45
+
46
+        }
47
+        return $entityList;
48
+    }
49
+
50
+    /**
51
+     * @param string $orderType
52
+     * @param array $orderIdList
53
+     * @return UserSignHongbaoEntity[]
54
+     */
55
+    public function getUserSignHongbaoEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
56
+    {
57
+        $entityList = [];
58
+        try {
59
+            $dataList = UserSignHongbao::getDB()
60
+                ->where('order_type', '=', $orderType)
61
+                ->whereIn('order_id', $orderIdList)
62
+                ->where('status', '=', UserSignHongbaoEnum::STATUS['PendingConfirmation']['code'])
63
+                ->select()
64
+                ->toArray();
65
+            if (!empty($dataList)) {
66
+                $entityList = array_map(function ($data) {
67
+                    return UserSignHongbaoEntity::newInstance($data);
68
+                }, $dataList);
69
+            }
70
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
71
+
72
+        }
73
+        return $entityList;
74
+    }
75
+
76
+    /**
77
+     * 批量更新
78
+     * @param $dataList
79
+     * @return array
80
+     */
81
+    public function saveAll($dataList): array
82
+    {
83
+        try {
84
+            return $this->getModel()::getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray();
85
+        } catch (\Exception $e) {
86
+            return [];
87
+        }
88
+    }
89
+}

+ 41 - 0
app/common/dao/user/UserSignJingdouDao.php

@@ -0,0 +1,41 @@
1
+<?php
2
+
3
+namespace app\common\dao\user;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\user\UserSignJingdou;
7
+use app\entity\CommonEntity;
8
+use app\entity\data\user\UserSignJingdouEntity;
9
+
10
+class UserSignJingdouDao extends BaseDao
11
+{
12
+    protected function getModel(): string
13
+    {
14
+        return UserSignJingdou::class;
15
+    }
16
+
17
+    /**
18
+     * @param array $idList
19
+     * @return CommonEntity[]
20
+     */
21
+    public function getStoreSignJingdouEntityListByIdList(array $idList): array
22
+    {
23
+        $entityList = [];
24
+        try {
25
+            /** @var UserSignJingdou $model */
26
+            $model = $this->getModel();
27
+            $dataRes = $model::getDB()
28
+                ->whereIn('id', $idList)
29
+                ->select()
30
+                ->toArray();
31
+            if (!empty($dataRes)) {
32
+                $entityList = array_map(function ($data) {
33
+                    return UserSignJingdouEntity::newInstance($data);
34
+                }, $dataRes);
35
+            }
36
+        } catch (\Exception $e) {
37
+
38
+        }
39
+        return $entityList;
40
+    }
41
+}

+ 90 - 0
app/common/dao/user/UserSignScoreDao.php

@@ -0,0 +1,90 @@
1
+<?php
2
+
3
+namespace app\common\dao\user;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\enum\user\UserSignScoreEnum;
7
+use app\common\model\BaseModel;
8
+use app\common\model\user\UserSignScore;
9
+use app\entity\CommonEntity;
10
+use app\entity\data\user\UserSignScoreEntity;
11
+use think\db\exception\DataNotFoundException;
12
+use think\db\exception\DbException;
13
+use think\db\exception\ModelNotFoundException;
14
+use think\facade\Log;
15
+
16
+class UserSignScoreDao extends BaseDao
17
+{
18
+    /**
19
+     * @return BaseModel
20
+     */
21
+    protected function getModel(): string
22
+    {
23
+        return UserSignScore::class;
24
+    }
25
+
26
+    /**
27
+     * @param array $idList
28
+     * @return CommonEntity[]
29
+     */
30
+    public function getUserSignScoreEntityListByIdList(array $idList): array
31
+    {
32
+        $entityList = [];
33
+        try {
34
+            /** @var UserSignScore $model */
35
+            $model = $this->getModel();
36
+            $dataRes = $model::getDB()
37
+                ->whereIn('id', $idList)
38
+                ->select()
39
+                ->toArray();
40
+            if (!empty($dataRes)) {
41
+                $entityList = array_map(function ($data) {
42
+                    return UserSignScoreEntity::newInstance($data);
43
+                }, $dataRes);
44
+            }
45
+        } catch (\Exception $e) {
46
+
47
+        }
48
+        return $entityList;
49
+    }
50
+
51
+    /**
52
+     * @param string $orderType
53
+     * @param array $orderIdList
54
+     * @return UserSignScoreEntity[]
55
+     */
56
+    public function getUserSignScoreEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
57
+    {
58
+        $entityList = [];
59
+        try {
60
+            $dataList = UserSignScore::getDB()
61
+                ->where('order_type', '=', $orderType)
62
+                ->whereIn('order_id', $orderIdList)
63
+                ->where('status', '=', UserSignScoreEnum::STATUS['Pending']['code'])
64
+                ->select()
65
+                ->toArray();
66
+            if (!empty($dataList)) {
67
+                $entityList = array_map(function ($data) {
68
+                    return UserSignScoreEntity::newInstance($data);
69
+                }, $dataList);
70
+            }
71
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
72
+
73
+        }
74
+        return $entityList;
75
+    }
76
+
77
+    /**
78
+     * 批量更新
79
+     * @param $dataList
80
+     * @return array
81
+     */
82
+    public function saveAll($dataList): array
83
+    {
84
+        try {
85
+            return $this->getModel()::getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray();
86
+        } catch (\Exception $e) {
87
+            return [];
88
+        }
89
+    }
90
+}

+ 59 - 0
app/common/dao/user/UserSignVrDao.php

@@ -0,0 +1,59 @@
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 UserSignVrDao extends BaseDao
12
+{
13
+    /**
14
+     * @return BaseModel
15
+     */
16
+    protected function getModel(): string
17
+    {
18
+        return UserSignVr::class;
19
+    }
20
+
21
+    /**
22
+     * @param array $idList
23
+     * @return CommonEntity[]
24
+     */
25
+    public function getUserSignVrEntityListByIdList(array $idList): array
26
+    {
27
+        $entityList = [];
28
+        try {
29
+            /** @var UserSignVr $model */
30
+            $model = $this->getModel();
31
+            $dataRes = $model::getDB()
32
+                ->whereIn('id', $idList)
33
+                ->select()
34
+                ->toArray();
35
+            if (!empty($dataRes)) {
36
+                $entityList = array_map(function ($data) {
37
+                    return UserSignVrEntity::newInstance($data);
38
+                }, $dataRes);
39
+            }
40
+        } catch (\Exception $e) {
41
+
42
+        }
43
+        return $entityList;
44
+    }
45
+
46
+    /**
47
+     * 批量更新
48
+     * @param $dataList
49
+     * @return array
50
+     */
51
+    public function saveAll($dataList): array
52
+    {
53
+        try {
54
+            return $this->getModel()::getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray();
55
+        } catch (\Exception $e) {
56
+            return [];
57
+        }
58
+    }
59
+}

+ 30 - 0
app/common/dao/user/ZeroUserLineDao.php

@@ -0,0 +1,30 @@
1
+<?php
2
+/**
3
+ * zero user line dao
4
+ */
5
+namespace app\common\dao\user;
6
+
7
+
8
+use app\common\dao\BaseDao;
9
+use app\common\model\user\ZeroUserLine;
10
+
11
+class ZeroUserLineDao extends BaseDao
12
+{
13
+    protected function getModel(): string
14
+    {
15
+        return ZeroUserLine::class;
16
+    }
17
+
18
+    /**
19
+     * @param $where
20
+     * @param $page
21
+     * @param $limit
22
+     * @return mixed
23
+     * 获取列表
24
+     */
25
+    public function getList($where, $page, $limit)
26
+    {
27
+        $model = $this->getModel();
28
+        return $model::getDB()->where($where)->order('id','desc')->paginate(['page' => $page, 'list_rows' => $limit]);
29
+    }
30
+}

+ 255 - 0
app/common/enum/CommonEnum.php

@@ -0,0 +1,255 @@
1
+<?php
2
+
3
+namespace app\common\enum;
4
+
5
+class CommonEnum
6
+{
7
+
8
+    // 系统指定的 商户ID
9
+    const DESIGN_MERCHANT_ID = [
10
+        'MemberZone' => ['code' => 496, 'name' => '会员专区'],
11
+        'WonderfulLiving' => ['code' => 439, 'name' => '精彩生活区'],
12
+        'Repurchase' => ['code' => 491, 'name' => '复购区'],
13
+    ];
14
+
15
+
16
+    const IS_DEL = [
17
+        'No' => ['code' => 0, 'name' => '未删除'],
18
+        'Yes' => ['code' => 1, 'name' => '已删除'],
19
+        'Pending' => ['code' => 2, 'name' => '待删除']
20
+    ];
21
+
22
+    // 订单类型:根据业务需要进一步扩展
23
+    const ORDER_TYPE = [
24
+        'Platform' => ['code' => 0, 'name' => '平台'],
25
+        'DuoduoJinbao' => ['code' => 1, 'name' => '多多进宝'],
26
+        'Vipshop' => ['code' => 2, 'name' => '唯品会'],
27
+        'SuningYigou' => ['code' => 3, 'name' => '苏宁易购'],
28
+        'NetEaseKaola' => ['code' => 4, 'name' => '网易考拉'],
29
+        'TaobaoKe' => ['code' => 5, 'name' => '淘宝客'],
30
+        'JingdongUnion' => ['code' => 6, 'name' => '京东联盟'],
31
+        'Eleme' => ['code' => 7, 'name' => '饿了么'],
32
+        'Online' => ['code' => 8, 'name' => '线上'],
33
+        'MobileTopUp' => ['code' => 9, 'name' => '话费'],
34
+        'Offline' => ['code' => 10, 'name' => '线下'],
35
+        'Platform-Group' => ['code' => 1000, 'name' => '平台-GroupId'], // 该中类型时,依然是 平台订单,只不过 表中的order_id 存储的是
36
+        'XingfuXiaodian' => ['code' => 2001, 'name' => '幸福小店'],
37
+    ];
38
+
39
+    // 佣金类型
40
+    const COMMISSION_TYPE = [
41
+        'AGENT_FEE' => ['code' => 1, 'name' => '代理费'],
42
+        'CONSUMPTION_COMMISSION' => ['code' => 2, 'name' => '消费佣金'],
43
+        'DIRECT_REFERRAL' => ['code' => 3, 'name' => '直推奖'],
44
+        'REGION_COMMISSION' => ['code' => 4, 'name' => '辖区佣金'],
45
+        'PENSION' => ['code' => 5, 'name' => '养老金'],
46
+        'AD_FEE' => ['code' => 6, 'name' => '广告费'],
47
+        'LOCKED_CUSTOMER' => ['code' => 7, 'name' => '锁客收益'],
48
+        'PLATFORM_REWARD' => ['code' => 8, 'name' => '平台奖励'],
49
+        'CHANNEL_DEALER' => ['code' => 9, 'name' => '渠道商'],
50
+        'SHOP_REWARD' => ['code' => 10, 'name' => '推广店铺收益'],
51
+        'PARTNER_DIVIDEND' => ['code' => 11, 'name' => '合伙人分红'],
52
+        'JOINT_CREATOR_DIVIDEND' => ['code' => 12, 'name' => '联创分红'],
53
+        'EQUITY_DIVIDEND' => ['code' => 13, 'name' => '股权分红'],
54
+        'SHARE_EARNINGS' => ['code' => 20, 'name' => '分享收益']
55
+    ];
56
+
57
+    const USER_GROUP = [
58
+        'RegularUser' => ['code' => 1, 'name' => '普通用户'],
59
+        'Salesperson' => ['code' => 2, 'name' => '业务员'],
60
+        'SalesManager' => ['code' => 3, 'name' => '业务经理'],
61
+        'JuniorPartner' => ['code' => 4, 'name' => '初级合伙人'],
62
+        'Mid-LevelPartner' => ['code' => 5, 'name' => '中级合伙人'],
63
+        'SeniorPartner' => ['code' => 6, 'name' => '中级合伙人'],
64
+        'Director' => ['code' => 7, 'name' => '董事']
65
+    ];
66
+
67
+    // 直推奖励的分配比例
68
+    const DIRECT_REFERRAL_BONUS = [
69
+        'BrokeragePrice' => ['code' => 0.9, 'name' => '直推奖励的佣金部分'],
70
+        'Fugou' => ['code' => 0.1, 'name' => '直推奖励的佣金部分']
71
+    ];
72
+
73
+    // 计算式小数点保留位数 超出位数 舍弃
74
+    const CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES = 5;
75
+    // 金额保留小数点位 超出部分舍弃
76
+    const DECIMAL_PLACES_OF_THE_AMOUNT = 2;
77
+    // 平台手续费(汇付通道服务费)
78
+    const HUIFU_COMMISSION_CHARGE = 0.0038;
79
+
80
+    // 订单 收益 的分配
81
+    const ORDER_EARNING_ALLOCATION = [
82
+        // 精彩生活区
83
+        'WonderfulLiving' => [
84
+            'Self' => [
85
+                'YangLaoJin' => [ // 钱
86
+                    'Ratio' => ['code' => 0.3, 'name' => '将利润的30%,当做养老金分配给下单人']
87
+                ],
88
+                'Hongbao' => [ // 钱
89
+                    'Ratio' => ['code' => 0.1575, 'name' => '将利润的35% * 45%,当做红包分配给下单人,前提下单人是老用户(35% * 45%)']
90
+                ],
91
+                'Score' => [ // 钱
92
+                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做积分值分配给下单人']
93
+                ],
94
+                'Pv' => [ // 数据 算业绩
95
+                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做PV值分配给下单人']
96
+                ],
97
+                'Gongxian' => [ // 数据 升级用
98
+                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做贡献值分配给下单人']
99
+                ]
100
+            ],
101
+            'Spread' => [
102
+                'BrokeragePrice' => [
103
+                    'Ratio' => ['code' => 0.35 * 0.9, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35% * 90% ,直推奖励的佣金部分'],
104
+                ],
105
+                'Fugou' => [
106
+                    'Ratio' => ['code' => 0.35 * 0.1, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35% * 10% ,直推奖励的复购部分'],
107
+                ],
108
+                'Gongxian' => [
109
+                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做贡献值分配给推荐人']
110
+                ],
111
+                'Score' => [
112
+                    'Ratio' => ['code' => 0.35, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35%,当做积分值分配给推荐人']
113
+                ],
114
+                'YangLaoJin' => [
115
+                    'Ratio' => ['code' => 0.35 * 0.5, 'name' => '将利润的35%中的5%,当做养老金分配给推荐人']
116
+                ]
117
+            ],
118
+            'Share' => [
119
+                'BrokeragePrice' => [
120
+                    'Ratio' => ['code' => 0.35 * 0.03 * 0.9, 'name' => '将利润的 35% 中的 3% 中的 90%,做为分享奖励的佣金部分'],
121
+                ],
122
+                'Fugou' => [
123
+                    'Ratio' => ['code' => 0.35 * 0.03 * 0.1, 'name' => '将利润的 35% 中的 3% 中的 10%,做为分享奖励的复购部分'],
124
+                ]
125
+            ],
126
+            'Lock' => [
127
+                'BrokeragePrice' => [
128
+                    'Ratio' => ['code' => 0.35 * 0.05 * 0.9, 'name' => '将利润的 35% 中的 5% 中的 90%,做为锁客奖励的佣金部分'],
129
+                ],
130
+                'Fugou' => [
131
+                    'Ratio' => ['code' => 0.35 * 0.05 * 0.1, 'name' => '将利润的 35% 中的 5% 中的 10%,做为锁客奖励的复购部分'],
132
+                ]
133
+            ]
134
+        ],
135
+        'MemberZone' => [
136
+            'Fixed' => [
137
+                'Basic' => [ // 售价 => 基础计算价格 (历史原因:原价是1000、2000...等,后来单间成本价上调了180,所以售价调整了,考虑到涨价前后的奖励应保持一致,所以设置了基础计算值)
138
+                    '1180.00' => 1000.00,
139
+                    '2360.00' => 2000.00,
140
+                    '5900.00' => 5000.00,
141
+                    '9440.00' => 8000.00,
142
+                    '10620.00' => 9000.00,
143
+                    '11800.00' => 10000.00
144
+                ]
145
+            ],
146
+            'Self' => [
147
+                // 养老金比例
148
+                'YangLaoJin' => [
149
+                    'Ratio' => ['code' => 0.035, 'name' => '将3.5%,当做养老金分配给下单人']
150
+                ],
151
+                'Gongxian' => [
152
+                    'Ratio' => ['code' => 0.7, 'name' => '将利润的35%,当做贡献值分配给下单人']
153
+                ],
154
+                'Pv' => [
155
+                    'Ratio' => ['code' => 0.7, 'name' => '将70%,当做PV值分配给下单人']
156
+                ],
157
+                'Score' => [
158
+                    'Ratio' => ['code' => 0.7, 'name' => '将利润的35%,当做积分值分配给下单人']
159
+                ]
160
+            ],
161
+            'Spread' => [
162
+                'IdentityRatio' => [
163
+                    1 => 0.1,
164
+                    2 => 0.3,
165
+                    3 => 0.3,
166
+                    4 => 0.3,
167
+                    5 => 0.3,
168
+                    6 => 0.3,
169
+                    7 => 0.3,
170
+                ],
171
+                'BrokeragePrice' => [
172
+                    'Ratio' => ['code' => 0.9, 'name' => '直推奖励的佣金部分'],
173
+                ],
174
+                'Fugou' => [
175
+                    'Ratio' => ['code' => 0.1, 'name' => '直推奖励的复购部分'],
176
+                ],
177
+                'Gongxian' => [
178
+                    'Ratio' => ['code' => 0.7, 'name' => '将70%,当做贡献值分配给推荐人'],
179
+                    'RegularUserRatio' => ['code' => 0.7 * 0.3, 'name' => '将70% * 30%,当做贡献值分配给推荐人(普通用户)'],
180
+                ],
181
+                'Score' => [
182
+                    'Ratio' => ['code' => 0.7, 'name' => '将用户身份等级对应的直推分润的70%,当做积分值分配给推荐人']
183
+                ],
184
+                'YangLaoJin' => [
185
+                    'Ratio' => ['code' => 0.035, 'name' => '将3.5%,当做养老金分配给推荐人']
186
+                ]
187
+            ]
188
+        ],
189
+        'Repurchase' => [
190
+            'Self' => [
191
+                // 养老金比例
192
+                'YangLaoJin' => [
193
+                    'Ratio' => ['code' => 0.5, 'name' => '将50%,当做养老金分配给下单人']
194
+                ]
195
+            ],
196
+            'SpreadDirectly' => [
197
+                // 养老金比例 直接推荐人
198
+                'YangLaoJin' => [
199
+                    'Ratio' => ['code' => 0.3, 'name' => '将30%,当做养老金分配给直推人']
200
+                ]
201
+            ],
202
+            'SpreadIndirectly' => [
203
+                // 养老金比例 间接推荐人
204
+                'YangLaoJin' => [
205
+                    'Ratio' => ['code' => 0.2, 'name' => '将20%,当做养老金分配给间推人']
206
+                ]
207
+            ]
208
+        ],
209
+        'CommercialDistrict' => [
210
+            'Self' => [
211
+                'YangLaoJin' => [ // 钱
212
+                    'Ratio' => ['code' => 0.3, 'name' => '将利润的30%,当做养老金分配给下单人']
213
+                ],
214
+                'Hongbao' => [ // 钱
215
+                    'Ratio' => ['code' => 0.35 * 0.45, 'name' => '将利润的35% * 45%,当做红包分配给下单人,前提下单人是老用户(35% * 45%)']
216
+                ],
217
+                'Score' => [ // 钱
218
+                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做积分值分配给下单人']
219
+                ],
220
+                'Pv' => [ // 数据 算业绩
221
+                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做PV值分配给下单人']
222
+                ],
223
+                'Gongxian' => [ // 数据 升级用
224
+                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做贡献值分配给下单人']
225
+                ]
226
+            ],
227
+            'Spread' => [
228
+                'BrokeragePrice' => [
229
+                    'Ratio' => ['code' => 0.35 * 0.9, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35% * 90% ,直推奖励的佣金部分'],
230
+                ],
231
+                'Fugou' => [
232
+                    'Ratio' => ['code' => 0.35 * 0.1, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35% * 10% ,直推奖励的复购部分'],
233
+                ],
234
+                'Gongxian' => [
235
+                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做贡献值分配给推荐人']
236
+                ],
237
+                'Score' => [
238
+                    'Ratio' => ['code' => 0.35, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35%,当做积分值分配给推荐人']
239
+                ],
240
+                'YangLaoJin' => [
241
+                    'Ratio' => ['code' => 0.35 * 0.5, 'name' => '将利润的35%中的5%,当做养老金分配给推荐人']
242
+                ]
243
+            ],
244
+            'Lock' => [
245
+                'BrokeragePrice' => [
246
+                    'Ratio' => ['code' => 0.35 * 0.05 * 0.9, 'name' => '将利润的 35% 中的 5% 中的 90%,做为锁客奖励的佣金部分'],
247
+                ],
248
+                'Fugou' => [
249
+                    'Ratio' => ['code' => 0.35 * 0.05 * 0.1, 'name' => '将利润的 35% 中的 5% 中的 10%,做为锁客奖励的复购部分'],
250
+                ]
251
+            ]
252
+        ]
253
+    ];
254
+
255
+}

+ 27 - 0
app/common/enum/gzc/GzcLogEnum.php

@@ -0,0 +1,27 @@
1
+<?php
2
+
3
+namespace app\common\enum\gzc;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class GzcLogEnum extends CommonEnum
8
+{
9
+    // 账号类型
10
+    const ACCOUNT_TYPE = [
11
+        'Bank' => ['code' => 1, 'name' => '银行卡'],
12
+        'Alipay' => ['code' => 2, 'name' => '支付宝'],
13
+        'Wxpay' => ['code' => 3, 'name' => '微信'],
14
+    ];
15
+
16
+    // 公证处是否已发起入账
17
+    const GZC_STATUS = [
18
+        'NotInitiated' => ['code' => 0, 'name' => '未发起'],
19
+        'Initiated' => ['code' => 1, 'name' => '已发起'],
20
+    ];
21
+
22
+    // 是否入账成功
23
+    const SUCCESS_STATUS = [
24
+        'Failed' => ['code' => 0, 'name' => '入账失败'],
25
+        'Success' => ['code' => 1, 'name' => '入账成功'],
26
+    ];
27
+}

+ 64 - 0
app/common/enum/merchant/MerchantEnum.php

@@ -0,0 +1,64 @@
1
+<?php
2
+
3
+namespace app\common\enum\merchant;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class MerchantEnum extends CommonEnum
8
+{
9
+    const IS_DEL = parent::IS_DEL;
10
+
11
+    // 商户类型
12
+    const MER_TYPE = [
13
+        'Normal' => ['code' => 0, 'name' => '普通商户'],
14
+        'Tea' => ['code' => 1, 'name' => '一壶茶'],
15
+    ];
16
+
17
+    // 商户级别
18
+    const MERCHANT_LEVEL = [
19
+        'Low' => ['code' => 0, 'name' => '低级商户'],
20
+        'High' => ['code' => 1, 'name' => '高级商户'],
21
+    ];
22
+
23
+    // 是否体验店
24
+    const IS_EXPERIENCE = [
25
+        'No' => ['code' => 0, 'name' => '否'],
26
+        'Yes' => ['code' => 1, 'name' => '是'],
27
+    ];
28
+
29
+    // 是否连锁店
30
+    const MER_CHAIN = [
31
+        'No' => ['code' => 0, 'name' => '不是'],
32
+        'Yes' => ['code' => 1, 'name' => '是'],
33
+    ];
34
+
35
+    // 是否已缴纳保证金
36
+    const BZJ = [
37
+        'No' => ['code' => 0, 'name' => '否'],
38
+        'Yes' => ['code' => 1, 'name' => '是'],
39
+    ];
40
+
41
+    // 商户状态
42
+    const MER_STATE = [
43
+        'Open' => ['code' => 1, 'name' => '开启'],
44
+        'Close' => ['code' => 0, 'name' => '关闭'],
45
+    ];
46
+
47
+    // 商户审核状态
48
+    const IS_AUDIT = [
49
+        'NotAudited' => ['code' => 0, 'name' => '不审核'],
50
+        'Audited' => ['code' => 1, 'name' => '审核'],
51
+    ];
52
+
53
+    // 海科商户结算状态
54
+    const HAIKE_SETTLE_STATUS = [
55
+        'NotSettled' => ['code' => '0', 'name' => '未结算'],
56
+        'Settled' => ['code' => '1', 'name' => '已结算'],
57
+    ];
58
+
59
+    // 商户是否禁用
60
+    const STATUS = [
61
+        'Locked' => ['code' => 0, 'name' => '锁定'],
62
+        'Normal' => ['code' => 1, 'name' => '正常'],
63
+    ];
64
+}

+ 14 - 0
app/common/enum/product/SeckillEnum.php

@@ -0,0 +1,14 @@
1
+<?php
2
+
3
+namespace app\common\enum\product;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class SeckillEnum extends CommonEnum
8
+{
9
+    const STATUS = [
10
+        'Close' => ['code' => 0, 'name' => '关闭'],
11
+        'Open' => ['code' => 1, 'name' => '开启'],
12
+        'Over' => ['code' => 2, 'name' => '已结束']
13
+    ];
14
+}

+ 33 - 0
app/common/enum/shipping/ShippingTemplateEnum.php

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+namespace app\common\enum\shipping;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class ShippingTemplateEnum extends CommonEnum
8
+{
9
+    // 计费方式
10
+    const TYPE = [
11
+        'Quantity' => ['code' => 0, 'name' => '数量'],
12
+        'Weight' => ['code' => 1, 'name' => '重量'],
13
+        'Volume' => ['code' => 2, 'name' => '体积'],
14
+    ];
15
+
16
+    // 开启指定包邮
17
+    const APPOINT = [
18
+        'No' => ['code' => 0, 'name' => '未开启'],
19
+        'Yes' => ['code' => 1, 'name' => '已开启']
20
+    ];
21
+
22
+    // 开启指定区域不配送
23
+    const UNDELIVERY = [
24
+        'No' => ['code' => 0, 'name' => '未开启'],
25
+        'Yes' => ['code' => 1, 'name' => '已开启']
26
+    ];
27
+
28
+    // 默认模板
29
+    const IS_DEFAULT = [
30
+        'No' => ['code' => 0, 'name' => '否'],
31
+        'Yes' => ['code' => 1, 'name' => '是']
32
+    ];
33
+}

+ 23 - 0
app/common/enum/store/CartEnum.php

@@ -0,0 +1,23 @@
1
+<?php
2
+
3
+namespace app\common\enum\store;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class CartEnum extends CommonEnum
8
+{
9
+    const PRODUCT_TYPE = [
10
+        'Ordinary' => ['code' => 0, 'name' => '普通产品']
11
+    ];
12
+
13
+    const IS_FAIL = [
14
+        'No' => ['code' => 0, 'name' => '未失效'],
15
+        'Yes' => ['code' => 1, 'name' => '失效']
16
+    ];
17
+
18
+    // 是否已购买 '0 = 未购买 1 = 已购买'
19
+    const IS_PAY = [
20
+        'No' => ['code' => 0, 'name' => '未购买'],
21
+        'Yes' => ['code' => 1, 'name' => '已购买']
22
+    ];
23
+}

+ 39 - 0
app/common/enum/store/ProductEnum.php

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+namespace app\common\enum\store;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class ProductEnum extends CommonEnum
8
+{
9
+    const IS_DEL = parent::IS_DEL;
10
+
11
+    const STATUS = [
12
+        'Pending' => ['code' => 0, 'name' => '审核中'],
13
+        'Approved' => ['code' => 1, 'name' => '审核通过'],
14
+        'Rejected' => ['code' => -1, 'name' => '未通过'],
15
+        'Withdrawn' => ['code' => -2, 'name' => '下架'],
16
+    ];
17
+
18
+    const IS_SHOW = [
19
+        'No' => ['code' => 0, 'name' => '未上架'],
20
+        'Yes' => ['code' => 1, 'name' => '上架']
21
+    ];
22
+
23
+    const IS_USED = [
24
+        'No' => ['code' => 0, 'name' => '隐藏'],
25
+        'Yes' => ['code' => 1, 'name' => '显示']
26
+    ];
27
+
28
+    const MER_STATUS = [
29
+        'No' => ['code' => 0, 'name' => '非正常'],
30
+        'Yes' => ['code' => 1, 'name' => '正常']
31
+    ];
32
+
33
+
34
+    // 是否秒杀
35
+    const SECKILL = [
36
+        'No' => ['code' => 0, 'name' => '否'],
37
+        'Yes' => ['code' => 1, 'name' => '是']
38
+    ];
39
+}

+ 13 - 0
app/common/enum/store/SeckillActiveEnum.php

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace app\common\enum\store;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class SeckillActiveEnum extends CommonEnum
8
+{
9
+    const STATUS = [
10
+        'Active' => ['code' => 0, 'name' => '进行中'],
11
+        'Finish' => ['code' => 1, 'name' => '已结束']
12
+    ];
13
+}

+ 22 - 0
app/common/enum/store/StoreCouponUserEnum.php

@@ -0,0 +1,22 @@
1
+<?php
2
+
3
+namespace app\common\enum\store;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class StoreCouponUserEnum extends CommonEnum
8
+{
9
+
10
+    const STATUS = [
11
+        'Unused' => ['code' => 0, 'name' => '未使用'],
12
+        'Used' => ['code' => 1, 'name' => '已使用'],
13
+        'Expired' => ['code' => 2, 'name' => '已过期'],
14
+    ];
15
+
16
+    const IS_FAIL = [
17
+        'No' => ['code' => 0, 'name' => '未失效'],
18
+        'Yes' => ['code' => 1, 'name' => '失效']
19
+    ];
20
+
21
+
22
+}

+ 42 - 0
app/common/enum/store/StoreGroupOrderEnum.php

@@ -0,0 +1,42 @@
1
+<?php
2
+
3
+namespace app\common\enum\store;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class StoreGroupOrderEnum extends CommonEnum
8
+{
9
+    // 支付方式
10
+    const PAY_TYPE = [
11
+        'BALANCE' => ['code' => 0, 'name' => '余额支付'],
12
+        'WECHAT' => ['code' => 1, 'name' => '微信支付'],
13
+        'MINI_PROGRAM' => ['code' => 2, 'name' => '小程序支付'],
14
+        'H5' => ['code' => 3, 'name' => 'H5支付'],
15
+        'ALIPAY' => ['code' => 4, 'name' => '支付宝支付'],
16
+    ];
17
+
18
+    // 分账状态
19
+    const SPLIT_STATUS = [
20
+        'NOT_SPLIT' => ['code' => 0, 'name' => '未分账'],
21
+        'SPLIT_SUCCESS' => ['code' => 1, 'name' => '分账成功'],
22
+        'SPLIT_FAILED' => ['code' => 2, 'name' => '分账失败'],
23
+    ];
24
+
25
+    // 是否提醒
26
+    const IS_REMIND = [
27
+        'NO' => ['code' => 0, 'name' => '不提醒'],
28
+        'YES' => ['code' => 1, 'name' => '提醒'],
29
+    ];
30
+
31
+    // 是否为测试订单
32
+    const TEST_ORDER = [
33
+        'NO' => ['code' => 0, 'name' => '不是测试订单'],
34
+        'YES' => ['code' => 1, 'name' => '是测试订单'],
35
+    ];
36
+
37
+    // 支付状态
38
+    const PAID = [
39
+        'NO' => ['code' => 0, 'name' => '未支付'],
40
+        'YES' => ['code' => 1, 'name' => '已支付'],
41
+    ];
42
+}

+ 116 - 0
app/common/enum/store/StoreOrderEnum.php

@@ -0,0 +1,116 @@
1
+<?php
2
+
3
+namespace app\common\enum\store;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class StoreOrderEnum extends CommonEnum
8
+{
9
+    // 配送方式
10
+    const DISTRIBUTION_MODE = [
11
+        'ExpressDelivery' => ['code' => 1, 'name' => '快递'],
12
+        'Self-Pickup' => ['code' => 2, 'name' => '自提'],
13
+        'MerchantDelivery' => ['code' => 3, 'name' => '配送']
14
+    ];
15
+
16
+    // 订单类型
17
+    const DOHUOMALL = [
18
+        'PlatformOrder' => ['code' => 0, 'name' => '平台订单'],
19
+        'SupplyChainOrder' => ['code' => 1, 'name' => '供应链订单']
20
+    ];
21
+
22
+    // 供应链订单状态
23
+    const DOHUOMALL_STATUS = [
24
+        'Failed' => ['code' => 0, 'name' => '失败'],
25
+        'PendingPayment' => ['code' => 1, 'name' => '待付款'],
26
+        'PendingShipment' => ['code' => 2, 'name' => '待发货'],
27
+        'PendingReceipt' => ['code' => 3, 'name' => '待收货'],
28
+        'Completed' => ['code' => 4, 'name' => '已完成'],
29
+        'Cancelled' => ['code' => 5, 'name' => '已取消'],
30
+        'InAfterSale' => ['code' => 6, 'name' => '售后中'],
31
+        'AfterSaleCompleted' => ['code' => 7, 'name' => '售后完成'],
32
+        'Rejected' => ['code' => 8, 'name' => '拒收'],
33
+        'NotSubmittedToWeiweiBao' => ['code' => 9, 'name' => '还未提交到微唯保']
34
+    ];
35
+
36
+    // 组合支付类型 (考虑到这个区分 A或B 在此步骤毫无意义,划分混乱) A:会员专区 B:精彩生活区 C:复购区
37
+    const FZONE_PAY_TYPE = [
38
+        'B1-VR+Score' => ['code' => 'b1', 'name' => 'VR+积分'],
39
+        'B2-Cash+Score' => ['code' => 'b2', 'name' => '现金+积分'],
40
+        'B3-VR+Jingdou' => ['code' => 'b3', 'name' => 'VR+京豆'],
41
+        'B4-Cash+Jingdou' => ['code' => 'b4', 'name' => '现金+京豆'],
42
+        'B5-VR' => ['code' => 'b5', 'name' => 'VR'],
43
+        'B6-Cash' => ['code' => 'b6', 'name' => '现金'],
44
+        'A1-VR' => ['code' => 'a1', 'name' => 'VR'],
45
+        'A2-Cash' => ['code' => 'a2', 'name' => '现金'],
46
+        'A3-Cash+VR' => ['code' => 'a3', 'name' => '现金+VR'],
47
+        'C1-Fugou' => ['code' => 'c1', 'name' => '复购金'],
48
+    ];
49
+
50
+    // 订单状态
51
+    const STATUS = [
52
+        'WAITING_SHIPMENT' => ['code' => 0, 'name' => '待发货'],
53
+        'WAITING_RECEIVE' => ['code' => 1, 'name' => '待收货'],
54
+        'WAITING_EVALUATION' => ['code' => 2, 'name' => '待评价'],
55
+        'COMPLETED' => ['code' => 3, 'name' => '已完成'],
56
+        'REFUND_REQUESTED' => ['code' => 4, 'name' => '已申请退款'],
57
+        'REFUNDED' => ['code' => -1, 'name' => '已退款'],
58
+        'UNPAID' => ['code' => 5, 'name' => '未支付'],
59
+        'CANCELLED' => ['code' => 6, 'name' => '已取消'],
60
+    ];
61
+
62
+    // 支付状态
63
+    const PAID_STATUS = [
64
+        'UNPAID' => ['code' => 0, 'name' => '未支付'],
65
+        'PAID' => ['code' => 1, 'name' => '已支付'],
66
+    ];
67
+
68
+    // 支付方式
69
+    const PAY_TYPE = [
70
+        'BALANCE' => ['code' => 0, 'name' => '余额支付'],
71
+        'WECHAT' => ['code' => 1, 'name' => '微信支付'],
72
+        'MINI_PROGRAM' => ['code' => 2, 'name' => '小程序支付'],
73
+        'ALIPAY' => ['code' => 4, 'name' => '支付宝支付'],
74
+        'SPECIAL_MERCHANT_POINTS' => ['code' => 5, 'name' => '特殊商户积分'],
75
+    ];
76
+
77
+    // 订单类型
78
+    const ORDER_TYPE = [
79
+        'ORDINARY' => ['code' => 0, 'name' => '普通订单'],
80
+        'PICKUP' => ['code' => 1, 'name' => '自提订单'],
81
+    ];
82
+
83
+    // 发货类型
84
+    const DELIVERY_TYPE = [
85
+        'DELIVERY' => ['code' => 1, 'name' => '发货'],
86
+        'DELIVERY_PERSON' => ['code' => 2, 'name' => '送货'],
87
+        'VIRTUAL' => ['code' => 3, 'name' => '虚拟商品'],
88
+    ];
89
+
90
+    // 是否分账
91
+    const IS_INDEPENDENT_ACCOUNT = [
92
+        'NO' => ['code' => 0, 'name' => '否'],
93
+        'YES' => ['code' => 1, 'name' => '是'],
94
+    ];
95
+
96
+    // 退款状态
97
+    const REFUND_STATUS = [
98
+        'WAITING_REVIEW' => ['code' => 0, 'name' => '待审核'],
99
+        'REVIEW_FAILED' => ['code' => -1, 'name' => '审核未通过'],
100
+        'WAITING_RETURN' => ['code' => 1, 'name' => '待退货'],
101
+        'WAITING_RECEIVE' => ['code' => 2, 'name' => '待收货'],
102
+        'REFUNDED' => ['code' => 3, 'name' => '已退款'],
103
+    ];
104
+
105
+    // 支付状态
106
+    const PAID = [
107
+        'NO' => ['code' => 0, 'name' => '未支付'],
108
+        'YES' => ['code' => 1, 'name' => '已支付'],
109
+    ];
110
+
111
+    // 是否已结算 is_settlement
112
+    const IS_SETTLEMENT = [
113
+        'NO' => ['code' => 0, 'name' => '未结算'],
114
+        'YES' => ['code' => 1, 'name' => '已结算'],
115
+    ];
116
+}

+ 68 - 0
app/common/enum/user/UserBillEnum.php

@@ -0,0 +1,68 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserBillEnum extends CommonEnum
8
+{
9
+    // 收支类型
10
+    const PM = [
11
+        'EXPEND' => ['code' => 0, 'name' => '支出'],
12
+        'INCOME' => ['code' => 1, 'name' => '获得'],
13
+    ];
14
+
15
+    // 明细种类
16
+    const CATEGORY = [
17
+        'NowMoney' => ['code' => 'now_money', 'name' => 'now_money']
18
+    ];
19
+
20
+    // 明细类型  commission佣金
21
+    const TYPE = [
22
+        'Commission' => ['code' => 'commission', 'name' => '佣金']
23
+    ];
24
+
25
+    // 状态
26
+    const STATUS = [
27
+        'PENDING' => ['code' => 0, 'name' => '待确定'],
28
+        'VALID' => ['code' => 1, 'name' => '有效'],
29
+        'INVALID' => ['code' => -1, 'name' => '无效'],
30
+    ];
31
+
32
+    // 佣金类型
33
+    const COMMISSION_TYPE = parent::COMMISSION_TYPE;
34
+
35
+    // 账单来源
36
+    const SOURCE = [
37
+        'ONLINE' => ['code' => 0, 'name' => '线上'],
38
+        'OFFLINE' => ['code' => 1, 'name' => '线下'],
39
+    ];
40
+
41
+    // 订单类型
42
+    const ORDER_TYPE = [
43
+        'SELF_OPERATED' => ['code' => 1, 'name' => '自营'],
44
+        'THIRD_PARTY' => ['code' => 2, 'name' => '第三方'],
45
+    ];
46
+
47
+    // 红积分佣金类型
48
+    const IS_RED_BROKERAGE = [
49
+        'NORMAL' => ['code' => 0, 'name' => '正常佣金'],
50
+        'RED' => ['code' => 1, 'name' => '红积分对冲佣金'],
51
+    ];
52
+
53
+    // 公证处状态
54
+    const GZC_STATUS = [
55
+        'NOT_ENTERED' => ['code' => 0, 'name' => '未进入'],
56
+        'ENTERED' => ['code' => 1, 'name' => '已进入'],
57
+    ];
58
+
59
+    // 是否成功发起
60
+    const IS_GZC = [
61
+        'NOT_STARTED' => ['code' => 0, 'name' => '未发起'],
62
+        'STARTED' => ['code' => 1, 'name' => '已发起'],
63
+        'SUCCESS' => ['code' => 2, 'name' => '已成功'],
64
+    ];
65
+
66
+    // 类型商店
67
+    const TYPE_SHOP = parent::ORDER_TYPE;
68
+}

+ 15 - 0
app/common/enum/user/UserCertificationEnum.php

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserCertificationEnum extends CommonEnum
8
+{
9
+    // 用户认证状态枚举
10
+    const STATUS = [
11
+        'Pending' => ['code' => 0, 'name' => '未审核'],
12
+        'Approved' => ['code' => 1, 'name' => '已通过'],
13
+        'Rejected' => ['code' => 2, 'name' => '已拒绝'],
14
+    ];
15
+}

+ 15 - 0
app/common/enum/user/UserEnum.php

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserEnum extends CommonEnum
8
+{
9
+    const IS_DEL = parent::IS_DEL;
10
+
11
+    const STATUS = [
12
+        'Disabled' => ['code' => 0, 'name' => '禁用'],
13
+        'Normal' => ['code' => 1, 'name' => '正常']
14
+    ];
15
+}

+ 17 - 0
app/common/enum/user/UserPvLogEnum.php

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserPvLogEnum extends CommonEnum
8
+{
9
+    // 1-有效,0-失效,-1-待确认
10
+    const STATUS = [
11
+        'Valid' => ['code' => 1, 'name' => '有效'],
12
+        'Invalid' => ['code' => 0, 'name' => '失效'],
13
+        'PendingConfirmation' => ['code' => -1, 'name' => '待确认'],
14
+    ];
15
+
16
+    const ORDER_TYPE = parent::ORDER_TYPE;
17
+}

+ 18 - 0
app/common/enum/user/UserSignFenrunEnum.php

@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserSignFenrunEnum extends CommonEnum
8
+{
9
+    // 状态枚举
10
+    const STATUS = [
11
+        'Settled' => ['code' => 1, 'name' => '已结算'],
12
+        'Invalid' => ['code' => 0, 'name' => '已失效'],
13
+        'Unsettled' => ['code' => -1, 'name' => '未结算'],
14
+    ];
15
+
16
+    // 订单类型枚举
17
+    const ORDER_TYPE = parent::ORDER_TYPE;
18
+}

+ 26 - 0
app/common/enum/user/UserSignFugouEnum.php

@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserSignFugouEnum extends CommonEnum
8
+{
9
+    // 1-有效 0-失效 -1待确认
10
+    const STATUS = [
11
+        'Valid' => ['code' => 1, 'name' => '有效'],
12
+        'Invalid' => ['code' => 0, 'name' => '失效'],
13
+        'Pending' => ['code' => -1, 'name' => '待确认'],
14
+    ];
15
+
16
+    // 1代理费 2 消费佣金 3直推奖 4辖区佣金 5养老金 6广告费 7锁客收益 8平台奖励 9渠道商 10推广店铺收益 11合伙人分红 12联创分红 13股权分红
17
+    const COMMISSION_TYPE = parent::COMMISSION_TYPE;
18
+
19
+    // 1赠送,2消耗
20
+    const TYPE = [
21
+        'Give' => ['code' => 1, 'name' => '赠送'],
22
+        'Consume' => ['code' => 2, 'name' => '消耗'],
23
+    ];
24
+
25
+    const ORDER_TYPE = parent::ORDER_TYPE;
26
+}

+ 24 - 0
app/common/enum/user/UserSignGongxianEnum.php

@@ -0,0 +1,24 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserSignGongxianEnum extends CommonEnum
8
+{
9
+    // 贡献值状态
10
+    const STATUS = [
11
+        'Valid' => ['code' => 1, 'name' => '有效'],
12
+        'Invalid' => ['code' => 0, 'name' => '失效'],
13
+        'PendingConfirmation' => ['code' => -1, 'name' => '待确认'],
14
+    ];
15
+
16
+    // 贡献值类型
17
+    const TYPE = [
18
+        'Give' => ['code' => 1, 'name' => '赠送'],
19
+        'Consume' => ['code' => 2, 'name' => '消耗'],
20
+    ];
21
+
22
+    // 订单类型(可以根据实际需求扩展订单类型)
23
+    const ORDER_TYPE = parent::ORDER_TYPE;
24
+}

+ 24 - 0
app/common/enum/user/UserSignHongbaoEnum.php

@@ -0,0 +1,24 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserSignHongbaoEnum extends CommonEnum
8
+{
9
+    // 1-有效,0-失效,-1-待确认
10
+    const STATUS = [
11
+        'Valid' => ['code' => 1, 'name' => '有效'],
12
+        'Invalid' => ['code' => 0, 'name' => '失效'],
13
+        'PendingConfirmation' => ['code' => -1, 'name' => '待确认'],
14
+    ];
15
+
16
+    // 1-消费赠送,2-消耗
17
+    const TYPE = [
18
+        'ConsumptionGift' => ['code' => 1, 'name' => '消费赠送'],
19
+        'Consumption' => ['code' => 2, 'name' => '消耗'],
20
+    ];
21
+
22
+    // 订单类型(可以根据实际需求扩展订单类型)
23
+    const ORDER_TYPE = parent::ORDER_TYPE;
24
+}

+ 23 - 0
app/common/enum/user/UserSignJingdouEnum.php

@@ -0,0 +1,23 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserSignJingdouEnum extends CommonEnum
8
+{
9
+    // 京豆状态
10
+    const STATUS = [
11
+        'Valid' => ['code' => 1, 'name' => '有效'],
12
+        'Invalid' => ['code' => 0, 'name' => '失效'],
13
+        'PendingConfirmation' => ['code' => -1, 'name' => '待确认'],
14
+    ];
15
+
16
+    // 京豆类型
17
+    const TYPE = [
18
+        'Gift' => ['code' => 1, 'name' => '赠送'],
19
+        'Consume' => ['code' => 2, 'name' => '消耗'],
20
+    ];
21
+
22
+    const ORDER_TYPE = parent::ORDER_TYPE;
23
+}

+ 32 - 0
app/common/enum/user/UserSignScoreEnum.php

@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserSignScoreEnum extends CommonEnum
8
+{
9
+    // 1-收入,2-支出
10
+    const PM = [
11
+        'Income' => ['code' => 1, 'name' => '收入'],
12
+        'Expend' => ['code' => 2, 'name' => '支出'],
13
+    ];
14
+
15
+    // 积分状态:1-有效,0-失效,-1-待确认
16
+    const STATUS = [
17
+        'Valid' => ['code' => 1, 'name' => '有效'],
18
+        'Invalid' => ['code' => 0, 'name' => '失效'],
19
+        'Pending' => ['code' => -1, 'name' => '待确认'],
20
+    ];
21
+
22
+    // 积分来源类型:1-签到,2-分享好友注册赠送,3-自己下单赠送,4-好友下单赠送,5-购买产品消耗
23
+    const SOURCE_TYPE = [
24
+        'SignIn' => ['code' => 1, 'name' => '签到'],
25
+        'ShareRegister' => ['code' => 2, 'name' => '分享好友注册赠送'],
26
+        'SelfOrder' => ['code' => 3, 'name' => '自己下单赠送'],
27
+        'FriendOrder' => ['code' => 4, 'name' => '好友下单赠送'],
28
+        'BuyProduct' => ['code' => 5, 'name' => '购买产品消耗'],
29
+    ];
30
+
31
+    const ORDER_TYPE = parent::ORDER_TYPE;
32
+}

+ 16 - 0
app/common/enum/user/UserSignVrEnum.php

@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class UserSignVrEnum extends CommonEnum
8
+{
9
+    // 1-兑换,2-消耗
10
+    const TYPE = [
11
+        'Exchange' => ['code' => 1, 'name' => '兑换'],
12
+        'Consume' => ['code' => 2, 'name' => '消耗'],
13
+    ];
14
+
15
+    const ORDER_TYPE = parent::ORDER_TYPE;
16
+}

+ 31 - 0
app/common/enum/user/ZeroUserEnum.php

@@ -0,0 +1,31 @@
1
+<?php
2
+
3
+namespace app\common\enum\user;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class ZeroUserEnum extends CommonEnum
8
+{
9
+    // 状态
10
+    const STATUS = [
11
+        0 => '失效',
12
+        1 => '正常',
13
+        2 => '合并',
14
+    ];
15
+    const STATUS_MAP = [
16
+        'FAILURE' => ['code' => 0, 'name' => '失效'],
17
+        'NORMAL' => ['code' => 1, 'name' => '正常'],
18
+        'MERGE' => ['code' => 2, 'name' => '合并'],
19
+    ];
20
+
21
+
22
+    // 是否带走团队
23
+    const IS_REMOVE = [
24
+        0 => '保留',
25
+        1 => '带走'
26
+    ];
27
+    const IS_REMOVE_MAP = [
28
+        'NO' => ['code' => 0, 'name' => '保留'],
29
+        'YES' => ['code' => 1, 'name' => '带走'],
30
+    ];
31
+}

+ 18 - 0
app/common/model/Region.php

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

+ 27 - 0
app/common/model/gzc/GzcLog.php

@@ -0,0 +1,27 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020/5/30
7
+ *
8
+ *
9
+ */
10
+
11
+namespace app\common\model\gzc;
12
+
13
+use app\common\model\BaseModel;
14
+
15
+class GzcLog extends BaseModel
16
+{
17
+
18
+    public static function tablePk(): string
19
+    {
20
+        return 'id';
21
+    }
22
+
23
+    public static function tableName(): string
24
+    {
25
+        return 'gzc_logs';
26
+    }
27
+}

+ 19 - 0
app/common/model/product/ProductSeckillModel.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\product;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class ProductSeckillModel 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 'product_seckill';
18
+    }
19
+}

+ 19 - 0
app/common/model/product/ShareModel.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\product;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class ShareModel 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 'product_share';
18
+    }
19
+}

+ 3 - 1
app/common/model/store/shipping/ShippingTemplateFree.php

@@ -8,6 +8,7 @@
8
 namespace app\common\model\store\shipping;
8
 namespace app\common\model\store\shipping;
9
 
9
 
10
 use app\common\model\BaseModel;
10
 use app\common\model\BaseModel;
11
+use app\common\model\Region;
11
 
12
 
12
 class ShippingTemplateFree extends BaseModel
13
 class ShippingTemplateFree extends BaseModel
13
 {
14
 {
@@ -41,7 +42,8 @@ class ShippingTemplateFree extends BaseModel
41
         $result = [];
42
         $result = [];
42
         if(is_array($city_id)){
43
         if(is_array($city_id)){
43
             foreach ($city_id as $v){
44
             foreach ($city_id as $v){
44
-                $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
45
+                // $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
46
+                $result[] = [Region::where('id',$v)->value('pid') ?? 0,intval($v) ];
45
             }
47
             }
46
         }
48
         }
47
         return $result;
49
         return $result;

+ 3 - 1
app/common/model/store/shipping/ShippingTemplateRegion.php

@@ -8,6 +8,7 @@
8
 namespace app\common\model\store\shipping;
8
 namespace app\common\model\store\shipping;
9
 
9
 
10
 use app\common\model\BaseModel;
10
 use app\common\model\BaseModel;
11
+use app\common\model\Region;
11
 
12
 
12
 class ShippingTemplateRegion extends BaseModel
13
 class ShippingTemplateRegion extends BaseModel
13
 {
14
 {
@@ -40,7 +41,8 @@ class ShippingTemplateRegion extends BaseModel
40
         $result = [];
41
         $result = [];
41
         if(is_array($city_id)){
42
         if(is_array($city_id)){
42
             foreach ($city_id as $v){
43
             foreach ($city_id as $v){
43
-                $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
44
+                // $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
45
+                $result[] = [Region::where('id',$v)->value('pid') ?? 0,intval($v) ];
44
             }
46
             }
45
         }
47
         }
46
         return $result;
48
         return $result;

+ 3 - 1
app/common/model/store/shipping/ShippingTemplateUndelivery.php

@@ -8,6 +8,7 @@
8
 namespace app\common\model\store\shipping;
8
 namespace app\common\model\store\shipping;
9
 
9
 
10
 use app\common\model\BaseModel;
10
 use app\common\model\BaseModel;
11
+use app\common\model\Region;
11
 
12
 
12
 class ShippingTemplateUndelivery extends BaseModel
13
 class ShippingTemplateUndelivery extends BaseModel
13
 {
14
 {
@@ -40,7 +41,8 @@ class ShippingTemplateUndelivery extends BaseModel
40
         $result = [];
41
         $result = [];
41
         if(is_array($city_id)){
42
         if(is_array($city_id)){
42
             foreach ($city_id as $v){
43
             foreach ($city_id as $v){
43
-                $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
44
+                // $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
45
+                $result[] = [Region::where('id',$v)->value('pid') ?? 0,intval($v) ];
44
             }
46
             }
45
         }else{
47
         }else{
46
             $result['city_id'] = [];
48
             $result['city_id'] = [];

+ 128 - 0
app/common/model/system/ApiRequestLog.php

@@ -0,0 +1,128 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2025-09-15
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\common\model\system;
12
+
13
+use app\common\model\BaseModel;
14
+
15
+class ApiRequestLog extends BaseModel
16
+{
17
+
18
+    /**
19
+     * @return string
20
+     * @author xaboy
21
+     * @day 2025-09-15
22
+     */
23
+    public static function tablePk(): string
24
+    {
25
+        return 'log_id';
26
+    }
27
+
28
+    /**
29
+     * @return string
30
+     * @author xaboy
31
+     * @day 2025-09-15
32
+     */
33
+    public static function tableName(): string
34
+    {
35
+        return 'api_request_log';
36
+    }
37
+
38
+    /**
39
+     * 记录接口请求日志
40
+     * @param array $data
41
+     * @return bool
42
+     */
43
+    public static function record(array $data): bool
44
+    {
45
+        try {
46
+            $logData = [
47
+                'request_id' => $data['request_id'] ?? self::generateRequestId(),
48
+                'app_type' => $data['app_type'] ?? '',
49
+                'request_method' => $data['request_method'] ?? '',
50
+                'request_url' => $data['request_url'] ?? '',
51
+                'request_params' => isset($data['request_params']) ? json_encode($data['request_params'], JSON_UNESCAPED_UNICODE) : null,
52
+                'request_headers' => isset($data['request_headers']) ? json_encode($data['request_headers'], JSON_UNESCAPED_UNICODE) : null,
53
+                'request_ip' => $data['request_ip'] ?? '',
54
+                'user_agent' => $data['user_agent'] ?? '',
55
+                'user_id' => $data['user_id'] ?? 0,
56
+                'merchant_id' => $data['merchant_id'] ?? 0,
57
+                'admin_id' => $data['admin_id'] ?? 0,
58
+                'response_code' => $data['response_code'] ?? 0,
59
+                'response_data' => isset($data['response_data']) ? json_encode($data['response_data'], JSON_UNESCAPED_UNICODE) : null,
60
+                'response_time' => $data['response_time'] ?? 0,
61
+                'error_message' => $data['error_message'] ?? '',
62
+            ];
63
+
64
+            return self::create($logData) !== false;
65
+        } catch (\Exception $e) {
66
+            // 记录日志失败时不中断主流程
67
+            return false;
68
+        }
69
+    }
70
+
71
+    /**
72
+     * 生成请求唯一标识
73
+     * @return string
74
+     */
75
+    private static function generateRequestId(): string
76
+    {
77
+        return md5(uniqid('api_request_', true) . mt_rand(1000, 9999));
78
+    }
79
+
80
+    /**
81
+     * 根据请求ID查找日志
82
+     * @param string $requestId
83
+     * @return array|null
84
+     */
85
+    public static function findByRequestId(string $requestId): ?array
86
+    {
87
+        $log = self::getDB()->where('request_id', $requestId)->find();
88
+        return $log ? $log->toArray() : null;
89
+    }
90
+
91
+    /**
92
+     * 获取指定时间范围内的日志列表
93
+     * @param string $startTime
94
+     * @param string $endTime
95
+     * @param int $page
96
+     * @param int $limit
97
+     * @return array
98
+     */
99
+    public static function getListByTimeRange(string $startTime, string $endTime, int $page = 1, int $limit = 20): array
100
+    {
101
+        $query = self::getDB()
102
+            ->where('create_time', '>=', $startTime)
103
+            ->where('create_time', '<=', $endTime)
104
+            ->order('log_id', 'desc');
105
+
106
+        $total = $query->count();
107
+        $list = $query->page($page, $limit)->select()->toArray();
108
+
109
+        return [
110
+            'list' => $list,
111
+            'total' => $total,
112
+            'page' => $page,
113
+            'limit' => $limit,
114
+            'total_page' => ceil($total / $limit)
115
+        ];
116
+    }
117
+
118
+    /**
119
+     * 清理过期日志
120
+     * @param int $days 保留天数
121
+     * @return int
122
+     */
123
+    public static function clearExpiredLogs(int $days = 30): int
124
+    {
125
+        $expireTime = date('Y-m-d H:i:s', strtotime("-$days days"));
126
+        return self::getDB()->where('create_time', '<', $expireTime)->delete();
127
+    }
128
+}

+ 20 - 0
app/common/model/system/merchant/MerchantContribution.php

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

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

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserPvLog 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_pv_log';
18
+    }
19
+}

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

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserSignFenrun 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_fenrun';
18
+    }
19
+}

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

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserSignFugou 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_fugou';
18
+    }
19
+}

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

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserSignGongxian 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_gongxian';
18
+    }
19
+}

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

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserSignHongbao 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_hongbao';
18
+    }
19
+}

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

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserSignJingdou 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_jingdou';
18
+    }
19
+}

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

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserSignScore 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_score';
18
+    }
19
+}

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

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserSignVr 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_vr';
18
+    }
19
+}

+ 28 - 0
app/common/model/user/ZeroUserLine.php

@@ -0,0 +1,28 @@
1
+<?php
2
+/**
3
+ * user_zero_line
4
+ */
5
+namespace app\common\model\user;
6
+
7
+
8
+use app\common\model\BaseModel;
9
+
10
+class ZeroUserLine extends BaseModel
11
+{
12
+
13
+    /**
14
+     * @return string
15
+     */
16
+    public static function tablePk(): string
17
+    {
18
+        return 'id';
19
+    }
20
+
21
+    /**
22
+     * @return string
23
+     */
24
+    public static function tableName(): string
25
+    {
26
+        return 'user_zero_line';
27
+    }
28
+}

+ 20 - 24
app/common/repositories/finance/FinanceRepository.php

@@ -1953,7 +1953,6 @@ class FinanceRepository extends BaseRepository
1953
         $query = Db::name('user_pv_log')
1953
         $query = Db::name('user_pv_log')
1954
         ->alias('uss')
1954
         ->alias('uss')
1955
         ->leftJoin('user u', 'u.uid=uss.uid')
1955
         ->leftJoin('user u', 'u.uid=uss.uid')
1956
-        ->leftJoin('store_order o', 'o.order_id=uss.order_id')
1957
         ->when(isset($params['uid']) && $params['uid'] != '', function ($query) use ($params) {
1956
         ->when(isset($params['uid']) && $params['uid'] != '', function ($query) use ($params) {
1958
             $query->where('uss.uid', $params['uid']);
1957
             $query->where('uss.uid', $params['uid']);
1959
         })
1958
         })
@@ -1976,49 +1975,46 @@ class FinanceRepository extends BaseRepository
1976
 
1975
 
1977
         //导出数据
1976
         //导出数据
1978
         $is_excel = request()->param('is_excel', 0);
1977
         $is_excel = request()->param('is_excel', 0);
1979
-        if($is_excel == 1){
1978
+        if ($is_excel == 1) {
1980
             $date['list'] = $this->date_where($query, $where['date'], 'uss.addtime', '-', 2)
1979
             $date['list'] = $this->date_where($query, $where['date'], 'uss.addtime', '-', 2)
1981
-            ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.pv,o.order_sn,uss.status,uss.mark,u.score')
1982
-            ->order('uss.id', 'desc')
1983
-            ->select();
1980
+                ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.pv,uss.order_id,uss.status,uss.mark')
1981
+                ->order('uss.id', 'desc')
1982
+                ->select();
1984
             $arr = [];
1983
             $arr = [];
1985
-            foreach ($date['list'] as $k=>$item){
1984
+            foreach ($date['list'] as $k => $item) {
1986
                 switch ($item['status']) {
1985
                 switch ($item['status']) {
1987
-                    case '1':
1988
-                        $item['status'] = '有效';
1989
-                        break;
1990
-                    case '-1':
1991
-                        $item['status'] = '待确认';
1992
-                        break;
1993
-                    case '0':
1994
-                        $item['status'] = '已失效';
1995
-                        break;
1986
+                    case '1': $statusLabel = '有效'; break;
1987
+                    case '-1': $statusLabel = '待确认'; break;
1988
+                    case '0': $statusLabel = '已失效'; break;
1989
+                    default: $statusLabel = (string)$item['status'];
1996
                 }
1990
                 }
1997
-                $arr[] = array(
1991
+                $addtimeFormatted = is_numeric($item['addtime']) ? date('Y-m-d H:i:s', $item['addtime']) : $item['addtime'];
1992
+                $arr[] = [
1998
                     $item['id'],
1993
                     $item['id'],
1999
-                    date('Y-m-d H:i:s', $item['addtime']),
1994
+                    $addtimeFormatted,
2000
                     $item['nickname'],
1995
                     $item['nickname'],
2001
                     $item['phone'],
1996
                     $item['phone'],
2002
                     $item['pv'],
1997
                     $item['pv'],
2003
-                    $item['status'],
2004
-                    $item['order_sn'],
1998
+                    $statusLabel,
1999
+                    $item['order_id'],
2005
                     $item['mark']
2000
                     $item['mark']
2006
-                );
2001
+                ];
2007
             }
2002
             }
2008
             return $this->getStatisticsExcel([
2003
             return $this->getStatisticsExcel([
2009
-                'ID','时间','用户昵称','手机号','PV数','状态','关联订单','说名',
2004
+                'ID', '时间', '用户昵称', '手机号', 'PV数', '状态', '关联订单号', '说明',
2010
             ], $arr, 'PV统计');
2005
             ], $arr, 'PV统计');
2011
         }
2006
         }
2012
 
2007
 
2013
 
2008
 
2009
+
2014
         $date['list'] = $this->date_where($query, $where['date'], 'uss.addtime', '-', 2)
2010
         $date['list'] = $this->date_where($query, $where['date'], 'uss.addtime', '-', 2)
2015
-            ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.pv,o.order_sn,uss.status,uss.mark,u.score')
2011
+            ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.pv,uss.order_id,uss.status,uss.mark,u.score')
2016
             ->page($page, $limit)
2012
             ->page($page, $limit)
2017
             ->order('uss.id', 'desc')
2013
             ->order('uss.id', 'desc')
2018
             ->select()
2014
             ->select()
2019
             ->each(function ($item) {
2015
             ->each(function ($item) {
2020
-                $item['mark'] = $item['mark'];
2021
-                $item['addtime'] = date('Y-m-d H:i:s', $item['addtime']);
2016
+                $item['addtime'] = is_numeric($item['addtime']) ? date('Y-m-d H:i:s', $item['addtime']) : $item['addtime'];
2017
+                $item['order_sn'] = $item['order_id'];
2022
                 return $item;
2018
                 return $item;
2023
             });
2019
             });
2024
         $date['count'] = $query->count();
2020
         $date['count'] = $query->count();

+ 88 - 0
app/common/repositories/gzc/GzcLogRepository.php

@@ -0,0 +1,88 @@
1
+<?php
2
+
3
+namespace app\common\repositories\gzc;
4
+
5
+use app\common\dao\gzc\GzcLogDao;
6
+use app\common\enum\CommonEnum;
7
+use app\common\repositories\BaseRepository;
8
+use app\common\repositories\store\order\StoreOrderRepository;
9
+use app\entity\data\gzc\GzcLogEntity;
10
+use think\exception\ValidateException;
11
+
12
+class GzcLogRepository extends BaseRepository
13
+{
14
+    public function __construct(GzcLogDao $dao)
15
+    {
16
+        $this->dao = $dao;
17
+    }
18
+
19
+    public function create($data)
20
+    {
21
+        return $this->dao->create($data);
22
+    }
23
+
24
+    /**
25
+     * @param GzcLogEntity $gzcLogEntity
26
+     * @return GzcLogEntity
27
+     */
28
+    public function createByEntity(GzcLogEntity $gzcLogEntity): GzcLogEntity
29
+    {
30
+        $result = $this->create($gzcLogEntity->toUnderlineArray())->toArray();
31
+        /** @var GzcLogEntity $entity */
32
+        $entity = GzcLogEntity::newInstance($result);
33
+        return $entity;
34
+    }
35
+
36
+    /**
37
+     * 添加 公证处记录
38
+     * @param int $uid
39
+     * @param string $userName
40
+     * @param string $mobile
41
+     * @param string $userCard
42
+     * @param int $orderType
43
+     * @param string $orderId
44
+     * @param float $pension
45
+     * @param int $payType
46
+     * @return GzcLogEntity
47
+     */
48
+    public function addGzcLog(int $uid, string $userName, string $mobile, string $userCard, int $orderType, string $orderId, float $pension, int $payType = 0): GzcLogEntity
49
+    {
50
+        $linkId = 0;
51
+        $orderSn = '';
52
+        $payTime = '';
53
+        if ($orderType == CommonEnum::ORDER_TYPE['Platform']['code']) {
54
+            /** @var StoreOrderRepository $storeOrderRepository */
55
+            $storeOrderRepository = app()->make(StoreOrderRepository::class);
56
+            $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId((int)$orderId);
57
+            if (empty($storeOrderEntity->getOrderId())) {
58
+                throw new ValidateException('未查询到订单信息');
59
+            }
60
+            $orderSn = $storeOrderEntity->getOrderSn();
61
+            $payTime = $storeOrderEntity->getPayTime();
62
+            $payType = 3;// 默认是微信
63
+            if ($storeOrderEntity->getFzonePayNote() != "现金") {
64
+                $payType = 4;
65
+            }
66
+        }
67
+
68
+        $createTime = date('Y-m-d H:i:s');
69
+        /** @var GzcLogEntity $gzcLogEntity */
70
+        $gzcLogEntity = GzcLogEntity::newInstance();
71
+        $gzcLogEntity->setUid($uid)
72
+            ->setPlatformNo('IN10' . (int)(microtime(true) * 1000) . mt_rand(10000, 99999))
73
+            ->setUserName($userName)
74
+            ->setMobile($mobile)
75
+            ->setUserCard($userCard)
76
+            ->setPension($pension)
77
+            ->setOutTradeNo($orderSn)
78
+            ->setAccountType($payType)
79
+            ->setOrderType($orderType)
80
+            ->setPayTime($payTime)
81
+            ->setCreateTime($createTime)
82
+            ->setUpdateTime($createTime)
83
+            ->setLinkId($orderId);
84
+
85
+        return $this->createByEntity($gzcLogEntity);
86
+    }
87
+
88
+}

+ 26 - 0
app/common/repositories/product/ProductSeckillRepository.php

@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+namespace app\common\repositories\product;
4
+
5
+use app\common\dao\product\ProductSeckillDao;
6
+use app\common\repositories\BaseRepository;
7
+use app\entity\data\product\ProductSeckillEntity;
8
+
9
+class ProductSeckillRepository extends BaseRepository
10
+{
11
+    public function __construct(ProductSeckillDao $dao)
12
+    {
13
+        $this->dao = $dao;
14
+    }
15
+
16
+    /**
17
+     * @param int $productId
18
+     * @return ProductSeckillEntity
19
+     */
20
+    public function getProductSeckillEntityByProductId(int $productId): ProductSeckillEntity
21
+    {
22
+        /** @var ProductSeckillEntity $entity */
23
+        $entity = $this->dao->getProductSeckillEntityByProductId($productId);
24
+        return $entity;
25
+    }
26
+}

+ 26 - 0
app/common/repositories/product/ShareRepository.php

@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+namespace app\common\repositories\product;
4
+
5
+use app\common\dao\product\ShareDao;
6
+use app\common\repositories\BaseRepository;
7
+use app\entity\data\product\ShareEntity;
8
+
9
+class ShareRepository extends BaseRepository
10
+{
11
+    public function __construct(ShareDao $dao)
12
+    {
13
+        $this->dao = $dao;
14
+    }
15
+
16
+    /**
17
+     * @param int $shareId
18
+     * @return ShareEntity
19
+     */
20
+    public function getShareEntityByShareId(int $shareId): ShareEntity
21
+    {
22
+        /** @var ShareEntity $shareEntity */
23
+        $shareEntity = $this->dao->getShareEntityByShareId($shareId);
24
+        return $shareEntity;
25
+    }
26
+}

+ 13 - 2
app/common/repositories/store/StoreSeckillActiveRepository.php

@@ -11,8 +11,7 @@ namespace app\common\repositories\store;
11
 
11
 
12
 use app\common\dao\store\StoreSeckillActiveDao;
12
 use app\common\dao\store\StoreSeckillActiveDao;
13
 use app\common\repositories\BaseRepository;
13
 use app\common\repositories\BaseRepository;
14
-use FormBuilder\Factory\Elm;
15
-use think\facade\Route;
14
+use app\entity\data\store\SeckillActiveEntity;
16
 
15
 
17
 class StoreSeckillActiveRepository extends BaseRepository
16
 class StoreSeckillActiveRepository extends BaseRepository
18
 {
17
 {
@@ -30,4 +29,16 @@ class StoreSeckillActiveRepository extends BaseRepository
30
     {
29
     {
31
         $this->dao = $dao;
30
         $this->dao = $dao;
32
     }
31
     }
32
+
33
+    /**
34
+     * 根据 商品ID 获取当前生效的 活动记录
35
+     * @param int $productId
36
+     * @return SeckillActiveEntity
37
+     */
38
+    public function getSeckillActiveEntityByProductIdInActive(int $productId): SeckillActiveEntity
39
+    {
40
+        /** @var SeckillActiveEntity $seckillActiveEntity */
41
+        $seckillActiveEntity = $this->dao->getSeckillActiveEntityByProductIdInActive($productId);
42
+        return $seckillActiveEntity;
43
+    }
33
 }
44
 }

+ 10 - 0
app/common/repositories/store/coupon/StoreCouponProductRepository.php

@@ -13,6 +13,7 @@ namespace app\common\repositories\store\coupon;
13
 
13
 
14
 use app\common\dao\store\coupon\StoreCouponProductDao;
14
 use app\common\dao\store\coupon\StoreCouponProductDao;
15
 use app\common\repositories\BaseRepository;
15
 use app\common\repositories\BaseRepository;
16
+use app\entity\data\store\StoreCouponProductEntity;
16
 
17
 
17
 /**
18
 /**
18
  * Class StoreCouponProductRepository
19
  * Class StoreCouponProductRepository
@@ -32,4 +33,13 @@ class StoreCouponProductRepository extends BaseRepository
32
     {
33
     {
33
         $this->dao = $dao;
34
         $this->dao = $dao;
34
     }
35
     }
36
+
37
+    /**
38
+     * @param int $couponId
39
+     * @return StoreCouponProductEntity[]
40
+     */
41
+    public function getStoreCouponProductEntityListByCouponId(int $couponId): array
42
+    {
43
+        return $this->dao->getStoreCouponProductEntityListByCouponId($couponId);
44
+    }
35
 }
45
 }

+ 10 - 0
app/common/repositories/store/coupon/StoreCouponUserRepository.php

@@ -14,6 +14,7 @@ namespace app\common\repositories\store\coupon;
14
 use app\common\dao\store\coupon\StoreCouponUserDao;
14
 use app\common\dao\store\coupon\StoreCouponUserDao;
15
 use app\common\model\store\coupon\StoreCoupon;
15
 use app\common\model\store\coupon\StoreCoupon;
16
 use app\common\repositories\BaseRepository;
16
 use app\common\repositories\BaseRepository;
17
+use app\entity\data\store\StoreCouponUserEntity;
17
 use think\facade\Db;
18
 use think\facade\Db;
18
 use think\db\exception\DataNotFoundException;
19
 use think\db\exception\DataNotFoundException;
19
 use think\db\exception\DbException;
20
 use think\db\exception\DbException;
@@ -151,4 +152,13 @@ class StoreCouponUserRepository extends BaseRepository
151
         return compact('count', 'list',"query");
152
         return compact('count', 'list',"query");
152
     }
153
     }
153
 
154
 
155
+    /**
156
+     * @param int $merId
157
+     * @param int $uid
158
+     * @return StoreCouponUserEntity[]
159
+     */
160
+    public function getValidStoreCouponUserEntityListByMerIdAndUid(int $merId, int $uid): array
161
+    {
162
+        return $this->dao->getValidStoreCouponUserEntityListByMerIdAndUid($merId, $uid);
163
+    }
154
 }
164
 }

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

@@ -12,10 +12,13 @@ namespace app\common\repositories\store\order;
12
 
12
 
13
 
13
 
14
 use app\common\dao\store\order\StoreCartDao;
14
 use app\common\dao\store\order\StoreCartDao;
15
+use app\common\enum\store\CartEnum;
15
 use app\common\repositories\BaseRepository;
16
 use app\common\repositories\BaseRepository;
16
 use app\common\repositories\store\coupon\StoreCouponProductRepository;
17
 use app\common\repositories\store\coupon\StoreCouponProductRepository;
17
 use app\common\repositories\store\coupon\StoreCouponRepository;
18
 use app\common\repositories\store\coupon\StoreCouponRepository;
18
 use app\common\repositories\store\product\ProductRepository;
19
 use app\common\repositories\store\product\ProductRepository;
20
+use app\entity\data\store\CartEntity;
21
+use think\db\exception\DbException;
19
 use think\facade\Db;
22
 use think\facade\Db;
20
 
23
 
21
 /**
24
 /**
@@ -120,4 +123,37 @@ class StoreCartRepository extends BaseRepository
120
         ];
123
         ];
121
         return $this->dao->getWhereCount($where);
124
         return $this->dao->getWhereCount($where);
122
     }
125
     }
126
+
127
+    /**
128
+     * 根据 购物车 ID 获取购物车实体
129
+     * @param int $cartId
130
+     * @return CartEntity
131
+     */
132
+    public function getCartEntityByCartId(int $cartId): CartEntity
133
+    {
134
+        /** @var CartEntity $cartEntity */
135
+        $cartEntity = $this->dao->getCartEntityByCartId($cartId);
136
+        return $cartEntity;
137
+    }
138
+
139
+    /**
140
+     * 根据 购物车 ID 获取购物车实体
141
+     * @param array $cartIdList
142
+     * @return CartEntity[]
143
+     */
144
+    public function getCartEntityListByCartIdList(array $cartIdList): array
145
+    {
146
+        return $this->dao->getCartEntityListByCartIdList($cartIdList);
147
+    }
148
+
149
+    /**
150
+     * @param array $cartIdList
151
+     * @param int $isPay
152
+     * @return int
153
+     * @throws DbException
154
+     */
155
+    public function updateIsPayByCartIdList(array $cartIdList, int $isPay = CartEnum::IS_PAY['Yes']['code']): int
156
+    {
157
+        return $this->dao->updateIsPayByCartIdList($cartIdList, $isPay);
158
+    }
123
 }
159
 }

+ 60 - 6
app/common/repositories/store/order/StoreGroupOrderRepository.php

@@ -14,7 +14,9 @@ namespace app\common\repositories\store\order;
14
 use app\common\dao\store\order\StoreGroupOrderDao;
14
 use app\common\dao\store\order\StoreGroupOrderDao;
15
 use app\common\repositories\BaseRepository;
15
 use app\common\repositories\BaseRepository;
16
 use app\common\repositories\store\coupon\StoreCouponUserRepository;
16
 use app\common\repositories\store\coupon\StoreCouponUserRepository;
17
+use app\entity\data\store\StoreGroupOrderEntity;
17
 use crmeb\jobs\CancelGroupOrderJob;
18
 use crmeb\jobs\CancelGroupOrderJob;
19
+use think\db\exception\DbException;
18
 use think\exception\ValidateException;
20
 use think\exception\ValidateException;
19
 use think\facade\Cache;
21
 use think\facade\Cache;
20
 use think\facade\Db;
22
 use think\facade\Db;
@@ -45,7 +47,7 @@ class StoreGroupOrderRepository extends BaseRepository
45
      * @param $limit
47
      * @param $limit
46
      * @return array
48
      * @return array
47
      * @throws \think\db\exception\DataNotFoundException
49
      * @throws \think\db\exception\DataNotFoundException
48
-     * @throws \think\db\exception\DbException
50
+     * @throws DbException
49
      * @throws \think\db\exception\ModelNotFoundException
51
      * @throws \think\db\exception\ModelNotFoundException
50
      * @author xaboy
52
      * @author xaboy
51
      * @day 2020/6/10
53
      * @day 2020/6/10
@@ -67,7 +69,7 @@ class StoreGroupOrderRepository extends BaseRepository
67
      * @param $id
69
      * @param $id
68
      * @return array|\think\Model|null
70
      * @return array|\think\Model|null
69
      * @throws \think\db\exception\DataNotFoundException
71
      * @throws \think\db\exception\DataNotFoundException
70
-     * @throws \think\db\exception\DbException
72
+     * @throws DbException
71
      * @throws \think\db\exception\ModelNotFoundException
73
      * @throws \think\db\exception\ModelNotFoundException
72
      * @author xaboy
74
      * @author xaboy
73
      * @day 2020/6/10
75
      * @day 2020/6/10
@@ -87,7 +89,7 @@ class StoreGroupOrderRepository extends BaseRepository
87
      * @param $id
89
      * @param $id
88
      * @return array|\think\Model|null
90
      * @return array|\think\Model|null
89
      * @throws \think\db\exception\DataNotFoundException
91
      * @throws \think\db\exception\DataNotFoundException
90
-     * @throws \think\db\exception\DbException
92
+     * @throws DbException
91
      * @throws \think\db\exception\ModelNotFoundException
93
      * @throws \think\db\exception\ModelNotFoundException
92
      * @author xaboy
94
      * @author xaboy
93
      * @day 2020/6/10
95
      * @day 2020/6/10
@@ -114,7 +116,7 @@ class StoreGroupOrderRepository extends BaseRepository
114
      * @param $id
116
      * @param $id
115
      * @return array|\think\Model|null
117
      * @return array|\think\Model|null
116
      * @throws \think\db\exception\DataNotFoundException
118
      * @throws \think\db\exception\DataNotFoundException
117
-     * @throws \think\db\exception\DbException
119
+     * @throws DbException
118
      * @throws \think\db\exception\ModelNotFoundException
120
      * @throws \think\db\exception\ModelNotFoundException
119
      * @author xaboy
121
      * @author xaboy
120
      * @day 2020/6/10
122
      * @day 2020/6/10
@@ -128,7 +130,7 @@ class StoreGroupOrderRepository extends BaseRepository
128
      * @param $id
130
      * @param $id
129
      * @param null $uid
131
      * @param null $uid
130
      * @throws \think\db\exception\DataNotFoundException
132
      * @throws \think\db\exception\DataNotFoundException
131
-     * @throws \think\db\exception\DbException
133
+     * @throws DbException
132
      * @throws \think\db\exception\ModelNotFoundException
134
      * @throws \think\db\exception\ModelNotFoundException
133
      * @author xaboy
135
      * @author xaboy
134
      * @day 2020/6/10
136
      * @day 2020/6/10
@@ -230,7 +232,7 @@ class StoreGroupOrderRepository extends BaseRepository
230
      * @param $product_id
232
      * @param $product_id
231
      * @return array
233
      * @return array
232
      * @throws \think\db\exception\DataNotFoundException
234
      * @throws \think\db\exception\DataNotFoundException
233
-     * @throws \think\db\exception\DbException
235
+     * @throws DbException
234
      * @throws \think\db\exception\ModelNotFoundException
236
      * @throws \think\db\exception\ModelNotFoundException
235
      */
237
      */
236
     public function ProductOutCancel($product_id){
238
     public function ProductOutCancel($product_id){
@@ -251,4 +253,56 @@ class StoreGroupOrderRepository extends BaseRepository
251
         return $order;
253
         return $order;
252
     }
254
     }
253
 
255
 
256
+    /**
257
+     * @param int $orderId
258
+     * @return StoreGroupOrderEntity
259
+     */
260
+    public function getStoreGroupOrderEntityByGroupOrderId(int $orderId): StoreGroupOrderEntity
261
+    {
262
+        $entityList = $this->getStoreGroupOrderEntityListByGroupOrderIdList([$orderId]);
263
+        $entity = array_shift($entityList);
264
+        if ($entity instanceof StoreGroupOrderEntity) {
265
+            return $entity;
266
+        } else {
267
+            /** @var StoreGroupOrderEntity */
268
+            return StoreGroupOrderEntity::newInstance();
269
+        }
270
+    }
271
+
272
+    /**
273
+     * @param array $groupOrderIdList
274
+     * @return StoreGroupOrderEntity[]
275
+     */
276
+    public function getStoreGroupOrderEntityListByGroupOrderIdList(array $groupOrderIdList): array
277
+    {
278
+        return $this->dao->getStoreGroupOrderEntityListByGroupOrderIdList($groupOrderIdList);
279
+    }
280
+
281
+    public function create($data)
282
+    {
283
+        return $this->dao->create($data);
284
+    }
285
+
286
+    /**
287
+     * 写入贡献值记录
288
+     * @param StoreGroupOrderEntity $storeGroupOrderEntity
289
+     * @return StoreGroupOrderEntity
290
+     */
291
+    public function createByEntity(StoreGroupOrderEntity $storeGroupOrderEntity): StoreGroupOrderEntity
292
+    {
293
+        $result = $this->create($storeGroupOrderEntity->toUnderlineArray())->toArray();
294
+        /** @var StoreGroupOrderEntity $entity */
295
+        $entity = StoreGroupOrderEntity::newInstance($result);
296
+        return $entity;
297
+    }
298
+
299
+    /**
300
+     * @param $groupOrderId
301
+     * @return int
302
+     * @throws DbException
303
+     */
304
+    public function paySuccess($groupOrderId): int
305
+    {
306
+        return $this->dao->paySuccess($groupOrderId);
307
+    }
254
 }
308
 }

文件差異過大導致無法顯示
+ 1788 - 26
app/common/repositories/store/order/StoreOrderRepository.php


+ 26 - 0
app/common/repositories/store/product/ProductAttrValueRepository.php

@@ -8,6 +8,7 @@ namespace app\common\repositories\store\product;
8
 
8
 
9
 use app\common\repositories\BaseRepository;
9
 use app\common\repositories\BaseRepository;
10
 use app\common\dao\store\product\ProductAttrValueDao as dao;
10
 use app\common\dao\store\product\ProductAttrValueDao as dao;
11
+use app\entity\data\store\StoreProductAttrValueEntity;
11
 use app\traits\GongApiRequest;
12
 use app\traits\GongApiRequest;
12
 use think\exception\ValidateException;
13
 use think\exception\ValidateException;
13
 use crmeb\exceptions\AuthException;
14
 use crmeb\exceptions\AuthException;
@@ -159,4 +160,29 @@ class ProductAttrValueRepository extends BaseRepository
159
         }
160
         }
160
         return true;
161
         return true;
161
     }
162
     }
163
+
164
+    /**
165
+     * @param string $unique
166
+     * @return StoreProductAttrValueEntity
167
+     */
168
+    public function getStoreProductAttrValueEntityByUnique(string $unique): StoreProductAttrValueEntity
169
+    {
170
+        $entityList = $this->getStoreProductAttrValueEntityListByUniqueList([$unique]);
171
+        $entity = array_shift($entityList);
172
+        if ($entity instanceof StoreProductAttrValueEntity) {
173
+            return $entity;
174
+        } else {
175
+            /** @var StoreProductAttrValueEntity */
176
+            return StoreProductAttrValueEntity::newInstance();
177
+        }
178
+    }
179
+
180
+    /**
181
+     * @param array $uniqueList
182
+     * @return StoreProductAttrValueEntity[]
183
+     */
184
+    public function getStoreProductAttrValueEntityListByUniqueList(array $uniqueList): array
185
+    {
186
+        return $this->dao->getStoreProductAttrValueEntityListByUniqueList($uniqueList);
187
+    }
162
 }
188
 }

+ 26 - 0
app/common/repositories/store/product/ProductRepository.php

@@ -23,6 +23,7 @@ use app\common\repositories\user\UserVisitRepository;
23
 use app\common\repositories\wechat\RoutineQrcodeRepository;
23
 use app\common\repositories\wechat\RoutineQrcodeRepository;
24
 use app\common\repositories\wechat\WechatQrcodeRepository;
24
 use app\common\repositories\wechat\WechatQrcodeRepository;
25
 use app\controller\merchant\gong\Goods;
25
 use app\controller\merchant\gong\Goods;
26
+use app\entity\data\store\StoreProductEntity;
26
 use app\traits\ShouxinyiApiRequest;
27
 use app\traits\ShouxinyiApiRequest;
27
 use crmeb\exceptions\ApiException;
28
 use crmeb\exceptions\ApiException;
28
 use crmeb\services\QrcodeService;
29
 use crmeb\services\QrcodeService;
@@ -2113,4 +2114,29 @@ class ProductRepository extends BaseRepository
2113
         //返佣总额 返利总额=(交易金额-手续费)*返利比例
2114
         //返佣总额 返利总额=(交易金额-手续费)*返利比例
2114
         return decimal2(bcmul($price-$souxufees,$base_commission/100,3));
2115
         return decimal2(bcmul($price-$souxufees,$base_commission/100,3));
2115
     }
2116
     }
2117
+
2118
+    /**
2119
+     * @param int $productId
2120
+     * @return StoreProductEntity
2121
+     */
2122
+    public function getStoreProductEntityByProductId(int $productId): StoreProductEntity
2123
+    {
2124
+        $entityList = $this->getStoreProductEntityListByProductIdList([$productId]);
2125
+        $entity = array_shift($entityList);
2126
+        if ($entity instanceof StoreProductEntity) {
2127
+            return $entity;
2128
+        } else {
2129
+            /** @var StoreProductEntity */
2130
+            return StoreProductEntity::newInstance();
2131
+        }
2132
+    }
2133
+
2134
+    /**
2135
+     * @param array $idList
2136
+     * @return StoreProductEntity[]
2137
+     */
2138
+    public function getStoreProductEntityListByProductIdList(array $idList): array
2139
+    {
2140
+        return $this->dao->getUserSignGongxianEntityListByIdList($idList);
2141
+    }
2116
 }
2142
 }

+ 10 - 0
app/common/repositories/store/shipping/ShippingTemplateFreeRepository.php

@@ -8,6 +8,7 @@ namespace app\common\repositories\store\shipping;
8
 
8
 
9
 use app\common\repositories\BaseRepository;
9
 use app\common\repositories\BaseRepository;
10
 use app\common\dao\store\shipping\ShippingTemplateFreeDao as dao;
10
 use app\common\dao\store\shipping\ShippingTemplateFreeDao as dao;
11
+use app\entity\data\shipping\ShippingTemplateFreeEntity;
11
 
12
 
12
 class ShippingTemplateFreeRepository extends BaseRepository
13
 class ShippingTemplateFreeRepository extends BaseRepository
13
 {
14
 {
@@ -66,4 +67,13 @@ class ShippingTemplateFreeRepository extends BaseRepository
66
     {
67
     {
67
         return $this->dao->insertAll($data);
68
         return $this->dao->insertAll($data);
68
     }
69
     }
70
+
71
+    /**
72
+     * @param int $tempId
73
+     * @return ShippingTemplateFreeEntity[]
74
+     */
75
+    public function getShippingTemplateFreeEntityListByTempId(int $tempId): array
76
+    {
77
+        return $this->dao->getShippingTemplateFreeEntityListByTempId($tempId);
78
+    }
69
 }
79
 }

+ 9 - 0
app/common/repositories/store/shipping/ShippingTemplateRegionRepository.php

@@ -8,6 +8,7 @@ namespace app\common\repositories\store\shipping;
8
 
8
 
9
 use app\common\repositories\BaseRepository;
9
 use app\common\repositories\BaseRepository;
10
 use app\common\dao\store\shipping\ShippingTemplateRegionDao as dao;
10
 use app\common\dao\store\shipping\ShippingTemplateRegionDao as dao;
11
+use app\entity\data\shipping\ShippingTemplateRegionEntity;
11
 
12
 
12
 class ShippingTemplateRegionRepository extends BaseRepository
13
 class ShippingTemplateRegionRepository extends BaseRepository
13
 {
14
 {
@@ -68,4 +69,12 @@ class ShippingTemplateRegionRepository extends BaseRepository
68
         return $this->dao->insertAll($data);
69
         return $this->dao->insertAll($data);
69
     }
70
     }
70
 
71
 
72
+    /**
73
+     * @param int $tempId
74
+     * @return ShippingTemplateRegionEntity[]
75
+     */
76
+    public function getShippingTemplateRegionEntityListByTempId(int $tempId): array
77
+    {
78
+        return $this->dao->getShippingTemplateRegionEntityListByTempId($tempId);
79
+    }
71
 }
80
 }

+ 11 - 0
app/common/repositories/store/shipping/ShippingTemplateRepository.php

@@ -10,6 +10,7 @@ namespace app\common\repositories\store\shipping;
10
 use app\common\repositories\BaseRepository;
10
 use app\common\repositories\BaseRepository;
11
 use app\common\dao\store\shipping\ShippingTemplateDao as dao;
11
 use app\common\dao\store\shipping\ShippingTemplateDao as dao;
12
 use app\common\repositories\store\product\ProductRepository;
12
 use app\common\repositories\store\product\ProductRepository;
13
+use app\entity\data\shipping\ShippingTemplateEntity;
13
 use think\facade\Db;
14
 use think\facade\Db;
14
 
15
 
15
 class ShippingTemplateRepository extends BaseRepository
16
 class ShippingTemplateRepository extends BaseRepository
@@ -230,4 +231,14 @@ class ShippingTemplateRepository extends BaseRepository
230
         return $this->create($data);
231
         return $this->create($data);
231
     }
232
     }
232
 
233
 
234
+    /**
235
+     * @param int $shippingTemplateId
236
+     * @return ShippingTemplateEntity
237
+     */
238
+    public function getShippingTemplateEntityByShippingTemplateId(int $shippingTemplateId): ShippingTemplateEntity
239
+    {
240
+        /** @var ShippingTemplateEntity $entity */
241
+        $entity = $this->dao->getShippingTemplateEntityByShippingTemplateId($shippingTemplateId);
242
+        return $entity;
243
+    }
233
 }
244
 }

+ 9 - 1
app/common/repositories/store/shipping/ShippingTemplateUndeliveRepository.php

@@ -9,6 +9,7 @@ namespace app\common\repositories\store\shipping;
9
 
9
 
10
 use app\common\repositories\BaseRepository;
10
 use app\common\repositories\BaseRepository;
11
 use app\common\dao\store\shipping\ShippingTemplateUndeliveryDao as dao;
11
 use app\common\dao\store\shipping\ShippingTemplateUndeliveryDao as dao;
12
+use app\entity\data\shipping\ShippingTemplateUndeliveryEntity;
12
 
13
 
13
 class ShippingTemplateUndeliveRepository extends BaseRepository
14
 class ShippingTemplateUndeliveRepository extends BaseRepository
14
 {
15
 {
@@ -55,5 +56,12 @@ class ShippingTemplateUndeliveRepository extends BaseRepository
55
         }
56
         }
56
     }
57
     }
57
 
58
 
58
-
59
+    /**
60
+     * @param int $tempId
61
+     * @return ShippingTemplateUndeliveryEntity[]
62
+     */
63
+    public function getShippingTemplateUndeliveryEntityListByTempId(int $tempId): array
64
+    {
65
+        return $this->dao->getShippingTemplateUndeliveryEntityListByTempId($tempId);
66
+    }
59
 }
67
 }

+ 35 - 0
app/common/repositories/system/merchant/MerchantContributionRepository.php

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+namespace app\common\repositories\system\merchant;
4
+
5
+use app\common\dao\system\merchant\MerchantContributionDao;
6
+use app\common\repositories\BaseRepository;
7
+use app\entity\data\merchant\MerchantContributionEntity;
8
+
9
+class MerchantContributionRepository extends BaseRepository
10
+{
11
+    /**
12
+     * @var MerchantContributionDao
13
+     */
14
+    protected $dao;
15
+
16
+    /**
17
+     * @param MerchantContributionDao $dao
18
+     */
19
+    public function __construct(MerchantContributionDao $dao)
20
+    {
21
+        $this->dao = $dao;
22
+    }
23
+
24
+    /**
25
+     * 根据商家的让利比例 获取对应的 配置信息
26
+     * @param float $profitSharing
27
+     * @return MerchantContributionEntity
28
+     */
29
+    public function getMerchantContributionEntityByProfitSharing(float $profitSharing): MerchantContributionEntity
30
+    {
31
+        /** @var MerchantContributionEntity $entity */
32
+        $entity = $this->dao->getMerchantContributionEntityByProfitSharing($profitSharing);
33
+        return $entity;
34
+    }
35
+}

+ 25 - 0
app/common/repositories/system/merchant/MerchantRepository.php

@@ -24,6 +24,7 @@ use app\common\repositories\user\UserVisitRepository;
24
 use app\common\repositories\wechat\RoutineQrcodeRepository;
24
 use app\common\repositories\wechat\RoutineQrcodeRepository;
25
 use app\controller\admin\system\merchant\MerchantIntention;
25
 use app\controller\admin\system\merchant\MerchantIntention;
26
 use app\controller\merchant\gong\Goods;
26
 use app\controller\merchant\gong\Goods;
27
+use app\entity\data\merchant\MerchantEntity;
27
 use app\traits\HaikeApiRequest;
28
 use app\traits\HaikeApiRequest;
28
 use crmeb\services\QrcodeService;
29
 use crmeb\services\QrcodeService;
29
 use crmeb\services\UploadService;
30
 use crmeb\services\UploadService;
@@ -1011,6 +1012,30 @@ class MerchantRepository extends BaseRepository
1011
 
1012
 
1012
     }
1013
     }
1013
 
1014
 
1015
+    /**
1016
+     * 根据 商户ID 获取 未删除的 商户信息
1017
+     * @param int $merchantId
1018
+     * @return MerchantEntity
1019
+     */
1020
+    public function getMerchantEntityByMerchantId(int $merchantId): MerchantEntity
1021
+    {
1022
+        $entityList = $this->getMerchantEntityListByMerchantIdList([$merchantId]);
1023
+        $entity = array_shift($entityList);
1024
+        if ($entity instanceof MerchantEntity) {
1025
+            return $entity;
1026
+        } else {
1027
+            /** @var MerchantEntity */
1028
+            return MerchantEntity::newInstance();
1029
+        }
1030
+    }
1014
 
1031
 
1032
+    /**
1033
+     * @param array $idList
1034
+     * @return MerchantEntity[]
1035
+     */
1036
+    public function getMerchantEntityListByMerchantIdList(array $idList): array
1037
+    {
1038
+        return $this->dao->getMerchantEntityListByMerchantIdList($idList);
1039
+    }
1015
 
1040
 
1016
 }
1041
 }

+ 14 - 0
app/common/repositories/user/UserAddressRepository.php

@@ -10,6 +10,7 @@ namespace app\common\repositories\user;
10
 use app\common\repositories\BaseRepository;
10
 use app\common\repositories\BaseRepository;
11
 use app\common\dao\user\UserAddressDao as dao;
11
 use app\common\dao\user\UserAddressDao as dao;
12
 use app\common\repositories\store\shipping\CityRepository;
12
 use app\common\repositories\store\shipping\CityRepository;
13
+use app\entity\data\user\UserAddressEntity;
13
 
14
 
14
 /**
15
 /**
15
  * Class UserAddressRepository
16
  * Class UserAddressRepository
@@ -122,4 +123,17 @@ class UserAddressRepository extends BaseRepository
122
         }
123
         }
123
         return $address;
124
         return $address;
124
     }
125
     }
126
+
127
+    /**
128
+     * 根据 地址ID 获取地址实体
129
+     *
130
+     * @param $addressId
131
+     * @return UserAddressEntity
132
+     */
133
+    public function getAddressEntityByAddressId($addressId): UserAddressEntity
134
+    {
135
+        /** @var UserAddressEntity $addressEntity */
136
+        $addressEntity = $this->dao->getAddressEntityByAddressId($addressId);
137
+        return $addressEntity;
138
+    }
125
 }
139
 }

+ 275 - 5
app/common/repositories/user/UserBillRepository.php

@@ -5,7 +5,7 @@
5
  * @author xaboy
5
  * @author xaboy
6
  * @day 2020-05-07
6
  * @day 2020-05-07
7
  *
7
  *
8
- * 
8
+ *
9
  */
9
  */
10
 
10
 
11
 namespace app\common\repositories\user;
11
 namespace app\common\repositories\user;
@@ -13,14 +13,20 @@ namespace app\common\repositories\user;
13
 
13
 
14
 use app\common\dao\BaseDao;
14
 use app\common\dao\BaseDao;
15
 use app\common\dao\user\UserBillDao;
15
 use app\common\dao\user\UserBillDao;
16
-use app\common\model\store\order\StoreOrder;
16
+use app\common\enum\user\UserBillEnum;
17
+use app\common\enum\user\UserCertificationEnum;
17
 use app\common\model\user\UserBill;
18
 use app\common\model\user\UserBill;
18
 use app\common\repositories\BaseRepository;
19
 use app\common\repositories\BaseRepository;
19
-use crmeb\jobs\SendTemplateMessageJob;
20
+use app\common\repositories\gzc\GzcLogRepository;
21
+use app\common\repositories\store\order\StoreOrderRepository;
22
+use app\entity\data\user\UserBillEntity;
23
+use app\entity\data\user\UserCertificationEntity;
24
+use app\entity\data\user\UserEntity;
25
+use app\utils\ArrayUtil;
26
+use think\db\exception\DbException;
27
+use think\exception\ValidateException;
20
 use think\facade\Cache;
28
 use think\facade\Cache;
21
-use function Symfony\Component\String\s;
22
 use think\facade\Db;
29
 use think\facade\Db;
23
-use think\facade\Queue;
24
 use think\Model;
30
 use think\Model;
25
 
31
 
26
 /**
32
 /**
@@ -376,4 +382,268 @@ class UserBillRepository extends BaseRepository
376
     {
382
     {
377
         return $this->bill($uid, $category, $type, 0, $data);
383
         return $this->bill($uid, $category, $type, 0, $data);
378
     }
384
     }
385
+
386
+    /**
387
+     * 添加 bill 数据
388
+     * @param int $uid
389
+     * @param int $commissionType
390
+     * @param int $pm
391
+     * @param float $number
392
+     * @param string $category
393
+     * @param string $type
394
+     * @param string $source
395
+     * @param int $orderType
396
+     * @param int $typeShop
397
+     * @param int $orderId
398
+     * @param string $mark
399
+     * @param string $title
400
+     * @return UserBillEntity
401
+     */
402
+    public function addUserBill(int $uid, int $commissionType, int $pm, float $number, string $category, string $type, string $source, int $orderType, int $typeShop = 0, int $orderId = 0, string $mark = '', string $title = ''): UserBillEntity
403
+    {
404
+
405
+        $orderSn = '';
406
+        $merId = 0;
407
+        if ($typeShop == UserBillEnum::TYPE_SHOP['Platform']['code']) {
408
+            /** @var StoreOrderRepository $storeOrderRepository */
409
+            $storeOrderRepository = app()->make(StoreOrderRepository::class);
410
+            $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId($orderId);
411
+            if (empty($storeOrderEntity->getOrderId())) {
412
+                throw new ValidateException('未查询到订单信息');
413
+            }
414
+            $orderId = $storeOrderEntity->getOrderId();
415
+            $orderSn = $storeOrderEntity->getOrderSn();
416
+            $merId = $storeOrderEntity->getMerId();
417
+        }
418
+
419
+        /** @var UserBillEntity $userBillEntity */
420
+        $userBillEntity = UserBillEntity::newInstance();
421
+        $userBillEntity->setUid($uid)
422
+            ->setLinkId($orderId)
423
+            //UserBillEnum::PM['INCOME']['code']
424
+            ->setPm($pm)
425
+            ->setTitle($title ?: ArrayUtil::getEnumNameByCode($commissionType, UserBillEnum::COMMISSION_TYPE))
426
+            ->setCategory($category)
427
+            ->setType($type)
428
+            ->setNumber($number)
429
+            ->setMark($mark)
430
+            ->setStatus(UserBillEnum::STATUS['PENDING']['code'])
431
+            ->setCommissionType($commissionType)
432
+            ->setOrderSn($orderSn)
433
+            ->setTypeShop($typeShop)
434
+            ->setMerId($merId)
435
+            // UserBillEnum::SOURCE['ONLINE']['code']
436
+            ->setSource($source)
437
+            ->setOrderType($orderType)
438
+            ->setIsRedBrokerage(UserBillEnum::IS_RED_BROKERAGE['NORMAL']['code'])
439
+            ->setGzc(UserBillEnum::GZC_STATUS['NOT_ENTERED']['code'])
440
+            ->setIsGzc(UserBillEnum::IS_GZC['NOT_STARTED']['code']);
441
+
442
+        return $this->createByEntity($userBillEntity);
443
+    }
444
+
445
+    /**
446
+     * 写入 数据
447
+     * @param UserBillEntity $userBillEntity
448
+     * @return UserBillEntity
449
+     */
450
+    public function createByEntity(UserBillEntity $userBillEntity): UserBillEntity
451
+    {
452
+        $result = $this->dao->create($userBillEntity->toUnderlineArray())->toArray();
453
+        /** @var UserBillEntity $entity */
454
+        $entity = UserBillEntity::newInstance($result);
455
+        return $entity;
456
+    }
457
+
458
+    /**
459
+     * @param int $billId
460
+     * @return UserBillEntity
461
+     */
462
+    public function getUserBillEntityByBillId(int $billId): UserBillEntity
463
+    {
464
+        $entityList = $this->getUserBillEntityListByBillIdList([$billId]);
465
+        $entity = array_shift($entityList);
466
+        if ($entity instanceof UserBillEntity) {
467
+            return $entity;
468
+        } else {
469
+            /** @var UserBillEntity */
470
+            return UserBillEntity::newInstance();
471
+        }
472
+    }
473
+
474
+    /**
475
+     * 获取Bill实体集合 根据 Id集合
476
+     * @param array $billIdList
477
+     * @return UserBillEntity[]
478
+     */
479
+    public function getUserBillEntityListByBillIdList(array $billIdList): array
480
+    {
481
+        return $this->dao->getUserBillEntityListByBillIdList($billIdList);
482
+    }
483
+
484
+    /**
485
+     * 获取Bill实体集合 根据 订单类型 订单Id集合 待结算状态
486
+     * @param string $typeShop
487
+     * @param array $orderIdList
488
+     * @return UserBillEntity[]
489
+     */
490
+    public function getUserBillEntityListByOrderIdListAndPending(string $typeShop, array $orderIdList): array
491
+    {
492
+        return $this->dao->getUserBillEntityListByOrderIdListAndPending($typeShop, $orderIdList);
493
+    }
494
+
495
+    /**
496
+     * @param $dataList
497
+     * @return array
498
+     */
499
+    public function batchUpdateUserBillDataByDataList($dataList): array
500
+    {
501
+        return $this->dao->saveAll($dataList);
502
+    }
503
+
504
+    /**
505
+     * 将 账单 记录设置为生效状态 并对用户的 对应 字段进行增减
506
+     * @param array $idList
507
+     * @return array
508
+     */
509
+    public function executeByIdList(array $idList): array
510
+    {
511
+        $userBillEntityList = $this->getUserBillEntityListByBillIdList($idList);
512
+        // 忽略 已经生效的 记录
513
+        $userBillEntityList = array_filter($userBillEntityList, function($entity) {
514
+            return $entity->getStatus() != UserBillEnum::STATUS['VALID']['code'];
515
+        });
516
+
517
+        if (!empty($userBillEntityList)) {
518
+            $pensionUidList = [];
519
+            // 获取所有记录的 归属人
520
+            $userIdList = array_map(function ($userBillEntity) use (&$pensionUidList) {
521
+                // 获取 养老金记录
522
+                if ($userBillEntity->getCommissionType() == UserBillEnum::COMMISSION_TYPE['PENSION']['code']) {
523
+                    $pensionUidList[] = $userBillEntity->getUid();
524
+                }
525
+                return $userBillEntity->getUid();
526
+            }, $userBillEntityList);
527
+
528
+            // 获取用户 映射信息
529
+            /** @var UserRepository $userRepository */
530
+            $userRepository = app()->make(UserRepository::class);
531
+            /** @var UserEntity[] $userEntityMapByUid */
532
+            $userEntityMapByUid = [];
533
+            if (!empty($userIdList)) {
534
+                $userEntityMapByUid = $userRepository->getUserEntityMapByUidList($userIdList);
535
+            }
536
+            // 获取实名认证 映射信息 (养老金记录 结算时 需要确定 所属人是否已经实名认证 如果实名认证了 需要推到养老金公证处明细表里 并修改养老金记录的推送状态)
537
+            /** @var UserCertificationEntity[] $userCertificationEntityMapByUid */
538
+            $userCertificationEntityMapByUid = [];
539
+            if (!empty($pensionUidList)) {
540
+                /** @var UserCertificationRepository $userCertificationRepository */
541
+                $userCertificationRepository = app()->make(UserCertificationRepository::class);
542
+                $userCertificationEntityMapByUid = $userCertificationRepository->getUserCertificationEntityMapByUidListApproved($pensionUidList);
543
+            }
544
+            /** @var GzcLogRepository $gzcLogRepository */
545
+            $gzcLogRepository = app()->make(GzcLogRepository::class);
546
+
547
+            $updateUserEntityList = [];
548
+            $updateUserBillEntityList = [];
549
+            foreach ($userBillEntityList as $userBillEntity) {
550
+                if (empty($userBillEntity->getBillId()) || empty($userBillEntity->getUid())) {
551
+                    // throw new ValidateException('无效的账单记录');
552
+                    continue;
553
+                }
554
+                if (!empty($userBillEntity->getTakeTime())) {
555
+                    throw new ValidateException("该账单记录已更新,请勿重复操作({$userBillEntity->getBillId()})");
556
+                }
557
+
558
+                $userEntity = $userEntityMapByUid[$userBillEntity->getUid()];
559
+                if (empty($userEntity) || empty($userEntity->getUid())) {
560
+                    throw new ValidateException("未查询到用户信息({$userBillEntity->getBillId()})");
561
+                }
562
+
563
+                // 更新 用户信息
564
+                /** @var UserEntity $updateUserEntity */
565
+                $updateUserEntity = $updateUserEntityList[$userEntity->getUid()] ?? UserEntity::newInstance();
566
+                $updateUserEntity->setUid($userEntity->getUid());
567
+                // 更新 账单 记录
568
+                /** @var UserBillEntity $updateUserBillEntity */
569
+                $updateUserBillEntity = $updateUserBillEntityList[$userBillEntity->getBillId()] ?? UserBillEntity::newInstance();
570
+                // 更新 账单记录 状态
571
+                $updateUserBillEntity
572
+                    ->setBillId($userBillEntity->getBillId())
573
+                    ->setStatus(UserBillEnum::STATUS['VALID']['code'])
574
+                    ->setTakeTime(time());
575
+
576
+                if ($userBillEntity->getCommissionType() == UserBillEnum::COMMISSION_TYPE['DIRECT_REFERRAL']['code']) {
577
+                    // 直推奖
578
+                    if (is_null($updateUserEntity->getBrokeragePrice())) {
579
+                        $updateUserEntity->setBrokeragePrice($userEntity->getBrokeragePrice());
580
+                    }
581
+                    // 更新用户 佣金 信息
582
+                    if ($userBillEntity->getPm() == UserBillEnum::PM['EXPEND']['code']) {
583
+                        if ($updateUserEntity->getBrokeragePrice() < $userBillEntity->getNumber()) {
584
+                            throw new ValidateException('用户佣金不足');
585
+                        }
586
+                        $updateUserEntity->setBrokeragePrice(bcsub($updateUserEntity->getBrokeragePrice(), $userBillEntity->getNumber(), 2));
587
+                    } else {
588
+                        $updateUserEntity->setBrokeragePrice(bcadd($updateUserEntity->getBrokeragePrice(), $userBillEntity->getNumber(), 2));
589
+                    }
590
+
591
+                } else if ($userBillEntity->getCommissionType() == UserBillEnum::COMMISSION_TYPE['PENSION']['code']) {
592
+
593
+                    if ($userBillEntity->getGzc() == UserBillEnum::GZC_STATUS['NOT_ENTERED']['code']) {
594
+                        if (!empty($userCertificationEntityMapByUid[$userBillEntity->getUid()])) {
595
+                            $userCertificationEntity = $userCertificationEntityMapByUid[$userBillEntity->getUid()];
596
+                            // 创建公证处记录
597
+                            $gzcLogRepository->addGzcLog(
598
+                                $userCertificationEntity->getUid(),
599
+                                $userCertificationEntity->getUserName(),
600
+                                $userCertificationEntity->getMobile(),
601
+                                $userCertificationEntity->getUserCard(),
602
+                                $userBillEntity->getTypeShop(),
603
+                                $userBillEntity->getLinkId(),
604
+                                $userBillEntity->getNumber()
605
+                            );
606
+
607
+                            // 养老金
608
+                            if (is_null($updateUserEntity->getAnnuity())) {
609
+                                $updateUserEntity->setAnnuity($userEntity->getAnnuity());
610
+                            }
611
+                            $updateUserEntity->setAnnuity(bcadd($updateUserEntity->getAnnuity(), $userBillEntity->getNumber(), 2));
612
+
613
+                            // 几笔养老金
614
+                            if (is_null($updateUserEntity->getAnnuityNum())) {
615
+                                $updateUserEntity->setAnnuityNum($userEntity->getAnnuityNum());
616
+                            }
617
+                            $updateUserEntity->setAnnuityNum(bcadd($updateUserEntity->getAnnuityNum(), 1));
618
+
619
+                            // 更新佣金记录
620
+                            $updateUserBillEntity
621
+                                ->setGzc(UserBillEnum::GZC_STATUS['ENTERED']['code'])
622
+                                ->setIsGzc(UserBillEnum::IS_GZC['NOT_STARTED']['code']);
623
+                        }
624
+                    }
625
+                }
626
+
627
+                $updateUserEntityList[$userEntity->getUid()] = $updateUserEntity;
628
+                $updateUserBillEntityList[$userBillEntity->getBillId()] = $updateUserBillEntity;
629
+            }
630
+            if (!empty($updateUserEntityList)) {
631
+                $userRepository->batchUpdateUserDataByDataList(
632
+                    array_map(function (UserEntity $updateUserEntity) {
633
+                        return $updateUserEntity->toUnderlineArray();
634
+                    }, $updateUserEntityList)
635
+                );
636
+            }
637
+
638
+            if (!empty($updateUserBillEntityList)) {
639
+                $this->batchUpdateUserBillDataByDataList(
640
+                    array_map(function (UserBillEntity $updateUserBillEntity) {
641
+                        return $updateUserBillEntity->toUnderlineArray();
642
+                    }, $updateUserBillEntityList)
643
+                );
644
+            }
645
+        }
646
+
647
+        return $idList;
648
+    }
379
 }
649
 }

+ 86 - 0
app/common/repositories/user/UserCertificationRepository.php

@@ -0,0 +1,86 @@
1
+<?php
2
+
3
+namespace app\common\repositories\user;
4
+
5
+use app\common\dao\user\UserCertificationDao;
6
+use app\common\enum\user\UserCertificationEnum;
7
+use app\common\repositories\BaseRepository;
8
+use app\entity\data\user\UserCertificationEntity;
9
+
10
+class UserCertificationRepository extends BaseRepository
11
+{
12
+    public function __construct(UserCertificationDao $dao)
13
+    {
14
+        $this->dao = $dao;
15
+    }
16
+
17
+    /**
18
+     * @param int $id
19
+     * @return UserCertificationEntity
20
+     */
21
+    public function getUserCertificationEntityById(int $id): UserCertificationEntity
22
+    {
23
+        $entityList = $this->getUserCertificationEntityListByIdList([$id]);
24
+        $entity = array_shift($entityList);
25
+        if ($entity instanceof UserCertificationEntity) {
26
+            return $entity;
27
+        } else {
28
+            /** @var UserCertificationEntity */
29
+            return UserCertificationEntity::newInstance();
30
+        }
31
+    }
32
+
33
+    /**
34
+     * @param array $idList
35
+     * @return UserCertificationEntity[]
36
+     */
37
+    public function getUserCertificationEntityListByIdList(array $idList): array
38
+    {
39
+        return $this->dao->getUserCertificationEntityListByIdList($idList);
40
+    }
41
+
42
+    /**
43
+     * @param array $uidList
44
+     * @return UserCertificationEntity[]
45
+     */
46
+    public function getUserCertificationEntityListByUidList(array $uidList): array
47
+    {
48
+        return $this->dao->getUserCertificationEntityListByUidList($uidList);
49
+    }
50
+
51
+    /**
52
+     * 获取 已通过的 用户实名认证实体 映射 根据用户ID
53
+     * @param array $uidList
54
+     * @return UserCertificationEntity[]
55
+     */
56
+    public function getUserCertificationEntityMapByUidListApproved(array $uidList): array
57
+    {
58
+        /** @var UserCertificationEntity[] $userCertificationEntityMapByUid */
59
+        $userCertificationEntityMapByUid = [];
60
+        $userCertificationEntityList = $this->getUserCertificationEntityListByUidList($uidList);
61
+        foreach ($userCertificationEntityList as $userCertificationEntity) {
62
+            if ($userCertificationEntity->getStatus() == UserCertificationEnum::STATUS['Approved']['code'] && !empty($userCertificationEntity->getUserCard())) {
63
+                $userCertificationEntityMapByUid[$userCertificationEntity->getUid()] = $userCertificationEntity;
64
+            }
65
+        }
66
+        return $userCertificationEntityMapByUid;
67
+    }
68
+
69
+    public function create($data)
70
+    {
71
+        return $this->dao->create($data);
72
+    }
73
+
74
+    /**
75
+     * 写入实名认证记录
76
+     * @param UserCertificationEntity $UserCertificationEntity
77
+     * @return UserCertificationEntity
78
+     */
79
+    public function createByEntity(UserCertificationEntity $UserCertificationEntity): UserCertificationEntity
80
+    {
81
+        $result = $this->dao->create($UserCertificationEntity->toUnderlineArray())->toArray();
82
+        /** @var UserCertificationEntity $entity */
83
+        $entity = UserCertificationEntity::newInstance($result);
84
+        return $entity;
85
+    }
86
+}

+ 208 - 0
app/common/repositories/user/UserPvLogRepository.php

@@ -0,0 +1,208 @@
1
+<?php
2
+
3
+namespace app\common\repositories\user;
4
+
5
+use app\common\dao\user\UserPvLogDao;
6
+use app\common\enum\user\UserPvLogEnum;
7
+use app\common\repositories\BaseRepository;
8
+use app\common\repositories\store\order\StoreOrderRepository;
9
+use app\entity\data\user\UserEntity;
10
+use app\entity\data\user\UserPvLogEntity;
11
+use think\db\exception\DbException;
12
+use think\exception\ValidateException;
13
+
14
+class UserPvLogRepository extends BaseRepository
15
+{
16
+    public function __construct(UserPvLogDao $dao)
17
+    {
18
+        $this->dao = $dao;
19
+    }
20
+
21
+    /**
22
+     * @param int $id
23
+     * @return UserPvLogEntity
24
+     */
25
+    public function getUserPvLogEntityById(int $id): UserPvLogEntity
26
+    {
27
+        $entityList = $this->getUserPvLogEntityListByIdList([$id]);
28
+        $entity = array_shift($entityList);
29
+        if ($entity instanceof UserPvLogEntity) {
30
+            return $entity;
31
+        } else {
32
+            /** @var UserPvLogEntity */
33
+            return UserPvLogEntity::newInstance();
34
+        }
35
+    }
36
+
37
+    /**
38
+     * @param array $idList
39
+     * @return UserPvLogEntity[]
40
+     */
41
+    public function getUserPvLogEntityListByIdList(array $idList): array
42
+    {
43
+        return $this->dao->getUserPvLogEntityListByIdList($idList);
44
+    }
45
+
46
+    /**
47
+     * @param string $orderType
48
+     * @param array $orderIdList
49
+     * @return UserPvLogEntity[]
50
+     */
51
+    public function getUserPvLogEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
52
+    {
53
+        return $this->dao->getUserPvLogEntityListByOrderIdListAndPending($orderType, $orderIdList);
54
+    }
55
+
56
+    public function create($data)
57
+    {
58
+        return $this->dao->create($data);
59
+    }
60
+
61
+    /**
62
+     * 写入 PV记录
63
+     * @param UserPvLogEntity $userPvLogEntity
64
+     * @return UserPvLogEntity
65
+     */
66
+    public function createByEntity(UserPvLogEntity $userPvLogEntity): UserPvLogEntity
67
+    {
68
+        $result = $this->dao->create($userPvLogEntity->toUnderlineArray())->toArray();
69
+        /** @var UserPvLogEntity $entity */
70
+        $entity = UserPvLogEntity::newInstance($result);
71
+        return $entity;
72
+    }
73
+
74
+    /**
75
+     * 添加Pv 记录
76
+     * @param int $uid
77
+     * @param float $pv
78
+     * @param string $mark
79
+     * @param string $orderType
80
+     * @param string $orderId
81
+     * @return UserPvLogEntity
82
+     */
83
+    public function addUserPvLog(int $uid, float $pv, string $mark = '', string $orderType = '', string $orderId = ''): UserPvLogEntity
84
+    {
85
+        if (!empty($orderType)) {
86
+            if (!empty($orderId)) {
87
+                if ($orderType == UserPvLogEnum::ORDER_TYPE['Platform']['code']) {
88
+                    /** @var StoreOrderRepository $storeOrderRepository */
89
+                    $storeOrderRepository = app()->make(StoreOrderRepository::class);
90
+                    $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId((int)$orderId);
91
+                    if (empty($storeOrderEntity->getOrderId())) {
92
+                        throw new ValidateException('未查询到订单信息');
93
+                    }
94
+                }
95
+            }
96
+        }
97
+
98
+        /** @var UserPvLogEntity $userPvLogEntity */
99
+        $userPvLogEntity = UserPvLogEntity::newInstance();
100
+        $userPvLogEntity->setUid($uid)
101
+            ->setPv($pv)
102
+            ->setMark($mark)
103
+            ->setOrderType($orderType)
104
+            ->setOrderId($orderId)
105
+            ->setAddtime(time())
106
+            ->setStatus(UserPvLogEnum::STATUS['PendingConfirmation']['code']);
107
+
108
+        return $this->createByEntity($userPvLogEntity);
109
+    }
110
+
111
+    /**
112
+     * 将 贡献值 直推贡献值 记录设置为生效状态 并对用户的 贡献值 直推贡献值 字段进行增减
113
+     * @param array $idList
114
+     * @return array
115
+     */
116
+    public function executeByIdList(array $idList): array
117
+    {
118
+        $userPvLogEntityList = $this->getUserPvLogEntityListByIdList($idList);
119
+        $userIdList = [];
120
+
121
+        // 忽略 已经生效的 记录
122
+        $userPvLogEntityList = array_filter($userPvLogEntityList, function ($entity) use (&$userIdList) {
123
+            // 积分数据不为空 用户不为空 状态属于待结算 并且结算字段为空
124
+            if ((!empty($entity->getId()) && !empty($entity->getUid()) && ($entity->getStatus() == UserPvLogEnum::STATUS['PendingConfirmation']['code']) && empty($entity->getSettlementTime()))) {
125
+                $userIdList[] = $entity->getUid();
126
+                return true;
127
+            }
128
+            return false;
129
+        });
130
+
131
+        if (!empty($userPvLogEntityList)) {
132
+            // 获取用户 映射信息
133
+            /** @var UserRepository $userRepository */
134
+            $userRepository = app()->make(UserRepository::class);
135
+            /** @var UserEntity[] $userEntityMapByUid */
136
+            $userEntityMapByUid = [];
137
+            if (!empty($userIdList)) {
138
+                $userEntityMapByUid = $userRepository->getUserEntityMapByUidList($userIdList);
139
+            }
140
+
141
+            /** @var UserEntity[] $updateUserEntityList */
142
+            $updateUserEntityList = [];
143
+            /** @var UserPvLogEntity[] $updateUserPvLogEntityList */
144
+            $updateUserPvLogEntityList = [];
145
+            foreach ($userPvLogEntityList as $userPvLogEntity) {
146
+
147
+                $userEntity = $userEntityMapByUid[$userPvLogEntity->getUid()];
148
+                if (empty($userEntity) || empty($userEntity->getUid())) {
149
+                    throw new ValidateException("未查询到用户信息(PvLogId:{$userPvLogEntity->getId()})");
150
+                }
151
+
152
+                // 组建 更新 用户信息
153
+                if (isset($updateUserEntityList[$userEntity->getUid()])) {
154
+                    $updateUserEntity = $updateUserEntityList[$userEntity->getUid()];
155
+                } else {
156
+                    /** @var UserEntity $updateUserEntity */
157
+                    $updateUserEntity = UserEntity::newInstance();
158
+                    $updateUserEntity
159
+                        ->setUid($userEntity->getUid())
160
+                        ->setPv($userEntity->getPv());
161
+                }
162
+                // 组建 账单 记录
163
+                if (isset($updateUserPvLogEntityList[$userPvLogEntity->getId()])) {
164
+                    $updateUserPvLogEntity = $updateUserPvLogEntityList[$userPvLogEntity->getId()];
165
+                } else {
166
+                    /** @var UserPvLogEntity $updateUserPvLogEntity */
167
+                    $updateUserPvLogEntity = UserPvLogEntity::newInstance();
168
+                    // 更新 账单记录 状态
169
+                    $updateUserPvLogEntity
170
+                        ->setId($userPvLogEntity->getId())
171
+                        ->setStatus(UserPvLogEnum::STATUS['Valid']['code'])
172
+                        ->setSettlementTime(date('Y-m-d H:i:s'));
173
+                }
174
+                // 写入Pv
175
+                $updateUserEntity->setPv(bcadd($updateUserEntity->getPv(), $userPvLogEntity->getPv(), 2));
176
+
177
+                $updateUserEntityList[$userPvLogEntity->getUid()] = $updateUserEntity;
178
+                $updateUserPvLogEntityList[$userPvLogEntity->getId()] = $updateUserPvLogEntity;
179
+            }
180
+
181
+            if (!empty($updateUserEntityList)) {
182
+                $userRepository->batchUpdateUserDataByDataList(
183
+                    array_map(function (UserEntity $updateUserEntity) {
184
+                        return $updateUserEntity->toUnderlineArray();
185
+                    }, $updateUserEntityList)
186
+                );
187
+            }
188
+
189
+            if (!empty($updateUserPvLogEntityList)) {
190
+                $this->batchUpdateUserPvLogDataByDataList(
191
+                    array_map(function (UserPvLogEntity $updateUserPvLogEntity) {
192
+                        return $updateUserPvLogEntity->toUnderlineArray();
193
+                    }, $updateUserPvLogEntityList)
194
+                );
195
+            }
196
+        }
197
+        return $idList;
198
+    }
199
+
200
+    /**
201
+     * @param $dataList
202
+     * @return array
203
+     */
204
+    public function batchUpdateUserPvLogDataByDataList($dataList): array
205
+    {
206
+        return $this->dao->saveAll($dataList);
207
+    }
208
+}

+ 327 - 19
app/common/repositories/user/UserRepository.php

@@ -15,6 +15,11 @@ use alipay\aop\AlipayConfig;
15
 use alipay\aop\AopCertClient;
15
 use alipay\aop\AopCertClient;
16
 use app\common\dao\BaseDao;
16
 use app\common\dao\BaseDao;
17
 use app\common\dao\user\UserDao;
17
 use app\common\dao\user\UserDao;
18
+use app\common\enum\user\UserBillEnum;
19
+use app\common\enum\user\UserSignFugouEnum;
20
+use app\common\enum\user\UserSignJingdouEnum;
21
+use app\common\enum\user\UserSignScoreEnum;
22
+use app\common\enum\user\UserSignVrEnum;
18
 use app\common\model\merchant\order\OrderMerchant;
23
 use app\common\model\merchant\order\OrderMerchant;
19
 use app\common\model\user\User;
24
 use app\common\model\user\User;
20
 use app\common\model\wechat\WechatUser;
25
 use app\common\model\wechat\WechatUser;
@@ -26,6 +31,11 @@ use app\common\repositories\wechat\RoutineQrcodeRepository;
26
 use app\controller\api\store\product\Jd;
31
 use app\controller\api\store\product\Jd;
27
 use app\controller\api\store\product\Vip;
32
 use app\controller\api\store\product\Vip;
28
 use app\controller\api\user\Im;
33
 use app\controller\api\user\Im;
34
+use app\entity\data\user\UserEntity;
35
+use app\entity\data\user\UserSignFugouEntity;
36
+use app\entity\data\user\UserSignJingdouEntity;
37
+use app\entity\data\user\UserSignScoreEntity;
38
+use app\entity\data\user\UserSignVrEntity;
29
 use app\traits\GzcApiRequest;
39
 use app\traits\GzcApiRequest;
30
 use crmeb\exceptions\AuthException;
40
 use crmeb\exceptions\AuthException;
31
 use crmeb\jobs\SendNewPeopleCouponJob;
41
 use crmeb\jobs\SendNewPeopleCouponJob;
@@ -842,7 +852,8 @@ class UserRepository extends BaseRepository
842
         }
852
         }
843
         return Elm::createForm(Route::buildUrl('systemUserChangePro', compact('id'))->build(), [
853
         return Elm::createForm(Route::buildUrl('systemUserChangePro', compact('id'))->build(), [
844
             Elm::input('spread_account_old', '原推荐人')->value($spread_message['account'].'('.$spread_message['nickname'].')')->disabled(true),
854
             Elm::input('spread_account_old', '原推荐人')->value($spread_message['account'].'('.$spread_message['nickname'].')')->disabled(true),
845
-            Elm::input('spread_account', '推荐人')->required()->placeholder("请填写推荐人手机号")
855
+            Elm::input('spread_account', '推荐人')->required()->placeholder("请填写推荐人手机号"),
856
+            Elm::textarea('mark', '备注', '')->placeholder('填写备注信息')
846
         ])->setTitle('修改用户推荐人');
857
         ])->setTitle('修改用户推荐人');
847
     }
858
     }
848
 
859
 
@@ -862,8 +873,9 @@ class UserRepository extends BaseRepository
862
             $level_message = ['account' => '无节点人', 'nickname' => '无节点人'];
873
             $level_message = ['account' => '无节点人', 'nickname' => '无节点人'];
863
         }
874
         }
864
         return Elm::createForm(Route::buildUrl('systemUserChangeLevelPro', compact('id'))->build(), [
875
         return Elm::createForm(Route::buildUrl('systemUserChangeLevelPro', compact('id'))->build(), [
865
-            Elm::input('spread_account_old', '原节点人')->value($level_message['account'].'('.$level_message['nickname'].')')->disabled(true),
866
-            Elm::input('level_account', '节点人(上级)')->required()->placeholder("请填写节点人(上级)手机号")
876
+            Elm::input('level_account_old', '原节点人')->value($level_message['account'].'('.$level_message['nickname'].')')->disabled(true),
877
+            Elm::input('level_account', '节点人(上级)')->required()->placeholder("请填写节点人(上级)手机号"),
878
+            Elm::textarea('mark', '备注', '')->placeholder('填写备注信息')
867
         ])->setTitle('修改用户节点人(上级)');
879
         ])->setTitle('修改用户节点人(上级)');
868
     }
880
     }
869
 
881
 
@@ -881,7 +893,7 @@ class UserRepository extends BaseRepository
881
         return Elm::createForm(Route::buildUrl('systemUserChangeGroupPro', compact('id'))->build(), [
893
         return Elm::createForm(Route::buildUrl('systemUserChangeGroupPro', compact('id'))->build(), [
882
             Elm::select('old_identity_id', '当前用户身份')->options([$oldIdentity])->value($oldIdentity['value'])->disabled(true),
894
             Elm::select('old_identity_id', '当前用户身份')->options([$oldIdentity])->value($oldIdentity['value'])->disabled(true),
883
             Elm::select('new_identity_id', '新的用户身份')->options($identityList),
895
             Elm::select('new_identity_id', '新的用户身份')->options($identityList),
884
-            Elm::textarea('mark', '备注', '')->required()->placeholder('请填写备注信息')
896
+            Elm::textarea('mark', '备注', '')->placeholder('填写备注信息')
885
         ])->setTitle('修改用户身份');
897
         ])->setTitle('修改用户身份');
886
     }
898
     }
887
 
899
 
@@ -3124,22 +3136,26 @@ class UserRepository extends BaseRepository
3124
    *@author cabbage
3136
    *@author cabbage
3125
    *@date 2020-10-31
3137
    *@date 2020-10-31
3126
    * */
3138
    * */
3127
-    public function update_spread($uid,$spread_account){
3128
-        //推荐人信息
3129
-        $spread = Db::name("user")->where('account',$spread_account)->field("uid")->find();
3139
+    public function update_spread($uid,$spread_account,$mark,$olld_id,$adminId,$spread){
3130
         //被推荐人信息
3140
         //被推荐人信息
3131
         $identity=Db::name("user")->where('uid',$uid)->field("identity,spread_uid")->find();
3141
         $identity=Db::name("user")->where('uid',$uid)->field("identity,spread_uid")->find();
3132
-        $user_identity_log=Db::name("user_identity_log")->where(["link_id"=>$uid])->find();
3142
+//        $user_identity_log=Db::name("user_identity_log")->where(["link_id"=>$uid])->find();
3133
         if($spread){
3143
         if($spread){
3134
             try{
3144
             try{
3135
-
3136
                 $data= Db::name("user")->where(["uid"=>$uid])->update(['spread_uid'=>$spread['uid']]);
3145
                 $data= Db::name("user")->where(["uid"=>$uid])->update(['spread_uid'=>$spread['uid']]);
3137
                 Db::name("merchant")->where(["uid"=>$uid])->update(['recommender'=>$spread['uid']]);
3146
                 Db::name("merchant")->where(["uid"=>$uid])->update(['recommender'=>$spread['uid']]);
3138
-                if ($user_identity_log){
3139
-                    Db::name("user_identity_log")->where(["id"=>$user_identity_log["id"]])->update(['uid'=>$spread['uid']]);
3140
-                }else{
3141
-                    Db::name("user_identity_log")->insert(['uid'=>$spread['uid'],"identity"=>$identity["identity"],"create_time"=>date("Y-m-d H:i:s"),"link_id"=>$uid]);
3142
-                }
3147
+ //               if ($user_identity_log){
3148
+ //                   Db::name("user_identity_log")->where(["id"=>$user_identity_log["id"]])->update(['uid'=>$spread['uid']]);
3149
+ //               }else{
3150
+ //                   Db::name("user_identity_log")->insert(['uid'=>$spread['uid'],"identity"=>$identity["identity"],"create_time"=>date("Y-m-d H:i:s"),"link_id"=>$uid]);
3151
+ //               }
3152
+                Db::name("user_spread_change_records")->insert([
3153
+                    'operation_id' => $adminId,
3154
+                    'uid' => $uid,
3155
+                    'old_spread_id' => $olld_id,
3156
+                    'new_spread_id' => $spread['uid'],
3157
+                    'mark' => $mark
3158
+                ]);
3143
                 Db::name("user")->where('account',$spread_account)->inc("spread_count",1)->update();
3159
                 Db::name("user")->where('account',$spread_account)->inc("spread_count",1)->update();
3144
                 if ($identity["spread_uid"]){
3160
                 if ($identity["spread_uid"]){
3145
                     Db::name("user")->where('uid',$identity["spread_uid"])->dec("spread_count")->update();
3161
                     Db::name("user")->where('uid',$identity["spread_uid"])->dec("spread_count")->update();
@@ -3154,10 +3170,15 @@ class UserRepository extends BaseRepository
3154
 
3170
 
3155
     }
3171
     }
3156
 
3172
 
3157
-    public function update_level_uid($uid, $level_account){
3158
-        $level = Db::name("user")->where('account',$level_account)->field("uid")->find();
3173
+    public function update_level_uid($uid, $olld_id, $level_account, $mark,$adminId,$level){
3159
         if($level){
3174
         if($level){
3160
             try{
3175
             try{
3176
+                Db::name("user_level_change_records")->insert([
3177
+                    'operation_id' => $adminId,
3178
+                    'uid' => $uid,
3179
+                    'old_level_id' => $olld_id,
3180
+                    'new_level_id' => $level['uid'],
3181
+                    'mark' => $mark ]);
3161
                 return Db::name("user")->where(["uid"=>$uid])->update(['level_id'=>$level['uid']]);
3182
                 return Db::name("user")->where(["uid"=>$uid])->update(['level_id'=>$level['uid']]);
3162
             }catch (\Exception $e) {
3183
             }catch (\Exception $e) {
3163
                 return false;
3184
                 return false;
@@ -3165,14 +3186,13 @@ class UserRepository extends BaseRepository
3165
         }else{
3186
         }else{
3166
             return false;
3187
             return false;
3167
         }
3188
         }
3168
-
3169
     }
3189
     }
3170
 
3190
 
3171
-    public function update_user_group($id, $old_identity_id, $new_identity_id, $adminid, $mark)
3191
+    public function update_user_group($id, $old_identity_id, $new_identity_id, $adminId, $mark)
3172
     {
3192
     {
3173
         try {
3193
         try {
3174
             Db::name("user_identity_change_records")->insert([
3194
             Db::name("user_identity_change_records")->insert([
3175
-                'operation_id' => $adminid,
3195
+                'operation_id' => $adminId,
3176
                 'uid' => $id,
3196
                 'uid' => $id,
3177
                 'old_identity_id' => $old_identity_id,
3197
                 'old_identity_id' => $old_identity_id,
3178
                 'new_identity_id' => $new_identity_id,
3198
                 'new_identity_id' => $new_identity_id,
@@ -4609,4 +4629,292 @@ class UserRepository extends BaseRepository
4609
         ]);
4629
         ]);
4610
     }
4630
     }
4611
 
4631
 
4632
+
4633
+    /**
4634
+     * @param int $uid
4635
+     * @return UserEntity
4636
+     */
4637
+    public function getUserEntityByUid(int $uid): UserEntity
4638
+    {
4639
+        $entityList = $this->getUserEntityListByUidList([$uid]);
4640
+        $entity = array_shift($entityList);
4641
+        if ($entity instanceof UserEntity) {
4642
+            return $entity;
4643
+        } else {
4644
+            /** @var UserEntity */
4645
+            return UserEntity::newInstance();
4646
+        }
4647
+    }
4648
+
4649
+    /**
4650
+     * 获取用户实体集合 根据 uid集合
4651
+     * @param array $uidList
4652
+     * @return UserEntity[]
4653
+     */
4654
+    public function getUserEntityListByUidList(array $uidList): array
4655
+    {
4656
+        return $this->dao->getUserEntityListByUidList($uidList);
4657
+    }
4658
+
4659
+    /**
4660
+     * 获取用户实体集合 根据 uid集合
4661
+     * @param array $uidList
4662
+     * @return UserEntity[]
4663
+     */
4664
+    public function getUserEntityMapByUidList(array $uidList): array
4665
+    {
4666
+        $userEntityList = $this->getUserEntityListByUidList($uidList);
4667
+        /** @var UserEntity[] $userEntityMapByUid */
4668
+        $userEntityMapByUid = array_column($userEntityList, null, 'uid');
4669
+        return $userEntityMapByUid;
4670
+    }
4671
+
4672
+    /**
4673
+     * 更新用户积分 并 写入积分变动记录
4674
+     * @param int $uid
4675
+     * @param int $type
4676
+     * @param float $score
4677
+     * @param string $mark
4678
+     * @param string $orderType
4679
+     * @param string $orderId
4680
+     * @return float
4681
+     */
4682
+    public function updateUserScore(int $uid, int $type, float $score, string $mark = '', string $orderType = '', string $orderId = ''): float
4683
+    {
4684
+        $userEntity = $this->getUserEntityByUid($uid);
4685
+        if (empty($userEntity->getUid())) {
4686
+            throw new ValidateException('未查询到用户信息');
4687
+        }
4688
+        if ($type == UserSignScoreEnum::PM['Expend']['code']) {
4689
+            $surplus = bcsub($userEntity->getScore(), $score, 2);
4690
+            if ($surplus < 0.00) {
4691
+                throw new ValidateException('用户积分不足');
4692
+            }
4693
+        } else {
4694
+            $surplus = bcadd($userEntity->getScore(), $score, 2);
4695
+        }
4696
+        try {
4697
+            $this->dao->update($uid, ['score' => $surplus]);
4698
+
4699
+            /** @var UserSignScoreEntity $userSignScoreEntity */
4700
+            $userSignScoreEntity = UserSignScoreEntity::newInstance();
4701
+            $userSignScoreEntity->setUid($uid)
4702
+                ->setPm($type)
4703
+                ->setRewardSocre($score)
4704
+                ->setAddtime(time())
4705
+                ->setStatus(UserSignScoreEnum::STATUS['Valid']['code'])
4706
+                ->setOrderType($orderType)
4707
+                ->setOrderId($orderId)
4708
+                ->setMark($mark)
4709
+                ->setSurplus($surplus);
4710
+
4711
+            /** @var UserSignScoreRepository $userSignScoreRepository */
4712
+            $userSignScoreRepository = app()->make(UserSignScoreRepository::class);
4713
+            $userSignScoreRepository->create($userSignScoreEntity->toUnderlineArray());
4714
+        } catch (DbException $e) {
4715
+            throw new ValidateException('更新积分失败');
4716
+        }
4717
+        return (float)$surplus;
4718
+    }
4719
+
4720
+
4721
+
4722
+    /**
4723
+     * 更新用户Vr 并 写入Vr变动记录
4724
+     * @param int $uid
4725
+     * @param int $type
4726
+     * @param float $vr
4727
+     * @param string $mark
4728
+     * @param string $orderType
4729
+     * @param string $orderId
4730
+     * @return float
4731
+     */
4732
+    public function updateUserVr(int $uid, int $type, float $vr, string $mark = '', string $orderType = '', string $orderId = ''): float
4733
+    {
4734
+        $userEntity = $this->getUserEntityByUid($uid);
4735
+        if (empty($userEntity->getUid())) {
4736
+            throw new ValidateException('未查询到用户信息');
4737
+        }
4738
+        if ($type == UserSignVrEnum::TYPE['Consume']['code']) {
4739
+            $surplus = bcsub($userEntity->getVr(), $vr, 2);
4740
+            if ($surplus < 0.00) {
4741
+                throw new ValidateException('用户VR不足');
4742
+            }
4743
+        } else {
4744
+            $surplus = bcadd($userEntity->getVr(), $vr, 2);
4745
+        }
4746
+        try {
4747
+            $this->dao->update($uid, ['vr' => $surplus]);
4748
+
4749
+            /** @var UserSignVrEntity $userSignVrEntity */
4750
+            $userSignVrEntity = UserSignVrEntity::newInstance();
4751
+            $userSignVrEntity->setUid($uid)
4752
+                ->setType($type)
4753
+                ->setNumber($vr)
4754
+                ->setAddtime(time())
4755
+                ->setOrderType($orderType)
4756
+                ->setOrderId($orderId)
4757
+                ->setMark($mark)
4758
+                ->setSurplus($surplus);
4759
+
4760
+            /** @var UserSignVrRepository $userSignVrRepository */
4761
+            $userSignVrRepository = app()->make(UserSignVrRepository::class);
4762
+            $userSignVrRepository->create($userSignVrEntity->toUnderlineArray());
4763
+        } catch (DbException $e) {
4764
+            throw new ValidateException('更新VR失败');
4765
+        }
4766
+        return (float)$surplus;
4767
+    }
4768
+
4769
+    /**
4770
+     * 更新用户京豆 并 写入 京豆变动记录
4771
+     * @param int $uid
4772
+     * @param int $type
4773
+     * @param float $jingdou
4774
+     * @param string $mark
4775
+     * @param string $orderType
4776
+     * @param string $orderId
4777
+     * @param int $merId
4778
+     * @return float
4779
+     */
4780
+    public function updateUserJingdou(int $uid, int $type, float $jingdou, string $mark = '', string $orderType = '', string $orderId = '', int $merId = 0): float
4781
+    {
4782
+        $userEntity = $this->getUserEntityByUid($uid);
4783
+        if (empty($userEntity->getUid())) {
4784
+            throw new ValidateException('未查询到用户信息');
4785
+        }
4786
+        if ($type == UserSignJingdouEnum::TYPE['Consume']['code']) {
4787
+            $surplus = bcsub($userEntity->getJingdou(), $jingdou, 2);
4788
+            if ($surplus < 0.00) {
4789
+                throw new ValidateException('用户京豆不足');
4790
+            }
4791
+        } else {
4792
+            $surplus = bcadd($userEntity->getJingdou(), $jingdou, 2);
4793
+        }
4794
+        try {
4795
+            $this->dao->update($uid, ['jingdou' => $surplus]);
4796
+
4797
+            /** @var UserSignJingdouEntity $userSignJingdouEntity */
4798
+            $userSignJingdouEntity = UserSignJingdouEntity::newInstance();
4799
+            $userSignJingdouEntity->setUid($uid)
4800
+                ->setType($type)
4801
+                ->setStatus(UserSignJingdouEnum::STATUS['Valid']['code'])
4802
+                ->setNumber($jingdou)
4803
+                ->setAddtime(time())
4804
+                ->setOrderType($orderType)
4805
+                ->setOrderId($orderId)
4806
+                ->setMark($mark)
4807
+                ->setSurplus($surplus);
4808
+
4809
+            /** @var UserSignJingdouRepository $userSignJingdouRepository */
4810
+            $userSignJingdouRepository = app()->make(UserSignJingdouRepository::class);
4811
+            $userSignJingdouRepository->create($userSignJingdouEntity->toUnderlineArray());
4812
+        } catch (DbException $e) {
4813
+            throw new ValidateException('更新京豆失败');
4814
+        }
4815
+        return (float)$surplus;
4816
+    }
4817
+
4818
+    /**
4819
+     * 更新用户复购金 并 写入 复购金变动记录
4820
+     * @param int $uid
4821
+     * @param int $type
4822
+     * @param float $fugou
4823
+     * @param string $mark
4824
+     * @param string $orderType
4825
+     * @param string $orderId
4826
+     * @return float
4827
+     */
4828
+    public function updateUserFugou(int $uid, int $type, float $fugou, string $mark = '', string $orderType = '', string $orderId = ''): float
4829
+    {
4830
+        $userEntity = $this->getUserEntityByUid($uid);
4831
+        if (empty($userEntity->getUid())) {
4832
+            throw new ValidateException('未查询到用户信息');
4833
+        }
4834
+        if ($type == UserSignFugouEnum::TYPE['Consume']['code']) {
4835
+            $surplus = bcsub($userEntity->getFugou(), $fugou, 2);
4836
+            if ($surplus < 0.00) {
4837
+                throw new ValidateException('用户复购金不足');
4838
+            }
4839
+        } else {
4840
+            $surplus = bcadd($userEntity->getFugou(), $fugou, 2);
4841
+        }
4842
+        try {
4843
+            $this->dao->update($uid, ['fugou' => $surplus]);
4844
+
4845
+            /** @var UserSignFugouEntity $userSignFugouEntity */
4846
+            $userSignFugouEntity = UserSignFugouEntity::newInstance();
4847
+            $userSignFugouEntity->setUid($uid)
4848
+                ->setType($type)
4849
+                ->setStatus(UserSignFugouEnum::STATUS['Valid']['code'])
4850
+                ->setNumber($fugou)
4851
+                ->setAddtime(time())
4852
+                ->setOrderType($orderType)
4853
+                ->setOrderId($orderId)
4854
+                ->setMark($mark)
4855
+                ->setSurplus($surplus);
4856
+
4857
+            /** @var UserSignFugouRepository $userSignFugouRepository */
4858
+            $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
4859
+            $userSignFugouRepository->create($userSignFugouEntity->toUnderlineArray());
4860
+        } catch (DbException $e) {
4861
+            throw new ValidateException('更新京豆失败');
4862
+        }
4863
+        return (float)$surplus;
4864
+    }
4865
+
4866
+    /**
4867
+     * 更新用户复购金 并 写入 复购金变动记录
4868
+     * @param int $uid
4869
+     * @param int $recordId
4870
+     * @return float
4871
+     */
4872
+    public function updateUserBrokeragePriceByRecordId(int $uid, int $recordId): float
4873
+    {
4874
+        $userEntity = $this->getUserEntityByUid($uid);
4875
+        if (empty($userEntity->getUid())) {
4876
+            throw new ValidateException('未查询到用户信息');
4877
+        }
4878
+
4879
+        /** @var UserBillRepository $userBillRepository */
4880
+        $userBillRepository = app()->make(UserBillRepository::class);
4881
+        $userBillEntity = $userBillRepository->getUserBillEntityByBillId($recordId);
4882
+        if (empty($userBillEntity->getBillId())) {
4883
+            throw new ValidateException('未查询到佣金记录信息');
4884
+        }
4885
+        if ($userBillEntity->getCommissionType() != UserBillEnum::COMMISSION_TYPE['DIRECT_REFERRAL']['code'] && $userBillEntity->getCommissionType() != UserBillEnum::COMMISSION_TYPE['SHARE_EARNINGS']['code']) {
4886
+            throw new ValidateException('该记录信息非佣金记录');
4887
+        }
4888
+        if ($userBillEntity->getStatus() != UserBillEnum::STATUS['PENDING']['code']) {
4889
+            throw new ValidateException('该记录信息非待分配状态');
4890
+        }
4891
+
4892
+        if ($userBillEntity->getPm() == UserBillEnum::PM['EXPEND']['code']) {
4893
+            $surplus = bcsub($userEntity->getBrokeragePrice(), $userBillEntity->getNumber(), 2);
4894
+            if ($surplus < 0.00) {
4895
+                throw new ValidateException('用户佣金不足');
4896
+            }
4897
+        } else {
4898
+            $surplus = bcadd($userEntity->getBrokeragePrice(), $userBillEntity->getNumber(), 2);
4899
+        }
4900
+        try {
4901
+            $this->dao->update($uid, ['brokerage_price' => $surplus]);
4902
+
4903
+            // 注意 单一
4904
+            // $userBillRepository->updateStatusByBillId($userBillEntity->getBillId(), UserBillEnum::STATUS['VALID']['code']);
4905
+        } catch (DbException $e) {
4906
+            throw new ValidateException('更新京豆失败');
4907
+        }
4908
+        return (float)$surplus;
4909
+    }
4910
+
4911
+    /**
4912
+     * 批量更新
4913
+     * @param $dataList
4914
+     * @return array
4915
+     */
4916
+    public function batchUpdateUserDataByDataList($dataList): array
4917
+    {
4918
+        return $this->dao->saveAll($dataList);
4919
+    }
4612
 }
4920
 }

+ 73 - 0
app/common/repositories/user/UserSignFenrunRepository.php

@@ -0,0 +1,73 @@
1
+<?php
2
+
3
+namespace app\common\repositories\user;
4
+
5
+use app\common\dao\user\UserSignFenrunDao;
6
+use app\common\enum\user\UserSignFenrunEnum;
7
+use app\common\repositories\BaseRepository;
8
+use app\common\repositories\store\order\StoreOrderRepository;
9
+use app\entity\data\user\UserSignFenrunEntity;
10
+use think\exception\ValidateException;
11
+
12
+class UserSignFenrunRepository extends BaseRepository
13
+{
14
+    public function __construct(UserSignFenrunDao $dao)
15
+    {
16
+        $this->dao = $dao;
17
+    }
18
+
19
+    public function create($data)
20
+    {
21
+        return $this->dao->create($data);
22
+    }
23
+
24
+    /**
25
+     * 写入分润记录
26
+     * @param UserSignFenrunEntity $userSignFenrunEntity
27
+     * @return UserSignFenrunEntity
28
+     */
29
+    public function createByEntity(UserSignFenrunEntity $userSignFenrunEntity): UserSignFenrunEntity
30
+    {
31
+        $result = $this->dao->create($userSignFenrunEntity->toUnderlineArray())->toArray();
32
+        /** @var UserSignFenrunEntity $entity */
33
+        $entity = UserSignFenrunEntity::newInstance($result);
34
+        return $entity;
35
+    }
36
+
37
+    /**
38
+     * 添加分润记录
39
+     * @param int $uid
40
+     * @param float $number
41
+     * @param string $mark
42
+     * @param string $orderType
43
+     * @param string $orderId
44
+     * @return UserSignFenrunEntity
45
+     */
46
+    public function addUserSingFenrun(int $uid, float $number, string $mark = '', string $orderType = '', string $orderId = ''): UserSignFenrunEntity
47
+    {
48
+        if (!empty($orderType)) {
49
+            if (!empty($orderId)) {
50
+                if ($orderType == UserSignFenrunEnum::ORDER_TYPE['Platform']['code']) {
51
+                    /** @var StoreOrderRepository $storeOrderRepository */
52
+                    $storeOrderRepository = app()->make(StoreOrderRepository::class);
53
+                    $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId((int)$orderId);
54
+                    if (empty($storeOrderEntity->getOrderId())) {
55
+                        throw new ValidateException('未查询到订单信息');
56
+                    }
57
+                }
58
+            }
59
+        }
60
+
61
+        /** @var UserSignFenrunEntity $userSignFenrunEntity */
62
+        $userSignFenrunEntity = UserSignFenrunEntity::newInstance();
63
+        $userSignFenrunEntity->setUid($uid)
64
+            ->setNumber($number)
65
+            ->setMark($mark)
66
+            ->setOrderType($orderType)
67
+            ->setOrderId($orderId)
68
+            ->setAddtime(time())
69
+            ->setStatus(UserSignFenrunEnum::STATUS['Unsettled']['code']);
70
+
71
+        return $this->createByEntity($userSignFenrunEntity);
72
+    }
73
+}

+ 236 - 0
app/common/repositories/user/UserSignFugouRepository.php

@@ -0,0 +1,236 @@
1
+<?php
2
+
3
+namespace app\common\repositories\user;
4
+
5
+use app\common\dao\user\UserSignFugouDao;
6
+use app\common\enum\user\UserSignFugouEnum;
7
+use app\common\repositories\BaseRepository;
8
+use app\common\repositories\store\order\StoreOrderRepository;
9
+use app\entity\data\user\UserEntity;
10
+use app\entity\data\user\UserSignFugouEntity;
11
+use think\db\exception\DbException;
12
+use think\exception\ValidateException;
13
+
14
+class UserSignFugouRepository extends BaseRepository
15
+{
16
+    public function __construct(UserSignFugouDao $dao)
17
+    {
18
+        $this->dao = $dao;
19
+    }
20
+
21
+    /**
22
+     * @param int $id
23
+     * @return UserSignFugouEntity
24
+     */
25
+    public function getUserSignFugouEntityById(int $id): UserSignFugouEntity
26
+    {
27
+        $entityList = $this->getUserSignFugouEntityListByIdList([$id]);
28
+        $entity = array_shift($entityList);
29
+        if ($entity instanceof UserSignFugouEntity) {
30
+            return $entity;
31
+        } else {
32
+            /** @var UserSignFugouEntity */
33
+            return UserSignFugouEntity::newInstance();
34
+        }
35
+    }
36
+
37
+    /**
38
+     * @param array $idList
39
+     * @return UserSignFugouEntity[]
40
+     */
41
+    public function getUserSignFugouEntityListByIdList(array $idList): array
42
+    {
43
+        return $this->dao->getUserSignFugouEntityListByIdList($idList);
44
+    }
45
+
46
+    /**
47
+     * @param string $orderType
48
+     * @param array $orderIdList
49
+     * @return UserSignFugouEntity[]
50
+     */
51
+    public function getUserSignFugouEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
52
+    {
53
+        return $this->dao->getUserSignFugouEntityListByOrderIdListAndPending($orderType, $orderIdList);
54
+    }
55
+
56
+    public function create($data)
57
+    {
58
+        return $this->dao->create($data);
59
+    }
60
+
61
+    /**
62
+     * 写入 复购金 记录
63
+     * @param UserSignFugouEntity $userSignFugouEntity
64
+     * @return UserSignFugouEntity
65
+     */
66
+    public function createByEntity(UserSignFugouEntity $userSignFugouEntity): UserSignFugouEntity
67
+    {
68
+        $result = $this->dao->create($userSignFugouEntity->toUnderlineArray())->toArray();
69
+        /** @var UserSignFugouEntity $entity */
70
+        $entity = UserSignFugouEntity::newInstance($result);
71
+        return $entity;
72
+    }
73
+
74
+    /**
75
+     * 添加 复购金记录
76
+     * @param int $uid
77
+     * @param int $type
78
+     * @param float $number
79
+     * @param int $commissionType
80
+     * @param string $mark
81
+     * @param string $orderType
82
+     * @param string $orderId
83
+     * @return UserSignFugouEntity
84
+     */
85
+    public function addUserSingFugou(int $uid, int $type, float $number, int $commissionType, string $mark = '', string $orderType = '', string $orderId = ''): UserSignFugouEntity
86
+    {
87
+        if (!empty($orderType)) {
88
+            if (!empty($orderId)) {
89
+                if ($orderType == UserSignFugouEnum::ORDER_TYPE['Platform']['code']) {
90
+                    /** @var StoreOrderRepository $storeOrderRepository */
91
+                    $storeOrderRepository = app()->make(StoreOrderRepository::class);
92
+                    $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId((int)$orderId);
93
+                    if (empty($storeOrderEntity->getOrderId())) {
94
+                        throw new ValidateException('未查询到订单信息');
95
+                    }
96
+                }
97
+            }
98
+        }
99
+
100
+        /** @var UserSignFugouEntity $userSignFugouEntity */
101
+        $userSignFugouEntity = UserSignFugouEntity::newInstance();
102
+        $userSignFugouEntity->setUid($uid)
103
+            ->setType($type)
104
+            ->setNumber($number)
105
+            ->setCommissionType($commissionType)
106
+            ->setMark($mark)
107
+            ->setOrderType($orderType)
108
+            ->setOrderId($orderId)
109
+            ->setAddtime(time())
110
+            ->setStatus(UserSignFugouEnum::STATUS['Pending']['code']);
111
+
112
+        return $this->createByEntity($userSignFugouEntity);
113
+    }
114
+
115
+    /**
116
+     * 将 复购 记录设置为生效状态 并对用户的 复购 字段进行增减
117
+     * @param int $id
118
+     * @return int
119
+     */
120
+    public function execute(int $id): int
121
+    {
122
+        $result = $this->executeByIdList([$id]);
123
+        return array_shift($result);
124
+    }
125
+
126
+    /**
127
+     * 将 复购 记录设置为生效状态 并对用户的 复购 字段进行增减
128
+     * @param array $idList
129
+     * @return array
130
+     */
131
+    public function executeByIdList(array $idList): array
132
+    {
133
+        $userSignFugouEntityList = $this->getUserSignFugouEntityListByIdList($idList);
134
+        $userIdList = [];
135
+
136
+        // 忽略 已经生效的 记录
137
+        $userSignFugouEntityList = array_filter($userSignFugouEntityList, function ($entity) use (&$userIdList) {
138
+            // 积分数据不为空 用户不为空 状态属于待结算 并且结算字段为空
139
+            if ((!empty($entity->getId()) && !empty($entity->getUid()) && ($entity->getStatus() == UserSignFugouEnum::STATUS['Pending']['code']) && empty($entity->getSettlementTime()))) {
140
+                $userIdList[] = $entity->getUid();
141
+                return true;
142
+            }
143
+            return false;
144
+        });
145
+
146
+        if (!empty($userSignFugouEntityList)) {
147
+            // 获取用户 映射信息
148
+            /** @var UserRepository $userRepository */
149
+            $userRepository = app()->make(UserRepository::class);
150
+            /** @var UserEntity[] $userEntityMapByUid */
151
+            $userEntityMapByUid = [];
152
+            if (!empty($userIdList)) {
153
+                $userEntityMapByUid = $userRepository->getUserEntityMapByUidList($userIdList);
154
+            }
155
+
156
+            /** @var UserEntity[] $updateUserEntityList */
157
+            $updateUserEntityList = [];
158
+            /** @var UserSignFugouEntity[] $updateUserFugouEntityList */
159
+            $updateUserFugouEntityList = [];
160
+            foreach ($userSignFugouEntityList as $userSignFugouEntity) {
161
+
162
+                $userEntity = $userEntityMapByUid[$userSignFugouEntity->getUid()];
163
+                if (empty($userEntity) || empty($userEntity->getUid())) {
164
+                    throw new ValidateException("未查询到用户信息(FugouId:{$userSignFugouEntity->getId()})");
165
+                }
166
+
167
+                // 组建 更新 用户信息
168
+                if (isset($updateUserEntityList[$userEntity->getUid()])) {
169
+                    $updateUserEntity = $updateUserEntityList[$userEntity->getUid()];
170
+                } else {
171
+                    /** @var UserEntity $updateUserEntity */
172
+                    $updateUserEntity = UserEntity::newInstance();
173
+                    $updateUserEntity
174
+                        ->setUid($userEntity->getUid())
175
+                        ->setFugou($userEntity->getFugou());
176
+
177
+                }
178
+                // 组建 账单 记录
179
+                if (isset($updateUserFugouEntityList[$userSignFugouEntity->getId()])) {
180
+                    $updateUserSignFugouEntity = $updateUserFugouEntityList[$userSignFugouEntity->getId()];
181
+                } else {
182
+                    /** @var UserSignFugouEntity $updateUserSignFugouEntity */
183
+                    $updateUserSignFugouEntity = UserSignFugouEntity::newInstance();
184
+                    // 更新 账单记录 状态
185
+                    $updateUserSignFugouEntity
186
+                        ->setId($userSignFugouEntity->getId())
187
+                        ->setStatus(UserSignFugouEnum::STATUS['Valid']['code'])
188
+                        ->setSettlementTime(date('Y-m-d H:i:s'));
189
+                }
190
+
191
+                if ($userSignFugouEntity->getType() == UserSignFugouEnum::TYPE['Consume']['code']) {
192
+                    // 支出
193
+                    $updateUserEntity->setFugou(bcsub($updateUserEntity->getFugou(), $userSignFugouEntity->getNumber(), 2));
194
+                    if ($updateUserEntity->getFugou() < 0.00) {
195
+                        throw new ValidateException('用户复购金不足');
196
+                    }
197
+                } else {
198
+                    $updateUserEntity->setFugou(bcadd($updateUserEntity->getFugou(), $userSignFugouEntity->getNumber(), 2));
199
+                }
200
+                $updateUserSignFugouEntity->setSurplus($updateUserEntity->getFugou());
201
+
202
+                $updateUserEntityList[$userSignFugouEntity->getUid()] = $updateUserEntity;
203
+                $updateUserFugouEntityList[$userSignFugouEntity->getId()] = $updateUserSignFugouEntity;
204
+            }
205
+            try {
206
+                if (!empty($updateUserEntityList)) {
207
+                    $userRepository->batchUpdateUserDataByDataList(
208
+                        array_map(function (UserEntity $updateUserEntity) {
209
+                            return $updateUserEntity->toUnderlineArray();
210
+                        }, $updateUserEntityList)
211
+                    );
212
+                }
213
+
214
+                if (!empty($updateUserFugouEntityList)) {
215
+                    $this->batchUpdateUserSignFugouDataByDataList(
216
+                        array_map(function (UserSignFugouEntity $updateUserSignFugouEntity) {
217
+                            return $updateUserSignFugouEntity->toUnderlineArray();
218
+                        }, $updateUserFugouEntityList)
219
+                    );
220
+                }
221
+            } catch (\Exception $e) {
222
+                throw new ValidateException('用户复购金结算失败');
223
+            }
224
+        }
225
+        return $idList;
226
+    }
227
+
228
+    /**
229
+     * @param $dataList
230
+     * @return array
231
+     */
232
+    public function batchUpdateUserSignFugouDataByDataList($dataList): array
233
+    {
234
+        return $this->dao->saveAll($dataList);
235
+    }
236
+}

+ 236 - 0
app/common/repositories/user/UserSignGongxianRepository.php

@@ -0,0 +1,236 @@
1
+<?php
2
+
3
+namespace app\common\repositories\user;
4
+
5
+use app\common\dao\user\UserSignGongxianDao;
6
+use app\common\enum\user\UserSignGongxianEnum;
7
+use app\common\repositories\BaseRepository;
8
+use app\common\repositories\store\order\StoreOrderRepository;
9
+use app\entity\data\user\UserEntity;
10
+use app\entity\data\user\UserSignGongxianEntity;
11
+use think\db\exception\DbException;
12
+use think\exception\ValidateException;
13
+
14
+class UserSignGongxianRepository extends BaseRepository
15
+{
16
+    public function __construct(UserSignGongxianDao $dao)
17
+    {
18
+        $this->dao = $dao;
19
+    }
20
+
21
+    /**
22
+     * @param int $id
23
+     * @return UserSignGongxianEntity
24
+     */
25
+    public function getUserSignGongxianEntityById(int $id): UserSignGongxianEntity
26
+    {
27
+        $entityList = $this->getUserSignGongxianEntityListByIdList([$id]);
28
+        $entity = array_shift($entityList);
29
+        if ($entity instanceof UserSignGongxianEntity) {
30
+            return $entity;
31
+        } else {
32
+            /** @var UserSignGongxianEntity */
33
+            return UserSignGongxianEntity::newInstance();
34
+        }
35
+    }
36
+
37
+    /**
38
+     * @param array $idList
39
+     * @return UserSignGongxianEntity[]
40
+     */
41
+    public function getUserSignGongxianEntityListByIdList(array $idList): array
42
+    {
43
+        return $this->dao->getUserSignGongxianEntityListByIdList($idList);
44
+    }
45
+
46
+    /**
47
+     * @param string $orderType
48
+     * @param array $orderIdList
49
+     * @return UserSignGongxianEntity[]
50
+     */
51
+    public function getUserSignGongxianEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
52
+    {
53
+        return $this->dao->getUserSignGongxianEntityListByOrderIdListAndPending($orderType, $orderIdList);
54
+    }
55
+
56
+    public function create($data)
57
+    {
58
+        return $this->dao->create($data);
59
+    }
60
+
61
+    /**
62
+     * 写入贡献值记录
63
+     * @param UserSignGongxianEntity $userSignGongxianEntity
64
+     * @return UserSignGongxianEntity
65
+     */
66
+    public function createByEntity(UserSignGongxianEntity $userSignGongxianEntity): UserSignGongxianEntity
67
+    {
68
+        $result = $this->dao->create($userSignGongxianEntity->toUnderlineArray())->toArray();
69
+        /** @var UserSignGongxianEntity $entity */
70
+        $entity = UserSignGongxianEntity::newInstance($result);
71
+        return $entity;
72
+    }
73
+
74
+    /**
75
+     * 添加贡献值记录
76
+     * @param int $uid
77
+     * @param int $type
78
+     * @param float $number
79
+     * @param string $mark
80
+     * @param string $orderType
81
+     * @param string $orderId
82
+     * @return UserSignGongxianEntity
83
+     */
84
+    public function addUserSingGongxian(int $uid, int $type, float $number, string $mark = '', string $orderType = '', string $orderId = ''): UserSignGongxianEntity
85
+    {
86
+        $merId = 0;
87
+        if (!empty($orderType)) {
88
+            if (!empty($orderId)) {
89
+                if ($orderType == UserSignGongxianEnum::ORDER_TYPE['Platform']['code']) {
90
+                    /** @var StoreOrderRepository $storeOrderRepository */
91
+                    $storeOrderRepository = app()->make(StoreOrderRepository::class);
92
+                    $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId((int)$orderId);
93
+                    if (empty($storeOrderEntity->getOrderId())) {
94
+                        throw new ValidateException('未查询到订单信息');
95
+                    }
96
+                    $merId = $storeOrderEntity->getMerId();
97
+                }
98
+            }
99
+        }
100
+
101
+        /** @var UserSignGongxianEntity $userSignGongxianEntity */
102
+        $userSignGongxianEntity = UserSignGongxianEntity::newInstance();
103
+        $userSignGongxianEntity->setUid($uid)
104
+            ->setType($type)
105
+            ->setNumber($number)
106
+            ->setMark($mark)
107
+            ->setOrderType($orderType)
108
+            ->setOrderId($orderId)
109
+            ->setMerId($merId)
110
+            ->setAddtime(time())
111
+            ->setStatus(UserSignGongxianEnum::STATUS['PendingConfirmation']['code']);
112
+
113
+        return $this->createByEntity($userSignGongxianEntity);
114
+    }
115
+
116
+    /**
117
+     * 将 贡献值 直推贡献值 记录设置为生效状态 并对用户的 贡献值 直推贡献值 字段进行增减
118
+     * @param array $idList
119
+     * @return array
120
+     */
121
+    public function executeByIdList(array $idList): array
122
+    {
123
+        $userSignGongxianEntityList = $this->getUserSignGongxianEntityListByIdList($idList);
124
+        $userIdList = [];
125
+
126
+        // 忽略 已经生效的 记录
127
+        $userSignGongxianEntityList = array_filter($userSignGongxianEntityList, function ($entity) use (&$userIdList) {
128
+            // 积分数据不为空 用户不为空 状态属于待结算 并且结算字段为空
129
+            if ((!empty($entity->getId()) && !empty($entity->getUid()) && ($entity->getStatus() == UserSignGongxianEnum::STATUS['PendingConfirmation']['code']) && empty($entity->getSettlementTime()))) {
130
+                $userIdList[] = $entity->getUid();
131
+                return true;
132
+            }
133
+            return false;
134
+        });
135
+
136
+        if (!empty($userSignGongxianEntityList)) {
137
+            // 获取用户 映射信息
138
+            /** @var UserRepository $userRepository */
139
+            $userRepository = app()->make(UserRepository::class);
140
+            /** @var UserEntity[] $userEntityMapByUid */
141
+            $userEntityMapByUid = [];
142
+            if (!empty($userIdList)) {
143
+                $userEntityMapByUid = $userRepository->getUserEntityMapByUidList($userIdList);
144
+            }
145
+
146
+            /** @var UserEntity[] $updateUserEntityList */
147
+            $updateUserEntityList = [];
148
+            /** @var UserSignGongxianEntity[] $updateUserScoreEntityList */
149
+            $updateUserScoreEntityList = [];
150
+            foreach ($userSignGongxianEntityList as $userSignGongxianEntity) {
151
+
152
+                $userEntity = $userEntityMapByUid[$userSignGongxianEntity->getUid()];
153
+                if (empty($userEntity) || empty($userEntity->getUid())) {
154
+                    throw new ValidateException("未查询到用户信息(GongxianId:{$userSignGongxianEntity->getId()})");
155
+                }
156
+
157
+                // 组建 更新 用户信息
158
+                if (isset($updateUserEntityList[$userEntity->getUid()])) {
159
+                    $updateUserEntity = $updateUserEntityList[$userEntity->getUid()];
160
+                } else {
161
+                    /** @var UserEntity $updateUserEntity */
162
+                    $updateUserEntity = UserEntity::newInstance();
163
+                    $updateUserEntity
164
+                        ->setUid($userEntity->getUid())
165
+                        ->setContribute($userEntity->getContribute())
166
+                        ->setPerContribute($userEntity->getPerContribute());
167
+                }
168
+                // 组建 账单 记录
169
+                if (isset($updateUserScoreEntityList[$userSignGongxianEntity->getId()])) {
170
+                    $updateUserSignGongxianEntity = $updateUserScoreEntityList[$userSignGongxianEntity->getId()];
171
+                } else {
172
+                    /** @var UserSignGongxianEntity $updateUserSignGongxianEntity */
173
+                    $updateUserSignGongxianEntity = UserSignGongxianEntity::newInstance();
174
+                    // 更新 账单记录 状态
175
+                    $updateUserSignGongxianEntity
176
+                        ->setId($userSignGongxianEntity->getId())
177
+                        ->setStatus(UserSignGongxianEnum::STATUS['Valid']['code'])
178
+                        ->setSettlementTime(date('Y-m-d H:i:s'));
179
+                }
180
+
181
+                if ($userSignGongxianEntity->getType() == UserSignGongxianEnum::TYPE['Consume']['code']) {
182
+                    // 消耗
183
+                    if (strpos($userSignGongxianEntity->getMark(), '购买') !== false) {
184
+                        $updateUserEntity->setContribute(bcsub($updateUserEntity->getContribute(), $userSignGongxianEntity->getNumber(), 2));
185
+                        if ($updateUserEntity->getContribute() < 0.00) {
186
+                            throw new ValidateException('用户贡献值不足');
187
+                        }
188
+                        $updateUserSignGongxianEntity->setSurplus($updateUserEntity->getContribute());
189
+                    } else if (strpos($userSignGongxianEntity->getMark(), '推广') !== false) {
190
+                        $updateUserEntity->setPerContribute(bcsub($updateUserEntity->getPerContribute(), $userSignGongxianEntity->getNumber(), 2));
191
+                        if ($updateUserEntity->getPerContribute() < 0.00) {
192
+                            throw new ValidateException('用户推广贡献值不足');
193
+                        }
194
+                        $updateUserSignGongxianEntity->setSurplus($updateUserEntity->getPerContribute());
195
+                    }
196
+                } else {
197
+                    if (strpos($userSignGongxianEntity->getMark(), '购买') !== false) {
198
+                        $updateUserEntity->setContribute(bcadd($updateUserEntity->getContribute(), $userSignGongxianEntity->getNumber(), 2));
199
+                        $updateUserSignGongxianEntity->setSurplus($updateUserEntity->getContribute());
200
+                    } else if (strpos($userSignGongxianEntity->getMark(), '推广') !== false) {
201
+                        $updateUserEntity->setPerContribute(bcadd($updateUserEntity->getPerContribute(), $userSignGongxianEntity->getNumber(), 2));
202
+                        $updateUserSignGongxianEntity->setSurplus($updateUserEntity->getPerContribute());
203
+                    }
204
+                }
205
+
206
+                $updateUserEntityList[$userSignGongxianEntity->getUid()] = $updateUserEntity;
207
+                $updateUserScoreEntityList[$userSignGongxianEntity->getId()] = $updateUserSignGongxianEntity;
208
+            }
209
+            if (!empty($updateUserEntityList)) {
210
+                $userRepository->batchUpdateUserDataByDataList(
211
+                    array_map(function (UserEntity $updateUserEntity) {
212
+                        return $updateUserEntity->toUnderlineArray();
213
+                    }, $updateUserEntityList)
214
+                );
215
+            }
216
+
217
+            if (!empty($updateUserScoreEntityList)) {
218
+                $this->batchUpdateUserSignGongxianDataByDataList(
219
+                    array_map(function (UserSignGongxianEntity $updateUserSignGongxianEntity) {
220
+                        return $updateUserSignGongxianEntity->toUnderlineArray();
221
+                    }, $updateUserScoreEntityList)
222
+                );
223
+            }
224
+        }
225
+        return $idList;
226
+    }
227
+
228
+    /**
229
+     * @param $dataList
230
+     * @return array
231
+     */
232
+    public function batchUpdateUserSignGongxianDataByDataList($dataList): array
233
+    {
234
+        return $this->dao->saveAll($dataList);
235
+    }
236
+}

+ 218 - 0
app/common/repositories/user/UserSignHongbaoRepository.php

@@ -0,0 +1,218 @@
1
+<?php
2
+
3
+namespace app\common\repositories\user;
4
+
5
+use app\common\dao\user\UserSignHongbaoDao;
6
+use app\common\enum\user\UserSignHongbaoEnum;
7
+use app\common\repositories\BaseRepository;
8
+use app\common\repositories\store\order\StoreOrderRepository;
9
+use app\entity\data\user\UserEntity;
10
+use app\entity\data\user\UserSignHongbaoEntity;
11
+use think\db\exception\DbException;
12
+use think\exception\ValidateException;
13
+
14
+class UserSignHongbaoRepository extends BaseRepository
15
+{
16
+    public function __construct(UserSignHongbaoDao $dao)
17
+    {
18
+        $this->dao = $dao;
19
+    }
20
+
21
+    /**
22
+     * @param int $id
23
+     * @return UserSignHongbaoEntity
24
+     */
25
+    public function getUserSignHongbaoEntityById(int $id): UserSignHongbaoEntity
26
+    {
27
+        $entityList = $this->getUserSignHongbaoEntityListByIdList([$id]);
28
+        $entity = array_shift($entityList);
29
+        if ($entity instanceof UserSignHongbaoEntity) {
30
+            return $entity;
31
+        } else {
32
+            /** @var UserSignHongbaoEntity */
33
+            return UserSignHongbaoEntity::newInstance();
34
+        }
35
+    }
36
+
37
+    /**
38
+     * @param array $idList
39
+     * @return UserSignHongbaoEntity[]
40
+     */
41
+    public function getUserSignHongbaoEntityListByIdList(array $idList): array
42
+    {
43
+        return $this->dao->getUserSignHongbaoEntityListByIdList($idList);
44
+    }
45
+
46
+    /**
47
+     * @param string $orderType
48
+     * @param array $orderIdList
49
+     * @return UserSignHongbaoEntity[]
50
+     */
51
+    public function getUserSignHongbaoEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
52
+    {
53
+        return $this->dao->getUserSignHongbaoEntityListByOrderIdListAndPending($orderType, $orderIdList);
54
+    }
55
+
56
+    public function create($data)
57
+    {
58
+        return $this->dao->create($data);
59
+    }
60
+
61
+    /**
62
+     * 写入红包记录
63
+     * @param UserSignHongbaoEntity $userSignHongbaoEntity
64
+     * @return UserSignHongbaoEntity
65
+     */
66
+    public function createByEntity(UserSignHongbaoEntity $userSignHongbaoEntity): UserSignHongbaoEntity
67
+    {
68
+        $result = $this->dao->create($userSignHongbaoEntity->toUnderlineArray())->toArray();
69
+        /** @var UserSignHongbaoEntity $entity */
70
+        $entity = UserSignHongbaoEntity::newInstance($result);
71
+        return $entity;
72
+    }
73
+
74
+    /**
75
+     * 添加红包记录
76
+     * @param int $uid
77
+     * @param int $type
78
+     * @param float $number
79
+     * @param string $mark
80
+     * @param string $orderType
81
+     * @param string $orderId
82
+     * @return UserSignHongbaoEntity
83
+     */
84
+    public function addUserSingHongbao(int $uid, int $type, float $number, string $mark = '', string $orderType = '', string $orderId = ''): UserSignHongbaoEntity
85
+    {
86
+        if (!empty($orderType)) {
87
+            if (!empty($orderId)) {
88
+                if ($orderType == UserSignHongbaoEnum::ORDER_TYPE['Platform']['code']) {
89
+                    /** @var StoreOrderRepository $storeOrderRepository */
90
+                    $storeOrderRepository = app()->make(StoreOrderRepository::class);
91
+                    $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId((int)$orderId);
92
+                    if (empty($storeOrderEntity->getOrderId())) {
93
+                        throw new ValidateException('未查询到订单信息');
94
+                    }
95
+                }
96
+            }
97
+        }
98
+
99
+        /** @var UserSignHongbaoEntity $userSignHongbaoEntity */
100
+        $userSignHongbaoEntity = UserSignHongbaoEntity::newInstance();
101
+        $userSignHongbaoEntity->setUid($uid)
102
+            ->setType($type)
103
+            ->setNumber($number)
104
+            ->setMark($mark)
105
+            ->setOrderType($orderType)
106
+            ->setOrderId($orderId)
107
+            ->setAddtime(time())
108
+            ->setStatus(UserSignHongbaoEnum::STATUS['PendingConfirmation']['code']);
109
+
110
+        return $this->createByEntity($userSignHongbaoEntity);
111
+    }
112
+
113
+    /**
114
+     * 将 贡献值 直推贡献值 记录设置为生效状态 并对用户的 贡献值 直推贡献值 字段进行增减
115
+     * @param array $idList
116
+     * @return array
117
+     */
118
+    public function executeByIdList(array $idList): array
119
+    {
120
+        $userSignHongbaoEntityList = $this->getUserSignHongbaoEntityListByIdList($idList);
121
+        $userIdList = [];
122
+
123
+        // 忽略 已经生效的 记录
124
+        $userSignHongbaoEntityList = array_filter($userSignHongbaoEntityList, function ($entity) use (&$userIdList) {
125
+            // 积分数据不为空 用户不为空 状态属于待结算 并且结算字段为空
126
+            if ((!empty($entity->getId()) && !empty($entity->getUid()) && ($entity->getStatus() == UserSignHongbaoEnum::STATUS['PendingConfirmation']['code']) && empty($entity->getSettlementTime()))) {
127
+                $userIdList[] = $entity->getUid();
128
+                return true;
129
+            }
130
+            return false;
131
+        });
132
+
133
+        if (!empty($userSignHongbaoEntityList)) {
134
+            // 获取用户 映射信息
135
+            /** @var UserRepository $userRepository */
136
+            $userRepository = app()->make(UserRepository::class);
137
+            /** @var UserEntity[] $userEntityMapByUid */
138
+            $userEntityMapByUid = [];
139
+            if (!empty($userIdList)) {
140
+                $userEntityMapByUid = $userRepository->getUserEntityMapByUidList($userIdList);
141
+            }
142
+
143
+            /** @var UserEntity[] $updateUserEntityList */
144
+            $updateUserEntityList = [];
145
+            /** @var UserSignHongbaoEntity[] $updateUserSignHongbaoEntityList */
146
+            $updateUserSignHongbaoEntityList = [];
147
+            foreach ($userSignHongbaoEntityList as $userSignHongbaoEntity) {
148
+
149
+                $userEntity = $userEntityMapByUid[$userSignHongbaoEntity->getUid()];
150
+                if (empty($userEntity) || empty($userEntity->getUid())) {
151
+                    throw new ValidateException("未查询到用户信息(HongbaoId:{$userSignHongbaoEntity->getId()})");
152
+                }
153
+
154
+                // 组建 更新 用户信息
155
+                if (isset($updateUserEntityList[$userEntity->getUid()])) {
156
+                    $updateUserEntity = $updateUserEntityList[$userEntity->getUid()];
157
+                } else {
158
+                    /** @var UserEntity $updateUserEntity */
159
+                    $updateUserEntity = UserEntity::newInstance();
160
+                    $updateUserEntity
161
+                        ->setUid($userEntity->getUid())
162
+                        ->setHongbao($userEntity->getHongbao());
163
+                }
164
+                // 组建 账单 记录
165
+                if (isset($updateUserSignHongbaoEntityList[$userSignHongbaoEntity->getId()])) {
166
+                    $updateUserSignHongbaoEntity = $updateUserSignHongbaoEntityList[$userSignHongbaoEntity->getId()];
167
+                } else {
168
+                    /** @var UserSignHongbaoEntity $updateUserSignHongbaoEntity */
169
+                    $updateUserSignHongbaoEntity = UserSignHongbaoEntity::newInstance();
170
+                    // 更新 账单记录 状态
171
+                    $updateUserSignHongbaoEntity
172
+                        ->setId($userSignHongbaoEntity->getId())
173
+                        ->setStatus(UserSignHongbaoEnum::STATUS['Valid']['code'])
174
+                        ->setSettlementTime(date('Y-m-d H:i:s'));
175
+                }
176
+
177
+                if ($userSignHongbaoEntity->getType() == UserSignHongbaoEnum::TYPE['Consumption']['code']) {
178
+                    // 消耗
179
+                    $updateUserEntity->setHongbao(bcsub($updateUserEntity->getHongbao(), $userSignHongbaoEntity->getNumber(), 2));
180
+                    if ($updateUserEntity->getHongbao() < 0.00) {
181
+                        throw new ValidateException('用户红包不足');
182
+                    }
183
+                } else {
184
+                    $updateUserEntity->setHongbao(bcadd($updateUserEntity->getHongbao(), $userSignHongbaoEntity->getNumber(), 2));
185
+                }
186
+                $updateUserSignHongbaoEntity->setSurplus($updateUserEntity->getHongbao());
187
+
188
+                $updateUserEntityList[$userSignHongbaoEntity->getUid()] = $updateUserEntity;
189
+                $updateUserSignHongbaoEntityList[$userSignHongbaoEntity->getId()] = $updateUserSignHongbaoEntity;
190
+            }
191
+            if (!empty($updateUserEntityList)) {
192
+                $userRepository->batchUpdateUserDataByDataList(
193
+                    array_map(function (UserEntity $updateUserEntity) {
194
+                        return $updateUserEntity->toUnderlineArray();
195
+                    }, $updateUserEntityList)
196
+                );
197
+            }
198
+
199
+            if (!empty($updateUserBillEntityList)) {
200
+                $this->batchUpdateUserSignHongbaoDataByDataList(
201
+                    array_map(function (UserSignHongbaoEntity $updateUserSignHongbaoEntity) {
202
+                        return $updateUserSignHongbaoEntity->toUnderlineArray();
203
+                    }, $updateUserSignHongbaoEntityList)
204
+                );
205
+            }
206
+        }
207
+        return $idList;
208
+    }
209
+
210
+    /**
211
+     * @param $dataList
212
+     * @return array
213
+     */
214
+    public function batchUpdateUserSignHongbaoDataByDataList($dataList): array
215
+    {
216
+        return $this->dao->saveAll($dataList);
217
+    }
218
+}

+ 0 - 0
app/common/repositories/user/UserSignJingdouRepository.php


部分文件因文件數量過多而無法顯示