|
|
@@ -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
|
}
|