|
|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.ruoyi.app.utils.ezPay.EzPay;
|
|
|
import com.ruoyi.app.utils.ezPay.EzPayConfig;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
+import com.ruoyi.common.utils.MessageUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.system.domain.PosLoveOrg;
|
|
|
import com.ruoyi.system.domain.PosOrder;
|
|
|
@@ -574,25 +575,25 @@ public class OrderInvoiceService {
|
|
|
switch (invoiceChoice) {
|
|
|
case "PHONE_BARCODE":
|
|
|
if (StrUtil.isBlank(carrierNum) || !carrierNum.matches("^/[0-9A-Z+\\-.]{7}$")) {
|
|
|
- throw new ServiceException("手机条码格式不正确(须为 / 加 7 位大写英文/数字/+-.)");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.barcode.format"));
|
|
|
}
|
|
|
EzPayConfig barCfg = getEzpayConfig(storeId);
|
|
|
if (barCfg == null) {
|
|
|
- throw new ServiceException("门店暂不支持电子发票,无法校验手机条码");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.store.notsupport.barcode"));
|
|
|
}
|
|
|
boolean barExist;
|
|
|
try {
|
|
|
barExist = ezPay.checkBarCode(ezpayBaseUrl, barCfg, carrierNum);
|
|
|
} catch (Exception e) {
|
|
|
- throw new ServiceException("手机条码校验服务暂不可用,请稍后重试");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.barcode.service.unavailable"));
|
|
|
}
|
|
|
if (!barExist) {
|
|
|
- throw new ServiceException("手机条码不存在,请确认或改选纸本发票");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.barcode.notexist"));
|
|
|
}
|
|
|
break;
|
|
|
case "CITIZEN":
|
|
|
if (StrUtil.isBlank(carrierNum) || !carrierNum.matches("^[A-Z]{2}\\d{14}$")) {
|
|
|
- throw new ServiceException("自然人凭证格式不正确(须为 2 位大写英文 + 14 位数字)");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.citizen.format"));
|
|
|
}
|
|
|
break;
|
|
|
case "MEMBER":
|
|
|
@@ -600,24 +601,24 @@ public class OrderInvoiceService {
|
|
|
break;
|
|
|
case "LOVE_CODE":
|
|
|
if (StrUtil.isBlank(loveCode) || !loveCode.matches("^\\d{3,7}$")) {
|
|
|
- throw new ServiceException("捐赠码格式不正确(须为 3-7 位数字)");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.lovecode.format"));
|
|
|
}
|
|
|
EzPayConfig loveCfg = getEzpayConfig(storeId);
|
|
|
if (loveCfg == null) {
|
|
|
- throw new ServiceException("门店暂不支持电子发票,无法校验捐赠码");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.store.notsupport.lovecode"));
|
|
|
}
|
|
|
resolveLoveOrg(loveCode, loveCfg); // 抛异常=捐赠码无效
|
|
|
break;
|
|
|
case "COMPANY":
|
|
|
if (StrUtil.isBlank(buyerUbn) || !buyerUbn.matches("^\\d{8}$")) {
|
|
|
- throw new ServiceException("统一编号格式不正确(须为 8 位数字)");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.ubn.format"));
|
|
|
}
|
|
|
if (StrUtil.isBlank(buyerEmail) || !buyerEmail.matches("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$")) {
|
|
|
- throw new ServiceException("公司发票须填写有效的买方邮箱(用于接收发票)");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.company.email"));
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
- throw new ServiceException("发票类型不合法:" + invoiceChoice);
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.choice.invalid", invoiceChoice));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -641,12 +642,12 @@ public class OrderInvoiceService {
|
|
|
}
|
|
|
try {
|
|
|
if (!ezPay.checkLoveCode(ezpayBaseUrl, cfg, loveCode)) {
|
|
|
- throw new ServiceException("捐赠码无效");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.lovecode.invalid"));
|
|
|
}
|
|
|
} catch (ServiceException se) {
|
|
|
throw se;
|
|
|
} catch (Exception e) {
|
|
|
- throw new ServiceException("捐赠码验证失败,请稍后重试");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.lovecode.verify.fail"));
|
|
|
}
|
|
|
return "未知机构";
|
|
|
}
|
|
|
@@ -658,32 +659,32 @@ public class OrderInvoiceService {
|
|
|
private void validateInvoiceInput(ApplyInvoiceDto dto) {
|
|
|
if ("B2B".equals(dto.getCategory())) {
|
|
|
if (StrUtil.isBlank(dto.getBuyerName())) {
|
|
|
- throw new ServiceException("B2B 发票须填写买方名称");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.b2b.buyername.blank"));
|
|
|
}
|
|
|
if (StrUtil.isBlank(dto.getBuyerUbn()) || !dto.getBuyerUbn().matches("\\d{8}")) {
|
|
|
- throw new ServiceException("统编格式不正确,须为 8 位数字");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.ubn.format"));
|
|
|
}
|
|
|
if (StrUtil.isBlank(dto.getBuyerEmail())) {
|
|
|
- throw new ServiceException("B2B 发票须填写买方邮箱");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.b2b.buyeremail.blank"));
|
|
|
}
|
|
|
if (StrUtil.isNotBlank(dto.getCarrierType()) || StrUtil.isNotBlank(dto.getCarrierNum())) {
|
|
|
- throw new ServiceException("B2B 发票不支持载具");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.b2b.nocarrier"));
|
|
|
}
|
|
|
} else if ("DONATION".equals(dto.getCategory())) {
|
|
|
// 捐赠:loveCode 3-7 位必填,与载具/统编互斥
|
|
|
if (StrUtil.isBlank(dto.getLoveCode()) || !dto.getLoveCode().matches("\\d{3,7}")) {
|
|
|
- throw new ServiceException("捐赠码格式不正确,须为 3-7 位数字");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.lovecode.format"));
|
|
|
}
|
|
|
if (StrUtil.isNotBlank(dto.getCarrierType()) || StrUtil.isNotBlank(dto.getCarrierNum())) {
|
|
|
- throw new ServiceException("捐赠发票不支持载具");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.donation.nocarrier"));
|
|
|
}
|
|
|
if (StrUtil.isNotBlank(dto.getBuyerUbn())) {
|
|
|
- throw new ServiceException("捐赠发票不支持统编");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.donation.noubn"));
|
|
|
}
|
|
|
} else if ("B2C".equals(dto.getCategory())) {
|
|
|
// 载具分支
|
|
|
if (StrUtil.isBlank(dto.getBuyerName())) {
|
|
|
- throw new ServiceException("买方名称不能为空");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.buyername.blank"));
|
|
|
}
|
|
|
String ct = dto.getCarrierType();
|
|
|
if (StrUtil.isBlank(ct)) {
|
|
|
@@ -691,10 +692,10 @@ public class OrderInvoiceService {
|
|
|
return;
|
|
|
}
|
|
|
if (!"0".equals(ct) && !"1".equals(ct) && !"2".equals(ct)) {
|
|
|
- throw new ServiceException("载具类型只能为 0手机条码/1自然人凭证/2ezPay会员");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.carriertype.invalid"));
|
|
|
}
|
|
|
if (StrUtil.isBlank(dto.getCarrierNum())) {
|
|
|
- throw new ServiceException("载具号码不能为空");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.carriernum.blank"));
|
|
|
}
|
|
|
// ezPay doc:载具号码前后不得含空白
|
|
|
dto.setCarrierNum(dto.getCarrierNum().trim());
|
|
|
@@ -702,12 +703,12 @@ public class OrderInvoiceService {
|
|
|
switch (ct) {
|
|
|
case "0":
|
|
|
if (!dto.getCarrierNum().matches("^/[0-9A-Z+\\-.]{7}$")) {
|
|
|
- throw new ServiceException("手机条码格式不正确(须为 / 加 7 位大写英文/数字/+ - .)");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.barcode.format"));
|
|
|
}
|
|
|
break;
|
|
|
case "1":
|
|
|
if (!dto.getCarrierNum().matches("^[A-Z]{2}\\d{14}$")) {
|
|
|
- throw new ServiceException("自然人凭证格式不正确(须为 2 位大写英文加 14 位数字)");
|
|
|
+ throw new ServiceException(MessageUtils.message("no.invoice.citizen.format"));
|
|
|
}
|
|
|
break;
|
|
|
case "2":
|