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

优化用户下单方法-进行中

sunxbiao 1 год назад
Родитель
Сommit
47b916712f

+ 92 - 45
app/common/enum/CommonEnum.php

@@ -79,117 +79,164 @@ class CommonEnum
79 79
                 ]
80 80
             ],
81 81
             'Spread' => [
82
-                'Basics' => [
83
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做推荐人利润分配的基础,目前绑定的是下单人的PV值']
84
-                ],
85 82
                 'BrokeragePrice' => [
86
-                    'Ratio' => ['code' => 0.9, 'name' => '直推奖励的佣金部分'],
83
+                    'Ratio' => ['code' => 0.35 * 0.9, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35% * 90% ,直推奖励的佣金部分'],
87 84
                 ],
88 85
                 'Fugou' => [
89
-                    'Ratio' => ['code' => 0.1, 'name' => '直推奖励的复购部分'],
86
+                    'Ratio' => ['code' => 0.35 * 0.1, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35% * 10% ,直推奖励的复购部分'],
90 87
                 ],
91 88
                 'Gongxian' => [
92 89
                     'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做贡献值分配给推荐人']
93 90
                 ],
94 91
                 'Score' => [
95
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做积分值分配给推荐人']
92
+                    'Ratio' => ['code' => 0.35, 'name' => '将商品利润中 用户身份对应分配比例 推荐人可分配利润中 35%,当做积分值分配给推荐人']
96 93
                 ],
97 94
                 'YangLaoJin' => [
98
-                    'Ratio' => ['code' => 0.05, 'name' => '将利润的35%,当做积分值分配给推荐人']
95
+                    'Ratio' => ['code' => 0.35 * 0.5, 'name' => '将利润的35%中的5%,当做养老金分配给推荐人']
99 96
                 ]
100 97
             ],
101 98
             'Share' => [
102
-                'Basics' => [
103
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做分享人利润分配的基础,目前绑定的是下单人的PV值']
104
-                ],
105 99
                 'BrokeragePrice' => [
106
-                    'Ratio' => ['code' => 0.027, 'name' => '分享奖励的佣金部分(0.03 * 0.9)'],
100
+                    'Ratio' => ['code' => 0.35 * 0.03 * 0.9, 'name' => '将利润的 35% 中的 3% 中的 90%,做为分享奖励的佣金部分'],
107 101
                 ],
108 102
                 'Fugou' => [
109
-                    'Ratio' => ['code' => 0.003, 'name' => '分享奖励的复购部分(0.03 * 0.1)'],
103
+                    'Ratio' => ['code' => 0.35 * 0.03 * 0.1, 'name' => '将利润的 35% 中的 3% 中的 10%,做为分享奖励的复购部分'],
110 104
                 ]
111 105
             ],
112 106
             'Lock' => [
113
-                'Basics' => [
114
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做锁客利润分配的基础,目前绑定的是下单人的PV值']
115
-                ],
116 107
                 'BrokeragePrice' => [
117
-                    'Ratio' => ['code' => 0.045, 'name' => '锁客奖励的佣金部分(0.05 * 0.9)'],
108
+                    'Ratio' => ['code' => 0.35 * 0.05 * 0.9, 'name' => '将利润的 35% 中的 5% 中的 90%,做为锁客奖励的佣金部分'],
118 109
                 ],
119 110
                 'Fugou' => [
120
-                    'Ratio' => ['code' => 0.005, 'name' => '锁客奖励的复购部分(0.05 * 0.1)'],
111
+                    'Ratio' => ['code' => 0.35 * 0.05 * 0.1, 'name' => '将利润的 35% 中的 5% 中的 10%,做为锁客奖励的复购部分'],
121 112
                 ]
122 113
             ]
123 114
         ],
