Merge branch 'dev-promotion' into test6.8.2
# Conflicts: # web/src/main/resources/databases.yml # web/src/main/webapp/META-INF/autoconf/databases.yml
Showing
12 changed files
with
62 additions
and
22 deletions
@@ -12,5 +12,5 @@ public interface OrderCouponMapper { | @@ -12,5 +12,5 @@ public interface OrderCouponMapper { | ||
12 | 12 | ||
13 | int insert(OrderCoupon orderCoupon); | 13 | int insert(OrderCoupon orderCoupon); |
14 | 14 | ||
15 | - List<OrderCoupon> selectByUidAndOrderCode(@Param("uid") int uid, @Param("orderCode") long orderCode); | 15 | + OrderCoupon selectByUidAndOrderCode(@Param("uid") int uid, @Param("orderCode") long orderCode); |
16 | } | 16 | } |
@@ -4,11 +4,20 @@ package com.yohoufo.dal.order.model; | @@ -4,11 +4,20 @@ package com.yohoufo.dal.order.model; | ||
4 | * Created by jiexiang.wu on 2018/11/20. | 4 | * Created by jiexiang.wu on 2018/11/20. |
5 | */ | 5 | */ |
6 | public class OrderCoupon { | 6 | public class OrderCoupon { |
7 | + private long id; | ||
7 | private int uid; | 8 | private int uid; |
8 | private long orderCode; | 9 | private long orderCode; |
9 | private String couponCode; | 10 | private String couponCode; |
10 | private int createTime; | 11 | private int createTime; |
11 | 12 | ||
13 | + public long getId() { | ||
14 | + return id; | ||
15 | + } | ||
16 | + | ||
17 | + public void setId(long id) { | ||
18 | + this.id = id; | ||
19 | + } | ||
20 | + | ||
12 | public int getUid() { | 21 | public int getUid() { |
13 | return uid; | 22 | return uid; |
14 | } | 23 | } |
@@ -20,8 +20,9 @@ | @@ -20,8 +20,9 @@ | ||
20 | <select id="selectByUidAndOrderCode" resultMap="BaseResultMap"> | 20 | <select id="selectByUidAndOrderCode" resultMap="BaseResultMap"> |
21 | select | 21 | select |
22 | <include refid="Base_Column_List"/> | 22 | <include refid="Base_Column_List"/> |
23 | - from buyer_order | 23 | + from order_coupon |
24 | where order_code = #{orderCode,jdbcType=BIGINT} | 24 | where order_code = #{orderCode,jdbcType=BIGINT} |
25 | and uid = #{uid,jdbcType=INTEGER} | 25 | and uid = #{uid,jdbcType=INTEGER} |
26 | + limit 1 | ||
26 | </select> | 27 | </select> |
27 | </mapper> | 28 | </mapper> |
@@ -50,13 +50,13 @@ public class ChargeService { | @@ -50,13 +50,13 @@ public class ChargeService { | ||
50 | //1.计算商品金额 | 50 | //1.计算商品金额 |
51 | calculateGoodsAmount(chargeContext); | 51 | calculateGoodsAmount(chargeContext); |
52 | //2.计算运费 | 52 | //2.计算运费 |
53 | - calculateExpressDeliveryAmount(chargeContext); | 53 | + calculateShippingAmount(chargeContext); |
54 | //3.计算优惠券 | 54 | //3.计算优惠券 |
55 | calculateCouponIfNeed(chargeContext); | 55 | calculateCouponIfNeed(chargeContext); |
56 | } | 56 | } |
57 | 57 | ||
58 | private void initCharge(ChargeContext chargeContext) { | 58 | private void initCharge(ChargeContext chargeContext) { |
59 | - logger.info("[{}] init charge,charge param:{},charge goods:{}", | 59 | + logger.info("[{}] step init charge,charge param:{},charge goods:{}", |
60 | chargeContext.getChargeParam().getUid(), | 60 | chargeContext.getChargeParam().getUid(), |
61 | chargeContext.getChargeParam(), | 61 | chargeContext.getChargeParam(), |
62 | chargeContext.getChargeGoods()); | 62 | chargeContext.getChargeGoods()); |
@@ -75,7 +75,7 @@ public class ChargeService { | @@ -75,7 +75,7 @@ public class ChargeService { | ||
75 | 75 | ||
76 | chargeContext.getChargeResult().setGoodsAmount(chargeGoods.getGoodsAmount().doubleValue()); | 76 | chargeContext.getChargeResult().setGoodsAmount(chargeGoods.getGoodsAmount().doubleValue()); |
77 | chargeContext.getChargeResult().setFinalAmount(chargeGoods.getGoodsAmount().doubleValue()); | 77 | chargeContext.getChargeResult().setFinalAmount(chargeGoods.getGoodsAmount().doubleValue()); |
78 | - logger.info("[{}] STEP goods charge,goodsPrice:{},goodsAmount:{},amount:{}", | 78 | + logger.info("[{}] step goods charge,goodsPrice:{},goodsAmount:{},amount:{}", |
79 | chargeContext.getChargeParam().getUid(), | 79 | chargeContext.getChargeParam().getUid(), |
80 | chargeGoods.getGoodsPrice(), | 80 | chargeGoods.getGoodsPrice(), |
81 | chargeContext.getChargeResult().getGoodsAmount(), | 81 | chargeContext.getChargeResult().getGoodsAmount(), |
@@ -87,9 +87,9 @@ public class ChargeService { | @@ -87,9 +87,9 @@ public class ChargeService { | ||
87 | * | 87 | * |
88 | * @param chargeContext | 88 | * @param chargeContext |
89 | */ | 89 | */ |
90 | - private void calculateExpressDeliveryAmount(ChargeContext chargeContext) { | 90 | + private void calculateShippingAmount(ChargeContext chargeContext) { |
91 | //运费 | 91 | //运费 |
92 | - chargeContext.getChargeResult().setExpressDeliveryAmount(delivery_way_sf_cost); | 92 | + chargeContext.getChargeResult().setShippingAmount(delivery_way_sf_cost); |
93 | 93 | ||
94 | ChargeResult chargeResult = chargeContext.getChargeResult(); | 94 | ChargeResult chargeResult = chargeContext.getChargeResult(); |
95 | 95 | ||
@@ -97,9 +97,9 @@ public class ChargeService { | @@ -97,9 +97,9 @@ public class ChargeService { | ||
97 | //包括运费 | 97 | //包括运费 |
98 | double newFinalAmount = YHMath.add(oldFinalAmount, delivery_way_sf_cost); | 98 | double newFinalAmount = YHMath.add(oldFinalAmount, delivery_way_sf_cost); |
99 | chargeResult.setFinalAmount(newFinalAmount); | 99 | chargeResult.setFinalAmount(newFinalAmount); |
100 | - logger.info("[{}] STEP express charge,sfExpressAmount:{},oldFinalAmount:{},newFinalAmount:{}", | 100 | + logger.info("[{}] step shipping charge,sfExpressAmount:{},oldFinalAmount:{},newFinalAmount:{}", |
101 | chargeContext.getChargeParam().getUid(), | 101 | chargeContext.getChargeParam().getUid(), |
102 | - chargeResult.getExpressDeliveryAmount(), | 102 | + chargeResult.getShippingAmount(), |
103 | oldFinalAmount, | 103 | oldFinalAmount, |
104 | chargeResult.getFinalAmount()); | 104 | chargeResult.getFinalAmount()); |
105 | } | 105 | } |
@@ -131,7 +131,7 @@ public class ChargeService { | @@ -131,7 +131,7 @@ public class ChargeService { | ||
131 | 131 | ||
132 | chargeResult.setCouponPayResult(couponPayResult); | 132 | chargeResult.setCouponPayResult(couponPayResult); |
133 | 133 | ||
134 | - logger.info("[{}] STEP coupon charge,oldFinalAmount:{},newFinalAmount:{},couponPayResult:{}", | 134 | + logger.info("[{}] step coupon charge,oldFinalAmount:{},newFinalAmount:{},couponPayResult:{}", |
135 | chargeContext.getChargeParam().getUid(), | 135 | chargeContext.getChargeParam().getUid(), |
136 | couponPayAmount, oldFinalAmount, chargeResult.getFinalAmount(), chargeResult.getCouponPayResult()); | 136 | couponPayAmount, oldFinalAmount, chargeResult.getFinalAmount(), chargeResult.getCouponPayResult()); |
137 | 137 |
@@ -4,10 +4,14 @@ import com.yohobuy.ufo.model.order.common.OrderStatus; | @@ -4,10 +4,14 @@ import com.yohobuy.ufo.model.order.common.OrderStatus; | ||
4 | import com.yohobuy.ufo.model.order.common.SkupStatus; | 4 | import com.yohobuy.ufo.model.order.common.SkupStatus; |
5 | import com.yohoufo.common.utils.DateUtil; | 5 | import com.yohoufo.common.utils.DateUtil; |
6 | import com.yohoufo.dal.order.BuyerOrderMapper; | 6 | import com.yohoufo.dal.order.BuyerOrderMapper; |
7 | +import com.yohoufo.dal.order.OrderCouponMapper; | ||
7 | import com.yohoufo.dal.order.SellerOrderGoodsMapper; | 8 | import com.yohoufo.dal.order.SellerOrderGoodsMapper; |
9 | +import com.yohoufo.dal.order.model.OrderCoupon; | ||
8 | import com.yohoufo.dal.order.model.SellerOrderGoods; | 10 | import com.yohoufo.dal.order.model.SellerOrderGoods; |
9 | import com.yohoufo.order.event.BeforeDepotReceiveEvent; | 11 | import com.yohoufo.order.event.BeforeDepotReceiveEvent; |
10 | import com.yohoufo.order.event.BeforeSellerDeliverEvent; | 12 | import com.yohoufo.order.event.BeforeSellerDeliverEvent; |
13 | +import com.yohoufo.order.model.bo.CouponBo; | ||
14 | +import com.yohoufo.order.service.proxy.CouponProxyService; | ||
11 | import com.yohoufo.order.utils.LoggerUtils; | 15 | import com.yohoufo.order.utils.LoggerUtils; |
12 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -33,6 +37,12 @@ public class BuyerOrderCancelService { | @@ -33,6 +37,12 @@ public class BuyerOrderCancelService { | ||
33 | @Autowired | 37 | @Autowired |
34 | private SellerOrderGoodsMapper sellerOrderGoodsMapper; | 38 | private SellerOrderGoodsMapper sellerOrderGoodsMapper; |
35 | 39 | ||
40 | + @Autowired | ||
41 | + private OrderCouponMapper orderCouponMapper; | ||
42 | + | ||
43 | + @Autowired | ||
44 | + private CouponProxyService couponProxyService; | ||
45 | + | ||
36 | public void cancel(BeforeSellerDeliverEvent bsdEvent){ | 46 | public void cancel(BeforeSellerDeliverEvent bsdEvent){ |
37 | OrderDynamicConfig.BuyerCancelCompensateNode compensate = orderDynamicConfig.getBeforeSellerDeliverBCCN(); | 47 | OrderDynamicConfig.BuyerCancelCompensateNode compensate = orderDynamicConfig.getBeforeSellerDeliverBCCN(); |
38 | 48 | ||
@@ -83,11 +93,25 @@ public class BuyerOrderCancelService { | @@ -83,11 +93,25 @@ public class BuyerOrderCancelService { | ||
83 | //(转账)瓜分指定赔偿款给卖家和平台 | 93 | //(转账)瓜分指定赔偿款给卖家和平台 |
84 | //(退费)扣除赔偿款,计算剩余的货款,退给买家 | 94 | //(退费)扣除赔偿款,计算剩余的货款,退给买家 |
85 | } | 95 | } |
86 | - | ||
87 | - | ||
88 | } | 96 | } |
89 | 97 | ||
90 | 98 | ||
91 | - | ||
92 | - | 99 | + /** |
100 | + * 退还优惠券 | ||
101 | + * | ||
102 | + * @param uid | ||
103 | + * @param orderCode | ||
104 | + */ | ||
105 | + public void refundCouponIfNeed(int uid, long orderCode) { | ||
106 | + try { | ||
107 | + OrderCoupon orderCoupon = orderCouponMapper.selectByUidAndOrderCode(uid, orderCode); | ||
108 | + if (orderCoupon == null) { | ||
109 | + logger.info("[{}] not need to refund coupon", orderCode); | ||
110 | + return; | ||
111 | + } | ||
112 | + couponProxyService.orderCancelCoupon(uid, orderCode, CouponBo.builder().couponCode(orderCoupon.getCouponCode()).build()); | ||
113 | + } catch (Exception ex) { | ||
114 | + logger.warn("refund coupon error,uid:{},orderCode:{}", uid, orderCode, ex); | ||
115 | + } | ||
116 | + } | ||
93 | } | 117 | } |
@@ -141,6 +141,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | @@ -141,6 +141,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | ||
141 | case WAITING_PAY: | 141 | case WAITING_PAY: |
142 | targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_PAY; | 142 | targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_PAY; |
143 | cancelBeforePaid(orderRequest, node, expectStatus, targetStatus); | 143 | cancelBeforePaid(orderRequest, node, expectStatus, targetStatus); |
144 | + //退还优惠券 | ||
145 | + buyerOrderCancelService.refundCouponIfNeed(orderRequest.getUid(),orderRequest.getOrderCode()); | ||
144 | break; | 146 | break; |
145 | case HAS_PAYED: | 147 | case HAS_PAYED: |
146 | BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(orderRequest.getUid(), | 148 | BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(orderRequest.getUid(), |
@@ -152,6 +154,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | @@ -152,6 +154,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | ||
152 | .expected(expectStatus).target(targetStatus).skup(skup).sellerUid(buyerOrder.getSellerUid()) | 154 | .expected(expectStatus).target(targetStatus).skup(skup).sellerUid(buyerOrder.getSellerUid()) |
153 | .build(); | 155 | .build(); |
154 | buyerOrderCancelService.cancel(bsde); | 156 | buyerOrderCancelService.cancel(bsde); |
157 | + //退还优惠券 | ||
158 | + buyerOrderCancelService.refundCouponIfNeed(orderRequest.getUid(),orderRequest.getOrderCode()); | ||
155 | break; | 159 | break; |
156 | case SELLER_SEND_OUT: | 160 | case SELLER_SEND_OUT: |
157 | bog = buyerOrderGoodsMapper.selectByOrderCode(orderRequest.getUid(), | 161 | bog = buyerOrderGoodsMapper.selectByOrderCode(orderRequest.getUid(), |
@@ -163,6 +167,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | @@ -163,6 +167,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | ||
163 | .expected(expectStatus).target(targetStatus).skup(skup).sellerUid(buyerOrder.getSellerUid()) | 167 | .expected(expectStatus).target(targetStatus).skup(skup).sellerUid(buyerOrder.getSellerUid()) |
164 | .build(); | 168 | .build(); |
165 | buyerOrderCancelService.cancel(bdre); | 169 | buyerOrderCancelService.cancel(bdre); |
170 | + //退还优惠券 | ||
171 | + buyerOrderCancelService.refundCouponIfNeed(orderRequest.getUid(),orderRequest.getOrderCode()); | ||
166 | break; | 172 | break; |
167 | } | 173 | } |
168 | 174 |
1 | package com.yohoufo.order.service.impl; | 1 | package com.yohoufo.order.service.impl; |
2 | 2 | ||
3 | -import com.google.common.collect.Lists; | ||
4 | import com.yoho.core.rest.client.ServiceCaller; | 3 | import com.yoho.core.rest.client.ServiceCaller; |
5 | import com.yoho.error.ServiceError; | 4 | import com.yoho.error.ServiceError; |
6 | import com.yoho.error.exception.ServiceException; | 5 | import com.yoho.error.exception.ServiceException; |
@@ -40,7 +39,6 @@ import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | @@ -40,7 +39,6 @@ import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; | ||
40 | import com.yohoufo.order.utils.AddressHelper; | 39 | import com.yohoufo.order.utils.AddressHelper; |
41 | import com.yohoufo.order.utils.MathUtils; | 40 | import com.yohoufo.order.utils.MathUtils; |
42 | import org.apache.commons.lang3.StringUtils; | 41 | import org.apache.commons.lang3.StringUtils; |
43 | -import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; | ||
44 | import org.slf4j.Logger; | 42 | import org.slf4j.Logger; |
45 | import org.slf4j.LoggerFactory; | 43 | import org.slf4j.LoggerFactory; |
46 | import org.springframework.beans.factory.annotation.Autowired; | 44 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -272,7 +270,7 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -272,7 +270,7 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
272 | .deliverWay(OrderConstant.DELIVERY_WAY_SF) | 270 | .deliverWay(OrderConstant.DELIVERY_WAY_SF) |
273 | .channelNo(shoppingRequest.getChannelNo()) | 271 | .channelNo(shoppingRequest.getChannelNo()) |
274 | .amount(BigDecimal.valueOf(chargeResult.getFinalAmount())) | 272 | .amount(BigDecimal.valueOf(chargeResult.getFinalAmount())) |
275 | - .shipFee(BigDecimal.valueOf(chargeResult.getExpressDeliveryAmount())) | 273 | + .shipFee(BigDecimal.valueOf(chargeResult.getShippingAmount())) |
276 | .couponBo(CouponBo.builder().couponCode(chargeResult.getCouponPayResult().getCouponCode()) | 274 | .couponBo(CouponBo.builder().couponCode(chargeResult.getCouponPayResult().getCouponCode()) |
277 | .couponAmount(BigDecimal.valueOf(chargeResult.getCouponPayResult().getCouponAmount())) | 275 | .couponAmount(BigDecimal.valueOf(chargeResult.getCouponPayResult().getCouponAmount())) |
278 | .build() | 276 | .build() |
@@ -98,10 +98,10 @@ public class CouponProxyService implements Compensator { | @@ -98,10 +98,10 @@ public class CouponProxyService implements Compensator { | ||
98 | ApiResponse resp = serviceCaller.call("app.coupons.cancel", uid, orderCode, Lists.newArrayList(coupon.getCouponCode())); | 98 | ApiResponse resp = serviceCaller.call("app.coupons.cancel", uid, orderCode, Lists.newArrayList(coupon.getCouponCode())); |
99 | Boolean result = getResultFromApiResponse(resp); | 99 | Boolean result = getResultFromApiResponse(resp); |
100 | if (result == null || result.booleanValue() == false) { | 100 | if (result == null || result.booleanValue() == false) { |
101 | - logger.warn("[{}] cancel couponBo fail,coupons is {}", orderCode, coupon); | ||
102 | - throw new ServiceException(ServiceError.PROMOTION_COUPON_IS_NOT_VAILD); | 101 | + logger.warn("[{}] cancel coupon fail,couponBo is {}", orderCode, coupon); |
102 | + } else { | ||
103 | + logger.info("[{}] cancel coupon success", orderCode); | ||
103 | } | 104 | } |
104 | - logger.info("[{}] cancel coupon success", orderCode); | ||
105 | } | 105 | } |
106 | 106 | ||
107 | private <T> T getResultFromApiResponse(ApiResponse resp) { | 107 | private <T> T getResultFromApiResponse(ApiResponse resp) { |
@@ -86,7 +86,7 @@ public class ShoppingSupport { | @@ -86,7 +86,7 @@ public class ShoppingSupport { | ||
86 | //运费 | 86 | //运费 |
87 | PromotionFormula expressFormula = new PromotionFormula(); | 87 | PromotionFormula expressFormula = new PromotionFormula(); |
88 | expressFormula.setPromotion(OrderConstant.DELIVERY_DESC); | 88 | expressFormula.setPromotion(OrderConstant.DELIVERY_DESC); |
89 | - expressFormula.setPromotionAmount(OrderConstant.PLUS_SIGN + MathUtils.formatCurrencyStr(chargeResult.getExpressDeliveryAmount())); | 89 | + expressFormula.setPromotionAmount(OrderConstant.PLUS_SIGN + MathUtils.formatCurrencyStr(chargeResult.getShippingAmount())); |
90 | 90 | ||
91 | formulas.add(expressFormula); | 91 | formulas.add(expressFormula); |
92 | 92 |
@@ -55,6 +55,7 @@ datasources: | @@ -55,6 +55,7 @@ datasources: | ||
55 | - com.yohoufo.dal.order.SkupBatchMapper | 55 | - com.yohoufo.dal.order.SkupBatchMapper |
56 | - com.yohoufo.dal.order.SellerWalletMapper | 56 | - com.yohoufo.dal.order.SellerWalletMapper |
57 | - com.yohoufo.dal.order.SellerWalletDetailMapper | 57 | - com.yohoufo.dal.order.SellerWalletDetailMapper |
58 | + - com.yohoufo.dal.order.OrderCouponMapper | ||
58 | 59 | ||
59 | ufo_promotion: | 60 | ufo_promotion: |
60 | servers: | 61 | servers: |
@@ -55,6 +55,7 @@ datasources: | @@ -55,6 +55,7 @@ datasources: | ||
55 | - com.yohoufo.dal.order.SkupBatchMapper | 55 | - com.yohoufo.dal.order.SkupBatchMapper |
56 | - com.yohoufo.dal.order.SellerWalletMapper | 56 | - com.yohoufo.dal.order.SellerWalletMapper |
57 | - com.yohoufo.dal.order.SellerWalletDetailMapper | 57 | - com.yohoufo.dal.order.SellerWalletDetailMapper |
58 | + - com.yohoufo.dal.order.OrderCouponMapper | ||
58 | 59 | ||
59 | ufo_promotion: | 60 | ufo_promotion: |
60 | servers: | 61 | servers: |
-
Please register or login to post a comment