|
|
@@ -16,6 +16,7 @@ use app\common\enum\CommonEnum;
|
|
16
|
16
|
use app\common\enum\shipping\ShippingTemplateEnum;
|
|
17
|
17
|
use app\common\enum\store\CartEnum;
|
|
18
|
18
|
use app\common\enum\store\ProductEnum;
|
|
|
19
|
+use app\common\enum\store\StoreOrderEnum;
|
|
19
|
20
|
use app\common\model\store\order\StoreGroupOrder;
|
|
20
|
21
|
use app\common\model\store\order\StoreOrder;
|
|
21
|
22
|
use app\common\model\store\order\StoreRefundOrder;
|
|
|
@@ -50,6 +51,7 @@ use app\common\repositories\wechat\RoutineQrcodeRepository;
|
|
50
|
51
|
use app\common\repositories\wechat\WechatUserRepository;
|
|
51
|
52
|
use app\controller\api\user\Volunteer;
|
|
52
|
53
|
use app\entity\data\merchant\MerchantEntity;
|
|
|
54
|
+use app\entity\data\product\SeckillEntity;
|
|
53
|
55
|
use app\entity\data\product\ShareEntity;
|
|
54
|
56
|
use app\entity\data\store\CartEntity;
|
|
55
|
57
|
use app\entity\data\store\StoreGroupOrderEntity;
|
|
|
@@ -10768,6 +10770,7 @@ class StoreOrderRepository extends BaseRepository
|
|
10768
|
10770
|
$productEntity->setProductType($productEntity->getType());
|
|
10769
|
10771
|
|
|
10770
|
10772
|
// 验证是否是秒杀产品 如果是秒杀产品,并且设置了 大仓会员价 则将大仓会员价 设置为 商品价格
|
|
|
10773
|
+ $seckillEntity = SeckillEntity::newInstance();
|
|
10771
|
10774
|
if ($productEntity->getSeckill() == ProductEnum::SECKILL['Yes']['code'] && !is_null($productEntity->getDcPrice()) && $productEntity->getDcPrice() > 0.00) {
|
|
10772
|
10775
|
// 获取 在活动期间内的 秒杀活动记录
|
|
10773
|
10776
|
$seckillEntity = $seckillRepository->getSeckillEntityByProductId($cartEntity->getProductId());
|
|
|
@@ -10777,7 +10780,8 @@ class StoreOrderRepository extends BaseRepository
|
|
10777
|
10780
|
}
|
|
10778
|
10781
|
}
|
|
10779
|
10782
|
|
|
10780
|
|
- // // 计算优惠券 ****************** 优惠券是此步骤(第一步需要考虑的问题,但是目前阶段暂不需要该功能 所以未完成 先注释)
|
|
|
10783
|
+ // 计算优惠券 ****************** 优惠券是此步骤(第一步需要考虑的问题,但是目前阶段暂不需要该功能 所以未完成 先注释)
|
|
|
10784
|
+ $youhuiPrice = 0.00;
|
|
10781
|
10785
|
// // 商品券 优先于 店铺券
|
|
10782
|
10786
|
// // 商品券(平台优惠券)
|
|
10783
|
10787
|
// if (!isset($storeCouponUserEntityListByMerIdMap[0])) {
|
|
|
@@ -10953,7 +10957,15 @@ class StoreOrderRepository extends BaseRepository
|
|
10953
|
10957
|
->setShareUid($shareEntity->getUid())
|
|
10954
|
10958
|
->setServiceMoney($serviceMoney)
|
|
10955
|
10959
|
->setTestOrder($userEntity->getTestUser())
|
|
10956
|
|
- ->setDacangId($productEntity->getDcId());
|
|
|
10960
|
+ ->setDacangId($productEntity->getDcId())
|
|
|
10961
|
+ ->setDistributionMode(StoreOrderEnum::DISTRIBUTION_MODE['ExpressDelivery']['code'])
|
|
|
10962
|
+ ->setAddressId($addressEntity->getAddressId())
|
|
|
10963
|
+ ->setSeckill($seckillEntity->getId())
|
|
|
10964
|
+ ->setYouhuiPrice($youhuiPrice)
|
|
|
10965
|
+ ->setDouhuomall(empty($productEntity->getSpuId())?StoreOrderEnum::DOHUOMALL['PlatformOrder']['code']:StoreOrderEnum::DOHUOMALL['SupplyChainOrder']['code'])
|
|
|
10966
|
+ ->setDouhuomallStatus(StoreOrderEnum::DOHUOMALL_STATUS['NotSubmittedToWeiweiBao']['code'])
|
|
|
10967
|
+ ->setFzonePaytype($storeOrderCreateRequestEntity->getFzonePayType())
|
|
|
10968
|
+ ->setConPri($serviceMoney);
|
|
10957
|
10969
|
|
|
10958
|
10970
|
|
|
10959
|
10971
|
|
|
|
@@ -10977,294 +10989,4 @@ class StoreOrderRepository extends BaseRepository
|
|
10977
|
10989
|
|
|
10978
|
10990
|
return [];
|
|
10979
|
10991
|
}
|
|
10980
|
|
-
|
|
10981
|
|
- /**
|
|
10982
|
|
- * @param CartEntity[] $cartEntityList
|
|
10983
|
|
- * @param AddressEntity $addressEntity
|
|
10984
|
|
- * @param UserEntity $userEntity
|
|
10985
|
|
- * @return array
|
|
10986
|
|
- */
|
|
10987
|
|
- public function cartIdByOrderInfoNew(array $cartEntityList, AddressEntity $addressEntity, UserEntity $userEntity)
|
|
10988
|
|
- {
|
|
10989
|
|
- // 商户
|
|
10990
|
|
- /** @var MerchantRepository $merchantRepository */
|
|
10991
|
|
- $merchantRepository = app()->make(MerchantRepository::class);
|
|
10992
|
|
- // 商品
|
|
10993
|
|
- /** @var ProductRepository $productRepository */
|
|
10994
|
|
- $productRepository = app()->make(ProductRepository::class);
|
|
10995
|
|
- // 商品属性
|
|
10996
|
|
- /** @var ProductAttrValueRepository $productAttrValueRepository */
|
|
10997
|
|
- $productAttrValueRepository = app()->make(ProductAttrValueRepository::class);
|
|
10998
|
|
- // 目前还未搞清这个表的意义
|
|
10999
|
|
- /** @var SeckillRepository $seckillRepository */
|
|
11000
|
|
- $seckillRepository = app()->make(SeckillRepository::class);
|
|
11001
|
|
- // 商户设置秒杀商品关联表
|
|
11002
|
|
- /** @var StoreSeckillActiveRepository $storeSeckillActiveRepository */
|
|
11003
|
|
- $storeSeckillActiveRepository = app()->make(StoreSeckillActiveRepository::class);
|
|
11004
|
|
-
|
|
11005
|
|
- // 优惠券 列表(商户or平台)
|
|
11006
|
|
- /** @var StoreCouponRepository $storeCouponRepository */
|
|
11007
|
|
- $storeCouponRepository = app()->make(StoreCouponRepository::class);
|
|
11008
|
|
- // 优惠券 商品 关联表
|
|
11009
|
|
- /** @var StoreCouponProductRepository $storeCouponProductRepository */
|
|
11010
|
|
- $storeCouponProductRepository = app()->make(StoreCouponProductRepository::class);
|
|
11011
|
|
- // 用户的优惠券领取记录
|
|
11012
|
|
- /** @var StoreCouponUserRepository $storeCouponUserRepository */
|
|
11013
|
|
- $storeCouponUserRepository = app()->make(StoreCouponUserRepository::class);
|
|
11014
|
|
-
|
|
11015
|
|
- // 获取 运费表数据 商品 对应的 运费模板
|
|
11016
|
|
- /** @var ShippingTemplateRepository $shippingTemplateRepository */
|
|
11017
|
|
- $shippingTemplateRepository = app()->make(ShippingTemplateRepository::class);
|
|
11018
|
|
- // 获取 商品 对应的 运费模板 de 指定不配送区域表
|
|
11019
|
|
- /** @var ShippingTemplateUndeliveRepository $shippingTemplateUndeliveRepository */
|
|
11020
|
|
- $shippingTemplateUndeliveRepository = app()->make(ShippingTemplateUndeliveRepository::class);
|
|
11021
|
|
- // 获取 商品 对应的 运费模板 de 指定包邮信息表
|
|
11022
|
|
- /** @var ShippingTemplateFreeRepository $shippingTemplateFreeRepository */
|
|
11023
|
|
- $shippingTemplateFreeRepository = app()->make(ShippingTemplateFreeRepository::class);
|
|
11024
|
|
- // 获取 商品 对应的 运费模板 de 配送区域表
|
|
11025
|
|
- /** @var ShippingTemplateRegionRepository $shippingTemplateRegionRepository */
|
|
11026
|
|
- $shippingTemplateRegionRepository = app()->make(ShippingTemplateRegionRepository::class);
|
|
11027
|
|
-
|
|
11028
|
|
- // 记录 用户 在指定商家的 优惠券
|
|
11029
|
|
- $storeCouponUserEntityListByMerIdMap = [];
|
|
11030
|
|
- // 当前优惠金额
|
|
11031
|
|
- $couponPrice = 0.00;
|
|
11032
|
|
- // 需要使用掉的优惠券
|
|
11033
|
|
- $useCouponProduct = [];
|
|
11034
|
|
-
|
|
11035
|
|
- // 商家列表 按 订单信息按 商家分组
|
|
11036
|
|
- $merchantMap = [];
|
|
11037
|
|
- // 记录 每家商户 每类商品 在此笔订单中的金额(只记录普通商品)
|
|
11038
|
|
- // 商品 => 此笔订单内此商品总价
|
|
11039
|
|
- $productPriceByMerIdMap = [];
|
|
11040
|
|
- // 订单所产生的养老金
|
|
11041
|
|
- $yanglaojin = 0.00;
|
|
11042
|
|
- // 订单总金额 (只含普通商品)
|
|
11043
|
|
- $validTotalPrice = 0.00;
|
|
11044
|
|
- // 订单总金额 (包含 秒杀商品价格)
|
|
11045
|
|
- $totalPrice = 0.00;
|
|
11046
|
|
- // 订单总数量
|
|
11047
|
|
- $totalNum = 0;
|
|
11048
|
|
- // 此笔订单产生的总 邮费
|
|
11049
|
|
- $postage = 0.00;
|
|
11050
|
|
-
|
|
11051
|
|
- $result = [];
|
|
11052
|
|
-
|
|
11053
|
|
- // 循环购物车 对购物车内的商品 进行条件验证 以及根据不同的商品 计算邮费
|
|
11054
|
|
- foreach ($cartEntityList as $cartEntity) {
|
|
11055
|
|
- // 验证商户
|
|
11056
|
|
- $merchantEntity = $merchantRepository->getMerchantEntityByMerchantId($cartEntity->getMerId());
|
|
11057
|
|
- if (empty($merchantEntity->getMerId())) {
|
|
11058
|
|
- throw new ValidateException('未查询到商户信息');
|
|
11059
|
|
- }
|
|
11060
|
|
-
|
|
11061
|
|
- // 获取购物车商品信息
|
|
11062
|
|
- $productEntity = $productRepository->getProductEntityByProductId($cartEntity->getProductId());
|
|
11063
|
|
- if (empty($productEntity->getProductId())) {
|
|
11064
|
|
- throw new ValidateException('未查询到商品信息');
|
|
11065
|
|
- }
|
|
11066
|
|
- if ($productEntity->getMerId() != $merchantEntity->getMerId()) {
|
|
11067
|
|
- throw new ValidateException('商家已下架该产品');
|
|
11068
|
|
- }
|
|
11069
|
|
-
|
|
11070
|
|
- // 获取购物车商品属性信息
|
|
11071
|
|
- $productAttrValueEntity = $productAttrValueRepository->getProductAttrValueEntityByUnique($cartEntity->getProductAttrUnique());
|
|
11072
|
|
- if (empty($productAttrValueEntity->getProductId())) {
|
|
11073
|
|
- throw new ValidateException('未查询到商品属性信息');
|
|
11074
|
|
- }
|
|
11075
|
|
-
|
|
11076
|
|
- // 判断订单是否已失效
|
|
11077
|
|
- if ($cartEntity->getIsFail() == CartEnum::IS_FAIL['Yes']['code']) {
|
|
11078
|
|
- throw new ValidateException($productEntity->getStoreName() . ' 已失效');
|
|
11079
|
|
- }
|
|
11080
|
|
-
|
|
11081
|
|
- // 如果商品类型是 普通商品 ,则判断库存是否充足
|
|
11082
|
|
- if ($cartEntity->getProductType() == CartEnum::PRODUCT_TYPE['Ordinary']['code']) {
|
|
11083
|
|
- if ($productAttrValueEntity->getStock() < $cartEntity->getCartNum()) {
|
|
11084
|
|
- throw new ValidateException($productEntity->getStoreName() . ' 库存不足--' . $cartEntity->getCartNum());
|
|
11085
|
|
- }
|
|
11086
|
|
- } else {
|
|
11087
|
|
- // 如果是秒杀商品 应该首先判断是否还在活动期间内(rrx_store_seckill_active 商户设置秒杀商品关联表)
|
|
11088
|
|
- $seckillActiveEntity = $storeSeckillActiveRepository->getSeckillActiveEntityByProductIdInActive($cartEntity->getProductId());
|
|
11089
|
|
- if (empty($seckillActiveEntity->getSeckillActiveId())) {
|
|
11090
|
|
- throw new ValidateException($productEntity->getStoreName() . ' 秒杀活动已失效');
|
|
11091
|
|
- }
|
|
11092
|
|
-
|
|
11093
|
|
- // 如果不是普通商品 则是否秒杀产品,如果是秒杀产品则判断是否超卖
|
|
11094
|
|
- if (!$this->getDayPayCount($cartEntity->getUid(), $cartEntity->getProductId()) || !$this->getPayCount($cartEntity->getUid(), $cartEntity->getProductId())) {
|
|
11095
|
|
- throw new ValidateException($productEntity->getStoreName() . ' 已超出购买限制');
|
|
11096
|
|
- }
|
|
11097
|
|
- }
|
|
11098
|
|
-
|
|
11099
|
|
- // 开始 计算 **************
|
|
11100
|
|
-
|
|
11101
|
|
- // ??? 暂时不理解这一步
|
|
11102
|
|
- // type => '商品类型:1:普通商品。2:爆款商品。3:消费积分商品 。5:会员专享商品(城中大仓)6:每日免费领商品 7:商户特殊商品 8:共富会员商品 9:共富高级会员商品 10:高级会员商品 11村代理商品(废弃) 12镇代理商品(废弃) 13县代理商品(废弃) 14- 合伙人商品 15 股权商品 16合伙人+股权商品',
|
|
11103
|
|
- // ProductType => 0.普通商品 1.秒杀商品
|
|
11104
|
|
- $productEntity->setProductType($productEntity->getType());
|
|
11105
|
|
-
|
|
11106
|
|
- // 验证是否是秒杀产品 如果是秒杀产品,并且设置了 大仓会员价 则将大仓会员价 设置为 商品价格
|
|
11107
|
|
- if ($productEntity->getSeckill() == ProductEnum::SECKILL['Yes']['code'] && !is_null($productEntity->getDcPrice()) && $productEntity->getDcPrice() > 0.00) {
|
|
11108
|
|
- // 获取 在活动期间内的 秒杀活动记录
|
|
11109
|
|
- $seckillEntity = $seckillRepository->getSeckillEntityByProductId($cartEntity->getProductId());
|
|
11110
|
|
- if (!empty($seckillEntity->getId())) {
|
|
11111
|
|
- // 把 商品属性的 价格 改成 大仓会员价
|
|
11112
|
|
- $productAttrValueEntity->setPrice($productEntity->getDcPrice());
|
|
11113
|
|
- }
|
|
11114
|
|
- }
|
|
11115
|
|
-
|
|
11116
|
|
- // // 计算优惠券 ****************** 优惠券是此步骤(第一步需要考虑的问题,但是目前阶段暂不需要该功能 所以未完成 先注释)
|
|
11117
|
|
- // // 商品券 优先于 店铺券
|
|
11118
|
|
- // // 商品券(平台优惠券)
|
|
11119
|
|
- // if (!isset($storeCouponUserEntityListByMerIdMap[0])) {
|
|
11120
|
|
- // $storeCouponUserEntityListByMerIdMap[0] = $storeCouponUserRepository->getValidStoreCouponUserEntityListByMerIdAndUid(0, $cartEntity->getUid());
|
|
11121
|
|
- // }
|
|
11122
|
|
- // // 店铺券(满减券)
|
|
11123
|
|
- // if (!isset($storeCouponUserEntityListByMerIdMap[$merchantEntity->getMerId()])) {
|
|
11124
|
|
- // // 查询 当前用户 在当前 店铺的 优惠券
|
|
11125
|
|
- // $storeCouponUserEntityListByMerIdMap[$merchantEntity->getMerId()] = $storeCouponUserRepository->getValidStoreCouponUserEntityListByMerIdAndUid($merchantEntity->getMerId(), $cartEntity->getUid());
|
|
11126
|
|
- // }
|
|
11127
|
|
- //
|
|
11128
|
|
- // if (!empty($storeCouponUserEntityListByMerIdMap[0]) || !empty($storeCouponUserEntityListByMerIdMap[$merchantEntity->getMerId()])) {
|
|
11129
|
|
- // foreach ([0, $merchantEntity->getMerId()] as $merId) {
|
|
11130
|
|
- // foreach ($storeCouponUserEntityListByMerIdMap[$merId] as $storeCouponUserEntity) {
|
|
11131
|
|
- // // 如果不能明确当前优惠券的 获取方式 ,则忽略当前的优惠券的有效性
|
|
11132
|
|
- // if (empty($storeCouponUserEntity->getType())) {
|
|
11133
|
|
- // continue;
|
|
11134
|
|
- // }
|
|
11135
|
|
- // // 优惠卷关联商品 辅助表
|
|
11136
|
|
- // $storeCouponProductEntityList = $storeCouponProductRepository->getStoreCouponProductEntityListByCouponId($storeCouponUserEntity->getCouponId());
|
|
11137
|
|
- // if (!empty($storeCouponProductEntityList)) {
|
|
11138
|
|
- // // 商品券
|
|
11139
|
|
- // foreach ($storeCouponProductEntityList as $storeCouponProductEntity) {
|
|
11140
|
|
- // // 如果当前 优惠券 所关联的 商品 是否在当前购买的 该商家的 商品列表中,(没有则说明此条关联记录 无用) 并且当前 该商家内 该商品没有已使用的优惠券
|
|
11141
|
|
- // if (in_array($storeCouponProductEntity->getProductId(), array_keys($productPriceByMerIdMap[$merchantEntity->getMerId()])) && !isset($useCouponProduct[$storeCouponProductEntity->getProductId()][$cartEntity->getCartId()])) {
|
|
11142
|
|
- // // 如果 当前该商家 该商品 的价格 超过了 “最低消费多少金额可用优惠券” 的金额 则记录该优惠金额,并记录该优惠券ID 后续设置为已使用
|
|
11143
|
|
- // if (($productAttrValueEntity->getPrice()) >= $storeCouponUserEntity->getUseMinPrice()) {
|
|
11144
|
|
- // $couponPrice = bcadd($couponPrice, $storeCouponUserEntity->getCouponPrice(), 2);
|
|
11145
|
|
- // // 一个商家的 一种商品 只能使用一次优惠券
|
|
11146
|
|
- // $useCouponProduct[$storeCouponProductEntity->getProductId()][$cartEntity->getCartId()][] = $storeCouponUserEntity->getCouponUserId();
|
|
11147
|
|
- // break;
|
|
11148
|
|
- // }
|
|
11149
|
|
- // }
|
|
11150
|
|
- // }
|
|
11151
|
|
- // } else {
|
|
11152
|
|
- // // 店铺券(平台券-满减券)
|
|
11153
|
|
- //
|
|
11154
|
|
- // }
|
|
11155
|
|
- // }
|
|
11156
|
|
- // }
|
|
11157
|
|
- // }
|
|
11158
|
|
-
|
|
11159
|
|
- // 计算单价 systemConfig('mer_365');
|
|
11160
|
|
- $price = bcmul($cartEntity->getCartNum(), $productAttrValueEntity->getPrice(), 2);
|
|
11161
|
|
- // 计算养老金 注意 此步骤需要传入商品的价格,因为上述 可能对商品的价格发生了改变
|
|
11162
|
|
- $yanglaojin = bcadd($yanglaojin, $productRepository->yanglaojin($cartEntity->getProductId(), $price), 2);
|
|
11163
|
|
- // 计算总价
|
|
11164
|
|
- $totalPrice = bcadd($totalPrice, $price, 2);
|
|
11165
|
|
- // 计算总数
|
|
11166
|
|
- $totalNum = bcadd($totalNum, $cartEntity->getCartNum(), 2);
|
|
11167
|
|
-
|
|
11168
|
|
- // 如果是 普通商品 product_type 类型 0=普通产品
|
|
11169
|
|
- if ($cartEntity->getProductType() == CartEnum::PRODUCT_TYPE['Ordinary']['code']) {
|
|
11170
|
|
- $validTotalPrice = bcadd($validTotalPrice, $price, 2);
|
|
11171
|
|
- }
|
|
11172
|
|
-
|
|
11173
|
|
- // 计算运费 获取该商品的运费模板 运费表
|
|
11174
|
|
- // TODO 注意 这个地址好像有问题,我再 客户端->收货地址管理中 (rrx_user_address)增加的廊坊市 对应的城市编号是(code_list)315 且city_id 字段的值是 2,而我再后台设置 可配送地址时 ,廊坊市对应的编码是 58247
|
|
11175
|
|
- // 判断商品是否是 供应链(微唯宝)商品
|
|
11176
|
|
- if (!empty($productAttrValueEntity->getGongSkuId())) {
|
|
11177
|
|
- $freight = GongApiRequest::freight($addressEntity->getCityId(), [['sku_id' => $productAttrValueEntity->getGongSkuId(), 'num' => $cartEntity->getCartNum()]]);
|
|
11178
|
|
- $freight = $freight['freight'] ?? 0;
|
|
11179
|
|
- $postage = bcadd($postage, $freight, 2);
|
|
11180
|
|
- } else {
|
|
11181
|
|
- $shippingTemplateEntity = $shippingTemplateRepository->getShippingTemplateEntityByShippingTemplateId($productEntity->getTempId());
|
|
11182
|
|
- if (empty($shippingTemplateEntity->getShippingTemplateId())) {
|
|
11183
|
|
- throw new ValidateException('未查询到商品所绑定的运费模板');
|
|
11184
|
|
- } else {
|
|
11185
|
|
- // 判断是否开启 开启指定区域不配送
|
|
11186
|
|
- if ($shippingTemplateEntity->getUndelivery() == ShippingTemplateEnum::UNDELIVERY['Yes']['code']) {
|
|
11187
|
|
- // 获取运费模板的 指定不配送区域列表
|
|
11188
|
|
- $shippingTemplateUndeliveryEntityList = $shippingTemplateUndeliveRepository->getShippingTemplateUndeliveryEntityListByTempId($shippingTemplateEntity->getShippingTemplateId());
|
|
11189
|
|
- foreach ($shippingTemplateUndeliveryEntityList as $shippingTemplateUndeliveryEntity) {
|
|
11190
|
|
- // 验证 此次配送地址 是否在不配送区域中
|
|
11191
|
|
- if (in_array($addressEntity->getCityId(), $shippingTemplateUndeliveryEntity->getCityIdList())) {
|
|
11192
|
|
- throw new ValidateException($productEntity->getStoreName() . '此商品不支持该配送区域');
|
|
11193
|
|
- }
|
|
11194
|
|
- }
|
|
11195
|
|
- }
|
|
11196
|
|
-
|
|
11197
|
|
- $isBaoYou = false;
|
|
11198
|
|
- $number = 0.00;
|
|
11199
|
|
- // 获取 当前商品的 计费方式 (计费方式 0=数量 1=重量 2=体积)
|
|
11200
|
|
- if ($shippingTemplateEntity->getType() == ShippingTemplateEnum::TYPE['Quantity']['code']) {
|
|
11201
|
|
- $number = $cartEntity->getCartNum();
|
|
11202
|
|
- } else if ($shippingTemplateEntity->getType() == ShippingTemplateEnum::TYPE['Weight']['code']) {
|
|
11203
|
|
- $number = bcmul($cartEntity->getCartNum(), $productAttrValueEntity->getWeight(), 2);
|
|
11204
|
|
- } else {
|
|
11205
|
|
- $number = bcmul($cartEntity->getCartNum(), $productAttrValueEntity->getVolume(), 2);
|
|
11206
|
|
- }
|
|
11207
|
|
-
|
|
11208
|
|
- // 获取 指定包邮信息 包邮信息表
|
|
11209
|
|
- $shippingTemplateFreeEntityList = $shippingTemplateFreeRepository->getShippingTemplateFreeEntityListByTempId($shippingTemplateEntity->getShippingTemplateId());
|
|
11210
|
|
- foreach ($shippingTemplateFreeEntityList as $shippingTemplateFreeEntity) {
|
|
11211
|
|
- // 判断当前收货地址 是不是 在 指定 包邮 地点内
|
|
11212
|
|
- if (in_array($addressEntity->getCityId(), $shippingTemplateFreeEntity->getCityIdList())) {
|
|
11213
|
|
- // 判断当前 商品 是否符合 最高包邮数量上限 和 最低包邮金额
|
|
11214
|
|
- if ($number <= $shippingTemplateFreeEntity->getNumber() && $price >= $shippingTemplateFreeEntity->getPrice()) {
|
|
11215
|
|
- $isBaoYou = true;
|
|
11216
|
|
- }
|
|
11217
|
|
- }
|
|
11218
|
|
- }
|
|
11219
|
|
-
|
|
11220
|
|
- // 如果不包邮 则需要计算邮费
|
|
11221
|
|
- if (!$isBaoYou){
|
|
11222
|
|
- // 配送区域表
|
|
11223
|
|
- $shippingTemplateRegionEntityList = $shippingTemplateRegionRepository->getShippingTemplateRegionEntityListByTempId($shippingTemplateEntity->getShippingTemplateId());
|
|
11224
|
|
- foreach ($shippingTemplateRegionEntityList as $shippingTemplateRegionEntity) {
|
|
11225
|
|
- // 判断当前收货地址 是否在可配送区域内
|
|
11226
|
|
- if (in_array($addressEntity->getCityId(), $shippingTemplateRegionEntity->getCityIdList())) {
|
|
11227
|
|
- // 比如 该商品 重量 5.03kg 首件重量 2kg 运费 2元 续件重量 3kg 续费3元
|
|
11228
|
|
- // 那本次 运费就是 首件运费 + ((重量 - 首件重量)/续件重量) * 续费单价
|
|
11229
|
|
- // 那本次 运费就是 2 + ((5.03 - 2)/3)向上取整 * 3 = 8
|
|
11230
|
|
- // 首件(重量or体积) 运费计算
|
|
11231
|
|
- $postage = bcadd($postage, $shippingTemplateRegionEntity->getFirstPrice(), 2);
|
|
11232
|
|
- if ($number > $shippingTemplateRegionEntity->getFirst()) {
|
|
11233
|
|
- // 数量(重量or体积) 超出 首件部分 也就是续费部分
|
|
11234
|
|
- $excess = bcsub($number, $shippingTemplateRegionEntity->getFirst(), 3);
|
|
11235
|
|
- // 查看 需 续费几次 并向上取整
|
|
11236
|
|
- $continueNum = ceil(bcdiv($excess, $shippingTemplateRegionEntity->getContinue(), 3));
|
|
11237
|
|
- $continueCost = bcmul($continueNum, $shippingTemplateRegionEntity->getContinuePrice(), 2);
|
|
11238
|
|
- $postage = bcadd($postage, $continueCost, 2);
|
|
11239
|
|
- }
|
|
11240
|
|
- }
|
|
11241
|
|
- }
|
|
11242
|
|
- }
|
|
11243
|
|
- }
|
|
11244
|
|
- }
|
|
11245
|
|
-
|
|
11246
|
|
-
|
|
11247
|
|
-
|
|
11248
|
|
- // 会员专区
|
|
11249
|
|
- if ($productEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['MemberZone']['code']) {
|
|
11250
|
|
-
|
|
11251
|
|
- }
|
|
11252
|
|
-
|
|
11253
|
|
-
|
|
11254
|
|
-
|
|
11255
|
|
- }
|
|
11256
|
|
-
|
|
11257
|
|
-
|
|
11258
|
|
-
|
|
11259
|
|
- return [
|
|
11260
|
|
- 'youhui_price' => 0.00, // 随机减金额
|
|
11261
|
|
- 'order_price' => 0.00,
|
|
11262
|
|
- 'total_price' => 0.00, // 订单总价
|
|
11263
|
|
- 'address' => $address,
|
|
11264
|
|
- 'order' => $merchantInfo,
|
|
11265
|
|
- 'status' => $status,
|
|
11266
|
|
- 'is_dacang_vip_product' => $is_dacang_vip_product,
|
|
11267
|
|
- 'youhui_price_key' => $uid_youhui_price_str ?? ''
|
|
11268
|
|
- ];
|
|
11269
|
|
- }
|
|
11270
|
10992
|
}
|