refactor(order): 重构订单相关功能

- 修改订单信息中的客户和代理商相关字段
- 更新订单信息查询逻辑,移除冗余的客户信息查询
- 优化订单信息展示,直接使用订单实体中的客户信息
- 更新数据库映射,调整字段名称以适应新的业务逻辑
- 修复模板文件中的字段引用
master
chenhao 2025-05-14 15:33:32 +08:00
parent 4988710301
commit 626e5ac48e
9 changed files with 81 additions and 52 deletions

View File

@ -100,7 +100,7 @@
<div class="col-sm-8">
<div class="input-group">
<input class="form-control" type="text" name="orderDeptName" onclick="selectDeptTreePartner()" id="treeName1" required>
<input name="partnerDept" type="hidden" id="treeId1" >
<input name="orderPartnerCode" type="hidden" id="treeId1" >
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>

View File

@ -104,11 +104,11 @@
<div class="form-group">
<label class="col-sm-4 control-label is-required">代理商:</label>
<div class="col-sm-8">
<div class="input-group">
<input name="partnerDept" type="hidden" th:field="*{partnerDept}" id="treeId1">
<input class="form-control" type="text" name="orderDeptName" onclick="selectDeptTreePartner()" id="treeName1" th:field="*{partnerDeptName}" required>
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
<!-- <div class="input-group">-->
<!-- <input name="orderPartnerCode" type="hidden" th:field="*{orderPartnerCode}" id="treeId1">-->
<!-- <input class="form-control" type="text" name="orderDeptName" onclick="selectDeptTreePartner()" id="treeName1" th:field="*{partnerDeptName}" required>-->
<!-- <span class="input-group-addon"><i class="fa fa-search"></i></span>-->
<!-- </div>-->
</div>
</div>
</div>

View File

