Authored by chenchao

add notice

... ... @@ -93,9 +93,6 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
private TradeBillsService tradeBillsService;
@Autowired
private DepositService depositService;
@Autowired
private AppraiseService appraiseService;
private boolean isDepositWithQuickDeliverGoods(int uid, long orderCode, Integer oa){
... ... @@ -157,17 +154,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
}
private void processDepositOrderOfQuickDeliverGoods(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){
Integer sellerUid = null;
Integer buyerUid = null;
Long orderCode = null;
Integer skup = null;
try {
depositService.changeOwner(sellerUid = buyerOrder.getSellerUid(), skup = sellerOrderGoods.getId(),
orderCode = buyerOrder.getOrderCode(), buyerUid = buyerOrder.getUid(), true);
}catch (Exception ex){
logger.warn("pay successful, processDepositOrder invoke depositService.changeOwner fail, sellerUid {}, buyerUid {},orderCode {},skup {}",
sellerUid, buyerUid, orderCode, skup);
}
Integer buyerUid = buyerOrder.getUid();
Long orderCode = buyerOrder.getOrderCode();
inBoxFacade.noticeWhenDepositOrderOfQuickDeliverGoodsPaid(buyerUid, orderCode, sellerOrderGoods);
}
private void processDepositOrderOfInstockGoods(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){
... ... @@ -238,22 +227,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
}
private void processQuickDeliverOrder(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){
//寄存订单 & 闪购商品
if (SkupType.QUICK_DELIVER.getCode() == sellerOrderGoods.getAttributes()){
Integer sellerUid = null;
Integer buyerUid = null;
Long orderCode = null;
Integer skup = null;
try {
depositService.changeOwner(sellerUid = buyerOrder.getSellerUid(), skup = sellerOrderGoods.getId(),
orderCode = buyerOrder.getOrderCode(), buyerUid = buyerOrder.getUid(), false);
}catch (Exception ex){
logger.warn("pay successful, processQuickDeliverOrder invoke depositService.changeOwner fail, sellerUid {}, buyerUid {},orderCode {},skup {}",
sellerUid, buyerUid, orderCode, skup);
}
}
//todo notice
// notice
inBoxFacade.noticeWhenQuickDeliverOrderPaid(buyerOrder.getUid(), buyerOrder.getOrderCode(), sellerOrderGoods);
}
@Override
... ...
... ... @@ -603,7 +603,7 @@ public class AppraiseService {
orderOperateRecordService.addRecord(orderCode, "买家操作", OperateTypeEnum.OPERATE_TYPE_QUALITY_MINI_FAULT_PASS);
//TODO 发消息 瑕疵接收,只给卖家发消息
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods, product);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods);
} else {
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); // 更新失败,可能是因为订单状态已经被并发修改
}
... ... @@ -1268,7 +1268,7 @@ public class AppraiseService {
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
//TODO 鉴定通过,
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods, product);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods);
} catch (Exception ex) {
LOGGER.warn("in judgeCenterPass,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
String content = "后台鉴定通过商品,订单" + orderCode + "退还保证金失败";
... ... @@ -1413,8 +1413,8 @@ public class AppraiseService {
//平台已发货给买家
Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.appraisePassNoticeBuyer(buyerUid, orderCode, sellerOrderGoods, product);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods, product);
inBoxFacade.appraisePassNoticeBuyer(buyerUid, orderCode, sellerOrderGoods);
inBoxFacade.appraisePassNoticeSeller(buyerUid, orderCode, sellerOrderGoods);
} catch (Exception ex) {
LOGGER.warn("in appraiseSuccess,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
String content = "鉴定通过时,订单" + orderCode + "退还保证金失败";
... ... @@ -1571,12 +1571,20 @@ public class AppraiseService {
public void processQuickDeliverOrderAfterPaid(long orderCode,int uid, boolean isDeposit){
BuyerOrderGoods pbog = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
BuyerOrder pbo = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
Integer sellerUid = pbo.getSellerUid();
Integer skup = pbog.getSkup();
try {
transferGoodsMoneyWhenPass(pbo.getSellerUid(), pbog.getSkup(), orderCode);
transferGoodsMoneyWhenPass(sellerUid, skup, orderCode);
}catch (Exception ex){
LOGGER.warn("in processQuickDeliverOrderAfterPaid transferGoodsMoneyWhenPass fail orderCode {} uid {}",
orderCode, uid, ex);
}
depositService.changeOwner(pbo.getSellerUid(), pbog.getSkup(), orderCode,uid, isDeposit);
try {
depositService.changeOwner(sellerUid, skup, orderCode,uid, isDeposit);
}catch (Exception ex){
LOGGER.warn("pay successful, processQuickDeliverOrder invoke depositService.changeOwner fail, sellerUid {}, buyerUid {},orderCode {},skup {}",
sellerUid, uid, orderCode, skup);
}
}
}
... ...
... ... @@ -117,6 +117,8 @@ public class InBoxFacade {
}
}
/**
* 卖家发货后
* @param buyerUid
... ... @@ -218,17 +220,18 @@ public class InBoxFacade {
*
* @return
*/
public void appraisePassNoticeBuyer(int buyerUid, long orderCode, SellerOrderGoods psog,Product product) {
public void appraisePassNoticeBuyer(int buyerUid, long orderCode, SellerOrderGoods psog) {
executorService.execute(()->{
try {
logger.info("record appraisePassNotice inbox msg, buyerUid {}, orderCode {}, psog {},SellerOrderGoods {} product {}",
buyerUid, orderCode, psog, JSON.toJSONString(psog), JSON.toJSONString(product));
logger.info("record appraisePassNotice inbox msg, buyerUid {}, orderCode {}, psog {},SellerOrderGoods {} ",
buyerUid, orderCode, psog, JSON.toJSONString(psog));
Product product = productMapper.selectByPrimaryKey(psog.getProductId());
String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
String skupTypeText=SkupType.getSkupType(psog.getAttributes()).attrName();
String prdName = psog.getProductName();
String sizeName = psog.getSizeName();
String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.PURCHASE_SENDED;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
... ... @@ -256,14 +259,15 @@ public class InBoxFacade {
}
public void appraisePassNoticeSeller(int buyerUid, long orderCode, SellerOrderGoods psog,Product product) {
public void appraisePassNoticeSeller(int buyerUid, long orderCode, SellerOrderGoods psog) {
executorService.execute(()->{
try {
logger.info("record appraisePassNoticeSeller inbox msg, buyerUid {}, orderCode {}, psog {},SellerOrderGoods {} product {}",
buyerUid, orderCode, psog, JSON.toJSONString(psog), JSON.toJSONString(product));
buyerUid, orderCode, psog, JSON.toJSONString(psog));
String prdName = psog.getProductName();
Product product = productMapper.selectByPrimaryKey(psog.getProductId());
String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
//seller notice
... ... @@ -1755,38 +1759,117 @@ public class InBoxFacade {
}
}
private void execute(Runnable task, String logModule, Object[] logParms){
try{
executorService.execute(task);
}catch (Exception ex){
logger.warn(logModule, logParms, ex);
}
}
public void noticeWhenBuyerBlownCustomsClearance(int buyerUid, long orderCode, SellerOrderGoods sog){
String prdName = sog.getProductName();
String sizeName = sog.getSizeName();
try {
executorService.execute(()->{
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.BUYER_BLOWN_CUSTOMS_CLEARANCE;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record noticeWhenBuyerBlownCustomsClearance to buyer inbox msg, buyerUid {}, orderCode {},prdName {} resp {}",
buyerUid, orderCode,prdName, resp);
Runnable task = ()->{
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.BUYER_BLOWN_CUSTOMS_CLEARANCE;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
//短信
String phone = userProxyService.getMobile(buyerUid);
if (StringUtils.isBlank(phone)){
logger.warn("in noticeWhenBuyerBlownCustomsClearance sms fail, buyerUid {} orderCode {} prdName {}", buyerUid, orderCode,prdName);
return;
}
List<String> mobileList = Arrays.asList(phone);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record noticeWhenBuyerBlownCustomsClearance to buyer inbox msg, buyerUid {}, orderCode {},prdName {} resp {}",
buyerUid, orderCode,prdName, resp);
InboxBusinessTypeEnum sms=InboxBusinessTypeEnum.SMS_BUYER_BLOWN_CUSTOMS_CLEARANCE;
//短信
String phone = userProxyService.getMobile(buyerUid);
if (StringUtils.isBlank(phone)){
logger.warn("in noticeWhenBuyerBlownCustomsClearance sms fail, buyerUid {} orderCode {} prdName {}", buyerUid, orderCode,prdName);
return;
}
List<String> mobileList = Arrays.asList(phone);
String content= getReplacedContent(sms.getContent(),prdName,sizeName,orderCode);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record noticeWhenBuyerBlownCustomsClearance inbox sms msg, buyer Uid {}, orderCode {},prdName {} ,sizeName {} ",
buyerUid, orderCode, prdName,sizeName);
});
} catch (Exception e) {
logger.warn("InBoxFacade noticeWhenBuyerBlownCustomsClearance error inbox msg, buyerUid {}, orderCode {} ,prdName {}",
buyerUid, orderCode, prdName, e);
}
InboxBusinessTypeEnum sms=InboxBusinessTypeEnum.SMS_BUYER_BLOWN_CUSTOMS_CLEARANCE;
String content= getReplacedContent(sms.getContent(),prdName,sizeName,orderCode);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record noticeWhenBuyerBlownCustomsClearance inbox sms msg, buyer Uid {}, orderCode {},prdName {} ,sizeName {} ",
buyerUid, orderCode, prdName,sizeName);
};
String logModule = "InBoxFacade noticeWhenBuyerBlownCustomsClearance error inbox msg, buyerUid {}, orderCode {} ,prdName {}";
Object[] logparams = new Object[]{buyerUid, orderCode, prdName};
execute(task, logModule, logparams);
}
public void noticeWhenQuickDeliverOrderPaid(int buyerUid, long orderCode, SellerOrderGoods sog){
String prdName = sog.getProductName();
String sizeName = sog.getSizeName();
Runnable task = ()->{
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_QUICK_DELIVER_ORDER_PAID;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record noticeWhenQuickDeliverOrderPaid to buyer inbox msg, buyerUid {}, orderCode {},prdName {} resp {}",
buyerUid, orderCode,prdName, resp);
//短信
String phone = userProxyService.getMobile(buyerUid);
if (StringUtils.isBlank(phone)){
logger.warn("in noticeWhenQuickDeliverOrderPaid sms fail, buyerUid {} orderCode {} prdName {}", buyerUid, orderCode,prdName);
return;
}
List<String> mobileList = Arrays.asList(phone);
InboxBusinessTypeEnum sms=InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_QUICK_DELIVER_ORDER_PAID;
String content= getReplacedContent(sms.getContent(),prdName,sizeName,orderCode);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record noticeWhenQuickDeliverOrderPaid inbox sms msg, buyer Uid {}, orderCode {},prdName {} ,sizeName {} ",
buyerUid, orderCode, prdName,sizeName);
};
String logModule = "InBoxFacade noticeWhenQuickDeliverOrderPaid error inbox msg, buyerUid {}, orderCode {} ,prdName {}";
Object[] logparams = new Object[]{buyerUid, orderCode, prdName};
execute(task, logModule, logparams);
appraisePassNoticeSeller(buyerUid,orderCode, sog);
}
public void noticeWhenDepositOrderOfQuickDeliverGoodsPaid(int buyerUid, long orderCode, SellerOrderGoods sog){
String prdName = sog.getProductName();
String sizeName = sog.getSizeName();
Runnable task = ()->{
InboxBusinessTypeEnum ibt = InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_DEPOSIT_ORDER_OF_QUICK_DELIVER_PAID;
String params = buildParams(orderCode);
InboxReqVO req = buildInboxReqVO(buyerUid, params, ibt);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record noticeWhenDepositOrderOfPaid to buyer inbox msg, buyerUid {}, orderCode {},prdName {} resp {}",
buyerUid, orderCode,prdName, resp);
//短信
String phone = userProxyService.getMobile(buyerUid);
if (StringUtils.isBlank(phone)){
logger.warn("in noticeWhenDepositOrderOfPaid sms fail, buyerUid {} orderCode {} prdName {}", buyerUid, orderCode,prdName);
return;
}
List<String> mobileList = Arrays.asList(phone);
InboxBusinessTypeEnum sms=InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_DEPOSIT_ORDER_OF_QUICK_DELIVER_PAID;
String content= getReplacedContent(sms.getContent(),prdName,sizeName,orderCode);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record noticeWhenDepositOrderOfPaid inbox sms msg, buyer Uid {}, orderCode {},prdName {} ,sizeName {} ",
buyerUid, orderCode, prdName,sizeName);
};
String logModule = "InBoxFacade noticeWhenDepositOrderOfPaid error inbox msg, buyerUid {}, orderCode {} ,prdName {}";
Object[] logparams = new Object[]{buyerUid, orderCode, prdName};
execute(task, logModule, logparams);
//
appraisePassNoticeSeller(buyerUid,orderCode, sog);
}
public InboxReqVO buildInboxReqVO(int uid, String params, InboxBusinessTypeEnum ibt) {
... ...