1
This commit is contained in:
@@ -14,8 +14,11 @@ import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.jarvis.domain.JDOrder;
|
||||
import com.ruoyi.jarvis.domain.OrderRows;
|
||||
import com.ruoyi.jarvis.domain.dto.LinkedJdOrderBrief;
|
||||
import com.ruoyi.jarvis.service.IGoodsInfoService;
|
||||
import com.ruoyi.jarvis.service.IJDOrderService;
|
||||
import com.ruoyi.jarvis.service.IOrderRowsService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
@@ -36,6 +39,9 @@ public class OrderRowsController extends BaseController
|
||||
@Autowired
|
||||
private IGoodsInfoService goodsInfoService;
|
||||
|
||||
@Autowired
|
||||
private IJDOrderService jdOrderService;
|
||||
|
||||
@Autowired
|
||||
private SuperAdminService superAdminService;
|
||||
|
||||
@@ -67,6 +73,7 @@ public class OrderRowsController extends BaseController
|
||||
|
||||
startPage();
|
||||
List<OrderRows> list = orderRowsService.selectOrderRowsList(orderRows);
|
||||
enrichLinkedJdOrders(list);
|
||||
TableDataInfo dataTable = getDataTable(list);
|
||||
Date beginTime = getDateFromParams(orderRows.getParams(), "beginTime");
|
||||
Date endTime = getDateFromParams(orderRows.getParams(), "endTime");
|
||||
@@ -135,6 +142,9 @@ public class OrderRowsController extends BaseController
|
||||
if (orderRows != null && orderRows.getGoodsInfoId() != null) {
|
||||
orderRows.setGoodsInfo(goodsInfoService.selectGoodsInfoById(orderRows.getGoodsInfoId()));
|
||||
}
|
||||
if (orderRows != null) {
|
||||
enrichLinkedJdOrders(Collections.singletonList(orderRows));
|
||||
}
|
||||
return success(orderRows);
|
||||
}
|
||||
|
||||
@@ -330,5 +340,57 @@ public class OrderRowsController extends BaseController
|
||||
return stat;
|
||||
}
|
||||
|
||||
private void enrichLinkedJdOrders(List<OrderRows> rows) {
|
||||
if (rows == null || rows.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<String> orderIds = new ArrayList<>();
|
||||
for (OrderRows row : rows) {
|
||||
if (row.getOrderId() != null) {
|
||||
String oid = String.valueOf(row.getOrderId());
|
||||
if (!orderIds.contains(oid)) {
|
||||
orderIds.add(oid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (orderIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<JDOrder> jdOrders = jdOrderService.selectLatestJDOrdersByOrderIds(orderIds);
|
||||
if (jdOrders == null || jdOrders.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, JDOrder> jdOrderMap = new HashMap<>();
|
||||
for (JDOrder jdOrder : jdOrders) {
|
||||
if (jdOrder != null && jdOrder.getOrderId() != null) {
|
||||
jdOrderMap.put(jdOrder.getOrderId(), jdOrder);
|
||||
}
|
||||
}
|
||||
for (OrderRows row : rows) {
|
||||
if (row.getOrderId() == null) {
|
||||
continue;
|
||||
}
|
||||
JDOrder jdOrder = jdOrderMap.get(String.valueOf(row.getOrderId()));
|
||||
if (jdOrder != null) {
|
||||
row.setLinkedJdOrder(toLinkedJdOrderBrief(jdOrder));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LinkedJdOrderBrief toLinkedJdOrderBrief(JDOrder jdOrder) {
|
||||
LinkedJdOrderBrief brief = new LinkedJdOrderBrief();
|
||||
brief.setId(jdOrder.getId());
|
||||
brief.setRemark(jdOrder.getRemark());
|
||||
brief.setOrderId(jdOrder.getOrderId());
|
||||
brief.setBuyer(jdOrder.getBuyer());
|
||||
brief.setModelNumber(jdOrder.getModelNumber());
|
||||
brief.setModelShop(jdOrder.getModelShop());
|
||||
brief.setPaymentAmount(jdOrder.getPaymentAmount());
|
||||
brief.setRebateAmount(jdOrder.getRebateAmount());
|
||||
brief.setAddress(jdOrder.getAddress());
|
||||
brief.setStatus(jdOrder.getStatus());
|
||||
brief.setOrderTime(jdOrder.getOrderTime());
|
||||
return brief;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.jarvis.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.jarvis.domain.dto.LinkedJdOrderBrief;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
@@ -233,4 +234,8 @@ public class OrderRows extends BaseEntity
|
||||
@Transient
|
||||
private GoodsInfo goodsInfo;
|
||||
|
||||
/** 关联本地慢单(jd_order,非表字段) */
|
||||
@Transient
|
||||
private LinkedJdOrderBrief linkedJdOrder;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.ruoyi.jarvis.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 京粉订单关联的本地慢单摘要
|
||||
*/
|
||||
public class LinkedJdOrderBrief {
|
||||
|
||||
private Long id;
|
||||
private String remark;
|
||||
private String orderId;
|
||||
private String buyer;
|
||||
private String modelNumber;
|
||||
private String modelShop;
|
||||
private Double paymentAmount;
|
||||
private Double rebateAmount;
|
||||
private String address;
|
||||
private String status;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date orderTime;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public String getBuyer() {
|
||||
return buyer;
|
||||
}
|
||||
|
||||
public void setBuyer(String buyer) {
|
||||
this.buyer = buyer;
|
||||
}
|
||||
|
||||
public String getModelNumber() {
|
||||
return modelNumber;
|
||||
}
|
||||
|
||||
public void setModelNumber(String modelNumber) {
|
||||
this.modelNumber = modelNumber;
|
||||
}
|
||||
|
||||
public String getModelShop() {
|
||||
return modelShop;
|
||||
}
|
||||
|
||||
public void setModelShop(String modelShop) {
|
||||
this.modelShop = modelShop;
|
||||
}
|
||||
|
||||
public Double getPaymentAmount() {
|
||||
return paymentAmount;
|
||||
}
|
||||
|
||||
public void setPaymentAmount(Double paymentAmount) {
|
||||
this.paymentAmount = paymentAmount;
|
||||
}
|
||||
|
||||
public Double getRebateAmount() {
|
||||
return rebateAmount;
|
||||
}
|
||||
|
||||
public void setRebateAmount(Double rebateAmount) {
|
||||
this.rebateAmount = rebateAmount;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getOrderTime() {
|
||||
return orderTime;
|
||||
}
|
||||
|
||||
public void setOrderTime(Date orderTime) {
|
||||
this.orderTime = orderTime;
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,11 @@ public interface JDOrderMapper {
|
||||
*/
|
||||
JDOrder selectJDOrderByOrderId(String orderId);
|
||||
|
||||
/**
|
||||
* 批量按京东订单号查询最新慢单(每个 order_id 取 id 最大一条)
|
||||
*/
|
||||
List<JDOrder> selectLatestJDOrdersByOrderIds(@org.apache.ibatis.annotations.Param("orderIds") List<String> orderIds);
|
||||
|
||||
/**
|
||||
* 根据物流链接查询订单
|
||||
*/
|
||||
|
||||
@@ -38,6 +38,9 @@ public interface IJDOrderService {
|
||||
/** 根据订单号查询订单 */
|
||||
JDOrder selectJDOrderByOrderId(String orderId);
|
||||
|
||||
/** 批量按京东订单号查询最新慢单 */
|
||||
List<JDOrder> selectLatestJDOrdersByOrderIds(List<String> orderIds);
|
||||
|
||||
/** 根据物流链接查询订单 */
|
||||
JDOrder selectJDOrderByLogisticsLink(String logisticsLink);
|
||||
|
||||
|
||||
@@ -66,6 +66,14 @@ public class JDOrderServiceImpl implements IJDOrderService {
|
||||
return jdOrderMapper.selectJDOrderByOrderId(orderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JDOrder> selectLatestJDOrdersByOrderIds(List<String> orderIds) {
|
||||
if (orderIds == null || orderIds.isEmpty()) {
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
return jdOrderMapper.selectLatestJDOrdersByOrderIds(orderIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JDOrder selectJDOrderByLogisticsLink(String logisticsLink) {
|
||||
return jdOrderMapper.selectJDOrderByLogisticsLink(logisticsLink);
|
||||
|
||||
@@ -276,6 +276,18 @@
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectLatestJDOrdersByOrderIds" resultMap="JDOrderResult">
|
||||
<include refid="selectJDOrderBase"/>
|
||||
where id in (
|
||||
select max(id) from jd_order
|
||||
where order_id in
|
||||
<foreach collection="orderIds" item="oid" open="(" separator="," close=")">
|
||||
#{oid}
|
||||
</foreach>
|
||||
group by order_id
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="selectJDOrderByLogisticsLink" parameterType="string" resultMap="JDOrderResult">
|
||||
<include refid="selectJDOrderBase"/>
|
||||
where logistics_link = #{logisticsLink}
|
||||
|
||||
Reference in New Issue
Block a user