@ -1,16 +1,21 @@
package com.ruoyi.sip.controller;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.sip.dto.ApiDataQueryDto;
import com.ruoyi.sip.service.IDeliveryListService;
import com.ruoyi.sip.service.IOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Base64;
import java.util.Objects;
/**
* @author : ch
@ -28,22 +33,34 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api")
public class ExternalController {
@Autowired
private IDeliveryListService deliveryListService;
@Autowired
private IDeliveryListService deliveryListService;
@Autowired
private IOrderInfoService orderInfoService;
@GetMapping("/v1/order/info")
@Anonymous
public AjaxResult getOrderInfo(@Validated ApiDataQueryDto dto) {
public AjaxResult getOrderInfo(@Validated ApiDataQueryDto dto, @RequestHeader(value = "apiKey",required = false) String apiKey) {
if (StringUtils.isEmpty(apiKey)) {
return AjaxResult.error("apiKey不能为空");
}
if (!"12345".equals(apiKey)){
return AjaxResult.error("鉴权失败");
}
return AjaxResult.success(orderInfoService.getOrderInfo(dto));
}
@GetMapping("/v1/number/info")
@Anonymous
private AjaxResult getNumberInfo(@Validated ApiDataQueryDto dto){
private AjaxResult getNumberInfo(@Validated ApiDataQueryDto dto,@RequestHeader(value = "apiKey",required = false) String apiKey) {
if (StringUtils.isEmpty(apiKey)) {
return AjaxResult.error("apiKey不能为空");
}
if (!"12345".equals(apiKey)){
return AjaxResult.error("鉴权失败");
}
return AjaxResult.success(deliveryListService.getNumberInfo(dto));
}
}
}

View File

@ -46,6 +46,14 @@ public class OrderInfo extends BaseEntity
private String customerName;
//客户编码
private String customerCode;
/**
*
*/
private String customerPostcode;
//一级行业
private String industryType;
//客户地址
private String customerAddress;
/** 客户联系人 */
private String customerContact;
@ -65,8 +73,8 @@ public class OrderInfo extends BaseEntity
private String orderAgentName;
/** 代理商编码 */
private Long partnerDept;
private String partnerDeptName;
private String orderPartnerCode;
private String orderPartnerName;
/** 合同签定日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")

View File

@ -28,4 +28,5 @@ public class ApiDataQueryDto {
@NotNull(message = "查询结束时间不能为空")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date queryEndTime;
}

View File

@ -165,8 +165,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
// 查询代表处信息
Map<String, AgentInfo> agentInfoMap = queryAgentInfoMap(orderInfos);
// 查询客户信息
Map<String, CustomerInfo> customerInfoMap = queryCustomerInfoMap(orderInfos);
return orderInfos.stream().map(orderInfo -> {
OrderInfoVo orderInfoVo = new OrderInfoVo();
@ -174,12 +173,12 @@ public class OrderInfoServiceImpl implements IOrderInfoService
orderInfoVo.setOrderName(orderInfo.getOrderName());
orderInfoVo.setVersionCode(orderInfo.getVersionCode());
// 固定值待确认
orderInfoVo.setBgProperty("1");
orderInfoVo.setBgType("1");
// 设置代表处信息
setAgentInfo(orderInfoVo, agentInfoMap.get(orderInfo.getOrderAgentCode()));
// 设置客户信息
setCustomerInfo(orderInfoVo, customerInfoMap.get(orderInfo.getCustomerCode()));
setCustomerInfo(orderInfoVo, orderInfo);
return orderInfoVo;
}).collect(Collectors.toList());
@ -201,15 +200,15 @@ public class OrderInfoServiceImpl implements IOrderInfoService
/**
*
*/
private Map<String, CustomerInfo> queryCustomerInfoMap(List<OrderInfo> orderInfos) {
CustomerInfo customerInfoQueryParams = new CustomerInfo();
customerInfoQueryParams.setCustomerCodeList(orderInfos.stream()
.map(OrderInfo::getCustomerCode)
.collect(Collectors.toList()));
List<CustomerInfo> customerInfos = customerInfoService.selectCustomerInfoList(customerInfoQueryParams);
return customerInfos.stream()
.collect(Collectors.toMap(CustomerInfo::getCustomerCode, Function.identity(), (v1, v2) -> v1));
}
// private Map<String, CustomerInfo> queryCustomerInfoMap(List<OrderInfo> orderInfos) {
// CustomerInfo customerInfoQueryParams = new CustomerInfo();
// customerInfoQueryParams.setCustomerCodeList(orderInfos.stream()
// .map(OrderInfo::getCustomerCode)
// .collect(Collectors.toList()));
// List<CustomerInfo> customerInfos = customerInfoService.selectCustomerInfoList(customerInfoQueryParams);
// return customerInfos.stream()
// .collect(Collectors.toMap(CustomerInfo::getCustomerCode, Function.identity(), (v1, v2) -> v1));
// }
/**
*
@ -231,16 +230,16 @@ public class OrderInfoServiceImpl implements IOrderInfoService
/**
*
*/
private void setCustomerInfo(OrderInfoVo orderInfoVo, CustomerInfo customerInfo) {
if (customerInfo != null) {
orderInfoVo.setCustomerCode(customerInfo.getCustomerCode());
orderInfoVo.setCustomerName(customerInfo.getCustomerName());
orderInfoVo.setCustomerPostcode(customerInfo.getCustomerPostcode());
orderInfoVo.setIndustryType(customerInfo.getIndustryType());
orderInfoVo.setCustomerAddress(customerInfo.getAddress());
orderInfoVo.setContactPerson(customerInfo.getContactPerson());
orderInfoVo.setContactEmail(customerInfo.getContactEmail());
orderInfoVo.setContactPhone(customerInfo.getContactPhone());
private void setCustomerInfo(OrderInfoVo orderInfoVo, OrderInfo dto) {
if (dto != null) {
orderInfoVo.setCustomerCode(dto.getCustomerCode());
orderInfoVo.setCustomerName(dto.getCustomerName());
orderInfoVo.setCustomerPostcode(dto.getCustomerPostcode());
orderInfoVo.setIndustryType(dto.getIndustryType());
orderInfoVo.setCustomerAddress(dto.getCustomerAddress());
orderInfoVo.setContactPerson(dto.getCustomerContact());
orderInfoVo.setContactEmail(dto.getCustomerEmail());
orderInfoVo.setContactPhone(dto.getCustomerPhone());
}
}

View File

@ -45,7 +45,7 @@ public class OrderInfoVo {
//客户邮编
private String customerPostcode;
//BG属性
private String bgProperty;
private String bgType;
//一级行业
private String industryType;
//客户地址

View File

@ -24,7 +24,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectCustomerInfoVo">
select id, customer_code, customer_name, customer_postcode, province, city, address, contact_person, contact_phone, contact_email, industry_type, remark, create_at, update_at, delete_at, status from customer_info
select id, customer_code, customer_name, customer_postcode, province, city, address, contact_person,
contact_phone, contact_email, industry_type, remark, create_at, update_at, delete_at, status from customer_info
</sql>
<select id="selectCustomerInfoList" parameterType="CustomerInfo" resultMap="CustomerInfoResult">

View File

@ -17,7 +17,7 @@
<result property="customerEmail" column="customer_email"/>
<result property="orderType" column="order_type"/>
<result property="orderAgentCode" column="order_agent_code"/>
<result property="partnerDept" column="partner_dept"/>
<result property="orderPartnerCode" column="order_partner_code"/>
<result property="orderDate" column="order_date"/>
<result property="status" column="status"/>
<result property="remark" column="remark"/>
@ -79,9 +79,12 @@
customer_contact,
customer_phone,
customer_email,
customer_address,
industry_type,
customer_postcode,
order_type,
order_agent_code,
partner_dept,
order_partner_code,
order_date,
status,
remark,
@ -128,7 +131,7 @@
t1.customer_email,
t1.order_type,
t1.order_agent_code,
t1.partner_dept,
t1.order_partner_code,
t1.order_date,
t1.status,
t1.remark,
@ -136,10 +139,10 @@
t1.updated_at,
t1.deleted_at,
t2.agent_name as order_agent_name,
t3.dept_name as partner_dept_name
t3.partner_name as order_partner_name
from order_info t1
left join agent_info t2 on t1.order_agent_code = t2.agent_code
left join sys_dept t3 on t1.partner_dept = t3.dept_id
left join partner_info t3 on t1.order_partner_code=t3.partner_code
where t1.id = #{id}
</select>
@ -215,7 +218,7 @@
<if test="customerEmail != null">customer_email,</if>
<if test="orderType != null">order_type,</if>
<if test="orderAgentCode != null">order_agent_code,</if>
<if test="partnerDept != null">partner_dept,</if>
<if test="orderPartnerCode != null">order_partner_code,</if>
<if test="orderDate != null">order_date,</if>
<if test="status != null">status,</if>
<if test="remark != null">remark,</if>
@ -232,7 +235,7 @@
<if test="customerEmail != null">#{customerEmail},</if>
<if test="orderType != null">#{orderType},</if>
<if test="orderAgentCode != null">#{orderAgentCode},</if>
<if test="partnerDept != null">#{partnerDept},</if>
<if test="orderPartnerCode != null">#{orderPartnerCode},</if>
<if test="orderDate != null">#{orderDate},</if>
<if test="status != null">#{status},</if>
<if test="remark != null">#{remark},</if>
@ -253,7 +256,7 @@
<if test="customerEmail != null">customer_email = #{customerEmail},</if>
<if test="orderType != null">order_type = #{orderType},</if>
<if test="orderAgentCode != null">order_agent_code = #{orderAgentCode},</if>
<if test="partnerDept != null">partner_dept = #{partnerDept},</if>
<if test="orderPartnerCode != null">order_partner_code = #{orderPartnerCode},</if>
<if test="orderDate != null">order_date = #{orderDate},</if>
<if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>