buyer order support skup type of hongkong
Showing
14 changed files
with
215 additions
and
41 deletions
1 | package com.yohoufo.order.charge; | 1 | package com.yohoufo.order.charge; |
2 | 2 | ||
3 | import com.yoho.core.common.utils.YHMath; | 3 | import com.yoho.core.common.utils.YHMath; |
4 | +import com.yohobuy.ufo.model.order.constants.DeliveryWayEnum; | ||
4 | import com.yohobuy.ufo.model.promotion.UserCouponsBo; | 5 | import com.yohobuy.ufo.model.promotion.UserCouponsBo; |
5 | import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum; | 6 | import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum; |
6 | import com.yohoufo.common.exception.UfoServiceException; | 7 | import com.yohoufo.common.exception.UfoServiceException; |
8 | +import com.yohoufo.common.utils.BigDecimalHelper; | ||
7 | import com.yohoufo.order.charge.coupon.CouponService; | 9 | import com.yohoufo.order.charge.coupon.CouponService; |
8 | import com.yohoufo.order.charge.model.*; | 10 | import com.yohoufo.order.charge.model.*; |
9 | import com.yohoufo.order.service.support.DeliveryWayCostSupport; | 11 | import com.yohoufo.order.service.support.DeliveryWayCostSupport; |
@@ -15,10 +17,13 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -15,10 +17,13 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
15 | import org.springframework.stereotype.Component; | 17 | import org.springframework.stereotype.Component; |
16 | 18 | ||
17 | import java.math.BigDecimal; | 19 | import java.math.BigDecimal; |
18 | -import java.util.*; | 20 | +import java.util.List; |
21 | +import java.util.Objects; | ||
22 | +import java.util.Optional; | ||
19 | 23 | ||
20 | import static com.yohoufo.order.charge.model.ChargeParam.*; | 24 | import static com.yohoufo.order.charge.model.ChargeParam.*; |
21 | -import static com.yohoufo.order.constants.ApiVersionConfig.*; | 25 | +import static com.yohoufo.order.constants.ApiVersionConfig.ApiVersion; |
26 | +import static com.yohoufo.order.constants.ApiVersionConfig.Payment; | ||
22 | 27 | ||
23 | /** | 28 | /** |
24 | * Created by jiexiang.wu on 2018/11/19. | 29 | * Created by jiexiang.wu on 2018/11/19. |
@@ -75,14 +80,15 @@ public class ChargeService { | @@ -75,14 +80,15 @@ public class ChargeService { | ||
75 | ChargeResult chargeResult = chargeContext.getChargeResult(); | 80 | ChargeResult chargeResult = chargeContext.getChargeResult(); |
76 | //算费商品 | 81 | //算费商品 |
77 | ChargeGoods chargeGoods = chargeContext.getChargeGoods(); | 82 | ChargeGoods chargeGoods = chargeContext.getChargeGoods(); |
78 | - | ||
79 | - chargeResult.setGoodsAmount(chargeGoods.getRealPrice().doubleValue()); | ||
80 | - chargeResult.setFinalAmount(chargeGoods.getRealPrice().doubleValue()); | ||
81 | - logger.info("[{}] step goods charge,goodsPrice:{},goodsAmount:{},amount:{}", | 83 | + BigDecimal goodsRealPrice = chargeGoods.getRealPrice(); |
84 | + chargeResult.setGoodsAmount(goodsRealPrice.doubleValue()); | ||
85 | + chargeResult.setFinalAmount(goodsRealPrice.doubleValue()); | ||
86 | + BigDecimal tariffRate = chargeGoods.getTariffRate(); | ||
87 | + logger.info("[{}] step goods charge,goodsPrice:{},goodsAmount:{},amount:{} tariffRate {}", | ||
82 | chargeContext.getChargeParam().getUid(), | 88 | chargeContext.getChargeParam().getUid(), |
83 | chargeGoods.getGoodsPrice(), | 89 | chargeGoods.getGoodsPrice(), |
84 | chargeResult.getGoodsAmount(), | 90 | chargeResult.getGoodsAmount(), |
85 | - chargeResult.getFinalAmount()); | 91 | + chargeResult.getFinalAmount(), tariffRate); |
86 | 92 | ||
87 | //活动优惠 | 93 | //活动优惠 |
88 | ActivityPrice activityPrice = chargeContext.getActivityPrice(); | 94 | ActivityPrice activityPrice = chargeContext.getActivityPrice(); |
@@ -96,6 +102,17 @@ public class ChargeService { | @@ -96,6 +102,17 @@ public class ChargeService { | ||
96 | 102 | ||
97 | double oldFinalAmount = chargeResult.getFinalAmount(); | 103 | double oldFinalAmount = chargeResult.getFinalAmount(); |
98 | double newFinalAmount = Math.max(0, YHMath.sub(oldFinalAmount, realCutPrice.doubleValue())); | 104 | double newFinalAmount = Math.max(0, YHMath.sub(oldFinalAmount, realCutPrice.doubleValue())); |
105 | + | ||
106 | + //加上税费 | ||
107 | + double tariffAmount = 0D; | ||
108 | + if (tariffRate!=null && tariffRate.compareTo(BigDecimal.ZERO)>0){ | ||
109 | + tariffAmount = BigDecimalHelper.halfUp(goodsRealPrice.multiply(tariffRate)).doubleValue(); | ||
110 | + } | ||
111 | + if (tariffAmount > 0D){ | ||
112 | + chargeResult.setTariffAmount(tariffAmount); | ||
113 | + newFinalAmount = YHMath.add(tariffAmount, newFinalAmount); | ||
114 | + } | ||
115 | + | ||
99 | chargeResult.setFinalAmount(newFinalAmount); | 116 | chargeResult.setFinalAmount(newFinalAmount); |
100 | 117 | ||
101 | ActivityCutResult activityCutResult = ActivityCutResult.builder() | 118 | ActivityCutResult activityCutResult = ActivityCutResult.builder() |
@@ -105,10 +122,11 @@ public class ChargeService { | @@ -105,10 +122,11 @@ public class ChargeService { | ||
105 | .build(); | 122 | .build(); |
106 | chargeResult.setActivityCutResult(activityCutResult); | 123 | chargeResult.setActivityCutResult(activityCutResult); |
107 | 124 | ||
108 | - logger.info("[{}] step activity charge,goodsPrice:{},realPrice:{},oldFinalAmount:{},newFinalAmount:{},activityPrice:{},activityCutResult:{}", | 125 | + logger.info("[{}] step activity charge,goodsPrice:{},realPrice:{},tariffAmount {},oldFinalAmount:{},newFinalAmount:{},activityPrice:{},activityCutResult:{}", |
109 | chargeContext.getChargeParam().getUid(), | 126 | chargeContext.getChargeParam().getUid(), |
110 | chargeGoods.getGoodsPrice(), | 127 | chargeGoods.getGoodsPrice(), |
111 | chargeGoods.getRealPrice(), | 128 | chargeGoods.getRealPrice(), |
129 | + tariffAmount, | ||
112 | oldFinalAmount, chargeResult.getFinalAmount(), | 130 | oldFinalAmount, chargeResult.getFinalAmount(), |
113 | activityPrice, | 131 | activityPrice, |
114 | chargeResult.getActivityCutResult()); | 132 | chargeResult.getActivityCutResult()); |
@@ -123,7 +141,26 @@ public class ChargeService { | @@ -123,7 +141,26 @@ public class ChargeService { | ||
123 | private void calculateShippingAmount(ChargeContext chargeContext) { | 141 | private void calculateShippingAmount(ChargeContext chargeContext) { |
124 | double deliveryWayCost = 0D; | 142 | double deliveryWayCost = 0D; |
125 | //如果是门店自提,则免运费 | 143 | //如果是门店自提,则免运费 |
126 | - if (shoppingSupport.isDeliveryWayByStore(chargeContext.getChargeParam().getDeliveryWay())){ | 144 | + DeliveryWayEnum deliveryWay = DeliveryWayEnum.getByCode(chargeContext.getChargeParam().getDeliveryWay()); |
145 | + if (deliveryWay == null){ | ||
146 | + deliveryWayCost = deliveryWayCostSupport.getCostOfSf(); | ||
147 | + }else{ | ||
148 | + switch (deliveryWay){ | ||
149 | + case SELF_FETCH: | ||
150 | + deliveryWayCost = 0D; | ||
151 | + break; | ||
152 | + case OVERSEAS_HONGHONG: | ||
153 | + deliveryWayCost = deliveryWayCostSupport.getCostFromHk(); | ||
154 | + break; | ||
155 | + case SF: | ||
156 | + default: | ||
157 | + deliveryWayCost = deliveryWayCostSupport.getCostOfSf(); | ||
158 | + break; | ||
159 | + } | ||
160 | + } | ||
161 | + | ||
162 | + /* | ||
163 | + if (shoppingSupport.isDeliveryWayByStore()){ | ||
127 | deliveryWayCost = 0D; | 164 | deliveryWayCost = 0D; |
128 | }else/* if(chargeContext.getUserAddressPair() != null){ | 165 | }else/* if(chargeContext.getUserAddressPair() != null){ |
129 | String areaCode = chargeContext.getUserAddressPair().getLeft().getAreaCode(); | 166 | String areaCode = chargeContext.getUserAddressPair().getLeft().getAreaCode(); |
@@ -133,9 +170,11 @@ public class ChargeService { | @@ -133,9 +170,11 @@ public class ChargeService { | ||
133 | if (chargeContext.isShipFeeRequird()){ | 170 | if (chargeContext.isShipFeeRequird()){ |
134 | deliveryWayCost = deliveryWayCostSupport.getCostOfSf(); | 171 | deliveryWayCost = deliveryWayCostSupport.getCostOfSf(); |
135 | } | 172 | } |
136 | - }*/{ | 173 | + }*/ |
174 | + /*{ | ||
137 | deliveryWayCost = deliveryWayCostSupport.getCostOfSf(); | 175 | deliveryWayCost = deliveryWayCostSupport.getCostOfSf(); |
138 | } | 176 | } |
177 | + */ | ||
139 | //运费 | 178 | //运费 |
140 | chargeContext.getChargeResult().setDeliveryWay(chargeContext.getChargeParam().getDeliveryWay()); | 179 | chargeContext.getChargeResult().setDeliveryWay(chargeContext.getChargeParam().getDeliveryWay()); |
141 | chargeContext.getChargeResult().setShippingAmount(deliveryWayCost); | 180 | chargeContext.getChargeResult().setShippingAmount(deliveryWayCost); |
1 | package com.yohoufo.order.charge.model; | 1 | package com.yohoufo.order.charge.model; |
2 | 2 | ||
3 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
3 | import lombok.Data; | 4 | import lombok.Data; |
4 | import lombok.ToString; | 5 | import lombok.ToString; |
5 | import lombok.Builder; | 6 | import lombok.Builder; |
@@ -20,12 +21,16 @@ public class ChargeGoods { | @@ -20,12 +21,16 @@ public class ChargeGoods { | ||
20 | 21 | ||
21 | private int attributes; | 22 | private int attributes; |
22 | 23 | ||
24 | + private SkupType skupType; | ||
25 | + | ||
23 | /** | 26 | /** |
24 | * 商品金额 | 27 | * 商品金额 |
25 | */ | 28 | */ |
26 | private BigDecimal goodsPrice; | 29 | private BigDecimal goodsPrice; |
27 | - | ||
28 | - | 30 | + /** |
31 | + * 关税费率 | ||
32 | + */ | ||
33 | + private BigDecimal tariffRate; | ||
29 | /** | 34 | /** |
30 | * 活动减免金额 | 35 | * 活动减免金额 |
31 | */ | 36 | */ |
@@ -29,6 +29,11 @@ public class ChargeResult { | @@ -29,6 +29,11 @@ public class ChargeResult { | ||
29 | private double finalShippingAmount; | 29 | private double finalShippingAmount; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | + * 关税 | ||
33 | + */ | ||
34 | + private double tariffAmount; | ||
35 | + | ||
36 | + /** | ||
32 | * 发货方式 | 37 | * 发货方式 |
33 | */ | 38 | */ |
34 | private int deliveryWay; | 39 | private int deliveryWay; |
@@ -176,7 +176,7 @@ public class SellerOrderController { | @@ -176,7 +176,7 @@ public class SellerOrderController { | ||
176 | @ResponseBody | 176 | @ResponseBody |
177 | public ApiResponse delete(@RequestParam(name = "uid", required = true)int uid, | 177 | public ApiResponse delete(@RequestParam(name = "uid", required = true)int uid, |
178 | @RequestParam(name = "orderCode", required = true)long orderCode | 178 | @RequestParam(name = "orderCode", required = true)long orderCode |
179 | - ) throws GatewayException { | 179 | + ) { |
180 | SellerOrderCancelReq req = SellerOrderCancelReq.builder() | 180 | SellerOrderCancelReq req = SellerOrderCancelReq.builder() |
181 | .uid(uid) | 181 | .uid(uid) |
182 | .orderCode(orderCode) | 182 | .orderCode(orderCode) |
@@ -32,4 +32,9 @@ public class AmountDetailBo { | @@ -32,4 +32,9 @@ public class AmountDetailBo { | ||
32 | * 运费券减免金额 | 32 | * 运费券减免金额 |
33 | */ | 33 | */ |
34 | private double shippingCouponCutAmount; | 34 | private double shippingCouponCutAmount; |
35 | + | ||
36 | + /** | ||
37 | + * 海外购商品入关的税费 | ||
38 | + */ | ||
39 | + private double tariffAmount; | ||
35 | } | 40 | } |
@@ -76,7 +76,8 @@ public class CacheKeyBuilder { | @@ -76,7 +76,8 @@ public class CacheKeyBuilder { | ||
76 | 76 | ||
77 | ORDER_CODE_RULE("ufo:order:code:rule", ""), | 77 | ORDER_CODE_RULE("ufo:order:code:rule", ""), |
78 | SELLER_GOODS_FEE_RATE("ufo:order:seller:goods:service:feeRate", ""), | 78 | SELLER_GOODS_FEE_RATE("ufo:order:seller:goods:service:feeRate", ""), |
79 | - SELLER_GOODS_PLATFORM_FEE("ufo:order:seller:goods:platform:fee", "") | 79 | + SELLER_GOODS_PLATFORM_FEE("ufo:order:seller:goods:platform:fee", ""), |
80 | + BUYER_ORDER_FEE("ufo:order:buyer:order:fee","") | ||
80 | ; | 81 | ; |
81 | 82 | ||
82 | private String fix; | 83 | private String fix; |
@@ -10,6 +10,7 @@ import com.yohobuy.ufo.model.order.resp.EntryThreshold; | @@ -10,6 +10,7 @@ import com.yohobuy.ufo.model.order.resp.EntryThreshold; | ||
10 | import com.yohoufo.common.cache.CacheClient; | 10 | import com.yohoufo.common.cache.CacheClient; |
11 | import com.yohoufo.dal.order.MetaConfigMapper; | 11 | import com.yohoufo.dal.order.MetaConfigMapper; |
12 | import com.yohoufo.dal.order.model.MetaConfig; | 12 | import com.yohoufo.dal.order.model.MetaConfig; |
13 | +import com.yohoufo.order.charge.model.FeeNRate; | ||
13 | import com.yohoufo.order.model.dto.*; | 14 | import com.yohoufo.order.model.dto.*; |
14 | import com.yohoufo.order.service.cache.CacheKeyBuilder; | 15 | import com.yohoufo.order.service.cache.CacheKeyBuilder; |
15 | import com.yohoufo.order.service.cache.ExpiredTime; | 16 | import com.yohoufo.order.service.cache.ExpiredTime; |
@@ -303,4 +304,19 @@ public class MetaConfigService { | @@ -303,4 +304,19 @@ public class MetaConfigService { | ||
303 | return pfMap; | 304 | return pfMap; |
304 | } | 305 | } |
305 | 306 | ||
307 | + | ||
308 | + public Map<String,FeeNRate> getBuyerOrderFeeNRate(){ | ||
309 | + CacheKeyBuilder.KeyTemp kt = CacheKeyBuilder.KeyTemp.BUYER_ORDER_FEE; | ||
310 | + RedisKeyBuilder rkb = kt.builderKeyOnlyFixed(); | ||
311 | + final String key = MetaConfigKey.BUYER_ORDER_FEE; | ||
312 | + String configVal = new DataProcesser(rkb, key, ExpiredTime.ORDER_BASE_CONFIG).getConfigVal(); | ||
313 | + Map<String,FeeNRate> pfMap = new HashMap<String,FeeNRate>(10); | ||
314 | + try{ | ||
315 | + pfMap = JSONObject.parseObject(configVal, new TypeReference<Map<String,FeeNRate>>(){}); | ||
316 | + }catch (Exception ex){ | ||
317 | + logger.warn("in getBuyerOrderFeeNRate parseObject fail, metaVal {}", configVal, ex); | ||
318 | + } | ||
319 | + return pfMap; | ||
320 | + } | ||
321 | + | ||
306 | } | 322 | } |
@@ -2,6 +2,8 @@ package com.yohoufo.order.service.impl; | @@ -2,6 +2,8 @@ package com.yohoufo.order.service.impl; | ||
2 | 2 | ||
3 | import java.util.List; | 3 | import java.util.List; |
4 | 4 | ||
5 | +import com.yohobuy.ufo.model.order.constants.DeliveryWayEnum; | ||
6 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
5 | import org.apache.commons.lang3.tuple.Pair; | 7 | import org.apache.commons.lang3.tuple.Pair; |
6 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
7 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -122,7 +124,7 @@ public class OfflineShoppingServiceImpl extends ShoppingServiceImpl implements I | @@ -122,7 +124,7 @@ public class OfflineShoppingServiceImpl extends ShoppingServiceImpl implements I | ||
122 | } | 124 | } |
123 | 125 | ||
124 | @Override | 126 | @Override |
125 | - protected int buildDeliveryWay() { | ||
126 | - return OrderConstant.DELIVERY_WAY_STORE; | 127 | + protected int buildDeliveryWay(SkupType skupType) { |
128 | + return DeliveryWayEnum.SELF_FETCH.getCode(); | ||
127 | } | 129 | } |
128 | } | 130 | } |
@@ -6,8 +6,7 @@ import com.yoho.core.rest.client.ServiceCaller; | @@ -6,8 +6,7 @@ import com.yoho.core.rest.client.ServiceCaller; | ||
6 | import com.yoho.error.ServiceError; | 6 | import com.yoho.error.ServiceError; |
7 | import com.yoho.error.exception.ServiceException; | 7 | import com.yoho.error.exception.ServiceException; |
8 | import com.yohobuy.ufo.model.order.common.*; | 8 | import com.yohobuy.ufo.model.order.common.*; |
9 | -import com.yohobuy.ufo.model.order.constants.ChangePriceStatus; | ||
10 | -import com.yohobuy.ufo.model.order.constants.SkupType; | 9 | +import com.yohobuy.ufo.model.order.constants.*; |
11 | import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum; | 10 | import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum; |
12 | import com.yohoufo.common.alarm.EventBusPublisher; | 11 | import com.yohoufo.common.alarm.EventBusPublisher; |
13 | import com.yohoufo.common.exception.UfoServiceException; | 12 | import com.yohoufo.common.exception.UfoServiceException; |
@@ -20,7 +19,6 @@ import com.yohoufo.dal.order.model.BuyerOrder; | @@ -20,7 +19,6 @@ import com.yohoufo.dal.order.model.BuyerOrder; | ||
20 | import com.yohoufo.dal.order.model.SellerChangePriceRecord; | 19 | import com.yohoufo.dal.order.model.SellerChangePriceRecord; |
21 | import com.yohoufo.dal.order.model.SellerOrder; | 20 | import com.yohoufo.dal.order.model.SellerOrder; |
22 | import com.yohoufo.dal.order.model.SellerOrderGoods; | 21 | import com.yohoufo.dal.order.model.SellerOrderGoods; |
23 | -import com.yohobuy.ufo.model.order.constants.OrderConstant; | ||
24 | import com.yohoufo.order.charge.ChargeContext; | 22 | import com.yohoufo.order.charge.ChargeContext; |
25 | import com.yohoufo.order.charge.ChargeService; | 23 | import com.yohoufo.order.charge.ChargeService; |
26 | import com.yohoufo.order.charge.model.*; | 24 | import com.yohoufo.order.charge.model.*; |
@@ -46,6 +44,7 @@ import com.yohoufo.order.service.listener.OrderChangeListenerContainer; | @@ -46,6 +44,7 @@ import com.yohoufo.order.service.listener.OrderChangeListenerContainer; | ||
46 | import com.yohoufo.order.service.proxy.BargainProxyService; | 44 | import com.yohoufo.order.service.proxy.BargainProxyService; |
47 | import com.yohoufo.order.service.proxy.InBoxFacade; | 45 | import com.yohoufo.order.service.proxy.InBoxFacade; |
48 | import com.yohoufo.order.service.proxy.UserProxyService; | 46 | import com.yohoufo.order.service.proxy.UserProxyService; |
47 | +import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport; | ||
49 | import com.yohoufo.order.service.support.CouponSupport; | 48 | import com.yohoufo.order.service.support.CouponSupport; |
50 | import com.yohoufo.order.service.support.ShoppingSupport; | 49 | import com.yohoufo.order.service.support.ShoppingSupport; |
51 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | 50 | import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; |
@@ -61,6 +60,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -61,6 +60,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
61 | import java.math.BigDecimal; | 60 | import java.math.BigDecimal; |
62 | import java.util.Arrays; | 61 | import java.util.Arrays; |
63 | import java.util.List; | 62 | import java.util.List; |
63 | +import java.util.Map; | ||
64 | import java.util.Objects; | 64 | import java.util.Objects; |
65 | import java.util.stream.Collectors; | 65 | import java.util.stream.Collectors; |
66 | 66 | ||
@@ -125,7 +125,10 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -125,7 +125,10 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
125 | private ConfigReader configReader; | 125 | private ConfigReader configReader; |
126 | 126 | ||
127 | @Autowired | 127 | @Autowired |
128 | - AppraiseAddressService appraiseAddressService; | 128 | + private AppraiseAddressService appraiseAddressService; |
129 | + | ||
130 | + @Autowired | ||
131 | + private MetaConfigService metaConfigService; | ||
129 | 132 | ||
130 | 133 | ||
131 | /** | 134 | /** |
@@ -133,6 +136,7 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -133,6 +136,7 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
133 | * @param request | 136 | * @param request |
134 | * @return | 137 | * @return |
135 | */ | 138 | */ |
139 | + @Override | ||
136 | public PaymentResponse payment(ShoppingRequest request){ | 140 | public PaymentResponse payment(ShoppingRequest request){ |
137 | int skup; | 141 | int skup; |
138 | int uid; | 142 | int uid; |
@@ -237,17 +241,34 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -237,17 +241,34 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
237 | .activityTypeEnum(activityTypeEnum).build(); | 241 | .activityTypeEnum(activityTypeEnum).build(); |
238 | } | 242 | } |
239 | 243 | ||
240 | - private ChargeContext buildChargeContext(ShoppingRequest request, SellerOrderGoods skupInfo, ActivityPrice activityPrice,int chargeStage) { | 244 | + private ChargeContext buildChargeContext(ShoppingRequest request, |
245 | + SellerOrderGoods skupInfo, | ||
246 | + ActivityPrice activityPrice, | ||
247 | + int chargeStage) { | ||
248 | + Integer skupAttr = skupInfo.getAttributes(); | ||
249 | + SkupType skupType = SkupType.getSkupType(skupAttr); | ||
250 | + FeeNRate feeNRate = getFeeNRate(skupType); | ||
251 | + BigDecimal tariffRate = null; | ||
252 | + if (feeNRate != null){ | ||
253 | + tariffRate = feeNRate.getTariffRate(); | ||
254 | + } | ||
241 | ChargeParam chargeParam = ChargeParam.builder().uid(request.getUid()) | 255 | ChargeParam chargeParam = ChargeParam.builder().uid(request.getUid()) |
242 | .chargeStage(chargeStage) | 256 | .chargeStage(chargeStage) |
243 | .apiVersion(request.getApiVersion()) | 257 | .apiVersion(request.getApiVersion()) |
244 | - .deliveryWay(buildDeliveryWay()) | 258 | + .deliveryWay(buildDeliveryWay(skupType)) |
245 | .couponCodes(request.getCouponCodes()).build(); | 259 | .couponCodes(request.getCouponCodes()).build(); |
246 | - | 260 | + ChargeGoods chargeGoods = ChargeGoods.builder() |
261 | + .goodsPrice(skupInfo.getGoodsPrice()) | ||
262 | + .productId(skupInfo.getProductId()) | ||
263 | + .attributes(skupAttr) | ||
264 | + .skup(skupInfo.getId()) | ||
265 | + .activityCutPrice(BigDecimal.ZERO) | ||
266 | + .skupType(skupType) | ||
267 | + .tariffRate(tariffRate) | ||
268 | + .build(); | ||
247 | return ChargeContext.builder() | 269 | return ChargeContext.builder() |
248 | .chargeParam(chargeParam) | 270 | .chargeParam(chargeParam) |
249 | - .chargeGoods(ChargeGoods.builder().goodsPrice(skupInfo.getGoodsPrice()).productId(skupInfo.getProductId()) | ||
250 | - .attributes(skupInfo.getAttributes()).skup(skupInfo.getId()).activityCutPrice(BigDecimal.ZERO).build()) | 271 | + .chargeGoods(chargeGoods) |
251 | .activityPrice(activityPrice) | 272 | .activityPrice(activityPrice) |
252 | .build(); | 273 | .build(); |
253 | 274 | ||
@@ -325,6 +346,32 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -325,6 +346,32 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
325 | return response; | 346 | return response; |
326 | } | 347 | } |
327 | 348 | ||
349 | + private FeeNRate buildDefaultFeeNRate(SkupType skupType){ | ||
350 | + FeeNRate feeNRate = null; | ||
351 | + switch (skupType){ | ||
352 | + case HK_IN_STOCK: | ||
353 | + feeNRate = new FeeNRate(); | ||
354 | + feeNRate.setShipFee(new BigDecimal(55)); | ||
355 | + feeNRate.setShipFee(new BigDecimal(0.091)); | ||
356 | + break; | ||
357 | + | ||
358 | + } | ||
359 | + return feeNRate; | ||
360 | + } | ||
361 | + | ||
362 | + | ||
363 | + private FeeNRate getFeeNRate(SkupType skupType){ | ||
364 | + if (skupType == null){ | ||
365 | + return null; | ||
366 | + } | ||
367 | + Map<String,FeeNRate> config = metaConfigService.getBuyerOrderFeeNRate(); | ||
368 | + if (config == null){ | ||
369 | + // set default | ||
370 | + return buildDefaultFeeNRate(skupType); | ||
371 | + } | ||
372 | + return config.get(skupType.getLocalCacheKey()); | ||
373 | + } | ||
374 | + | ||
328 | /** | 375 | /** |
329 | * 提交订单 | 376 | * 提交订单 |
330 | * @param shoppingRequest | 377 | * @param shoppingRequest |
@@ -366,6 +413,8 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -366,6 +413,8 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
366 | 413 | ||
367 | logger.info("generate new orderCode:{}",orderCode); | 414 | logger.info("generate new orderCode:{}",orderCode); |
368 | 415 | ||
416 | + SkupType skupType = chargeContext.getChargeGoods().getSkupType(); | ||
417 | + | ||
369 | // 减库存,skup更新成不可售,入库 | 418 | // 减库存,skup更新成不可售,入库 |
370 | //BigDecimal shipFee = new BigDecimal(delivery_way_sf_cost); | 419 | //BigDecimal shipFee = new BigDecimal(delivery_way_sf_cost); |
371 | OrderBuilder orderBuilder = OrderBuilder.builder() | 420 | OrderBuilder orderBuilder = OrderBuilder.builder() |
@@ -374,7 +423,7 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -374,7 +423,7 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
374 | .orderCode(orderCode) | 423 | .orderCode(orderCode) |
375 | .productId(psog.getProductId()) | 424 | .productId(psog.getProductId()) |
376 | .paymentType(OrderConstant.PAYMENT_ONLINE) | 425 | .paymentType(OrderConstant.PAYMENT_ONLINE) |
377 | - .deliverWay(buildDeliveryWay()) | 426 | + .deliverWay(buildDeliveryWay(skupType)) |
378 | .channelNo(shoppingRequest.getChannelNo()) | 427 | .channelNo(shoppingRequest.getChannelNo()) |
379 | .amount(BigDecimal.valueOf(chargeResult.getFinalAmount())) | 428 | .amount(BigDecimal.valueOf(chargeResult.getFinalAmount())) |
380 | .shipFee(BigDecimal.valueOf(chargeResult.getFinalShippingAmount())) | 429 | .shipFee(BigDecimal.valueOf(chargeResult.getFinalShippingAmount())) |
@@ -425,7 +474,7 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -425,7 +474,7 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
425 | // | 474 | // |
426 | inBoxFacade.sellerSkupCreateOrderByBuyer(sellerUid, psog); | 475 | inBoxFacade.sellerSkupCreateOrderByBuyer(sellerUid, psog); |
427 | }else{ | 476 | }else{ |
428 | - logger.warn("buyer submit order "); | 477 | + logger.warn("buyer submit order ordeCreationService.doSubmitOrder fail shoppingRequest {}", shoppingRequest); |
429 | } | 478 | } |
430 | // 返回结果 | 479 | // 返回结果 |
431 | return OrderSubmitResponse.builder().orderCode(orderCode).productId(psog.getProductId()) | 480 | return OrderSubmitResponse.builder().orderCode(orderCode).productId(psog.getProductId()) |
@@ -548,6 +597,8 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -548,6 +597,8 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
548 | //活动金额 | 597 | //活动金额 |
549 | amountDetailBo.setActivityCutAmount(chargeResult.getActivityCutResult().getActivityCutAmount()); | 598 | amountDetailBo.setActivityCutAmount(chargeResult.getActivityCutResult().getActivityCutAmount()); |
550 | 599 | ||
600 | + //税费 | ||
601 | + amountDetailBo.setTariffAmount(chargeResult.getTariffAmount()); | ||
551 | //活动券减免金额 | 602 | //活动券减免金额 |
552 | chargeResult.getCouponPayResultList().getCouponPayResultByCouponType(CouponTypeEnum.ACTIVITY_COUPON.getCode()). | 603 | chargeResult.getCouponPayResultList().getCouponPayResultByCouponType(CouponTypeEnum.ACTIVITY_COUPON.getCode()). |
553 | ifPresent(tempPayResult -> amountDetailBo.setCouponCutAmount(tempPayResult.getCouponAmount())); | 604 | ifPresent(tempPayResult -> amountDetailBo.setCouponCutAmount(tempPayResult.getCouponAmount())); |
@@ -559,8 +610,33 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -559,8 +610,33 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
559 | return amountDetailBo; | 610 | return amountDetailBo; |
560 | } | 611 | } |
561 | 612 | ||
562 | - protected int buildDeliveryWay() { | ||
563 | - return OrderConstant.DELIVERY_WAY_SF; | 613 | + protected int buildDeliveryWay(SkupType skupType) { |
614 | + DeliveryWayEnum deliveryWay ; | ||
615 | + if (skupType==null){ | ||
616 | + deliveryWay = DeliveryWayEnum.SF; | ||
617 | + }else{ | ||
618 | + SkupTypeCodeSupport.CodeNode codeNode = SkupTypeCodeSupport.explain(skupType.getCode()); | ||
619 | + | ||
620 | + RegionEnum regionEnum = RegionEnum.getByCode(codeNode.getRegion()); | ||
621 | + if (regionEnum == null){ | ||
622 | + deliveryWay = DeliveryWayEnum.SF; | ||
623 | + }else{ | ||
624 | + switch (regionEnum){ | ||
625 | + case HONGKONG: | ||
626 | + deliveryWay = DeliveryWayEnum.OVERSEAS_HONGHONG; | ||
627 | + break; | ||
628 | + case MAINLAND: | ||
629 | + default: | ||
630 | + deliveryWay = DeliveryWayEnum.SF; | ||
631 | + break; | ||
632 | + | ||
633 | + } | ||
634 | + } | ||
635 | + | ||
636 | + | ||
637 | + } | ||
638 | + | ||
639 | + return deliveryWay.getCode(); | ||
564 | } | 640 | } |
565 | 641 | ||
566 | } | 642 | } |
@@ -18,6 +18,7 @@ import com.yohoufo.common.alarm.SmsAlarmEvent; | @@ -18,6 +18,7 @@ import com.yohoufo.common.alarm.SmsAlarmEvent; | ||
18 | import com.yohoufo.common.exception.UfoServiceException; | 18 | import com.yohoufo.common.exception.UfoServiceException; |
19 | import com.yohoufo.dal.order.model.SellerOrderGoods; | 19 | import com.yohoufo.dal.order.model.SellerOrderGoods; |
20 | import com.yohoufo.order.convert.builder.AlarmEventBuilder; | 20 | import com.yohoufo.order.convert.builder.AlarmEventBuilder; |
21 | +import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport; | ||
21 | import lombok.Data; | 22 | import lombok.Data; |
22 | import org.apache.commons.collections.CollectionUtils; | 23 | import org.apache.commons.collections.CollectionUtils; |
23 | import org.apache.commons.collections.MapUtils; | 24 | import org.apache.commons.collections.MapUtils; |
@@ -329,16 +330,18 @@ public class ProductProxyService extends AbsProxyService{ | @@ -329,16 +330,18 @@ public class ProductProxyService extends AbsProxyService{ | ||
329 | skupReq.setStorageId(goods.getStorageId()); | 330 | skupReq.setStorageId(goods.getStorageId()); |
330 | skupReq.setPrice(goods.getGoodsPrice()); | 331 | skupReq.setPrice(goods.getGoodsPrice()); |
331 | skupReq.setSellerUid(goods.getUid()); | 332 | skupReq.setSellerUid(goods.getUid()); |
332 | - Integer skupa = goods.getAttributes(); | 333 | + Integer skupa = goods.getAttributes() == null ? 0 : goods.getAttributes(); |
334 | + SkupTypeCodeSupport.CodeNode codeNode = SkupTypeCodeSupport.explain(skupa); | ||
335 | + skupReq.setRegion(codeNode.getRegion()); | ||
333 | if (Objects.nonNull(skupa) && SkupType.ADVANCE.getCode() == skupa){ | 336 | if (Objects.nonNull(skupa) && SkupType.ADVANCE.getCode() == skupa){ |
334 | skupReq.setPreSaleFlag(isAdvace); | 337 | skupReq.setPreSaleFlag(isAdvace); |
335 | } | 338 | } |
336 | skupBoList.add(skupReq); | 339 | skupBoList.add(skupReq); |
337 | skupList.add(goods.getId()); | 340 | skupList.add(goods.getId()); |
338 | } | 341 | } |
339 | - ApiResponse resp = ufoServiceCaller.call(batchCreateSkup, skupBoList); | ||
340 | - | ||
341 | - logger.info("call {} resp {}", batchCreateSkup, resp); | 342 | + final String serviceName = batchCreateSkup; |
343 | + ApiResponse resp = ufoServiceCaller.call(serviceName, skupBoList); | ||
344 | + logger.info("call {} resp {}", serviceName, resp); | ||
342 | return (null == resp || null == resp.getData())? false : (boolean)resp.getData(); | 345 | return (null == resp || null == resp.getData())? false : (boolean)resp.getData(); |
343 | } | 346 | } |
344 | 347 |
@@ -54,7 +54,7 @@ public class SkupTypeCodeSupport { | @@ -54,7 +54,7 @@ public class SkupTypeCodeSupport { | ||
54 | 54 | ||
55 | 55 | ||
56 | public static void main(String[] args) { | 56 | public static void main(String[] args) { |
57 | - CodeNode cn = SkupTypeCodeSupport.explain(19); | 57 | + CodeNode cn = SkupTypeCodeSupport.explain(0); |
58 | System.out.println("test SkupTypeCodeSupport.explain -->" + cn); | 58 | System.out.println("test SkupTypeCodeSupport.explain -->" + cn); |
59 | System.out.println("generate-->" +generate(cn)); | 59 | System.out.println("generate-->" +generate(cn)); |
60 | } | 60 | } |
1 | package com.yohoufo.order.service.support; | 1 | package com.yohoufo.order.service.support; |
2 | 2 | ||
3 | import com.google.common.collect.Lists; | 3 | import com.google.common.collect.Lists; |
4 | +import com.yohobuy.ufo.model.order.constants.DeliveryWayEnum; | ||
4 | import com.yohobuy.ufo.model.order.constants.OrderDetailDesc; | 5 | import com.yohobuy.ufo.model.order.constants.OrderDetailDesc; |
5 | import com.yohobuy.ufo.model.order.constants.SkupType; | 6 | import com.yohobuy.ufo.model.order.constants.SkupType; |
6 | import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum; | 7 | import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum; |
@@ -69,11 +70,11 @@ public class ShoppingSupport { | @@ -69,11 +70,11 @@ public class ShoppingSupport { | ||
69 | 70 | ||
70 | 71 | ||
71 | private String getDeliveryWayStr(int deliveryWay) { | 72 | private String getDeliveryWayStr(int deliveryWay) { |
72 | - return deliveryWay == OrderConstant.DELIVERY_WAY_STORE ? OrderConstant.DELIVERY_WAY_STORE_NAME : OrderConstant.DELIVERY_WAY_SF_NAME; | 73 | + return deliveryWay == DeliveryWayEnum.SELF_FETCH.getCode() ? OrderConstant.DELIVERY_WAY_STORE_NAME : OrderConstant.DELIVERY_WAY_SF_NAME; |
73 | } | 74 | } |
74 | 75 | ||
75 | public boolean isDeliveryWayByStore(int deliveryWay) { | 76 | public boolean isDeliveryWayByStore(int deliveryWay) { |
76 | - return deliveryWay == OrderConstant.DELIVERY_WAY_STORE; | 77 | + return deliveryWay == DeliveryWayEnum.SELF_FETCH.getCode(); |
77 | } | 78 | } |
78 | 79 | ||
79 | 80 | ||
@@ -111,19 +112,24 @@ public class ShoppingSupport { | @@ -111,19 +112,24 @@ public class ShoppingSupport { | ||
111 | goodsFormula.setPromotionAmount(MathUtils.formatCurrencyStr(chargeResult.getGoodsAmount())); | 112 | goodsFormula.setPromotionAmount(MathUtils.formatCurrencyStr(chargeResult.getGoodsAmount())); |
112 | 113 | ||
113 | formulas.add(goodsFormula); | 114 | formulas.add(goodsFormula); |
114 | - | ||
115 | //运费 | 115 | //运费 |
116 | PromotionFormula expressFormula = new PromotionFormula(); | 116 | PromotionFormula expressFormula = new PromotionFormula(); |
117 | expressFormula.setPromotion(OrderConstant.DELIVERY_DESC); | 117 | expressFormula.setPromotion(OrderConstant.DELIVERY_DESC); |
118 | String shipFee = OrderConstant.PLUS_SIGN + MathUtils.formatCurrencyStr(chargeResult.getShippingAmount()); | 118 | String shipFee = OrderConstant.PLUS_SIGN + MathUtils.formatCurrencyStr(chargeResult.getShippingAmount()); |
119 | - | ||
120 | expressFormula.setPromotionAmount(shipFee); | 119 | expressFormula.setPromotionAmount(shipFee); |
121 | - | ||
122 | formulas.add(expressFormula); | 120 | formulas.add(expressFormula); |
123 | - | 121 | + //税费 |
122 | + double tariffAmount; | ||
123 | + if ((tariffAmount=chargeResult.getTariffAmount()) > 0D){ | ||
124 | + PromotionFormula tariffFormula = new PromotionFormula(); | ||
125 | + tariffFormula.setPromotion(OrderConstant.TAX_DESC); | ||
126 | + String tariffAmountDesc = OrderConstant.PLUS_SIGN + MathUtils.formatCurrencyStr(tariffAmount); | ||
127 | + tariffFormula.setPromotionAmount(tariffAmountDesc); | ||
128 | + formulas.add(tariffFormula); | ||
129 | + } | ||
124 | //活动优惠 | 130 | //活动优惠 |
125 | ActivityCutResult activityCutResult = chargeResult.getActivityCutResult(); | 131 | ActivityCutResult activityCutResult = chargeResult.getActivityCutResult(); |
126 | - if (activityCutResult.getActivityCutAmount() > 0) { | 132 | + if (activityCutResult.getActivityCutAmount() > 0D) { |
127 | PromotionFormula activityFormula = new PromotionFormula(); | 133 | PromotionFormula activityFormula = new PromotionFormula(); |
128 | activityFormula.setPromotion(OrderConstant.ACTIVITY_DESC); | 134 | activityFormula.setPromotion(OrderConstant.ACTIVITY_DESC); |
129 | activityFormula.setPromotionAmount(OrderConstant.SUB_SIGN + MathUtils.formatCurrencyStr(activityCutResult.getActivityCutAmount())); | 135 | activityFormula.setPromotionAmount(OrderConstant.SUB_SIGN + MathUtils.formatCurrencyStr(activityCutResult.getActivityCutAmount())); |
-
Please register or login to post a comment