...
|
...
|
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.proxy; |
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Sets;
|
|
|
import com.yoho.message.sdk.common.constants.UFOMessageScene;
|
|
|
import com.yoho.message.sdk.common.model.SendMessageRspBo;
|
|
|
import com.yoho.message.sdk.service.ufo.IUFOSendService;
|
|
|
import com.yoho.message.sdk.service.ufo.UFOMessageService;
|
|
|
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
|
...
|
...
|
@@ -22,6 +23,7 @@ import com.yohoufo.order.service.seller.SkupService; |
|
|
import lombok.Builder;
|
|
|
import lombok.NonNull;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -154,7 +156,7 @@ public class SellerNoticeFacade extends BaseNoticeFacade { |
|
|
@Builder
|
|
|
private static class PushDataNode{
|
|
|
|
|
|
Supplier pushSupplier;
|
|
|
Supplier<SendMessageRspBo> pushSupplier;
|
|
|
|
|
|
boolean pushEnable;
|
|
|
}
|
...
|
...
|
@@ -172,16 +174,23 @@ public class SellerNoticeFacade extends BaseNoticeFacade { |
|
|
boolean pushEnable = skupType.equals(SkupType.IN_STOCK)
|
|
|
&& Objects.nonNull(leastPrice=skupService.getLeastPriceOfSku(sku , statusList, skupTypes))
|
|
|
&& leastPrice.compareTo(soldProduct.getPrice())<=0;
|
|
|
Supplier pushSupplier = null;
|
|
|
Supplier<SendMessageRspBo> pushSupplier = null;
|
|
|
if (pushEnable){
|
|
|
List<Integer> uids = bidProductProxyService.getAllUidBySku(sku);
|
|
|
SellerOrderGoods tsog = new SellerOrderGoods();
|
|
|
tsog.setStorageId(sku);
|
|
|
tsog.setProductId(productId);
|
|
|
tsog.setProductName(prdName);
|
|
|
tsog.setGoodsPrice(soldProduct.getPrice());
|
|
|
tsog.setSizeName(sizeName);
|
|
|
pushSupplier = ()-> msgService.noticeBuyerWhenSellerOnShelve(uids, tsog, product);
|
|
|
//because of whole method is not atomic operation
|
|
|
//so at current time, uid may be null
|
|
|
if (CollectionUtils.isEmpty(uids)){
|
|
|
log.warn("in buildPushDataNode by GoodsInfo,bidProductProxyService.getAllUidBySku find no uid, sku {}", sku);
|
|
|
pushEnable = false;
|
|
|
}else {
|
|
|
SellerOrderGoods tsog = new SellerOrderGoods();
|
|
|
tsog.setStorageId(sku);
|
|
|
tsog.setProductId(productId);
|
|
|
tsog.setProductName(prdName);
|
|
|
tsog.setGoodsPrice(soldProduct.getPrice());
|
|
|
tsog.setSizeName(sizeName);
|
|
|
pushSupplier = () -> msgService.noticeBuyerWhenSellerOnShelve(uids, tsog, product);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return PushDataNode.builder().pushEnable(pushEnable).pushSupplier(pushSupplier).build();
|
...
|
...
|
@@ -200,7 +209,14 @@ public class SellerNoticeFacade extends BaseNoticeFacade { |
|
|
Supplier pushSupplier = null;
|
|
|
if (pushEnable){
|
|
|
List<Integer> uids = bidProductProxyService.getAllUidBySku(sku);
|
|
|
pushSupplier = ()-> msgService.noticeBuyerWhenSellerOnShelve(uids, tsog, productSupplier.get());
|
|
|
//because of whole method is not atomic operation
|
|
|
//so at current time, uid may be null
|
|
|
if (CollectionUtils.isEmpty(uids)){
|
|
|
log.warn("in buildPushDataNode by SellerOrderGoods,bidProductProxyService.getAllUidBySku find no uid, sku {}", sku);
|
|
|
pushEnable = false;
|
|
|
}else {
|
|
|
pushSupplier = () -> msgService.noticeBuyerWhenSellerOnShelve(uids, tsog, productSupplier.get());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return PushDataNode.builder().pushEnable(pushEnable).pushSupplier(pushSupplier).build();
|
...
|
...
|
@@ -209,15 +225,25 @@ public class SellerNoticeFacade extends BaseNoticeFacade { |
|
|
|
|
|
public void pushMsg2BuyerWhenSellerChangePrice(SellerOrderGoods sog){
|
|
|
Integer sellerUid = sog.getUid();
|
|
|
//
|
|
|
Supplier<Product> productSupplier = () -> productMapper.selectByPrimaryKey(sog.getProductId());
|
|
|
PushDataNode pushDataNode = buildPushDataNode(sog, productSupplier);
|
|
|
if (pushDataNode.pushEnable){
|
|
|
pushDataNode.pushSupplier.get();
|
|
|
}else {
|
|
|
log.warn("pushMsg2BuyerWhenSellerChangePrice not match condition ,seller {} sku {}",
|
|
|
sellerUid, sog.getStorageId());
|
|
|
}
|
|
|
|
|
|
Supplier<SendMessageRspBo> supplier = ()->{
|
|
|
//
|
|
|
Supplier<Product> productSupplier = () -> productMapper.selectByPrimaryKey(sog.getProductId());
|
|
|
PushDataNode pushDataNode = buildPushDataNode(sog, productSupplier);
|
|
|
SendMessageRspBo bo = null;
|
|
|
if (pushDataNode.pushEnable){
|
|
|
bo = pushDataNode.pushSupplier.get();
|
|
|
}else {
|
|
|
log.warn("pushMsg2BuyerWhenSellerChangePrice not match condition ,seller {} sku {}",
|
|
|
sellerUid, sog.getStorageId());
|
|
|
}
|
|
|
return bo;
|
|
|
};
|
|
|
//uid not used in push method of baseNoticeFacade
|
|
|
newNotice(sellerUid).withLogPrefix("pushMsg2BuyerWhenSellerChangePrice")
|
|
|
.needSendPush(false)
|
|
|
.needSendSms(false)
|
|
|
.withPush(supplier).send();
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -233,7 +259,15 @@ public class SellerNoticeFacade extends BaseNoticeFacade { |
|
|
Integer productId = soldProduct.getProductId();
|
|
|
Product product = productMapper.selectByPrimaryKey(productId);
|
|
|
//
|
|
|
PushDataNode pushDataNode = buildPushDataNode(soldProduct, product);
|
|
|
Supplier<SendMessageRspBo> pushSupplier = ()->{
|
|
|
PushDataNode pushDataNode = buildPushDataNode(soldProduct, product);
|
|
|
SendMessageRspBo bo = null;
|
|
|
if (pushDataNode.pushEnable){
|
|
|
bo = pushDataNode.pushSupplier.get();
|
|
|
}
|
|
|
return bo;
|
|
|
};
|
|
|
|
|
|
newNotice(sellerUid)
|
|
|
.withLogPrefix("notice seller sale shelf")
|
|
|
.withInBox(() -> {
|
...
|
...
|
@@ -242,7 +276,7 @@ public class SellerNoticeFacade extends BaseNoticeFacade { |
|
|
String goodsTypeType = buildGoodsTypeTagForSeller(skupAttributes);
|
|
|
return buildInboxContent(InboxBusinessTypeEnum.SALE_SHELF, goodsTypeType, prdName, sizeName, productCode);
|
|
|
})
|
|
|
.withPushIf(pushDataNode.pushEnable, pushDataNode.pushSupplier)
|
|
|
.withPush(pushSupplier)
|
|
|
.send();
|
|
|
} catch (Exception e) {
|
|
|
log.warn("notice seller sale shelf fail, sellerUid {}, prdName {} ,sizeName {} ", sellerUid, prdName, sizeName, e);
|
...
|
...
|
@@ -1034,4 +1068,11 @@ public class SellerNoticeFacade extends BaseNoticeFacade { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public void pushSellerWhenBidOrderPaid(Integer sellerUid,Supplier<SendMessageRspBo> pushSupplier){
|
|
|
newNotice(sellerUid).withLogPrefix("pushSellerWhenBidOrderPaid").needSendSms(false)
|
|
|
.needSendInbox(false).withPush(pushSupplier)
|
|
|
.send();
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|