|
@@ -26,10 +26,13 @@ import com.yoho.product.model.SecondhandImages; |
|
@@ -26,10 +26,13 @@ import com.yoho.product.model.SecondhandImages; |
26
|
import com.yoho.product.model.SecondhandInfo;
|
26
|
import com.yoho.product.model.SecondhandInfo;
|
27
|
import com.yoho.product.model.SecondhandReq;
|
27
|
import com.yoho.product.model.SecondhandReq;
|
28
|
import com.yoho.product.model.SecondhandRsp;
|
28
|
import com.yoho.product.model.SecondhandRsp;
|
|
|
29
|
+import com.yoho.ufo.dal.GoodsImagesMapper;
|
29
|
import com.yoho.ufo.dal.ProductMapper;
|
30
|
import com.yoho.ufo.dal.ProductMapper;
|
30
|
import com.yoho.ufo.dal.StoragePriceMapper;
|
31
|
import com.yoho.ufo.dal.StoragePriceMapper;
|
|
|
32
|
+import com.yoho.ufo.dal.model.GoodsImages;
|
31
|
import com.yoho.ufo.dal.model.Product;
|
33
|
import com.yoho.ufo.dal.model.Product;
|
32
|
import com.yoho.ufo.dal.model.StoragePrice;
|
34
|
import com.yoho.ufo.dal.model.StoragePrice;
|
|
|
35
|
+import com.yoho.ufo.exception.CommonException;
|
33
|
import com.yoho.ufo.service.ISecondhandProductService;
|
36
|
import com.yoho.ufo.service.ISecondhandProductService;
|
34
|
import com.yoho.ufo.service.model.PageResponseBO;
|
37
|
import com.yoho.ufo.service.model.PageResponseBO;
|
35
|
import com.yoho.ufo.util.DateUtil;
|
38
|
import com.yoho.ufo.util.DateUtil;
|
|
@@ -62,6 +65,9 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
@@ -62,6 +65,9 @@ public class SecondhandProductService implements ISecondhandProductService{ |
62
|
private SecondhandFlawMapper secondhandFlawMapper;
|
65
|
private SecondhandFlawMapper secondhandFlawMapper;
|
63
|
|
66
|
|
64
|
@Autowired
|
67
|
@Autowired
|
|
|
68
|
+ private GoodsImagesMapper goodsImagesMapper;
|
|
|
69
|
+
|
|
|
70
|
+ @Autowired
|
65
|
private ServiceCaller serviceCaller;
|
71
|
private ServiceCaller serviceCaller;
|
66
|
|
72
|
|
67
|
private static final Integer STATUS_NEW = 0;
|
73
|
private static final Integer STATUS_NEW = 0;
|
|
@@ -75,10 +81,10 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
@@ -75,10 +81,10 @@ public class SecondhandProductService implements ISecondhandProductService{ |
75
|
@Override
|
81
|
@Override
|
76
|
public Map<String, Integer> getCountByStatus(){
|
82
|
public Map<String, Integer> getCountByStatus(){
|
77
|
|
83
|
|
78
|
- int totalNum = secondhandInfoMapper.selectCountByStatus(null);
|
|
|
79
|
- int toBeAuditedNum = secondhandInfoMapper.selectCountByStatus(STATUS_WAIT_TO_BE_AUDITED);
|
|
|
80
|
- int auditPassNum = secondhandInfoMapper.selectCountByStatus(STATUS_AUDIT_PASS);
|
|
|
81
|
- int auditRejectNum = secondhandInfoMapper.selectCountByStatus(STATUS_AUDIT_REJECT);
|
84
|
+ int totalNum = storagePriceMapper.selectSecondCntByStatus(null);
|
|
|
85
|
+ int toBeAuditedNum = storagePriceMapper.selectSecondCntByStatus(STATUS_WAIT_TO_BE_AUDITED);
|
|
|
86
|
+ int auditPassNum = storagePriceMapper.selectSecondCntByStatus(STATUS_AUDIT_PASS);
|
|
|
87
|
+ int auditRejectNum = storagePriceMapper.selectSecondCntByStatus(STATUS_AUDIT_REJECT);
|
82
|
|
88
|
|
83
|
Map<String, Integer> resultMap = Maps.newHashMap();
|
89
|
Map<String, Integer> resultMap = Maps.newHashMap();
|
84
|
resultMap.put("totalNum", totalNum);
|
90
|
resultMap.put("totalNum", totalNum);
|
|
@@ -92,23 +98,26 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
@@ -92,23 +98,26 @@ public class SecondhandProductService implements ISecondhandProductService{ |
92
|
@Override
|
98
|
@Override
|
93
|
public PageResponseBO<SecondhandRsp> querySecondhandSkupList(SecondhandReq req) {
|
99
|
public PageResponseBO<SecondhandRsp> querySecondhandSkupList(SecondhandReq req) {
|
94
|
|
100
|
|
95
|
- int total = secondhandInfoMapper.selectTotalByCondition(req);
|
101
|
+ int total = storagePriceMapper.selectSecondTotalByCondition(req);
|
96
|
if(total == 0) {
|
102
|
if(total == 0) {
|
97
|
return null;
|
103
|
return null;
|
98
|
}
|
104
|
}
|
99
|
|
105
|
|
100
|
- List<SecondhandInfo> infoList = secondhandInfoMapper.selectByCondition(req);
|
|
|
101
|
- if(CollectionUtils.isEmpty(infoList)) {
|
106
|
+ List<StoragePrice> storagePriceList = storagePriceMapper.selectSecondByCondition(req);
|
|
|
107
|
+ if(CollectionUtils.isEmpty(storagePriceList)) {
|
102
|
return null;
|
108
|
return null;
|
103
|
}
|
109
|
}
|
104
|
|
110
|
|
|
|
111
|
+ List<Integer> skupList = storagePriceList.stream().map(StoragePrice::getSkup).collect(Collectors.toList());
|
|
|
112
|
+
|
|
|
113
|
+ //查询secondhand_info
|
|
|
114
|
+ List<SecondhandInfo> infoList = secondhandInfoMapper.selectBySkups(skupList);
|
|
|
115
|
+
|
105
|
//查询secondhand_images
|
116
|
//查询secondhand_images
|
106
|
- List<Integer> skupList = infoList.stream().map(SecondhandInfo::getSkup).collect(Collectors.toList());
|
|
|
107
|
List<SecondhandImages> imageList = secondhandImagesMapper.selectBySkups(skupList);
|
117
|
List<SecondhandImages> imageList = secondhandImagesMapper.selectBySkups(skupList);
|
108
|
Map<Integer, List<SecondhandImages>> skupImageMap = imageList.stream().collect(Collectors.groupingBy(SecondhandImages::getSkup));
|
118
|
Map<Integer, List<SecondhandImages>> skupImageMap = imageList.stream().collect(Collectors.groupingBy(SecondhandImages::getSkup));
|
109
|
|
119
|
|
110
|
//查询storage_price
|
120
|
//查询storage_price
|
111
|
- List<StoragePrice> storagePriceList = storagePriceMapper.selectBySkupList(skupList);
|
|
|
112
|
Map<Integer, StoragePrice> storagePriceMap = storagePriceList.stream().collect(Collectors.toMap(StoragePrice::getSkup, s->s));
|
121
|
Map<Integer, StoragePrice> storagePriceMap = storagePriceList.stream().collect(Collectors.toMap(StoragePrice::getSkup, s->s));
|
113
|
|
122
|
|
114
|
//查询seller_order_goods
|
123
|
//查询seller_order_goods
|
|
@@ -125,8 +134,13 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
@@ -125,8 +134,13 @@ public class SecondhandProductService implements ISecondhandProductService{ |
125
|
List<SecondhandFlaw> flawList = secondhandFlawMapper.selectBatchByIds(getFlawIdList(flawIdStrList));
|
134
|
List<SecondhandFlaw> flawList = secondhandFlawMapper.selectBatchByIds(getFlawIdList(flawIdStrList));
|
126
|
Map<Integer, String> flawMap = flawList.stream().collect(Collectors.toMap(SecondhandFlaw::getId, SecondhandFlaw::getName));
|
135
|
Map<Integer, String> flawMap = flawList.stream().collect(Collectors.toMap(SecondhandFlaw::getId, SecondhandFlaw::getName));
|
127
|
|
136
|
|
|
|
137
|
+ //查询goods_images
|
|
|
138
|
+ List<Integer> goodsIdList = storagePriceList.stream().map(StoragePrice::getGoodsId).collect(Collectors.toList());
|
|
|
139
|
+ List<GoodsImages> goodsImagesList = goodsImagesMapper.selectDefaultByGoodsIdList(goodsIdList);
|
|
|
140
|
+ Map<Integer, String> goodsIdImageMap = goodsImagesList.stream().collect(Collectors.toMap(GoodsImages::getGoodsId, GoodsImages::getImageUrl));
|
|
|
141
|
+
|
128
|
//组装
|
142
|
//组装
|
129
|
- List<SecondhandRsp> respList = convertToResp(infoList, skupImageMap, storagePriceMap, sellerGoodsMap, productIdNameMap, flawMap);
|
143
|
+ List<SecondhandRsp> respList = convertToResp(infoList, skupImageMap, storagePriceMap, sellerGoodsMap, productIdNameMap, flawMap, goodsIdImageMap);
|
130
|
|
144
|
|
131
|
PageResponseBO<SecondhandRsp> result=new PageResponseBO<>();
|
145
|
PageResponseBO<SecondhandRsp> result=new PageResponseBO<>();
|
132
|
result.setList(respList);
|
146
|
result.setList(respList);
|
|
@@ -139,10 +153,15 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
@@ -139,10 +153,15 @@ public class SecondhandProductService implements ISecondhandProductService{ |
139
|
|
153
|
|
140
|
@Override
|
154
|
@Override
|
141
|
public int updateStatus(SecondhandReq req) {
|
155
|
public int updateStatus(SecondhandReq req) {
|
|
|
156
|
+ //查询storage_price中status
|
|
|
157
|
+ Integer status = storagePriceMapper.selectBySkup(req.getSkup()).getStatus();
|
|
|
158
|
+ if(!ProductSkupStatusEnum.CHECKING.getStatus().equals(status)) {//如果不是待审核状态,直接返回
|
|
|
159
|
+ throw new CommonException(400, "不是待审核状态,当前状态是"+ProductSkupStatusEnum.getTypeName(status));
|
|
|
160
|
+ }
|
|
|
161
|
+
|
142
|
SecondhandInfo auditInfo = new SecondhandInfo();
|
162
|
SecondhandInfo auditInfo = new SecondhandInfo();
|
143
|
UserHelper userInfo = new UserHelper();
|
163
|
UserHelper userInfo = new UserHelper();
|
144
|
auditInfo.setSkup(req.getSkup());
|
164
|
auditInfo.setSkup(req.getSkup());
|
145
|
- auditInfo.setStatus(req.getStatus());
|
|
|
146
|
auditInfo.setRejectReason(req.getRejectReason());
|
165
|
auditInfo.setRejectReason(req.getRejectReason());
|
147
|
auditInfo.setAuditName(userInfo.getUserName());
|
166
|
auditInfo.setAuditName(userInfo.getUserName());
|
148
|
auditInfo.setAuditUid(userInfo.getUserId());
|
167
|
auditInfo.setAuditUid(userInfo.getUserId());
|
|
@@ -152,7 +171,7 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
@@ -152,7 +171,7 @@ public class SecondhandProductService implements ISecondhandProductService{ |
152
|
return num;
|
171
|
return num;
|
153
|
}
|
172
|
}
|
154
|
//更新storage_price
|
173
|
//更新storage_price
|
155
|
- num = storagePriceMapper.updateStatusBySkup(req.getStatus(), req.getSkup());
|
174
|
+ num = storagePriceMapper.updateSecondhandStatusBySkup(req.getStatus(), req.getSkup());
|
156
|
if(num == 0) {
|
175
|
if(num == 0) {
|
157
|
return num;
|
176
|
return num;
|
158
|
}
|
177
|
}
|
|
@@ -204,7 +223,7 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
@@ -204,7 +223,7 @@ public class SecondhandProductService implements ISecondhandProductService{ |
204
|
|
223
|
|
205
|
private List<SecondhandRsp> convertToResp(List<SecondhandInfo> infoList, Map<Integer, List<SecondhandImages>> skupImageMap,
|
224
|
private List<SecondhandRsp> convertToResp(List<SecondhandInfo> infoList, Map<Integer, List<SecondhandImages>> skupImageMap,
|
206
|
Map<Integer, StoragePrice> storagePriceMap, Map<Integer, SellerOrderGoods> sellerGoodsMap,
|
225
|
Map<Integer, StoragePrice> storagePriceMap, Map<Integer, SellerOrderGoods> sellerGoodsMap,
|
207
|
- Map<Integer, String> productIdNameMap, Map<Integer, String> flawMap){
|
226
|
+ Map<Integer, String> productIdNameMap, Map<Integer, String> flawMap, Map<Integer, String> goodsIdImageMap){
|
208
|
List<SecondhandRsp> respList = Lists.newArrayList();
|
227
|
List<SecondhandRsp> respList = Lists.newArrayList();
|
209
|
for(SecondhandInfo item : infoList) {
|
228
|
for(SecondhandInfo item : infoList) {
|
210
|
SecondhandRsp rsp = new SecondhandRsp();
|
229
|
SecondhandRsp rsp = new SecondhandRsp();
|
|
@@ -225,13 +244,13 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
@@ -225,13 +244,13 @@ public class SecondhandProductService implements ISecondhandProductService{ |
225
|
if(null == sellerGoods) {
|
244
|
if(null == sellerGoods) {
|
226
|
continue;
|
245
|
continue;
|
227
|
}
|
246
|
}
|
228
|
- rsp.setProductImage(ImagesHelper.getImageAbsoluteUrl(sellerGoods.getImageUrl(), "goodsimg"));
|
247
|
+ rsp.setProductImage(ImagesHelper.getImageAbsoluteUrl(goodsIdImageMap.get(storagePrice.getGoodsId()), "goodsimg"));
|
229
|
rsp.setColorName(sellerGoods.getColorName());
|
248
|
rsp.setColorName(sellerGoods.getColorName());
|
230
|
rsp.setSizeName(sellerGoods.getSizeName());
|
249
|
rsp.setSizeName(sellerGoods.getSizeName());
|
231
|
rsp.setSellerUid(storagePrice.getSellerUid());
|
250
|
rsp.setSellerUid(storagePrice.getSellerUid());
|
232
|
rsp.setPrice(String.valueOf(storagePrice.getPrice()));
|
251
|
rsp.setPrice(String.valueOf(storagePrice.getPrice()));
|
233
|
- rsp.setStatus(item.getStatus());
|
|
|
234
|
- rsp.setStatusStr(ProductSkupStatusEnum.getTypeName(item.getStatus()));
|
252
|
+ rsp.setStatus(storagePrice.getStatus());
|
|
|
253
|
+// rsp.setStatusStr(ProductSkupStatusEnum.getTypeName(storagePrice.getStatus()));
|
235
|
rsp.setCreateTimeStr(DateUtil.getDateFormatFromInt(item.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
254
|
rsp.setCreateTimeStr(DateUtil.getDateFormatFromInt(item.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
236
|
rsp.setAuditTimeStr(null == item.getAuditTime() ? "" : DateUtil.getDateFormatFromInt(item.getAuditTime(), "yyyy-MM-dd HH:mm:ss"));
|
255
|
rsp.setAuditTimeStr(null == item.getAuditTime() ? "" : DateUtil.getDateFormatFromInt(item.getAuditTime(), "yyyy-MM-dd HH:mm:ss"));
|
237
|
rsp.setAuditName(null == item.getAuditName() ? "" : item.getAuditName());
|
256
|
rsp.setAuditName(null == item.getAuditName() ? "" : item.getAuditName());
|