sunxbiao 5 mesi fa
parent
commit
244354da58

+ 41 - 0
app/common/dao/shared/SharedProsperityRewardRecordDao.php

@@ -0,0 +1,41 @@
1
+<?php
2
+
3
+namespace app\common\dao\shared;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\shared\SharedProsperityRewardRecord;
7
+use app\entity\data\shared\SharedProsperityRewardRecordEntity;
8
+
9
+class SharedProsperityRewardRecordDao extends BaseDao
10
+{
11
+
12
+    protected function getModel(): string
13
+    {
14
+        return SharedProsperityRewardRecord::class;
15
+    }
16
+
17
+    /**
18
+     * @param array $idList
19
+     * @return SharedProsperityRewardRecordEntity[]
20
+     */
21
+    public function getSharedProsperityRewardRecordEntityListByIdList(array $idList): array
22
+    {
23
+        $entityList = [];
24
+        try {
25
+            /** @var SharedProsperityRewardRecord $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 SharedProsperityRewardRecordEntity::newInstance($data);
34
+                }, $dataRes);
35
+            }
36
+        } catch (\Exception $e) {
37
+
38
+        }
39
+        return $entityList;
40
+    }
41
+}

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

@@ -639,6 +639,31 @@ class StoreOrderDao extends BaseDao
639 639
     }
640 640
 
641 641
     /**
642
+     * @param array $orderSnList
643
+     * @return CommonEntity[]
644
+     */
645
+    public function getStoreOrderEntityListByOrderSnList(array $orderSnList): array
646
+    {
647
+        $entityList = [];
648
+        try {
649
+            /** @var StoreOrder $model */
650
+            $model = $this->getModel();
651
+            $dataRes = $model::getDB()
652
+                ->whereIn('order_sn', $orderSnList)
653
+                ->select()
654
+                ->toArray();
655
+            if (!empty($dataRes)) {
656
+                $entityList = array_map(function ($data) {
657
+                    return StoreOrderEntity::newInstance($data);
658
+                }, $dataRes);
659
+            }
660
+        } catch (\Exception $e) {
661
+
662
+        }
663
+        return $entityList;
664
+    }
665
+
666
+    /**
642 667
      * @param array $groupOrderIdList
643 668
      * @return CommonEntity[]
644 669
      */

+ 15 - 3
app/common/enum/CommonEnum.php

@@ -255,13 +255,25 @@ class CommonEnum
255 255
         // 共富区
256 256
         'SharedProsperity' => [
257 257
             'Self' => [
258
-                'YangLaoJin' => [ // 钱
259
-                    'Ratio' => ['code' => 0.7 * 0.1, 'name' => '将利润(PV)的70%中的10%,当做养老金分配给下单人']
258
+                'YangLaoJin' => [
259
+                    'Ratio' => ['code' => 0.05, 'name' => '将订单消费金额的5%,当做养老金分配给下单人']
260
+                ],
261
+                'Pv' => [
262
+                    'Ratio' => ['code' => 1, 'name' => '将利润的100%,作为PV值分配给下单人']
263
+                ],
264
+                'ConsumerStocks' => [
265
+                    'Ratio' => ['code' => 0.5, 'name' => '在共富区消费者获得购买商品赠送商品额50%的消费股']
266
+                ],
267
+                'WithdrawalLimit' => [
268
+                    'Ratio' => ['code' => 5, 'name' => '消费配额1:5提现(需要提现的会员,需有提现配额才能提现,例:消费1000,配5000的提现额度)']
260 269
                 ]
261 270
             ],
262 271
             'Spread' => [
263 272
                 'YangLaoJin' => [
264
-                    'Ratio' => ['code' => 0.7 * 0.05, 'name' => '将利润(PV)的70%中的5%,当做养老金分配给推荐人']
273
+                    'Ratio' => ['code' => 0.03, 'name' => '将订单消费金额的3%,当做养老金分配给推荐人']
274
+                ],
275
+                'ConsumerStocks' => [
276
+                    'Ratio' => ['code' => 0.5, 'name' => '在共富区推广者获得购买商品赠送商品额50%的消费股']
265 277
                 ]
266 278
             ]
267 279
         ]

+ 25 - 0
app/common/enum/shared/SharedProsperityRewardRecordEnum.php

@@ -0,0 +1,25 @@
1
+<?php
2
+
3
+namespace app\common\enum\shared;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class SharedProsperityRewardRecordEnum extends CommonEnum
8
+{
9
+    // 明细类型  commission佣金
10
+    const TYPE = [
11
+        'CONSUMER_STOCKS' => ['code' => 1001, 'name' => '共富体系消费股'],
12
+        'WITHDRAWAL_LIMIT' => ['code' => 1002, 'name' => '共富体系提现额度'],
13
+        'PV' => ['code' => 1003, 'name' => '共富体系PV值'],
14
+    ];
15
+
16
+    // 状态
17
+    const STATUS = [
18
+        'PENDING' => ['code' => 0, 'name' => '待确定'],
19
+        'VALID' => ['code' => 1, 'name' => '有效'],
20
+        'INVALID' => ['code' => -1, 'name' => '无效'],
21
+    ];
22
+
23
+    // 类型商店
24
+    const TYPE_SHOP = parent::ORDER_TYPE;
25
+}

+ 2 - 1
app/common/enum/user/UserBillEnum.php

@@ -14,7 +14,8 @@ class UserBillEnum extends CommonEnum
14 14
 
15 15
     // 明细种类
16 16
     const CATEGORY = [
17
-        'NowMoney' => ['code' => 'now_money', 'name' => 'now_money']
17
+        'NowMoney' => ['code' => 'now_money', 'name' => 'now_money'],
18
+        'OfflineRechargeMoney' => ['code' => 'offline_recharge_money', 'name' => 'offline_recharge_money'],
18 19
     ];
19 20
 
20 21
     // 明细类型  commission佣金

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

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

+ 266 - 0
app/common/repositories/shared/SharedProsperityRewardRecordRepository.php

@@ -0,0 +1,266 @@
1
+<?php
2
+
3
+namespace app\common\repositories\shared;
4
+
5
+use app\common\dao\shared\SharedProsperityRewardRecordDao;
6
+use app\common\enum\shared\SharedProsperityRewardRecordEnum;
7
+use app\common\repositories\BaseRepository;
8
+use app\common\repositories\store\order\StoreOrderRepository;
9
+use app\entity\data\shared\SharedProsperityRewardRecordEntity;
10
+use app\entity\data\shared\SharedProsperityUserEntity;
11
+use think\db\exception\DbException;
12
+use think\exception\ValidateException;
13
+
14
+class SharedProsperityRewardRecordRepository extends BaseRepository
15
+{
16
+
17
+    protected $dao;
18
+
19
+    /**
20
+     * SharedProsperityRewardRecordRepository constructor.
21
+     * @param SharedProsperityRewardRecordDao $dao
22
+     */
23
+    public function __construct(SharedProsperityRewardRecordDao $dao)
24
+    {
25
+        $this->dao = $dao;
26
+    }
27
+
28
+    /**
29
+     * @param int $id
30
+     * @return SharedProsperityRewardRecordEntity
31
+     */
32
+    public function getSharedProsperityRewardRecordEntityById(int $id): SharedProsperityRewardRecordEntity
33
+    {
34
+        $entityList = $this->getSharedProsperityRewardRecordEntityListByIdList([$id]);
35
+        $entity = array_shift($entityList);
36
+        if ($entity instanceof SharedProsperityRewardRecordEntity) {
37
+            return $entity;
38
+        } else {
39
+            /** @var SharedProsperityRewardRecordEntity */
40
+            return SharedProsperityRewardRecordEntity::newInstance();
41
+        }
42
+    }
43
+
44
+    /**
45
+     * @param array $idList
46
+     * @return SharedProsperityRewardRecordEntity[]
47
+     */
48
+    public function getSharedProsperityRewardRecordEntityListByIdList(array $idList): array
49
+    {
50
+        return $this->dao->getSharedProsperityRewardRecordEntityListByIdList($idList);
51
+    }
52
+
53
+    public function create($data)
54
+    {
55
+        return $this->dao->create($data);
56
+    }
57
+
58
+    /**
59
+     * @param SharedProsperityRewardRecordEntity $sharedProsperityRewardRecordEntity
60
+     * @return SharedProsperityRewardRecordEntity
61
+     */
62
+    public function createByEntity(SharedProsperityRewardRecordEntity $sharedProsperityRewardRecordEntity): SharedProsperityRewardRecordEntity
63
+    {
64
+        $result = $this->create($sharedProsperityRewardRecordEntity->toUnderlineArray())->toArray();
65
+        /** @var SharedProsperityRewardRecordEntity $entity */
66
+        $entity = SharedProsperityRewardRecordEntity::newInstance($result);
67
+        return $entity;
68
+    }
69
+
70
+    /**
71
+     * @param $id
72
+     * @param $data
73
+     * @return int
74
+     */
75
+    public function update($id, $data): int
76
+    {
77
+        try {
78
+            return $this->dao->update($id, $data);
79
+        } catch (DbException $e) {
80
+            return 0;
81
+        }
82
+    }
83
+
84
+    /**
85
+     * @param SharedProsperityRewardRecordEntity $sharedProsperityRewardRecordEntity
86
+     * @return SharedProsperityRewardRecordEntity
87
+     */
88
+    public function updateByEntity(SharedProsperityRewardRecordEntity $sharedProsperityRewardRecordEntity): SharedProsperityRewardRecordEntity
89
+    {
90
+        if (empty($sharedProsperityRewardRecordEntity->getId())) {
91
+            return SharedProsperityRewardRecordEntity::newInstance();
92
+        }
93
+        $result = $this->update($sharedProsperityRewardRecordEntity->getId(), $sharedProsperityRewardRecordEntity->toUnderlineArray());
94
+        if ($result > 0) {
95
+            return $this->getSharedProsperityRewardRecordEntityById($sharedProsperityRewardRecordEntity->getId());
96
+        }
97
+        return SharedProsperityRewardRecordEntity::newInstance();
98
+    }
99
+
100
+    /**
101
+     * 添加 共富体系奖励记录
102
+     * @param int $uid
103
+     * @param int $type
104
+     * @param float $number
105
+     * @param int $typeShop
106
+     * @param string $orderSn
107
+     * @param string $remark
108
+     * @return SharedProsperityRewardRecordEntity
109
+     */
110
+    public function addSharedProsperityRewardRecord(int $uid, int $type, float $number, int $typeShop = 0, string $orderSn = '', string $remark = ''): SharedProsperityRewardRecordEntity
111
+    {
112
+        if ($typeShop == SharedProsperityRewardRecordEnum::TYPE_SHOP['Platform']['code']) {
113
+            /** @var StoreOrderRepository $storeOrderRepository */
114
+            $storeOrderRepository = app()->make(StoreOrderRepository::class);
115
+            $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderSn($orderSn);
116
+            if (empty($storeOrderEntity->getOrderId())) {
117
+                throw new ValidateException('未查询到订单信息');
118
+            }
119
+        }
120
+
121
+        /** @var SharedProsperityRewardRecordEntity $sharedProsperityRewardRecordEntity */
122
+        $sharedProsperityRewardRecordEntity = SharedProsperityRewardRecordEntity::newInstance();
123
+        $sharedProsperityRewardRecordEntity->setUserId($uid)
124
+            //UserBillEnum::PM['INCOME']['code']
125
+            ->setType($type)
126
+            ->setNumber($number)
127
+            ->setStatus(SharedProsperityRewardRecordEnum::STATUS['PENDING']['code'])
128
+            ->setTypeShop($typeShop)
129
+            ->setOrderSn($orderSn)
130
+            ->setRemark($remark);
131
+
132
+        return $this->createByEntity($sharedProsperityRewardRecordEntity);
133
+    }
134
+
135
+    /**
136
+     * 结算 共富体系奖励记录
137
+     * @param array $idList
138
+     * @return array
139
+     */
140
+    public function executeByIdList(array $idList): array
141
+    {
142
+        $sharedProsperityRewardRecordEntityList = $this->getSharedProsperityRewardRecordEntityListByIdList($idList);
143
+        // 忽略 已经生效的 记录
144
+        $sharedProsperityRewardRecordEntityList = array_filter($sharedProsperityRewardRecordEntityList, function($entity) {
145
+            return $entity->getStatus() != SharedProsperityRewardRecordEnum::STATUS['VALID']['code'];
146
+        });
147
+
148
+        if (!empty($sharedProsperityRewardRecordEntityList)) {
149
+            // 获取所有记录的 归属人
150
+            $userIdList = array_map(function ($sharedProsperityRewardRecordEntity) {
151
+                return $sharedProsperityRewardRecordEntity->getUserId();
152
+            }, $sharedProsperityRewardRecordEntityList);
153
+
154
+            // 获取用户 映射信息
155
+            /** @var SharedProsperityUserRepository $sharedProsperityUserRepository */
156
+            $sharedProsperityUserRepository = app()->make(SharedProsperityUserRepository::class);
157
+            /** @var SharedProsperityUserEntity[] $sharedProsperityUserEntityMapByUserId */
158
+            $sharedProsperityUserEntityMapByUserId = [];
159
+            if (!empty($userIdList)) {
160
+                $sharedProsperityUserEntityMapByUserId = $sharedProsperityUserRepository->getSharedProsperityUserEntityMapByUserIdList($userIdList);
161
+            }
162
+
163
+            $updateSharedProsperityUserEntityList = [];
164
+            $updateSharedProsperityRewardRecordEntityList = [];
165
+            foreach ($sharedProsperityRewardRecordEntityList as $sharedProsperityRewardRecordEntity) {
166
+                if (empty($sharedProsperityRewardRecordEntity->getId()) || empty($sharedProsperityRewardRecordEntity->getUserId())) {
167
+                    // throw new ValidateException('无效的账单记录');
168
+                    continue;
169
+                }
170
+                if (!empty($sharedProsperityRewardRecordEntity->getTakeTime())) {
171
+                    throw new ValidateException("该奖励记录已更新,请勿重复操作({$sharedProsperityRewardRecordEntity->getId()})");
172
+                }
173
+
174
+                $sharedProsperityUserEntity = $sharedProsperityUserEntityMapByUserId[$sharedProsperityRewardRecordEntity->getUserId()];
175
+                if (empty($sharedProsperityUserEntity) || empty($sharedProsperityUserEntity->getUserId())) {
176
+                    throw new ValidateException("未查询到用户信息({$sharedProsperityRewardRecordEntity->getId()})");
177
+                }
178
+
179
+                // 更新 用户信息
180
+                /** @var SharedProsperityUserEntity $updateSharedProsperityUserEntity */
181
+                $updateSharedProsperityUserEntity = $updateSharedProsperityUserEntityList[$sharedProsperityUserEntity->getUserId()] ?? SharedProsperityUserEntity::newInstance();
182
+                $updateSharedProsperityUserEntity->setId();
183
+
184
+                // 更新 账单 记录
185
+                /** @var SharedProsperityRewardRecordEntity $updateSharedProsperityRewardRecord */
186
+                $updateSharedProsperityRewardRecord = $updateSharedProsperityRewardRecordEntityList[$sharedProsperityRewardRecordEntity->getId()] ?? SharedProsperityRewardRecordEntity::newInstance();
187
+                // 更新 账单记录 状态
188
+                $updateSharedProsperityRewardRecord
189
+                    ->setId($sharedProsperityRewardRecordEntity->getBillId())
190
+                    ->setStatus(UserBillEnum::STATUS['VALID']['code'])
191
+                    ->setTakeTime(time());
192
+
193
+                if ($sharedProsperityRewardRecordEntity->getCommissionType() == UserBillEnum::COMMISSION_TYPE['DIRECT_REFERRAL']['code']) {
194
+                    // 直推奖
195
+                    if (is_null($updateSharedProsperityUserEntity->getBrokeragePrice())) {
196
+                        $updateSharedProsperityUserEntity->setBrokeragePrice($sharedProsperityUserEntity->getBrokeragePrice());
197
+                    }
198
+                    // 更新用户 佣金 信息
199
+                    if ($sharedProsperityRewardRecordEntity->getPm() == UserBillEnum::PM['EXPEND']['code']) {
200
+                        if ($updateSharedProsperityUserEntity->getBrokeragePrice() < $sharedProsperityRewardRecordEntity->getNumber()) {
201
+                            throw new ValidateException('用户佣金不足');
202
+                        }
203
+                        $updateSharedProsperityUserEntity->setBrokeragePrice(bcsub($updateSharedProsperityUserEntity->getBrokeragePrice(), $sharedProsperityRewardRecordEntity->getNumber(), 2));
204
+                    } else {
205
+                        $updateSharedProsperityUserEntity->setBrokeragePrice(bcadd($updateSharedProsperityUserEntity->getBrokeragePrice(), $sharedProsperityRewardRecordEntity->getNumber(), 2));
206
+                    }
207
+
208
+                } else if ($sharedProsperityRewardRecordEntity->getCommissionType() == UserBillEnum::COMMISSION_TYPE['PENSION']['code']) {
209
+
210
+                    if ($sharedProsperityRewardRecordEntity->getGzc() == UserBillEnum::GZC_STATUS['NOT_ENTERED']['code']) {
211
+                        if (!empty($userCertificationEntityMapByUid[$sharedProsperityRewardRecordEntity->getUid()])) {
212
+                            $userCertificationEntity = $userCertificationEntityMapByUid[$sharedProsperityRewardRecordEntity->getUid()];
213
+                            // 创建公证处记录
214
+                            $gzcLogRepository->addGzcLog(
215
+                                $userCertificationEntity->getUid(),
216
+                                $userCertificationEntity->getUserName(),
217
+                                $userCertificationEntity->getMobile(),
218
+                                $userCertificationEntity->getUserCard(),
219
+                                $sharedProsperityRewardRecordEntity->getTypeShop(),
220
+                                $sharedProsperityRewardRecordEntity->getLinkId(),
221
+                                $sharedProsperityRewardRecordEntity->getNumber()
222
+                            );
223
+
224
+                            // 养老金
225
+                            if (is_null($updateSharedProsperityUserEntity->getAnnuity())) {
226
+                                $updateSharedProsperityUserEntity->setAnnuity($sharedProsperityUserEntity->getAnnuity());
227
+                            }
228
+                            $updateSharedProsperityUserEntity->setAnnuity(bcadd($updateSharedProsperityUserEntity->getAnnuity(), $sharedProsperityRewardRecordEntity->getNumber(), 2));
229
+
230
+                            // 几笔养老金
231
+                            if (is_null($updateSharedProsperityUserEntity->getAnnuityNum())) {
232
+                                $updateSharedProsperityUserEntity->setAnnuityNum($sharedProsperityUserEntity->getAnnuityNum());
233
+                            }
234
+                            $updateSharedProsperityUserEntity->setAnnuityNum(bcadd($updateSharedProsperityUserEntity->getAnnuityNum(), 1));
235
+
236
+                            // 更新佣金记录
237
+                            $updateSharedProsperityRewardRecord
238
+                                ->setGzc(UserBillEnum::GZC_STATUS['ENTERED']['code'])
239
+                                ->setIsGzc(UserBillEnum::IS_GZC['NOT_STARTED']['code']);
240
+                        }
241
+                    }
242
+                }
243
+
244
+                $updateSharedProsperityUserEntityList[$sharedProsperityUserEntity->getUid()] = $updateSharedProsperityUserEntity;
245
+                $updateSharedProsperityRewardRecordEntityList[$sharedProsperityRewardRecordEntity->getBillId()] = $updateSharedProsperityRewardRecord;
246
+            }
247
+            if (!empty($updateSharedProsperityUserEntityList)) {
248
+                $sharedProsperityUserRepository->batchUpdateUserDataByDataList(
249
+                    array_map(function (UserEntity $updateUserEntity) {
250
+                        return $updateUserEntity->toUnderlineArray();
251
+                    }, $updateSharedProsperityUserEntityList)
252
+                );
253
+            }
254
+
255
+            if (!empty($updateSharedProsperityRewardRecordEntityList)) {
256
+                $this->batchUpdateUserBillDataByDataList(
257
+                    array_map(function (UserBillEntity $updateUserBillEntity) {
258
+                        return $updateUserBillEntity->toUnderlineArray();
259
+                    }, $updateSharedProsperityRewardRecordEntityList)
260
+                );
261
+            }
262
+        }
263
+
264
+        return $idList;
265
+    }
266
+}

+ 12 - 0
app/common/repositories/shared/SharedProsperityUserRepository.php

@@ -46,6 +46,18 @@ class SharedProsperityUserRepository extends BaseRepository
46 46
         return $this->dao->getSharedProsperityUserEntityListByUserIdList($userIdList);
47 47
     }
48 48
 
49
+    /**
50
+     * @param array $userIdList
51
+     * @return SharedProsperityUserEntity[]
52
+     */
53
+    public function getSharedProsperityUserEntityMapByUserIdList(array $userIdList): array
54
+    {
55
+        $sharedProsperityUserEntityList = $this->dao->getSharedProsperityUserEntityListByUserIdList($userIdList);
56
+        /** @var SharedProsperityUserEntity[] $sharedProsperityUserEntityMapByUserId */
57
+        $sharedProsperityUserEntityMapByUserId = array_column($sharedProsperityUserEntityList, null, 'userId');
58
+        return $sharedProsperityUserEntityMapByUserId;
59
+    }
60
+
49 61
     public function create($data)
50 62
     {
51 63
         return $this->dao->create($data);

+ 89 - 47
app/common/repositories/store/order/StoreOrderRepository.php

@@ -10775,6 +10775,31 @@ class StoreOrderRepository extends BaseRepository
10775 10775
         return $this->dao->getStoreOrderEntityListByOrderIdList($orderIdList);
10776 10776
     }
10777 10777
 
10778
+    /**
10779
+     * @param string $orderSn
10780
+     * @return StoreOrderEntity
10781
+     */
10782
+    public function getStoreOrderEntityByOrderSn(string $orderSn): StoreOrderEntity
10783
+    {
10784
+        $entityList = $this->getStoreOrderEntityListByOrderSnList([$orderSn]);
10785
+        $entity = array_shift($entityList);
10786
+        if ($entity instanceof StoreOrderEntity) {
10787
+            return $entity;
10788
+        } else {
10789
+            /** @var StoreOrderEntity */
10790
+            return StoreOrderEntity::newInstance();
10791
+        }
10792
+    }
10793
+
10794
+    /**
10795
+     * @param array $orderSnList
10796
+     * @return StoreOrderEntity[]
10797
+     */
10798
+    public function getStoreOrderEntityListByOrderSnList(array $orderSnList): array
10799
+    {
10800
+        return $this->dao->getStoreOrderEntityListByOrderSnList($orderSnList);
10801
+    }
10802
+
10778 10803
 
10779 10804
     /**
10780 10805
      * @param int $groupOrderId
@@ -11471,51 +11496,52 @@ class StoreOrderRepository extends BaseRepository
11471 11496
                 '购买复购区获得养老金'
11472 11497
             );
11473 11498
 
11474
-            // 给推荐人的奖励
11475
-            if (!empty($userEntity->getSpreadUid())) {
11476
-                $userEntityBySpreadUid = $userRepository->getUserEntityByUid($userEntity->getSpreadUid());
11477
-                if (!empty($userEntityBySpreadUid->getUid()) && $userEntityBySpreadUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
11478
-                    $yanglaojinBySpreadDirectly = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['Repurchase']['SpreadDirectly']['YangLaoJin']['Ratio']['code'],CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11479
-                    /** @var UserBillRepository $userBillRepository */
11480
-                    $userBillRepository = app()->make(UserBillRepository::class);
11481
-                    $userBillRepository->addUserBill(
11482
-                        $userEntityBySpreadUid->getUid(),
11483
-                        UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11484
-                        UserBillEnum::PM['INCOME']['code'],
11485
-                        $yanglaojinBySpreadDirectly,
11486
-                        UserBillEnum::CATEGORY['NowMoney']['code'],
11487
-                        UserBillEnum::TYPE['Commission']['code'],
11488
-                        UserBillEnum::SOURCE['ONLINE']['code'],
11489
-                        UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11490
-                        UserBillEnum::TYPE_SHOP['Platform']['code'],
11491
-                        $storeOrderEntity->getOrderId(),
11492
-                        '推荐复购区商品获得养老金'
11493
-                    );
11494
-
11495
-                    // 给间接推荐人的奖励
11496
-                    if (!empty($userEntityBySpreadUid->getSpreadUid())) {
11497
-                        $userEntityByIndirectlySpreadUid = $userRepository->getUserEntityByUid($userEntityBySpreadUid->getSpreadUid());
11498
-                        if (!empty($userEntityByIndirectlySpreadUid->getUid()) && $userEntityByIndirectlySpreadUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
11499
-                            $yanglaojinBySpreadIndirectly = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['Repurchase']['SpreadIndirectly']['YangLaoJin']['Ratio']['code'],CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11500
-                            /** @var UserBillRepository $userBillRepository */
11501
-                            $userBillRepository = app()->make(UserBillRepository::class);
11502
-                            $userBillRepository->addUserBill(
11503
-                                $userEntityByIndirectlySpreadUid->getUid(),
11504
-                                UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11505
-                                UserBillEnum::PM['INCOME']['code'],
11506
-                                $yanglaojinBySpreadIndirectly,
11507
-                                UserBillEnum::CATEGORY['NowMoney']['code'],
11508
-                                UserBillEnum::TYPE['Commission']['code'],
11509
-                                UserBillEnum::SOURCE['ONLINE']['code'],
11510
-                                UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11511
-                                UserBillEnum::TYPE_SHOP['Platform']['code'],
11512
-                                $storeOrderEntity->getOrderId(),
11513
-                                '间推复购区商品获得养老金'
11514
-                            );
11515
-                        }
11516
-                    }
11517
-                }
11518
-            }
11499
+            // 复购区不再向推荐人发放养老金
11500
+            // // 给推荐人的奖励
11501
+            // if (!empty($userEntity->getSpreadUid())) {
11502
+            //     $userEntityBySpreadUid = $userRepository->getUserEntityByUid($userEntity->getSpreadUid());
11503
+            //     if (!empty($userEntityBySpreadUid->getUid()) && $userEntityBySpreadUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
11504
+            //         $yanglaojinBySpreadDirectly = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['Repurchase']['SpreadDirectly']['YangLaoJin']['Ratio']['code'],CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11505
+            //         /** @var UserBillRepository $userBillRepository */
11506
+            //         $userBillRepository = app()->make(UserBillRepository::class);
11507
+            //         $userBillRepository->addUserBill(
11508
+            //             $userEntityBySpreadUid->getUid(),
11509
+            //             UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11510
+            //             UserBillEnum::PM['INCOME']['code'],
11511
+            //             $yanglaojinBySpreadDirectly,
11512
+            //             UserBillEnum::CATEGORY['NowMoney']['code'],
11513
+            //             UserBillEnum::TYPE['Commission']['code'],
11514
+            //             UserBillEnum::SOURCE['ONLINE']['code'],
11515
+            //             UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11516
+            //             UserBillEnum::TYPE_SHOP['Platform']['code'],
11517
+            //             $storeOrderEntity->getOrderId(),
11518
+            //             '推荐复购区商品获得养老金'
11519
+            //         );
11520
+            //
11521
+            //         // 给间接推荐人的奖励
11522
+            //         if (!empty($userEntityBySpreadUid->getSpreadUid())) {
11523
+            //             $userEntityByIndirectlySpreadUid = $userRepository->getUserEntityByUid($userEntityBySpreadUid->getSpreadUid());
11524
+            //             if (!empty($userEntityByIndirectlySpreadUid->getUid()) && $userEntityByIndirectlySpreadUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
11525
+            //                 $yanglaojinBySpreadIndirectly = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['Repurchase']['SpreadIndirectly']['YangLaoJin']['Ratio']['code'],CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11526
+            //                 /** @var UserBillRepository $userBillRepository */
11527
+            //                 $userBillRepository = app()->make(UserBillRepository::class);
11528
+            //                 $userBillRepository->addUserBill(
11529
+            //                     $userEntityByIndirectlySpreadUid->getUid(),
11530
+            //                     UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11531
+            //                     UserBillEnum::PM['INCOME']['code'],
11532
+            //                     $yanglaojinBySpreadIndirectly,
11533
+            //                     UserBillEnum::CATEGORY['NowMoney']['code'],
11534
+            //                     UserBillEnum::TYPE['Commission']['code'],
11535
+            //                     UserBillEnum::SOURCE['ONLINE']['code'],
11536
+            //                     UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11537
+            //                     UserBillEnum::TYPE_SHOP['Platform']['code'],
11538
+            //                     $storeOrderEntity->getOrderId(),
11539
+            //                     '间推复购区商品获得养老金'
11540
+            //                 );
11541
+            //             }
11542
+            //         }
11543
+            //     }
11544
+            // }
11519 11545
         } else if ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['SharedProsperity']['code']) {
11520 11546
             /** @var SharedProsperityUserRepository $sharedProsperityUserRepository */
11521 11547
             $sharedProsperityUserRepository = app()->make(SharedProsperityUserRepository::class);
@@ -11541,7 +11567,7 @@ class StoreOrderRepository extends BaseRepository
11541 11567
             }
