feat(sip): 根据项目ID生成订单编号
- 新增根据项目ID获取代理省份的方法- 修改订单编号生成逻辑,使用代理省份而非直接使用省份参数- 增加异常处理,当代理省份为空时抛出服务异常 - 优化数据库查询,减少冗余的省份参数传递master
parent
7d23b0ade8
commit
1a66bb45b1
|
@ -59,4 +59,6 @@ public interface AgentInfoMapper
|
|||
*/
|
||||
public int deleteAgentInfoByIds(String[] ids);
|
||||
public int selectCountByCode(AgentInfo agentInfo);
|
||||
|
||||
AgentInfo selectAgentInfoByCode(String agentCode);
|
||||
}
|
||||
|
|
|
@ -62,4 +62,6 @@ public interface ProjectOrderInfoMapper
|
|||
List<ProjectOrderInfo> selectProjectOrderInfoByProjectId(List<Long> projectId);
|
||||
|
||||
int selectMaxOrderCode(String province);
|
||||
|
||||
String selectAgentProvinceByProjectId(Long projectId);
|
||||
}
|
||||
|
|
|
@ -58,4 +58,6 @@ public interface IAgentInfoService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteAgentInfoById(Long id);
|
||||
|
||||
AgentInfo selectAgentInfoByCode(String agentCode);
|
||||
}
|
||||
|
|
|
@ -105,4 +105,10 @@ public class AgentInfoServiceImpl implements IAgentInfoService
|
|||
{
|
||||
return agentInfoMapper.deleteAgentInfoById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgentInfo selectAgentInfoByCode(String agentCode) {
|
||||
|
||||
return agentInfoMapper.selectAgentInfoByCode(agentCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ShiroUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.sip.domain.*;
|
||||
import com.ruoyi.sip.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -34,6 +35,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
private IProjectProductInfoService productInfoService;
|
||||
@Autowired
|
||||
private ICnareaService cnareaService;
|
||||
|
||||
/**
|
||||
* 查询订单管理
|
||||
*
|
||||
|
@ -80,8 +82,9 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
*/
|
||||
@Override
|
||||
public int insertProjectOrderInfo(ProjectOrderInfo projectOrderInfo) {
|
||||
|
||||
// 生成订单编号
|
||||
String orderNumber = generateOrderNumber(projectOrderInfo.getProvince());
|
||||
String orderNumber = generateOrderNumber(projectOrderInfo.getProjectId());
|
||||
projectOrderInfo.setOrderCode(orderNumber);
|
||||
projectOrderInfo.setCreateTime(DateUtils.getNowDate());
|
||||
projectOrderInfo.setCreateBy(ShiroUtils.getUserId().toString());
|
||||
|
@ -111,7 +114,11 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
* @param province 省份代码
|
||||
* @return 订单编号
|
||||
*/
|
||||
private String generateOrderNumber(String province) {
|
||||
private String generateOrderNumber(Long projectId) {
|
||||
String province = projectOrderInfoMapper.selectAgentProvinceByProjectId(projectId);
|
||||
if (StringUtils.isEmpty(province)) {
|
||||
throw new ServiceException("代表处所属省为空,无法生成订单编号");
|
||||
}
|
||||
// 获取当前时间,格式为yyyyMMdd
|
||||
String currentDate = DateUtils.dateTimeNow("yyyyMMdd");
|
||||
Cnarea cnarea = new Cnarea();
|
||||
|
@ -143,7 +150,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
public int updateProjectOrderInfo(ProjectOrderInfo projectOrderInfo) {
|
||||
ProjectOrderInfo existProjectOrderInfo = projectOrderInfoMapper.selectProjectOrderInfoById(projectOrderInfo.getId());
|
||||
if (!existProjectOrderInfo.getProvince().equals(projectOrderInfo.getProvince())) {
|
||||
String orderNumber = generateOrderNumber(projectOrderInfo.getProvince());
|
||||
String orderNumber = generateOrderNumber(projectOrderInfo.getProjectId());
|
||||
projectOrderInfo.setOrderCode(orderNumber);
|
||||
}
|
||||
projectOrderInfo.setUpdateBy(ShiroUtils.getUserId().toString());
|
||||
|
|
|
@ -101,6 +101,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
|
||||
|
||||
</select>
|
||||
<select id="selectAgentProvinceByProjectId" resultType="java.lang.String">
|
||||
select t2.province
|
||||
from project_info t1
|
||||
inner join agent_info t2 on t1.agent_code = t2.agent_code
|
||||
where t1.id = #{projectId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertProjectOrderInfo" parameterType="ProjectOrderInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
|
|
|
@ -49,6 +49,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where agent_code=#{agentCode} and status=0
|
||||
<if test="id != null">and id!=#{id}</if>
|
||||
</select>
|
||||
<select id="selectAgentInfoByCode" resultType="com.ruoyi.sip.domain.AgentInfo">
|
||||
<include refid="selectAgentInfoVo"/>
|
||||
where agent_code=#{agentCode}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertAgentInfo" parameterType="AgentInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into agent_info
|
||||
|
|
Loading…
Reference in New Issue