124 115
         'MemberZone' => [
125 116
             'Fixed' => [
126
-                'Basic' => [ // 售价 => 基础计算价格
127
-                    1180 => 1000,
128
-                    2360 => 2000,
129
-                    9440 => 8000,
130
-                    10620 => 9000,
131
-                    11800 => 10000
117
+                'Basic' => [ // 售价 => 基础计算价格 (历史原因:原价是1000、2000...等,后来单间成本价上调了180,所以售价调整了,考虑到涨价前后的奖励应保持一致,所以设置了基础计算值)
118
+                    1180.00 => 1000.00,
119
+                    2360.00 => 2000.00,
120
+                    9440.00 => 8000.00,
121
+                    10620.00 => 9000.00,
122
+                    11800.00 => 10000.00
132 123
                 ]
133 124
             ],
134 125
             'Self' => [
135 126
                 // 养老金比例
136 127
                 'YangLaoJin' => [
137
-                    'Ratio' => ['code' => 0.3, 'name' => '将利润的30%,当做养老金分配给下单人']
128
+                    'Ratio' => ['code' => 0.035, 'name' => '将3.5%,当做养老金分配给下单人']
129
+                ],
130
+                'Gongxian' => [
131
+                    'Ratio' => ['code' => 0.7, 'name' => '将利润的35%,当做贡献值分配给下单人']
138 132
                 ],
139 133
                 'Pv' => [
140
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做PV值分配给下单人']
134
+                    'Ratio' => ['code' => 0.7, 'name' => '将70%,当做PV值分配给下单人']
135
+                ],
136
+                'Score' => [
137
+                    'Ratio' => ['code' => 0.7, 'name' => '将利润的35%,当做积分值分配给下单人']
138
+                ]
139
+            ],
140
+            'Spread' => [
141
+                'IdentityRatio' => [
142
+                    1 => 0.1,
143
+                    2 => 0.3,
144
+                    3 => 0.3,
145
+                    4 => 0.3,
146
+                    5 => 0.3,
147
+                    6 => 0.3,
148
+                    7 => 0.3,
149
+                ],
150
+                'BrokeragePrice' => [
151
+                    'Ratio' => ['code' => 0.9, 'name' => '直推奖励的佣金部分'],
152
+                ],
153
+                'Fugou' => [
154
+                    'Ratio' => ['code' => 0.1, 'name' => '直推奖励的复购部分'],
141 155
                 ],
142 156
                 'Gongxian' => [
143
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做贡献值分配给下单人']
157
+                    'Ratio' => ['code' => 0.7, 'name' => '将70%,当做贡献值分配给推荐人'],
158
+                    'RegularUserRatio' => ['code' => 0.7 * 0.3, 'name' => '将70% * 30%,当做贡献值分配给推荐人(普通用户)'],
144 159
                 ],
145 160
                 'Score' => [
161
+                    'Ratio' => ['code' => 0.7, 'name' => '将用户身份等级对应的直推分润的70%,当做积分值分配给推荐人']
162
+                ],
163
+                'YangLaoJin' => [
164
+                    'Ratio' => ['code' => 0.035, 'name' => '将3.5%,当做养老金分配给推荐人']
165
+                ]
166
+            ]
167
+        ],
168
+        'Repurchase' => [
169
+            'Self' => [
170
+                // 养老金比例
171
+                'YangLaoJin' => [
172
+                    'Ratio' => ['code' => 0.5, 'name' => '将50%,当做养老金分配给下单人']
173
+                ]
174
+            ],
175
+            'SpreadDirectly' => [
176
+                // 养老金比例 直接推荐人
177
+                'YangLaoJin' => [
178
+                    'Ratio' => ['code' => 0.3, 'name' => '将30%,当做养老金分配给直推人']
179
+                ]
180
+            ],
181
+            'SpreadIndirectly' => [
182
+                // 养老金比例 间接推荐人
183
+                'YangLaoJin' => [
184
+                    'Ratio' => ['code' => 0.2, 'name' => '将20%,当做养老金分配给间推人']
185
+                ]
186
+            ]
187
+        ],
188
+        'CommercialDistrict' => [
189
+            'Self' => [
190
+                'YangLaoJin' => [ // 钱
191
+                    'Ratio' => ['code' => 0.3, 'name' => '将利润的30%,当做养老金分配给下单人']
192
+                ],
193
+                'Hongbao' => [ // 钱
194
+                    'Ratio' => ['code' => 0.35 * 0.45, 'name' => '将利润的35% * 45%,当做红包分配给下单人,前提下单人是老用户(35% * 45%)']
195
+                ],
196
+                'Score' => [ // 钱
146 197
                     'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做积分值分配给下单人']
147 198
                 ],
148
-                'Hongbao' => [
149
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做红包分配给下单人,前提下单人是老用户']
199
+                'Pv' => [ // 数据 算业绩
200
+                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做PV值分配给下单人']
201
+                ],
202
+                'Gongxian' => [ // 数据 升级用
203
+                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做贡献值分配给下单人']
150 204
                 ]
151 205
             ],
152 206
             'Spread' => [
153
-                'Basics' => [
154
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做推荐人利润分配的基础,目前绑定的是下单人的PV值']
155
-                ],
156 207
                 'BrokeragePrice' => [
157
-                    'Ratio' => ['code' => 0.9, 'name' => '直推奖励的佣金部分'],
208
+                    'Ratio' => ['code' => 0.35 * 0.9, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35% * 90% ,直推奖励的佣金部分'],
158 209
                 ],
159 210
                 'Fugou' => [
160
-                    'Ratio' => ['code' => 0.1, 'name' => '直推奖励的复购部分'],
211
+                    'Ratio' => ['code' => 0.35 * 0.1, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35% * 10% ,直推奖励的复购部分'],
161 212
                 ],
162 213
                 'Gongxian' => [
163 214
                     'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做贡献值分配给推荐人']
164 215
                 ],
165 216
                 'Score' => [
166
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做积分值分配给推荐人']
217
+                    'Ratio' => ['code' => 0.35, 'name' => '将商品利润中 用户身份对应分配比例 的推荐人可分配利润中 35%,当做积分值分配给推荐人']
218
+                ],
219
+                'YangLaoJin' => [
220
+                    'Ratio' => ['code' => 0.35 * 0.5, 'name' => '将利润的35%中的5%,当做养老金分配给推荐人']
167 221
                 ]
168 222
             ],
169 223
             'Share' => [
170
-                'Basics' => [
171
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做分享人利润分配的基础,目前绑定的是下单人的PV值']
172
-                ],
173 224
                 'BrokeragePrice' => [
174
-                    'Ratio' => ['code' => 0.027, 'name' => '分享奖励的佣金部分(0.03 * 0.9)'],
225
+                    'Ratio' => ['code' => 0.35 * 0.03 * 0.9, 'name' => '将利润的 35% 中的 3% 中的 90%,做为分享奖励的佣金部分'],
175 226
                 ],
176 227
                 'Fugou' => [
177
-                    'Ratio' => ['code' => 0.003, 'name' => '分享奖励的复购部分(0.03 * 0.1)'],
228
+                    'Ratio' => ['code' => 0.35 * 0.03 * 0.1, 'name' => '将利润的 35% 中的 3% 中的 10%,做为分享奖励的复购部分'],
178 229
                 ]
179 230
             ],
180 231
             'Lock' => [
181
-                'Basics' => [
182
-                    'Ratio' => ['code' => 0.35, 'name' => '将利润的35%,当做锁客利润分配的基础,目前绑定的是下单人的PV值']
183
-                ],
184 232
                 'BrokeragePrice' => [
185
-                    'Ratio' => ['code' => 0.045, 'name' => '锁客奖励的佣金部分(0.05 * 0.9)'],
233
+                    'Ratio' => ['code' => 0.35 * 0.05 * 0.9, 'name' => '将利润的 35% 中的 5% 中的 90%,做为锁客奖励的佣金部分'],
186 234
                 ],
187 235
                 'Fugou' => [
188
-                    'Ratio' => ['code' => 0.005, 'name' => '锁客奖励的复购部分(0.05 * 0.1)'],
236
+                    'Ratio' => ['code' => 0.35 * 0.05 * 0.1, 'name' => '将利润的 35% 中的 5% 中的 10%,做为锁客奖励的复购部分'],
189 237
                 ]
190 238
             ]
191 239
         ]
192
-
193 240
     ];
194 241
 
195 242
 }

