Authored by wujiexiang

求购订单调价

... ... @@ -108,7 +108,7 @@ public class BuyerBidPriceService {
logger.info("[{}] will change price,orderCode:{},oldSkup:{}", uid, context.buyerOrder.getOrderCode(), oldSkup);
//调价前将原skup取消,若生成新skup失败,则需要手动恢复原skup
bidProductProxyService.cancelSaleByUser(oldSkup);
bidProductProxyService.cancelSaleBeforeChangePrice(oldSkup);
logger.info("[{}] was canceled success", oldSkup);
//构建参数
... ...
... ... @@ -74,9 +74,14 @@ public class BidProductProxyService extends AbsProxyService {
return getResultFromApiResponse(ufoServiceCaller.call(api, skup), Boolean.class);
}
public boolean cancelSaleByUser(int skup) {
logger.info("cancelSaleByUser,skup:{}", skup);
public boolean cancelSaleBeforeChangePrice(int skup) {
logger.info("cancelSaleBeforeChangePrice,skup:{}", skup);
try {
return cancelSale(skup, Operator.USER);
} catch (UfoServiceException use) {
//方便
throw new UfoServiceException(use.getCode(), "您的求购商品正在被卖家匹配中,无法调价");
}
}
... ...
... ... @@ -85,7 +85,7 @@ public class BidProductService {
BidStoragePrice bidStoragePrice = checkAndGetSkup(skup);
if (bidStoragePrice.getStatus() == BidSkupStatus.BID_SUCCESS.getCode()) {
logger.warn("[{}] status is bid_success,can't be canceled", skup);
throw new ServiceException(500, "商品取消失败(已变现)");
throw new ServiceException(500, "您的求购商品正在被卖家匹配中,无法取消求购");
}
if (!doCancelSale(skup, BidSkupStatus.USER_CANCEL)) {
logger.warn("cancelSaleByUser fail, skup:{}", skup);
... ...
package com.yohoufo.order;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
/**
* Created by chao.chen on 2019/1/4.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath*:META-INF/spring/mybatis-datasource.xml",
"classpath*:META-INF/spring/spring*.xml"})
public class BaseWebTest {
}
... ...
package com.yohoufo.order.bid;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.order.BaseWebTest;
import com.yohoufo.order.common.Operator;
import com.yohoufo.order.model.RequestedCancelEventStatusChangeBuyerOrder;
import com.yohoufo.order.service.BuyerOrderStateChangers;
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
import com.yohoufo.order.service.listener.OrderChangeListenerContainer;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.web.WebAppConfiguration;
import java.util.concurrent.TimeUnit;
@WebAppConfiguration("src/main/resources")
public class BuyerBidOrderServiceTest extends BaseWebTest {
@Autowired
private OrderChangeListenerContainer orderChangeListenerContainer;
@Autowired
BuyerOrderMapper buyerOrderMapper;
@Autowired
BuyerOrderStateChangers buyerOrderStateChangers;
int uid = 500031116;
@Test
public void test_refundDeposit_when_paySuccess() throws Exception {
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(10018031345472L, uid);
//订单事件
orderChangeListenerContainer.fireAsyncEvent(new BuyerOrderChangeEvent(buyerOrder, BuyerOrderChangeEvent.BizCase.PAY_SUCCESS));
TimeUnit.SECONDS.sleep(100);
}
@Test
public void test_deposit_pay_success() {
long orderCode = 10033859845960L;
buyerOrderStateChangers.selectOneToChange(uid, orderCode, OrderStatus.WAITING_PAY_DEPOSIT, OrderStatus.BIDING);
}
@Test
public void test_buyer_close_bid() throws Exception {
long orderCode = 10029406388043L;
buyerOrderStateChangers.selectOneToChange(uid, orderCode,OrderStatus.BIDING,OrderStatus.BUYER_CLOSE_BID);
TimeUnit.SECONDS.sleep(100);
}
@Test
public void test_buyer_pay_timeout() throws Exception {
long orderCode = 10029406388043L;
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid);
RequestedCancelEventStatusChangeBuyerOrder statusChangeBuyerOrder = new RequestedCancelEventStatusChangeBuyerOrder(buyerOrder,
OrderStatus.WAITING_PAY,
OrderStatus.BUYER_BID_PAY_TIMEOUT,
Operator.SYSTEM,
null);
buyerOrderStateChangers.selectOneToChange(statusChangeBuyerOrder);
TimeUnit.SECONDS.sleep(100);
}
}
... ...