1.1.3 报价单新增客户ID、质保期字段

dev
yinq 1 month ago
parent 52d2b0229e
commit 38507edcaf

@ -504,7 +504,7 @@ public class TemplateVariableAssignServiceImpl implements ITemplateVariableAssig
continue;
}
// 1) 先处理报价单特殊变量(金额大小写、质保期等)
// 1) 先处理报价单特殊变量(金额大小写等)
Object value = resolveSpecialQuoteValue(variable, quoteInfo);
// 2) 根据变量数据源从主表或明细表取值
@ -533,7 +533,7 @@ public class TemplateVariableAssignServiceImpl implements ITemplateVariableAssig
/**
* data_field
* 线/
* 线/
*/
private Object resolveSpecialQuoteValue(BaseTemplateVariableVo variable, CrmQuoteInfoVo quoteInfo) {
if (variable == null || quoteInfo == null) {
@ -560,11 +560,6 @@ public class TemplateVariableAssignServiceImpl implements ITemplateVariableAssig
return formatMoney(totalAmount);
}
if ("质保期".equals(normalizedVarName)
|| "warrantyPeriodDescription".equalsIgnoreCase(dataField)) {
return StringUtils.isNotBlank(quoteInfo.getRemark()) ? quoteInfo.getRemark() : "";
}
return null;
}

