...
|
...
|
@@ -26,10 +26,13 @@ import com.yoho.product.model.SecondhandImages; |
|
|
import com.yoho.product.model.SecondhandInfo;
|
|
|
import com.yoho.product.model.SecondhandReq;
|
|
|
import com.yoho.product.model.SecondhandRsp;
|
|
|
import com.yoho.ufo.dal.GoodsImagesMapper;
|
|
|
import com.yoho.ufo.dal.ProductMapper;
|
|
|
import com.yoho.ufo.dal.StoragePriceMapper;
|
|
|
import com.yoho.ufo.dal.model.GoodsImages;
|
|
|
import com.yoho.ufo.dal.model.Product;
|
|
|
import com.yoho.ufo.dal.model.StoragePrice;
|
|
|
import com.yoho.ufo.exception.CommonException;
|
|
|
import com.yoho.ufo.service.ISecondhandProductService;
|
|
|
import com.yoho.ufo.service.model.PageResponseBO;
|
|
|
import com.yoho.ufo.util.DateUtil;
|
...
|
...
|
@@ -62,6 +65,9 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
private SecondhandFlawMapper secondhandFlawMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private GoodsImagesMapper goodsImagesMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private ServiceCaller serviceCaller;
|
|
|
|
|
|
private static final Integer STATUS_NEW = 0;
|
...
|
...
|
@@ -75,10 +81,10 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
@Override
|
|
|
public Map<String, Integer> getCountByStatus(){
|
|
|
|
|
|
int totalNum = secondhandInfoMapper.selectCountByStatus(null);
|
|
|
int toBeAuditedNum = secondhandInfoMapper.selectCountByStatus(STATUS_WAIT_TO_BE_AUDITED);
|
|
|
int auditPassNum = secondhandInfoMapper.selectCountByStatus(STATUS_AUDIT_PASS);
|
|
|
int auditRejectNum = secondhandInfoMapper.selectCountByStatus(STATUS_AUDIT_REJECT);
|
|
|
int totalNum = storagePriceMapper.selectSecondCntByStatus(null);
|
|
|
int toBeAuditedNum = storagePriceMapper.selectSecondCntByStatus(STATUS_WAIT_TO_BE_AUDITED);
|
|
|
int auditPassNum = storagePriceMapper.selectSecondCntByStatus(STATUS_AUDIT_PASS);
|
|
|
int auditRejectNum = storagePriceMapper.selectSecondCntByStatus(STATUS_AUDIT_REJECT);
|
|
|
|
|
|
Map<String, Integer> resultMap = Maps.newHashMap();
|
|
|
resultMap.put("totalNum", totalNum);
|
...
|
...
|
@@ -92,23 +98,26 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
@Override
|
|
|
public PageResponseBO<SecondhandRsp> querySecondhandSkupList(SecondhandReq req) {
|
|
|
|
|
|
int total = secondhandInfoMapper.selectTotalByCondition(req);
|
|
|
int total = storagePriceMapper.selectSecondTotalByCondition(req);
|
|
|
if(total == 0) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
List<SecondhandInfo> infoList = secondhandInfoMapper.selectByCondition(req);
|
|
|
if(CollectionUtils.isEmpty(infoList)) {
|
|
|
List<StoragePrice> storagePriceList = storagePriceMapper.selectSecondByCondition(req);
|
|
|
if(CollectionUtils.isEmpty(storagePriceList)) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
List<Integer> skupList = storagePriceList.stream().map(StoragePrice::getSkup).collect(Collectors.toList());
|
|
|
|
|
|
//查询secondhand_info
|
|
|
List<SecondhandInfo> infoList = secondhandInfoMapper.selectBySkups(skupList);
|
|
|
|
|
|
//查询secondhand_images
|
|
|
List<Integer> skupList = infoList.stream().map(SecondhandInfo::getSkup).collect(Collectors.toList());
|
|
|
List<SecondhandImages> imageList = secondhandImagesMapper.selectBySkups(skupList);
|
|
|
Map<Integer, List<SecondhandImages>> skupImageMap = imageList.stream().collect(Collectors.groupingBy(SecondhandImages::getSkup));
|
|
|
|
|
|
//查询storage_price
|
|
|
List<StoragePrice> storagePriceList = storagePriceMapper.selectBySkupList(skupList);
|
|
|
Map<Integer, StoragePrice> storagePriceMap = storagePriceList.stream().collect(Collectors.toMap(StoragePrice::getSkup, s->s));
|
|
|
|
|
|
//查询seller_order_goods
|
...
|
...
|
@@ -125,8 +134,13 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
List<SecondhandFlaw> flawList = secondhandFlawMapper.selectBatchByIds(getFlawIdList(flawIdStrList));
|
|
|
Map<Integer, String> flawMap = flawList.stream().collect(Collectors.toMap(SecondhandFlaw::getId, SecondhandFlaw::getName));
|
|
|
|
|
|
//查询goods_images
|
|
|
List<Integer> goodsIdList = storagePriceList.stream().map(StoragePrice::getGoodsId).collect(Collectors.toList());
|
|
|
List<GoodsImages> goodsImagesList = goodsImagesMapper.selectDefaultByGoodsIdList(goodsIdList);
|
|
|
Map<Integer, String> goodsIdImageMap = goodsImagesList.stream().collect(Collectors.toMap(GoodsImages::getGoodsId, GoodsImages::getImageUrl));
|
|
|
|
|
|
//组装
|
|
|
List<SecondhandRsp> respList = convertToResp(infoList, skupImageMap, storagePriceMap, sellerGoodsMap, productIdNameMap, flawMap);
|
|
|
List<SecondhandRsp> respList = convertToResp(infoList, skupImageMap, storagePriceMap, sellerGoodsMap, productIdNameMap, flawMap, goodsIdImageMap);
|
|
|
|
|
|
PageResponseBO<SecondhandRsp> result=new PageResponseBO<>();
|
|
|
result.setList(respList);
|
...
|
...
|
@@ -139,10 +153,15 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
|
|
|
@Override
|
|
|
public int updateStatus(SecondhandReq req) {
|
|
|
//查询storage_price中status
|
|
|
Integer status = storagePriceMapper.selectBySkup(req.getSkup()).getStatus();
|
|
|
if(!ProductSkupStatusEnum.CHECKING.getStatus().equals(status)) {//如果不是待审核状态,直接返回
|
|
|
throw new CommonException(400, "不是待审核状态,当前状态是"+ProductSkupStatusEnum.getTypeName(status));
|
|
|
}
|
|
|
|
|
|
SecondhandInfo auditInfo = new SecondhandInfo();
|
|
|
UserHelper userInfo = new UserHelper();
|
|
|
auditInfo.setSkup(req.getSkup());
|
|
|
auditInfo.setStatus(req.getStatus());
|
|
|
auditInfo.setRejectReason(req.getRejectReason());
|
|
|
auditInfo.setAuditName(userInfo.getUserName());
|
|
|
auditInfo.setAuditUid(userInfo.getUserId());
|
...
|
...
|
@@ -152,7 +171,7 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
return num;
|
|
|
}
|
|
|
//更新storage_price
|
|
|
num = storagePriceMapper.updateStatusBySkup(req.getStatus(), req.getSkup());
|
|
|
num = storagePriceMapper.updateSecondhandStatusBySkup(req.getStatus(), req.getSkup());
|
|
|
if(num == 0) {
|
|
|
return num;
|
|
|
}
|
...
|
...
|
@@ -204,7 +223,7 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
|
|
|
private List<SecondhandRsp> convertToResp(List<SecondhandInfo> infoList, Map<Integer, List<SecondhandImages>> skupImageMap,
|
|
|
Map<Integer, StoragePrice> storagePriceMap, Map<Integer, SellerOrderGoods> sellerGoodsMap,
|
|
|
Map<Integer, String> productIdNameMap, Map<Integer, String> flawMap){
|
|
|
Map<Integer, String> productIdNameMap, Map<Integer, String> flawMap, Map<Integer, String> goodsIdImageMap){
|
|
|
List<SecondhandRsp> respList = Lists.newArrayList();
|
|
|
for(SecondhandInfo item : infoList) {
|
|
|
SecondhandRsp rsp = new SecondhandRsp();
|
...
|
...
|
@@ -225,13 +244,13 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
if(null == sellerGoods) {
|
|
|
continue;
|
|
|
}
|
|
|
rsp.setProductImage(ImagesHelper.getImageAbsoluteUrl(sellerGoods.getImageUrl(), "goodsimg"));
|
|
|
rsp.setProductImage(ImagesHelper.getImageAbsoluteUrl(goodsIdImageMap.get(storagePrice.getGoodsId()), "goodsimg"));
|
|
|
rsp.setColorName(sellerGoods.getColorName());
|
|
|
rsp.setSizeName(sellerGoods.getSizeName());
|
|
|
rsp.setSellerUid(storagePrice.getSellerUid());
|
|
|
rsp.setPrice(String.valueOf(storagePrice.getPrice()));
|
|
|
rsp.setStatus(item.getStatus());
|
|
|
rsp.setStatusStr(ProductSkupStatusEnum.getTypeName(item.getStatus()));
|
|
|
rsp.setStatus(storagePrice.getStatus());
|
|
|
// rsp.setStatusStr(ProductSkupStatusEnum.getTypeName(storagePrice.getStatus()));
|
|
|
rsp.setCreateTimeStr(DateUtil.getDateFormatFromInt(item.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
rsp.setAuditTimeStr(null == item.getAuditTime() ? "" : DateUtil.getDateFormatFromInt(item.getAuditTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
rsp.setAuditName(null == item.getAuditName() ? "" : item.getAuditName());
|
...
|
...
|
|