Authored by qinchao

add 订单状态拆分 接口for platform

... ... @@ -40,6 +40,33 @@ public class AppraiseController {
}
/**
* 鉴定中心鉴定通过后,发货
* 提供给运营平台使用
* @return
*/
@RequestMapping(value="/deliverGoods")
@IgnoreSession
@IgnoreSignature
public ApiResponse deliverGoods(@RequestBody AppraiseExpressInfoBo appraiseExpressInfoBo) {
logger.info("in deliverGoods , req {}", appraiseExpressInfoBo);
appraiseService.deliverGoods(appraiseExpressInfoBo);
return new ApiResponse();
}
/**
* 鉴定中心鉴定不通过后,寄回
* 提供给运营平台使用
* @return
*/
@RequestMapping(value="/returnBackOrderCauseOfJudgeFailure")
@IgnoreSession
@IgnoreSignature
public ApiResponse returnBackOrderCauseOfJudgeFailure(@RequestBody AppraiseExpressInfoBo appraiseExpressInfoBo) {
logger.info("in returnBackOrderCauseOfJudgeFailure , req {}", appraiseExpressInfoBo);
appraiseService.returnBackOrderCauseOfJudgeFailure(appraiseExpressInfoBo);
return new ApiResponse();
}
/**
* 卖家发货后,买家又取消了订单,鉴定中心寄回商品给卖家
* 提供给运营平台使用
* @return
... ...
... ... @@ -234,6 +234,17 @@ public class BuyerOrderController {
return new ApiResponse.ApiResponseBuilder().code(200).message("鉴定中心确认收货成功").build();
}
@IgnoreSession
@IgnoreSignature
@RequestMapping(value = "/erp/judgeBegin")
@ResponseBody
public ApiResponse judgeBegin(@RequestBody OrderRequest request) {
LOG.info("method ufo.depot.judgeBegin in, req is {}", request);
buyerOrderService.judgeBegin(request.getOrderCode());
LOG.info("method ufo.depot.judgeBegin out, req is {}", request);
return new ApiResponse.ApiResponseBuilder().code(200).message("鉴定中心开始鉴定成功").build();
}
@RequestMapping(params = "method=ufo.buyer.computeCompensate")
@ResponseBody
public ApiResponse computeCompensate(@RequestParam("orderCode") long orderCode,
... ...
... ... @@ -52,5 +52,7 @@ public interface IBuyerOrderService extends IOrderListService, IOrderDetailServi
void confirmReceive(long orderCode);
void judgeBegin(long orderCode);
OrderCntResp getOrderCnt(OrderRequest req, OrderListType listType);
}
... ...
... ... @@ -10,6 +10,7 @@ import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
... ... @@ -104,7 +105,7 @@ public class AppraiseService {
throw new ServiceException(ServiceError.ORDER_NULL);
}
final OrderStatus expectOrderStatus = OrderStatus.PLATFORM_CHECKING;
final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE;
final OrderStatus targetOrderStatus = OrderStatus.JUDGE_PASS;
if (expectOrderStatus.getCode() != buyerOrder.getStatus().intValue()){
LOGGER.warn("in appraiseSuccess, buyer Order orderCode {} pstatus {}, expect Order Status {}",
orderCode, buyerOrder.getStatus(), expectOrderStatus);
... ... @@ -188,7 +189,8 @@ public class AppraiseService {
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
EventBusPublisher.publishEvent(buyerConfirmEvent);
//记录物流信息
expressInfoService.appraiseSuccess(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
//不发物流
//expressInfoService.appraiseSuccess(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
//平台已发货给买家
inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
}catch (Exception ex){
... ... @@ -273,6 +275,106 @@ public class AppraiseService {
}
/**
* 发货
* (1)更新订单状态
* (2)记录物流
* (3)消息
*/
public void deliverGoods(AppraiseExpressInfoBo appraiseExpressInfoBo){
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
Long orderCode=appraiseExpressInfoBo.getOrderCode();
String wayBillCode=appraiseExpressInfoBo.getWayBillCode();
Integer depotNum=appraiseExpressInfoBo.getDepotNum();
String mobile=appraiseExpressInfoBo.getMobile();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("deliverGoods getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
OrderStatus expectStatus = OrderStatus.JUDGE_PASS;
final OrderStatus targetStatus = OrderStatus.WAITING_RECEIVE;
if (buyerOrder.getStatus() != expectStatus.getCode()){
LOGGER.warn("deliverGoods expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
//更新状态为 (待收货[买家])
int buyerUid = buyerOrder.getUid();
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
int skup = bog.getSkup();
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
expectStatus.getCode(), targetStatus.getCode(), DateUtil.getCurrentTimeSecond());
LOGGER.info("deliverGoods updateBuyerCnt {} ,expectStatus {}, actual status {}, orderCode {}", updateBuyerCnt ,expectStatus,
buyerOrder.getStatus(), orderCode);
if(updateBuyerCnt==1){
int sellerUid = buyerOrder.getSellerUid();
//记录物流信息
expressInfoService.appraiseSuccess(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
//平台已发货给买家 TODO
//inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
//清理
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(buyerUid)));
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);
EventBusPublisher.publishEvent(event);
}else{
LOGGER.warn("in deliverGoods update buyer count fail ,expectStatus {}, actual status {}, orderCode {}", updateBuyerCnt ,expectStatus,
buyerOrder.getStatus(), orderCode);
throw new UfoServiceException(400,"更新订单状态失败");
}
}
/**
* 鉴定不通过退回
* (1)记录物流
* (2)消息
*/
public void returnBackOrderCauseOfJudgeFailure(AppraiseExpressInfoBo appraiseExpressInfoBo){
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
Long orderCode=appraiseExpressInfoBo.getOrderCode();
String wayBillCode=appraiseExpressInfoBo.getWayBillCode();
Integer depotNum=appraiseExpressInfoBo.getDepotNum();
String mobile=appraiseExpressInfoBo.getMobile();
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("returnBackOrderCauseOfJudgeFailure getOrderInfo order not exist, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
OrderStatus expectStatus = OrderStatus.CHECKING_FAKE;
if (buyerOrder.getStatus() != expectStatus.getCode()){
LOGGER.warn("returnBackOrderCauseOfJudgeFailure expectStatus {}, actual status {}, orderCode {}", expectStatus,
buyerOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
//更新物流信息
int sellerUid = buyerOrder.getSellerUid();
expressInfoService.appraiseFail(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
//发消息给卖家 TODO
//inBoxFacade.sendCancelledProductToSellerByCenter(sellerUid,wayBillCode);
}
/**
* 直接退回商品,记录物流,不涉及状态更改
* @param expressCompanyId
* @param orderCode
... ... @@ -396,6 +498,7 @@ public class AppraiseService {
payRefundService.refund(req, bleb);
//
//TODO 消息
inBoxFacade.noticeSellerWhenAppraiseFail( sellerOrderGoods,orderCode,wayBillCode);
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
}catch (Exception ex){
... ... @@ -414,7 +517,8 @@ public class AppraiseService {
}finally {
//更新物流信息,写到最后
expressInfoService.appraiseFail(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
//鉴定不通过,不发物流
//expressInfoService.appraiseFail(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
}
}else{
... ...
... ... @@ -630,14 +630,18 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
public void confirmReceive(long orderCode) {
logger.info("in confirmReceive, orderCode {}", orderCode);
OrderStatus expectStatus = OrderStatus.SELLER_SEND_OUT;
OrderStatus targetStatus = OrderStatus.PLATFORM_CHECKING;
OrderStatus targetStatus = OrderStatus.PLATFORM_RECEIVE;
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder != null && buyerOrder.getStatus() == expectStatus.getCode()){
int uid = buyerOrder.getUid();
int sellerUid = buyerOrder.getSellerUid();
logger.info("in confirmReceive begin update status orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
buyerOrderMapper.updateStatusByOrderCode(orderCode, uid, expectStatus.getCode(),
targetStatus.getCode(), DateUtil.getCurrentTimeSecond());
cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
/*
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
... ... @@ -650,10 +654,45 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(uid);
EventBusPublisher.publishEvent(event);
*/
}
}
@Override
public void judgeBegin(long orderCode){
logger.info("in judgeBegin, orderCode {}", orderCode);
OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
OrderStatus targetStatus = OrderStatus.PLATFORM_CHECKING;
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder != null && buyerOrder.getStatus() == expectStatus.getCode()){
int uid = buyerOrder.getUid();
int sellerUid = buyerOrder.getSellerUid();
logger.info("in judgeBegin begin update status orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
buyerOrderMapper.updateStatusByOrderCode(orderCode, uid, expectStatus.getCode(),
targetStatus.getCode(), DateUtil.getCurrentTimeSecond());
cleanCacheAfterUpdateStatus(orderCode,uid,sellerUid);
}
}
//清理缓存
private void cleanCacheAfterUpdateStatus(long orderCode,int uid,int sellerUid){
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
logger.info("in cleanCacheAfterUpdateStatus begin clean cache orderCode {},uid {} ,sellerUid {}", orderCode,uid,sellerUid);
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(uid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(uid)));
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(uid);
EventBusPublisher.publishEvent(event);
}
@Override
public OrderCntResp getOrderCnt(OrderRequest req, OrderListType listType) {
logger.info("in buyer getOrderCnt req {} listType {}", req, listType);
OrderCntResp resp;
... ...