@ -90,6 +90,11 @@ public class CrmQuoteInfo extends TenantEntity {
*/
private Long deliveryPeriod;
/**
*
*/
private Integer warrantyPeriod;
/**
* /
*/
@ -135,6 +140,11 @@ public class CrmQuoteInfo extends TenantEntity {
*/
private BigDecimal totalIncludingTax;
/**
* ID
*/
private Long customerId;
/**
* ID
*/

@ -90,6 +90,11 @@ public class CrmQuoteInfoBo extends BaseEntity {
*/
private Long deliveryPeriod;
/**
*
*/
private Integer warrantyPeriod;
/**
* /
*/
@ -135,6 +140,11 @@ public class CrmQuoteInfoBo extends BaseEntity {
*/
private BigDecimal totalIncludingTax;
/**
* ID
*/
private Long customerId;
/**
* ID
*/

@ -102,7 +102,6 @@ public class CrmQuoteInfoVo implements Serializable {
*
*/
@ExcelProperty(value = "报价有效期", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "天=")
private Long validDays;
/**
@ -115,9 +114,14 @@ public class CrmQuoteInfoVo implements Serializable {
*
*/
@ExcelProperty(value = "交货期", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "天=")
private Long deliveryPeriod;
/**
*
*/
@ExcelProperty(value = "质保期")
private Integer warrantyPeriod;
/**
* /
*/
@ -127,8 +131,7 @@ public class CrmQuoteInfoVo implements Serializable {
/**
* (1 2)
*/
@ExcelProperty(value = "付款方式(1电汇 2承兑)", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "payment_method")
@ExcelProperty(value = "付款方式", converter = ExcelDictConvert.class)
private String paymentMethod;
/**
@ -142,13 +145,12 @@ public class CrmQuoteInfoVo implements Serializable {
* 13%
*/
@ExcelProperty(value = "含税信息", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "如=含13%增值税")
private String taxIncludedInfo;
/**
* ()
*/
@ExcelProperty(value = "税率(默认按明细可覆盖)")
@ExcelProperty(value = "税率")
private BigDecimal taxRate;
/**
@ -175,6 +177,12 @@ public class CrmQuoteInfoVo implements Serializable {
@ExcelProperty(value = "含税总价")
private BigDecimal totalIncludingTax;
/**
* ID
*/
@ExcelProperty(value = "客户ID")
private Long customerId;
/**
* ID
*/
@ -250,7 +258,7 @@ public class CrmQuoteInfoVo implements Serializable {
/**
* (1 2 3)
*/
@ExcelProperty(value = "报价单状态(1暂存 2审批中 3可用)", converter = ExcelDictConvert.class)
@ExcelProperty(value = "报价单状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "quote_status")
private String quoteStatus;
@ -271,9 +279,6 @@ public class CrmQuoteInfoVo implements Serializable {
@ExcelProperty(value = "客户方联系人(实时)")
private String customerContactRealName;
/** 派生供货方联系人真实名称CrmCustomerContact */
/* @ExcelProperty(value = "供货方联系人(实时)")
private String supplierContactRealName;*/
/**
*
*/
@ -286,7 +291,6 @@ public class CrmQuoteInfoVo implements Serializable {
@ExcelProperty(value = "报价单子表-物料明细")
private List<CrmQuoteMaterialVo> itemsVo;
/**
*
*/

@ -143,7 +143,7 @@ public class CrmQuoteInfoServiceImpl implements ICrmQuoteInfoService {
// 客户公司名称CrmCustomerInfo
.select(CrmCustomerInfo::getCustomerName)
.leftJoin(CrmCustomerInfo.class, CrmCustomerInfo::getCustomerId, CrmCustomerContact::getCustomerId)
.leftJoin(CrmCustomerInfo.class, CrmCustomerInfo::getCustomerId, CrmQuoteInfo::getCustomerId)
/*
// 供货方联系人CrmCustomerContact别名SupplierContact
@ -166,6 +166,7 @@ public class CrmQuoteInfoServiceImpl implements ICrmQuoteInfoService {
.eq(bo.getValidDays() != null, CrmQuoteInfo::getValidDays, bo.getValidDays())
.eq(bo.getValidTo() != null, CrmQuoteInfo::getValidTo, bo.getValidTo())
.eq(bo.getDeliveryPeriod() != null, CrmQuoteInfo::getDeliveryPeriod, bo.getDeliveryPeriod())
.eq(bo.getWarrantyPeriod() != null, CrmQuoteInfo::getWarrantyPeriod, bo.getWarrantyPeriod())
.eq(StringUtils.isNotBlank(bo.getDeliveryMethod()), CrmQuoteInfo::getDeliveryMethod, bo.getDeliveryMethod())
.eq(StringUtils.isNotBlank(bo.getPaymentMethod()), CrmQuoteInfo::getPaymentMethod, bo.getPaymentMethod())
.eq(StringUtils.isNotBlank(bo.getCurrencyType()), CrmQuoteInfo::getCurrencyType, bo.getCurrencyType())
@ -175,6 +176,7 @@ public class CrmQuoteInfoServiceImpl implements ICrmQuoteInfoService {
.eq(bo.getTotalBeforeTax() != null, CrmQuoteInfo::getTotalBeforeTax, bo.getTotalBeforeTax())
.eq(bo.getTotalTax() != null, CrmQuoteInfo::getTotalTax, bo.getTotalTax())
.eq(bo.getTotalIncludingTax() != null, CrmQuoteInfo::getTotalIncludingTax, bo.getTotalIncludingTax())
.eq(bo.getCustomerId() != null, CrmQuoteInfo::getCustomerId, bo.getCustomerId())
.eq(bo.getCustomerContactId() != null, CrmQuoteInfo::getCustomerContactId, bo.getCustomerContactId())
.like(StringUtils.isNotBlank(bo.getCustomerContactName()), CrmQuoteInfo::getCustomerContactName, bo.getCustomerContactName())
.eq(StringUtils.isNotBlank(bo.getCustomerContactPhone()), CrmQuoteInfo::getCustomerContactPhone, bo.getCustomerContactPhone())
@ -203,8 +205,8 @@ public class CrmQuoteInfoServiceImpl implements ICrmQuoteInfoService {
@Transactional(rollbackFor = Exception.class)
public Boolean insertByBo(CrmQuoteInfoBo bo) {
CrmQuoteInfo add = MapstructUtils.convert(bo, CrmQuoteInfo.class);
fillCustomerInfo(bo, add);
validEntityBeforeSave(add);
Long customerId = resolveCustomerId(bo.getCustomerContactId());
String quoteCode = remoteCodeRuleService.selectCodeRuleCode("1004");
add.setQuoteCode(quoteCode);
@ -225,7 +227,7 @@ public class CrmQuoteInfoServiceImpl implements ICrmQuoteInfoService {
if (entity.getItemNo() == null) {
entity.setItemNo((long) (i + 1));
}
processRelationMaterial(entity, customerId);
processRelationMaterial(entity, add.getCustomerId());
quoteMaterialMapper.insert(entity);
}
// 回写主表金额汇总
@ -245,12 +247,12 @@ public class CrmQuoteInfoServiceImpl implements ICrmQuoteInfoService {
@Transactional(rollbackFor = Exception.class)
public Boolean updateByBo(CrmQuoteInfoBo bo) {
CrmQuoteInfo update = MapstructUtils.convert(bo, CrmQuoteInfo.class);
fillCustomerInfo(bo, update);
validEntityBeforeSave(update);
boolean ok = baseMapper.updateById(update) > 0;
if (!ok) return false;
// 差异更新子表:存在则更新,不存在则插入;并删除前端未提交的旧记录
Long qid = bo.getQuoteId();
Long customerId = resolveCustomerId(bo.getCustomerContactId());
List<CrmQuoteMaterial> oldItems = quoteMaterialMapper.selectList(
Wrappers.<CrmQuoteMaterial>lambdaQuery().eq(CrmQuoteMaterial::getQuoteId, qid)
);
@ -266,7 +268,7 @@ public class CrmQuoteInfoServiceImpl implements ICrmQuoteInfoService {
if (entity.getItemNo() == null) {
entity.setItemNo((long) (i + 1));
}
processRelationMaterial(entity, customerId);
processRelationMaterial(entity, update.getCustomerId());
// 使用 insertOrUpdate 简化增改逻辑,参考合同物料实现
quoteMaterialMapper.insertOrUpdate(entity);
}
@ -311,6 +313,20 @@ public class CrmQuoteInfoServiceImpl implements ICrmQuoteInfoService {
return customerContactVo == null ? null : customerContactVo.getCustomerId();
}
private void fillCustomerInfo(CrmQuoteInfoBo bo, CrmQuoteInfo entity) {
Long resolvedCustomerId = bo.getCustomerId();
if (resolvedCustomerId == null && bo.getCustomerContactId() != null) {
resolvedCustomerId = resolveCustomerId(bo.getCustomerContactId());
}
if (resolvedCustomerId != null && bo.getCustomerContactId() != null) {
Long contactCustomerId = resolveCustomerId(bo.getCustomerContactId());
if (contactCustomerId != null && !Objects.equals(contactCustomerId, resolvedCustomerId)) {
throw new ServiceException("所选联系人不属于当前客户");
}
}
entity.setCustomerId(resolvedCustomerId);
}
/**
*
* <p>
@ -459,14 +475,9 @@ public class CrmQuoteInfoServiceImpl implements ICrmQuoteInfoService {
if (base == null) {
return List.of();
}
// 通过联系人拿客户ID
Long contactId = base.getCustomerContactId();
Long customerId = null;
if (contactId != null) {
CrmCustomerContactVo contactVo = customerContactService.queryById(contactId);
if (contactVo != null) {
customerId = contactVo.getCustomerId();
}
Long customerId = base.getCustomerId();
if (customerId == null) {
customerId = resolveCustomerId(base.getCustomerContactId());
}
MPJLambdaWrapper<CrmQuoteInfo> lqw = JoinWrappers.lambda(CrmQuoteInfo.class)
@ -476,15 +487,14 @@ public class CrmQuoteInfoServiceImpl implements ICrmQuoteInfoService {
.leftJoin(CrmCustomerContact.class, "CustomerContact", CrmCustomerContact::getContactId, CrmQuoteInfo::getCustomerContactId)
// 客户公司名称
.select(CrmCustomerInfo::getCustomerName)
.leftJoin(CrmCustomerInfo.class, "Customer", CrmCustomerInfo::getCustomerId, CrmCustomerContact::getCustomerId)
.leftJoin(CrmCustomerInfo.class, "Customer", CrmCustomerInfo::getCustomerId, CrmQuoteInfo::getCustomerId)
// .leftJoin(CrmCustomerContact.class, "SupplierContact", CrmCustomerContact::getContactId, CrmQuoteInfo::getSupplierContactId)
//供应商信息
.select(CrmSupplierInfo::getSupplierName)
.leftJoin(CrmSupplierInfo.class, CrmSupplierInfo::getSupplierId, CrmQuoteInfo::getSupplierContactId)
// .selectAs("SupplierContact", CrmCustomerContact::getContactName, CrmQuoteInfo::getSupplierContactRealName)
.eq(CrmQuoteInfo::getQuoteName, base.getQuoteName())
// 使用客户方联系人别名的 customer_id 过滤同一客户
.eq(customerId != null, CrmCustomerContact::getCustomerId, customerId)
.eq(customerId != null, CrmQuoteInfo::getCustomerId, customerId)
.orderByAsc(CrmQuoteInfo::getQuoteDate);
return baseMapper.selectVoList(lqw);

@ -8,22 +8,24 @@
<select id="selectCustomCrmQuoteInfoVoList" resultMap="CrmQuoteInfoResult">
select t.quote_id, t.tenant_id, t.quote_code, t.quote_name, t.quote_round, t.quote_category,
t.quote_type, t.business_direction, t.quote_dept_id, t.quote_date, t.valid_from, t.valid_days, t.valid_to,
t.delivery_period, t.delivery_method, t.payment_method, t.currency_type, t.tax_included_info, t.tax_rate, t.total_price, t.total_before_tax,
t.total_tax, t.total_including_tax, t.customer_contact_id, t.customer_contact_name, t.customer_contact_phone, t.customer_contact_email,
t.supplier_contact_id, t.supplier_contact_name, t.supplier_contact_phone, t.supplier_contact_email, t.project_id, t.template_id, t.oss_id, t.quote_status,
t.flow_status, t.remark,
ci.customer_name as customerName,
s.supplier_name as supplierName,
d.dept_name as deptName,
u3.nick_name as createName,
t.del_flag, t.create_dept, t.create_by, t.create_time, t.update_by, t.update_time
t.quote_type, t.business_direction, t.quote_dept_id, t.quote_date, t.valid_from, t.valid_days, t.valid_to,
t.delivery_period, t.warranty_period, t.delivery_method, t.payment_method, t.currency_type, t.tax_included_info, t.tax_rate,
t.total_price, t.total_before_tax,
t.total_tax, t.total_including_tax, t.customer_id, t.customer_contact_id, t.customer_contact_name,
t.customer_contact_phone, t.customer_contact_email,
t.supplier_contact_id, t.supplier_contact_name, t.supplier_contact_phone, t.supplier_contact_email,
t.project_id, t.template_id, t.oss_id, t.quote_status,
t.flow_status, t.remark,
ci.customer_name as customerName,
s.supplier_name as supplierName,
d.dept_name as deptName,
u3.nick_name as createName,
t.del_flag, t.create_dept, t.create_by, t.create_time, t.update_by, t.update_time
from crm_quote_info t
left join sys_user u3 on t.create_by = u3.user_id
left join sys_dept d on d.dept_id = t.quote_dept_id
left join crm_customer_contact cc on t.customer_contact_id = cc.contact_id
left join crm_customer_info ci on ci.customer_id = cc.customer_id
left join crm_supplier_info s on s.supplier_id = t.supplier_contact_id
left join sys_user u3 on t.create_by = u3.user_id
left join sys_dept d on d.dept_id = t.quote_dept_id
left join crm_customer_info ci on ci.customer_id = t.customer_id
left join crm_supplier_info s on s.supplier_id = t.supplier_contact_id
<where>
<if test="ew != null and ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment}
@ -33,17 +35,67 @@
<!-- 根据ID查询详情 -->
<select id="selectCustomCrmQuoteInfoVoById" resultMap="CrmQuoteInfoResult">
select t.quote_id, t.tenant_id, t.quote_code, t.quote_name, t.quote_round, t.quote_category, t.quote_type, t.business_direction, t.quote_dept_id, t.quote_date, t.valid_from, t.valid_days, t.valid_to, t.delivery_period, t.delivery_method, t.payment_method, t.currency_type, t.tax_included_info, t.tax_rate, t.total_price, t.total_before_tax, t.total_tax, t.total_including_tax, t.customer_contact_id, t.customer_contact_name, t.customer_contact_phone, t.customer_contact_email, t.supplier_contact_id, t.supplier_contact_name, t.supplier_contact_phone, t.supplier_contact_email, t.project_id, t.template_id, t.oss_id, t.quote_status, t.flow_status, t.remark, t.del_flag, t.create_dept, t.create_by, t.create_time, t.update_by, t.update_time
select t.quote_id,
t.tenant_id,
t.quote_code,
t.quote_name,
t.quote_round,
t.quote_category,
t.quote_type,
t.business_direction,
t.quote_dept_id,
t.quote_date,
t.valid_from,
t.valid_days,
t.valid_to,
t.delivery_period,
t.warranty_period,
t.delivery_method,
t.payment_method,
t.currency_type,
t.tax_included_info,
t.tax_rate,
t.total_price,
t.total_before_tax,
t.total_tax,
t.total_including_tax,
t.customer_id,
t.customer_contact_id,
t.customer_contact_name,
t.customer_contact_phone,
t.customer_contact_email,
t.supplier_contact_id,
t.supplier_contact_name,
t.supplier_contact_phone,
t.supplier_contact_email,
t.project_id,
t.template_id,
t.oss_id,
t.quote_status,
t.flow_status,
t.remark,
ci.customer_name as customerName,
t.del_flag,
t.create_dept,
t.create_by,
t.create_time,
t.update_by,
t.update_time
from crm_quote_info t
left join crm_customer_info ci on ci.customer_id = t.customer_id
where t.quote_id = #{quoteId}
</select>
<!-- 批量查询 - 根据ID列表 -->
<select id="selectCustomCrmQuoteInfoVoByIds" resultMap="CrmQuoteInfoResult">
select t.quote_id, t.tenant_id, t.quote_code, t.quote_name, t.quote_round, t.quote_category,
t.quote_type, t.business_direction, t.quote_dept_id, t.quote_date, t.valid_from, t.valid_days,
t.valid_to, t.delivery_period, t.delivery_method, t.payment_method, t.currency_type, t.tax_included_info,
t.tax_rate, t.total_price, t.total_before_tax, t.total_tax, t.total_including_tax, t.customer_contact_id, t.customer_contact_name, t.customer_contact_phone, t.customer_contact_email, t.supplier_contact_id, t.supplier_contact_name, t.supplier_contact_phone, t.supplier_contact_email, t.project_id, t.template_id, t.oss_id, t.quote_status, t.flow_status, t.remark, t.del_flag, t.create_dept, t.create_by, t.create_time, t.update_by, t.update_time
t.quote_type, t.business_direction, t.quote_dept_id, t.quote_date, t.valid_from, t.valid_days,
t.valid_to, t.delivery_period, t.warranty_period, t.delivery_method, t.payment_method, t.currency_type, t.tax_included_info,
t.tax_rate, t.total_price, t.total_before_tax, t.total_tax, t.total_including_tax, t.customer_id,
t.customer_contact_id, t.customer_contact_name, t.customer_contact_phone, t.customer_contact_email,
t.supplier_contact_id, t.supplier_contact_name, t.supplier_contact_phone, t.supplier_contact_email,
t.project_id, t.template_id, t.oss_id, t.quote_status, t.flow_status, t.remark, t.del_flag, t.create_dept,
t.create_by, t.create_time, t.update_by, t.update_time
from crm_quote_info t
where t.quote_id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
@ -63,7 +115,7 @@
<!-- 分页查询(带自定义条件) -->
<select id="selectCustomCrmQuoteInfoVoPage" resultMap="CrmQuoteInfoResult">
select quote_id, tenant_id, quote_code, quote_name, quote_round, quote_category, quote_type, business_direction, quote_dept_id, quote_date, valid_from, valid_days, valid_to, delivery_period, delivery_method, payment_method, currency_type, tax_included_info, tax_rate, total_price, total_before_tax, total_tax, total_including_tax, customer_contact_id, customer_contact_name, customer_contact_phone, customer_contact_email, supplier_contact_id, supplier_contact_name, supplier_contact_phone, supplier_contact_email, project_id, template_id, oss_id, quote_status, flow_status, remark, del_flag, create_dept, create_by, create_time, update_by, update_time
select quote_id, tenant_id, quote_code, quote_name, quote_round, quote_category, quote_type, business_direction, quote_dept_id, quote_date, valid_from, valid_days, valid_to, delivery_period, warranty_period, delivery_method, payment_method, currency_type, tax_included_info, tax_rate, total_price, total_before_tax, total_tax, total_including_tax, customer_id, customer_contact_id, customer_contact_name, customer_contact_phone, customer_contact_email, supplier_contact_id, supplier_contact_name, supplier_contact_phone, supplier_contact_email, project_id, template_id, oss_id, quote_status, flow_status, remark, del_flag, create_dept, create_by, create_time, update_by, update_time
from crm_quote_info t
<where>
<if test="ew != null and ew.sqlSegment != null and ew.sqlSegment != ''">
@ -101,6 +153,8 @@
delivery_period,
warranty_period,
delivery_method,
payment_method,
@ -119,6 +173,8 @@
total_including_tax,
customer_id,
customer_contact_id,
customer_contact_name,
@ -189,6 +245,8 @@
#{item.deliveryPeriod},
#{item.warrantyPeriod},
#{item.deliveryMethod},
#{item.paymentMethod},
@ -207,6 +265,8 @@
#{item.totalIncludingTax},
#{item.customerId},
#{item.customerContactId},
#{item.customerContactName},
@ -295,6 +355,9 @@
<if test="item.deliveryPeriod != null">
delivery_period = #{item.deliveryPeriod},
</if>
<if test="item.warrantyPeriod != null">
warranty_period = #{item.warrantyPeriod},
</if>
<if test="item.deliveryMethod != null and item.deliveryMethod != ''">
delivery_method = #{item.deliveryMethod},
</if>
@ -322,6 +385,9 @@
<if test="item.totalIncludingTax != null">
total_including_tax = #{item.totalIncludingTax},
</if>
<if test="item.customerId != null">
customer_id = #{item.customerId},
</if>
<if test="item.customerContactId != null">
customer_contact_id = #{item.customerContactId},
</if>

Loading…
Cancel
Save