|
@@ -8,17 +8,16 @@ import com.fjhx.base.BaseEntity;
|
|
|
import com.fjhx.constants.ExcelImportBusinessType;
|
|
|
import com.fjhx.constants.SystemConfigKeyConstant;
|
|
|
import com.fjhx.entity.customer.CustomerInfo;
|
|
|
-import com.fjhx.entity.order.OrderJd;
|
|
|
-import com.fjhx.entity.order.OrderJdDetails;
|
|
|
-import com.fjhx.entity.order.OrderSales;
|
|
|
+import com.fjhx.entity.order.Order;
|
|
|
+import com.fjhx.entity.order.OrderDetails;
|
|
|
import com.fjhx.entity.product.ProductInfo;
|
|
|
-import com.fjhx.mapper.order.OrderJdMapper;
|
|
|
-import com.fjhx.params.order.OrderJdEx;
|
|
|
+import com.fjhx.mapper.order.OrderMapper;
|
|
|
+import com.fjhx.params.order.OrderEx;
|
|
|
import com.fjhx.params.order.OrderJdExcelVo;
|
|
|
-import com.fjhx.params.order.OrderJdVo;
|
|
|
+import com.fjhx.params.order.OrderVo;
|
|
|
import com.fjhx.service.excel.ExcelImportLogService;
|
|
|
-import com.fjhx.service.order.OrderJdDetailsService;
|
|
|
-import com.fjhx.service.order.OrderJdService;
|
|
|
+import com.fjhx.service.order.OrderDetailsService;
|
|
|
+import com.fjhx.service.order.OrderService;
|
|
|
import com.fjhx.service.product.ProductInfoService;
|
|
|
import com.fjhx.service.system.SystemConfigService;
|
|
|
import com.fjhx.uitl.code.CodeEnum;
|
|
@@ -44,38 +43,39 @@ import java.util.stream.Collectors;
|
|
|
* </p>
|
|
|
*
|
|
|
* @author ${author}
|
|
|
- * @since 2022-12-08
|
|
|
+ * @since 2022-12-13
|
|
|
*/
|
|
|
@Service
|
|
|
-public class OrderJdServiceImpl extends ServiceImpl<OrderJdMapper, OrderJd> implements OrderJdService {
|
|
|
+public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
|
|
|
|
|
|
@Autowired
|
|
|
- private ExcelImportLogService excelImportLogService;
|
|
|
+ private OrderDetailsService orderDetailsService;
|
|
|
|
|
|
@Autowired
|
|
|
- private ProductInfoService productInfoService;
|
|
|
+ private ExcelImportLogService excelImportLogService;
|
|
|
|
|
|
@Autowired
|
|
|
- private OrderJdDetailsService orderJdDetailsService;
|
|
|
+ private ProductInfoService productInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
private SystemConfigService systemConfigService;
|
|
|
|
|
|
@Override
|
|
|
- public Page<OrderJdEx> getPage(Map<String, Object> condition) {
|
|
|
+ public Page<OrderEx> getPage(Map<String, Object> condition) {
|
|
|
|
|
|
IWrapper<Object> wrapper = IWrapper.getWrapper(condition)
|
|
|
- .keyword(new KeywordData("oj", OrderSales::getCode), new KeywordData("ci", CustomerInfo::getName))
|
|
|
- .eq("oj", OrderJd::getStatus)
|
|
|
- .like("oj", OrderJd::getCode)
|
|
|
+ .keyword(new KeywordData("o", Order::getCode), new KeywordData("ci", CustomerInfo::getName))
|
|
|
+ .eq("o", Order::getType)
|
|
|
+ .eq("o", Order::getStatus)
|
|
|
+ .like("o", Order::getCode)
|
|
|
.like("ci", CustomerInfo::getName, condition.get("customerName"))
|
|
|
- .eq("oj", OrderJd::getCountryId)
|
|
|
- .eq("oj", OrderJd::getProvinceId)
|
|
|
- .eq("oj", OrderJd::getCityId)
|
|
|
- .ge("oj", OrderJd::getAmountMoney, condition.get("minAmountMoney"))
|
|
|
- .le("oj", OrderJd::getAmountMoney, condition.get("maxAmountMoney"));
|
|
|
+ .eq("o", Order::getCountryId)
|
|
|
+ .eq("o", Order::getProvinceId)
|
|
|
+ .eq("o", Order::getCityId)
|
|
|
+ .ge("o", Order::getAmountMoney, condition.get("minAmountMoney"))
|
|
|
+ .le("o", Order::getAmountMoney, condition.get("maxAmountMoney"));
|
|
|
|
|
|
- Page<OrderJdEx> page = baseMapper.getPage(createPage(condition), wrapper);
|
|
|
+ Page<OrderEx> page = baseMapper.getPage(createPage(condition), wrapper);
|
|
|
|
|
|
// 赋值国省市
|
|
|
RegionClientUtil.setEntityRegionName(page.getRecords());
|
|
@@ -83,47 +83,42 @@ public class OrderJdServiceImpl extends ServiceImpl<OrderJdMapper, OrderJd> impl
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void add(OrderJdVo orderJdVo) {
|
|
|
+ public void add(OrderVo orderVo) {
|
|
|
// 订单明细
|
|
|
- List<OrderJdDetails> orderJdDetailsList = orderJdVo.getOrderJdDetailsList();
|
|
|
- Assert.notEmpty(orderJdDetailsList, "订单明细不能为空");
|
|
|
+ List<OrderDetails> orderDetailsList = orderVo.getOrderDetailsList();
|
|
|
+ Assert.notEmpty(orderDetailsList, "订单明细不能为空");
|
|
|
|
|
|
// 获取京东客户id
|
|
|
Long customerCustomerId = systemConfigService.getValue(SystemConfigKeyConstant.CUSTOMER_CUSTOMER_ID, Long.class);
|
|
|
- orderJdVo.setCustomerInfoId(customerCustomerId);
|
|
|
+ orderVo.setCustomerInfoId(customerCustomerId);
|
|
|
|
|
|
// 订单时间
|
|
|
- orderJdVo.setOrderTime(ObjectUtil.defaultIfNull(orderJdVo.getOrderTime(), new Date()));
|
|
|
+ orderVo.setOrderTime(ObjectUtil.defaultIfNull(orderVo.getOrderTime(), new Date()));
|
|
|
|
|
|
// 统计订单金额
|
|
|
- BigDecimal amountMoney = orderJdDetailsList.stream()
|
|
|
+ BigDecimal amountMoney = orderDetailsList.stream()
|
|
|
.map(item -> item.getPrice().multiply(item.getQuantity())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- orderJdVo.setAmountMoney(amountMoney);
|
|
|
+ orderVo.setAmountMoney(amountMoney);
|
|
|
|
|
|
- orderJdVo.setStatus(1);
|
|
|
+ orderVo.setStatus(1);
|
|
|
|
|
|
synchronized (this) {
|
|
|
- orderJdVo.setCode(CodeEnum.ORDER_JD.getCode(orderJdVo.getCode()));
|
|
|
- save(orderJdVo);
|
|
|
+ orderVo.setCode(CodeEnum.ORDER_JD.getCode(orderVo.getCode()));
|
|
|
+ save(orderVo);
|
|
|
}
|
|
|
+
|
|
|
// 添加订单明细
|
|
|
- for (OrderJdDetails orderJdDetails : orderJdDetailsList) {
|
|
|
- orderJdDetails.setOrderJdId(orderJdVo.getId());
|
|
|
- orderJdDetails.setNotIssuedQuantity(orderJdDetails.getQuantity());
|
|
|
+ for (OrderDetails orderDetails : orderDetailsList) {
|
|
|
+ orderDetails.setOrderId(orderVo.getId());
|
|
|
+ orderDetails.setNotIssuedQuantity(orderDetails.getQuantity());
|
|
|
}
|
|
|
- orderJdDetailsService.saveBatch(orderJdDetailsList);
|
|
|
+ orderDetailsService.saveBatch(orderDetailsList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void edit(OrderJdVo orderJdVo) {
|
|
|
- updateById(orderJdVo);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void delete(OrderJdVo orderJdVo) {
|
|
|
- removeById(orderJdVo.getId());
|
|
|
+ public void edit(OrderVo orderVo) {
|
|
|
+ updateById(orderVo);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -150,10 +145,10 @@ public class OrderJdServiceImpl extends ServiceImpl<OrderJdMapper, OrderJd> impl
|
|
|
excelImportLogService.saveLog(flag, ExcelImportBusinessType.JD_ORDER, file);
|
|
|
|
|
|
// 京东订单表
|
|
|
- Map<String, OrderJd> map = new HashMap<>();
|
|
|
+ Map<String, Order> map = new HashMap<>();
|
|
|
|
|
|
// 京东订单明细
|
|
|
- List<OrderJdDetails> orderJdDetailsList = new ArrayList<>();
|
|
|
+ List<OrderDetails> orderDetailsList = new ArrayList<>();
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
@@ -165,41 +160,41 @@ public class OrderJdServiceImpl extends ServiceImpl<OrderJdMapper, OrderJd> impl
|
|
|
BigDecimal quantity = orderJdExcelVo.getQuantity();
|
|
|
|
|
|
Long productId = codeIdMap.get(productCode);
|
|
|
- OrderJd orderJd = map.get(code);
|
|
|
- if (orderJd == null) {
|
|
|
- orderJd = new OrderJdEx();
|
|
|
+ Order order = map.get(code);
|
|
|
+ if (order == null) {
|
|
|
+ order = new OrderEx();
|
|
|
|
|
|
long id = IdWorker.getId();
|
|
|
- orderJd.setId(id);
|
|
|
- orderJd.setCustomerInfoId(customerCustomerId);
|
|
|
- orderJd.setCode(code);
|
|
|
- orderJd.setAmountMoney(price.multiply(quantity));
|
|
|
- orderJd.setOrderTime(orderJdExcelVo.getOrderTime());
|
|
|
- orderJd.setStatus(1);
|
|
|
- orderJd.setCountryId("China");
|
|
|
- orderJd.setDetailedAddress(orderJdExcelVo.getDetailedAddress());
|
|
|
- orderJd.setContacts(orderJdExcelVo.getContacts());
|
|
|
- orderJd.setPhone(orderJdExcelVo.getPhone());
|
|
|
- orderJd.setExcelImportId(flag);
|
|
|
- orderJd.setCreateUser(AuthUtil.getUserId());
|
|
|
- orderJd.setCreateTime(date);
|
|
|
- map.put(code, orderJd);
|
|
|
+ order.setId(id);
|
|
|
+ order.setCustomerInfoId(customerCustomerId);
|
|
|
+ order.setCode(code);
|
|
|
+ order.setAmountMoney(price.multiply(quantity));
|
|
|
+ order.setOrderTime(orderJdExcelVo.getOrderTime());
|
|
|
+ order.setStatus(1);
|
|
|
+ order.setCountryId("China");
|
|
|
+ order.setDetailedAddress(orderJdExcelVo.getDetailedAddress());
|
|
|
+ order.setContacts(orderJdExcelVo.getContacts());
|
|
|
+ order.setPhone(orderJdExcelVo.getPhone());
|
|
|
+ order.setExcelImportId(flag);
|
|
|
+ order.setCreateUser(AuthUtil.getUserId());
|
|
|
+ order.setCreateTime(date);
|
|
|
+ map.put(code, order);
|
|
|
} else {
|
|
|
- orderJd.setAmountMoney(orderJd.getAmountMoney().add(price.multiply(quantity)));
|
|
|
+ order.setAmountMoney(order.getAmountMoney().add(price.multiply(quantity)));
|
|
|
}
|
|
|
|
|
|
- OrderJdDetails orderJdDetails = new OrderJdDetails();
|
|
|
- orderJdDetails.setOrderJdId(orderJd.getId());
|
|
|
- orderJdDetails.setProductId(productId);
|
|
|
- orderJdDetails.setQuantity(quantity);
|
|
|
- orderJdDetails.setPrice(price);
|
|
|
- orderJdDetails.setNotIssuedQuantity(quantity);
|
|
|
+ OrderDetails orderDetails = new OrderDetails();
|
|
|
+ orderDetails.setOrderId(order.getId());
|
|
|
+ orderDetails.setProductId(productId);
|
|
|
+ orderDetails.setQuantity(quantity);
|
|
|
+ orderDetails.setPrice(price);
|
|
|
+ orderDetails.setNotIssuedQuantity(quantity);
|
|
|
|
|
|
- orderJdDetailsList.add(orderJdDetails);
|
|
|
+ orderDetailsList.add(orderDetails);
|
|
|
}
|
|
|
|
|
|
saveBatch(new ArrayList<>(map.values()));
|
|
|
- orderJdDetailsService.saveBatch(orderJdDetailsList);
|
|
|
+ orderDetailsService.saveBatch(orderDetailsList);
|
|
|
|
|
|
// 保存导入记录
|
|
|
excelImportLogService.editLog(start, flag, 1);
|
|
@@ -212,7 +207,7 @@ public class OrderJdServiceImpl extends ServiceImpl<OrderJdMapper, OrderJd> impl
|
|
|
*/
|
|
|
private void verifyOrderNumber(List<OrderJdExcelVo> list) {
|
|
|
List<String> codeList = list.stream().map(OrderJdExcelVo::getCode).distinct().collect(Collectors.toList());
|
|
|
- List<String> existCodeList = listObj(OrderJd::getCode, q -> q.in(OrderJd::getCode, codeList));
|
|
|
+ List<String> existCodeList = listObj(Order::getCode, q -> q.in(Order::getCode, codeList));
|
|
|
|
|
|
if (existCodeList.size() > 0) {
|
|
|
StringJoiner joiner = new StringJoiner(",");
|
|
@@ -242,9 +237,6 @@ public class OrderJdServiceImpl extends ServiceImpl<OrderJdMapper, OrderJd> impl
|
|
|
joiner.add(productCode);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-// // 保存导入记录
|
|
|
-// excelImportLogService.editLog(start, flag, 2);
|
|
|
throw new ServiceException("产品表中未找到对应产品编码:" + joiner);
|
|
|
}
|
|
|
return kv;
|