|
|
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);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|