11542 11568
 
11543 11569
             // 为消费者 初始化 添加养老金记录
11544
-            $yanglaojin = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11570
+            $yanglaojin = bcmul($storeOrderEntity->getTotalPrice(), CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11545 11571
             /** @var UserBillRepository $userBillRepository */
11546 11572
             $userBillRepository = app()->make(UserBillRepository::class);
11547 11573
             $userBillRepository->addUserBill(
@@ -11558,7 +11584,23 @@ class StoreOrderRepository extends BaseRepository
11558 11584
                 '购买共富区商品获得养老金'
11559 11585
             );
11560 11586
 
11561
-            // 消费股 TODO 该做这里了
11587
+            // 发放消费股
11588
+            $userBillRepository->addUserBill(
11589
+                $sharedProsperityUserEntity->getUserId(),
11590
+                UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11591
+                UserBillEnum::PM['INCOME']['code'],
11592
+                $yanglaojin,
11593
+                UserBillEnum::CATEGORY['NowMoney']['code'],
11594
+                UserBillEnum::TYPE['Commission']['code'],
11595
+                UserBillEnum::SOURCE['ONLINE']['code'],
11596
+                UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11597
+                UserBillEnum::TYPE_SHOP['Platform']['code'],
11598
+                $storeOrderEntity->getOrderId(),
11599
+                '购买共富区商品获得养老金'
11600
+            );
11601
+
11602
+
11603
+            // 发放提现额度
11562 11604
 
11563 11605
             if (!empty($sharedProsperityUserEntity->getParentId())) {
11564 11606
                 // 如果 共富区推荐人 不是平台,则为 推荐人发放 推荐奖励

+ 237 - 0
app/entity/data/shared/SharedProsperityRewardRecordEntity.php

@@ -0,0 +1,237 @@
1
+<?php
2
+
3
+namespace app\entity\data\shared;
4
+
5
+use app\entity\data\DataEntity;
6
+
7
+class SharedProsperityRewardRecordEntity extends DataEntity
8
+{
9
+    public $id = null;  // ID
10
+    public $userId = null;  // 用户ID
11
+    public $type = null;  // 奖励类型
12
+    public $number = null;  // 明细数字
13
+    public $balance = null;  // 剩余
14
+    public $status = null;  // 状态
15
+    public $typeShop = null;  // 类型商店
16
+    public $orderSn = null;  // 订单号
17
+    public $takeTime = null;  // 结算时间
18
+    public $remark = null;
19
+    public $createTime = null;  // 添加时间
20
+    public $updateTime = null;  // 更新时间
21
+
22
+    /**
23
+     * @return mixed
24
+     */
25
+    public function getId()
26
+    {
27
+        return $this->id;
28
+    }
29
+
30
+    /**
31
+     * @param mixed $id
32
+     * @return SharedProsperityRewardRecordEntity
33
+     */
34
+    public function setId($id): SharedProsperityRewardRecordEntity
35
+    {
36
+        $this->id = $id;
37
+        return $this;
38
+    }
39
+
40
+    /**
41
+     * @return mixed
42
+     */
43
+    public function getUserId()
44
+    {
45
+        return $this->userId;
46
+    }
47
+
48
+    /**
49
+     * @param mixed $userId
50
+     * @return SharedProsperityRewardRecordEntity
51
+     */
52
+    public function setUserId($userId): SharedProsperityRewardRecordEntity
53
+    {
54
+        $this->userId = $userId;
55
+        return $this;
56
+    }
57
+
58
+    /**
59
+     * @return mixed
60
+     */
61
+    public function getType()
62
+    {
63
+        return $this->type;
64
+    }
65
+
66
+    /**
67
+     * @param mixed $type
68
+     * @return SharedProsperityRewardRecordEntity
69
+     */
70
+    public function setType($type): SharedProsperityRewardRecordEntity
71
+    {
72
+        $this->type = $type;
73
+        return $this;
74
+    }
75
+
76
+    /**
77
+     * @return mixed
78
+     */
79
+    public function getNumber()
80
+    {
81
+        return $this->number;
82
+    }
83
+
84
+    /**
85
+     * @param mixed $number
86
+     * @return SharedProsperityRewardRecordEntity
87
+     */
88
+    public function setNumber($number): SharedProsperityRewardRecordEntity
89
+    {
90
+        $this->number = $number;
91
+        return $this;
92
+    }
93
+
94
+    /**
95
+     * @return mixed
96
+     */
97
+    public function getBalance()
98
+    {
99
+        return $this->balance;
100
+    }
101
+
102
+    /**
103
+     * @param mixed $balance
104
+     * @return SharedProsperityRewardRecordEntity
105
+     */
106
+    public function setBalance($balance): SharedProsperityRewardRecordEntity
107
+    {
108
+        $this->balance = $balance;
109
+        return $this;
110
+    }
111
+
112
+    /**
113
+     * @return mixed
114
+     */
115
+    public function getStatus()
116
+    {
117
+        return $this->status;
118
+    }
119
+
120
+    /**
121
+     * @param mixed $status
122
+     * @return SharedProsperityRewardRecordEntity
123
+     */
124
+    public function setStatus($status): SharedProsperityRewardRecordEntity
125
+    {
126
+        $this->status = $status;
127
+        return $this;
128
+    }
129
+
130
+    /**
131
+     * @return mixed
132
+     */
133
+    public function getTypeShop()
134
+    {
135
+        return $this->typeShop;
136
+    }
137
+
138
+    /**
139
+     * @param mixed $typeShop
140
+     * @return SharedProsperityRewardRecordEntity
141
+     */
142
+    public function setTypeShop($typeShop): SharedProsperityRewardRecordEntity
143
+    {
144
+        $this->typeShop = $typeShop;
145
+        return $this;
146
+    }
147
+
148
+    /**
149
+     * @return mixed
150
+     */
151
+    public function getOrderSn()
152
+    {
153
+        return $this->orderSn;
154
+    }
155
+
156
+    /**
157
+     * @param mixed $orderSn
158
+     * @return SharedProsperityRewardRecordEntity
159
+     */
160
+    public function setOrderSn($orderSn): SharedProsperityRewardRecordEntity
161
+    {
162
+        $this->orderSn = $orderSn;
163
+        return $this;
164
+    }
165
+
166
+    /**
167
+     * @return mixed
168
+     */
169
+    public function getTakeTime()
170
+    {
171
+        return $this->takeTime;
172
+    }
173
+
174
+    /**
175
+     * @param mixed $takeTime
176
+     * @return SharedProsperityRewardRecordEntity
177
+     */
178
+    public function setTakeTime($takeTime): SharedProsperityRewardRecordEntity
179
+    {
180
+        $this->takeTime = $takeTime;
181
+        return $this;
182
+    }
183
+
184
+    /**
185
+     * @return mixed
186
+     */
187
+    public function getRemark()
188
+    {
189
+        return $this->remark;
190
+    }
191
+
192
+    /**
193
+     * @param mixed $remark
194
+     * @return SharedProsperityRewardRecordEntity
195
+     */
196
+    public function setRemark($remark): SharedProsperityRewardRecordEntity
197
+    {
198
+        $this->remark = $remark;
199
+        return $this;
200
+    }
201
+
202
+    /**
203
+     * @return mixed
204
+     */
205
+    public function getCreateTime()
206
+    {
207
+        return $this->createTime;
208
+    }
209
+
210
+    /**
211
+     * @param mixed $createTime
212
+     * @return SharedProsperityRewardRecordEntity
213
+     */
214
+    public function setCreateTime($createTime): SharedProsperityRewardRecordEntity
215
+    {
216
+        $this->createTime = $createTime;
217
+        return $this;
218
+    }
219
+
220
+    /**
221
+     * @return mixed
222
+     */
223
+    public function getUpdateTime()
224
+    {
225
+        return $this->updateTime;
226
+    }
227
+
228
+    /**
229
+     * @param mixed $updateTime
230
+     * @return SharedProsperityRewardRecordEntity
231
+     */
232
+    public function setUpdateTime($updateTime): SharedProsperityRewardRecordEntity
233
+    {
234
+        $this->updateTime = $updateTime;
235
+        return $this;
236
+    }
237
+}

+ 6 - 6
app/entity/data/shared/SharedProsperityUserEntity.php

@@ -10,7 +10,7 @@ class SharedProsperityUserEntity extends DataEntity
10 10
     public $userId = null;  // 用户id
11 11
     public $parentId = null;  // 推荐人用户id
12 12
     public $pv = null;  // pv
13
-    public $teamPv = null;  // 团队pv
13
+    public $consumerStocks = null; // 消费股
14 14
     public $withdrawalLimit = null;  // 提现额度
15 15
     public $partnerLevel = null;  // 合伙人等级
16 16
     public $createTime = null;  // 创建时间
@@ -91,18 +91,18 @@ class SharedProsperityUserEntity extends DataEntity
91 91
     /**
92 92
      * @return mixed
93 93
      */
94
-    public function getTeamPv()
94
+    public function getConsumerStocks()
95 95
     {
96
-        return $this->teamPv;
96
+        return $this->consumerStocks;
97 97
     }
98 98
 
99 99
     /**
100
-     * @param mixed $teamPv
100
+     * @param mixed $consumerStocks
101 101
      * @return SharedProsperityUserEntity
102 102
      */
103
-    public function setTeamPv($teamPv): SharedProsperityUserEntity
103
+    public function setConsumerStocks($consumerStocks): SharedProsperityUserEntity
104 104
     {
105
-        $this->teamPv = $teamPv;
105
+        $this->consumerStocks = $consumerStocks;
106 106
         return $this;
107 107
     }
108 108