|
@@ -384,49 +384,48 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
|
|
|
}
|
|
|
objectMap.put(columnValue, row.get(s));
|
|
|
}
|
|
|
- StudentPaymentRouteOrder studentPaymentRouteOrder = null;
|
|
|
- try {
|
|
|
- studentPaymentRouteOrder = JSONObject.parseObject(objectMap.toJSONString(),StudentPaymentRouteOrder.class);
|
|
|
- //是否有销售金额
|
|
|
- if(studentPaymentRouteOrder.getSaleAmount() != null && studentPaymentRouteOrder.getSaleAmount().longValue() != 0l){
|
|
|
- String goodsIds = studentPaymentRouteOrder.getGoodsIds();
|
|
|
- String goodsNums = studentPaymentRouteOrder.getGoodsNums();
|
|
|
- if(StringUtils.isAllEmpty(goodsIds,goodsNums)){
|
|
|
- throw new BizException("导入失败:有销售金额时商品编号和数量必填");
|
|
|
- }
|
|
|
- List<String> goodsIdList = new ArrayList(Arrays.asList(goodsIds.split(",")));
|
|
|
- List<String> goodsNumList = new ArrayList(Arrays.asList(goodsNums.split(",")));
|
|
|
- if(goodsIdList.size() != goodsNumList.size()){
|
|
|
- throw new BizException("导入失败:商品编号和商品数量不一致");
|
|
|
+ StudentPaymentRouteOrder studentPaymentRouteOrder = JSONObject.parseObject(objectMap.toJSONString(),StudentPaymentRouteOrder.class);
|
|
|
+ //是否有销售金额
|
|
|
+ if(studentPaymentRouteOrder.getSaleAmount() != null && studentPaymentRouteOrder.getSaleAmount().longValue() != 0l){
|
|
|
+ String goodsIds = studentPaymentRouteOrder.getGoodsIds();
|
|
|
+ String goodsNums = studentPaymentRouteOrder.getGoodsNums();
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(goodsNums)){
|
|
|
+ throw new BizException("导入失败:有销售金额时商品数量必填");
|
|
|
+ }
|
|
|
+ if(StringUtils.isEmpty(goodsIds)){
|
|
|
+ throw new BizException("导入失败:有销售金额时商品编号必填");
|
|
|
+ }
|
|
|
+ List<String> goodsIdList = new ArrayList(Arrays.asList(goodsIds.split(",")));
|
|
|
+ List<String> goodsNumList = new ArrayList(Arrays.asList(goodsNums.split(",")));
|
|
|
+ if(goodsIdList.size() != goodsNumList.size()){
|
|
|
+ throw new BizException("导入失败:商品编号和商品数量不一致");
|
|
|
+ }
|
|
|
+ JSONArray goodsJSON = new JSONArray();
|
|
|
+ for (int i = 0; i < goodsIdList.size(); i++) {
|
|
|
+ if(!goodsDao.findByIdAndStatus(goodsIdList.get(i), 1)){
|
|
|
+ throw new BizException("导入失败:商品编号{}不存在",goodsIdList.get(i));
|
|
|
}
|
|
|
- JSONArray goodsJSON = new JSONArray();
|
|
|
- for (int i = 0; i < goodsIdList.size(); i++) {
|
|
|
- if(!goodsDao.findByIdAndStatus(goodsIdList.get(i), 1)){
|
|
|
- throw new BizException("导入失败:商品编号{}不存在",goodsIdList.get(i));
|
|
|
- }
|
|
|
- try {
|
|
|
- int goodsNum = Integer.parseInt(goodsNumList.get(i));
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put(goodsIdList.get(i),goodsNum);
|
|
|
- goodsJSON.add(jsonObject);
|
|
|
- }catch (Exception e1){
|
|
|
- throw new BizException("导入失败:商品数量{}填写错误",goodsNumList.get(i));
|
|
|
- }
|
|
|
+ try {
|
|
|
+ int goodsNum = Integer.parseInt(goodsNumList.get(i));
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put(goodsIdList.get(i),goodsNum);
|
|
|
+ goodsJSON.add(jsonObject);
|
|
|
+ }catch (Exception e1){
|
|
|
+ throw new BizException("导入失败:商品数量{}填写错误",goodsNumList.get(i));
|
|
|
}
|
|
|
- studentPaymentRouteOrder.setGoodsJson(goodsJSON.toJSONString());
|
|
|
}
|
|
|
- studentPaymentRouteOrders.add(studentPaymentRouteOrder);
|
|
|
- } catch (Exception ex) {
|
|
|
- throw new BizException("导入数据出错,请检查Excel表格");
|
|
|
+ studentPaymentRouteOrder.setGoodsJson(goodsJSON.toJSONString());
|
|
|
}
|
|
|
+ studentPaymentRouteOrders.add(studentPaymentRouteOrder);
|
|
|
}
|
|
|
}
|
|
|
- if(studentPaymentRouteOrders.size() != 0){
|
|
|
- Map<String, List<StudentPaymentRouteOrder>> stringListMap = studentPaymentRouteOrders.stream().collect(Collectors.groupingBy(StudentPaymentRouteOrder::getOrderNo));
|
|
|
- if(sheetsListMap.size() != studentPaymentRouteOrders.size()){
|
|
|
+ if(studentPaymentRouteOrders.size() > 0){
|
|
|
+ Map<String, List<StudentPaymentRouteOrder>> stringListMap = studentPaymentRouteOrders.stream().collect(Collectors.groupingBy(StudentPaymentRouteOrder::getTransNo));
|
|
|
+ if(stringListMap.size() != studentPaymentRouteOrders.size()){
|
|
|
throw new BizException("导入失败:请勿录入重复的交易流水号");
|
|
|
}
|
|
|
- studentPaymentOrderDao.batchInsert(studentPaymentRouteOrders);
|
|
|
+ studentPaymentRouteOrderDao.batchAdd(studentPaymentRouteOrders);
|
|
|
}
|
|
|
return studentPaymentRouteOrders;
|
|
|
}
|