Showing
9 changed files
with
129 additions
and
37 deletions
@@ -183,7 +183,10 @@ public class BuyerBidDepositPaymentService extends AbstractOrderPaymentService { | @@ -183,7 +183,10 @@ public class BuyerBidDepositPaymentService extends AbstractOrderPaymentService { | ||
183 | 183 | ||
184 | final static List<Integer> canRefundStatusList = Arrays.asList( | 184 | final static List<Integer> canRefundStatusList = Arrays.asList( |
185 | OrderStatus.BIDING.getCode(), | 185 | OrderStatus.BIDING.getCode(), |
186 | - OrderStatus.HAS_PAYED.getCode() | 186 | + OrderStatus.HAS_PAYED.getCode(), |
187 | + OrderStatus.BUYER_CLOSE_BID.getCode(), | ||
188 | + OrderStatus.SYSTEM_CLOSE_BID.getCode(), | ||
189 | + OrderStatus.PLATFORM_CLOSE_BID.getCode() | ||
187 | ); | 190 | ); |
188 | 191 | ||
189 | @Override | 192 | @Override |
@@ -11,6 +11,8 @@ import com.yohoufo.order.utils.LoggerUtils; | @@ -11,6 +11,8 @@ import com.yohoufo.order.utils.LoggerUtils; | ||
11 | import org.slf4j.Logger; | 11 | import org.slf4j.Logger; |
12 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
13 | import org.springframework.stereotype.Component; | 13 | import org.springframework.stereotype.Component; |
14 | +import org.springframework.transaction.annotation.Propagation; | ||
15 | +import org.springframework.transaction.annotation.Transactional; | ||
14 | import org.springframework.util.Assert; | 16 | import org.springframework.util.Assert; |
15 | 17 | ||
16 | /** | 18 | /** |
@@ -26,6 +28,7 @@ public class BidSkupService { | @@ -26,6 +28,7 @@ public class BidSkupService { | ||
26 | private SellerOrderGoodsMapper sellerOrderGoodsMapper; | 28 | private SellerOrderGoodsMapper sellerOrderGoodsMapper; |
27 | 29 | ||
28 | 30 | ||
31 | + @Transactional(propagation = Propagation.REQUIRED) | ||
29 | @Database(ForceMaster = true, DataSource = "ufo_order") | 32 | @Database(ForceMaster = true, DataSource = "ufo_order") |
30 | public int create(int uid, GoodsInfo goodsInfo) { | 33 | public int create(int uid, GoodsInfo goodsInfo) { |
31 | Assert.notNull(goodsInfo, "goodsInfo must not be null"); | 34 | Assert.notNull(goodsInfo, "goodsInfo must not be null"); |
@@ -48,6 +51,7 @@ public class BidSkupService { | @@ -48,6 +51,7 @@ public class BidSkupService { | ||
48 | * | 51 | * |
49 | * @param uid | 52 | * @param uid |
50 | */ | 53 | */ |
54 | + @Transactional(propagation = Propagation.REQUIRED) | ||
51 | @Database(ForceMaster = true, DataSource = "ufo_order") | 55 | @Database(ForceMaster = true, DataSource = "ufo_order") |
52 | public void bind(int uid, int skup, boolean finishPay) { | 56 | public void bind(int uid, int skup, boolean finishPay) { |
53 | SellerOrderGoods condition = new SellerOrderGoods(); | 57 | SellerOrderGoods condition = new SellerOrderGoods(); |
@@ -69,6 +73,7 @@ public class BidSkupService { | @@ -69,6 +73,7 @@ public class BidSkupService { | ||
69 | * @param uid | 73 | * @param uid |
70 | * @param skup | 74 | * @param skup |
71 | */ | 75 | */ |
76 | + @Transactional(propagation = Propagation.REQUIRED) | ||
72 | @Database(ForceMaster = true, DataSource = "ufo_order") | 77 | @Database(ForceMaster = true, DataSource = "ufo_order") |
73 | public void unbind(int uid,int skup) { | 78 | public void unbind(int uid,int skup) { |
74 | SellerOrderGoods condition = new SellerOrderGoods(); | 79 | SellerOrderGoods condition = new SellerOrderGoods(); |
@@ -27,6 +27,8 @@ import com.yohoufo.order.utils.LoggerUtils; | @@ -27,6 +27,8 @@ import com.yohoufo.order.utils.LoggerUtils; | ||
27 | import org.slf4j.Logger; | 27 | import org.slf4j.Logger; |
28 | import org.springframework.beans.factory.annotation.Autowired; | 28 | import org.springframework.beans.factory.annotation.Autowired; |
29 | import org.springframework.stereotype.Service; | 29 | import org.springframework.stereotype.Service; |
30 | +import org.springframework.transaction.annotation.Propagation; | ||
31 | +import org.springframework.transaction.annotation.Transactional; | ||
30 | 32 | ||
31 | import java.math.BigDecimal; | 33 | import java.math.BigDecimal; |
32 | import java.util.ArrayList; | 34 | import java.util.ArrayList; |
@@ -76,6 +78,7 @@ public class BuyerBidOrderSubmitService { | @@ -76,6 +78,7 @@ public class BuyerBidOrderSubmitService { | ||
76 | * | 78 | * |
77 | * @param orderBuilder | 79 | * @param orderBuilder |
78 | */ | 80 | */ |
81 | + @Transactional(propagation = Propagation.REQUIRED) | ||
79 | @Database(ForceMaster = true, DataSource = "ufo_order") | 82 | @Database(ForceMaster = true, DataSource = "ufo_order") |
80 | public BuyerOrderSubmitResult createOrder(OrderBuilder orderBuilder, BidOrderMetaBo bidOrderMetaBo) { | 83 | public BuyerOrderSubmitResult createOrder(OrderBuilder orderBuilder, BidOrderMetaBo bidOrderMetaBo) { |
81 | 84 |
@@ -21,6 +21,8 @@ import com.yohoufo.order.utils.LoggerUtils; | @@ -21,6 +21,8 @@ import com.yohoufo.order.utils.LoggerUtils; | ||
21 | import org.slf4j.Logger; | 21 | import org.slf4j.Logger; |
22 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
23 | import org.springframework.stereotype.Service; | 23 | import org.springframework.stereotype.Service; |
24 | +import org.springframework.transaction.annotation.Propagation; | ||
25 | +import org.springframework.transaction.annotation.Transactional; | ||
24 | 26 | ||
25 | import java.util.ArrayList; | 27 | import java.util.ArrayList; |
26 | import java.util.List; | 28 | import java.util.List; |
@@ -95,6 +97,7 @@ public class SellerBidOrderBindService { | @@ -95,6 +97,7 @@ public class SellerBidOrderBindService { | ||
95 | * @param submitSellerOrder | 97 | * @param submitSellerOrder |
96 | * @return | 98 | * @return |
97 | */ | 99 | */ |
100 | + @Transactional(propagation = Propagation.REQUIRED) | ||
98 | @Database(ForceMaster = true, DataSource = "ufo_order") | 101 | @Database(ForceMaster = true, DataSource = "ufo_order") |
99 | public void bindAndCreateOrder(SubmitSellerOrder submitSellerOrder) { | 102 | public void bindAndCreateOrder(SubmitSellerOrder submitSellerOrder) { |
100 | /** | 103 | /** |
@@ -109,6 +112,7 @@ public class SellerBidOrderBindService { | @@ -109,6 +112,7 @@ public class SellerBidOrderBindService { | ||
109 | } | 112 | } |
110 | 113 | ||
111 | 114 | ||
115 | + @Transactional(propagation = Propagation.REQUIRED) | ||
112 | @Database(ForceMaster = true, DataSource = "ufo_order") | 116 | @Database(ForceMaster = true, DataSource = "ufo_order") |
113 | public void unbind(int uid, long orderCode, int skup, SellerOrderStatus targetStatus) { | 117 | public void unbind(int uid, long orderCode, int skup, SellerOrderStatus targetStatus) { |
114 | bidSkupService.unbind(uid, skup); | 118 | bidSkupService.unbind(uid, skup); |
@@ -207,10 +211,10 @@ public class SellerBidOrderBindService { | @@ -207,10 +211,10 @@ public class SellerBidOrderBindService { | ||
207 | buyerOrder.setBidType(OrderConstant.BUYER_BID_TYPE); | 211 | buyerOrder.setBidType(OrderConstant.BUYER_BID_TYPE); |
208 | boolean success = buyerOrderMapper.updateByOrderCode(buyerOrder) > 0; | 212 | boolean success = buyerOrderMapper.updateByOrderCode(buyerOrder) > 0; |
209 | if (!success) { | 213 | if (!success) { |
210 | - logger.warn("[{}] buyer order is bind with sellerUid:{} fail ", buyerOrderGoods.getOrderCode()); | 214 | + logger.warn("[{}] buyer order is bind with sellerUid:{} fail ", buyerOrderGoods.getOrderCode(), sellerUid); |
211 | throw new UfoServiceException(500, "操作失败"); | 215 | throw new UfoServiceException(500, "操作失败"); |
212 | } | 216 | } |
213 | - logger.info("[{}] buyer order is bind with sellerUid:{} success ", buyerOrderGoods.getOrderCode()); | 217 | + logger.info("[{}] buyer order is bind with sellerUid:{} success ", buyerOrderGoods.getOrderCode(), sellerUid); |
214 | } | 218 | } |
215 | } | 219 | } |
216 | } | 220 | } |
@@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo; | @@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo; | ||
5 | import com.yohobuy.ufo.model.order.common.OrderStatus; | 5 | import com.yohobuy.ufo.model.order.common.OrderStatus; |
6 | import com.yohobuy.ufo.model.order.constants.OrderConstant; | 6 | import com.yohobuy.ufo.model.order.constants.OrderConstant; |
7 | import com.yohoufo.dal.order.model.*; | 7 | import com.yohoufo.dal.order.model.*; |
8 | +import com.yohoufo.order.model.PayRefundBo; | ||
8 | import com.yohoufo.order.model.RequestedStatusChangeBuyerOrder; | 9 | import com.yohoufo.order.model.RequestedStatusChangeBuyerOrder; |
9 | import com.yohoufo.order.model.request.PaymentRequest; | 10 | import com.yohoufo.order.model.request.PaymentRequest; |
10 | import com.yohoufo.order.service.AbstractBuyerOrderStateChanger; | 11 | import com.yohoufo.order.service.AbstractBuyerOrderStateChanger; |
@@ -68,8 +69,8 @@ public class BuyerOrderBidingCancelChanger extends AbstractBuyerOrderStateChange | @@ -68,8 +69,8 @@ public class BuyerOrderBidingCancelChanger extends AbstractBuyerOrderStateChange | ||
68 | .build(); | 69 | .build(); |
69 | 70 | ||
70 | logger.info("[{}] refund deposit,paymentRequest:{}", orderCode, paymentRequest); | 71 | logger.info("[{}] refund deposit,paymentRequest:{}", orderCode, paymentRequest); |
71 | - paymentService.refund(paymentRequest); | ||
72 | - logger.info("[{}] refund deposit success", buyerOrder.getOrderCode()); | 72 | + PayRefundBo payRefundBo = paymentService.refund(paymentRequest); |
73 | + logger.info("[{}] refund deposit end,result:{}", buyerOrder.getOrderCode(), payRefundBo); | ||
73 | } | 74 | } |
74 | 75 | ||
75 | @Override | 76 | @Override |
@@ -17,6 +17,7 @@ import com.yohoufo.dal.order.SellerOrderGoodsMapper; | @@ -17,6 +17,7 @@ import com.yohoufo.dal.order.SellerOrderGoodsMapper; | ||
17 | import com.yohoufo.dal.order.model.*; | 17 | import com.yohoufo.dal.order.model.*; |
18 | import com.yohoufo.order.constants.ActivityTypeEnum; | 18 | import com.yohoufo.order.constants.ActivityTypeEnum; |
19 | import com.yohoufo.order.constants.MetaKey; | 19 | import com.yohoufo.order.constants.MetaKey; |
20 | +import com.yohoufo.order.model.PayRefundBo; | ||
20 | import com.yohoufo.order.model.bo.ActivityBo; | 21 | import com.yohoufo.order.model.bo.ActivityBo; |
21 | import com.yohoufo.order.model.bo.BidOrderMetaBo; | 22 | import com.yohoufo.order.model.bo.BidOrderMetaBo; |
22 | import com.yohoufo.order.model.request.PaymentRequest; | 23 | import com.yohoufo.order.model.request.PaymentRequest; |
@@ -328,8 +329,8 @@ public class BuyerOrderChangeBusinessPostProcessor { | @@ -328,8 +329,8 @@ public class BuyerOrderChangeBusinessPostProcessor { | ||
328 | .build(); | 329 | .build(); |
329 | 330 | ||
330 | logger.info("[{}] refund deposit,paymentRequest:{}", orderCode, paymentRequest); | 331 | logger.info("[{}] refund deposit,paymentRequest:{}", orderCode, paymentRequest); |
331 | - paymentService.refund(paymentRequest); | ||
332 | - logger.info("[{}] refund deposit success", buyerOrder.getOrderCode()); | 332 | + PayRefundBo payRefundBo = paymentService.refund(paymentRequest); |
333 | + logger.info("[{}] refund deposit end,result:{}", buyerOrder.getOrderCode(), payRefundBo); | ||
333 | } | 334 | } |
334 | 335 | ||
335 | 336 |
1 | package com.yohoufo.order.service.proxy; | 1 | package com.yohoufo.order.service.proxy; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
3 | import com.yohobuy.ufo.model.BidStoragePriceVo; | 4 | import com.yohobuy.ufo.model.BidStoragePriceVo; |
4 | import com.yohobuy.ufo.model.order.common.OrderAttributes; | 5 | import com.yohobuy.ufo.model.order.common.OrderAttributes; |
6 | +import com.yohoufo.common.ApiResponse; | ||
7 | +import com.yohoufo.common.exception.UfoServiceException; | ||
5 | import com.yohoufo.dal.order.model.SellerOrderGoods; | 8 | import com.yohoufo.dal.order.model.SellerOrderGoods; |
6 | import com.yohoufo.order.common.Operator; | 9 | import com.yohoufo.order.common.Operator; |
7 | import org.slf4j.Logger; | 10 | import org.slf4j.Logger; |
8 | import org.slf4j.LoggerFactory; | 11 | import org.slf4j.LoggerFactory; |
9 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
10 | 13 | ||
14 | +import java.util.Objects; | ||
15 | + | ||
11 | @Service | 16 | @Service |
12 | public class BidProductProxyService extends AbsProxyService { | 17 | public class BidProductProxyService extends AbsProxyService { |
13 | 18 | ||
@@ -59,8 +64,7 @@ public class BidProductProxyService extends AbsProxyService { | @@ -59,8 +64,7 @@ public class BidProductProxyService extends AbsProxyService { | ||
59 | default: | 64 | default: |
60 | api = null; | 65 | api = null; |
61 | } | 66 | } |
62 | - ufoServiceCaller.call(api, skup); | ||
63 | - return true; | 67 | + return getResultFromApiResponse(ufoServiceCaller.call(api, skup), Boolean.class); |
64 | } | 68 | } |
65 | 69 | ||
66 | public boolean cancelSaleByUser(int skup) { | 70 | public boolean cancelSaleByUser(int skup) { |
@@ -69,16 +73,14 @@ public class BidProductProxyService extends AbsProxyService { | @@ -69,16 +73,14 @@ public class BidProductProxyService extends AbsProxyService { | ||
69 | } | 73 | } |
70 | 74 | ||
71 | 75 | ||
72 | - | ||
73 | public boolean trySale(int productId, int skup) { | 76 | public boolean trySale(int productId, int skup) { |
74 | logger.info("trySale,productId:{},skup:{}", productId, skup); | 77 | logger.info("trySale,productId:{},skup:{}", productId, skup); |
75 | - ufoServiceCaller.call(SALE_API, productId, skup); | ||
76 | - return true; | 78 | + return getResultFromApiResponse(ufoServiceCaller.call(SALE_API, productId, skup), Boolean.class); |
77 | } | 79 | } |
78 | 80 | ||
79 | public boolean isCanceled(int skup) { | 81 | public boolean isCanceled(int skup) { |
80 | logger.info("isCanceled,skup:{}", skup); | 82 | logger.info("isCanceled,skup:{}", skup); |
81 | - return ufoServiceCaller.call(IS_CANCELED_API, skup); | 83 | + return getResultFromApiResponse(ufoServiceCaller.call(IS_CANCELED_API, skup), Boolean.class); |
82 | } | 84 | } |
83 | 85 | ||
84 | /** | 86 | /** |
@@ -88,14 +90,13 @@ public class BidProductProxyService extends AbsProxyService { | @@ -88,14 +90,13 @@ public class BidProductProxyService extends AbsProxyService { | ||
88 | */ | 90 | */ |
89 | public BidStoragePriceVo getSaleable(int skup) { | 91 | public BidStoragePriceVo getSaleable(int skup) { |
90 | logger.info("getSaleable,skup:{}", skup); | 92 | logger.info("getSaleable,skup:{}", skup); |
91 | - return ufoServiceCaller.call(GET_SALEABLE_API, skup); | 93 | + return getResultFromApiResponse(ufoServiceCaller.call(GET_SALEABLE_API, skup), BidStoragePriceVo.class); |
92 | } | 94 | } |
93 | 95 | ||
94 | public boolean resetSaleableFromUserCancel(int skup) { | 96 | public boolean resetSaleableFromUserCancel(int skup) { |
95 | logger.info("resetSaleableFromUserCancel,skup:{}", skup); | 97 | logger.info("resetSaleableFromUserCancel,skup:{}", skup); |
96 | try { | 98 | try { |
97 | - ufoServiceCaller.call(RESET_SALEABLE_FROM_USERCANCEL_API, skup); | ||
98 | - return true; | 99 | + return getResultFromApiResponse(ufoServiceCaller.call(RESET_SALEABLE_FROM_USERCANCEL_API, skup), Boolean.class); |
99 | } catch (Exception ex) { | 100 | } catch (Exception ex) { |
100 | logger.warn("exception happened when reset saleable,skup:{}", skup); | 101 | logger.warn("exception happened when reset saleable,skup:{}", skup); |
101 | return false; | 102 | return false; |
@@ -105,11 +106,28 @@ public class BidProductProxyService extends AbsProxyService { | @@ -105,11 +106,28 @@ public class BidProductProxyService extends AbsProxyService { | ||
105 | public boolean resetSaleableFromBidFinished(int skup) { | 106 | public boolean resetSaleableFromBidFinished(int skup) { |
106 | logger.info("resetSaleableFromBidFinished,skup:{}", skup); | 107 | logger.info("resetSaleableFromBidFinished,skup:{}", skup); |
107 | try { | 108 | try { |
108 | - ufoServiceCaller.call(RESET_SALEABLE_FROM_BIDFINISHED_API, skup); | ||
109 | - return true; | 109 | + return getResultFromApiResponse(ufoServiceCaller.call(RESET_SALEABLE_FROM_BIDFINISHED_API, skup), Boolean.class); |
110 | } catch (Exception ex) { | 110 | } catch (Exception ex) { |
111 | logger.warn("exception happened when reset saleable,skup:{}", skup); | 111 | logger.warn("exception happened when reset saleable,skup:{}", skup); |
112 | return false; | 112 | return false; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | + | ||
116 | + public <T> T getResultFromApiResponse(ApiResponse resp, Class<T> clazz) { | ||
117 | + if (resp == null) { | ||
118 | + throw new UfoServiceException(500, "服务器访问异常"); | ||
119 | + } | ||
120 | + if (resp.getCode() != 200) { | ||
121 | + throw new UfoServiceException(resp.getCode(), resp.getMessage()); | ||
122 | + } | ||
123 | + | ||
124 | + if (Objects.isNull(resp.getData())) { | ||
125 | + return null; | ||
126 | + } | ||
127 | + if (resp.getData() instanceof JSONObject) { | ||
128 | + return ((JSONObject) resp.getData()).toJavaObject(clazz); | ||
129 | + } else { | ||
130 | + return JSONObject.parseObject(JSONObject.toJSONString(resp.getData()), clazz); | ||
131 | + } | ||
132 | + } | ||
115 | } | 133 | } |
1 | package com.yohoufo.product.controller; | 1 | package com.yohoufo.product.controller; |
2 | 2 | ||
3 | +import com.yoho.error.exception.ServiceException; | ||
3 | import com.yohobuy.ufo.model.BidStoragePriceVo; | 4 | import com.yohobuy.ufo.model.BidStoragePriceVo; |
4 | import com.yohoufo.common.ApiResponse; | 5 | import com.yohoufo.common.ApiResponse; |
5 | import com.yohoufo.product.service.impl.BidProductService; | 6 | import com.yohoufo.product.service.impl.BidProductService; |
@@ -21,10 +22,9 @@ public class BidProductController { | @@ -21,10 +22,9 @@ public class BidProductController { | ||
21 | 22 | ||
22 | // 创建skup | 23 | // 创建skup |
23 | @RequestMapping(params = "method=ufo.product.bid.createSkup") | 24 | @RequestMapping(params = "method=ufo.product.bid.createSkup") |
24 | - public boolean createSkup(@RequestBody BidStoragePriceVo skupVo) { | 25 | + public void createSkup(@RequestBody BidStoragePriceVo skupVo) { |
25 | logger.info("in method=ufo.product.bid.createSkup, skupVo = {}", skupVo); | 26 | logger.info("in method=ufo.product.bid.createSkup, skupVo = {}", skupVo); |
26 | bidProductService.createSkup(skupVo); | 27 | bidProductService.createSkup(skupVo); |
27 | - return true; | ||
28 | } | 28 | } |
29 | 29 | ||
30 | 30 | ||
@@ -35,9 +35,16 @@ public class BidProductController { | @@ -35,9 +35,16 @@ public class BidProductController { | ||
35 | * @return | 35 | * @return |
36 | */ | 36 | */ |
37 | @RequestMapping(params = "method=ufo.product.bid.isCanceled") | 37 | @RequestMapping(params = "method=ufo.product.bid.isCanceled") |
38 | - public boolean isCanceled(@RequestParam(value = "skup") int skup) { | 38 | + public ApiResponse isCanceled(@RequestParam(value = "skup") int skup) { |
39 | logger.info("in method=ufo.product.bid.isCanceled, skup = {}", skup); | 39 | logger.info("in method=ufo.product.bid.isCanceled, skup = {}", skup); |
40 | - return bidProductService.isCanceled(skup); | 40 | + try { |
41 | + boolean result = bidProductService.isCanceled(skup); | ||
42 | + return new ApiResponse(200, "ok", result); | ||
43 | + } catch (ServiceException sex) { | ||
44 | + return new ApiResponse(sex.getCode(), sex.getErrorMessage(), false); | ||
45 | + } catch (Exception ex) { | ||
46 | + return new ApiResponse(500, "操作失败", false); | ||
47 | + } | ||
41 | } | 48 | } |
42 | 49 | ||
43 | /** | 50 | /** |
@@ -47,9 +54,15 @@ public class BidProductController { | @@ -47,9 +54,15 @@ public class BidProductController { | ||
47 | @RequestMapping(params = "method=ufo.product.bid.cancelSaleByUser") | 54 | @RequestMapping(params = "method=ufo.product.bid.cancelSaleByUser") |
48 | public ApiResponse cancelSaleByUser(@RequestParam(value = "skup") int skup) { | 55 | public ApiResponse cancelSaleByUser(@RequestParam(value = "skup") int skup) { |
49 | logger.info("in method=ufo.product.bid.cancelSaleByUser, skup = {}", skup); | 56 | logger.info("in method=ufo.product.bid.cancelSaleByUser, skup = {}", skup); |
57 | + try { | ||
50 | bidProductService.cancelSaleByUser(skup); | 58 | bidProductService.cancelSaleByUser(skup); |
51 | logger.info("cancelSaleByUser success, skup = {}", skup); | 59 | logger.info("cancelSaleByUser success, skup = {}", skup); |
52 | - return new ApiResponse(200, "ok", Boolean.TRUE); | 60 | + return new ApiResponse(200, "ok", true); |
61 | + } catch (ServiceException sex) { | ||
62 | + return new ApiResponse(sex.getCode(), sex.getErrorMessage(), false); | ||
63 | + } catch (Exception ex) { | ||
64 | + return new ApiResponse(500, "操作失败", false); | ||
65 | + } | ||
53 | } | 66 | } |
54 | 67 | ||
55 | /** | 68 | /** |
@@ -59,9 +72,15 @@ public class BidProductController { | @@ -59,9 +72,15 @@ public class BidProductController { | ||
59 | @RequestMapping(params = "method=ufo.product.bid.cancelSaleBySystem") | 72 | @RequestMapping(params = "method=ufo.product.bid.cancelSaleBySystem") |
60 | public ApiResponse cancelSaleBySystem(@RequestParam(value = "skup") int skup) { | 73 | public ApiResponse cancelSaleBySystem(@RequestParam(value = "skup") int skup) { |
61 | logger.info("in method=ufo.product.bid.cancelSaleBySystem, skup = {}", skup); | 74 | logger.info("in method=ufo.product.bid.cancelSaleBySystem, skup = {}", skup); |
75 | + try { | ||
62 | bidProductService.cancelSaleBySystem(skup); | 76 | bidProductService.cancelSaleBySystem(skup); |
63 | logger.info("cancelSaleBySystem success, skup = {}", skup); | 77 | logger.info("cancelSaleBySystem success, skup = {}", skup); |
64 | - return new ApiResponse(200, "ok", Boolean.TRUE); | 78 | + return new ApiResponse(200, "ok", true); |
79 | + } catch (ServiceException sex) { | ||
80 | + return new ApiResponse(sex.getCode(), sex.getErrorMessage(), false); | ||
81 | + } catch (Exception ex) { | ||
82 | + return new ApiResponse(500, "操作失败", false); | ||
83 | + } | ||
65 | } | 84 | } |
66 | 85 | ||
67 | /** | 86 | /** |
@@ -71,9 +90,15 @@ public class BidProductController { | @@ -71,9 +90,15 @@ public class BidProductController { | ||
71 | @RequestMapping(params = "method=ufo.product.bid.cancelSaleByCS") | 90 | @RequestMapping(params = "method=ufo.product.bid.cancelSaleByCS") |
72 | public ApiResponse cancelSaleByCS(@RequestParam(value = "skup") int skup) { | 91 | public ApiResponse cancelSaleByCS(@RequestParam(value = "skup") int skup) { |
73 | logger.info("in method=ufo.product.bid.cancelSaleByCS, skup = {}", skup); | 92 | logger.info("in method=ufo.product.bid.cancelSaleByCS, skup = {}", skup); |
93 | + try { | ||
74 | bidProductService.cancelSaleByPlatform(skup); | 94 | bidProductService.cancelSaleByPlatform(skup); |
75 | logger.info("cancelSaleByCS success, skup = {}", skup); | 95 | logger.info("cancelSaleByCS success, skup = {}", skup); |
76 | - return new ApiResponse(200, "ok", Boolean.TRUE); | 96 | + return new ApiResponse(200, "ok", true); |
97 | + } catch (ServiceException sex) { | ||
98 | + return new ApiResponse(sex.getCode(), sex.getErrorMessage(), false); | ||
99 | + } catch (Exception ex) { | ||
100 | + return new ApiResponse(500, "操作失败", false); | ||
101 | + } | ||
77 | } | 102 | } |
78 | 103 | ||
79 | /** | 104 | /** |
@@ -83,9 +108,15 @@ public class BidProductController { | @@ -83,9 +108,15 @@ public class BidProductController { | ||
83 | @RequestMapping(params = "method=ufo.product.bid.resetSaleableFromUserCancel") | 108 | @RequestMapping(params = "method=ufo.product.bid.resetSaleableFromUserCancel") |
84 | public ApiResponse resetSaleableFromUserCancel(@RequestParam(value = "skup") int skup) { | 109 | public ApiResponse resetSaleableFromUserCancel(@RequestParam(value = "skup") int skup) { |
85 | logger.info("in method=ufo.product.bid.resetSaleableFromUserCancel, skup = {}", skup); | 110 | logger.info("in method=ufo.product.bid.resetSaleableFromUserCancel, skup = {}", skup); |
111 | + try { | ||
86 | bidProductService.resetSaleableFromUserCancel(skup); | 112 | bidProductService.resetSaleableFromUserCancel(skup); |
87 | logger.info("resetSaleable success, skup = {}", skup); | 113 | logger.info("resetSaleable success, skup = {}", skup); |
88 | - return new ApiResponse(200, "ok", Boolean.TRUE); | 114 | + return new ApiResponse(200, "ok", true); |
115 | + } catch (ServiceException sex) { | ||
116 | + return new ApiResponse(sex.getCode(), sex.getErrorMessage(), false); | ||
117 | + } catch (Exception ex) { | ||
118 | + return new ApiResponse(500, "操作失败", false); | ||
119 | + } | ||
89 | } | 120 | } |
90 | 121 | ||
91 | /** | 122 | /** |
@@ -95,9 +126,15 @@ public class BidProductController { | @@ -95,9 +126,15 @@ public class BidProductController { | ||
95 | @RequestMapping(params = "method=ufo.product.bid.resetSaleableFromBidFinished") | 126 | @RequestMapping(params = "method=ufo.product.bid.resetSaleableFromBidFinished") |
96 | public ApiResponse resetSaleableFromBidFinished(@RequestParam(value = "skup") int skup) { | 127 | public ApiResponse resetSaleableFromBidFinished(@RequestParam(value = "skup") int skup) { |
97 | logger.info("in method=ufo.product.bid.resetSaleableFromBidFinished, skup = {}", skup); | 128 | logger.info("in method=ufo.product.bid.resetSaleableFromBidFinished, skup = {}", skup); |
129 | + try { | ||
98 | bidProductService.resetSaleableFromBidFinished(skup); | 130 | bidProductService.resetSaleableFromBidFinished(skup); |
99 | logger.info("resetSaleable success, skup = {}", skup); | 131 | logger.info("resetSaleable success, skup = {}", skup); |
100 | - return new ApiResponse(200, "ok", Boolean.TRUE); | 132 | + return new ApiResponse(200, "ok", true); |
133 | + } catch (ServiceException sex) { | ||
134 | + return new ApiResponse(sex.getCode(), sex.getErrorMessage(), false); | ||
135 | + } catch (Exception ex) { | ||
136 | + return new ApiResponse(500, "操作失败", false); | ||
137 | + } | ||
101 | } | 138 | } |
102 | 139 | ||
103 | /** | 140 | /** |
@@ -110,9 +147,15 @@ public class BidProductController { | @@ -110,9 +147,15 @@ public class BidProductController { | ||
110 | public ApiResponse sale(@RequestParam(value = "productId") int productId, | 147 | public ApiResponse sale(@RequestParam(value = "productId") int productId, |
111 | @RequestParam(value = "skup") int skup) { | 148 | @RequestParam(value = "skup") int skup) { |
112 | logger.info("in method=ufo.product.bid.sale,productId = {}, skup = {}", productId, skup); | 149 | logger.info("in method=ufo.product.bid.sale,productId = {}, skup = {}", productId, skup); |
150 | + try { | ||
113 | bidProductService.sale(productId, skup); | 151 | bidProductService.sale(productId, skup); |
114 | logger.info("sale success, skup = {}", skup); | 152 | logger.info("sale success, skup = {}", skup); |
115 | - return new ApiResponse(200, "ok", Boolean.TRUE); | 153 | + return new ApiResponse(200, "ok", true); |
154 | + } catch (ServiceException sex) { | ||
155 | + return new ApiResponse(sex.getCode(), sex.getErrorMessage(), false); | ||
156 | + } catch (Exception ex) { | ||
157 | + return new ApiResponse(500, "操作失败", false); | ||
158 | + } | ||
116 | } | 159 | } |
117 | 160 | ||
118 | /** | 161 | /** |
@@ -122,8 +165,15 @@ public class BidProductController { | @@ -122,8 +165,15 @@ public class BidProductController { | ||
122 | * @return | 165 | * @return |
123 | */ | 166 | */ |
124 | @RequestMapping(params = "method=ufo.product.bid.getSaleable") | 167 | @RequestMapping(params = "method=ufo.product.bid.getSaleable") |
125 | - public BidStoragePriceVo getSaleable(@RequestParam(value = "skup") int skup) { | 168 | + public ApiResponse getSaleable(@RequestParam(value = "skup") int skup) { |
126 | logger.info("in method=ufo.product.bid.getSaleable, skup = {}", skup); | 169 | logger.info("in method=ufo.product.bid.getSaleable, skup = {}", skup); |
127 | - return bidProductService.getSaleable(skup); | 170 | + try { |
171 | + BidStoragePriceVo bidStoragePriceVo = bidProductService.getSaleable(skup); | ||
172 | + return new ApiResponse(200, "ok", bidStoragePriceVo); | ||
173 | + } catch (ServiceException sex) { | ||
174 | + return new ApiResponse(sex.getCode(), sex.getErrorMessage(), null); | ||
175 | + } catch (Exception ex) { | ||
176 | + return new ApiResponse(500, "操作失败", null); | ||
177 | + } | ||
128 | } | 178 | } |
129 | } | 179 | } |
@@ -60,7 +60,8 @@ public class BidProductService { | @@ -60,7 +60,8 @@ public class BidProductService { | ||
60 | //检测一下skup是否存在 | 60 | //检测一下skup是否存在 |
61 | checkAndGetSkup(skup); | 61 | checkAndGetSkup(skup); |
62 | if (!doCancelSale(skup, BidSkupStatus.USER_CANCEL)) { | 62 | if (!doCancelSale(skup, BidSkupStatus.USER_CANCEL)) { |
63 | - throw new ServiceException(500, "商品(skup)取消失败:" + skup); | 63 | + logger.warn("cancelSaleByUser fail, skup:{}", skup); |
64 | + throw new ServiceException(500, "商品取消失败"); | ||
64 | } | 65 | } |
65 | } | 66 | } |
66 | 67 | ||
@@ -75,7 +76,8 @@ public class BidProductService { | @@ -75,7 +76,8 @@ public class BidProductService { | ||
75 | //检测一下skup是否存在 | 76 | //检测一下skup是否存在 |
76 | checkAndGetSkup(skup); | 77 | checkAndGetSkup(skup); |
77 | if (!doCancelSale(skup, BidSkupStatus.SYS_CANCEL)) { | 78 | if (!doCancelSale(skup, BidSkupStatus.SYS_CANCEL)) { |
78 | - throw new ServiceException(500, "商品(skup)取消失败:" + skup); | 79 | + logger.warn("cancelSaleBySystem fail, skup:{}", skup); |
80 | + throw new ServiceException(500, "商品取消失败:" + skup); | ||
79 | } | 81 | } |
80 | } | 82 | } |
81 | 83 | ||
@@ -90,7 +92,8 @@ public class BidProductService { | @@ -90,7 +92,8 @@ public class BidProductService { | ||
90 | //检测一下skup是否存在 | 92 | //检测一下skup是否存在 |
91 | checkAndGetSkup(skup); | 93 | checkAndGetSkup(skup); |
92 | if (!doCancelSale(skup, BidSkupStatus.PLATFORM_CANCEL)) { | 94 | if (!doCancelSale(skup, BidSkupStatus.PLATFORM_CANCEL)) { |
93 | - throw new ServiceException(500, "商品(skup)取消失败:" + skup); | 95 | + logger.warn("cancelSaleByPlatform fail, skup:{}", skup); |
96 | + throw new ServiceException(500, "商品取消失败"); | ||
94 | } | 97 | } |
95 | } | 98 | } |
96 | 99 | ||
@@ -103,7 +106,8 @@ public class BidProductService { | @@ -103,7 +106,8 @@ public class BidProductService { | ||
103 | public void resetSaleableFromUserCancel(int skup) { | 106 | public void resetSaleableFromUserCancel(int skup) { |
104 | logger.info("resetSaleableFromUserCancel, skup:{}", skup); | 107 | logger.info("resetSaleableFromUserCancel, skup:{}", skup); |
105 | if (!doResetSaleable(skup, BidSkupStatus.USER_CANCEL)) { | 108 | if (!doResetSaleable(skup, BidSkupStatus.USER_CANCEL)) { |
106 | - throw new ServiceException(500, "商品(skup)恢复到可售状态失败:" + skup); | 109 | + logger.warn("resetSaleableFromUserCancel fail, skup:{}", skup); |
110 | + throw new ServiceException(500, "商品恢复到可售状态失败"); | ||
107 | } | 111 | } |
108 | } | 112 | } |
109 | 113 | ||
@@ -116,7 +120,8 @@ public class BidProductService { | @@ -116,7 +120,8 @@ public class BidProductService { | ||
116 | public void resetSaleableFromBidFinished(int skup) { | 120 | public void resetSaleableFromBidFinished(int skup) { |
117 | logger.info("resetSaleableFromBidFinished, skup:{}", skup); | 121 | logger.info("resetSaleableFromBidFinished, skup:{}", skup); |
118 | if (!doResetSaleable(skup, BidSkupStatus.BID_FINISHED)) { | 122 | if (!doResetSaleable(skup, BidSkupStatus.BID_FINISHED)) { |
119 | - throw new ServiceException(500, "商品(skup)恢复到可售状态失败:" + skup); | 123 | + logger.warn("resetSaleableFromBidFinished fail, skup:{}", skup); |
124 | + throw new ServiceException(500, "商品恢复到可售状态失败"); | ||
120 | } | 125 | } |
121 | } | 126 | } |
122 | 127 | ||
@@ -133,7 +138,8 @@ public class BidProductService { | @@ -133,7 +138,8 @@ public class BidProductService { | ||
133 | checkProductStatus(productId); | 138 | checkProductStatus(productId); |
134 | //必须是上架状态 | 139 | //必须是上架状态 |
135 | if (!doSale(skup)) { | 140 | if (!doSale(skup)) { |
136 | - throw new ServiceException(500, "商品(skup)已卖出:" + skup); | 141 | + logger.warn("sale fail, skup:{}", skup); |
142 | + throw new ServiceException(500, "商品已卖出"); | ||
137 | } | 143 | } |
138 | } | 144 | } |
139 | 145 | ||
@@ -264,7 +270,8 @@ public class BidProductService { | @@ -264,7 +270,8 @@ public class BidProductService { | ||
264 | 270 | ||
265 | BidStoragePrice sp = bidStoragePriceMapper.selectBySkup(skup); | 271 | BidStoragePrice sp = bidStoragePriceMapper.selectBySkup(skup); |
266 | if (sp == null) { | 272 | if (sp == null) { |
267 | - throw new ServiceException(400, "商品(skup)不存在:" + skup); | 273 | + logger.warn("not find sp,skup = {}", skup); |
274 | + throw new ServiceException(400, "商品不存在"); | ||
268 | } | 275 | } |
269 | return sp; | 276 | return sp; |
270 | } | 277 | } |
-
Please register or login to post a comment