feat(project): 增加订单渠道枚举并优化客户与供应商编码更新逻辑

- 新增 OrderChannelEnum 枚举类,用于定义订单渠道类型(直签、总代)- 在客户信息更新时同步更新项目信息中的客户编码
- 在供应商信息更新时同步更新订单信息中的供应商编码-优化订单审批流程中代理商编码的获取逻辑
- 调整价格计算函数 setOrderPriceData 的调用方式和参数传递
- 修复产品列表中目录价格输入框值更新的问题
- 增加合作伙伴邮箱字段从前端选择数据中自动填充
- 更新订单导出逻辑中订单渠道显示为枚举值对应的中文描述- 优化邮件发送逻辑,优先使用订单中已有的合作伙伴邮箱- 修复编辑页面中上传按钮点击事件判断条件不准确的问题
dev_1.0.0
chenhao 2025-09-29 20:24:52 +08:00
parent 654cc07f01
commit ef70d29a82
11 changed files with 79 additions and 27 deletions

View File

@ -168,19 +168,20 @@
});
}
function setOrderPriceData(){
calcFlag = true;
function setOrderPriceData(flag){
calcFlag = flag??true;
let allPrice=0.00;
$(".all-price-column").find('.allPrice').each(function (index) {
allPrice+=parseFloat($(this).val())
})
let allPriceDiscount=0.00;
$('.all-price-discount-column').find('.allPrice-discount').each(function (index) {
allPriceDiscount+=parseFloat($(this).val())
})
if (!allPriceDiscount){
allPriceDiscount=1.00
}
// let allPriceDiscount=0.00;
// $('.all-price-discount-column').find('.allPrice-discount').each(function (index) {
// allPriceDiscount+=parseFloat($(this).val())
// })
let discountFold = $('#allPriceCountValue');
let discountFoldValue = discountFold.length > 0 ? discountFold.val() : 1.00
let shipmentAmount = $('#shipmentAmount');
if (shipmentAmount){
allPrice = preciseCurrencyRound(Number(allPrice));
@ -189,7 +190,7 @@
}
let actualPurchaseAmount = $('#actualPurchaseAmount');
if (actualPurchaseAmount.length>0 && !actualPurchaseAmount.val()){
allPriceDiscount = preciseCurrencyRound(Number(allPriceDiscount)*Number(allPrice));
let allPriceDiscount = preciseCurrencyRound(Number(discountFoldValue)*Number(allPrice));
actualPurchaseAmount.val(allPriceDiscount)
$('#displayactualPurchaseAmount').val(formatAmountNumber(allPriceDiscount))
}
@ -328,7 +329,7 @@
<td class="product-desc-column"><textarea name="${submitName}[${length}].productDesc" required class="form-control productDesc" placeholder="自动带入" readonly>${data.productDesc || ''}</textarea></td>
<td class="quantity-column"><input value="${data.quantity || ''}" name="${submitName}[${length}].quantity" type="number" min="0" class="form-control quantity" step="${quantityStepFlag ? 0.1 : 1}" required></td>
<td class="catalogue-price-column"><input value="${data.cataloguePrice || ''}" name="${submitName}[${length}].cataloguePrice" readonly type="hidden" class="form-control cataloguePrice" required>
<input value="${data.cataloguePriceFormmat || ''}" ${flag?"readonly":''} onfocus="getData(this,'cataloguePrice')" onblur="this.value=formatAmountNumber(this.value)" type="text" class="form-control catalogue-price-format" required>
<input value="${data.cataloguePriceFormmat || ''}" ${flag?"readonly":''} onfocus="getData(this,'cataloguePrice')" onblur="this.value=formatAmountNumber(this.value)" type="text" class="form-control catalogue-price-format" required>
</td>
<td class="guidance-discount-column">
<input value="${data.guidanceDiscount || ''}" name="${submitName}[${length}].guidanceDiscount" readonly type="hidden" class="form-control guidanceDiscount" >
@ -384,6 +385,7 @@
* 计算所有产品的目录总价之和并分配到updatePriceProductList产品的目录单价
*/
function calculateAndDistributeCataloguePrice() {
console.log(calcFlag)
if (!canUpdateFlag || !calcFlag) {
return;
}
@ -587,7 +589,7 @@
})
$('.productTable .catalogue-price-format').on('change', function () {
let val = $(this).val()
$(this).parent().parent().find('.cataloguePrice').val(val)
$(this).parent().find('.cataloguePrice').val(val)
let quantity = $(this).parent().parent().find('.quantity').val()
let discount=$(this).parent().parent().find('.discount').val()
if (discount && val){
@ -604,7 +606,7 @@
$(this).parent().parent().find('.catalogueAllPrice').val(preciseCurrencyRound(val * quantity))
$(this).parent().parent().find('.catalogueAllPrice-formmat').val(formatAmountNumber(preciseCurrencyRound(val * quantity)))
}
setOrderPriceData()
setOrderPriceData(false)
})
$('.productTable .guidance-discount-format').on('input', function () {
let val = $(this).val()

View File

@ -749,6 +749,7 @@
return;
}
$('[name="partnerCode"]').val(rows[0].partnerCode);
$('[name="partnerEmail"]').val(rows[0].contactEmail);
$('[name="partnerName"]').val(rows[0].partnerName);
$('[name="level"]').val(rows[0].level);
$('[name="partnerUserName"]').val(rows[0].contactPerson);

View File

@ -1025,7 +1025,9 @@
return;
}
$('[name="partnerCode"]').val(rows[0].partnerCode);
console.log(rows[0])
$('[name="partnerName"]').val(rows[0].partnerName);
$('[name="partnerEmail"]').val(rows[0].contactEmail);
$('[name="level"]').val(rows[0].level);
$('[name="partnerUserName"]').val(rows[0].contactPerson);
$('[name="partnerPhone"]').val(rows[0].contactPhone);
@ -1218,7 +1220,7 @@
function importList(sortNum) {
if (sortNum === 0) {
$('#uploadInput').click()
} else if (sortNum === 1 || sortNum === 2) {
} else if (sortNum === 1 ) {
$('#uploadInput1').click()
} else {
$('#uploadInput2').click()
@ -1295,7 +1297,7 @@
}) : '';
window.localStorage.removeItem('getDetail')
if (!$('#shipmentAmount').val() || !$('#actualPurchaseAmount').val()) {
setOrderPriceData()
setOrderPriceData(false)
}
if (!canUpdate) {
$('.table-responsive table tbody tr td').find('input,textarea').each(function () {

View File

@ -306,6 +306,22 @@ public class ProjectOrderInfo extends BaseEntity {
this.value = value;
}
}
@Getter
public enum OrderChannelEnum {
DIRECT_SIGNING("2", "直签"),
TOTAL_GENERATION("1", "总代"),
;
private final String value;
private final String code;
OrderChannelEnum(String code, String value) {
this.code = code;
this.value = value;
}
}
@Getter
public enum ProcessTemplateEnum {

View File

@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.sip.domain.ProjectInfo;
import com.ruoyi.sip.dto.HomepageQueryDto;
import com.ruoyi.sip.dto.StatisticsDetailDto;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
@ -70,4 +71,5 @@ public interface ProjectInfoMapper
List<StatisticsDetailDto> listHomePageData(HomepageQueryDto dto);
void updateOrderTimeById(Long projectId);
void updateCustomerCodeByCode(@Param("oldValue") String oldValue, @Param("newValue")String newValue);
}

View File

@ -79,4 +79,6 @@ public interface ProjectOrderInfoMapper
List<OrderInfoVo> listOrderInfoVo(ProjectOrderInfo queryParams);
List<ProjectOrderInfo> listByCodeList(List<String> businessKeyList);
void updatePartnerCodeByCode(@Param("oldValue") String partnerCode, @Param("newValue")String newPartnerCode);
}

View File

@ -11,6 +11,7 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.sip.domain.Cnarea;
import com.ruoyi.sip.domain.CustomerInfo;
import com.ruoyi.sip.mapper.CustomerInfoMapper;
import com.ruoyi.sip.mapper.ProjectInfoMapper;
import com.ruoyi.sip.service.ICnareaService;
import com.ruoyi.sip.service.ICustomerInfoService;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,6 +19,8 @@ import org.springframework.stereotype.Service;
import com.ruoyi.common.core.text.Convert;
import javax.annotation.Resource;
/**
* Service
*
@ -29,6 +32,8 @@ public class CustomerInfoServiceImpl implements ICustomerInfoService
{
@Autowired
private CustomerInfoMapper customerInfoMapper;
@Resource
private ProjectInfoMapper projectInfoMapper;
@Autowired
private ICnareaService cnareaService;
// 添加静态锁,确保生成编码的操作是线程安全的
@ -142,6 +147,7 @@ public class CustomerInfoServiceImpl implements ICustomerInfoService
if (count > 0) {
throw new ServiceException("客户编码已存在");
}
projectInfoMapper.updateCustomerCodeByCode(oldCustomerInfo.getCustomerCode(), newCustomerCode);
return customerInfoMapper.updateCustomerInfo(customerInfo);
} finally {
lock.unlock();

View File

@ -12,6 +12,7 @@ import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.sip.domain.Cnarea;
import com.ruoyi.sip.domain.CustomerInfo;
import com.ruoyi.sip.mapper.ProjectOrderInfoMapper;
import com.ruoyi.sip.service.ICnareaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -19,6 +20,9 @@ import com.ruoyi.sip.mapper.PartnerInfoMapper;
import com.ruoyi.sip.domain.PartnerInfo;
import com.ruoyi.sip.service.IPartnerInfoService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* Service
@ -27,12 +31,15 @@ import com.ruoyi.common.core.text.Convert;
* @date 2025-04-30
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class PartnerInfoServiceImpl implements IPartnerInfoService
{
@Autowired
private PartnerInfoMapper partnerInfoMapper;
@Autowired
private ICnareaService cnareaService;
@Resource
private ProjectOrderInfoMapper projectOrderInfoMapper;
// 添加静态锁,确保生成编码的操作是线程安全的
private static final Lock lock = new ReentrantLock();
@ -140,6 +147,7 @@ public class PartnerInfoServiceImpl implements IPartnerInfoService
if (i > 0) {
throw new ServiceException("该编码已存在");
}
projectOrderInfoMapper.updatePartnerCodeByCode(existsInfo.getPartnerCode(),newPartnerCode);
return partnerInfoMapper.updatePartnerInfo(partnerInfo);
} finally {
lock.unlock();

View File

@ -161,7 +161,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To
String dictType= "YYS".equals(projectOrderInfo.getBgProperty())?"bg_yys":"bg_hysy";
projectOrderInfo.setIndustryTypeDesc(DictUtils.getDictLabel(dictType, projectOrderInfo.getIndustryType()));
projectOrderInfo.setOrderChannelDesc(StringUtils.isEmpty(projectOrderInfo.getOrderChannel()) ? "" :
"1".equals(projectOrderInfo.getOrderChannel()) ? "总代" : "直签");
ProjectOrderInfo.OrderChannelEnum.TOTAL_GENERATION.getCode().equals(projectOrderInfo.getOrderChannel()) ? "总代" : "直签");
projectOrderInfo.setLevelDesc(DictUtils.getDictLabel("identify_level", projectOrderInfo.getLevel()));
projectOrderInfo.setCompanyDeliveryDesc(DictUtils.getDictLabel("company_delivery", projectOrderInfo.getCompanyDelivery()));
@ -255,7 +255,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To
List<ProjectOrderInfo> projectOrderInfos = projectOrderInfoMapper.selectProjectOrderInfoList(projectOrderInfo);
for (ProjectOrderInfo orderInfo : projectOrderInfos) {
//省代看总代合同
orderInfo.setShowLog(showLog && "1".equals(orderInfo.getOrderChannel()));
orderInfo.setShowLog(showLog && ProjectOrderInfo.OrderChannelEnum.TOTAL_GENERATION.getCode().equals(orderInfo.getOrderChannel()));
}
return projectOrderInfos;
}
@ -398,7 +398,8 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To
fileLogService.deleteProjectOrderFileLogByIds(deleteFileId);
}
if (ProjectOrderInfo.OrderStatus.WAIT_APPROVE.getCode().equals(projectOrderInfo.getOrderStatus())) {
List<PartnerInfo> partnerInfos = partnerInfoService.selectPartnerInfoByCode(Collections.singletonList(projectOrderInfo.getPartnerCode()));
List<String> codeList = getPartnerCodeByProcessTemplate(projectOrderInfo);
List<PartnerInfo> partnerInfos = partnerInfoService.selectPartnerInfoByCode(codeList);
//线下合同不走省代审批
if (ProjectOrderInfo.ProcessTypeEnum.ONLINE.getCode().equals(projectOrderInfo.getProcessType()) && (CollUtil.isEmpty(partnerInfos) || StringUtils.isEmpty(partnerInfos.get(0).getSystemUserId()))) {
throw new ServiceException(StrUtil.format("代理商配置[{}]未指定系统用户,无法提交审批", existProjectOrderInfo.getPartnerName()));
@ -441,6 +442,11 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To
return projectOrderInfoMapper.updateProjectOrderInfo(projectOrderInfo);
}
private static List<String> getPartnerCodeByProcessTemplate(ProjectOrderInfo projectOrderInfo) {
return ProjectOrderInfo.OrderChannelEnum.TOTAL_GENERATION.getCode().equals(projectOrderInfo.getOrderChannel()) ?
Collections.singletonList("AGT-BJS-0002"):Collections.singletonList(projectOrderInfo.getPartnerCode());
}
@Override
public int updateProjectOrderInfoByCode(ProjectOrderInfo projectOrderInfo) {
return projectOrderInfoMapper.updateProjectOrderInfoByCode(projectOrderInfo);
@ -575,8 +581,8 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To
if (CollUtil.isNotEmpty(todo.getTaxRateData())) {
handleTaxRateData(todo, variables);
}
if (variables.containsKey("allPriceCountValue") && "商务".equals(todo.getTaskName())) {
if (variables.containsKey("allPriceCountValue") && todo.getTaskName().startsWith("商务")) {
BigDecimal allPriceCountValue = new BigDecimal((String) variables.get("allPriceCountValue"));
ProjectOrderInfo projectOrderInfo = new ProjectOrderInfo();
projectOrderInfo.setOrderCode(todo.getBusinessKey());
@ -954,7 +960,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To
row.add(info.getAgentName());
row.add(info.getDutyName());
row.add(StringUtils.isEmpty(info.getOrderChannel()) ? "" :
"1".equals(info.getOrderChannel()) ? "总代" : "直签");
ProjectOrderInfo.OrderChannelEnum.TOTAL_GENERATION.getCode().equals(info.getOrderChannel()) ? "总代" : "直签");
row.add(info.getCustomerName());
row.add(DictUtils.getDictLabel("bg_type", info.getBgProperty()));
@ -1146,11 +1152,13 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To
.collect(Collectors.toList()));
// 查询代理商邮箱
List<PartnerInfo> partnerInfos = partnerInfoService.listByOrderCode(Collections.singletonList(dbProjectOrderInfo.getOrderCode()));
emailList.addAll(partnerInfos.stream()
.map(PartnerInfo::getContactEmail)
.filter(StringUtils::isNotEmpty)
.collect(Collectors.toList()));
if (StringUtils.isNotEmpty(dbProjectOrderInfo.getPartnerEmail())) {
emailList.add(dbProjectOrderInfo.getPartnerEmail());
} else {
List<String> orderCodeList = getPartnerCodeByProcessTemplate(dbProjectOrderInfo);
List<PartnerInfo> partnerInfos = partnerInfoService.selectPartnerInfoByCode(orderCodeList);
emailList.addAll(partnerInfos.stream().map(PartnerInfo::getContactEmail).filter(StringUtils::isNotEmpty).collect(Collectors.toList()));
}
// 发送邮件
this.sendPartnerMail(emailList.stream().distinct().collect(Collectors.toList()), dbProjectOrderInfo);

View File

@ -272,7 +272,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateCustomerCodeByCode">
update project_info set customer_code = #{newValue} where customer_code = #{oldValue}
</update>
<update id="updateProjectInfo" parameterType="ProjectInfo">
update project_info
<trim prefix="SET" suffixOverrides=",">

View File

@ -554,6 +554,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where order_code = #{orderCode}
</update>
<update id="updatePartnerCodeByCode">
update project_order_info set partner_code = #{newValue} where partner_code = #{oldValue}
</update>
<delete id="deleteProjectOrderInfoById" parameterType="Long">
delete from project_order_info where id = #{id}