Showing
5 changed files
with
93 additions
and
5 deletions
@@ -108,7 +108,7 @@ public class BuyerBidPriceService { | @@ -108,7 +108,7 @@ public class BuyerBidPriceService { | ||
108 | logger.info("[{}] will change price,orderCode:{},oldSkup:{}", uid, context.buyerOrder.getOrderCode(), oldSkup); | 108 | logger.info("[{}] will change price,orderCode:{},oldSkup:{}", uid, context.buyerOrder.getOrderCode(), oldSkup); |
109 | 109 | ||
110 | //调价前将原skup取消,若生成新skup失败,则需要手动恢复原skup | 110 | //调价前将原skup取消,若生成新skup失败,则需要手动恢复原skup |
111 | - bidProductProxyService.cancelSaleByUser(oldSkup); | 111 | + bidProductProxyService.cancelSaleBeforeChangePrice(oldSkup); |
112 | logger.info("[{}] was canceled success", oldSkup); | 112 | logger.info("[{}] was canceled success", oldSkup); |
113 | 113 | ||
114 | //构建参数 | 114 | //构建参数 |
@@ -74,9 +74,14 @@ public class BidProductProxyService extends AbsProxyService { | @@ -74,9 +74,14 @@ public class BidProductProxyService extends AbsProxyService { | ||
74 | return getResultFromApiResponse(ufoServiceCaller.call(api, skup), Boolean.class); | 74 | return getResultFromApiResponse(ufoServiceCaller.call(api, skup), Boolean.class); |
75 | } | 75 | } |
76 | 76 | ||
77 | - public boolean cancelSaleByUser(int skup) { | ||
78 | - logger.info("cancelSaleByUser,skup:{}", skup); | ||
79 | - return cancelSale(skup, Operator.USER); | 77 | + public boolean cancelSaleBeforeChangePrice(int skup) { |
78 | + logger.info("cancelSaleBeforeChangePrice,skup:{}", skup); | ||
79 | + try { | ||
80 | + return cancelSale(skup, Operator.USER); | ||
81 | + } catch (UfoServiceException use) { | ||
82 | + //方便 | ||
83 | + throw new UfoServiceException(use.getCode(), "您的求购商品正在被卖家匹配中,无法调价"); | ||
84 | + } | ||
80 | } | 85 | } |
81 | 86 | ||
82 | 87 |
@@ -85,7 +85,7 @@ public class BidProductService { | @@ -85,7 +85,7 @@ public class BidProductService { | ||
85 | BidStoragePrice bidStoragePrice = checkAndGetSkup(skup); | 85 | BidStoragePrice bidStoragePrice = checkAndGetSkup(skup); |
86 | if (bidStoragePrice.getStatus() == BidSkupStatus.BID_SUCCESS.getCode()) { | 86 | if (bidStoragePrice.getStatus() == BidSkupStatus.BID_SUCCESS.getCode()) { |
87 | logger.warn("[{}] status is bid_success,can't be canceled", skup); | 87 | logger.warn("[{}] status is bid_success,can't be canceled", skup); |
88 | - throw new ServiceException(500, "商品取消失败(已变现)"); | 88 | + throw new ServiceException(500, "您的求购商品正在被卖家匹配中,无法取消求购"); |
89 | } | 89 | } |
90 | if (!doCancelSale(skup, BidSkupStatus.USER_CANCEL)) { | 90 | if (!doCancelSale(skup, BidSkupStatus.USER_CANCEL)) { |
91 | logger.warn("cancelSaleByUser fail, skup:{}", skup); | 91 | logger.warn("cancelSaleByUser fail, skup:{}", skup); |
1 | +package com.yohoufo.order; | ||
2 | + | ||
3 | +import org.junit.runner.RunWith; | ||
4 | +import org.springframework.test.context.ContextConfiguration; | ||
5 | +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
6 | +import org.springframework.test.context.web.WebAppConfiguration; | ||
7 | + | ||
8 | +/** | ||
9 | + * Created by chao.chen on 2019/1/4. | ||
10 | + */ | ||
11 | +@RunWith(SpringJUnit4ClassRunner.class) | ||
12 | +@ContextConfiguration(locations = { | ||
13 | + "classpath*:META-INF/spring/mybatis-datasource.xml", | ||
14 | + "classpath*:META-INF/spring/spring*.xml"}) | ||
15 | +public class BaseWebTest { | ||
16 | +} |
1 | +package com.yohoufo.order.bid; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.common.OrderStatus; | ||
4 | +import com.yohoufo.dal.order.BuyerOrderMapper; | ||
5 | +import com.yohoufo.dal.order.model.BuyerOrder; | ||
6 | +import com.yohoufo.order.BaseWebTest; | ||
7 | +import com.yohoufo.order.common.Operator; | ||
8 | +import com.yohoufo.order.model.RequestedCancelEventStatusChangeBuyerOrder; | ||
9 | +import com.yohoufo.order.service.BuyerOrderStateChangers; | ||
10 | +import com.yohoufo.order.service.listener.BuyerOrderChangeEvent; | ||
11 | +import com.yohoufo.order.service.listener.OrderChangeListenerContainer; | ||
12 | +import org.junit.Test; | ||
13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
14 | +import org.springframework.test.context.web.WebAppConfiguration; | ||
15 | + | ||
16 | +import java.util.concurrent.TimeUnit; | ||
17 | + | ||
18 | +@WebAppConfiguration("src/main/resources") | ||
19 | +public class BuyerBidOrderServiceTest extends BaseWebTest { | ||
20 | + | ||
21 | + @Autowired | ||
22 | + private OrderChangeListenerContainer orderChangeListenerContainer; | ||
23 | + | ||
24 | + @Autowired | ||
25 | + BuyerOrderMapper buyerOrderMapper; | ||
26 | + | ||
27 | + @Autowired | ||
28 | + BuyerOrderStateChangers buyerOrderStateChangers; | ||
29 | + | ||
30 | + int uid = 500031116; | ||
31 | + | ||
32 | + @Test | ||
33 | + public void test_refundDeposit_when_paySuccess() throws Exception { | ||
34 | + BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(10018031345472L, uid); | ||
35 | + //订单事件 | ||
36 | + orderChangeListenerContainer.fireAsyncEvent(new BuyerOrderChangeEvent(buyerOrder, BuyerOrderChangeEvent.BizCase.PAY_SUCCESS)); | ||
37 | + | ||
38 | + TimeUnit.SECONDS.sleep(100); | ||
39 | + | ||
40 | + } | ||
41 | + | ||
42 | + @Test | ||
43 | + public void test_deposit_pay_success() { | ||
44 | + long orderCode = 10033859845960L; | ||
45 | + buyerOrderStateChangers.selectOneToChange(uid, orderCode, OrderStatus.WAITING_PAY_DEPOSIT, OrderStatus.BIDING); | ||
46 | + } | ||
47 | + | ||
48 | + @Test | ||
49 | + public void test_buyer_close_bid() throws Exception { | ||
50 | + long orderCode = 10029406388043L; | ||
51 | + buyerOrderStateChangers.selectOneToChange(uid, orderCode,OrderStatus.BIDING,OrderStatus.BUYER_CLOSE_BID); | ||
52 | + TimeUnit.SECONDS.sleep(100); | ||
53 | + } | ||
54 | + | ||
55 | + @Test | ||
56 | + public void test_buyer_pay_timeout() throws Exception { | ||
57 | + long orderCode = 10029406388043L; | ||
58 | + BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid); | ||
59 | + RequestedCancelEventStatusChangeBuyerOrder statusChangeBuyerOrder = new RequestedCancelEventStatusChangeBuyerOrder(buyerOrder, | ||
60 | + OrderStatus.WAITING_PAY, | ||
61 | + OrderStatus.BUYER_BID_PAY_TIMEOUT, | ||
62 | + Operator.SYSTEM, | ||
63 | + null); | ||
64 | + buyerOrderStateChangers.selectOneToChange(statusChangeBuyerOrder); | ||
65 | + TimeUnit.SECONDS.sleep(100); | ||
66 | + } | ||
67 | +} |
-
Please register or login to post a comment