Authored by chenchao

Merge branch 'master' of http://git.yoho.cn/ufo/ufo-service-model

# Conflicts:
#	users/src/main/java/com/yohobuy/ufo/model/enums/InboxBusinessTypeEnum.java
... ... @@ -35,7 +35,7 @@
<sql id="Base_Column_List" >
id, product_id, goods_id, storage_id, deposit_code, shelf_code, owner_uid, order_code,
skup, status, order_status, update_time, create_time, deposit_start_time, deposit_end_time,
edit_pid, del_status, out_type
edit_pid, del_status, out_type, new_order_code, new_skup
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ...
... ... @@ -38,6 +38,6 @@ public class BuyerOrderConfirmDelayMsgConsumer implements YhConsumer {
OrderRequest req = OrderRequest.builder().uid(buyerUid).orderCode(orderCode).build();
buyerOrderService.confirm(req);
logger.info("topic {}, msg {} finish", getMessageTopic(), buyerConfirmEvent);
logger.info("topic {}, msg {} finish", getMessageTopic(), o);
}
}
... ...
... ... @@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.utils.DateUtil;
... ... @@ -49,6 +46,11 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static com.yohobuy.ufo.model.order.common.EnumExpressDataOperateTransferCode.judge_pass;
import static com.yohobuy.ufo.model.order.common.EnumExpressDataOperateTransferCode.platform_receive;
import static com.yohobuy.ufo.model.order.common.EnumExpressDataType.operate_transfer;
import static com.yohobuy.ufo.model.order.common.EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
@Service
public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
... ... @@ -95,6 +97,9 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
@Autowired
private AppraiseService appraiseService;
@Autowired
private IExpressInfoService expressInfoService;
private boolean isDepositWithQuickDeliverGoods(int uid, long orderCode, Integer oa){
BuyerOrderGoods pbog = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(pbog.getSkup());
... ... @@ -230,6 +235,23 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
// notice
inBoxFacade.noticeWhenQuickDeliverOrderPaid(buyerOrder.getUid(), buyerOrder.getOrderCode(), sellerOrderGoods);
Integer sellerUid = buyerOrder.getSellerUid();
Integer buyerUid = buyerOrder.getUid();
Long orderCode = buyerOrder.getOrderCode();
Integer skup = sellerOrderGoods.getId();
if (BuyerOrderUtils.isQuickDeliver(buyerOrder.getAttributes())) {
try {
// 插入物流调拨信息
expressInfoService.saveOperateTransferExpressInfo(buyerUid, orderCode,
EXPRESS_TYPE_JUDGE_CENTER.getCode(), operate_transfer, platform_receive);
expressInfoService.saveOperateTransferExpressInfo(buyerUid, orderCode,
EXPRESS_TYPE_JUDGE_CENTER.getCode(), operate_transfer, judge_pass);
} catch (Exception ex) {
logger.warn("pay successful, processQuickDeliverOrder invoke save transfer express info fail, sellerUid {}, buyerUid {},orderCode {},skup {}",
sellerUid, buyerUid, orderCode, skup);
}
}
}
@Override
... ...
... ... @@ -60,4 +60,11 @@ public interface DepositService {
* @param depositCode
*/
void clearCacheByDepositCode(Integer uid, String depositCode);
/**
* 根据货号查询库存
* @param depositCode
* @return
*/
StorageDeposit selectStorageDeposit(Integer uid, String depositCode);
}
... ...
... ... @@ -35,6 +35,8 @@ public interface IExpressInfoService {
void deliverToDepot(Integer sellerUid,Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum);
/**
* 卖家发货的商品,买家取消后,鉴定中心寄回商品给卖家
* @param sellerUid 卖家uid
... ...
... ... @@ -7,20 +7,25 @@ import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.DepositOrder;
import com.yohoufo.dal.order.model.EntrySellerRechargeOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.StorageDeposit;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.model.response.PrepayResponse;
import com.yohoufo.order.service.AbstractOrderPaymentService;
import com.yohoufo.order.service.DepositService;
import com.yohoufo.order.service.deposit.DepositOrderService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.swing.text.html.Option;
import java.util.Objects;
import java.util.Optional;
@Service
public class DepositOrderPaymentService extends AbstractOrderPaymentService {
... ... @@ -32,6 +37,12 @@ public class DepositOrderPaymentService extends AbstractOrderPaymentService {
@Autowired
private DepositService depositService;
@Autowired
protected InBoxFacade inBoxFacade;
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Override
public boolean isTimeoutCancelStatus(OrderInfo orderInfo) {
return false;
... ... @@ -151,6 +162,19 @@ public class DepositOrderPaymentService extends AbstractOrderPaymentService {
if (result != 1) {
logger.error("depositService.changeStorageStatus find wrong, depositCode is {}, result is {}", depositOrder.getDepositCode(), result);
return;
} else {
try {
logger.info("depositService.notify begin, orderInfo is {}", orderInfo);
StorageDeposit deposit = depositService.selectStorageDeposit(depositOrder.getUid(), depositOrder.getDepositCode());
SellerOrderGoods psog = Optional.ofNullable(deposit).map(StorageDeposit::getSkup)
.map(sellerOrderGoodsMapper::selectByPrimaryKey).orElse(null);
inBoxFacade.recallDepositnotify(deposit.getOwnerUid(), psog); // 更新待拣货状态成功后,发通知
} catch (Exception e) {
logger.error("depositService.notify find wrong, orderInfo is {}", orderInfo);
}
}
}
... ...
... ... @@ -13,8 +13,10 @@ import com.yohoufo.common.cache.ControllerCacheAop;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.StorageDepositMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.StorageDeposit;
import com.yohoufo.dal.order.model.StorageDepositCount;
... ... @@ -52,6 +54,9 @@ public class DepositServiceImpl implements DepositService {
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
private BuyerOrderMapper buyerOrderMapper;
@Autowired
private UfoServiceCaller ufoServiceCaller;
private static final int DEPOSIT_MAX_TIME = 45 * 24 * 60 * 60;
... ... @@ -107,6 +112,8 @@ public class DepositServiceImpl implements DepositService {
}
// 召回或者到期退回的
List<StorageDeposit> depositList = storageDepositMapper.queryUserDopositBack(uid, (page - 1) * limit, limit);
List<BuyerOrder> buyerGoodsList = buyerOrderMapper.selectByOrderCodes(depositList.stream().map(StorageDeposit::getOrderCode).collect(Collectors.toList()), null);
Map<Long, BuyerOrder> buyerGoodsMap = buyerGoodsList.stream().map(Function.identity()).collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity()));
List<Integer> skupList = depositList.stream().map(StorageDeposit::getSkup).collect(Collectors.toList());
List<SellerOrderGoods> goodsList = sellerOrderGoodsMapper.selectBySkups(skupList);
Map<Integer, SellerOrderGoods> goodsMap = goodsList.stream().map(Function.identity()).collect(Collectors.toMap(SellerOrderGoods::getId, Function.identity()));
... ... @@ -120,7 +127,10 @@ public class DepositServiceImpl implements DepositService {
bo.setColorName(goods.getColorName());
bo.setSizeName(goods.getSizeName());
bo.setPic(ImageUrlAssist.getAllProductPicUrl(goods.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
bo.setPrice(goods.getGoodsPrice().toString());
BuyerOrder buyerOrder = buyerGoodsMap.get(buyerGoodsMap.get(depo.getOrderCode()));
if (buyerOrder != null) {
bo.setPrice(buyerOrder.getAmount().toString());
}
bo.setDepositStatusName(getBackStatusName(depo.getStatus()));
bo.setDepositCode(depo.getDepositCode());
}
... ... @@ -368,6 +378,15 @@ public class DepositServiceImpl implements DepositService {
}
/**
* 根据货号查询库存
* @param depositCode
* @return
*/
public StorageDeposit selectStorageDeposit(Integer uid, String depositCode) {
return storageDepositMapper.queryByDepositCode(uid, depositCode);
}
/**
* Do 转 Vo
* @param storageDeposit
* @return
... ...
... ... @@ -1872,6 +1872,41 @@ public class InBoxFacade {
appraisePassNoticeSeller(buyerUid,orderCode, sog);
}
// 召回的
public void recallDepositnotify(int uid, SellerOrderGoods sog) {
if (null == sog) {
logger.warn("InBoxFacade recallDepositnotify error SellerOrderGoods is null, uid {}", uid);
return;
}
String prdName = sog.getProductName();
String sizeName = sog.getSizeName();
try {
executorService.execute(()->{
Product product = productMapper.selectByPrimaryKey(sog.getProductId());
String productCode = product.getProductCode();
InboxBusinessTypeEnum ibtOfSeller = InboxBusinessTypeEnum.NOTICE_SELLER_DEPOSIT_RECALL;
String paramsOfSeller = buildParams(prdName, sizeName,productCode);
InboxReqVO reqOfSeller = buildInboxReqVO(uid, paramsOfSeller, ibtOfSeller);
InBoxResponse respOfSeller = inBoxSDK.addInbox(reqOfSeller);
logger.info("record recallDepositnotify to seller inbox msg, uid {}, sog {} resp {}",
uid, sog, respOfSeller);
String phone = userProxyService.getMobile(uid);
if (StringUtils.isBlank(phone)){
logger.warn("in recallDepositnotify sms fail, uid {} sog {}", uid, sog);
return;
}
List<String> mobileList = Arrays.asList(phone);
String content= getReplacedContent(InboxBusinessTypeEnum.SMS_NOTIFY_SELLER_DEPOSIT_RECALL.getContent(),prdName, sizeName, productCode);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record recallDepositnotify inbox sms msg, uid {}, sog {}", uid, sog);
});
} catch (Exception e) {
logger.warn("InBoxFacade recallDepositnotify error inbox msg, uid {}, sog {}", uid, sog, e);
}
}
public InboxReqVO buildInboxReqVO(int uid, String params, InboxBusinessTypeEnum ibt) {
InboxReqVO req = new InboxReqVO();
req.setType(ibt.getType());
... ...
package com.yohoufo.order.service.proxy;
import com.yoho.message.sdk.service.ufo.IUFOSendService;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.product.ProductMapper;
import com.yohoufo.inboxclient.sdk.InBoxSDK;
import com.yohoufo.order.utils.PubThreadFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@Service
public class SellerOrderMessage {
private ExecutorService executorService;
@Autowired
private InBoxSDK inBoxSDK;
@Autowired
private SendSmsService sendSmsService;
@Autowired
private UserProxyService userProxyService;
@Autowired
private ProductMapper productMapper;
@Autowired
private SellerOrderMapper sellerOrderMapper;
@Autowired
private IUFOSendService ufoSendService;
@PostConstruct
public void init() {
executorService = new ThreadPoolExecutor(5, 10,
60, TimeUnit.SECONDS,
new ArrayBlockingQueue<>(1000),
new PubThreadFactory("seller-order-message"));
}
}
... ...
... ... @@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
... ... @@ -451,6 +452,8 @@ public class ProductController {
cacheAop.clearCache(
ProductController.class.getMethod("queryProductDetailById", new Class[]{Integer.class}),
new Object[]{productId});
Method queryLeastFlashSalePrice = ProductController.class.getMethod("queryLeastFlashSalePrice", new Class[]{Integer.class});
cacheAop.clearCache(queryLeastFlashSalePrice, new Object[]{productId});
Integer storageId = sp.getStorageId();
// sku最低价
LOG.info("clearCache queryStorageLeastprice skup = {}, ", skup);
... ... @@ -506,6 +509,8 @@ public class ProductController {
cacheAop.clearCache(
ProductController.class.getMethod("queryProductInStockNewBriefById", new Class[]{Integer.class}),
new Object[]{productId});
Method queryLeastFlashSalePrice = ProductController.class.getMethod("queryLeastFlashSalePrice", new Class[]{Integer.class});
cacheAop.clearCache(queryLeastFlashSalePrice, new Object[]{productId});
} catch (Exception e) {
LOG.error("删除商品详情缓存失败!", e);
}
... ... @@ -528,6 +533,8 @@ public class ProductController {
cacheAop.clearCache(
ProductController.class.getMethod("queryProductInStockNewBriefById", new Class[]{Integer.class}),
new Object[]{productId});
Method queryLeastFlashSalePrice = ProductController.class.getMethod("queryLeastFlashSalePrice", new Class[]{Integer.class});
cacheAop.clearCache(queryLeastFlashSalePrice, new Object[]{productId});
}
}
if (CollectionUtils.isNotEmpty(storageIdList)) {
... ...