Authored by chenchao

add notice when on or off shelve

package com.yohoufo.order.service;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
import com.yohobuy.ufo.model.order.bo.DepositProductBo;
import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
... ... @@ -24,11 +25,13 @@ public interface DepositService {
// 上架
boolean changeSaleStatusOn(Integer uid, String depositCode, Integer skup);
// 下架
@Database(ForceMaster=true)
boolean changeSaleStatusOff(Integer uid, Integer skup);
// 批量上架
List<StorageDeposit> changeSaleStatusOnBatch(Integer uid, Integer storageId, List<Integer> skupList);
// 批量下架
@Database(ForceMaster=true)
List<Integer> changeSaleStatusOffBatch(Integer uid, List<Integer> skupList);
... ...
... ... @@ -108,14 +108,13 @@ public class SellerDownShelfTaskHandler extends AbstractSellerTaskHandler<SkupDo
//明细
addWalletDetail(uid, taskId, isSuper, sellerWallet, successOrders);
}else{
for (Integer skup : result.successSkups) {
try {
depositService.changeSaleStatusOff(uid, skup);
}catch (Exception ex){
log.warn("in batch off shelve 4 quick deliver prd fail , uid {} skup {}",
uid, skup, ex);
}
try {
depositService.changeSaleStatusOffBatch(uid, new ArrayList<>(result.successSkups));
}catch (Exception ex){
log.warn("in batch off shelve 4 quick deliver prd fail , uid {} skups {}",
uid, result.successSkups, ex);
}
}
//消息盒子
inboxNotify(uid, skupDtoMap);
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
import com.yohobuy.ufo.model.order.bo.DepositProductBo;
... ... @@ -16,17 +16,19 @@ 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.SellerOrderMapper;
import com.yohoufo.dal.order.StorageDepositMapper;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.dal.user.model.ZhiMaCert;
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;
import com.yohoufo.order.controller.DepositController;
import com.yohoufo.order.model.response.AppraiseAddressResp;
import com.yohoufo.order.service.DepositService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.SellerNoticeFacade;
import com.yohoufo.order.service.seller.SkupService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -40,7 +42,7 @@ import java.util.stream.Collectors;
@Service
public class DepositServiceImpl implements DepositService {
private final Logger LOGGER = LoggerFactory.getLogger(DepositServiceImpl.class);
private final Logger LOGGER = LoggerUtils.getSellerOrderLogger();
@Autowired
private ControllerCacheAop cacheAop;
... ... @@ -52,9 +54,6 @@ public class DepositServiceImpl implements DepositService {
private StorageDepositMapper storageDepositMapper;
@Autowired
private SellerOrderMapper sellerOrderMapper;
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
... ... @@ -71,6 +70,8 @@ public class DepositServiceImpl implements DepositService {
@Autowired
private SkupService skupService;
@Autowired
private SellerNoticeFacade sellerNoticeFacade;
private static final int DEPOSIT_MAX_TIME = 45 * 24 * 60 * 60;
... ... @@ -245,16 +246,30 @@ public class DepositServiceImpl implements DepositService {
}
// 下架
@Override
@Database(ForceMaster=true)
public boolean changeSaleStatusOff(Integer uid, Integer skup) {
LOGGER.info("changeSaleStatusOff uid {}, skup is {}", uid, skup);
boolean result = storageDepositMapper.changeSaleStatusOff(uid, skup) == 1;
if (result) {
StorageDeposit sd = storageDepositMapper.queryByOwnerSkup(uid, skup);
clearCache(uid, sd.getProductId(), sd.getStorageId());
StorageDeposit sd = doChangeSaleStatusOff(uid, skup);
boolean result;
if (result = Objects.nonNull(sd)) {
LOGGER.info("changeSaleStatusOff ready 2 processAfterOffShelve uid {} skup {} sample {}",
uid, skup, sd);
processAfterOffShelve(uid, sd);
}
return result;
}
private StorageDeposit doChangeSaleStatusOff(Integer uid, Integer newSkup){
int result = storageDepositMapper.changeSaleStatusOff(uid, newSkup) ;
LOGGER.info("doChangeSaleStatusOff uid {}, newSkup {} storageDepositMapper.changeSaleStatusOff result {}",
uid, newSkup, result);
StorageDeposit sd = null;
if (result>0) {
sd = storageDepositMapper.queryByOwnerSkup(uid, newSkup);
}
return sd;
}
// 批量上架
public List<StorageDeposit> changeSaleStatusOnBatch(Integer uid, Integer storageId, List<Integer> skupList) {
... ... @@ -278,17 +293,34 @@ public class DepositServiceImpl implements DepositService {
}
// 批量下架
@Database(ForceMaster=true)
public List<Integer> changeSaleStatusOffBatch(Integer uid, List<Integer> skupList) {
List<Integer> successList = new ArrayList<>();
StorageDeposit sample = null;
StorageDeposit sd = null;
for (Integer skup : skupList) {
if (changeSaleStatusOff(uid, skup)) {
if (Objects.nonNull(sd=doChangeSaleStatusOff(uid, skup))) {
LOGGER.info("changeSaleStatusOff success! uid {}, skup is {}", uid, skup);
successList.add(skup);
sample = sd;
}
}
if (Objects.nonNull(sample)){
LOGGER.info("changeSaleStatusOffBatch ready 2 processAfterOffShelve uid {} skupList {} sample {}",
uid, skupList, sample);
processAfterOffShelve(uid, sample);
}
return successList;
}
private void processAfterOffShelve(int uid, StorageDeposit sd ){
clearCache(uid, sd.getProductId(), sd.getStorageId());
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(sd.getNewSkup());
sellerNoticeFacade.depositGoodsSaleUnShelf(uid, psog.getProductName(), psog.getSizeName(), psog.getProductId());
}
/**
* 转卖
* @param uid
... ... @@ -412,7 +444,7 @@ public class DepositServiceImpl implements DepositService {
Method queryUserStorageCount = DepositController.class.getMethod("queryUserStorageCount", new Class[]{Integer.class});
cacheAop.clearCache(queryUserStorageCount, new Object[]{uid});
} catch (Exception e) {
LOGGER.error("删除用户寄存缓存失败!", e);
LOGGER.warn("删除用户寄存缓存失败!", e);
}
}
... ...
... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service.seller.quickDeliver;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.ProductInfo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.SellerOrderListType;
... ... @@ -23,6 +24,7 @@ import com.yohoufo.order.service.DepositService;
import com.yohoufo.order.service.handler.SellerOrderSubmitHandler;
import com.yohoufo.order.service.impl.SkupListService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.SellerNoticeFacade;
import com.yohoufo.order.service.seller.orderMeta.SellerOrderMetaService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -71,6 +73,9 @@ public class QuickDeliverGoodsService {
@Autowired
private DepositService depositService;
@Autowired
private SellerNoticeFacade sellerNoticeFacade;
public DepositPublishResp publish(QuickDeliverOrderSubmitReq req){
QuickDeliverOrderContext qdoc = quickDeliverPublishProcessor.buildPublishCtx(req);
... ... @@ -121,7 +126,9 @@ public class QuickDeliverGoodsService {
syncPrd(context, depositCode);
successNum++;
}
//在for循环中被用作值传递,部分数据会有变化,使用时需要注意动态变化的属性
GoodsInfo goodsInfo = context.getSoldProduct();
sellerNoticeFacade.depositGoodsSaleShelf(uid, goodsInfo.getProductName(), goodsInfo.getSizeName(), goodsInfo.getProductId());
DepositPublishResp resp = DepositPublishResp.builder().successNum(successNum)
.build();
return resp;
... ...