|
|
@@ -22,6 +22,7 @@ use app\common\enum\store\StoreOrderEnum;
|
|
22
|
22
|
use app\common\enum\user\UserBillEnum;
|
|
23
|
23
|
use app\common\enum\user\UserEnum;
|
|
24
|
24
|
use app\common\enum\user\UserPvLogEnum;
|
|
|
25
|
+use app\common\enum\user\UserSignFenrunEnum;
|
|
25
|
26
|
use app\common\enum\user\UserSignFugouEnum;
|
|
26
|
27
|
use app\common\enum\user\UserSignGongxianEnum;
|
|
27
|
28
|
use app\common\enum\user\UserSignHongbaoEnum;
|
|
|
@@ -52,15 +53,19 @@ use app\common\repositories\store\shipping\ShippingTemplateUndeliveRepository;
|
|
52
|
53
|
use app\common\repositories\store\StoreSeckillActiveRepository;
|
|
53
|
54
|
use app\common\repositories\system\attachment\AttachmentRepository;
|
|
54
|
55
|
use app\common\repositories\system\merchant\FinancialRecordRepository;
|
|
|
56
|
+use app\common\repositories\system\merchant\MerchantCategoryRepository;
|
|
|
57
|
+use app\common\repositories\system\merchant\MerchantContributionRepository;
|
|
55
|
58
|
use app\common\repositories\system\merchant\MerchantRepository;
|
|
56
|
59
|
use app\common\repositories\merchant\MerchantRepository as m;
|
|
57
|
60
|
use app\common\repositories\user\UserAddressRepository;
|
|
58
|
61
|
use app\common\repositories\user\UserBillRepository;
|
|
59
|
62
|
use app\common\repositories\user\UserPvLogRepository;
|
|
60
|
63
|
use app\common\repositories\user\UserRepository;
|
|
|
64
|
+use app\common\repositories\user\UserSignFenrunRepository;
|
|
61
|
65
|
use app\common\repositories\user\UserSignFugouRepository;
|
|
62
|
66
|
use app\common\repositories\user\UserSignGongxianRepository;
|
|
63
|
67
|
use app\common\repositories\user\UserSignHongbaoRepository;
|
|
|
68
|
+use app\common\repositories\user\UserSignJingdouRepository;
|
|
64
|
69
|
use app\common\repositories\user\UserSignScoreRepository;
|
|
65
|
70
|
use app\common\repositories\user\UserThirdRepository;
|
|
66
|
71
|
use app\common\repositories\wechat\RoutineQrcodeRepository;
|
|
|
@@ -10991,7 +10996,10 @@ class StoreOrderRepository extends BaseRepository
|
|
10991
|
10996
|
// 创建订单
|
|
10992
|
10997
|
/** @var StoreOrderEntity $storeOrderEntity */
|
|
10993
|
10998
|
$storeOrderEntity = StoreOrderEntity::newInstance();
|
|
10994
|
|
- $storeOrderEntity->setCommissionRate((float)$merchantRepository->get($cartEntity->getMerId())->mer_commission_rate)
|
|
|
10999
|
+ // $huifuCommissionRate = CommonEnum::HUIFU_COMMISSION_CHARGE;
|
|
|
11000
|
+ // ->setCommissionRate(现金 * $huifuCommissionRate)
|
|
|
11001
|
+ $storeOrderEntity
|
|
|
11002
|
+ ->setExtensionOne($productAttrValueEntity->getExtensionOne())
|
|
10995
|
11003
|
// 二级佣金 此字段已被用于分佣比例
|
|
10996
|
11004
|
->setExtensionTwo($productAttrValueEntity->getExtensionTwo())
|
|
10997
|
11005
|
->setOrderSn($this->getNewOrderId() . ($num++))
|
|
|
@@ -11057,6 +11065,9 @@ class StoreOrderRepository extends BaseRepository
|
|
11057
|
11065
|
$storeOrderEntityList[$key] = $storeOrderEntity;
|
|
11058
|
11066
|
$storeOrderIdList[] = $storeOrderEntity->getOrderId();
|
|
11059
|
11067
|
|
|
|
11068
|
+ // 生成奖励数据
|
|
|
11069
|
+ $this->createRewardMechanismByStoreOrderId($storeOrderEntity->getOrderId());
|
|
|
11070
|
+
|
|
11060
|
11071
|
// 将每件商品设计到的优惠券要取消掉
|
|
11061
|
11072
|
|
|
11062
|
11073
|
// 准备订单的 状态数据
|
|
|
@@ -11245,8 +11256,6 @@ class StoreOrderRepository extends BaseRepository
|
|
11245
|
11256
|
'status' => StoreOrderEnum::STATUS['WAITING_SHIPMENT']['code'],
|
|
11246
|
11257
|
'distribution_mode' => StoreOrderEnum::DISTRIBUTION_MODE['ExpressDelivery']
|
|
11247
|
11258
|
]);
|
|
11248
|
|
-
|
|
11249
|
|
-
|
|
11250
|
11259
|
foreach ($storeOrderEntityList as $storeOrderEntity) {
|
|
11251
|
11260
|
|
|
11252
|
11261
|
}
|
|
|
@@ -11261,12 +11270,31 @@ class StoreOrderRepository extends BaseRepository
|
|
11261
|
11270
|
*/
|
|
11262
|
11271
|
public function getStoreOrderEntityByOrderId(int $orderId): StoreOrderEntity
|
|
11263
|
11272
|
{
|
|
11264
|
|
- /** @var StoreOrderEntity $storeOrderEntity */
|
|
11265
|
|
- $storeOrderEntity = $this->dao->getStoreOrderEntityByOrderId($orderId);
|
|
11266
|
|
- return $storeOrderEntity;
|
|
|
11273
|
+ $entityList = $this->getStoreOrderEntityListByOrderIdList([$orderId]);
|
|
|
11274
|
+ $entity = array_shift($entityList);
|
|
|
11275
|
+ if ($entity instanceof StoreOrderEntity) {
|
|
|
11276
|
+ return $entity;
|
|
|
11277
|
+ } else {
|
|
|
11278
|
+ /** @var StoreOrderEntity */
|
|
|
11279
|
+ return StoreOrderEntity::newInstance();
|
|
|
11280
|
+ }
|
|
|
11281
|
+ }
|
|
|
11282
|
+
|
|
|
11283
|
+ /**
|
|
|
11284
|
+ * @param array $orderIdList
|
|
|
11285
|
+ * @return StoreOrderEntity[]
|
|
|
11286
|
+ */
|
|
|
11287
|
+ public function getStoreOrderEntityListByOrderIdList(array $orderIdList): array
|
|
|
11288
|
+ {
|
|
|
11289
|
+ return $this->dao->getStoreOrderEntityListByOrderIdList($orderIdList);
|
|
11267
|
11290
|
}
|
|
11268
|
11291
|
|
|
11269
|
|
- public function createCommissionByStoreOrderEntity(int $orderId)
|
|
|
11292
|
+ /**
|
|
|
11293
|
+ * 根据 订单ID 来生 成奖励数据(待生效)
|
|
|
11294
|
+ * @param int $orderId
|
|
|
11295
|
+ * @return void
|
|
|
11296
|
+ */
|
|
|
11297
|
+ public function createRewardMechanismByStoreOrderId(int $orderId)
|
|
11270
|
11298
|
{
|
|
11271
|
11299
|
/** @var StoreOrderRepository $storeOrderRepository */
|
|
11272
|
11300
|
$storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
@@ -11698,6 +11726,10 @@ class StoreOrderRepository extends BaseRepository
|
|
11698
|
11726
|
}
|
|
11699
|
11727
|
}
|
|
11700
|
11728
|
} else {
|
|
|
11729
|
+ /** @var MerchantRepository $merchantRepository */
|
|
|
11730
|
+ $merchantRepository = app()->make(MerchantRepository::class);
|
|
|
11731
|
+ $merchantEntity = $merchantRepository->getMerchantEntityByMerchantId($storeOrderEntity->getMerId());
|
|
|
11732
|
+
|
|
11701
|
11733
|
// 为消费者 初始化 添加养老金记录
|
|
11702
|
11734
|
$yanglaojin = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
11703
|
11735
|
/** @var UserBillRepository $userBillRepository */
|
|
|
@@ -11750,7 +11782,18 @@ class StoreOrderRepository extends BaseRepository
|
|
11750
|
11782
|
$storeOrderEntity->getOrderId()
|
|
11751
|
11783
|
);
|
|
11752
|
11784
|
|
|
11753
|
|
- // 分润记录 todo
|
|
|
11785
|
+ // 分润记录
|
|
|
11786
|
+ if (!empty($merchantEntity->getUid())) {
|
|
|
11787
|
+ /** @var UserSignFenrunRepository $userSignFenrunRepository */
|
|
|
11788
|
+ $userSignFenrunRepository = app()->make(UserSignFenrunRepository::class);
|
|
|
11789
|
+ $userSignFenrunRepository->addUserSingFenrun(
|
|
|
11790
|
+ $merchantEntity->getUid(),
|
|
|
11791
|
+ $storeOrderEntity->getConPri(),
|
|
|
11792
|
+ '商贸区下单产生分润值',
|
|
|
11793
|
+ UserSignFenrunEnum::ORDER_TYPE['Platform']['code'],
|
|
|
11794
|
+ $storeOrderEntity->getOrderId()
|
|
|
11795
|
+ );
|
|
|
11796
|
+ }
|
|
11754
|
11797
|
|
|
11755
|
11798
|
// 给老用户的奖励 红包
|
|
11756
|
11799
|
if ($userEntity->getIsOld()) {
|
|
|
@@ -11850,19 +11893,19 @@ class StoreOrderRepository extends BaseRepository
|
|
11850
|
11893
|
}
|
|
11851
|
11894
|
}
|
|
11852
|
11895
|
|
|
11853
|
|
- // 锁客收益 todo
|
|
|
11896
|
+ // 锁客收益
|
|
11854
|
11897
|
if (!empty($userEntity->getMerId())) {
|
|
11855
|
11898
|
/** @var MerchantRepository $merchantRepository */
|
|
11856
|
11899
|
$merchantRepository = app()->make(MerchantRepository::class);
|
|
11857
|
|
- $merchantEntity = $merchantRepository->getMerchantEntityByMerchantId($userEntity->getMerId());
|
|
11858
|
|
- if ($merchantEntity->getStatus() == MerchantEnum::STATUS['Normal']['code'] && !empty($merchantEntity->getUid())) {
|
|
|
11900
|
+ $merchantEntityByLock = $merchantRepository->getMerchantEntityByMerchantId($userEntity->getMerId());
|
|
|
11901
|
+ if ($merchantEntityByLock->getStatus() == MerchantEnum::STATUS['Normal']['code'] && !empty($merchantEntityByLock->getUid())) {
|
|
11859
|
11902
|
// 计算 佣金
|
|
11860
|
|
- $brokeragePriceByMerId = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Lock']['BrokeragePrice']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
11903
|
+ $brokeragePriceByMerId = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Lock']['BrokeragePrice']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
11861
|
11904
|
// 添加佣金记录
|
|
11862
|
11905
|
/** @var UserBillRepository $userBillRepository */
|
|
11863
|
11906
|
$userBillRepository = app()->make(UserBillRepository::class);
|
|
11864
|
11907
|
$userBillRepository->addUserBill(
|
|
11865
|
|
- $merchantEntity->getUid(),
|
|
|
11908
|
+ $merchantEntityByLock->getUid(),
|
|
11866
|
11909
|
UserBillEnum::TYPE_SHOP['Platform']['code'],
|
|
11867
|
11910
|
$storeOrderEntity->getOrderId(),
|
|
11868
|
11911
|
UserBillEnum::COMMISSION_TYPE['LOCKED_CUSTOMER']['code'],
|
|
|
@@ -11871,12 +11914,12 @@ class StoreOrderRepository extends BaseRepository
|
|
11871
|
11914
|
);
|
|
11872
|
11915
|
|
|
11873
|
11916
|
// 计算 复购金
|
|
11874
|
|
- $fugouByMerId = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Lock']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
11917
|
+ $fugouByMerId = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Lock']['Fugou']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
11875
|
11918
|
// 添加复购金记录
|
|
11876
|
11919
|
/** @var UserSignFugouRepository $userSignFugouRepository */
|
|
11877
|
11920
|
$userSignFugouRepository = app()->make(UserSignFugouRepository::class);
|
|
11878
|
11921
|
$userSignFugouRepository->addUserSingFugou(
|
|
11879
|
|
- $merchantEntity->getUid(),
|
|
|
11922
|
+ $merchantEntityByLock->getUid(),
|
|
11880
|
11923
|
UserSignFugouEnum::TYPE['Give']['code'],
|
|
11881
|
11924
|
$fugouByMerId,
|
|
11882
|
11925
|
'锁客复购金(精彩生活区商品赠送)',
|
|
|
@@ -11886,7 +11929,119 @@ class StoreOrderRepository extends BaseRepository
|
|
11886
|
11929
|
}
|
|
11887
|
11930
|
}
|
|
11888
|
11931
|
|
|
11889
|
|
- // 商户收益 todo
|
|
|
11932
|
+ // 商户收益 给商户 京豆
|
|
|
11933
|
+ /** @var MerchantContributionRepository $merchantContributionRepository */
|
|
|
11934
|
+ $merchantContributionRepository = app()->make(MerchantContributionRepository::class);
|
|
|
11935
|
+ $merchantContributionEntity = $merchantContributionRepository->getMerchantContributionEntityByProfitSharing($storeOrderEntity->getExtensionOne());
|
|
|
11936
|
+ if (!empty($merchantContributionEntity->getId())) {
|
|
|
11937
|
+ /** @var UserSignJingdouRepository $userSignJingdouRepository */
|
|
|
11938
|
+ $userSignJingdouRepository = app()->make(UserSignJingdouRepository::class);
|
|
|
11939
|
+ $userSignJingdouRepository->addUserSingJingdou(
|
|
|
11940
|
+ $merchantEntity->getUid(),
|
|
|
11941
|
+ UserSignJingdouEnum::TYPE['Gift']['code'],
|
|
|
11942
|
+ bcmul($storeOrderEntity->getConPri(), $merchantContributionEntity->getJd(), CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT),
|
|
|
11943
|
+ $storeOrderEntity->getMerId(),
|
|
|
11944
|
+ '线上用户消费商家获得京豆',
|
|
|
11945
|
+ UserSignFugouEnum::ORDER_TYPE['Platform']['code'],
|
|
|
11946
|
+ $storeOrderEntity->getOrderId()
|
|
|
11947
|
+ );
|
|
|
11948
|
+ }
|
|
|
11949
|
+ }
|
|
|
11950
|
+ }
|
|
|
11951
|
+
|
|
|
11952
|
+ public function settlementOrderByOrderIdList(array $orderIdList)
|
|
|
11953
|
+ {
|
|
|
11954
|
+ /** @var StoreOrderRepository $storeOrderRepository */
|
|
|
11955
|
+ $storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
11956
|
+ $storeOrderEntityList = $storeOrderRepository->getStoreOrderEntityListByOrderIdList($orderIdList);
|
|
|
11957
|
+ if (!empty($storeOrderEntityList)) {
|
|
|
11958
|
+ $existOrderIdList = array_map(function ($storeOrderEntity) {
|
|
|
11959
|
+ if ($storeOrderEntity->getIsSettlement() == StoreOrderEnum::IS_SETTLEMENT['NO']['code']) {
|
|
|
11960
|
+ return $storeOrderEntity->getOrderId();
|
|
|
11961
|
+ }
|
|
|
11962
|
+ }, $storeOrderEntityList);
|
|
|
11963
|
+
|
|
|
11964
|
+ /** @var UserBillRepository $userBillRepository */
|
|
|
11965
|
+ $userBillRepository = app()->make(UserBillRepository::class);
|
|
|
11966
|
+ $userBillEntityList = $userBillRepository->getUserBillEntityListByOrderIdListAndPending(UserBillEnum::TYPE_SHOP['Platform']['code'], $existOrderIdList);
|
|
|
11967
|
+ if (!empty($userBillEntityList)) {
|
|
|
11968
|
+ foreach ($userBillEntityList as $userBillEntity) {
|
|
|
11969
|
+ if ($userBillEntity->getCommissionType() == UserBillEnum::COMMISSION_TYPE['PENSION']['code']) {
|
|
|
11970
|
+ // 养老金 todo
|
|
|
11971
|
+ }
|
|
|
11972
|
+ }
|
|
|
11973
|
+ }
|
|
|
11974
|
+
|
|
|
11975
|
+
|
|
|
11976
|
+
|
|
|
11977
|
+ foreach ($storeOrderEntityList as $storeOrderEntity) {
|
|
|
11978
|
+ // 结算养老金
|
|
|
11979
|
+ $yanglaojin = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
11980
|
+ /** @var UserBillRepository $userBillRepository */
|
|
|
11981
|
+ $userBillRepository = app()->make(UserBillRepository::class);
|
|
|
11982
|
+ $userBillRepository->addUserBill(
|
|
|
11983
|
+ $storeOrderEntity->getUid(),
|
|
|
11984
|
+ UserBillEnum::TYPE_SHOP['Platform']['code'],
|
|
|
11985
|
+ $storeOrderEntity->getOrderId(),
|
|
|
11986
|
+ UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
|
|
|
11987
|
+ $yanglaojin,
|
|
|
11988
|
+ '购买精彩生活商品赠送养老金'
|
|
|
11989
|
+ );
|
|
|
11990
|
+
|
|
|
11991
|
+ // 为用户初始胡 贡献值
|
|
|
11992
|
+ $gongxian = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['Gongxian']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
11993
|
+ /** @var UserSignGongxianRepository $userSignGongxianRepository */
|
|
|
11994
|
+ $userSignGongxianRepository = app()->make(UserSignGongxianRepository::class);
|
|
|
11995
|
+ $userSignGongxianRepository->addUserSingGongxian(
|
|
|
11996
|
+ $storeOrderEntity->getUid(),
|
|
|
11997
|
+ UserSignGongxianEnum::TYPE['Give']['code'],
|
|
|
11998
|
+ $gongxian,
|
|
|
11999
|
+ '购买精彩生活商品赠送贡献值',
|
|
|
12000
|
+ UserSignGongxianEnum::ORDER_TYPE['Platform']['code'],
|
|
|
12001
|
+ $storeOrderEntity->getOrderId()
|
|
|
12002
|
+ );
|
|
|
12003
|
+
|
|
|
12004
|
+ // 初始化 PV
|
|
|
12005
|
+ $pv = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['Pv']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
12006
|
+ /** @var UserPvLogRepository $userPvLogRepository */
|
|
|
12007
|
+ $userPvLogRepository = app()->make(UserPvLogRepository::class);
|
|
|
12008
|
+ $userPvLogRepository->addUserPvLog(
|
|
|
12009
|
+ $storeOrderEntity->getUid(),
|
|
|
12010
|
+ $pv,
|
|
|
12011
|
+ '购买精彩生活商品赠送PV值',
|
|
|
12012
|
+ UserPvLogEnum::ORDER_TYPE['Platform']['code'],
|
|
|
12013
|
+ $storeOrderEntity->getOrderId()
|
|
|
12014
|
+ );
|
|
|
12015
|
+
|
|
|
12016
|
+ // 初始化积分
|
|
|
12017
|
+ $score = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['Score']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
12018
|
+ /** @var UserSignScoreRepository $userSignScoreRepository */
|
|
|
12019
|
+ $userSignScoreRepository = app()->make(UserSignScoreRepository::class);
|
|
|
12020
|
+ $userSignScoreRepository->addUserSingScore(
|
|
|
12021
|
+ $storeOrderEntity->getUid(),
|
|
|
12022
|
+ UserSignScoreEnum::SOURCE_TYPE['SelfOrder']['code'],
|
|
|
12023
|
+ UserSignScoreEnum::PM['Income']['code'],
|
|
|
12024
|
+ $score,
|
|
|
12025
|
+ '购买精彩生活商品赠送积分',
|
|
|
12026
|
+ UserSignHongbaoEnum::ORDER_TYPE['Platform']['code'],
|
|
|
12027
|
+ $storeOrderEntity->getOrderId()
|
|
|
12028
|
+ );
|
|
|
12029
|
+
|
|
|
12030
|
+ // 给老用户的奖励 红包
|
|
|
12031
|
+ if ($userEntity->getIsOld()) {
|
|
|
12032
|
+ $hongbao = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Self']['Hongbao']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
12033
|
+ /** @var UserSignHongbaoRepository $userSignHongbaoRepository */
|
|
|
12034
|
+ $userSignHongbaoRepository = app()->make(UserSignHongbaoRepository::class);
|
|
|
12035
|
+ $userSignHongbaoRepository->addUserSingHongbao(
|
|
|
12036
|
+ $storeOrderEntity->getUid(),
|
|
|
12037
|
+ UserSignHongbaoEnum::TYPE['ConsumptionGift']['code'],
|
|
|
12038
|
+ $hongbao,
|
|
|
12039
|
+ '购买精彩生活商品赠送红包',
|
|
|
12040
|
+ UserSignHongbaoEnum::ORDER_TYPE['Platform']['code'],
|
|
|
12041
|
+ $storeOrderEntity->getOrderId()
|
|
|
12042
|
+ );
|
|
|
12043
|
+ }
|
|
|
12044
|
+ }
|
|
11890
|
12045
|
}
|
|
11891
|
12046
|
}
|
|
11892
|
12047
|
}
|