|
|
@@ -11266,8 +11266,12 @@ class StoreOrderRepository extends BaseRepository
|
|
11266
|
11266
|
return $storeOrderEntity;
|
|
11267
|
11267
|
}
|
|
11268
|
11268
|
|
|
11269
|
|
- public function createCommissionByStoreOrderEntity(StoreOrderEntity $storeOrderEntity)
|
|
|
11269
|
+ public function createCommissionByStoreOrderEntity(int $orderId)
|
|
11270
|
11270
|
{
|
|
|
11271
|
+ /** @var StoreOrderRepository $storeOrderRepository */
|
|
|
11272
|
+ $storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
11273
|
+ $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId($orderId);
|
|
|
11274
|
+
|
|
11271
|
11275
|
/** @var UserRepository $userRepository */
|
|
11272
|
11276
|
$userRepository = app()->make(UserRepository::class);
|
|
11273
|
11277
|
$userEntity = $userRepository->getUserEntityByUid($storeOrderEntity->getUid());
|
|
|
@@ -11276,12 +11280,12 @@ class StoreOrderRepository extends BaseRepository
|
|
11276
|
11280
|
}
|
|
11277
|
11281
|
|
|
11278
|
11282
|
// 精彩生活区
|
|
11279
|
|
- if ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['WonderfulLiving']['Self']['code']) {
|
|
|
11283
|
+ if ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['WonderfulLiving']['code']) {
|
|
11280
|
11284
|
// 为消费者 初始化 添加养老金记录
|
|
11281
|
11285
|
$yanglaojin = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
11282
|
11286
|
/** @var UserBillRepository $userBillRepository */
|
|
11283
|
11287
|
$userBillRepository = app()->make(UserBillRepository::class);
|
|
11284
|
|
- $userBillEntity = $userBillRepository->addUserBill(
|
|
|
11288
|
+ $userBillRepository->addUserBill(
|
|
11285
|
11289
|
$storeOrderEntity->getUid(),
|
|
11286
|
11290
|
UserBillEnum::TYPE_SHOP['Platform']['code'],
|
|
11287
|
11291
|
$storeOrderEntity->getOrderId(),
|
|
|
@@ -11294,7 +11298,7 @@ class StoreOrderRepository extends BaseRepository
|
|
11294
|
11298
|
$gongxian = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['Gongxian']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
11295
|
11299
|
/** @var UserSignGongxianRepository $userSignGongxianRepository */
|
|
11296
|
11300
|
$userSignGongxianRepository = app()->make(UserSignGongxianRepository::class);
|
|
11297
|
|
- $userSignGongxianEntity = $userSignGongxianRepository->addUserSingGongxian(
|
|
|
11301
|
+ $userSignGongxianRepository->addUserSingGongxian(
|
|
11298
|
11302
|
$storeOrderEntity->getUid(),
|
|
11299
|
11303
|
UserSignGongxianEnum::TYPE['Give']['code'],
|
|
11300
|
11304
|
$gongxian,
|
|
|
@@ -11307,7 +11311,7 @@ class StoreOrderRepository extends BaseRepository
|
|
11307
|
11311
|
$pv = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['Pv']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
11308
|
11312
|
/** @var UserPvLogRepository $userPvLogRepository */
|
|
11309
|
11313
|
$userPvLogRepository = app()->make(UserPvLogRepository::class);
|
|
11310
|
|
- $userPvLogEntity = $userPvLogRepository->addUserPvLog(
|
|
|
11314
|
+ $userPvLogRepository->addUserPvLog(
|
|
11311
|
11315
|
$storeOrderEntity->getUid(),
|
|
11312
|
11316
|
$pv,
|
|
11313
|
11317
|
'购买精彩生活商品赠送PV值',
|
|
|
@@ -11329,7 +11333,7 @@ class StoreOrderRepository extends BaseRepository
|
|
11329
|
11333
|
$storeOrderEntity->getOrderId()
|
|
11330
|
11334
|
);
|
|
11331
|
11335
|
|
|
11332
|
|
- // 给老用户的奖励
|
|
|
11336
|
+ // 给老用户的奖励 红包
|
|
11333
|
11337
|
if ($userEntity->getIsOld()) {
|
|
11334
|
11338
|
$hongbao = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['Hongbao']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
11335
|
11339
|
/** @var UserSignHongbaoRepository $userSignHongbaoRepository */
|
|
|
@@ -11349,12 +11353,12 @@ class StoreOrderRepository extends BaseRepository
|
|
11349
|
11353
|
$userEntityBySpreadUid = $userRepository->getUserEntityByUid($userEntity->getSpreadUid());
|
|
11350
|
11354
|
if (!empty($userEntityBySpreadUid->getUid()) && $userEntityBySpreadUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
|
|
11351
|
11355
|
// 推荐人 数据分配的 基础值
|
|
11352
|
|
- $basics = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Spread']['Basics']['Ratio']['code'], CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
|
|
|
11356
|
+ $basicsBySpread = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Spread']['Basics']['Ratio']['code'], CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
|
|
11353
|
11357
|
|
|
11354
|
11358
|
// 后台设置中 可以设置 直推收益 的比例
|
|
11355
|
11359
|
$rate = static::getUserGroupRate($userEntityBySpreadUid->getUserGroup());
|
|
11356
|
11360
|
// 推荐 奖金 目前需要将 奖金按比例 分成佣金和复购金
|
|
11357
|
|
- $directReferralBonus = bcmul($basics, $rate, CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
|
|
|
11361
|
+ $directReferralBonus = bcmul($basicsBySpread, $rate, CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
|
|
11358
|
11362
|
|
|
11359
|
11363
|
// 计算 复购金
|
|
11360
|
11364
|
$fugouBySpreadUid = bcmul($directReferralBonus, CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Spread']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
@@ -11365,7 +11369,7 @@ class StoreOrderRepository extends BaseRepository
|
|
11365
|
11369
|
$userEntityBySpreadUid->getUid(),
|
|
11366
|
11370
|
UserSignFugouEnum::TYPE['Give']['code'],
|
|
11367
|
11371
|
$fugouBySpreadUid,
|
|
11368
|
|
- '用户购买精彩生活区商品',
|
|
|
11372
|
+ '推广精彩生活区商品赠送复购金',
|
|
11369
|
11373
|
UserSignFugouEnum::ORDER_TYPE['Platform']['code'],
|
|
11370
|
11374
|
$storeOrderEntity->getOrderId()
|
|
11371
|
11375
|
);
|
|
|
@@ -11381,7 +11385,7 @@ class StoreOrderRepository extends BaseRepository
|
|
11381
|
11385
|
$storeOrderEntity->getOrderId(),
|
|
11382
|
11386
|
UserBillEnum::COMMISSION_TYPE['DIRECT_REFERRAL']['code'],
|
|
11383
|
11387
|
$brokeragePriceBySpreadUid,
|
|
11384
|
|
- '推广获得佣金'
|
|
|
11388
|
+ '推广精彩生活区商品赠送佣金'
|
|
11385
|
11389
|
);
|
|
11386
|
11390
|
|
|
11387
|
11391
|
// 初始胡 贡献值
|
|
|
@@ -11413,6 +11417,21 @@ class StoreOrderRepository extends BaseRepository
|
|
11413
|
11417
|
UserSignHongbaoEnum::ORDER_TYPE['Platform']['code'],
|
|
11414
|
11418
|
$storeOrderEntity->getOrderId()
|
|
11415
|
11419
|
);
|
|
|
11420
|
+
|
|
|
11421
|
+ // 如果用户的身份 不是 普通用户 (高于普通用户) 则发放养老金
|
|
|
11422
|
+ if ($userEntityBySpreadUid->getUserGroup() != CommonEnum::USER_GROUP['RegularUser']['code']) {
|
|
|
11423
|
+ // $basicsBySpread
|
|
|
11424
|
+ /** @var UserBillRepository $userBillRepository */
|
|
|
11425
|
+ $userBillRepository = app()->make(UserBillRepository::class);
|
|
|
11426
|
+ $userBillRepository->addUserBill(
|
|
|
11427
|
+ $storeOrderEntity->getUid(),
|
|
|
11428
|
+ UserBillEnum::TYPE_SHOP['Platform']['code'],
|
|
|
11429
|
+ $storeOrderEntity->getOrderId(),
|
|
|
11430
|
+ UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
|
|
|
11431
|
+ $yanglaojin,
|
|
|
11432
|
+ '消费获得养老金'
|
|
|
11433
|
+ );
|
|
|
11434
|
+ }
|
|
11416
|
11435
|
}
|
|
11417
|
11436
|
}
|
|
11418
|
11437
|
|
|
|
@@ -11420,7 +11439,89 @@ class StoreOrderRepository extends BaseRepository
|
|
11420
|
11439
|
if (!empty($storeOrderEntity->getShareUid())) {
|
|
11421
|
11440
|
$userEntityByShareUid = $userRepository->getUserEntityByUid($storeOrderEntity->getShareUid());
|
|
11422
|
11441
|
if (!empty($userEntityByShareUid->getUid()) && $userEntityByShareUid->getIsDel() == UserEnum::IS_DEL['No']['code']) {
|
|
11423
|
|
-
|
|
|
11442
|
+ // 分享人人 数据分配的 基础值
|
|
|
11443
|
+ $basicsByShare = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Share']['Basics']['Ratio']['code'], CommonEnum::CALCULATE_THE_NUMBER_OF_DECIMAL_PLACES);
|
|
|
11444
|
+ // 计算 佣金
|
|
|
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
|
+
|
|
|
11449
|
+ // 添加佣金记录
|
|
|
11450
|
+ /** @var UserBillRepository $userBillRepository */
|
|
|
11451
|
+ $userBillRepository = app()->make(UserBillRepository::class);
|
|
|
11452
|
+ $userBillRepository->addUserBill(
|
|
|
11453
|
+ $userEntityByShareUid->getUid(),
|
|
|
11454
|
+ UserBillEnum::TYPE_SHOP['Platform']['code'],
|
|
|
11455
|
+ $storeOrderEntity->getOrderId(),
|
|
|
11456
|
+ UserBillEnum::COMMISSION_TYPE['SHARE_EARNINGS']['code'],
|
|
|
11457
|
+ $brokeragePriceByShareUid,
|
|
|
11458
|
+ '分享精彩生活区商品赠送佣金'
|
|
|
11459
|
+ );
|
|
|
11460
|
+
|
|
|
11461
|
+ // 添加复购金记录
|
|
|
11462
|
+ /** @var UserSignFugouRepository $userSignFugouRepository */
|
|
|
11463
|
+ $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
|
|
|
11464
|
+ $userSignFugouRepository->addUserSingFugou(
|
|
|
11465
|
+ $userEntityByShareUid->getUid(),
|
|
|
11466
|
+ UserSignFugouEnum::TYPE['Give']['code'],
|
|
|
11467
|
+ $fugouByShareUid,
|
|
|
11468
|
+ '分享精彩生活区商品赠送复购金',
|
|
|
11469
|
+ UserSignFugouEnum::ORDER_TYPE['Platform']['code'],
|
|
|
11470
|
+ $storeOrderEntity->getOrderId()
|
|
|
11471
|
+ );
|
|
|
11472
|
+ }
|
|
|
11473
|
+ }
|
|
|
11474
|
+
|
|
|
11475
|
+ // 锁客收益
|
|
|
11476
|
+ if (!empty($userEntity->getMerId())) {
|
|
|
11477
|
+ /** @var MerchantRepository $merchantRepository */
|
|
|
11478
|
+ $merchantRepository = app()->make(MerchantRepository::class);
|
|
|
11479
|
+ $merchantEntity = $merchantRepository->getMerchantEntityByMerchantId($userEntity->getMerId());
|
|
|
11480
|
+ 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
|
+ // 计算 佣金
|
|
|
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
|
+
|
|
|
11488
|
+ // 添加佣金记录
|
|
|
11489
|
+ /** @var UserBillRepository $userBillRepository */
|
|
|
11490
|
+ $userBillRepository = app()->make(UserBillRepository::class);
|
|
|
11491
|
+ $userBillRepository->addUserBill(
|
|
|
11492
|
+ $merchantEntity->getUid(),
|
|
|
11493
|
+ UserBillEnum::TYPE_SHOP['Platform']['code'],
|
|
|
11494
|
+ $storeOrderEntity->getOrderId(),
|
|
|
11495
|
+ UserBillEnum::COMMISSION_TYPE['LOCKED_CUSTOMER']['code'],
|
|
|
11496
|
+ $brokeragePriceByMerId,
|
|
|
11497
|
+ '锁客佣金(精彩生活区商品赠送)'
|
|
|
11498
|
+ );
|
|
|
11499
|
+
|
|
|
11500
|
+ // 添加复购金记录
|
|
|
11501
|
+ /** @var UserSignFugouRepository $userSignFugouRepository */
|
|
|
11502
|
+ $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
|
|
|
11503
|
+ $userSignFugouRepository->addUserSingFugou(
|
|
|
11504
|
+ $merchantEntity->getUid(),
|
|
|
11505
|
+ UserSignFugouEnum::TYPE['Give']['code'],
|
|
|
11506
|
+ $fugouByMerId,
|
|
|
11507
|
+ '锁客复购金(精彩生活区商品赠送)',
|
|
|
11508
|
+ UserSignFugouEnum::ORDER_TYPE['Platform']['code'],
|
|
|
11509
|
+ $storeOrderEntity->getOrderId()
|
|
|
11510
|
+ );
|
|
|
11511
|
+ }
|
|
|
11512
|
+ }
|
|
|
11513
|
+ } else if ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['MemberZone']['code']) {
|
|
|
11514
|
+ // 由于 会员专区的订单不允许退货 所以支付成功后即 结算数据
|
|
|
11515
|
+ if ($storeOrderEntity->getPaid() == StoreOrderEnum::PAID['YES']['code']) {
|
|
|
11516
|
+ // 如果订单已经支付
|
|
|
11517
|
+
|
|
|
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('更新订单结算状态失败!');
|
|
11424
|
11525
|
}
|
|
11425
|
11526
|
}
|
|
11426
|
11527
|
}
|