Authored by LUOXC

refactor

... ... @@ -56,7 +56,7 @@ public class BaseNoticeFacade {
}
public Notice withInBox(InboxBusinessTypeEnum businessType, Object... args) {
inBoxContent = buildInboxReqVO(uid, buildParams(args), businessType);
inBoxContent = buildInboxContent(businessType, args);
return this;
}
... ... @@ -66,7 +66,7 @@ public class BaseNoticeFacade {
}
public Notice withSms(InboxBusinessTypeEnum businessType, Object... args) {
smsContent = getReplacedContent(businessType.getContent(), args);
smsContent = buildSmsContent(businessType, args);
return this;
}
... ... @@ -86,6 +86,7 @@ public class BaseNoticeFacade {
InboxReqVO inBoxContent = getInBoxContent();
if (Objects.nonNull(inBoxContent)) {
try {
inBoxContent.setUid(uid);
InBoxResponse resp = inBoxSDK.addInbox(inBoxContent);
log.info("send in box success, uid {}, content {} response {}", uid, inBoxContent, resp);
} catch (Exception e) {
... ... @@ -171,11 +172,19 @@ public class BaseNoticeFacade {
return req;
}
protected InboxReqVO buildInboxContent(InboxBusinessTypeEnum ibt,Object... params) {
InboxReqVO req = new InboxReqVO();
req.setType(ibt.getType());
req.setBusinessType(ibt.getBusinessType());
req.setParams(buildParams(params));
return req;
}
protected String getReplacedContent(String content, Object... params) {
return MessageFormatter.arrayFormat(content, params).getMessage();
}
protected String replaceSMSContent(InboxBusinessTypeEnum ibte, Object... params){
protected String buildSmsContent(InboxBusinessTypeEnum ibte, Object... params){
return getReplacedContent(ibte.getContent(), params);
}
... ...
... ... @@ -20,7 +20,6 @@ import lombok.NonNull;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.MessageFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -33,8 +32,6 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* Created by chenchao on 2018/10/8.
... ... @@ -96,29 +93,27 @@ public class InBoxFacade extends BaseNoticeFacade{
}
/**
* 卖家发货后
*
* @param buyerUid
* @param orderCode
*/
public void sellerDeliver2Depot(int buyerUid, long orderCode, SellerOrderGoods psog) {
try {
executorService.execute(() -> {
logger.info("notice buyer seller deliver 2 depot, buyerUid {}, orderCode {}", buyerUid, orderCode);
String skupTypeText = SkupType.getSkupType(psog.getAttributes()).attrName();
String prdName = psog.getProductName();
String sizeName = psog.getSizeName();
Product product = productMapper.selectByPrimaryKey(psog.getProductId());
String productCode = product.getProductCode();
newNotice(buyerUid)
.withInBox(InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_SELLER_DELIVER, orderCode)
.withPush(() -> ufoSendService.sellerDeliverNotice(String.valueOf(buyerUid), String.valueOf(orderCode)))
.withSms(InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_SELLER_DELIVER, skupTypeText, prdName, sizeName, productCode, orderCode)
.send();
});
logger.info("notice buyer seller deliver 2 depot, buyerUid {}, orderCode {}", buyerUid, orderCode);
newNotice(buyerUid)
.withInBox(InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_SELLER_DELIVER, orderCode)
.withPush(() -> ufoSendService.sellerDeliverNotice(String.valueOf(buyerUid), String.valueOf(orderCode)))
.withSms(() -> {
String skupTypeText = SkupType.getSkupType(psog.getAttributes()).attrName();
String prdName = psog.getProductName();
String sizeName = psog.getSizeName();
Product product = productMapper.selectByPrimaryKey(psog.getProductId());
String productCode = product.getProductCode();
return buildSmsContent(InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_SELLER_DELIVER, skupTypeText, prdName, sizeName, productCode, orderCode);
})
.send();
} catch (Exception ex) {
logger.warn("notice buyer seller deliver 2 depot fail, buyerUid {}, orderCode {}", buyerUid, orderCode, ex);
}
... ... @@ -131,19 +126,18 @@ public class InBoxFacade extends BaseNoticeFacade{
*/
public void appraisePassAndDeliveryGoodsToBuyerNoticeBuyer(int buyerUid, long orderCode, SellerOrderGoods psog) {
try {
executorService.execute(() -> {
logger.info("notice buyer appraise pass, buyerUid {}, orderCode {}", buyerUid, orderCode);
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();
newNotice(buyerUid)
.withInBox(InboxBusinessTypeEnum.PURCHASE_SENDED, orderCode)
.withSms(InboxBusinessTypeEnum.SMS_SEND, skupTypeText, prdName, sizeName, productCode, orderCode)
.send();
});
logger.info("notice buyer appraise pass, buyerUid {}, orderCode {}", buyerUid, orderCode);
newNotice(buyerUid)
.withInBox(InboxBusinessTypeEnum.PURCHASE_SENDED, orderCode)
.withSms(() -> {
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();
return buildSmsContent(InboxBusinessTypeEnum.SMS_SEND, skupTypeText, prdName, sizeName, productCode, orderCode);
})
.send();
} catch (Exception e) {
logger.warn("notice buyer appraise pass fail, buyerUid {}, orderCode {}", buyerUid, orderCode, e);
}
... ... @@ -151,20 +145,21 @@ public class InBoxFacade extends BaseNoticeFacade{
public void appraisePassNoticeSeller(int buyerUid, long orderCode, SellerOrderGoods psog) {
try {
executorService.execute(() -> {
logger.info("notice seller appraise pass, buyerUid {}, orderCode {}", buyerUid, orderCode);
String prdName = psog.getProductName();
Product product = productMapper.selectByPrimaryKey(psog.getProductId());
String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
String sizeName = psog.getSizeName();
Integer sellerUid = psog.getUid();
String skupTypeText = SkupType.getSkupType(psog.getAttributes()).attrName();
newNotice(sellerUid)
.withInBox(InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_APPRAISE_PASS, skupTypeText, prdName, sizeName, productCode)
.withSms(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_APPRAISE_PASS, skupTypeText, orderCode)
.send();
});
logger.info("notice seller appraise pass, buyerUid {}, orderCode {}", buyerUid, orderCode);
newNotice(psog.getUid())
.withInBox(() -> {
String prdName = psog.getProductName();
Product product = productMapper.selectByPrimaryKey(psog.getProductId());
String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
String sizeName = psog.getSizeName();
String skupTypeText = SkupType.getSkupType(psog.getAttributes()).attrName();
return buildInboxContent(InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_APPRAISE_PASS,skupTypeText, prdName, sizeName, productCode);
})
.withSms(() -> {
String skupTypeText = SkupType.getSkupType(psog.getAttributes()).attrName();
return buildSmsContent(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_APPRAISE_PASS, skupTypeText, orderCode);
})
.send();
} catch (Exception e) {
logger.warn("notice seller appraise pass fail, buyerUid {}, orderCode {}", buyerUid, orderCode, e);
... ... @@ -1475,7 +1470,7 @@ public class InBoxFacade extends BaseNoticeFacade{
if(autoReSell){
sms=InboxBusinessTypeEnum.SMS_NOTICE_SELLER_AUTO_RESELL_WHEN_BUYER_CANCEL_NO_RESPONSIBILITY;
}
String content = replaceSMSContent(sms, orderCode,skupTypeText, prdName,sizeName,productCode);
String content = buildSmsContent(sms, orderCode,skupTypeText, prdName,sizeName,productCode);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record noticeSellerWhenBuyerCancelNoResponsibility inbox sms msg, sellerUid {}, orderCode {},prdName {}",
sellerUid, orderCode, prdName);
... ...