Authored by chenchao

add no responsibility

... ... @@ -37,6 +37,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
... ... @@ -90,9 +91,6 @@ public class BuyerOrderCancelService {
private OrderStatusFlowService orderStatusFlowService;
public void cancel(BeforeSellerDeliverEvent bsdEvent){
int buyerUid = bsdEvent.getBuyerUid();
int sellerUid = bsdEvent.getSellerUid();
... ... @@ -114,6 +112,8 @@ public class BuyerOrderCancelService {
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
if (rows>0) {
boolean noResponsibility = Objects.isNull(bpcr.getPenaltyAmount())
|| BigDecimal.ZERO.compareTo(bpcr.getPenaltyAmount()) == 0;
//退还优惠券
refundCouponIfNeed(buyerUid, orderCode);
int skup = bsdEvent.getSkup();
... ... @@ -128,8 +128,12 @@ public class BuyerOrderCancelService {
soc.setUpdateTime(DateUtil.getCurrentTimeSecond());
sellerOrderMapper.updateBySkups(soc, Arrays.asList(skup));
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
inBoxFacade.buyerCancelBeforeSellerDeliver(buyerUid, orderCode,
bpcr.getPenaltyAmount().toPlainString(), psog);
if (noResponsibility){
inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode);
}else {
inBoxFacade.buyerCancelBeforeSellerDeliver(buyerUid, orderCode,
bpcr.getPenaltyAmount().toPlainString(), psog);
}
//TODO 整个过程异步去执行(考虑退费依赖订单状态)
//(退费)退保证金给卖家
//(转账)瓜分指定赔偿款给卖家和平台
... ... @@ -217,10 +221,11 @@ public class BuyerOrderCancelService {
}
OrderStatus expected = bdrEvent.getExpected();
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
if (rows>0) {
boolean noResponsibility = Objects.isNull(bpcr.getPenaltyAmount())
|| BigDecimal.ZERO.compareTo(bpcr.getPenaltyAmount()) == 0;
//退还优惠券
refundCouponIfNeed(buyerUid, orderCode);
... ... @@ -236,8 +241,12 @@ public class BuyerOrderCancelService {
soc.setUpdateTime(DateUtil.getCurrentTimeSecond());
sellerOrderMapper.updateBySkups(soc, Arrays.asList(skup));
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
inBoxFacade.buyerCancelBeforeDepotReceive(buyerUid, orderCode,
bpcr.getPenaltyAmount().toPlainString(), psog);
if (noResponsibility){
inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode);
}else {
inBoxFacade.buyerCancelBeforeDepotReceive(buyerUid, orderCode,
bpcr.getPenaltyAmount().toPlainString(), psog);
}
//整个过程异步去执行(考虑退费依赖订单状态)
//(退费)退保证金给卖家
//(转账)瓜分指定赔偿款给卖家和平台
... ...
... ... @@ -188,6 +188,9 @@ public class InBoxFacade {
});
}
private String replaceSMSContent(InboxBusinessTypeEnum ibte, Object... params){
return getReplacedContent(ibte.getContent(), params);
}
private String getReplacedContent(String content ,Object... params) {
return MessageFormatter.arrayFormat(content, params).getMessage();
... ... @@ -1075,6 +1078,45 @@ public class InBoxFacade {
}
}
/**
* 买家在24小时内取消预售
* 站内:您的商品「商品名称」「尺码」,已被买家取消,您出售的商品已下架,保证金将于1个工作日内退回您的账户。
* 短信:买家已取消订单,订单编号{}。您的商品「商品名称」已下架,更多信息请查看Yoho!Buy有货APP [我的-球鞋交易-出售]。
*/
public void noticeSellerWhenBuyerCancelNoResponsibility(SellerOrderGoods sog, long orderCode){
Integer sellerUid = sog.getUid();
String prdName = sog.getProductName();
String sizeName = sog.getSizeName();
try {
executorService.execute(()->{
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_BUYER_CANCEL_NO_RESPONSIBILITY;
String params = buildParams(prdName, sizeName, orderCode);
InboxReqVO req = buildInboxReqVO(sellerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record noticeSellerWhenBuyerCancelNoResponsibility to seller inbox msg, sellerUid {}, orderCode {},prdName {} resp {}",
sellerUid, orderCode,prdName, resp);
//短信
String phone = userProxyService.getMobile(sellerUid);
if (StringUtils.isBlank(phone)){
logger.warn("in noticeSellerWhenBuyerCancelNoResponsibility sms fail, sellerUid {} orderCode {} prdName {}", sellerUid, orderCode,prdName);
return;
}
List<String> mobileList = Arrays.asList(phone);
String content = replaceSMSContent(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_BUYER_CANCEL_NO_RESPONSIBILITY, orderCode, prdName);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record noticeSellerWhenBuyerCancelNoResponsibility inbox sms msg, sellerUid {}, orderCode {},prdName {}",
sellerUid, orderCode, prdName);
});
} catch (Exception e) {
logger.warn("InBoxFacade noticeSellerWhenBuyerCancelNoResponsibility error inbox msg, sellerUid {}, orderCode {} ,prdName {}",
sellerUid, orderCode, prdName, e);
}
}
public void buyerCancelBeforeSellerDeliver(int buyerUid, long orderCode,String compesant, SellerOrderGoods sog) {
Integer sellerUid = sog.getUid();
String prdName = sog.getProductName();
... ... @@ -1103,8 +1145,6 @@ public class InBoxFacade {
return;
}
List<String> mobileList = Arrays.asList(phone);
//SmsContentEnum smsIbt=SmsContentEnum.SMS_CLOSED_PLATFORM;
//String content=smsIbt.getReplacedContent(prdName);
String content= getReplacedContent(InboxBusinessTypeEnum.SMS_CANCELED_BY_BUYER_AFTER_PAID.getContent(),orderCode,prdName);
sendSmsService.smsSendByMobile(content,mobileList);
... ...