|
|
@@ -11697,41 +11697,41 @@ class StoreOrderRepository extends BaseRepository
|
|
11697
|
11697
|
* @param StoreOrderCreateRequestEntity $storeOrderCreateRequestEntity
|
|
11698
|
11698
|
* @return array
|
|
11699
|
11699
|
*/
|
|
11700
|
|
- public function createOrderNew2(StoreOrderCreateRequestEntity $storeOrderCreateRequestEntity)
|
|
|
11700
|
+ public function createOrderNew2(StoreOrderCreateRequestEntity $storeOrderCreateRequestEntity): array
|
|
11701
|
11701
|
{
|
|
11702
|
11702
|
|
|
11703
|
11703
|
// 1、验证数据合规性 并获取 请求 数据
|
|
11704
|
11704
|
$verifyResult = $this->verifyRequestInformation($storeOrderCreateRequestEntity);
|
|
11705
|
|
- /** @var UserEntity $userEntity */
|
|
|
11705
|
+ /** @var UserEntity $userEntity 当前操作用户 */
|
|
11706
|
11706
|
$userEntity = $verifyResult['userEntity'];
|
|
11707
|
|
- /** @var CartEntity[] $cartEntityList */
|
|
|
11707
|
+ /** @var CartEntity[] $cartEntityList 发起创建订单的购物车列表 */
|
|
11708
|
11708
|
$cartEntityList = $verifyResult['cartEntityList'];
|
|
11709
|
11709
|
$cartEntityMap = array_column($cartEntityList, null, 'cartId');
|
|
11710
|
11710
|
$cartIdList = array_keys($cartEntityMap);
|
|
11711
|
|
- /** @var AddressEntity $addressEntity */
|
|
|
11711
|
+ /** @var AddressEntity $addressEntity 地址信息 */
|
|
11712
|
11712
|
$addressEntity = $verifyResult['addressEntity'];
|
|
11713
|
|
- /** @var ShareEntity $shareEntity */
|
|
|
11713
|
+ /** @var ShareEntity $shareEntity 订单所带的分享信息 */
|
|
11714
|
11714
|
$shareEntity = $verifyResult['shareEntity'];
|
|
11715
|
|
- /** @var MerchantEntity[] $merchantEntityMap */
|
|
|
11715
|
+ /** @var MerchantEntity[] $merchantEntityMap 订单所涉及的商户信息映射 */
|
|
11716
|
11716
|
$merchantEntityMap = $verifyResult['merchantEntityMap'];
|
|
11717
|
|
- /** @var StoreProductEntity[] $storeProductEntityMap */
|
|
|
11717
|
+ /** @var StoreProductEntity[] $storeProductEntityMap 订单所涉及的 商品信息 映射 */
|
|
11718
|
11718
|
$storeProductEntityMap = $verifyResult['storeProductEntityMap'];
|
|
11719
|
|
- /** @var StoreProductAttrValueEntity[] $storeProductAttrValueEntityMap */
|
|
|
11719
|
+ /** @var StoreProductAttrValueEntity[] $storeProductAttrValueEntityMap 订单所涉及的 商品属性信息 */
|
|
11720
|
11720
|
$storeProductAttrValueEntityMap = $verifyResult['storeProductAttrValueEntityMap'];
|
|
11721
|
11721
|
|
|
11722
|
11722
|
// 2、加载 需要调用的 模块
|
|
11723
|
11723
|
// 商品秒杀
|
|
11724
|
11724
|
/** @var ProductSeckillRepository $productSeckillRepository */
|
|
11725
|
11725
|
$productSeckillRepository = app()->make(ProductSeckillRepository::class);
|
|
11726
|
|
- // 优惠券 列表(商户or平台)
|
|
11727
|
|
- /** @var StoreCouponRepository $storeCouponRepository */
|
|
11728
|
|
- $storeCouponRepository = app()->make(StoreCouponRepository::class);
|
|
11729
|
|
- // 优惠券 商品 关联表
|
|
11730
|
|
- /** @var StoreCouponProductRepository $storeCouponProductRepository */
|
|
11731
|
|
- $storeCouponProductRepository = app()->make(StoreCouponProductRepository::class);
|
|
11732
|
|
- // 用户的优惠券领取记录
|
|
11733
|
|
- /** @var StoreCouponUserRepository $storeCouponUserRepository */
|
|
11734
|
|
- $storeCouponUserRepository = app()->make(StoreCouponUserRepository::class);
|
|
|
11726
|
+ // // 优惠券 列表(商户or平台)
|
|
|
11727
|
+ // /** @var StoreCouponRepository $storeCouponRepository */
|
|
|
11728
|
+ // $storeCouponRepository = app()->make(StoreCouponRepository::class);
|
|
|
11729
|
+ // // 优惠券 商品 关联表
|
|
|
11730
|
+ // /** @var StoreCouponProductRepository $storeCouponProductRepository */
|
|
|
11731
|
+ // $storeCouponProductRepository = app()->make(StoreCouponProductRepository::class);
|
|
|
11732
|
+ // // 用户的优惠券领取记录
|
|
|
11733
|
+ // /** @var StoreCouponUserRepository $storeCouponUserRepository */
|
|
|
11734
|
+ // $storeCouponUserRepository = app()->make(StoreCouponUserRepository::class);
|
|
11735
|
11735
|
|
|
11736
|
11736
|
// 获取 运费表数据 商品 对应的 运费模板
|
|
11737
|
11737
|
/** @var ShippingTemplateRepository $shippingTemplateRepository */
|
|
|
@@ -11757,23 +11757,22 @@ class StoreOrderRepository extends BaseRepository
|
|
11757
|
11757
|
/** @var StoreCartRepository $storeCartRepository */
|
|
11758
|
11758
|
$storeCartRepository = app()->make(StoreCartRepository::class);
|
|
11759
|
11759
|
|
|
11760
|
|
- // 3、加载 变量
|
|
11761
|
|
- $storeOrderEntityList = [];
|
|
11762
|
|
- $storeCouponUserEntityListByMerIdMap = [];
|
|
11763
|
|
- $totalPrice = 0.00;
|
|
11764
|
|
- $totalPostage = 0.00;
|
|
11765
|
|
- $totalNum = 0;
|
|
11766
|
|
- $totalCost = 0.00;
|
|
11767
|
|
- $yanglaojinMap = [];
|
|
11768
|
|
- $productStockList = [];
|
|
11769
|
|
- $productAttrValueStockList = [];
|
|
|
11760
|
+ // 3、创建 变量
|
|
|
11761
|
+ $storeOrderEntityList = []; // 订单数据实体列表 主要用于写入数据,循环获取数据
|
|
|
11762
|
+ $storeCouponUserEntityListByMerIdMap = []; // 订单优惠券 商户 映射
|
|
|
11763
|
+ $totalPrice = 0.00; // 订单总价
|
|
|
11764
|
+ $totalPostage = 0.00; // 订单总邮费
|
|
|
11765
|
+ $totalNum = 0; // 订单总商品数量
|
|
|
11766
|
+ $totalCost = 0.00; // 订单商品 总成本
|
|
|
11767
|
+ $productStockList = []; // 商品 库存更新列表
|
|
|
11768
|
+ $productAttrValueStockList = []; // 商品 属性 库存更新列表
|
|
11770
|
11769
|
|
|
11771
|
11770
|
// 4、组装数据 每条购物车信息 就是一条订单数据
|
|
11772
|
11771
|
// 循环购物车 对购物车内的商品 进行条件验证 以及根据不同的商品 计算邮费
|
|
11773
|
|
- foreach ($cartEntityList as $cartId => $cartEntity) {
|
|
11774
|
|
- // 商品 实体
|
|
|
11772
|
+ foreach ($cartEntityMap as $cartId => $cartEntity) {
|
|
|
11773
|
+ // 获取商品 实体
|
|
11775
|
11774
|
$productEntity = $storeProductEntityMap[$cartEntity->getProductId()];
|
|
11776
|
|
- // 商品属性 实体
|
|
|
11775
|
+ // 获取商品属性 实体
|
|
11777
|
11776
|
$productAttrValueEntity = $storeProductAttrValueEntityMap[$cartEntity->getProductAttrUnique()];
|
|
11778
|
11777
|
|
|
11779
|
11778
|
// 验证是否是秒杀产品 如果是秒杀产品,并且设置了 大仓会员价 则将大仓会员价 设置为 商品价格
|
|
|
@@ -11923,8 +11922,6 @@ class StoreOrderRepository extends BaseRepository
|
|
11923
|
11922
|
$cost = bcsub($price, $serviceMoney, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
11924
|
11923
|
// 商家 实际可以得到的钱 商家获利部分 + 邮费 - 订单手续费
|
|
11925
|
11924
|
$merMoney = bcsub(bcadd($cost, $postage, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT), $commissionRate, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
11926
|
|
- // 计算养老金 注意 此步骤需要传入商品的价格,因为上述 可能对商品的价格发生了改变
|
|
11927
|
|
- $yanglaojinMap[$cartEntity->getCartId()] = bcadd(0.00, $productRepository->yanglaojin($cartEntity->getProductId(), $price), CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
11928
|
11925
|
|
|
11929
|
11926
|
// 计算总 邮费
|
|
11930
|
11927
|
$totalPostage = bcadd($totalPostage, $postage, 2);
|
|
|
@@ -12014,7 +12011,7 @@ class StoreOrderRepository extends BaseRepository
|
|
12014
|
12011
|
// 5.2 修改 购物车状态
|
|
12015
|
12012
|
$storeCartRepository->updateIsPayByCartIdList($cartIdList);
|
|
12016
|
12013
|
|
|
12017
|
|
- // 5.3 写入 订单组
|
|
|
12014
|
+ // 5.3 写入 组合订单 (支付订单)
|
|
12018
|
12015
|
/** @var StoreGroupOrderRepository $storeGroupOrderRepository */
|
|
12019
|
12016
|
$storeGroupOrderRepository = app()->make(StoreGroupOrderRepository::class);
|
|
12020
|
12017
|
$storeGroupOrderEntity = $storeGroupOrderRepository->createByEntity($storeGroupOrderEntity);
|