Merge branch 'test6.8.5' of http://git.yoho.cn/ufo/yohoufo-fore into test6.8.5
Showing
22 changed files
with
497 additions
and
50 deletions
@@ -56,4 +56,6 @@ public interface StoragePriceMapper { | @@ -56,4 +56,6 @@ public interface StoragePriceMapper { | ||
56 | List<StoragePrice> selectBatchLeastPrice(@Param("skuList") Collection<Integer> skuList); | 56 | List<StoragePrice> selectBatchLeastPrice(@Param("skuList") Collection<Integer> skuList); |
57 | 57 | ||
58 | List<StoragePrice> selectByStorageIdsPlus(@Param("list") List<Integer> integers, @Param("storageId") Integer storageId, @Param("sellerUid") Integer sellerUid); | 58 | List<StoragePrice> selectByStorageIdsPlus(@Param("list") List<Integer> integers, @Param("storageId") Integer storageId, @Param("sellerUid") Integer sellerUid); |
59 | + | ||
60 | + int updateSkupHideStatus(@Param("uid") Integer uid, @Param("status") int status); | ||
59 | } | 61 | } |
@@ -85,7 +85,7 @@ | @@ -85,7 +85,7 @@ | ||
85 | where skup = #{skup,jdbcType=INTEGER} and status = 2 | 85 | where skup = #{skup,jdbcType=INTEGER} and status = 2 |
86 | </update> | 86 | </update> |
87 | <select id="selectLeastPrice" resultMap="BaseResultMap"> | 87 | <select id="selectLeastPrice" resultMap="BaseResultMap"> |
88 | - select price, skup from storage_price where storage_id = #{storageId,jdbcType=INTEGER} and status = 1 order by price limit 1 | 88 | + select price, skup from storage_price where storage_id = #{storageId,jdbcType=INTEGER} and status = 1 and is_hide = 0 order by price limit 1 |
89 | </select> | 89 | </select> |
90 | <select id="selectByStorageIds" resultMap="BaseResultMap"> | 90 | <select id="selectByStorageIds" resultMap="BaseResultMap"> |
91 | select id, skup, storage_id, price, status | 91 | select id, skup, storage_id, price, status |
@@ -95,6 +95,7 @@ | @@ -95,6 +95,7 @@ | ||
95 | open="(" separator="," close=")"> | 95 | open="(" separator="," close=")"> |
96 | #{item} | 96 | #{item} |
97 | </foreach> | 97 | </foreach> |
98 | + and is_hide = 0 | ||
98 | </select> | 99 | </select> |
99 | <select id="selectBySkupList" resultMap="BaseResultMap"> | 100 | <select id="selectBySkupList" resultMap="BaseResultMap"> |
100 | select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status, | 101 | select id, skup, product_id, goods_id, storage_id, depot_num, seller_uid, price, status, |
@@ -137,6 +138,11 @@ | @@ -137,6 +138,11 @@ | ||
137 | #{skup} | 138 | #{skup} |
138 | </foreach> | 139 | </foreach> |
139 | </update> | 140 | </update> |
141 | + | ||
142 | + <update id="updateSkupHideStatus"> | ||
143 | + update storage_price set is_hide = #{status}, update_time = unix_timestamp() | ||
144 | + where seller_uid = #{uid} and status in(0,1,100) | ||
145 | + </update> | ||
140 | 146 | ||
141 | <select id="selectBatchLeastPrice" resultMap="BaseResultMap"> | 147 | <select id="selectBatchLeastPrice" resultMap="BaseResultMap"> |
142 | select storage_id , min(price) as price from storage_price where | 148 | select storage_id , min(price) as price from storage_price where |
@@ -3,10 +3,12 @@ package com.yohoufo.order.charge; | @@ -3,10 +3,12 @@ package com.yohoufo.order.charge; | ||
3 | import com.yoho.core.common.utils.YHMath; | 3 | import com.yoho.core.common.utils.YHMath; |
4 | import com.yoho.error.ServiceError; | 4 | import com.yoho.error.ServiceError; |
5 | import com.yoho.error.exception.ServiceException; | 5 | import com.yoho.error.exception.ServiceException; |
6 | +import com.yohobuy.ufo.model.order.constants.OrderConstant; | ||
6 | import com.yohobuy.ufo.model.promotion.UserCouponsBo; | 7 | import com.yohobuy.ufo.model.promotion.UserCouponsBo; |
7 | import com.yohoufo.order.charge.model.*; | 8 | import com.yohoufo.order.charge.model.*; |
8 | import com.yohoufo.order.service.support.DeliveryWayCostSupport; | 9 | import com.yohoufo.order.service.support.DeliveryWayCostSupport; |
9 | import com.yohoufo.order.service.proxy.CouponProxyService; | 10 | import com.yohoufo.order.service.proxy.CouponProxyService; |
11 | +import com.yohoufo.order.service.support.ShoppingSupport; | ||
10 | import com.yohoufo.order.utils.LoggerUtils; | 12 | import com.yohoufo.order.utils.LoggerUtils; |
11 | import org.apache.commons.collections.CollectionUtils; | 13 | import org.apache.commons.collections.CollectionUtils; |
12 | import org.slf4j.Logger; | 14 | import org.slf4j.Logger; |
@@ -33,6 +35,9 @@ public class ChargeService { | @@ -33,6 +35,9 @@ public class ChargeService { | ||
33 | @Autowired | 35 | @Autowired |
34 | private DeliveryWayCostSupport deliveryWayCostSupport; | 36 | private DeliveryWayCostSupport deliveryWayCostSupport; |
35 | 37 | ||
38 | + @Autowired | ||
39 | + private ShoppingSupport shoppingSupport; | ||
40 | + | ||
36 | 41 | ||
37 | /** | 42 | /** |
38 | * 算费 | 43 | * 算费 |
@@ -87,9 +92,12 @@ public class ChargeService { | @@ -87,9 +92,12 @@ public class ChargeService { | ||
87 | */ | 92 | */ |
88 | private void calculateShippingAmount(ChargeContext chargeContext) { | 93 | private void calculateShippingAmount(ChargeContext chargeContext) { |
89 | 94 | ||
90 | - double deliveryWayCost = deliveryWayCostSupport.getCostOfSf(); | 95 | + //如果是门店自提,则免运费 |
96 | + double deliveryWayCost = shoppingSupport.isDeliveryWayByStore(chargeContext.getChargeParam().getDeliveryWay()) ? | ||
97 | + 0 : deliveryWayCostSupport.getCostOfSf(); | ||
91 | 98 | ||
92 | //运费 | 99 | //运费 |
100 | + chargeContext.getChargeResult().setDeliveryWay(chargeContext.getChargeParam().getDeliveryWay()); | ||
93 | chargeContext.getChargeResult().setShippingAmount(deliveryWayCost); | 101 | chargeContext.getChargeResult().setShippingAmount(deliveryWayCost); |
94 | 102 | ||
95 | ChargeResult chargeResult = chargeContext.getChargeResult(); | 103 | ChargeResult chargeResult = chargeContext.getChargeResult(); |
@@ -98,8 +106,9 @@ public class ChargeService { | @@ -98,8 +106,9 @@ public class ChargeService { | ||
98 | //包括运费 | 106 | //包括运费 |
99 | double newFinalAmount = YHMath.add(oldFinalAmount, deliveryWayCost); | 107 | double newFinalAmount = YHMath.add(oldFinalAmount, deliveryWayCost); |
100 | chargeResult.setFinalAmount(newFinalAmount); | 108 | chargeResult.setFinalAmount(newFinalAmount); |
101 | - logger.info("[{}] step shipping charge,sfExpressAmount:{},oldFinalAmount:{},newFinalAmount:{}", | 109 | + logger.info("[{}] step shipping charge, deliveryWay:{},sfExpressAmount:{},oldFinalAmount:{},newFinalAmount:{}", |
102 | chargeContext.getChargeParam().getUid(), | 110 | chargeContext.getChargeParam().getUid(), |
111 | + chargeContext.getChargeParam().getDeliveryWay(), | ||
103 | chargeResult.getShippingAmount(), | 112 | chargeResult.getShippingAmount(), |
104 | oldFinalAmount, | 113 | oldFinalAmount, |
105 | chargeResult.getFinalAmount()); | 114 | chargeResult.getFinalAmount()); |
@@ -15,5 +15,6 @@ import java.util.List; | @@ -15,5 +15,6 @@ import java.util.List; | ||
15 | @Builder | 15 | @Builder |
16 | public class ChargeParam { | 16 | public class ChargeParam { |
17 | private int uid; | 17 | private int uid; |
18 | + private int deliveryWay; | ||
18 | private List<String> couponCodes; | 19 | private List<String> couponCodes; |
19 | } | 20 | } |
@@ -49,6 +49,23 @@ public class ActionStatusHold { | @@ -49,6 +49,23 @@ public class ActionStatusHold { | ||
49 | static { | 49 | static { |
50 | canModifyAddressStatus = Arrays.asList(OrderStatus.HAS_PAYED.getCode(), OrderStatus.SELLER_SEND_OUT.getCode(),OrderStatus.PLATFORM_RECEIVE.getCode()); | 50 | canModifyAddressStatus = Arrays.asList(OrderStatus.HAS_PAYED.getCode(), OrderStatus.SELLER_SEND_OUT.getCode(),OrderStatus.PLATFORM_RECEIVE.getCode()); |
51 | } | 51 | } |
52 | + | ||
53 | + //has paid | ||
54 | + static List<Integer> hasPaid ; | ||
55 | + static { | ||
56 | + hasPaid = Arrays.asList(OrderStatus.HAS_PAYED.getCode(), | ||
57 | + OrderStatus.SELLER_SEND_OUT.getCode(), | ||
58 | + OrderStatus.PLATFORM_CHECKING.getCode(), | ||
59 | + OrderStatus.WAITING_RECEIVE.getCode(), | ||
60 | + OrderStatus.PLATFORM_RECEIVE.getCode(), | ||
61 | + OrderStatus.JUDGE_PASS.getCode(), | ||
62 | + OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode(), | ||
63 | + OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode()); | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
67 | + public static boolean isBuyerPaid(Integer status){ | ||
68 | + return BuyerASH.hasPaid.contains(status); | ||
52 | } | 69 | } |
53 | 70 | ||
54 | public static boolean buyerCanModifyAddress(Integer status){ | 71 | public static boolean buyerCanModifyAddress(Integer status){ |
1 | +package com.yohoufo.order.controller; | ||
2 | + | ||
3 | +import com.yohoufo.common.ApiResponse; | ||
4 | +import com.yohoufo.order.model.request.OfflineShoppingRequest; | ||
5 | +import com.yohoufo.order.model.response.ComputeResponse; | ||
6 | +import com.yohoufo.order.model.response.OfflinePaymentResponse; | ||
7 | +import com.yohoufo.order.model.response.OrderSubmitResponse; | ||
8 | +import com.yohoufo.order.service.IOfflineShoppingService; | ||
9 | +import com.yohoufo.order.utils.CouponCodeUtils; | ||
10 | +import com.yohoufo.order.utils.LoggerUtils; | ||
11 | +import org.apache.commons.lang3.StringUtils; | ||
12 | +import org.slf4j.Logger; | ||
13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
14 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
15 | +import org.springframework.web.bind.annotation.RequestParam; | ||
16 | +import org.springframework.web.bind.annotation.RestController; | ||
17 | + | ||
18 | +@RestController | ||
19 | +@RequestMapping(value = "/shopping") | ||
20 | +public class OfflineShoppingController { | ||
21 | + | ||
22 | + private Logger logger = LoggerUtils.getBuyerOrderLogger(); | ||
23 | + | ||
24 | + @Autowired | ||
25 | + IOfflineShoppingService offlineShoppingService; | ||
26 | + | ||
27 | + /** | ||
28 | + * 结算 | ||
29 | + * @return | ||
30 | + */ | ||
31 | + @RequestMapping(params = "method=ufo.order.offlinePayment") | ||
32 | + public ApiResponse offlinePayment(@RequestParam(name = "uid") Integer uid, | ||
33 | + @RequestParam(name = "skup") Integer skup, | ||
34 | + @RequestParam(name = "store_id") Integer storeId){ | ||
35 | + OfflineShoppingRequest req = new OfflineShoppingRequest(); | ||
36 | + req.setUid(uid); | ||
37 | + req.setSkup(skup); | ||
38 | + req.setStoreId(storeId); | ||
39 | + logger.info("in ufo.order.offlinePayment, req {}", req); | ||
40 | + OfflinePaymentResponse paymentResponse = offlineShoppingService.offlinePayment(req); | ||
41 | + return new ApiResponse.ApiResponseBuilder().code(200).data(paymentResponse).build(); | ||
42 | + } | ||
43 | + | ||
44 | + | ||
45 | + /** | ||
46 | + * 用券结算 | ||
47 | + * | ||
48 | + * @return | ||
49 | + */ | ||
50 | + @RequestMapping(params = "method=ufo.order.offlineCompute") | ||
51 | + public ApiResponse offlineCompute(@RequestParam(name = "uid") Integer uid, | ||
52 | + @RequestParam(name = "skup") Integer skup, | ||
53 | + @RequestParam(name = "coupon_code",required = false) String couponCode) { | ||
54 | + | ||
55 | + OfflineShoppingRequest req = new OfflineShoppingRequest(); | ||
56 | + req.setUid(uid); | ||
57 | + req.setSkup(skup); | ||
58 | + req.setCouponCodes(CouponCodeUtils.asList(couponCode)); | ||
59 | + | ||
60 | + logger.info("in ufo.order.offlineCompute, req {}", req); | ||
61 | + ComputeResponse resp = offlineShoppingService.offlineCompute(req); | ||
62 | + return new ApiResponse.ApiResponseBuilder().code(200).data(resp).build(); | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * 提交订单成功 | ||
67 | + * @return | ||
68 | + */ | ||
69 | + @RequestMapping(params = "method=ufo.order.offlineSubmit") | ||
70 | + public ApiResponse offlineSubmit(@RequestParam(name = "uid") Integer uid, | ||
71 | + @RequestParam(name = "skup") Integer skup, | ||
72 | + @RequestParam(name = "coupon_code",required = false) String couponCode, | ||
73 | + @RequestParam(name = "channelNo", required = false) String channelNo, | ||
74 | + @RequestParam(name = "store_id") Integer storeId, | ||
75 | + @RequestParam(name = "user_longitude") Double userLongitude, | ||
76 | + @RequestParam(name = "user_latitude") Double userLatitude, | ||
77 | + @RequestParam(name = "client_type", required = false) String clientType){ | ||
78 | + if(StringUtils.isBlank(channelNo)){ | ||
79 | + channelNo = "2919"; | ||
80 | + } | ||
81 | + | ||
82 | + OfflineShoppingRequest request = new OfflineShoppingRequest(); | ||
83 | + request.setUid(uid); | ||
84 | + request.setSkup(skup); | ||
85 | + request.setCouponCodes(CouponCodeUtils.asList(couponCode)); | ||
86 | + request.setChannelNo(channelNo); | ||
87 | + request.setAddressId("0"); //门店自提,不需addressId | ||
88 | + request.setStoreId(storeId); | ||
89 | + request.setUserLongitude(userLongitude); | ||
90 | + request.setUserLatitude(userLatitude); | ||
91 | + request.setClientType(clientType); | ||
92 | + | ||
93 | + logger.info("in ufo.order.offlineSubmit, req {}", request); | ||
94 | + OrderSubmitResponse submitResponse = offlineShoppingService.offlineSubmit(request); | ||
95 | + logger.info("out ufo.order.offlineSubmit,resp:{}", submitResponse); | ||
96 | + return new ApiResponse.ApiResponseBuilder().code(200).data(submitResponse).build(); | ||
97 | + } | ||
98 | +} |
@@ -15,6 +15,7 @@ import java.math.BigDecimal; | @@ -15,6 +15,7 @@ import java.math.BigDecimal; | ||
15 | @AllArgsConstructor | 15 | @AllArgsConstructor |
16 | @NoArgsConstructor | 16 | @NoArgsConstructor |
17 | public class BuyerPenaltyCalResult { | 17 | public class BuyerPenaltyCalResult { |
18 | + | ||
18 | private Integer uid; | 19 | private Integer uid; |
19 | private Long orderCode; | 20 | private Long orderCode; |
20 | private BigDecimal orderActualAmount; | 21 | private BigDecimal orderActualAmount; |
@@ -22,4 +23,9 @@ public class BuyerPenaltyCalResult { | @@ -22,4 +23,9 @@ public class BuyerPenaltyCalResult { | ||
22 | private BigDecimal penaltyAmount; | 23 | private BigDecimal penaltyAmount; |
23 | private BigDecimal leftAmount; | 24 | private BigDecimal leftAmount; |
24 | private BigDecimal penaltyRate; | 25 | private BigDecimal penaltyRate; |
26 | + private final static BuyerPenaltyCalResult defaultBPCR; | ||
27 | + static {defaultBPCR = new BuyerPenaltyCalResult();} | ||
28 | + public static BuyerPenaltyCalResult getDefault(){ | ||
29 | + return defaultBPCR; | ||
30 | + } | ||
25 | } | 31 | } |
1 | +package com.yohoufo.order.model.request; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | +import lombok.ToString; | ||
5 | + | ||
6 | +@Data | ||
7 | +@ToString(callSuper = true) | ||
8 | +public class OfflineShoppingRequest extends ShoppingRequest { | ||
9 | + | ||
10 | + private Integer storeId; | ||
11 | + | ||
12 | + private Double userLongitude; | ||
13 | + | ||
14 | + private Double userLatitude; | ||
15 | +} |
1 | +package com.yohoufo.order.model.response; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | +import lombok.ToString; | ||
5 | + | ||
6 | +@Data | ||
7 | +@ToString(callSuper = true) | ||
8 | +public class OfflinePaymentResponse extends PaymentResponse { | ||
9 | + | ||
10 | + private String storeName; | ||
11 | + | ||
12 | + private String storeAddress; | ||
13 | + | ||
14 | + public static OfflinePaymentResponse wrap(PaymentResponse paymentResponse) { | ||
15 | + OfflinePaymentResponse offlinePaymentResponse = new OfflinePaymentResponse(); | ||
16 | + offlinePaymentResponse.setAmount(paymentResponse.getAmount()); | ||
17 | + offlinePaymentResponse.setGood(paymentResponse.getGood()); | ||
18 | + offlinePaymentResponse.setPaymentWay(paymentResponse.getPaymentWay()); | ||
19 | + offlinePaymentResponse.setDeliveryWay(paymentResponse.getDeliveryWay()); | ||
20 | + offlinePaymentResponse.setPromotionFormulaList(paymentResponse.getPromotionFormulaList()); | ||
21 | + offlinePaymentResponse.setDamagesDesc(paymentResponse.getDamagesDesc()); | ||
22 | + | ||
23 | + return offlinePaymentResponse; | ||
24 | + } | ||
25 | + | ||
26 | +} |
1 | +package com.yohoufo.order.service; | ||
2 | + | ||
3 | +import com.yohoufo.order.model.request.OfflineShoppingRequest; | ||
4 | +import com.yohoufo.order.model.response.ComputeResponse; | ||
5 | +import com.yohoufo.order.model.response.OfflinePaymentResponse; | ||
6 | +import com.yohoufo.order.model.response.OrderSubmitResponse; | ||
7 | + | ||
8 | +public interface IOfflineShoppingService { | ||
9 | + /** | ||
10 | + * 结算页数据 | ||
11 | + * @param request | ||
12 | + * @return | ||
13 | + */ | ||
14 | + OfflinePaymentResponse offlinePayment(OfflineShoppingRequest request); | ||
15 | + | ||
16 | + | ||
17 | + /** | ||
18 | + * 重新结算 | ||
19 | + * @param request | ||
20 | + * @return | ||
21 | + */ | ||
22 | + ComputeResponse offlineCompute(OfflineShoppingRequest request); | ||
23 | + | ||
24 | + | ||
25 | + /** | ||
26 | + * 提交订单 | ||
27 | + * @param shoppingRequest | ||
28 | + * @return | ||
29 | + */ | ||
30 | + OrderSubmitResponse offlineSubmit(OfflineShoppingRequest shoppingRequest); | ||
31 | +} |
@@ -624,7 +624,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { | @@ -624,7 +624,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { | ||
624 | || type == SellerWalletDetail.Type.APPRAISE_FAIL | 624 | || type == SellerWalletDetail.Type.APPRAISE_FAIL |
625 | || type == SellerWalletDetail.Type.CS_CANCEL_BEFORE_DEPOT_RECEIVE) { | 625 | || type == SellerWalletDetail.Type.CS_CANCEL_BEFORE_DEPOT_RECEIVE) { |
626 | // 处罚保证金 | 626 | // 处罚保证金 |
627 | - lockAmount = money.multiply(new BigDecimal("-1")); | 627 | + // TODO 如果是超级卖家 |
628 | + boolean isSuper = false; | ||
629 | + logger.info("{}修改钱包,uid={},处罚保证金场合:获取身份超级卖家:{}", type.getName(), uid, isSuper); | ||
630 | + if(isSuper) { | ||
631 | + availAmount = money.multiply(new BigDecimal("-1")); | ||
632 | + } else { | ||
633 | + lockAmount = money.multiply(new BigDecimal("-1")); | ||
634 | + } | ||
628 | tradeAmount = lockAmount; | 635 | tradeAmount = lockAmount; |
629 | logger.info("{}修改钱包,uid={},处罚保证金场合:", type.getName(), uid); | 636 | logger.info("{}修改钱包,uid={},处罚保证金场合:", type.getName(), uid); |
630 | } | 637 | } |
@@ -635,7 +642,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { | @@ -635,7 +642,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { | ||
635 | logger.info("{}修改钱包表余额,bean={}", message, sw); | 642 | logger.info("{}修改钱包表余额,bean={}", message, sw); |
636 | if (sellerWalletMapper.addMoney(sw) == 0) { | 643 | if (sellerWalletMapper.addMoney(sw) == 0) { |
637 | logger.error(message + "失败,(余额不足或钱包不可用)更新表返回0,bean={}", sw); | 644 | logger.error(message + "失败,(余额不足或钱包不可用)更新表返回0,bean={}", sw); |
638 | - // CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "(余额不足货钱包不可用)更新表返回0,uid=" + uid + ", bean为:"+ sw); | 645 | + CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.walletPunishment", "用户:" + uid + ",(余额不足货钱包不可用),更新表返回 0,bean为:"+ sw); |
639 | return null; | 646 | return null; |
640 | } | 647 | } |
641 | logger.info("修改钱包表余额成功,bean={}", sw); | 648 | logger.info("修改钱包表余额成功,bean={}", sw); |
@@ -10,17 +10,15 @@ import com.yohoufo.common.utils.DateUtil; | @@ -10,17 +10,15 @@ import com.yohoufo.common.utils.DateUtil; | ||
10 | import com.yohoufo.dal.order.OrdersPayMapper; | 10 | import com.yohoufo.dal.order.OrdersPayMapper; |
11 | import com.yohoufo.dal.order.model.BuyerOrder; | 11 | import com.yohoufo.dal.order.model.BuyerOrder; |
12 | import com.yohoufo.dal.order.model.OrdersPay; | 12 | import com.yohoufo.dal.order.model.OrdersPay; |
13 | +import com.yohoufo.order.common.ActionStatusHold; | ||
13 | import com.yohoufo.order.model.dto.BuyerPenalty; | 14 | import com.yohoufo.order.model.dto.BuyerPenalty; |
14 | import com.yohoufo.order.model.dto.BuyerPenaltyCalResult; | 15 | import com.yohoufo.order.model.dto.BuyerPenaltyCalResult; |
15 | import com.yohoufo.order.service.impl.MetaConfigService; | 16 | import com.yohoufo.order.service.impl.MetaConfigService; |
16 | -import com.yohoufo.order.service.impl.OrderDynamicConfig; | ||
17 | import com.yohoufo.order.utils.LoggerUtils; | 17 | import com.yohoufo.order.utils.LoggerUtils; |
18 | import org.slf4j.Logger; | 18 | import org.slf4j.Logger; |
19 | -import org.slf4j.LoggerFactory; | ||
20 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
21 | import org.springframework.stereotype.Component; | 20 | import org.springframework.stereotype.Component; |
22 | 21 | ||
23 | -import javax.annotation.Resource; | ||
24 | import java.math.BigDecimal; | 22 | import java.math.BigDecimal; |
25 | import java.util.Collection; | 23 | import java.util.Collection; |
26 | import java.util.Objects; | 24 | import java.util.Objects; |
@@ -42,6 +40,9 @@ public class BuyerCancelCompensateComputeHandler { | @@ -42,6 +40,9 @@ public class BuyerCancelCompensateComputeHandler { | ||
42 | public BuyerPenaltyCalResult calBuyerPenaltyCalResult(BuyerOrder buyerOrder){ | 40 | public BuyerPenaltyCalResult calBuyerPenaltyCalResult(BuyerOrder buyerOrder){ |
43 | Integer buyerUid = buyerOrder.getUid(); | 41 | Integer buyerUid = buyerOrder.getUid(); |
44 | Long orderCode = buyerOrder.getOrderCode(); | 42 | Long orderCode = buyerOrder.getOrderCode(); |
43 | + if(!ActionStatusHold.isBuyerPaid(buyerOrder.getStatus())){ | ||
44 | + return BuyerPenaltyCalResult.getDefault(); | ||
45 | + } | ||
45 | OrderStatus orderStatus = OrderStatus.getOrderStatus(buyerOrder.getStatus()); | 46 | OrderStatus orderStatus = OrderStatus.getOrderStatus(buyerOrder.getStatus()); |
46 | BigDecimal orderActualAmount = buyerOrder.getAmount(); | 47 | BigDecimal orderActualAmount = buyerOrder.getAmount(); |
47 | BigDecimal shipFee = buyerOrder.getShipFee(); | 48 | BigDecimal shipFee = buyerOrder.getShipFee(); |
@@ -7,14 +7,16 @@ import com.yohobuy.ufo.model.order.bo.ButtonShowBo; | @@ -7,14 +7,16 @@ import com.yohobuy.ufo.model.order.bo.ButtonShowBo; | ||
7 | import com.yohobuy.ufo.model.order.bo.OrderInfo; | 7 | import com.yohobuy.ufo.model.order.bo.OrderInfo; |
8 | import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; | 8 | import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; |
9 | import com.yohobuy.ufo.model.order.common.ButtonShow; | 9 | import com.yohobuy.ufo.model.order.common.ButtonShow; |
10 | -import com.yohobuy.ufo.model.order.common.SkupStatus; | ||
11 | -import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail; | ||
12 | -import com.yohoufo.common.utils.DateUtil; | ||
13 | -import com.yohoufo.dal.order.model.*; | ||
14 | import com.yohobuy.ufo.model.order.common.OrderStatus; | 10 | import com.yohobuy.ufo.model.order.common.OrderStatus; |
15 | import com.yohobuy.ufo.model.order.common.TabType; | 11 | import com.yohobuy.ufo.model.order.common.TabType; |
16 | -import com.yohoufo.order.convert.GoodsInfoConvertor; | 12 | +import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail; |
17 | import com.yohobuy.ufo.model.order.vo.AddressInfo; | 13 | import com.yohobuy.ufo.model.order.vo.AddressInfo; |
14 | +import com.yohoufo.common.utils.DateUtil; | ||
15 | +import com.yohoufo.dal.order.model.BuyerOrder; | ||
16 | +import com.yohoufo.dal.order.model.BuyerOrderGoods; | ||
17 | +import com.yohoufo.dal.order.model.BuyerOrderMeta; | ||
18 | +import com.yohoufo.dal.order.model.SellerOrderGoods; | ||
19 | +import com.yohoufo.order.convert.GoodsInfoConvertor; | ||
18 | import com.yohoufo.order.model.request.OrderRequest; | 20 | import com.yohoufo.order.model.request.OrderRequest; |
19 | import com.yohoufo.order.model.response.GoodsInfo; | 21 | import com.yohoufo.order.model.response.GoodsInfo; |
20 | import com.yohoufo.order.model.response.OrderDetailInfo; | 22 | import com.yohoufo.order.model.response.OrderDetailInfo; |
@@ -36,9 +38,6 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen | @@ -36,9 +38,6 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen | ||
36 | private final Logger logger = LoggerFactory.getLogger(getClass()); | 38 | private final Logger logger = LoggerFactory.getLogger(getClass()); |
37 | 39 | ||
38 | @Autowired | 40 | @Autowired |
39 | - private OrdersPayService ordersPayService; | ||
40 | - | ||
41 | - @Autowired | ||
42 | protected IExpressInfoService expressInfoService; | 41 | protected IExpressInfoService expressInfoService; |
43 | 42 | ||
44 | abstract BuyerOrder getBuyerOrder(int uid, long orderCode); | 43 | abstract BuyerOrder getBuyerOrder(int uid, long orderCode); |
@@ -2,7 +2,6 @@ package com.yohoufo.order.service.impl; | @@ -2,7 +2,6 @@ package com.yohoufo.order.service.impl; | ||
2 | 2 | ||
3 | import com.google.common.base.Verify; | 3 | import com.google.common.base.Verify; |
4 | import com.yoho.error.ServiceError; | 4 | import com.yoho.error.ServiceError; |
5 | -import com.yoho.error.exception.ServiceException; | ||
6 | import com.yohobuy.ufo.model.order.common.OrderStatus; | 5 | import com.yohobuy.ufo.model.order.common.OrderStatus; |
7 | import com.yohoufo.common.alarm.EventBusPublisher; | 6 | import com.yohoufo.common.alarm.EventBusPublisher; |
8 | import com.yohoufo.common.alarm.SmsAlarmEvent; | 7 | import com.yohoufo.common.alarm.SmsAlarmEvent; |
@@ -30,11 +29,13 @@ import java.math.BigDecimal; | @@ -30,11 +29,13 @@ import java.math.BigDecimal; | ||
30 | import java.util.Objects; | 29 | import java.util.Objects; |
31 | import java.util.function.BiConsumer; | 30 | import java.util.function.BiConsumer; |
32 | 31 | ||
32 | +import static com.yohoufo.order.utils.ServiceExceptions.throwServiceException; | ||
33 | + | ||
33 | /** | 34 | /** |
34 | * @author LUOXC | 35 | * @author LUOXC |
35 | * @date 2019/1/8 14:07 | 36 | * @date 2019/1/8 14:07 |
36 | */ | 37 | */ |
37 | -@Slf4j | 38 | +@Slf4j(topic = "orderCloseLog") |
38 | class BuyerOrderCancelHandler { | 39 | class BuyerOrderCancelHandler { |
39 | 40 | ||
40 | private final int uid; | 41 | private final int uid; |
@@ -65,8 +66,6 @@ class BuyerOrderCancelHandler { | @@ -65,8 +66,6 @@ class BuyerOrderCancelHandler { | ||
65 | private BuyerRefundCouponEvent.BizCase refundCouponCase; | 66 | private BuyerRefundCouponEvent.BizCase refundCouponCase; |
66 | 67 | ||
67 | 68 | ||
68 | - | ||
69 | - | ||
70 | private AlarmConfig failAlarm; | 69 | private AlarmConfig failAlarm; |
71 | 70 | ||
72 | BuyerOrderCancelHandler(int uid, long orderCode) { | 71 | BuyerOrderCancelHandler(int uid, long orderCode) { |
@@ -132,19 +131,29 @@ class BuyerOrderCancelHandler { | @@ -132,19 +131,29 @@ class BuyerOrderCancelHandler { | ||
132 | } | 131 | } |
133 | 132 | ||
134 | public void cancel() { | 133 | public void cancel() { |
134 | + log.info("cancel order {} from {} to {}", orderCode, expectStatus, targetStatus); | ||
135 | verify(); | 135 | verify(); |
136 | // 获取买家订单 | 136 | // 获取买家订单 |
137 | BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid); | 137 | BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid); |
138 | + if (Objects.isNull(buyerOrder)) { | ||
139 | + log.info("cancel order {} fail, order is not exist", orderCode); | ||
140 | + throwServiceException(ServiceError.ORDER_NOT_EXIST); | ||
141 | + } | ||
138 | // 当前状态不可取消订单 | 142 | // 当前状态不可取消订单 |
139 | if (expectStatus.getCode() != buyerOrder.getStatus()) { | 143 | if (expectStatus.getCode() != buyerOrder.getStatus()) { |
140 | - throw new ServiceException(ServiceError.ORDER_SERVICE_ERROR); | 144 | + log.info("cancel order {} fail, order status is not expect", orderCode); |
145 | + throwServiceException("当前状态不可取消订单"); | ||
141 | } | 146 | } |
142 | // 更新订单状态成功 | 147 | // 更新订单状态成功 |
143 | if (updateBuyerOrderStatus()) { | 148 | if (updateBuyerOrderStatus()) { |
149 | + log.info("cancel order {} from {} to {} success", orderCode, expectStatus, targetStatus); | ||
144 | refundCoupon(); | 150 | refundCoupon(); |
145 | transfer(); | 151 | transfer(); |
146 | refundPayGoodsMoney(buyerOrder); | 152 | refundPayGoodsMoney(buyerOrder); |
147 | noticeSeller(); | 153 | noticeSeller(); |
154 | + } else { | ||
155 | + log.info("cancel order {} fail, order status has changed", orderCode); | ||
156 | + throwServiceException("当前状态不可取消订单"); | ||
148 | } | 157 | } |
149 | } | 158 | } |
150 | 159 | ||
@@ -180,6 +189,7 @@ class BuyerOrderCancelHandler { | @@ -180,6 +189,7 @@ class BuyerOrderCancelHandler { | ||
180 | .uid(uid) | 189 | .uid(uid) |
181 | .orderCode(orderCode) | 190 | .orderCode(orderCode) |
182 | .build(); | 191 | .build(); |
192 | + log.info("refund coupon by order {} request is {}", orderCode, buyerRefundCouponEvent); | ||
183 | EventBusPublisher.publishEvent(buyerRefundCouponEvent); | 193 | EventBusPublisher.publishEvent(buyerRefundCouponEvent); |
184 | } | 194 | } |
185 | 195 | ||
@@ -193,6 +203,7 @@ class BuyerOrderCancelHandler { | @@ -193,6 +203,7 @@ class BuyerOrderCancelHandler { | ||
193 | .transferCase(transferCase) | 203 | .transferCase(transferCase) |
194 | .swdType(sellerWalletDetailType) | 204 | .swdType(sellerWalletDetailType) |
195 | .build(); | 205 | .build(); |
206 | + log.info("transfer by order {} request is {}", orderCode, transferMoneyRequest); | ||
196 | transferService.transfer(transferMoneyRequest); | 207 | transferService.transfer(transferMoneyRequest); |
197 | } | 208 | } |
198 | 209 | ||
@@ -215,9 +226,11 @@ class BuyerOrderCancelHandler { | @@ -215,9 +226,11 @@ class BuyerOrderCancelHandler { | ||
215 | .refundCase(goodsMoneyRefundCase) | 226 | .refundCase(goodsMoneyRefundCase) |
216 | .amount(goodsMoney); | 227 | .amount(goodsMoney); |
217 | try { | 228 | try { |
229 | + log.info("refund pay goods money by order {} request is {} ", orderCode, paymentRequest); | ||
218 | goodsMoneyRefundConsumer.accept(paymentRequest, billLogEventBuilder.skup(getSkup())); | 230 | goodsMoneyRefundConsumer.accept(paymentRequest, billLogEventBuilder.skup(getSkup())); |
219 | - } catch (Exception ex) { | ||
220 | - log.warn("pay refund fail,req {}", paymentRequest, ex); | 231 | + log.info("refund pay goods money by order {} success", orderCode); |
232 | + } catch (Exception e) { | ||
233 | + log.info("refund pay goods money by order {} fail request is {}", orderCode, paymentRequest, e); | ||
221 | BillLogEvent billLogEvent = billLogEventBuilder.tradeStatus(BillTradeStatus.FAIL.getCode()).build(); | 234 | BillLogEvent billLogEvent = billLogEventBuilder.tradeStatus(BillTradeStatus.FAIL.getCode()).build(); |
222 | EventBusPublisher.publishEvent(billLogEvent); | 235 | EventBusPublisher.publishEvent(billLogEvent); |
223 | 236 | ||
@@ -235,10 +248,11 @@ class BuyerOrderCancelHandler { | @@ -235,10 +248,11 @@ class BuyerOrderCancelHandler { | ||
235 | private void noticeSeller() { | 248 | private void noticeSeller() { |
236 | if (Objects.nonNull(sellerNoticeSender)) { | 249 | if (Objects.nonNull(sellerNoticeSender)) { |
237 | try { | 250 | try { |
251 | + log.info("notice seller buyer order has closed by order {}", orderCode); | ||
238 | SellerOrderGoods sog = getSellerOrderGoods(); | 252 | SellerOrderGoods sog = getSellerOrderGoods(); |
239 | sellerNoticeSender.notice(sog, orderCode, sellerNoticeSenderTimes); | 253 | sellerNoticeSender.notice(sog, orderCode, sellerNoticeSenderTimes); |
240 | - } catch (Exception ex) { | ||
241 | - log.warn("seller deliver notice fail,times {} order code is {}", sellerNoticeSenderTimes, orderCode, ex); | 254 | + } catch (Exception e) { |
255 | + log.info("notice seller buyer order has closed by order {} fail", orderCode, e); | ||
242 | } | 256 | } |
243 | } | 257 | } |
244 | } | 258 | } |
1 | +package com.yohoufo.order.service.impl; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
4 | +import com.yoho.tools.common.beans.ApiResponse; | ||
5 | +import com.yohobuy.ufo.model.order.common.OrderAttributes; | ||
6 | +import com.yohobuy.ufo.model.order.constants.OrderConstant; | ||
7 | +import com.yohobuy.ufo.model.order.vo.AddressInfo; | ||
8 | +import com.yohobuy.ufo.model.response.store.StoreInfoBo; | ||
9 | +import com.yohoufo.common.caller.UfoServiceCaller; | ||
10 | +import com.yohoufo.common.exception.UfoServiceException; | ||
11 | +import com.yohoufo.order.model.request.OfflineShoppingRequest; | ||
12 | +import com.yohoufo.order.model.request.ShoppingRequest; | ||
13 | +import com.yohoufo.order.model.response.ComputeResponse; | ||
14 | +import com.yohoufo.order.model.response.OfflinePaymentResponse; | ||
15 | +import com.yohoufo.order.model.response.OrderSubmitResponse; | ||
16 | +import com.yohoufo.order.model.response.PaymentResponse; | ||
17 | +import com.yohoufo.order.service.IOfflineShoppingService; | ||
18 | +import com.yohoufo.order.utils.LoggerUtils; | ||
19 | +import org.apache.commons.lang3.tuple.Pair; | ||
20 | +import org.slf4j.Logger; | ||
21 | +import org.springframework.beans.factory.annotation.Autowired; | ||
22 | +import org.springframework.stereotype.Service; | ||
23 | + | ||
24 | +@Service("offlineShoppingService") | ||
25 | +public class OfflineShoppingServiceImpl extends ShoppingServiceImpl implements IOfflineShoppingService { | ||
26 | + | ||
27 | + private final Logger logger = LoggerUtils.getBuyerOrderLogger(); | ||
28 | + | ||
29 | + @Autowired | ||
30 | + UfoServiceCaller ufoServiceCaller; | ||
31 | + | ||
32 | + @Override | ||
33 | + public OfflinePaymentResponse offlinePayment(OfflineShoppingRequest request) { | ||
34 | + StoreInfoBo storeInfoBo = queryStoreInfo(request.getStoreId()); | ||
35 | + if(storeInfoBo == null) { | ||
36 | + logger.warn("storeId from goods not invalid, req: {}", request); | ||
37 | + throw new UfoServiceException(500, "商品门店信息为空"); | ||
38 | + } | ||
39 | + | ||
40 | + PaymentResponse paymentResponse = super.payment(request); | ||
41 | + return buildOfflinePaymentResponse(paymentResponse, storeInfoBo); | ||
42 | + } | ||
43 | + | ||
44 | + private OfflinePaymentResponse buildOfflinePaymentResponse(PaymentResponse paymentResponse, StoreInfoBo storeInfoBo) { | ||
45 | + OfflinePaymentResponse offlinePaymentResponse = OfflinePaymentResponse.wrap(paymentResponse); | ||
46 | + offlinePaymentResponse.setStoreName(storeInfoBo.getStoreName()); | ||
47 | + offlinePaymentResponse.setStoreAddress(storeInfoBo.getStoreAddress()); | ||
48 | + return offlinePaymentResponse; | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public ComputeResponse offlineCompute(OfflineShoppingRequest request) { | ||
53 | + return super.compute(request); | ||
54 | + } | ||
55 | + | ||
56 | + @Override | ||
57 | + public OrderSubmitResponse offlineSubmit(OfflineShoppingRequest offlineRequest) { | ||
58 | + if(!checkLocationInStore(offlineRequest.getStoreId(), offlineRequest.getUserLongitude(), offlineRequest.getUserLatitude())) { | ||
59 | + logger.warn("user not location in the store, req: {}", offlineRequest); | ||
60 | + throw new UfoServiceException(500, "定位不在门店内,不允许购买"); | ||
61 | + } | ||
62 | + return super.submit(offlineRequest); | ||
63 | + } | ||
64 | + | ||
65 | + private boolean checkLocationInStore(int storeId, double userLongitude, double userLatitude) { | ||
66 | + ApiResponse resp = ufoServiceCaller.call("ufo.store.isLocationInStore", ApiResponse.class, storeId, userLongitude, userLatitude); | ||
67 | + if (resp != null && resp.getCode()==200) { | ||
68 | + if (resp.getData() != null) { | ||
69 | + JSONObject json = (JSONObject)resp.getData(); | ||
70 | + return json.getBoolean("isInRange"); | ||
71 | + } | ||
72 | + } | ||
73 | + logger.warn("check location failed: {}", resp); | ||
74 | + throw new UfoServiceException(500, "校验定位信息失败"); | ||
75 | + } | ||
76 | + | ||
77 | + | ||
78 | + //查询门店信息 | ||
79 | + private StoreInfoBo queryStoreInfo(int storeId) { | ||
80 | + ApiResponse resp = ufoServiceCaller.call("ufo.store.queryStoreInfoById", ApiResponse.class, storeId); | ||
81 | + if (resp != null && resp.getCode()==200) { | ||
82 | + if (resp.getData() != null) { | ||
83 | + return (StoreInfoBo)resp.getData(); | ||
84 | + } | ||
85 | + } | ||
86 | + return null; | ||
87 | + } | ||
88 | + | ||
89 | + | ||
90 | + @Override | ||
91 | + protected Pair<AddressInfo, AddressInfo> getAndCheckAddressInfo(ShoppingRequest shoppingRequest) { | ||
92 | + OfflineShoppingRequest offlineShoppingRequest = (OfflineShoppingRequest) shoppingRequest; | ||
93 | + | ||
94 | + StoreInfoBo storeInfoBo = queryStoreInfo(offlineShoppingRequest.getStoreId()); | ||
95 | + if(storeInfoBo == null) { | ||
96 | + logger.warn("storeInfo not exist, req: {}", offlineShoppingRequest); | ||
97 | + throw new UfoServiceException(500, "门店信息不存在"); | ||
98 | + } | ||
99 | + | ||
100 | + AddressInfo storeAddress = new AddressInfo(); | ||
101 | + storeAddress.setAddress_id(0); | ||
102 | + storeAddress.setUid(offlineShoppingRequest.getUid()); | ||
103 | + storeAddress.setAddress(storeInfoBo.getStoreAddress()); | ||
104 | + | ||
105 | + return Pair.of(storeAddress, storeAddress); | ||
106 | + } | ||
107 | + | ||
108 | + | ||
109 | + @Override | ||
110 | + protected OrderAttributes buildOrderArrtribute() { | ||
111 | + return OrderAttributes.OFFLINE; | ||
112 | + } | ||
113 | + | ||
114 | + @Override | ||
115 | + protected int buildDeliveryWay() { | ||
116 | + return OrderConstant.DELIVERY_WAY_STORE; | ||
117 | + } | ||
118 | +} |
@@ -43,13 +43,17 @@ import com.yohoufo.order.utils.AddressHelper; | @@ -43,13 +43,17 @@ import com.yohoufo.order.utils.AddressHelper; | ||
43 | import com.yohoufo.order.utils.LoggerUtils; | 43 | import com.yohoufo.order.utils.LoggerUtils; |
44 | import com.yohoufo.order.utils.MathUtils; | 44 | import com.yohoufo.order.utils.MathUtils; |
45 | import org.apache.commons.lang3.StringUtils; | 45 | import org.apache.commons.lang3.StringUtils; |
46 | +import org.apache.commons.lang3.tuple.Pair; | ||
46 | import org.slf4j.Logger; | 47 | import org.slf4j.Logger; |
47 | import org.springframework.beans.factory.annotation.Autowired; | 48 | import org.springframework.beans.factory.annotation.Autowired; |
48 | import java.math.BigDecimal; | 49 | import java.math.BigDecimal; |
49 | import java.util.Arrays; | 50 | import java.util.Arrays; |
50 | import java.util.List; | 51 | import java.util.List; |
52 | + | ||
53 | +import org.springframework.context.annotation.Primary; | ||
51 | import org.springframework.stereotype.Service; | 54 | import org.springframework.stereotype.Service; |
52 | 55 | ||
56 | +@Primary | ||
53 | @Service | 57 | @Service |
54 | public class ShoppingServiceImpl implements IShoppingService { | 58 | public class ShoppingServiceImpl implements IShoppingService { |
55 | 59 | ||
@@ -119,7 +123,7 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -119,7 +123,7 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
119 | 123 | ||
120 | PaymentResponse response = new PaymentResponse(); | 124 | PaymentResponse response = new PaymentResponse(); |
121 | response.setPaymentWay(shoppingSupport.getPaymentWay()); | 125 | response.setPaymentWay(shoppingSupport.getPaymentWay()); |
122 | - response.setDeliveryWay(shoppingSupport.getDeliverWay(chargeContext.getChargeResult().getShippingAmount())); | 126 | + response.setDeliveryWay(shoppingSupport.getDeliverWay(chargeContext.getChargeResult())); |
123 | response.setGood(shoppingSupport.getGoodsInfo(skupGood)); | 127 | response.setGood(shoppingSupport.getGoodsInfo(skupGood)); |
124 | response.setPromotionFormulaList(shoppingSupport.getPromotionFormula(chargeResult)); | 128 | response.setPromotionFormulaList(shoppingSupport.getPromotionFormula(chargeResult)); |
125 | response.setAmount(MathUtils.formatStr(chargeResult.getFinalAmount())); | 129 | response.setAmount(MathUtils.formatStr(chargeResult.getFinalAmount())); |
@@ -149,8 +153,12 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -149,8 +153,12 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
149 | } | 153 | } |
150 | 154 | ||
151 | private ChargeContext buildChargeContext(ShoppingRequest request, SellerOrderGoods skupInfo) { | 155 | private ChargeContext buildChargeContext(ShoppingRequest request, SellerOrderGoods skupInfo) { |
156 | + ChargeParam chargeParam = ChargeParam.builder().uid(request.getUid()) | ||
157 | + .deliveryWay(buildDeliveryWay()) | ||
158 | + .couponCodes(request.getCouponCodes()).build(); | ||
159 | + | ||
152 | return ChargeContext.builder() | 160 | return ChargeContext.builder() |
153 | - .chargeParam(ChargeParam.builder().uid(request.getUid()).couponCodes(request.getCouponCodes()).build()) | 161 | + .chargeParam(chargeParam) |
154 | .chargeGoods(ChargeGoods.builder().goodsPrice(skupInfo.getGoodsPrice()).productId(skupInfo.getProductId()).skup(skupInfo.getId()).build()).build(); | 162 | .chargeGoods(ChargeGoods.builder().goodsPrice(skupInfo.getGoodsPrice()).productId(skupInfo.getProductId()).skup(skupInfo.getId()).build()).build(); |
155 | } | 163 | } |
156 | 164 | ||
@@ -230,22 +238,11 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -230,22 +238,11 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
230 | throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); | 238 | throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); |
231 | } | 239 | } |
232 | 240 | ||
233 | - // 检查地址是否合法 | ||
234 | - int addressId = AddressUtil.getDecryptStr(shoppingRequest.getAddressId()); | ||
235 | - if (addressId < 0){ | ||
236 | - logger.warn("submit addressId invalidate, uid is {}, skup is {}, addressId is {}", shoppingRequest.getUid(), | ||
237 | - shoppingRequest.getSkup(), shoppingRequest.getAddressId()); | ||
238 | - throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE); | ||
239 | - } | 241 | + //查询并校验用户地址 |
242 | + Pair<AddressInfo, AddressInfo> userAddressPair = getAndCheckAddressInfo(shoppingRequest); | ||
240 | 243 | ||
241 | // 检查skup是否可售 | 244 | // 检查skup是否可售 |
242 | SellerOrderGoods skup = checkSkupSellOrNot(shoppingRequest.getSkup()); | 245 | SellerOrderGoods skup = checkSkupSellOrNot(shoppingRequest.getSkup()); |
243 | - AddressInfo addressInfo = userProxyService.getAddressInfoNotHidden(shoppingRequest.getUid(), addressId); | ||
244 | - if(AddressHelper.isNeedUpdate(addressInfo)){ | ||
245 | - logger.warn("submit addressId need update, uid is {}, skup is {}, addressId is {}", shoppingRequest.getUid(), | ||
246 | - shoppingRequest.getSkup(), shoppingRequest.getAddressId()); | ||
247 | - throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE); | ||
248 | - } | ||
249 | 246 | ||
250 | //算费 | 247 | //算费 |
251 | ChargeContext chargeContext = buildChargeContext(shoppingRequest,skup); | 248 | ChargeContext chargeContext = buildChargeContext(shoppingRequest,skup); |
@@ -258,8 +255,6 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -258,8 +255,6 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
258 | 255 | ||
259 | logger.info("generate new orderCode:{}",orderCode); | 256 | logger.info("generate new orderCode:{}",orderCode); |
260 | 257 | ||
261 | - AddressInfo hiddenAddress = userProxyService.getHiddenAddressInfo(shoppingRequest.getUid(), addressId); | ||
262 | - | ||
263 | // 减库存,skup更新成不可售,入库 | 258 | // 减库存,skup更新成不可售,入库 |
264 | //BigDecimal shipFee = new BigDecimal(delivery_way_sf_cost); | 259 | //BigDecimal shipFee = new BigDecimal(delivery_way_sf_cost); |
265 | int uid; | 260 | int uid; |
@@ -269,7 +264,7 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -269,7 +264,7 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
269 | .orderCode(orderCode) | 264 | .orderCode(orderCode) |
270 | .productId(skup.getProductId()) | 265 | .productId(skup.getProductId()) |
271 | .paymentType(OrderConstant.PAYMENT_ONLINE) | 266 | .paymentType(OrderConstant.PAYMENT_ONLINE) |
272 | - .deliverWay(OrderConstant.DELIVERY_WAY_SF) | 267 | + .deliverWay(buildDeliveryWay()) |
273 | .channelNo(shoppingRequest.getChannelNo()) | 268 | .channelNo(shoppingRequest.getChannelNo()) |
274 | .amount(BigDecimal.valueOf(chargeResult.getFinalAmount())) | 269 | .amount(BigDecimal.valueOf(chargeResult.getFinalAmount())) |
275 | .shipFee(BigDecimal.valueOf(chargeResult.getShippingAmount())) | 270 | .shipFee(BigDecimal.valueOf(chargeResult.getShippingAmount())) |
@@ -277,10 +272,10 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -277,10 +272,10 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
277 | .couponAmount(BigDecimal.valueOf(chargeResult.getCouponPayResult().getCouponAmount())) | 272 | .couponAmount(BigDecimal.valueOf(chargeResult.getCouponPayResult().getCouponAmount())) |
278 | .build() | 273 | .build() |
279 | ) | 274 | ) |
280 | - .hiddenAddressInfo(hiddenAddress) | ||
281 | - .addressInfo(addressInfo) | 275 | + .hiddenAddressInfo(userAddressPair.getRight()) |
276 | + .addressInfo(userAddressPair.getLeft()) | ||
282 | .clientType(shoppingRequest.getClientType()) | 277 | .clientType(shoppingRequest.getClientType()) |
283 | - .attributes(OrderAttributes.COMMON_IN_STOCK.getCode()) | 278 | + .attributes(buildOrderArrtribute().getCode()) //1,普通;2,线下店;3,急速发货 |
284 | .build(); | 279 | .build(); |
285 | 280 | ||
286 | BuyerOrderSubmitResult submitResult = ordeCreationService.doSumbitOrder(orderBuilder); | 281 | BuyerOrderSubmitResult submitResult = ordeCreationService.doSumbitOrder(orderBuilder); |
@@ -323,6 +318,43 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -323,6 +318,43 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
323 | } | 318 | } |
324 | 319 | ||
325 | 320 | ||
321 | + /** | ||
322 | + * 查询并校验用户地址(left: 用户地址; right: 脱敏的用户地址) | ||
323 | + * | ||
324 | + * @return | ||
325 | + */ | ||
326 | + protected Pair<AddressInfo, AddressInfo> getAndCheckAddressInfo(ShoppingRequest shoppingRequest) { | ||
327 | + // 检查地址是否合法 | ||
328 | + int addressId = AddressUtil.getDecryptStr(shoppingRequest.getAddressId()); | ||
329 | + if (addressId < 0){ | ||
330 | + logger.warn("submit addressId invalidate, uid is {}, skup is {}, addressId is {}", shoppingRequest.getUid(), | ||
331 | + shoppingRequest.getSkup(), shoppingRequest.getAddressId()); | ||
332 | + throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE); | ||
333 | + } | ||
334 | + | ||
335 | + AddressInfo addressInfo = userProxyService.getAddressInfoNotHidden(shoppingRequest.getUid(), addressId); | ||
336 | + if(AddressHelper.isNeedUpdate(addressInfo)){ | ||
337 | + logger.warn("submit addressId need update, uid is {}, skup is {}, addressId is {}", shoppingRequest.getUid(), | ||
338 | + shoppingRequest.getSkup(), shoppingRequest.getAddressId()); | ||
339 | + throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE); | ||
340 | + } | ||
341 | + | ||
342 | + //脱敏的用户地址 | ||
343 | + AddressInfo hiddenAddress = userProxyService.getHiddenAddressInfo(shoppingRequest.getUid(), addressId); | ||
344 | + | ||
345 | + return Pair.of(addressInfo, hiddenAddress); | ||
346 | + } | ||
326 | 347 | ||
348 | + /** | ||
349 | + * 获取订单attribute属性 | ||
350 | + * @return | ||
351 | + */ | ||
352 | + protected OrderAttributes buildOrderArrtribute() { | ||
353 | + return OrderAttributes.COMMON_IN_STOCK; | ||
354 | + } | ||
355 | + | ||
356 | + protected int buildDeliveryWay() { | ||
357 | + return OrderConstant.DELIVERY_WAY_SF; | ||
358 | + } | ||
327 | 359 | ||
328 | } | 360 | } |
@@ -39,16 +39,25 @@ public class ShoppingSupport { | @@ -39,16 +39,25 @@ public class ShoppingSupport { | ||
39 | * 配送方式 | 39 | * 配送方式 |
40 | * @return | 40 | * @return |
41 | */ | 41 | */ |
42 | - public PaymentResponse.DeliveryWay getDeliverWay(double deliveryWayCost) { | 42 | + public PaymentResponse.DeliveryWay getDeliverWay(final ChargeResult chargeResult) { |
43 | // 快递方式 | 43 | // 快递方式 |
44 | PaymentResponse.DeliveryWay deliveryWay = new PaymentResponse.DeliveryWay(); | 44 | PaymentResponse.DeliveryWay deliveryWay = new PaymentResponse.DeliveryWay(); |
45 | - deliveryWay.setDeliveryWayId(OrderConstant.DELIVERY_WAY_SF); | ||
46 | - deliveryWay.setDeliveryWayCost(OrderConstant.MONEY_SIGN + deliveryWayCost); | ||
47 | - deliveryWay.setDeliveryWayName(OrderConstant.DELIVERY_WAY_SF_NAME); | 45 | + deliveryWay.setDeliveryWayId(chargeResult.getDeliveryWay()); |
46 | + deliveryWay.setDeliveryWayCost(OrderConstant.MONEY_SIGN + chargeResult.getShippingAmount()); | ||
47 | + deliveryWay.setDeliveryWayName(getDeliveryWayStr(chargeResult.getDeliveryWay())); | ||
48 | return deliveryWay; | 48 | return deliveryWay; |
49 | } | 49 | } |
50 | 50 | ||
51 | 51 | ||
52 | + private String getDeliveryWayStr(int deliveryWay) { | ||
53 | + return deliveryWay == OrderConstant.DELIVERY_WAY_STORE ? OrderConstant.DELIVERY_WAY_STORE_NAME : OrderConstant.DELIVERY_WAY_SF_NAME; | ||
54 | + } | ||
55 | + | ||
56 | + public boolean isDeliveryWayByStore(int deliveryWay) { | ||
57 | + return deliveryWay == OrderConstant.DELIVERY_WAY_STORE; | ||
58 | + } | ||
59 | + | ||
60 | + | ||
52 | /** | 61 | /** |
53 | * 商品情报 | 62 | * 商品情报 |
54 | * @param skup | 63 | * @param skup |
1 | +package com.yohoufo.order.utils; | ||
2 | + | ||
3 | +import com.yoho.error.ServiceError; | ||
4 | +import com.yoho.error.exception.ServiceException; | ||
5 | + | ||
6 | +/** | ||
7 | + * @author LUOXC | ||
8 | + * @date 2019/1/9 11:14 | ||
9 | + */ | ||
10 | +public class ServiceExceptions { | ||
11 | + | ||
12 | + public static void throwServiceException(String message) { | ||
13 | + ServiceException serviceException = new ServiceException(ServiceError.ORDER_SERVICE_ERROR); | ||
14 | + serviceException.setParams(message); | ||
15 | + throw serviceException; | ||
16 | + } | ||
17 | + | ||
18 | + public static void throwServiceException(ServiceError serviceError) { | ||
19 | + throw new ServiceException(serviceError); | ||
20 | + } | ||
21 | + | ||
22 | +} |
@@ -38,6 +38,7 @@ import com.yohoufo.product.service.ProductService; | @@ -38,6 +38,7 @@ import com.yohoufo.product.service.ProductService; | ||
38 | public class ProductController { | 38 | public class ProductController { |
39 | 39 | ||
40 | private final Logger LOG = LoggerFactory.getLogger(ProductController.class); | 40 | private final Logger LOG = LoggerFactory.getLogger(ProductController.class); |
41 | + | ||
41 | 42 | ||
42 | @Autowired | 43 | @Autowired |
43 | private ProductService productService; | 44 | private ProductService productService; |
@@ -278,6 +279,24 @@ public class ProductController { | @@ -278,6 +279,24 @@ public class ProductController { | ||
278 | clearProductCache(skup); | 279 | clearProductCache(skup); |
279 | return new ApiResponse(200, "取消卖出成功!", Boolean.TRUE); | 280 | return new ApiResponse(200, "取消卖出成功!", Boolean.TRUE); |
280 | } | 281 | } |
282 | + | ||
283 | + @RequestMapping(params = "method=ufo.product.hideSellerAllSkup") | ||
284 | + public ApiResponse hideSellerAllSkup( | ||
285 | + @RequestParam(value = "uid", required = true) Integer uid) { | ||
286 | + LOG.info("in method=ufo.product.hideSellerAllSkup uid={}", uid); | ||
287 | + productService.changeSkupHideStatus(uid, 1);// status:1 隐藏商品 | ||
288 | + LOG.info("hideSellerAllSkup success uid = {}", uid); | ||
289 | + return new ApiResponse(200, "隐藏用户商品成功!", Boolean.TRUE); | ||
290 | + } | ||
291 | + | ||
292 | + @RequestMapping(params = "method=ufo.product.showSellerAllSkup") | ||
293 | + public ApiResponse showSellerAllSkup( | ||
294 | + @RequestParam(value = "uid", required = true) Integer uid) { | ||
295 | + LOG.info("in method=ufo.product.showSellerAllSkup uid={}", uid); | ||
296 | + productService.changeSkupHideStatus(uid, 0);// status:0 展示商品 | ||
297 | + LOG.info("showSellerAllSkup success uid = {}", uid); | ||
298 | + return new ApiResponse(200, "隐藏用户商品成功!", Boolean.TRUE); | ||
299 | + } | ||
281 | 300 | ||
282 | @Autowired | 301 | @Autowired |
283 | private ControllerCacheAop cacheAop; | 302 | private ControllerCacheAop cacheAop; |
@@ -83,4 +83,6 @@ public interface ProductService { | @@ -83,4 +83,6 @@ public interface ProductService { | ||
83 | * @return | 83 | * @return |
84 | */ | 84 | */ |
85 | SkupDetailForScreenResp getSkuPDetailForShopsScreen(Integer skuP, Integer storeId); | 85 | SkupDetailForScreenResp getSkuPDetailForShopsScreen(Integer skuP, Integer storeId); |
86 | + | ||
87 | + void changeSkupHideStatus(Integer uid, int status); | ||
86 | } | 88 | } |
@@ -734,6 +734,13 @@ public class ProductServiceImpl implements ProductService{ | @@ -734,6 +734,13 @@ public class ProductServiceImpl implements ProductService{ | ||
734 | public int sellerBatchUpdatePrice(List<Integer> skupList, Double price) { | 734 | public int sellerBatchUpdatePrice(List<Integer> skupList, Double price) { |
735 | return storagePriceMapper.updateBatchPrice(skupList, price); | 735 | return storagePriceMapper.updateBatchPrice(skupList, price); |
736 | } | 736 | } |
737 | + | ||
738 | + @Override | ||
739 | + public void changeSkupHideStatus(Integer uid, int status) { | ||
740 | + LOGGER.info("开始:Skup隐藏展示状态修改,uid={} , toStatus={}"); | ||
741 | + int count = storagePriceMapper.updateSkupHideStatus(uid, status); | ||
742 | + LOGGER.info("完成:Skup隐藏展示状态修改,uid={} , toStatus={}, exeCount={}", uid, status, count); | ||
743 | + } | ||
737 | 744 | ||
738 | @Override | 745 | @Override |
739 | public List<SaleCategoryBo> querySaleCategory() { | 746 | public List<SaleCategoryBo> querySaleCategory() { |
@@ -979,4 +986,5 @@ public class ProductServiceImpl implements ProductService{ | @@ -979,4 +986,5 @@ public class ProductServiceImpl implements ProductService{ | ||
979 | result.setSkupDetail(innerResult); | 986 | result.setSkupDetail(innerResult); |
980 | return result; | 987 | return result; |
981 | } | 988 | } |
989 | + | ||
982 | } | 990 | } |
-
Please register or login to post a comment