+ 398 - 35
app/common/repositories/store/order/StoreOrderRepository.php

@@ -11291,7 +11291,7 @@ class StoreOrderRepository extends BaseRepository
11291 11291
                 $storeOrderEntity->getOrderId(),
11292 11292
                 UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11293 11293
                 $yanglaojin,
11294
-                '消费获得养老金'
11294
+                '购买精彩生活商品赠送养老金'
11295 11295
             );
11296 11296
 
11297 11297
             // 为用户初始胡 贡献值
@@ -11352,13 +11352,10 @@ class StoreOrderRepository extends BaseRepository
11352 11352
             if (!empty($userEntity->getSpreadUid())) {
11353 11353
                 $userEntityBySpreadUid = $userRepository->getUserEntityByUid($userEntity->getSpreadUid());
11354 11354
                 if (!empty($userEntityBySpreadUid->getUid()) && $userEntityBySpreadUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
11355
-                    // 推荐人 数据分配的 基础值
11356
-                    $basicsBySpread = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Spread']['Basics']['Ratio']['code'], CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
11357
-
11358
-                    // 后台设置中 可以设置  直推收益 的比例
11355
+                    // 后台设置中 可以设置 推荐人 直推收益 的比例
11359 11356
                     $rate = static::getUserGroupRate($userEntityBySpreadUid->getUserGroup());
11360 11357
                     // 推荐 奖金 目前需要将 奖金按比例 分成佣金和复购金
11361
-                    $directReferralBonus = bcmul($basicsBySpread, $rate, CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
11358
+                    $directReferralBonus = bcmul($storeOrderEntity->getConPri(), $rate, CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
11362 11359
 
11363 11360
                     // 计算 复购金
11364 11361
                     $fugouBySpreadUid = bcmul($directReferralBonus, CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Spread']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
@@ -11403,8 +11400,7 @@ class StoreOrderRepository extends BaseRepository
11403 11400
                     );
11404 11401
 
11405 11402
                     // 计算积分值
11406
-                    $basicsScoreBySpreadUid = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Spread']['Score']['Ratio']['code'], CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
11407
-                    $scoreBySpreadUid = bcmul($basicsScoreBySpreadUid, $rate, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11403
+                    $scoreBySpreadUid = bcmul($directReferralBonus, CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Spread']['Score']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11408 11404
                     // 赠送积分
11409 11405
                     /** @var UserSignScoreRepository $userSignScoreRepository */
11410 11406
                     $userSignScoreRepository = app()->make(UserSignScoreRepository::class);
@@ -11420,16 +11416,16 @@ class StoreOrderRepository extends BaseRepository
11420 11416
 
11421 11417
                     // 如果用户的身份 不是 普通用户 (高于普通用户) 则发放养老金
11422 11418
                     if ($userEntityBySpreadUid->getUserGroup() != CommonEnum::USER_GROUP['RegularUser']['code']) {
11423
-                        // $basicsBySpread
11419
+                        $yanglaojinBySpreadUid = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11424 11420
                         /** @var UserBillRepository $userBillRepository */
11425 11421
                         $userBillRepository = app()->make(UserBillRepository::class);
11426 11422
                         $userBillRepository->addUserBill(
11427
-                            $storeOrderEntity->getUid(),
11423
+                            $userEntityBySpreadUid->getUid(),
11428 11424
                             UserBillEnum::TYPE_SHOP['Platform']['code'],
11429 11425
                             $storeOrderEntity->getOrderId(),
11430 11426
                             UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11431
-                            $yanglaojin,
11432
-                            '消费获得养老金'
11427
+                            $yanglaojinBySpreadUid,
11428
+                            '推广精彩生活区商品获得养老金'
11433 11429
                         );
11434 11430
                     }
11435 11431
                 }
@@ -11439,13 +11435,8 @@ class StoreOrderRepository extends BaseRepository
11439 11435
             if (!empty($storeOrderEntity->getShareUid())) {
11440 11436
                 $userEntityByShareUid = $userRepository->getUserEntityByUid($storeOrderEntity->getShareUid());
11441 11437
                 if (!empty($userEntityByShareUid->getUid()) && $userEntityByShareUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
11442
-                    // 分享人人 数据分配的 基础值
11443
-                    $basicsByShare = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Share']['Basics']['Ratio']['code'], CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
11444 11438
                     // 计算 佣金
11445
-                    $brokeragePriceByShareUid = bcmul($basicsByShare, CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Share']['BrokeragePrice']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11446
-                    // 计算 复购金
11447
-                    $fugouByShareUid = bcmul($basicsByShare, CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Share']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11448
-
11439
+                    $brokeragePriceByShareUid = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Share']['BrokeragePrice']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11449 11440
                     // 添加佣金记录
11450 11441
                     /** @var UserBillRepository $userBillRepository */
11451 11442
                     $userBillRepository = app()->make(UserBillRepository::class);
@@ -11457,7 +11448,8 @@ class StoreOrderRepository extends BaseRepository
11457 11448
                         $brokeragePriceByShareUid,
11458 11449
                         '分享精彩生活区商品赠送佣金'
11459 11450
                     );
11460
-
11451
+                    // 计算 复购金
11452
+                    $fugouByShareUid = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Share']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11461 11453
                     // 添加复购金记录
11462 11454
                     /** @var UserSignFugouRepository $userSignFugouRepository */
11463 11455
                     $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
@@ -11478,13 +11470,8 @@ class StoreOrderRepository extends BaseRepository
11478 11470
                 $merchantRepository = app()->make(MerchantRepository::class);
11479 11471
                 $merchantEntity = $merchantRepository->getMerchantEntityByMerchantId($userEntity->getMerId());
11480 11472
                 if ($merchantEntity->getStatus() == MerchantEnum::STATUS['Normal']['code'] && !empty($merchantEntity->getUid())) {
11481
-                    // 锁客 数据分配的 基础值
11482
-                    $basicsByMerId = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Lock']['Basics']['Ratio']['code'], CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
11483 11473
                     // 计算 佣金
11484
-                    $brokeragePriceByMerId = bcmul($basicsByMerId, CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Lock']['BrokeragePrice']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11485
-                    // 计算 复购金
11486
-                    $fugouByMerId = bcmul($basicsByMerId, CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Lock']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11487
-
11474
+                    $brokeragePriceByMerId = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Lock']['BrokeragePrice']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11488 11475
                     // 添加佣金记录
11489 11476
                     /** @var UserBillRepository $userBillRepository */
11490 11477
                     $userBillRepository = app()->make(UserBillRepository::class);
@@ -11497,6 +11484,8 @@ class StoreOrderRepository extends BaseRepository
11497 11484
                         '锁客佣金(精彩生活区商品赠送)'
11498 11485
                     );
11499 11486
 
11487
+                    // 计算 复购金
11488
+                    $fugouByMerId = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Lock']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11500 11489
                     // 添加复购金记录
11501 11490
                     /** @var UserSignFugouRepository $userSignFugouRepository */
11502 11491
                     $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
@@ -11511,19 +11500,393 @@ class StoreOrderRepository extends BaseRepository
11511 11500
                 }
11512 11501
             }
11513 11502
         } else if ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['MemberZone']['code']) {
11514
-            // 由于 会员专区的订单不允许退货 所以支付成功后即 结算数据
11515
-            if ($storeOrderEntity->getPaid() == StoreOrderEnum::PAID['YES']['code']) {
11516
-                // 如果订单已经支付
11503
+            if (isset(CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Fixed']['Basic'][$storeOrderEntity->getTotalPrice()])) {
11504
+                $basePrice = CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Fixed']['Basic'][$storeOrderEntity->getTotalPrice()];
11505
+
11506
+                // 为消费者 初始化 添加养老金记录
11507
+                $yanglaojin = bcmul($basePrice, CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11508
+                /** @var UserBillRepository $userBillRepository */
11509
+                $userBillRepository = app()->make(UserBillRepository::class);
11510
+                $userBillRepository->addUserBill(
11511
+                    $storeOrderEntity->getUid(),
11512
+                    UserBillEnum::TYPE_SHOP['Platform']['code'],
11513
+                    $storeOrderEntity->getOrderId(),
11514
+                    UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11515
+                    $yanglaojin,
11516
+                    '购买会员专区商品赠送养老金'
11517
+                );
11517 11518
 
11518
-                // 将 订单 设置成已计算状态
11519
-                try {
11520
-                    $storeOrderRepository->update($storeOrderEntity->getOrderId(), [
11521
-                        'is_settlement' => StoreOrderEnum::IS_SETTLEMENT['YES']['code']
11522
-                    ]);
11523
-                } catch (DbException $e) {
11524
-                    throw new ValidateException('更新订单结算状态失败!');
11519
+                // 为用户初始胡 贡献值
11520
+                $gongxian = bcmul($basePrice, CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Self']['Gongxian']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11521
+                /** @var UserSignGongxianRepository $userSignGongxianRepository */
11522
+                $userSignGongxianRepository = app()->make(UserSignGongxianRepository::class);
11523
+                $userSignGongxianRepository->addUserSingGongxian(
11524
+                    $storeOrderEntity->getUid(),
11525
+                    UserSignGongxianEnum::TYPE['Give']['code'],
11526
+                    $gongxian,
11527
+                    '购买会员专区商品赠送贡献值',
11528
+                    UserSignGongxianEnum::ORDER_TYPE['Platform']['code'],
11529
+                    $storeOrderEntity->getOrderId()
11530
+                );
11531
+
11532
+                // 初始化 PV
11533
+                $pv = bcmul($basePrice, CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Self']['Pv']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11534
+                /** @var UserPvLogRepository $userPvLogRepository */
11535
+                $userPvLogRepository = app()->make(UserPvLogRepository::class);
11536
+                $userPvLogRepository->addUserPvLog(
11537
+                    $storeOrderEntity->getUid(),
11538
+                    $pv,
11539
+                    '购买会员专区商品赠送PV值',
11540
+                    UserPvLogEnum::ORDER_TYPE['Platform']['code'],
11541
+                    $storeOrderEntity->getOrderId()
11542
+                );
11543
+
11544
+                // 初始化积分
11545
+                $score = bcmul($basePrice, CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Self']['Score']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11546
+                /** @var UserSignScoreRepository $userSignScoreRepository */
11547
+                $userSignScoreRepository = app()->make(UserSignScoreRepository::class);
11548
+                $userSignScoreRepository->addUserSingScore(
11549
+                    $storeOrderEntity->getUid(),
11550
+                    UserSignScoreEnum::SOURCE_TYPE['SelfOrder']['code'],
11551
+                    UserSignScoreEnum::PM['Income']['code'],
11552
+                    $score,
11553
+                    '购买会员专区商品赠送积分',
11554
+                    UserSignHongbaoEnum::ORDER_TYPE['Platform']['code'],
11555
+                    $storeOrderEntity->getOrderId()
11556
+                );
11557
+
11558
+                // 给推荐人的奖励
11559
+                if (!empty($userEntity->getSpreadUid())) {
11560
+                    $userEntityBySpreadUid = $userRepository->getUserEntityByUid($userEntity->getSpreadUid());
11561
+                    if (!empty($userEntityBySpreadUid->getUid()) && $userEntityBySpreadUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
11562
+                        // 分配 直推佣金+复购金
11563
+                        if (isset(CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Spread']['IdentityRatio'][$userEntityBySpreadUid->getUserGroup()])) {
11564
+                            $identityRatio = CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Spread']['IdentityRatio'][$userEntityBySpreadUid->getUserGroup()];
11565
+                            // 基础价格 * 不同身份的比例
11566
+                            $directReferralBonus = bcmul($basePrice, $identityRatio, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11567
+
11568
+                            // 计算 复购金
11569
+                            $fugouBySpreadUid = bcmul($directReferralBonus, CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Spread']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11570
+                            // 添加复购金记录
11571
+                            /** @var UserSignFugouRepository $userSignFugouRepository */
11572
+                            $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
11573
+                            $userSignFugouRepository->addUserSingFugou(
11574
+                                $userEntityBySpreadUid->getUid(),
11575
+                                UserSignFugouEnum::TYPE['Give']['code'],
11576
+                                $fugouBySpreadUid,
11577
+                                '推广会员专区商品赠送复购金',
11578
+                                UserSignFugouEnum::ORDER_TYPE['Platform']['code'],
11579
+                                $storeOrderEntity->getOrderId()
11580
+                            );
11581
+
11582
+                            // 计算 佣金
11583
+                            $brokeragePriceBySpreadUid = bcmul($directReferralBonus, CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Spread']['BrokeragePrice']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11584
+                            // 添加佣金记录
11585
+                            /** @var UserBillRepository $userBillRepository */
11586
+                            $userBillRepository = app()->make(UserBillRepository::class);
11587
+                            $userBillRepository->addUserBill(
11588
+                                $userEntityBySpreadUid->getUid(),
11589
+                                UserBillEnum::TYPE_SHOP['Platform']['code'],
11590
+                                $storeOrderEntity->getOrderId(),
11591
+                                UserBillEnum::COMMISSION_TYPE['DIRECT_REFERRAL']['code'],
11592
+                                $brokeragePriceBySpreadUid,
11593
+                                '推广会员专区商品赠送佣金'
11594
+                            );
11595
+                        }
11596
+
11597
+                        // 初始胡 贡献值
11598
+                        if ($userEntityBySpreadUid->getUserGroup() == CommonEnum::USER_GROUP['RegularUser']['code']) {
11599
+                            // 如果 推荐人是 普通用户
11600
+                            $gongxianRatio = CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Spread']['Gongxian']['RegularUserRatio']['code'];
11601
+                        } else {
11602
+                            $gongxianRatio = CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Spread']['Gongxian']['Ratio']['code'];
11603
+                        }
11604
+                        $gongxianBySpreadUid = bcmul($basePrice, $gongxianRatio, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11605
+                        // 赠送贡献值
11606
+                        /** @var UserSignGongxianRepository $userSignGongxianRepository */
11607
+                        $userSignGongxianRepository = app()->make(UserSignGongxianRepository::class);
11608
+                        $userSignGongxianRepository->addUserSingGongxian(
11609
+                            $userEntityBySpreadUid->getUid(),
11610
+                            UserSignGongxianEnum::TYPE['Give']['code'],
11611
+                            $gongxianBySpreadUid,
11612
+                            '推广会员专区商品赠送贡献值',
11613
+                            UserSignGongxianEnum::ORDER_TYPE['Platform']['code'],
11614
+                            $storeOrderEntity->getOrderId()
11615
+                        );
11616
+
11617
+                        // 计算积分值
11618
+                        // 后台设置中 可以设置 推荐人 直推收益 的比例
11619
+                        $rate = static::getUserGroupRate($userEntityBySpreadUid->getUserGroup());
11620
+                        $scoreByUserGroupRate = bcmul($basePrice, $rate, CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
11621
+                        $scoreBySpreadUid = bcmul($scoreByUserGroupRate, CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Spread']['Score']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11622
+                        // 赠送积分
11623
+                        /** @var UserSignScoreRepository $userSignScoreRepository */
11624
+                        $userSignScoreRepository = app()->make(UserSignScoreRepository::class);
11625
+                        $userSignScoreRepository->addUserSingScore(
11626
+                            $userEntityBySpreadUid->getUid(),
11627
+                            UserSignScoreEnum::SOURCE_TYPE['SelfOrder']['code'],
11628
+                            UserSignScoreEnum::PM['Income']['code'],
11629
+                            $scoreBySpreadUid,
11630
+                            '推广会员专区商品赠送积分',
11631
+                            UserSignHongbaoEnum::ORDER_TYPE['Platform']['code'],
11632
+                            $storeOrderEntity->getOrderId()
11633
+                        );
11634
+
11635
+                        // 如果用户的身份 不是 普通用户 (高于普通用户) 则发放养老金
11636
+                        if ($userEntityBySpreadUid->getUserGroup() != CommonEnum::USER_GROUP['RegularUser']['code']) {
11637
+                            $yanglaojinBySpreadUid = bcmul($basePrice, CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11638
+                            /** @var UserBillRepository $userBillRepository */
11639
+                            $userBillRepository = app()->make(UserBillRepository::class);
11640
+                            $userBillRepository->addUserBill(
11641
+                                $userEntityBySpreadUid->getUid(),
11642
+                                UserBillEnum::TYPE_SHOP['Platform']['code'],
11643
+                                $storeOrderEntity->getOrderId(),
11644
+                                UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11645
+                                $yanglaojinBySpreadUid,
11646
+                                '推广会员专区商品获得养老金'
11647
+                            );
11648
+                        }
11649
+                    }
11650
+                }
11651
+            }
11652
+        } else if ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['Repurchase']['code']) {
11653
+            $yanglaojin = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['Repurchase']['Self']['YangLaoJin']['Ratio']['code'],CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11654
+            /** @var UserBillRepository $userBillRepository */
11655
+            $userBillRepository = app()->make(UserBillRepository::class);
11656
+            $userBillRepository->addUserBill(
11657
+                $storeOrderEntity->getUid(),
11658
+                UserBillEnum::TYPE_SHOP['Platform']['code'],
11659
+                $storeOrderEntity->getOrderId(),
11660
+                UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11661
+                $yanglaojin,
11662
+                '购买复购区赠送养老金'
11663
+            );
11664
+
11665
+            // 给推荐人的奖励
11666
+            if (!empty($userEntity->getSpreadUid())) {
11667
+                $userEntityBySpreadUid = $userRepository->getUserEntityByUid($userEntity->getSpreadUid());
11668
+                if (!empty($userEntityBySpreadUid->getUid()) && $userEntityBySpreadUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
11669
+                    $yanglaojinBySpreadDirectly = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['Repurchase']['SpreadDirectly']['YangLaoJin']['Ratio']['code'],CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11670
+                    /** @var UserBillRepository $userBillRepository */
11671
+                    $userBillRepository = app()->make(UserBillRepository::class);
11672
+                    $userBillRepository->addUserBill(
11673
+                        $userEntityBySpreadUid->getUid(),
11674
+                        UserBillEnum::TYPE_SHOP['Platform']['code'],
11675
+                        $storeOrderEntity->getOrderId(),
11676
+                        UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11677
+                        $yanglaojinBySpreadDirectly,
11678
+                        '推荐复购区商品赠送养老金'
11679
+                    );
11680
+
11681
+                    // 给间接推荐人的奖励
11682
+                    if (!empty($userEntityBySpreadUid->getSpreadUid())) {
11683
+                        $userEntityByIndirectlySpreadUid = $userRepository->getUserEntityByUid($userEntityBySpreadUid->getSpreadUid());
11684
+                        if (!empty($userEntityByIndirectlySpreadUid->getUid()) && $userEntityByIndirectlySpreadUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
11685
+                            $yanglaojinBySpreadIndirectly = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['Repurchase']['SpreadIndirectly']['YangLaoJin']['Ratio']['code'],CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11686
+                            /** @var UserBillRepository $userBillRepository */
11687
+                            $userBillRepository = app()->make(UserBillRepository::class);
11688
+                            $userBillRepository->addUserBill(
11689
+                                $userEntityByIndirectlySpreadUid->getUid(),
11690
+                                UserBillEnum::TYPE_SHOP['Platform']['code'],
11691
+                                $storeOrderEntity->getOrderId(),
11692
+                                UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11693
+                                $yanglaojinBySpreadIndirectly,
11694
+                                '间推复购区商品赠送养老金'
11695
+                            );
11696
+                        }
11697
+                    }
11698
+                }
11699
+            }
11700
+        } else {
11701
+            // 为消费者 初始化 添加养老金记录
11702
+            $yanglaojin = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11703
+            /** @var UserBillRepository $userBillRepository */
11704
+            $userBillRepository = app()->make(UserBillRepository::class);
11705
+            $userBillRepository->addUserBill(
11706
+                $storeOrderEntity->getUid(),
11707
+                UserBillEnum::TYPE_SHOP['Platform']['code'],
11708
+                $storeOrderEntity->getOrderId(),
11709
+                UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11710
+                $yanglaojin,
11711
+                '购买商贸区商品赠送养老金'
11712
+            );
11713
+
11714
+            // 为用户初始胡 贡献值
11715
+            $gongxian = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Self']['Gongxian']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11716
+            /** @var UserSignGongxianRepository $userSignGongxianRepository */
11717
+            $userSignGongxianRepository = app()->make(UserSignGongxianRepository::class);
11718
+            $userSignGongxianRepository->addUserSingGongxian(
11719
+                $storeOrderEntity->getUid(),
11720
+                UserSignGongxianEnum::TYPE['Give']['code'],
11721
+                $gongxian,
11722
+                '购买商贸区商品赠送贡献值',
11723
+                UserSignGongxianEnum::ORDER_TYPE['Platform']['code'],
11724
+                $storeOrderEntity->getOrderId()
11725
+            );
11726
+
11727
+            // 初始化 PV
11728
+            $pv = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Self']['Pv']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11729
+            /** @var UserPvLogRepository $userPvLogRepository */
11730
+            $userPvLogRepository = app()->make(UserPvLogRepository::class);
11731
+            $userPvLogRepository->addUserPvLog(
11732
+                $storeOrderEntity->getUid(),
11733
+                $pv,
11734
+                '购买商贸区商品赠送PV值',
11735
+                UserPvLogEnum::ORDER_TYPE['Platform']['code'],
11736
+                $storeOrderEntity->getOrderId()
11737
+            );
11738
+
11739
+            // 初始化积分
11740
+            $score = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Self']['Score']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11741
+            /** @var UserSignScoreRepository $userSignScoreRepository */
11742
+            $userSignScoreRepository = app()->make(UserSignScoreRepository::class);
11743
+            $userSignScoreRepository->addUserSingScore(
11744
+                $storeOrderEntity->getUid(),
11745
+                UserSignScoreEnum::SOURCE_TYPE['SelfOrder']['code'],
11746
+                UserSignScoreEnum::PM['Income']['code'],
11747
+                $score,
11748
+                '购买商贸区商品赠送积分',
11749
+                UserSignHongbaoEnum::ORDER_TYPE['Platform']['code'],
11750
+                $storeOrderEntity->getOrderId()
11751
+            );
11752
+
11753
+            // 分润记录 todo
11754
+
11755
+            // 给老用户的奖励 红包
11756
+            if ($userEntity->getIsOld()) {
11757
+                $hongbao =  bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Self']['Hongbao']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11758
+                /** @var UserSignHongbaoRepository $userSignHongbaoRepository */
11759
+                $userSignHongbaoRepository = app()->make(UserSignHongbaoRepository::class);
11760
+                $userSignHongbaoRepository->addUserSingHongbao(
11761
+                    $storeOrderEntity->getUid(),
11762
+                    UserSignHongbaoEnum::TYPE['ConsumptionGift']['code'],
11763
+                    $hongbao,
11764
+                    '购买商贸区商品赠送红包',
11765
+                    UserSignHongbaoEnum::ORDER_TYPE['Platform']['code'],
11766
+                    $storeOrderEntity->getOrderId()
11767
+                );
11768
+            }
11769
+
11770
+            // 给推荐人的奖励
11771
+            if (!empty($userEntity->getSpreadUid())) {
11772
+                $userEntityBySpreadUid = $userRepository->getUserEntityByUid($userEntity->getSpreadUid());
11773
+                if (!empty($userEntityBySpreadUid->getUid()) && $userEntityBySpreadUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
11774
+                    // 后台设置中 可以设置 推荐人 直推收益 的比例
11775
+                    $rate = static::getUserGroupRate($userEntityBySpreadUid->getUserGroup());
11776
+                    // 推荐 奖金 目前需要将 奖金按比例 分成佣金和复购金
11777
+                    $directReferralBonus = bcmul($storeOrderEntity->getConPri(), $rate, CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
11778
+
11779
+                    // 计算 复购金
11780
+                    $fugouBySpreadUid = bcmul($directReferralBonus, CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Spread']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11781
+                    // 添加复购金记录
11782
+                    /** @var UserSignFugouRepository $userSignFugouRepository */
11783
+                    $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
11784
+                    $userSignFugouRepository->addUserSingFugou(
11785
+                        $userEntityBySpreadUid->getUid(),
11786
+                        UserSignFugouEnum::TYPE['Give']['code'],
11787
+                        $fugouBySpreadUid,
11788
+                        '推广商贸区商品赠送复购金',
11789
+                        UserSignFugouEnum::ORDER_TYPE['Platform']['code'],
11790
+                        $storeOrderEntity->getOrderId()
11791
+                    );
11792
+
11793
+                    // 计算 佣金
11794
+                    $brokeragePriceBySpreadUid = bcmul($directReferralBonus, CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Spread']['BrokeragePrice']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11795
+                    // 添加佣金记录
11796
+                    /** @var UserBillRepository $userBillRepository */
11797
+                    $userBillRepository = app()->make(UserBillRepository::class);
11798
+                    $userBillRepository->addUserBill(
11799
+                        $userEntityBySpreadUid->getUid(),
11800
+                        UserBillEnum::TYPE_SHOP['Platform']['code'],
11801
+                        $storeOrderEntity->getOrderId(),
11802
+                        UserBillEnum::COMMISSION_TYPE['DIRECT_REFERRAL']['code'],
11803
+                        $brokeragePriceBySpreadUid,
11804
+                        '推广商贸区商品赠送佣金'
11805
+                    );
11806
+
11807
+                    // 初始胡 贡献值
11808
+                    $gongxianBySpreadUid = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Spread']['Gongxian']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11809
+                    // 赠送贡献值
11810
+                    /** @var UserSignGongxianRepository $userSignGongxianRepository */
11811
+                    $userSignGongxianRepository = app()->make(UserSignGongxianRepository::class);
11812
+                    $userSignGongxianRepository->addUserSingGongxian(
11813
+                        $userEntityBySpreadUid->getUid(),
11814
+                        UserSignGongxianEnum::TYPE['Give']['code'],
11815
+                        $gongxianBySpreadUid,
11816
+                        '推广商贸区商品赠送贡献值',
11817
+                        UserSignGongxianEnum::ORDER_TYPE['Platform']['code'],
11818
+                        $storeOrderEntity->getOrderId()
11819
+                    );
11820
+
11821
+                    // 计算积分值
11822
+                    $scoreBySpreadUid = bcmul($directReferralBonus, CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Spread']['Score']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11823
+                    // 赠送积分
11824
+                    /** @var UserSignScoreRepository $userSignScoreRepository */
11825
+                    $userSignScoreRepository = app()->make(UserSignScoreRepository::class);
11826
+                    $userSignScoreRepository->addUserSingScore(
11827
+                        $userEntityBySpreadUid->getUid(),
11828
+                        UserSignScoreEnum::SOURCE_TYPE['SelfOrder']['code'],
11829
+                        UserSignScoreEnum::PM['Income']['code'],
11830
+                        $scoreBySpreadUid,
11831
+                        '推广商贸区商品赠送积分',
11832
+                        UserSignHongbaoEnum::ORDER_TYPE['Platform']['code'],
11833
+                        $storeOrderEntity->getOrderId()
11834
+                    );
11835
+
11836
+                    // 如果用户的身份 不是 普通用户 (高于普通用户) 则发放养老金
11837
+                    if ($userEntityBySpreadUid->getUserGroup() != CommonEnum::USER_GROUP['RegularUser']['code']) {
11838
+                        $yanglaojinBySpreadUid = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11839
+                        /** @var UserBillRepository $userBillRepository */
11840
+                        $userBillRepository = app()->make(UserBillRepository::class);
11841
+                        $userBillRepository->addUserBill(
11842
+                            $userEntityBySpreadUid->getUid(),
11843
+                            UserBillEnum::TYPE_SHOP['Platform']['code'],
11844
+                            $storeOrderEntity->getOrderId(),
11845
+                            UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11846
+                            $yanglaojinBySpreadUid,
11847
+                            '推广商贸区商品获得养老金'
11848
+                        );
11849
+                    }
11850
+                }
11851
+            }
11852
+
11853
+            // 锁客收益 todo
11854
+            if (!empty($userEntity->getMerId())) {
11855
+                /** @var MerchantRepository $merchantRepository */
11856
+                $merchantRepository = app()->make(MerchantRepository::class);
11857
+                $merchantEntity = $merchantRepository->getMerchantEntityByMerchantId($userEntity->getMerId());
11858
+                if ($merchantEntity->getStatus() == MerchantEnum::STATUS['Normal']['code'] && !empty($merchantEntity->getUid())) {
11859
+                    // 计算 佣金
11860
+                    $brokeragePriceByMerId = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Lock']['BrokeragePrice']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11861
+                    // 添加佣金记录
11862
+                    /** @var UserBillRepository $userBillRepository */
11863
+                    $userBillRepository = app()->make(UserBillRepository::class);
11864
+                    $userBillRepository->addUserBill(
11865
+                        $merchantEntity->getUid(),
11866
+                        UserBillEnum::TYPE_SHOP['Platform']['code'],
11867
+                        $storeOrderEntity->getOrderId(),
11868
+                        UserBillEnum::COMMISSION_TYPE['LOCKED_CUSTOMER']['code'],
11869
+                        $brokeragePriceByMerId,
11870
+                        '锁客佣金(精彩生活区商品赠送)'
11871
+                    );
11872
+
11873
+                    // 计算 复购金
11874
+                    $fugouByMerId = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Lock']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11875
+                    // 添加复购金记录
11876
+                    /** @var UserSignFugouRepository $userSignFugouRepository */
11877
+                    $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
11878
+                    $userSignFugouRepository->addUserSingFugou(
11879
+                        $merchantEntity->getUid(),
11880
+                        UserSignFugouEnum::TYPE['Give']['code'],
11881
+                        $fugouByMerId,
11882
+                        '锁客复购金(精彩生活区商品赠送)',
11883
+                        UserSignFugouEnum::ORDER_TYPE['Platform']['code'],
11884
+                        $storeOrderEntity->getOrderId()
11885
+                    );
11525 11886
                 }
11526 11887
             }
11888
+
11889
+            // 商户收益 todo
11527 11890
         }
11528 11891
     }
11529 11892
 }