|
@@ -1,6 +1,9 @@
|
|
package com.fjhx.victoriatourist.service.jd.impl;
|
|
package com.fjhx.victoriatourist.service.jd.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
|
+import com.alibaba.excel.context.AnalysisContext;
|
|
|
|
+import com.alibaba.excel.event.AnalysisEventListener;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -9,7 +12,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.fjhx.common.utils.Assert;
|
|
import com.fjhx.common.utils.Assert;
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
-import com.fjhx.victoriatourist.entity.jd.dto.JdRefundDto;
|
|
|
|
|
|
+import com.fjhx.item.util.excel.util.ExcelUtil;
|
|
import com.fjhx.victoriatourist.entity.jd.dto.JdRefundSelectDto;
|
|
import com.fjhx.victoriatourist.entity.jd.dto.JdRefundSelectDto;
|
|
import com.fjhx.victoriatourist.entity.jd.po.JdRefund;
|
|
import com.fjhx.victoriatourist.entity.jd.po.JdRefund;
|
|
import com.fjhx.victoriatourist.entity.jd.po.JdRefundDetail;
|
|
import com.fjhx.victoriatourist.entity.jd.po.JdRefundDetail;
|
|
@@ -27,8 +30,10 @@ import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -105,17 +110,17 @@ public class JdRefundServiceImpl extends ServiceImpl<JdRefundMapper, JdRefund> i
|
|
|
|
|
|
@DSTransactional
|
|
@DSTransactional
|
|
@Override
|
|
@Override
|
|
- public void confirm(JdRefundDto dto) {
|
|
|
|
- JdRefundDetail jdRefundDetail = jdRefundDetailService.getById(dto.getId());
|
|
|
|
|
|
+ public void confirm(Long id) {
|
|
|
|
+ JdRefundDetail jdRefundDetail = jdRefundDetailService.getById(id);
|
|
Assert.notEmpty(jdRefundDetail, "京东售后明细不存在");
|
|
Assert.notEmpty(jdRefundDetail, "京东售后明细不存在");
|
|
|
|
|
|
Integer status = jdRefundDetail.getStatus();
|
|
Integer status = jdRefundDetail.getStatus();
|
|
- Assert.eqZero(status, "京东售后单已确认");
|
|
|
|
|
|
+ Assert.eqZero(status, "京东售后单已确认,备件条码:" + jdRefundDetail.getPartCode());
|
|
|
|
|
|
// 获取产品编号
|
|
// 获取产品编号
|
|
String wareId = jdRefundDetail.getWareId();
|
|
String wareId = jdRefundDetail.getWareId();
|
|
ProductInfo productInfo = productInfoService.getOne(q -> q.eq(ProductInfo::getCustomCode, wareId));
|
|
ProductInfo productInfo = productInfoService.getOne(q -> q.eq(ProductInfo::getCustomCode, wareId));
|
|
- Assert.notEmpty(productInfo, "未知产品编码:" + wareId);
|
|
|
|
|
|
+ Assert.notEmpty(productInfo, "未知产品编码:" + wareId + ",备件条码:" + jdRefundDetail.getPartCode());
|
|
|
|
|
|
// key: product_id value:产品数量
|
|
// key: product_id value:产品数量
|
|
Map<Long, Integer> map = new HashMap<>();
|
|
Map<Long, Integer> map = new HashMap<>();
|
|
@@ -180,8 +185,8 @@ public class JdRefundServiceImpl extends ServiceImpl<JdRefundMapper, JdRefund> i
|
|
|
|
|
|
@DSTransactional
|
|
@DSTransactional
|
|
@Override
|
|
@Override
|
|
- public void cancelConfirm(JdRefundDto dto) {
|
|
|
|
- JdRefundDetail jdRefundDetail = jdRefundDetailService.getById(dto.getId());
|
|
|
|
|
|
+ public void cancelConfirm(Long id) {
|
|
|
|
+ JdRefundDetail jdRefundDetail = jdRefundDetailService.getById(id);
|
|
Assert.notEmpty(jdRefundDetail, "京东售后明细不存在");
|
|
Assert.notEmpty(jdRefundDetail, "京东售后明细不存在");
|
|
|
|
|
|
Integer status = jdRefundDetail.getStatus();
|
|
Integer status = jdRefundDetail.getStatus();
|
|
@@ -239,6 +244,42 @@ public class JdRefundServiceImpl extends ServiceImpl<JdRefundMapper, JdRefund> i
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @DSTransactional
|
|
|
|
+ @Override
|
|
|
|
+ public void confirmExcelImport(MultipartFile file) {
|
|
|
|
+
|
|
|
|
+ // 备件条码列表
|
|
|
|
+ List<String> partCodeList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ EasyExcel.read(ExcelUtil.getInputStream(file)).sheet(0).registerReadListener(new AnalysisEventListener<Map<Integer, String>>() {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void invoke(Map<Integer, String> map, AnalysisContext analysisContext) {
|
|
|
|
+ partCodeList.add(map.get(0));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void doAfterAllAnalysed(AnalysisContext context) {
|
|
|
|
+ //数据读取完毕
|
|
|
|
+ }
|
|
|
|
+ }).headRowNumber(1).doRead();
|
|
|
|
+
|
|
|
|
+ if (partCodeList.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, Long> map = jdRefundDetailService.list(q -> q.in(JdRefundDetail::getPartCode, partCodeList))
|
|
|
|
+ .stream().collect(Collectors.toMap(JdRefundDetail::getPartCode, JdRefundDetail::getId));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (String partCode : partCodeList) {
|
|
|
|
+ Long id = map.get(partCode);
|
|
|
|
+ Assert.notEmpty(id, "备件条码不存在:" + partCode);
|
|
|
|
+ confirm(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 赋值需要质检的商品
|
|
* 赋值需要质检的商品
|
|
*/
|
|
*/
|