|
|
|
|
@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
|
|
import org.dromara.common.core.service.DictService;
|
|
|
|
|
import org.dromara.common.core.validate.AddGroup;
|
|
|
|
|
import org.dromara.common.core.validate.EditGroup;
|
|
|
|
|
import org.dromara.common.excel.utils.ExcelUtil;
|
|
|
|
|
@ -47,6 +48,7 @@ import java.util.*;
|
|
|
|
|
public class CrmQuoteInfoController extends BaseController {
|
|
|
|
|
|
|
|
|
|
private final ICrmQuoteInfoService crmQuoteInfoService;
|
|
|
|
|
private final DictService dictService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询报价单信息列表
|
|
|
|
|
@ -172,13 +174,29 @@ public class CrmQuoteInfoController extends BaseController {
|
|
|
|
|
templateData.put("title", quoteInfo.getQuoteName() != null ? quoteInfo.getQuoteName() : "");
|
|
|
|
|
templateData.put("quoteDate", quoteInfo.getQuoteDate() != null ? DateUtil.format(quoteInfo.getQuoteDate(), "yyyy年MM月dd日") : "");
|
|
|
|
|
templateData.put("taxIncludedInfo", quoteInfo.getTaxIncludedInfo() != null ? quoteInfo.getTaxIncludedInfo() : "");
|
|
|
|
|
templateData.put("paymentMethod", quoteInfo.getPaymentMethod() != null ? quoteInfo.getPaymentMethod() : "");
|
|
|
|
|
templateData.put("deliveryPeriod", quoteInfo.getDeliveryPeriod() != null ? quoteInfo.getDeliveryPeriod() + "天" : "");
|
|
|
|
|
templateData.put("deliveryMethod", quoteInfo.getDeliveryMethod() != null ? quoteInfo.getDeliveryMethod() : "");
|
|
|
|
|
templateData.put("quoteValidity", quoteInfo.getValidDays() != null ? quoteInfo.getValidDays() + "天" : "");
|
|
|
|
|
//付款方式字典
|
|
|
|
|
String paymentMethodLabel = "";
|
|
|
|
|
if (quoteInfo.getPaymentMethod() != null) {
|
|
|
|
|
String dictLabel = dictService.getDictLabel("payment_method", quoteInfo.getPaymentMethod());
|
|
|
|
|
paymentMethodLabel = dictLabel != null ? dictLabel : "";
|
|
|
|
|
}
|
|
|
|
|
templateData.put("paymentMethod", paymentMethodLabel);
|
|
|
|
|
//币种字典
|
|
|
|
|
String currencyLabel = "人民币";
|
|
|
|
|
if (quoteInfo.getCurrencyType() != null) {
|
|
|
|
|
String dictLabel = dictService.getDictLabel("currency_type", quoteInfo.getCurrencyType());
|
|
|
|
|
if (dictLabel != null) {
|
|
|
|
|
currencyLabel = dictLabel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
templateData.put("currencyType", currencyLabel);
|
|
|
|
|
|
|
|
|
|
// 币种
|
|
|
|
|
templateData.put("currencyType", quoteInfo.getCurrencyType() != null ? quoteInfo.getCurrencyType() : "人民币");
|
|
|
|
|
// 价格单位,根据币种名称解析
|
|
|
|
|
String priceUnit = resolvePriceUnit(currencyLabel);
|
|
|
|
|
templateData.put("priceUnit", priceUnit);
|
|
|
|
|
|
|
|
|
|
// 金额相关
|
|
|
|
|
BigDecimal totalAmount = quoteInfo.getTotalIncludingTax() != null ? quoteInfo.getTotalIncludingTax() : BigDecimal.ZERO;
|
|
|
|
|
@ -191,6 +209,9 @@ public class CrmQuoteInfoController extends BaseController {
|
|
|
|
|
templateData.put("supplierContactPhone", quoteInfo.getSupplierContactPhone() != null ? quoteInfo.getSupplierContactPhone() : "");
|
|
|
|
|
templateData.put("supplierContactEmail", quoteInfo.getSupplierContactEmail() != null ? quoteInfo.getSupplierContactEmail() : "");
|
|
|
|
|
|
|
|
|
|
//总备注
|
|
|
|
|
templateData.put("totalRemark", quoteInfo.getRemark() != null ? quoteInfo.getRemark() : "");
|
|
|
|
|
|
|
|
|
|
// 准备明细数据列表(对应模板中的{.key}占位符)
|
|
|
|
|
List<QuoteTemplateMaterialDto> materialList = new ArrayList<>();
|
|
|
|
|
if (CollUtil.isNotEmpty(quoteInfo.getItemsVo())) {
|
|
|
|
|
@ -235,5 +256,99 @@ public class CrmQuoteInfoController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据币种名称解析价格单位
|
|
|
|
|
* 例如:币种包含“人民币”时,价格单位为“元”
|
|
|
|
|
* 其他币种默认返回币种名称本身
|
|
|
|
|
*
|
|
|
|
|
* @param currencyLabel 币种名称
|
|
|
|
|
* @return 价格单位
|
|
|
|
|
*/
|
|
|
|
|
private String resolvePriceUnit(String currencyLabel) {
|
|
|
|
|
if (currencyLabel == null || currencyLabel.isBlank()) {
|
|
|
|
|
return "元";
|
|
|
|
|
}
|
|
|
|
|
String label = currencyLabel.trim();
|
|
|
|
|
|
|
|
|
|
// 人民币:使用 if 单独处理
|
|
|
|
|
if (label.contains("人民币") || "CNY".equalsIgnoreCase(label) || "RMB".equalsIgnoreCase(label)) {
|
|
|
|
|
return "元";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 其他币种:使用 switch,按中英文名称和常见代码匹配
|
|
|
|
|
switch (label) {
|
|
|
|
|
case "美元":
|
|
|
|
|
case "美金":
|
|
|
|
|
case "USD":
|
|
|
|
|
return "美元";
|
|
|
|
|
case "欧元":
|
|
|
|
|
case "EUR":
|
|
|
|
|
return "欧元";
|
|
|
|
|
case "日元":
|
|
|
|
|
case "日币":
|
|
|
|
|
case "JPY":
|
|
|
|
|
return "日元";
|
|
|
|
|
case "英镑":
|
|
|
|
|
case "GBP":
|
|
|
|
|
return "英镑";
|
|
|
|
|
case "港币":
|
|
|
|
|
case "HKD":
|
|
|
|
|
return "港币";
|
|
|
|
|
case "韩元":
|
|
|
|
|
case "韩币":
|
|
|
|
|
case "KRW":
|
|
|
|
|
return "韩元";
|
|
|
|
|
case "加元":
|
|
|
|
|
case "CAD":
|
|
|
|
|
return "加元";
|
|
|
|
|
case "澳元":
|
|
|
|
|
case "AUD":
|
|
|
|
|
return "澳元";
|
|
|
|
|
case "瑞士法郎":
|
|
|
|
|
case "CHF":
|
|
|
|
|
return "瑞士法郎";
|
|
|
|
|
case "新西兰元":
|
|
|
|
|
case "NZD":
|
|
|
|
|
return "新西兰元";
|
|
|
|
|
case "新加坡元":
|
|
|
|
|
case "新币":
|
|
|
|
|
case "SGD":
|
|
|
|
|
return "新加坡元";
|
|
|
|
|
case "泰铢":
|
|
|
|
|
case "THB":
|
|
|
|
|
return "泰铢";
|
|
|
|
|
case "林吉特":
|
|
|
|
|
case "马来西亚林吉特":
|
|
|
|
|
case "MYR":
|
|
|
|
|
return "林吉特";
|
|
|
|
|
case "印尼盾":
|
|
|
|
|
case "印尼卢比":
|
|
|
|
|
case "IDR":
|
|
|
|
|
return "印尼盾";
|
|
|
|
|
case "菲律宾比索":
|
|
|
|
|
case "菲币":
|
|
|
|
|
case "PHP":
|
|
|
|
|
return "菲律宾比索";
|
|
|
|
|
case "越南盾":
|
|
|
|
|
case "VND":
|
|
|
|
|
return "越南盾";
|
|
|
|
|
case "新台币":
|
|
|
|
|
case "台币":
|
|
|
|
|
case "TWD":
|
|
|
|
|
return "新台币";
|
|
|
|
|
case "卢比":
|
|
|
|
|
case "印度卢比":
|
|
|
|
|
case "INR":
|
|
|
|
|
return "卢比";
|
|
|
|
|
case "柬埔寨瑞尔":
|
|
|
|
|
case "瑞尔":
|
|
|
|
|
case "KHR":
|
|
|
|
|
return "瑞尔";
|
|
|
|
|
default:
|
|
|
|
|
// 默认直接返回币种名称
|
|
|
|
|
return label;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|