diff --git a/ruoyi-admin/src/main/resources/templates/layout/product-list.html b/ruoyi-admin/src/main/resources/templates/layout/product-list.html index 2b0909a6..3266aa0a 100644 --- a/ruoyi-admin/src/main/resources/templates/layout/product-list.html +++ b/ruoyi-admin/src/main/resources/templates/layout/product-list.html @@ -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 @@ - + @@ -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() diff --git a/ruoyi-admin/src/main/resources/templates/project/order/add.html b/ruoyi-admin/src/main/resources/templates/project/order/add.html index bea218db..4c6fc9c9 100644 --- a/ruoyi-admin/src/main/resources/templates/project/order/add.html +++ b/ruoyi-admin/src/main/resources/templates/project/order/add.html @@ -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); diff --git a/ruoyi-admin/src/main/resources/templates/project/order/edit.html b/ruoyi-admin/src/main/resources/templates/project/order/edit.html index f62ec9db..18c3ff15 100644 --- a/ruoyi-admin/src/main/resources/templates/project/order/edit.html +++ b/ruoyi-admin/src/main/resources/templates/project/order/edit.html @@ -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 () { diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/ProjectOrderInfo.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/ProjectOrderInfo.java index d893275f..3fb4bf55 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/ProjectOrderInfo.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/ProjectOrderInfo.java @@ -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 { diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectInfoMapper.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectInfoMapper.java index e91c5603..b2487545 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectInfoMapper.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectInfoMapper.java @@ -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 listHomePageData(HomepageQueryDto dto); void updateOrderTimeById(Long projectId); + void updateCustomerCodeByCode(@Param("oldValue") String oldValue, @Param("newValue")String newValue); } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectOrderInfoMapper.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectOrderInfoMapper.java index d2e3d941..902ef689 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectOrderInfoMapper.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectOrderInfoMapper.java @@ -79,4 +79,6 @@ public interface ProjectOrderInfoMapper List listOrderInfoVo(ProjectOrderInfo queryParams); List listByCodeList(List businessKeyList); + + void updatePartnerCodeByCode(@Param("oldValue") String partnerCode, @Param("newValue")String newPartnerCode); } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/CustomerInfoServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/CustomerInfoServiceImpl.java index 5f471892..2b1dd790 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/CustomerInfoServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/CustomerInfoServiceImpl.java @@ -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(); diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/PartnerInfoServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/PartnerInfoServiceImpl.java index c9b1ac32..e158cf76 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/PartnerInfoServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/PartnerInfoServiceImpl.java @@ -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(); diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java index 98fe0dfb..c4f0a23d 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java @@ -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 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 partnerInfos = partnerInfoService.selectPartnerInfoByCode(Collections.singletonList(projectOrderInfo.getPartnerCode())); + List codeList = getPartnerCodeByProcessTemplate(projectOrderInfo); + List 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 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 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 orderCodeList = getPartnerCodeByProcessTemplate(dbProjectOrderInfo); + List 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); diff --git a/ruoyi-sip/src/main/resources/mapper/sip/ProjectInfoMapper.xml b/ruoyi-sip/src/main/resources/mapper/sip/ProjectInfoMapper.xml index 5dd786e5..dcc6092c 100644 --- a/ruoyi-sip/src/main/resources/mapper/sip/ProjectInfoMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/sip/ProjectInfoMapper.xml @@ -272,7 +272,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{updateTime}, - + + update project_info set customer_code = #{newValue} where customer_code = #{oldValue} + update project_info diff --git a/ruoyi-sip/src/main/resources/mapper/sip/ProjectOrderInfoMapper.xml b/ruoyi-sip/src/main/resources/mapper/sip/ProjectOrderInfoMapper.xml index cc504e82..6fb9fd4a 100644 --- a/ruoyi-sip/src/main/resources/mapper/sip/ProjectOrderInfoMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/sip/ProjectOrderInfoMapper.xml @@ -554,6 +554,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where order_code = #{orderCode} + + update project_order_info set partner_code = #{newValue} where partner_code = #{oldValue} + delete from project_order_info where id = #{id}