|
@@ -1,5 +1,6 @@
|
|
|
package com.fjhx.service.order.impl;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -8,16 +9,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.Order;
|
|
|
import com.fjhx.entity.order.OrderDetails;
|
|
|
+import com.fjhx.entity.order.OrderInfo;
|
|
|
import com.fjhx.entity.product.ProductInfo;
|
|
|
-import com.fjhx.mapper.order.OrderMapper;
|
|
|
-import com.fjhx.params.order.OrderEx;
|
|
|
+import com.fjhx.mapper.order.OrderInfoMapper;
|
|
|
+import com.fjhx.params.order.OrderInfoEx;
|
|
|
+import com.fjhx.params.order.OrderInfoVo;
|
|
|
import com.fjhx.params.order.OrderJdExcelVo;
|
|
|
-import com.fjhx.params.order.OrderVo;
|
|
|
import com.fjhx.service.excel.ExcelImportLogService;
|
|
|
import com.fjhx.service.order.OrderDetailsService;
|
|
|
-import com.fjhx.service.order.OrderService;
|
|
|
+import com.fjhx.service.order.OrderInfoService;
|
|
|
import com.fjhx.service.product.ProductInfoService;
|
|
|
import com.fjhx.service.system.SystemConfigService;
|
|
|
import com.fjhx.uitl.code.CodeEnum;
|
|
@@ -46,7 +47,7 @@ import java.util.stream.Collectors;
|
|
|
* @since 2022-12-13
|
|
|
*/
|
|
|
@Service
|
|
|
-public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
|
|
|
+public class OrderInfoInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements OrderInfoService {
|
|
|
|
|
|
@Autowired
|
|
|
private OrderDetailsService orderDetailsService;
|
|
@@ -61,21 +62,28 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
private SystemConfigService systemConfigService;
|
|
|
|
|
|
@Override
|
|
|
- public Page<OrderEx> getPage(Map<String, Object> condition) {
|
|
|
+ public Page<OrderInfoEx> getPage(Map<String, Object> condition) {
|
|
|
|
|
|
IWrapper<Object> wrapper = IWrapper.getWrapper(condition)
|
|
|
- .keyword(new KeywordData("o", Order::getCode), new KeywordData("ci", CustomerInfo::getName))
|
|
|
- .eq("o", Order::getType)
|
|
|
- .eq("o", Order::getStatus)
|
|
|
- .like("o", Order::getCode)
|
|
|
+ .keyword(new KeywordData("oi", OrderInfo::getCode), new KeywordData("ci", CustomerInfo::getName))
|
|
|
+ .func(q -> {
|
|
|
+ Integer type = Convert.toInt(condition.get("type"));
|
|
|
+ if (type == null) {
|
|
|
+ q.in("oi", OrderInfo::getType, 1, 2);
|
|
|
+ } else {
|
|
|
+ q.eq("oi", OrderInfo::getType);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .eq("oi", OrderInfo::getStatus)
|
|
|
+ .like("oi", OrderInfo::getCode)
|
|
|
.like("ci", CustomerInfo::getName, condition.get("customerName"))
|
|
|
- .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"));
|
|
|
+ .eq("oi", OrderInfo::getCountryId)
|
|
|
+ .eq("oi", OrderInfo::getProvinceId)
|
|
|
+ .eq("oi", OrderInfo::getCityId)
|
|
|
+ .ge("oi", OrderInfo::getAmountMoney, condition.get("minAmountMoney"))
|
|
|
+ .le("oi", OrderInfo::getAmountMoney, condition.get("maxAmountMoney"));
|
|
|
|
|
|
- Page<OrderEx> page = baseMapper.getPage(createPage(condition), wrapper);
|
|
|
+ Page<OrderInfoEx> page = baseMapper.getPage(createPage(condition), wrapper);
|
|
|
|
|
|
// 赋值国省市
|
|
|
RegionClientUtil.setEntityRegionName(page.getRecords());
|
|
@@ -84,14 +92,17 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void add(OrderVo orderVo) {
|
|
|
+ public void add(OrderInfoVo orderVo) {
|
|
|
// 订单明细
|
|
|
List<OrderDetails> orderDetailsList = orderVo.getOrderDetailsList();
|
|
|
Assert.notEmpty(orderDetailsList, "订单明细不能为空");
|
|
|
|
|
|
- // 获取京东客户id
|
|
|
- Long customerCustomerId = systemConfigService.getValue(SystemConfigKeyConstant.CUSTOMER_CUSTOMER_ID, Long.class);
|
|
|
- orderVo.setCustomerInfoId(customerCustomerId);
|
|
|
+ Integer type = orderVo.getType();
|
|
|
+ if (type == 3) {
|
|
|
+ // 获取京东客户id
|
|
|
+ Long customerCustomerId = systemConfigService.getValue(SystemConfigKeyConstant.CUSTOMER_CUSTOMER_ID, Long.class);
|
|
|
+ orderVo.setCustomerInfoId(customerCustomerId);
|
|
|
+ }
|
|
|
|
|
|
// 订单时间
|
|
|
orderVo.setOrderTime(ObjectUtil.defaultIfNull(orderVo.getOrderTime(), new Date()));
|
|
@@ -104,7 +115,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
orderVo.setStatus(1);
|
|
|
|
|
|
synchronized (this) {
|
|
|
- orderVo.setCode(CodeEnum.ORDER_JD.getCode(orderVo.getCode()));
|
|
|
+ if (type == 3) {
|
|
|
+ orderVo.setCode(CodeEnum.ORDER_JD.getCode(orderVo.getCode()));
|
|
|
+ } else {
|
|
|
+ orderVo.setCode(CodeEnum.ORDER_SALES.getCode(orderVo.getCode()));
|
|
|
+ }
|
|
|
save(orderVo);
|
|
|
}
|
|
|
|
|
@@ -117,7 +132,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void edit(OrderVo orderVo) {
|
|
|
+ public void edit(OrderInfoVo orderVo) {
|
|
|
updateById(orderVo);
|
|
|
}
|
|
|
|
|
@@ -145,7 +160,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
excelImportLogService.saveLog(flag, ExcelImportBusinessType.JD_ORDER, file);
|
|
|
|
|
|
// 京东订单表
|
|
|
- Map<String, Order> map = new HashMap<>();
|
|
|
+ Map<String, OrderInfo> map = new HashMap<>();
|
|
|
|
|
|
// 京东订单明细
|
|
|
List<OrderDetails> orderDetailsList = new ArrayList<>();
|
|
@@ -160,31 +175,32 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
BigDecimal quantity = orderJdExcelVo.getQuantity();
|
|
|
|
|
|
Long productId = codeIdMap.get(productCode);
|
|
|
- Order order = map.get(code);
|
|
|
- if (order == null) {
|
|
|
- order = new OrderEx();
|
|
|
+ OrderInfo orderInfo = map.get(code);
|
|
|
+ if (orderInfo == null) {
|
|
|
+ orderInfo = new OrderInfoEx();
|
|
|
|
|
|
long id = IdWorker.getId();
|
|
|
- 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);
|
|
|
+ orderInfo.setId(id);
|
|
|
+ orderInfo.setType(3);
|
|
|
+ orderInfo.setCustomerInfoId(customerCustomerId);
|
|
|
+ orderInfo.setCode(code);
|
|
|
+ orderInfo.setAmountMoney(price.multiply(quantity));
|
|
|
+ orderInfo.setOrderTime(orderJdExcelVo.getOrderTime());
|
|
|
+ orderInfo.setStatus(1);
|
|
|
+ orderInfo.setCountryId("China");
|
|
|
+ orderInfo.setDetailedAddress(orderJdExcelVo.getDetailedAddress());
|
|
|
+ orderInfo.setContacts(orderJdExcelVo.getContacts());
|
|
|
+ orderInfo.setPhone(orderJdExcelVo.getPhone());
|
|
|
+ orderInfo.setExcelImportId(flag);
|
|
|
+ orderInfo.setCreateUser(AuthUtil.getUserId());
|
|
|
+ orderInfo.setCreateTime(date);
|
|
|
+ map.put(code, orderInfo);
|
|
|
} else {
|
|
|
- order.setAmountMoney(order.getAmountMoney().add(price.multiply(quantity)));
|
|
|
+ orderInfo.setAmountMoney(orderInfo.getAmountMoney().add(price.multiply(quantity)));
|
|
|
}
|
|
|
|
|
|
OrderDetails orderDetails = new OrderDetails();
|
|
|
- orderDetails.setOrderId(order.getId());
|
|
|
+ orderDetails.setOrderId(orderInfo.getId());
|
|
|
orderDetails.setProductId(productId);
|
|
|
orderDetails.setQuantity(quantity);
|
|
|
orderDetails.setPrice(price);
|
|
@@ -207,13 +223,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
*/
|
|
|
private void verifyOrderNumber(List<OrderJdExcelVo> list) {
|
|
|
List<String> codeList = list.stream().map(OrderJdExcelVo::getCode).distinct().collect(Collectors.toList());
|
|
|
- List<String> existCodeList = listObj(Order::getCode, q -> q.in(Order::getCode, codeList));
|
|
|
+ List<String> existCodeList = listObj(OrderInfo::getCode, q -> q.in(OrderInfo::getCode, codeList));
|
|
|
|
|
|
if (existCodeList.size() > 0) {
|
|
|
StringJoiner joiner = new StringJoiner(",");
|
|
|
existCodeList.forEach(joiner::add);
|
|
|
-
|
|
|
- // 保存导入记录
|
|
|
throw new ServiceException("存在相同的采购单号:" + joiner);
|
|
|
}
|
|
|
}
|