Merge branch 'master' of http://git.lionquexpress.com/wuweihua/BMS
This commit is contained in:
@@ -27,7 +27,9 @@ import com.bms.common.utils.MessageUtils;
|
||||
import com.bms.price.domain.BmsProduct;
|
||||
import com.bms.price.domain.BmsProductCountry;
|
||||
import com.bms.price.domain.BmsProductImportTask;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
import com.bms.price.service.IBmsProductService;
|
||||
import com.bms.price.service.IPrcPriceExcelFileService;
|
||||
|
||||
/**
|
||||
* Product list (async Excel import)
|
||||
@@ -41,6 +43,9 @@ public class ProductController extends BaseController
|
||||
@Autowired
|
||||
private IBmsProductService productService;
|
||||
|
||||
@Autowired
|
||||
private IPrcPriceExcelFileService priceExcelFileService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:product:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(BmsProduct product)
|
||||
@@ -50,6 +55,15 @@ public class ProductController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/** Imported quote Excel attachments for this product_code (via product.pef_id). */
|
||||
@PreAuthorize("@ss.hasPermi('price:product:query')")
|
||||
@GetMapping("/{productCode}/excelFiles")
|
||||
public AjaxResult excelFiles(@PathVariable String productCode)
|
||||
{
|
||||
List<PrcPriceExcelFile> list = priceExcelFileService.selectByProductCode(productCode);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品下拉选项(非分页)。
|
||||
* 供计费列表、客户绑定等场景选择产品;不做权限控制(仍需登录)。
|
||||
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
package com.bms.web.controller.price;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.bms.common.annotation.Log;
|
||||
import com.bms.common.core.controller.BaseController;
|
||||
import com.bms.common.core.domain.AjaxResult;
|
||||
import com.bms.common.core.page.TableDataInfo;
|
||||
import com.bms.common.enums.BusinessType;
|
||||
import com.bms.common.utils.MessageUtils;
|
||||
import com.bms.price.domain.BmsRedlineProduct;
|
||||
import com.bms.price.domain.BmsRedlineProductCountry;
|
||||
import com.bms.price.domain.BmsRedlineProductImportTask;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
import com.bms.price.service.IBmsRedlineProductService;
|
||||
import com.bms.price.service.IPrcPriceExcelFileService;
|
||||
|
||||
/**
|
||||
* redline product list (async Excel import)
|
||||
*
|
||||
* @author bms
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/price/redline")
|
||||
public class RedlineProductController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IBmsRedlineProductService productService;
|
||||
|
||||
@Autowired
|
||||
private IPrcPriceExcelFileService priceExcelFileService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(BmsRedlineProduct product)
|
||||
{
|
||||
startPage();
|
||||
List<BmsRedlineProduct> list = productService.selectBmsRedlineProductList(product);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/** Imported quote Excel attachments for this product_code (via product.pef_id). */
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:query')")
|
||||
@GetMapping("/{productCode}/excelFiles")
|
||||
public AjaxResult excelFiles(@PathVariable String productCode)
|
||||
{
|
||||
List<PrcPriceExcelFile> list = priceExcelFileService.selectByRedlineProductCode(productCode);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品下拉选项(非分页)。
|
||||
* 供计费列表、客户绑定等场景选择产品;不做权限控制(仍需登录)。
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect(BmsRedlineProduct product)
|
||||
{
|
||||
List<BmsRedlineProduct> list = productService.selectBmsRedlineProductList(product);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:import')")
|
||||
@GetMapping("/import/task/{taskId}")
|
||||
public AjaxResult getImportTask(@PathVariable String taskId)
|
||||
{
|
||||
BmsRedlineProductImportTask task = productService.getImportTask(taskId);
|
||||
if (task == null)
|
||||
{
|
||||
return error(MessageUtils.message("price.product.import.task.notExists"));
|
||||
}
|
||||
return success(task);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:query')")
|
||||
@GetMapping("/{productCode}/countries")
|
||||
public AjaxResult countries(@PathVariable String productCode,
|
||||
@RequestParam(required = false) Date effectiveDate,
|
||||
@RequestParam(required = false) Long productId)
|
||||
{
|
||||
List<BmsRedlineProductCountry> list = productService.selectCountryListByProductCode(productCode, effectiveDate, productId);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:query')")
|
||||
@GetMapping("/{productId}")
|
||||
public AjaxResult getInfo(@PathVariable Long productId)
|
||||
{
|
||||
return success(productService.selectBmsRedlineProductById(productId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:add')")
|
||||
@Log(title = "\u4ea7\u54c1\u5217\u8868", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody BmsRedlineProduct product)
|
||||
{
|
||||
product.setCreateBy(getUsername());
|
||||
return toAjax(productService.insertBmsRedlineProduct(product));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:edit')")
|
||||
@Log(title = "\u4ea7\u54c1\u5217\u8868", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody BmsRedlineProduct product)
|
||||
{
|
||||
product.setUpdateBy(getUsername());
|
||||
return toAjax(productService.updateBmsRedlineProduct(product));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:edit')")
|
||||
@Log(title = "\u4ea7\u54c1\u56fd\u5bb6\u660e\u7ec6", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/country")
|
||||
public AjaxResult editCountry(@RequestBody BmsRedlineProductCountry country)
|
||||
{
|
||||
return toAjax(productService.updateBmsRedlineProductCountry(country));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:remove')")
|
||||
@Log(title = "\u4ea7\u54c1\u5217\u8868", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{productIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] productIds)
|
||||
{
|
||||
return toAjax(productService.deleteBmsRedlineProductByIds(productIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Async import Weishi B2C workbook. Returns taskId; poll /import/task/{taskId}.
|
||||
* effectiveDate is required: written to product / product_country; previous open rows expire at this date.
|
||||
*/
|
||||
@Log(title = "\u4ea7\u54c1\u5217\u8868", businessType = BusinessType.IMPORT)
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:import')")
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date effectiveDate) throws Exception
|
||||
{
|
||||
String taskId = productService.submitImportProductExcelAsync(file, updateSupport, getUsername(), effectiveDate);
|
||||
Map<String, Object> payload = new HashMap<String, Object>();
|
||||
payload.put("taskId", taskId);
|
||||
return success(payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Async single-country cost-sheet import. Returns taskId; poll /import/task/{taskId}.
|
||||
* effectiveDate is required: written to product / product_country; previous open rows expire at this date.
|
||||
*/
|
||||
@Log(title = "\u4ea7\u54c1\u5217\u8868", businessType = BusinessType.IMPORT)
|
||||
@PreAuthorize("@ss.hasPermi('price:redline:import')")
|
||||
@PostMapping("/importCountryData")
|
||||
public AjaxResult importCountryData(MultipartFile file, String countryCode,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date effectiveDate) throws Exception
|
||||
{
|
||||
String taskId = productService.submitImportCountryProductExcelAsync(file, countryCode, getUsername(),
|
||||
effectiveDate);
|
||||
Map<String, Object> payload = new HashMap<String, Object>();
|
||||
payload.put("taskId", taskId);
|
||||
return success(payload);
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.bms.common.annotation.Log;
|
||||
import com.bms.common.core.controller.BaseController;
|
||||
@@ -58,9 +59,10 @@ public class SurchargeController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:surcharge:query') or @ss.hasPermi('price:set:query') or @ss.hasPermi('price:set:add')")
|
||||
@GetMapping("/byProduct/{productCode}")
|
||||
public AjaxResult listByProduct(@PathVariable String productCode)
|
||||
public AjaxResult listByProduct(@PathVariable String productCode,
|
||||
@RequestParam(required = false) String priceType)
|
||||
{
|
||||
return success(surchargeRelService.selectRelByProductCode(productCode));
|
||||
return success(surchargeRelService.selectRelByProductCode(productCode, priceType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +80,7 @@ public class SurchargeController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定附加费到产品/明细(body: scId, productId, productCode, detailId;detailId 空=产品级)
|
||||
* 绑定附加费(body: scId, productId, productCode, detailId, priceType, countryCode;priceType 默认 PRODUCT;countryCode 空=全部)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:surcharge:add')")
|
||||
@Log(title = "附加费关联", businessType = BusinessType.INSERT)
|
||||
|
||||
@@ -47,6 +47,8 @@ price.surcharge.chargeValue.negative=计费数值不能为负数
|
||||
price.surchargeRel.scId.empty=附加费ID不能为空
|
||||
price.surchargeRel.productId.empty=产品ID不能为空
|
||||
price.surchargeRel.productCode.empty=产品代码不能为空
|
||||
price.surchargeRel.priceType.invalid=价格类型必须为 PRODUCT/SALES/REDLINE
|
||||
price.surchargeRel.detailId.empty=销售价关联必须指定套餐明细ID
|
||||
# 套餐 PrcPriceSet
|
||||
price.set.notExists=套餐不存在
|
||||
price.set.name.empty=套餐名称不能为空
|
||||
@@ -128,6 +130,8 @@ price.product.import.success.detail2=范围:产品目录 + 重量段 + 运费/
|
||||
price.product.import.noSheet=未找到产品明细sheet(需与产品名称一致):{0}
|
||||
price.product.import.noCountry=产品明细sheet无有效国家/重量段数据:{0}
|
||||
price.product.import.euEmpty=国家表无欧盟成员(is_eu=1),无法展开「欧盟」
|
||||
price.product.import.dupCountry.item=产品{0}({1})重复国家+重量段:{2}
|
||||
price.product.import.dupCountry=导入失败:以下产品明细中存在重复的国家+重量段,请合并后重试:{0}
|
||||
price.product.import.success.unmatched=未匹配国家表(country_code 为空):{0}
|
||||
price.product.import.countryRequired=请选择目的国家
|
||||
price.product.import.countryNotFound=国家不存在或已停用:{0}
|
||||
|
||||
@@ -33,6 +33,8 @@ public class BmsProduct extends BaseEntity
|
||||
public static final String STATUS_EXPIRED = "2";
|
||||
private String status;
|
||||
private String sourceSheet;
|
||||
/** FK prc_price_excel_file.pef_id */
|
||||
private Long pefId;
|
||||
private Long tmsId;
|
||||
private Integer countryCount;
|
||||
private Integer surchargeCount;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.bms.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/** Redline catalog main table redline_product */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BmsRedlineProduct extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long productId;
|
||||
private String productCode;
|
||||
private String productName;
|
||||
private String serviceLevel;
|
||||
private String cargoAttr;
|
||||
private String destRegion;
|
||||
private String updateNote;
|
||||
/** TAX_INCLUDED / TAX_EXCLUDED */
|
||||
private String taxMode;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date effectiveDate;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date expireDate;
|
||||
/** 0 pending, 1 active, 2 expired */
|
||||
public static final String STATUS_PENDING = "0";
|
||||
public static final String STATUS_ACTIVE = "1";
|
||||
public static final String STATUS_EXPIRED = "2";
|
||||
private String status;
|
||||
private String sourceSheet;
|
||||
/** FK prc_price_excel_file.pef_id */
|
||||
private Long pefId;
|
||||
private Long tmsId;
|
||||
private Integer countryCount;
|
||||
private Integer surchargeCount;
|
||||
private List<BmsRedlineProductCountry> countries;
|
||||
/** query alias of status (0/1/2) */
|
||||
private String effectStatus;
|
||||
/** query: active = status in (0,1); expired = status 2 */
|
||||
private String statusGroup;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** Redline country detail table redline_product_country */
|
||||
@Data
|
||||
public class BmsRedlineProductCountry implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long detailId;
|
||||
/** FK to product.product_id */
|
||||
private Long productId;
|
||||
private String productCode;
|
||||
private String countryName;
|
||||
private String countryCode;
|
||||
/** prc_zone.zone_id; null when product country has no zone */
|
||||
private Long zoneId;
|
||||
/** e.g. Z1; null when no zone */
|
||||
private String zoneCode;
|
||||
/** e.g. Australia(Z1); null when no zone */
|
||||
private String zoneName;
|
||||
private BigDecimal weightMin;
|
||||
private BigDecimal weightMax;
|
||||
private BigDecimal freightPrice;
|
||||
private BigDecimal registrationFee;
|
||||
private String sizeLimit;
|
||||
private String lastMile;
|
||||
private String leadTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date effectiveDate;
|
||||
/** null=open; closed to next import effective_date */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date expireDate;
|
||||
/** 0 pending, 1 active, 2 expired */
|
||||
private String status;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
/** query only: true = expire_date is null */
|
||||
private Boolean openOnly;
|
||||
/** query alias of status (0/1/2) */
|
||||
private String effectStatus;
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Async product Excel import progress (Redis).
|
||||
*/
|
||||
public class BmsRedlineProductImportTask implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String STATUS_PENDING = "PENDING";
|
||||
public static final String STATUS_RUNNING = "RUNNING";
|
||||
public static final String STATUS_SUCCESS = "SUCCESS";
|
||||
public static final String STATUS_FAIL = "FAIL";
|
||||
|
||||
private String taskId;
|
||||
private String status;
|
||||
private int percent;
|
||||
private String message;
|
||||
private String error;
|
||||
|
||||
public String getTaskId()
|
||||
{
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(String taskId)
|
||||
{
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getPercent()
|
||||
{
|
||||
return percent;
|
||||
}
|
||||
|
||||
public void setPercent(int percent)
|
||||
{
|
||||
this.percent = percent;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getError()
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error)
|
||||
{
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.bms.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* Import quote Excel attachment: prc_price_excel_file
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PrcPriceExcelFile extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String TYPE_PRODUCT = "PRODUCT";
|
||||
public static final String TYPE_REDLINE = "REDLINE";
|
||||
public static final String TYPE_SALES = "SALES";
|
||||
|
||||
private Long pefId;
|
||||
/** PRODUCT / REDLINE / SALES */
|
||||
private String excelType;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date effectiveTime;
|
||||
private String fileName;
|
||||
private String filePath;
|
||||
private Long fileSize;
|
||||
private String contentType;
|
||||
private String fileExtension;
|
||||
private String ossId;
|
||||
/** Comma-separated sheet names (optional) */
|
||||
private String sheetNames;
|
||||
}
|
||||
@@ -48,4 +48,9 @@ public class PrcPriceSet extends BaseEntity
|
||||
private String pullFromLibrary;
|
||||
/** Y: even if version already has details, delete+re-pull from library */
|
||||
private String forcePullLibrary;
|
||||
/**
|
||||
* Request-only: stamp this Excel attachment id onto prc_price_set_product.pef_id
|
||||
* when saving IMPORT details (not a column on prc_price_set).
|
||||
*/
|
||||
private Long pefId;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@ public class PrcPriceSetDetail implements Serializable
|
||||
/** null = open */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date expireDate;
|
||||
private List<PrcPriceSetVersionSurcharge> surcharges;
|
||||
/** SALES rels for this detail (detail_id=psd_id, product_id=psp_id) */
|
||||
private List<PrcSurchargeRel> surcharges;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
@@ -37,6 +37,8 @@ public class PrcPriceSetProduct implements Serializable
|
||||
private Long sourceProductId;
|
||||
/** 来源Excel sheet */
|
||||
private String sourceSheet;
|
||||
/** 关联导入价表Excel附件 prc_price_excel_file.pef_id */
|
||||
private Long pefId;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
@@ -34,5 +34,4 @@ public class PrcPriceSetVersion extends BaseEntity
|
||||
|
||||
private List<PrcPriceSetDetail> details;
|
||||
private List<PrcPriceSetProduct> products;
|
||||
private List<PrcPriceSetVersionSurcharge> surcharges;
|
||||
}
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.bms.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/** Price set version surcharge snapshot prc_price_set_version_surcharge */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PrcPriceSetVersionSurcharge extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long psvsId;
|
||||
private Long psvId;
|
||||
/** source prc_surcharge.sc_id */
|
||||
private Long scId;
|
||||
/** prc_price_set_detail.psd_id */
|
||||
private Long psdId;
|
||||
/** copied from detail */
|
||||
private String productCode;
|
||||
private String scName;
|
||||
private String feeType;
|
||||
/** FIXED / WEIGHT / RATE */
|
||||
private String chargeType;
|
||||
private BigDecimal chargeValue;
|
||||
private String currency;
|
||||
private String roundMode;
|
||||
private String countryCode;
|
||||
private String scNote;
|
||||
}
|
||||
@@ -6,13 +6,12 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 附加费与产品/明细关联 prc_surcharge_rel
|
||||
* 同时携带附加费展示字段(JOIN prc_surcharge)与明细展示字段(LEFT JOIN product_country),
|
||||
* 便于产品列表抽屉直接渲染。
|
||||
* 附加费与产品/明细/套餐关联 prc_surcharge_rel
|
||||
* 同时携带附加费展示字段(JOIN prc_surcharge)与明细展示字段(LEFT JOIN product_country,仅 PRODUCT/REDLINE)。
|
||||
*
|
||||
* 语义:
|
||||
* detail_id 为空 = 产品级附加费(作用于该产品全部明细)
|
||||
* detail_id 有值 = 明细级附加费(作用于该产品某个 国家×重量段 明细)
|
||||
* price_type 语义:
|
||||
* PRODUCT / REDLINE : product_id=product.product_id,detail_id=product_country.detail_id(空=产品全部明细)
|
||||
* SALES : product_id=prc_price_set_product.psp_id,detail_id=prc_price_set_detail.psd_id
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -20,11 +19,24 @@ public class PrcSurchargeRel extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 价格类型:产品价 */
|
||||
public static final String PRICE_TYPE_PRODUCT = "PRODUCT";
|
||||
/** 价格类型:销售价(套餐) */
|
||||
public static final String PRICE_TYPE_SALES = "SALES";
|
||||
/** 价格类型:红线价 */
|
||||
public static final String PRICE_TYPE_REDLINE = "REDLINE";
|
||||
|
||||
private Long relId;
|
||||
private Long scId;
|
||||
/** PRODUCT/REDLINE=product_id;SALES=psp_id */
|
||||
private Long productId;
|
||||
private String productCode;
|
||||
/** PRODUCT/REDLINE=product_country.detail_id;SALES=psd_id */
|
||||
private Long detailId;
|
||||
/** PRODUCT / SALES / REDLINE */
|
||||
private String priceType;
|
||||
/** 适用国家ISO2(空=全部),rel 表字段 */
|
||||
private String countryCode;
|
||||
|
||||
/** 附加费冗余展示字段 */
|
||||
private String scName;
|
||||
@@ -34,10 +46,9 @@ public class PrcSurchargeRel extends BaseEntity
|
||||
private String currency;
|
||||
private String roundMode;
|
||||
private String ssCode;
|
||||
private String countryCode;
|
||||
private String scNote;
|
||||
|
||||
/** 明细展示字段 */
|
||||
/** 明细展示字段(PRODUCT/REDLINE LEFT JOIN product_country) */
|
||||
private String countryName;
|
||||
private BigDecimal weightMin;
|
||||
private BigDecimal weightMax;
|
||||
|
||||
@@ -58,8 +58,10 @@ public class TmsPriceQuoteResult implements Serializable
|
||||
private BigDecimal surchargeAmount;
|
||||
/** product catalog total: base freight*weight + base registration (no package surcharge) */
|
||||
private BigDecimal productAmount;
|
||||
/** redline total reserved */
|
||||
/** redline total from redline_product_country (+ REDLINE surcharges) */
|
||||
private BigDecimal redlineAmount;
|
||||
/** matched redline_product_country.detail_id for REDLINE surcharge scope */
|
||||
private Long redlineCountryId;
|
||||
/** cost total (currently = product catalog amount) */
|
||||
private BigDecimal costAmount;
|
||||
/** receivable total (order bill) */
|
||||
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.BmsRedlineProductCountry;
|
||||
|
||||
/**
|
||||
* 红线价国家明细 数据层
|
||||
*
|
||||
* @author bms
|
||||
*/
|
||||
public interface BmsRedlineProductCountryMapper
|
||||
{
|
||||
public List<BmsRedlineProductCountry> selectBmsRedlineProductCountryList(BmsRedlineProductCountry country);
|
||||
|
||||
public int insertBmsRedlineProductCountry(BmsRedlineProductCountry country);
|
||||
|
||||
/** 按明细行主键更新可编辑字段(重量段/运费/挂号费/尺寸/尾程/时效/生效失效日期) */
|
||||
public int updateBmsRedlineProductCountry(BmsRedlineProductCountry country);
|
||||
|
||||
/** Import overlay: update price/zone/attrs on matched country row */
|
||||
public int updateBmsRedlineProductCountryImport(BmsRedlineProductCountry country);
|
||||
|
||||
public int deleteByProductId(Long productId);
|
||||
|
||||
public int deleteByProductCode(String productCode);
|
||||
|
||||
public int deleteByProductCodeAndEffectiveDate(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("effectiveDate") Date effectiveDate);
|
||||
|
||||
/** Max open (expire_date is null) effective_date for product */
|
||||
public Date selectMaxOpenEffectiveDate(@Param("productCode") String productCode);
|
||||
|
||||
/** Close open versions: set expire_date = newEffectiveDate where effective_date < newEffectiveDate */
|
||||
public int expireOpenByProductCode(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("newEffectiveDate") Date newEffectiveDate);
|
||||
|
||||
/**
|
||||
* Close open rows for one product + country where effective_date < newEffectiveDate.
|
||||
* Match by country_code when present, otherwise country_name.
|
||||
*/
|
||||
public int expireOpenByProductCodeAndCountry(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName,
|
||||
@Param("newEffectiveDate") Date newEffectiveDate);
|
||||
|
||||
/** Recompute status from effective_date / expire_date vs today */
|
||||
public int refreshStatusByDates();
|
||||
|
||||
/** Replace same-day version only */
|
||||
public int deleteOpenByProductCodeAndEffectiveDate(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("effectiveDate") Date effectiveDate);
|
||||
|
||||
/**
|
||||
* Delete open rows for one product + country on a given effective_date (same-day replace).
|
||||
* Needed because unique key keeps expired same-day weight bands.
|
||||
*/
|
||||
public int deleteOpenByProductCodeAndCountryOnDate(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName,
|
||||
@Param("effectiveDate") Date effectiveDate);
|
||||
|
||||
/** Open country rows (expire_date is null) for product */
|
||||
public List<BmsRedlineProductCountry> selectOpenByProductCode(@Param("productCode") String productCode);
|
||||
|
||||
/** Copy previously open rows into a new effective_date (caller must expire first) */
|
||||
public int copyOpenCountries(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("productId") Long productId,
|
||||
@Param("effectiveDate") Date effectiveDate,
|
||||
@Param("status") String status);
|
||||
|
||||
/**
|
||||
* Match by product + country + weight + bizDate (+ optional zoneCode).
|
||||
* When zoneCode is empty, prefer rows without zone.
|
||||
* When zoneCode is set, require matching zone_code.
|
||||
*/
|
||||
public BmsRedlineProductCountry selectMatchByProductCountryWeight(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName,
|
||||
@Param("zoneCode") String zoneCode,
|
||||
@Param("weight") BigDecimal weight,
|
||||
@Param("bizDate") Date bizDate);
|
||||
|
||||
/** Count product-country rows that have a zone for this product+country+bizDate */
|
||||
public int countZonedByProductCountry(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName,
|
||||
@Param("bizDate") Date bizDate);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.BmsRedlineProduct;
|
||||
|
||||
/**
|
||||
* 产品主表 数据层
|
||||
*
|
||||
* @author bms
|
||||
*/
|
||||
public interface BmsRedlineProductMapper
|
||||
{
|
||||
public BmsRedlineProduct selectBmsRedlineProductById(Long productId);
|
||||
|
||||
/** Latest row by product_code (effective_date desc) */
|
||||
public BmsRedlineProduct selectBmsRedlineProductByCode(String productCode);
|
||||
|
||||
/** Unique business key: product_code + effective_date */
|
||||
public BmsRedlineProduct selectBmsRedlineProductByCodeAndDate(@Param("productCode") String productCode,
|
||||
@Param("effectiveDate") Date effectiveDate);
|
||||
|
||||
/** Product version effective on bizDate */
|
||||
public BmsRedlineProduct selectEffectiveBmsRedlineProductByCode(@Param("productCode") String productCode,
|
||||
@Param("bizDate") Date bizDate);
|
||||
|
||||
public List<BmsRedlineProduct> selectBmsRedlineProductList(BmsRedlineProduct product);
|
||||
|
||||
public int insertBmsRedlineProduct(BmsRedlineProduct product);
|
||||
|
||||
public int updateBmsRedlineProduct(BmsRedlineProduct product);
|
||||
|
||||
public int deleteBmsRedlineProductByIds(Long[] productIds);
|
||||
|
||||
/** Close previous open versions: expire_date = newEffectiveDate */
|
||||
public int expireOpenByProductCode(
|
||||
@Param("productCode") String productCode,
|
||||
@Param("newEffectiveDate") Date newEffectiveDate,
|
||||
@Param("excludeId") Long excludeId);
|
||||
|
||||
/** Recompute status from effective_date / expire_date vs today */
|
||||
public int refreshStatusByDates();
|
||||
}
|
||||
@@ -47,4 +47,7 @@ public interface PrcIncomeBillFeeMapper
|
||||
public int deleteByFeeId(String feeId);
|
||||
|
||||
public int deleteByBillId(String billId);
|
||||
|
||||
/** Rebill: delete auto fees only; keep manual_flag=1 rows. */
|
||||
public int deleteAutoFeesByBillId(String billId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
|
||||
/**
|
||||
* Import quote Excel attachment mapper
|
||||
*/
|
||||
public interface PrcPriceExcelFileMapper
|
||||
{
|
||||
public PrcPriceExcelFile selectPrcPriceExcelFileById(Long pefId);
|
||||
|
||||
public List<PrcPriceExcelFile> selectPrcPriceExcelFileList(PrcPriceExcelFile query);
|
||||
|
||||
/** Distinct PRODUCT excel files linked by product.pef_id for this product_code */
|
||||
public List<PrcPriceExcelFile> selectByProductCode(@Param("productCode") String productCode);
|
||||
|
||||
public List<PrcPriceExcelFile> selectByRedlineProductCode(@Param("productCode") String productCode);
|
||||
|
||||
public int insertPrcPriceExcelFile(PrcPriceExcelFile row);
|
||||
|
||||
public int updatePrcPriceExcelFile(PrcPriceExcelFile row);
|
||||
|
||||
public int deletePrcPriceExcelFileByIds(Long[] pefIds);
|
||||
}
|
||||
@@ -34,4 +34,8 @@ public interface PrcPriceSetProductMapper
|
||||
|
||||
/** Bind detail.psp_id from set product by psv + product_code. */
|
||||
public int bindDetailPspByPsvId(@Param("psvId") Long psvId);
|
||||
|
||||
/** Stamp Excel attachment id on set products under this version (optional code filter). */
|
||||
public int updatePefIdByPsvId(@Param("psvId") Long psvId, @Param("pefId") Long pefId,
|
||||
@Param("productCodes") List<String> productCodes);
|
||||
}
|
||||
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PrcPriceSetVersionSurcharge;
|
||||
|
||||
/**
|
||||
* Price set version surcharge snapshot
|
||||
*/
|
||||
public interface PrcPriceSetVersionSurchargeMapper
|
||||
{
|
||||
public PrcPriceSetVersionSurcharge selectPrcPriceSetVersionSurchargeById(Long psvsId);
|
||||
|
||||
public List<PrcPriceSetVersionSurcharge> selectPrcPriceSetVersionSurchargeList(PrcPriceSetVersionSurcharge surcharge);
|
||||
|
||||
public int insertPrcPriceSetVersionSurcharge(PrcPriceSetVersionSurcharge surcharge);
|
||||
|
||||
public int updatePrcPriceSetVersionSurcharge(PrcPriceSetVersionSurcharge surcharge);
|
||||
|
||||
public int deletePrcPriceSetVersionSurchargeByIds(Long[] psvsIds);
|
||||
|
||||
public int deleteByPsvId(Long psvId);
|
||||
|
||||
public int deleteByPsdId(Long psdId);
|
||||
|
||||
public List<PrcPriceSetVersionSurcharge> selectByPsdIds(@Param("psdIds") List<Long> psdIds);
|
||||
|
||||
/** Snapshot all applicable product-rel surcharges for details under psvId (library create). */
|
||||
public int insertFromLibraryRels(@Param("psvId") Long psvId, @Param("createBy") String createBy);
|
||||
|
||||
/** Copy surcharge snapshots from src version onto new version details (match by detail keys). */
|
||||
public int copySurchargesFromVersion(
|
||||
@Param("srcPsvId") Long srcPsvId,
|
||||
@Param("newPsvId") Long newPsvId,
|
||||
@Param("createBy") String createBy);
|
||||
}
|
||||
@@ -5,24 +5,36 @@ import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PrcSurchargeRel;
|
||||
|
||||
/**
|
||||
* 附加费与产品/明细关联 数据层
|
||||
* 附加费与产品/明细/套餐关联 数据层
|
||||
*
|
||||
* @author bms
|
||||
*/
|
||||
public interface PrcSurchargeRelMapper
|
||||
{
|
||||
/**
|
||||
* 查询关联列表(JOIN 附加费 + 明细),支持按 productCode / scId 过滤
|
||||
* 查询关联列表(JOIN 附加费 + 明细),支持按 productCode / scId / priceType / detailId 过滤
|
||||
*/
|
||||
public List<PrcSurchargeRel> selectPrcSurchargeRelList(PrcSurchargeRel rel);
|
||||
|
||||
public List<PrcSurchargeRel> selectByDetailIdsAndPriceType(
|
||||
@Param("detailIds") List<Long> detailIds,
|
||||
@Param("priceType") String priceType);
|
||||
|
||||
public int insertPrcSurchargeRel(PrcSurchargeRel rel);
|
||||
|
||||
public int deletePrcSurchargeRelByIds(Long[] relIds);
|
||||
|
||||
/** 删除产品时清理其关联 */
|
||||
/** 删除产品时清理 PRODUCT/REDLINE 关联 */
|
||||
public int deleteRelByProductCodes(String[] productCodes);
|
||||
|
||||
public int deleteByDetailIdsAndPriceType(
|
||||
@Param("detailIds") List<Long> detailIds,
|
||||
@Param("priceType") String priceType);
|
||||
|
||||
public int deleteByProductIdsAndPriceType(
|
||||
@Param("productIds") List<Long> productIds,
|
||||
@Param("priceType") String priceType);
|
||||
|
||||
/** 附加费版本化编辑后,把产品关联从旧记录重指向新记录 */
|
||||
public int rebindRelScId(@Param("oldScId") Long oldScId, @Param("newScId") Long newScId, @Param("operator") String operator);
|
||||
}
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.bms.price.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.bms.price.domain.BmsRedlineProduct;
|
||||
import com.bms.price.domain.BmsRedlineProductCountry;
|
||||
import com.bms.price.domain.BmsRedlineProductImportTask;
|
||||
|
||||
/**
|
||||
* redline product list service
|
||||
*
|
||||
* @author bms
|
||||
*/
|
||||
public interface IBmsRedlineProductService
|
||||
{
|
||||
public BmsRedlineProduct selectBmsRedlineProductById(Long productId);
|
||||
|
||||
public List<BmsRedlineProduct> selectBmsRedlineProductList(BmsRedlineProduct product);
|
||||
|
||||
public int insertBmsRedlineProduct(BmsRedlineProduct product);
|
||||
|
||||
public int updateBmsRedlineProduct(BmsRedlineProduct product);
|
||||
|
||||
public int updateBmsRedlineProductCountry(BmsRedlineProductCountry country);
|
||||
|
||||
public int deleteBmsRedlineProductByIds(Long[] productIds);
|
||||
|
||||
public List<BmsRedlineProductCountry> selectCountryListByProductCode(String productCode);
|
||||
|
||||
public List<BmsRedlineProductCountry> selectCountryListByProductCode(String productCode, Date effectiveDate);
|
||||
|
||||
public List<BmsRedlineProductCountry> selectCountryListByProductCode(String productCode, Date effectiveDate, Long productId);
|
||||
|
||||
public String importProductExcel(MultipartFile file, boolean updateSupport, String operName, Date effectiveDate) throws Exception;
|
||||
|
||||
public String importCountryProductExcel(MultipartFile file, String countryCode, String operName, Date effectiveDate) throws Exception;
|
||||
|
||||
/** Submit async all-country import; returns taskId for polling getImportTask. */
|
||||
public String submitImportProductExcelAsync(MultipartFile file, boolean updateSupport, String operName, Date effectiveDate) throws Exception;
|
||||
|
||||
/** Submit async single-country import; returns taskId for polling getImportTask. */
|
||||
public String submitImportCountryProductExcelAsync(MultipartFile file, String countryCode, String operName, Date effectiveDate) throws Exception;
|
||||
|
||||
/** Poll Redis progress for product import task. */
|
||||
public BmsRedlineProductImportTask getImportTask(String taskId);
|
||||
|
||||
/** Sync import from bytes (used by async runner; taskId may be null). */
|
||||
public String importProductExcel(byte[] bytes, String filename, boolean updateSupport, String operName, String taskId, Date effectiveDate) throws Exception;
|
||||
|
||||
/** Sync country import from bytes (used by async runner; taskId may be null). */
|
||||
public String importCountryProductExcel(byte[] bytes, String filename, String countryCode, String operName, String taskId, Date effectiveDate) throws Exception;
|
||||
|
||||
public java.util.Map<String, List<BmsRedlineProductCountry>> parseQuoteExcelByProduct(MultipartFile file) throws Exception;
|
||||
|
||||
public java.util.Map<String, List<BmsRedlineProductCountry>> parseQuoteExcelByProduct(byte[] bytes, String filename) throws Exception;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.bms.price.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
|
||||
/**
|
||||
* Import quote Excel attachment service
|
||||
*/
|
||||
public interface IPrcPriceExcelFileService
|
||||
{
|
||||
public PrcPriceExcelFile selectPrcPriceExcelFileById(Long pefId);
|
||||
|
||||
/** Import Excel attachments linked to this product_code via product.pef_id */
|
||||
public List<PrcPriceExcelFile> selectByProductCode(String productCode);
|
||||
|
||||
List<PrcPriceExcelFile> selectByRedlineProductCode(String productCode);
|
||||
|
||||
/**
|
||||
* Persist uploaded Excel under upload/price/excel and insert metadata row.
|
||||
*
|
||||
* @param excelType PRODUCT / REDLINE / SALES
|
||||
* @return inserted row with pefId
|
||||
*/
|
||||
public PrcPriceExcelFile saveImportExcel(String excelType, Date effectiveTime, byte[] bytes,
|
||||
String filename, String operName) throws Exception;
|
||||
}
|
||||
@@ -13,6 +13,8 @@ public interface IPrcSurchargeRelService
|
||||
/** 查询某产品已关联的附加费(含附加费与明细展示字段) */
|
||||
public List<PrcSurchargeRel> selectRelByProductCode(String productCode);
|
||||
|
||||
public List<PrcSurchargeRel> selectRelByProductCode(String productCode, String priceType);
|
||||
|
||||
public List<PrcSurchargeRel> selectPrcSurchargeRelList(PrcSurchargeRel rel);
|
||||
|
||||
public int insertPrcSurchargeRel(PrcSurchargeRel rel);
|
||||
|
||||
+164
@@ -41,7 +41,9 @@ import com.bms.price.domain.PrcZone;
|
||||
import com.bms.price.mapper.BmsProductCountryMapper;
|
||||
import com.bms.price.mapper.BmsProductMapper;
|
||||
import com.bms.price.mapper.PrcZoneMapper;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
import com.bms.price.service.IBmsProductService;
|
||||
import com.bms.price.service.IPrcPriceExcelFileService;
|
||||
import com.bms.price.service.IPrcSurchargeRelService;
|
||||
import com.bms.price.task.BmsProductImportAsyncRunner;
|
||||
import com.bms.price.util.ZoneCodeAbbrevs;
|
||||
@@ -94,6 +96,9 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
@Autowired
|
||||
private BmsProductImportAsyncRunner importAsyncRunner;
|
||||
|
||||
@Autowired
|
||||
private IPrcPriceExcelFileService priceExcelFileService;
|
||||
|
||||
@Override
|
||||
public BmsProduct selectBmsProductById(Long productId)
|
||||
{
|
||||
@@ -309,6 +314,13 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
}
|
||||
List<BmsRegion> euRegions = loadEuRegions(regionByNameCn);
|
||||
Map<String, PrcZone> zoneByCountryAndCode = loadZoneByCountryAndCode();
|
||||
// Pre-check: same product cannot have duplicate country + weight band in Excel
|
||||
assertImportProductsNoDupCountryWeight(workbook, products, regionByNameCn, euRegions,
|
||||
zoneByCountryAndCode);
|
||||
|
||||
PrcPriceExcelFile excelFile = priceExcelFileService.saveImportExcel(
|
||||
PrcPriceExcelFile.TYPE_PRODUCT, forcedEff, bytes, filename, operName);
|
||||
Long pefId = excelFile != null ? excelFile.getPefId() : null;
|
||||
|
||||
int successNum = 0;
|
||||
int skipNum = 0;
|
||||
@@ -328,6 +340,7 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
try
|
||||
{
|
||||
product.setEffectiveDate(forcedEff);
|
||||
product.setPefId(pefId);
|
||||
int[] nums = importOneProduct(workbook, product, operName, regionByNameCn, euRegions,
|
||||
zoneByCountryAndCode, unmatchedCountries, forcedEff);
|
||||
transactionManager.commit(tx);
|
||||
@@ -428,6 +441,10 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
// Pre-check all products: reject whole import before any write if any is earlier than prev version
|
||||
assertImportProductsEffectiveNotBeforePrev(products, forcedEff);
|
||||
|
||||
PrcPriceExcelFile excelFile = priceExcelFileService.saveImportExcel(
|
||||
PrcPriceExcelFile.TYPE_PRODUCT, forcedEff, bytes, filename, operName);
|
||||
Long pefId = excelFile != null ? excelFile.getPefId() : null;
|
||||
|
||||
int successNum = 0;
|
||||
int skipNum = 0;
|
||||
int countryNum = 0;
|
||||
@@ -455,11 +472,13 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
product.setDestRegion(countryLabel);
|
||||
product.setSourceSheet(block.sheetName);
|
||||
product.setEffectiveDate(forcedEff);
|
||||
product.setPefId(pefId);
|
||||
if (StringUtils.isEmpty(product.getTaxMode()))
|
||||
{
|
||||
product.setTaxMode(resolveTaxMode(product.getProductName()));
|
||||
}
|
||||
List<BmsProductCountry> countries = stampSelectedCountry(block.rows, region, forcedEff);
|
||||
assertNoDuplicateCountryWeightRows(product, countries);
|
||||
int[] nums = persistImportedProduct(product, countries, operName);
|
||||
transactionManager.commit(tx);
|
||||
successNum += nums[0];
|
||||
@@ -597,6 +616,7 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
{
|
||||
continue;
|
||||
}
|
||||
assertNoDuplicateCountryWeightRows(product, rows);
|
||||
String code = product.getProductCode().trim().toUpperCase(Locale.ROOT);
|
||||
out.put(code, rows);
|
||||
}
|
||||
@@ -632,6 +652,7 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
throw new ServiceException(MessageUtils.message("price.product.import.noCountry",
|
||||
productSheet.getSheetName()));
|
||||
}
|
||||
assertNoDuplicateCountryWeightRows(product, countries);
|
||||
// UI-selected effective date wins over Excel; previous open product/country rows expire at this date
|
||||
Date newEff = requireImportEffectiveDate(forcedEffectiveDate != null ? forcedEffectiveDate
|
||||
: product.getEffectiveDate());
|
||||
@@ -643,6 +664,7 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
if (existing != null)
|
||||
{
|
||||
product.setProductId(existing.getProductId());
|
||||
patchProductPefId(product, operName);
|
||||
int countryRows = saveCountries(product, countries);
|
||||
return new int[] { 0, 1, countryRows };
|
||||
}
|
||||
@@ -666,6 +688,19 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
return new int[] { 1, 0, countryRows };
|
||||
}
|
||||
|
||||
private void patchProductPefId(BmsProduct product, String operName)
|
||||
{
|
||||
if (product == null || product.getProductId() == null || product.getPefId() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
BmsProduct pefPatch = new BmsProduct();
|
||||
pefPatch.setProductId(product.getProductId());
|
||||
pefPatch.setPefId(product.getPefId());
|
||||
pefPatch.setUpdateBy(operName);
|
||||
productMapper.updateBmsProduct(pefPatch);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save country rows by effective_date.
|
||||
@@ -1988,6 +2023,134 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Workbook pre-check for full import: reject before any write when a product sheet
|
||||
* has duplicate country + weight band (same zone) rows.
|
||||
*/
|
||||
private void assertImportProductsNoDupCountryWeight(Workbook workbook, List<BmsProduct> products,
|
||||
Map<String, BmsRegion> regionByNameCn, List<BmsRegion> euRegions,
|
||||
Map<String, PrcZone> zoneByCountryAndCode)
|
||||
{
|
||||
if (workbook == null || products == null || products.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<String> tips = new ArrayList<String>();
|
||||
Set<String> unmatchedCountries = new HashSet<String>();
|
||||
for (BmsProduct product : products)
|
||||
{
|
||||
if (product == null || StringUtils.isEmpty(product.getProductCode()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Sheet productSheet = findProductSheet(workbook, product);
|
||||
if (productSheet == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<BmsProductCountry> rows = parseProductSheet(productSheet, product,
|
||||
regionByNameCn, euRegions, zoneByCountryAndCode, unmatchedCountries);
|
||||
String tip = buildDuplicateCountryWeightTip(product, rows);
|
||||
if (StringUtils.isNotEmpty(tip))
|
||||
{
|
||||
tips.add(tip);
|
||||
}
|
||||
}
|
||||
if (!tips.isEmpty())
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.product.import.dupCountry",
|
||||
String.join("<br/>", tips)));
|
||||
}
|
||||
}
|
||||
|
||||
/** Fail when Excel rows for one product contain duplicate country + weight band. */
|
||||
private void assertNoDuplicateCountryWeightRows(BmsProduct product, List<BmsProductCountry> rows)
|
||||
{
|
||||
String tip = buildDuplicateCountryWeightTip(product, rows);
|
||||
if (StringUtils.isNotEmpty(tip))
|
||||
{
|
||||
throw new ServiceException(tip);
|
||||
}
|
||||
}
|
||||
|
||||
private String buildDuplicateCountryWeightTip(BmsProduct product, List<BmsProductCountry> rows)
|
||||
{
|
||||
List<String> dups = findDuplicateCountryWeightLabels(rows);
|
||||
if (dups.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String code = product == null || StringUtils.isEmpty(product.getProductCode())
|
||||
? "-" : product.getProductCode();
|
||||
String name = product == null || StringUtils.isEmpty(product.getProductName())
|
||||
? "-" : product.getProductName();
|
||||
return MessageUtils.message("price.product.import.dupCountry.item",
|
||||
code, name, String.join("\u3001", dups));
|
||||
}
|
||||
|
||||
private List<String> findDuplicateCountryWeightLabels(List<BmsProductCountry> rows)
|
||||
{
|
||||
List<String> dups = new ArrayList<String>();
|
||||
if (rows == null || rows.isEmpty())
|
||||
{
|
||||
return dups;
|
||||
}
|
||||
Map<String, Integer> counts = new LinkedHashMap<String, Integer>();
|
||||
Map<String, String> labels = new LinkedHashMap<String, String>();
|
||||
for (BmsProductCountry c : rows)
|
||||
{
|
||||
if (c == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String key = countryWeightDupKey(c);
|
||||
Integer n = counts.get(key);
|
||||
counts.put(key, n == null ? 1 : n.intValue() + 1);
|
||||
if (!labels.containsKey(key))
|
||||
{
|
||||
labels.put(key, formatCountryWeightTip(c));
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Integer> e : counts.entrySet())
|
||||
{
|
||||
if (e.getValue() != null && e.getValue().intValue() > 1)
|
||||
{
|
||||
dups.add(labels.get(e.getKey()));
|
||||
}
|
||||
}
|
||||
return dups;
|
||||
}
|
||||
|
||||
/** Align with uk_product_country_zone_weight_eff (country + zone + weight min/max). */
|
||||
private String countryWeightDupKey(BmsProductCountry c)
|
||||
{
|
||||
String country = StringUtils.isNotEmpty(c.getCountryCode())
|
||||
? c.getCountryCode().trim().toUpperCase(Locale.ROOT)
|
||||
: (c.getCountryName() == null ? "" : c.getCountryName().trim());
|
||||
String zone = c.getZoneCode() == null ? "" : c.getZoneCode().trim().toUpperCase(Locale.ROOT);
|
||||
return country + "|" + zone + "|" + decimalKey(c.getWeightMin()) + "|" + decimalKey(c.getWeightMax());
|
||||
}
|
||||
|
||||
private String formatCountryWeightTip(BmsProductCountry c)
|
||||
{
|
||||
String name = StringUtils.isNotEmpty(c.getCountryName()) ? c.getCountryName()
|
||||
: (StringUtils.isNotEmpty(c.getCountryCode()) ? c.getCountryCode() : "-");
|
||||
if (StringUtils.isNotEmpty(c.getZoneCode()))
|
||||
{
|
||||
name = name + "(" + c.getZoneCode() + ")";
|
||||
}
|
||||
return name + " " + decimalKey(c.getWeightMin()) + "~" + decimalKey(c.getWeightMax());
|
||||
}
|
||||
|
||||
private String decimalKey(BigDecimal v)
|
||||
{
|
||||
if (v == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return v.stripTrailingZeros().toPlainString();
|
||||
}
|
||||
|
||||
/** Stamp product + all country detail rows with the same effective date. */
|
||||
private void applyForcedEffectiveDate(BmsProduct product, List<BmsProductCountry> countries, Date newEff)
|
||||
{
|
||||
@@ -2025,6 +2188,7 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
if (existing != null)
|
||||
{
|
||||
product.setProductId(existing.getProductId());
|
||||
patchProductPefId(product, operName);
|
||||
int countryRows = saveCountries(product, countries);
|
||||
return new int[] { 0, 1, countryRows };
|
||||
}
|
||||
|
||||
+2290
File diff suppressed because it is too large
Load Diff
+84
-6
@@ -8,8 +8,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -1115,18 +1117,39 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
else
|
||||
{
|
||||
orderBillMapper.updatePrcOrderBill(bill);
|
||||
incomeBillFeeMapper.deleteByBillId(bill.getBillId());
|
||||
// Keep manually added fees (manual_flag=1) across rebill
|
||||
incomeBillFeeMapper.deleteAutoFeesByBillId(bill.getBillId());
|
||||
// Payable not in scope yet: skip prc_pay_bill_fee cleanup/write.
|
||||
// payBillFeeMapper.deleteByBillId(bill.getBillId());
|
||||
}
|
||||
PrcIncomeBill incomeBill = persistIncomeBill(bill, result);
|
||||
List<PrcIncomeBillFee> fees = toFeeRows(bill.getBillId(),
|
||||
incomeBill == null ? null : incomeBill.getIncomeBillId(), result);
|
||||
if (existed != null)
|
||||
{
|
||||
fees = filterAutoFeesAgainstManual(bill.getBillId(), fees);
|
||||
}
|
||||
if (!fees.isEmpty())
|
||||
{
|
||||
incomeBillFeeMapper.insertBatch(fees);
|
||||
}
|
||||
orderBillMapper.refreshArBillStatusByBillIds(Arrays.asList(bill.getBillId()));
|
||||
if (existed != null)
|
||||
{
|
||||
// Quote totals were written above; recalc so retained manual fees join income/credit
|
||||
TmsPriceQuoteResult refreshed = refreshBillIncomeTotals(bill);
|
||||
if (refreshed != null)
|
||||
{
|
||||
result.setSurchargeAmount(refreshed.getSurchargeAmount());
|
||||
result.setIncomeTotal(refreshed.getIncomeTotal());
|
||||
result.setPayableTotal(refreshed.getPayableTotal());
|
||||
result.setCreditArrearsStatus(refreshed.getCreditArrearsStatus());
|
||||
result.setFeeDetails(refreshed.getFeeDetails());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
orderBillMapper.refreshArBillStatusByBillIds(Arrays.asList(bill.getBillId()));
|
||||
}
|
||||
// Payable not in scope yet: do not write prc_pay_bill / prc_pay_bill_fee.
|
||||
// PrcPayBill payBill = persistPayBill(bill, result);
|
||||
// List<PrcPayBillFee> payFees = toPayFeeRows(bill.getBillId(),
|
||||
@@ -1141,6 +1164,53 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
billSearchStore.save(EsLogType.BILL, EsBizLogSupport.billBizId(request), requestJson, toResponseJson(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop auto fee lines that collide with retained manual rows on uk_bill_fee_item
|
||||
* (bill_id, fee_type, sc_id). Manual fees win on rebill.
|
||||
*/
|
||||
private List<PrcIncomeBillFee> filterAutoFeesAgainstManual(String billId, List<PrcIncomeBillFee> autoFees)
|
||||
{
|
||||
if (autoFees == null || autoFees.isEmpty() || StringUtils.isEmpty(billId))
|
||||
{
|
||||
return autoFees == null ? new ArrayList<PrcIncomeBillFee>() : autoFees;
|
||||
}
|
||||
List<PrcIncomeBillFee> existing = incomeBillFeeMapper.selectByBillId(billId);
|
||||
if (existing == null || existing.isEmpty())
|
||||
{
|
||||
return autoFees;
|
||||
}
|
||||
Set<String> manualKeys = new HashSet<String>();
|
||||
for (PrcIncomeBillFee row : existing)
|
||||
{
|
||||
if (row != null && "1".equals(row.getManualFlag()))
|
||||
{
|
||||
manualKeys.add(feeUniqueKey(row.getFeeType(), row.getScId()));
|
||||
}
|
||||
}
|
||||
if (manualKeys.isEmpty())
|
||||
{
|
||||
return autoFees;
|
||||
}
|
||||
List<PrcIncomeBillFee> out = new ArrayList<PrcIncomeBillFee>();
|
||||
for (PrcIncomeBillFee fee : autoFees)
|
||||
{
|
||||
if (fee == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!manualKeys.contains(feeUniqueKey(fee.getFeeType(), fee.getScId())))
|
||||
{
|
||||
out.add(fee);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private String feeUniqueKey(String feeType, Long scId)
|
||||
{
|
||||
return StringUtils.nvl(feeType, "") + "|" + (scId == null ? "0" : String.valueOf(scId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Occupy/release credit by income total delta (bizType=ORDER).
|
||||
* Missing/disabled customer: skip occupy, return NORMAL.
|
||||
@@ -1347,7 +1417,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return fees;
|
||||
}
|
||||
|
||||
/** 应收主表与订单计费一对一落库;销售价=套餐计费,产品价=产品目录价;红线价预留。 */
|
||||
/** 应收主表与订单计费一对一落库;销售价=套餐计费,产品价=产品目录价,红线价=红线目录价(含 REDLINE 附加费)。 */
|
||||
private PrcIncomeBill persistIncomeBill(PrcOrderBill bill, TmsPriceQuoteResult result)
|
||||
{
|
||||
if (bill == null || StringUtils.isEmpty(bill.getBillId()))
|
||||
@@ -1364,8 +1434,9 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
row.setCreateBy(bill.getCreateBy());
|
||||
}
|
||||
row.setCurrency(StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency());
|
||||
// 产品价=目录价;红线价预留
|
||||
// product catalog + redline from quote
|
||||
row.setProductAmount(result == null ? null : result.getProductAmount());
|
||||
row.setRedlineAmount(result == null ? null : result.getRedlineAmount());
|
||||
row.setSalesAmount(sales);
|
||||
row.setIncomeTotal(sales);
|
||||
row.setBelongSaler(bill.getBelongSaler());
|
||||
@@ -1410,7 +1481,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return fees;
|
||||
}
|
||||
|
||||
/** 应付主表与订单计费一对一落库;成本价/应付=产品目录价,同步写入 product_amount;红线价预留。 */
|
||||
/** 应付主表与订单计费一对一落库;成本价/应付=产品目录价,同步写入 product_amount;红线价同步写入 redline_amount。 */
|
||||
private PrcPayBill persistPayBill(PrcOrderBill bill, TmsPriceQuoteResult result)
|
||||
{
|
||||
if (bill == null || StringUtils.isEmpty(bill.getBillId()))
|
||||
@@ -1427,9 +1498,10 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
row.setCreateBy(bill.getCreateBy());
|
||||
}
|
||||
row.setCurrency(StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency());
|
||||
// 产品价/成本价=目录价;红线价预留
|
||||
// product/cost = catalog; redline from quote
|
||||
BigDecimal product = result == null ? null : result.getProductAmount();
|
||||
row.setProductAmount(product);
|
||||
row.setRedlineAmount(result == null ? null : result.getRedlineAmount());
|
||||
row.setCostAmount(pay);
|
||||
row.setPayTotal(pay);
|
||||
row.setBelongSaler(bill.getBelongSaler());
|
||||
@@ -1493,6 +1565,12 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
r.setBizDate(bill.getBizDate());
|
||||
r.setFeeDetails(toIncomeFeeLines(incomeFees));
|
||||
r.setPayFeeDetails(toPayFeeLines(payFees));
|
||||
PrcIncomeBill incomeBill = incomeBillMapper.selectByBillId(bill.getBillId());
|
||||
if (incomeBill != null)
|
||||
{
|
||||
r.setProductAmount(incomeBill.getProductAmount());
|
||||
r.setRedlineAmount(incomeBill.getRedlineAmount());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
package com.bms.price.service.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bms.common.config.BmsConfig;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.DateUtils;
|
||||
import com.bms.common.utils.StringUtils;
|
||||
import com.bms.common.utils.file.FileUploadUtils;
|
||||
import com.bms.common.utils.uuid.IdUtils;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
import com.bms.price.mapper.PrcPriceExcelFileMapper;
|
||||
import com.bms.price.service.IPrcPriceExcelFileService;
|
||||
|
||||
/**
|
||||
* Persist import Excel bytes and metadata
|
||||
*/
|
||||
@Service
|
||||
public class PrcPriceExcelFileServiceImpl implements IPrcPriceExcelFileService
|
||||
{
|
||||
private static final String SUB_DIR = "price/excel";
|
||||
|
||||
@Autowired
|
||||
private PrcPriceExcelFileMapper excelFileMapper;
|
||||
|
||||
@Override
|
||||
public PrcPriceExcelFile selectPrcPriceExcelFileById(Long pefId)
|
||||
{
|
||||
return excelFileMapper.selectPrcPriceExcelFileById(pefId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrcPriceExcelFile> selectByProductCode(String productCode)
|
||||
{
|
||||
if (StringUtils.isEmpty(productCode))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<PrcPriceExcelFile> list = excelFileMapper.selectByProductCode(productCode.trim());
|
||||
return list == null ? Collections.emptyList() : list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrcPriceExcelFile> selectByRedlineProductCode(String productCode)
|
||||
{
|
||||
if (productCode == null || productCode.trim().isEmpty())
|
||||
{
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
List<PrcPriceExcelFile> list = excelFileMapper.selectByRedlineProductCode(productCode.trim());
|
||||
return list == null ? java.util.Collections.emptyList() : list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrcPriceExcelFile saveImportExcel(String excelType, Date effectiveTime, byte[] bytes,
|
||||
String filename, String operName) throws Exception
|
||||
{
|
||||
if (StringUtils.isEmpty(excelType))
|
||||
{
|
||||
throw new ServiceException("excelType required");
|
||||
}
|
||||
if (bytes == null || bytes.length == 0)
|
||||
{
|
||||
throw new ServiceException("excel empty");
|
||||
}
|
||||
if (effectiveTime == null)
|
||||
{
|
||||
effectiveTime = new Date();
|
||||
}
|
||||
String originalName = StringUtils.isNotEmpty(filename) ? filename : "import.xlsx";
|
||||
String ext = FilenameUtils.getExtension(originalName);
|
||||
if (StringUtils.isEmpty(ext))
|
||||
{
|
||||
ext = "xlsx";
|
||||
}
|
||||
ext = ext.toLowerCase(Locale.ROOT);
|
||||
|
||||
String uploadDir = BmsConfig.getUploadPath() + File.separator + SUB_DIR;
|
||||
String pathName = DateUtils.datePath() + "/" + IdUtils.fastSimpleUUID() + "." + ext;
|
||||
File dest = FileUploadUtils.getAbsoluteFile(uploadDir, pathName);
|
||||
FileOutputStream fos = null;
|
||||
try
|
||||
{
|
||||
fos = new FileOutputStream(dest);
|
||||
fos.write(bytes);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.close(fos);
|
||||
}
|
||||
String storedPath = FileUploadUtils.getPathFileName(uploadDir, pathName);
|
||||
|
||||
PrcPriceExcelFile row = new PrcPriceExcelFile();
|
||||
row.setExcelType(excelType.trim().toUpperCase(Locale.ROOT));
|
||||
row.setEffectiveTime(effectiveTime);
|
||||
row.setFileName(originalName);
|
||||
row.setFilePath(storedPath);
|
||||
row.setFileSize(Long.valueOf(bytes.length));
|
||||
row.setContentType(resolveContentType(ext));
|
||||
row.setFileExtension(ext);
|
||||
row.setCreateBy(operName);
|
||||
excelFileMapper.insertPrcPriceExcelFile(row);
|
||||
return row;
|
||||
}
|
||||
|
||||
private static String resolveContentType(String ext)
|
||||
{
|
||||
if ("xls".equals(ext))
|
||||
{
|
||||
return "application/vnd.ms-excel";
|
||||
}
|
||||
if ("xlsx".equals(ext))
|
||||
{
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+403
-154
@@ -22,17 +22,18 @@ import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.DateUtils;
|
||||
import com.bms.common.utils.MessageUtils;
|
||||
import com.bms.common.utils.StringUtils;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.common.utils.uuid.IdUtils;
|
||||
import com.bms.price.domain.BmsProduct;
|
||||
import com.bms.price.domain.BmsProductCountry;
|
||||
import com.bms.price.domain.PrcCustomerPriceSet;
|
||||
import com.bms.price.domain.PrcPriceExcelFile;
|
||||
import com.bms.price.domain.PrcPriceSet;
|
||||
import com.bms.price.domain.PrcPriceSetCheckItem;
|
||||
import com.bms.price.domain.PrcPriceSetDetail;
|
||||
import com.bms.price.domain.PrcPriceSetProduct;
|
||||
import com.bms.price.domain.PrcPriceSetSaveTask;
|
||||
import com.bms.price.domain.PrcPriceSetVersion;
|
||||
import com.bms.price.domain.PrcPriceSetVersionSurcharge;
|
||||
import com.bms.price.domain.PrcSurcharge;
|
||||
import com.bms.price.domain.PrcSurchargeRel;
|
||||
import com.bms.price.mapper.BmsProductCountryMapper;
|
||||
@@ -42,10 +43,10 @@ import com.bms.price.mapper.PrcPriceSetDetailMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetProductMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetVersionMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetVersionSurchargeMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeRelMapper;
|
||||
import com.bms.price.service.IBmsProductService;
|
||||
import com.bms.price.service.IPrcPriceExcelFileService;
|
||||
import com.bms.price.service.IPrcPriceSetService;
|
||||
import com.bms.price.task.PrcPriceSetSaveAsyncRunner;
|
||||
|
||||
@@ -88,9 +89,6 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
@Autowired
|
||||
private PrcPriceSetVersionMapper versionMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcPriceSetVersionSurchargeMapper versionSurchargeMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcSurchargeRelMapper surchargeRelMapper;
|
||||
|
||||
@@ -117,6 +115,9 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
@Autowired
|
||||
private PrcPriceSetSaveAsyncRunner saveAsyncRunner;
|
||||
|
||||
@Autowired
|
||||
private IPrcPriceExcelFileService priceExcelFileService;
|
||||
|
||||
@Override
|
||||
public PrcPriceSet selectPrcPriceSetById(Long priceSetId)
|
||||
{
|
||||
@@ -174,10 +175,10 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Always replace snapshot for this batch API (null would skip in updateDetail)
|
||||
// Always replace SALES rels for this batch API (null would skip in updateDetail)
|
||||
if (detail.getSurcharges() == null)
|
||||
{
|
||||
detail.setSurcharges(new ArrayList<PrcPriceSetVersionSurcharge>());
|
||||
detail.setSurcharges(new ArrayList<PrcSurchargeRel>());
|
||||
}
|
||||
rows += updateDetail(detail);
|
||||
}
|
||||
@@ -468,7 +469,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
if (detailRows > 0)
|
||||
{
|
||||
setProductMapper.bindDetailPspByPsvId(nv.getPsvId());
|
||||
versionSurchargeMapper.copySurchargesFromVersion(sourcePsvId, nv.getPsvId(), createBy);
|
||||
copySalesSurchargeRelsFromVersion(sourcePsvId, nv.getPsvId(), createBy);
|
||||
}
|
||||
refreshVersionStatus(set.getPriceSetId());
|
||||
return nv.getPsvId();
|
||||
@@ -521,7 +522,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
throw new ServiceException(MessageUtils.message("price.set.version.delete.statusNotAllowed"));
|
||||
}
|
||||
requireSet(version.getPriceSetId());
|
||||
versionSurchargeMapper.deleteByPsvId(psvId);
|
||||
deleteSalesRelsByPsvId(psvId);
|
||||
detailMapper.deletePrcPriceSetDetailByPsvId(psvId);
|
||||
setProductMapper.deleteByPsvId(psvId);
|
||||
int rows = versionMapper.deletePrcPriceSetVersionByIds(new Long[] { psvId });
|
||||
@@ -852,7 +853,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Attach version surcharge snapshots to a page of details (for drawer list). */
|
||||
/** Attach SALES surcharge rels (detail_id=psd_id) to a page of details. */
|
||||
private void fillDetailSurcharges(List<PrcPriceSetDetail> details)
|
||||
{
|
||||
if (details == null || details.isEmpty())
|
||||
@@ -871,21 +872,22 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<PrcPriceSetVersionSurcharge> surcharges = versionSurchargeMapper.selectByPsdIds(psdIds);
|
||||
Map<Long, List<PrcPriceSetVersionSurcharge>> byPsd = new HashMap<Long, List<PrcPriceSetVersionSurcharge>>();
|
||||
List<PrcSurchargeRel> surcharges =
|
||||
surchargeRelMapper.selectByDetailIdsAndPriceType(psdIds, PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
Map<Long, List<PrcSurchargeRel>> byPsd = new HashMap<Long, List<PrcSurchargeRel>>();
|
||||
if (surcharges != null)
|
||||
{
|
||||
for (PrcPriceSetVersionSurcharge sc : surcharges)
|
||||
for (PrcSurchargeRel sc : surcharges)
|
||||
{
|
||||
if (sc == null || sc.getPsdId() == null)
|
||||
if (sc == null || sc.getDetailId() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<PrcPriceSetVersionSurcharge> list = byPsd.get(sc.getPsdId());
|
||||
List<PrcSurchargeRel> list = byPsd.get(sc.getDetailId());
|
||||
if (list == null)
|
||||
{
|
||||
list = new ArrayList<PrcPriceSetVersionSurcharge>();
|
||||
byPsd.put(sc.getPsdId(), list);
|
||||
list = new ArrayList<PrcSurchargeRel>();
|
||||
byPsd.put(sc.getDetailId(), list);
|
||||
}
|
||||
list.add(sc);
|
||||
}
|
||||
@@ -896,8 +898,8 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<PrcPriceSetVersionSurcharge> list = byPsd.get(d.getPsdId());
|
||||
d.setSurcharges(list != null ? list : new ArrayList<PrcPriceSetVersionSurcharge>());
|
||||
List<PrcSurchargeRel> list = byPsd.get(d.getPsdId());
|
||||
d.setSurcharges(list != null ? list : new ArrayList<PrcSurchargeRel>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -910,9 +912,10 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
detail.setPsvId(resolvePsvId(detail.getPriceSetId(), detail.getPsvId()));
|
||||
detail.setPspId(lookupSetProductId(detail.getPsvId(), detail.getProductCode()));
|
||||
int rows = detailMapper.insertPrcPriceSetDetail(detail);
|
||||
PrcPriceSetVersion ver = new PrcPriceSetVersion();
|
||||
ver.setPsvId(detail.getPsvId());
|
||||
snapshotVersionSurcharges(ver, java.util.Collections.singletonList(detail));
|
||||
if (detail.getSurcharges() != null)
|
||||
{
|
||||
replaceSalesSurchargeRels(java.util.Collections.singletonList(detail));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
@@ -1071,6 +1074,18 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
assertUpdateOnlyWeightBandsMatch(byProduct, detailIndex);
|
||||
}
|
||||
String operName = null;
|
||||
try
|
||||
{
|
||||
operName = SecurityUtils.getUsername();
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
operName = null;
|
||||
}
|
||||
PrcPriceExcelFile excelFile = priceExcelFileService.saveImportExcel(
|
||||
PrcPriceExcelFile.TYPE_SALES, new Date(), bytes, filename, operName);
|
||||
Long pefId = excelFile != null ? excelFile.getPefId() : null;
|
||||
|
||||
Map<String, PrcPriceSetProduct> productMap = new LinkedHashMap<String, PrcPriceSetProduct>();
|
||||
int updated = 0;
|
||||
@@ -1172,9 +1187,20 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
throw new ServiceException(MessageUtils.message("price.set.import.noDetailWritten"));
|
||||
}
|
||||
|
||||
if (pefId != null)
|
||||
{
|
||||
for (PrcPriceSetProduct sp : productMap.values())
|
||||
{
|
||||
if (sp != null)
|
||||
{
|
||||
sp.setPefId(pefId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("products", new ArrayList<PrcPriceSetProduct>(productMap.values()));
|
||||
result.put("details", details);
|
||||
result.put("pefId", pefId);
|
||||
if (updateOnly)
|
||||
{
|
||||
result.put("message", MessageUtils.message("price.set.import.updateSuccess",
|
||||
@@ -1291,6 +1317,12 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
assertUpdateOnlyWeightBandsMatch(byProduct, detailIndex);
|
||||
}
|
||||
PrcPriceSetVersion verForFile = versionMapper.selectPrcPriceSetVersionById(psvId);
|
||||
Date excelEff = verForFile != null && verForFile.getEffectiveTime() != null
|
||||
? verForFile.getEffectiveTime() : new Date();
|
||||
PrcPriceExcelFile excelFile = priceExcelFileService.saveImportExcel(
|
||||
PrcPriceExcelFile.TYPE_SALES, excelEff, bytes, filename, operName);
|
||||
Long pefId = excelFile != null ? excelFile.getPefId() : null;
|
||||
|
||||
int updated = 0;
|
||||
int inserted = 0;
|
||||
@@ -1321,7 +1353,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
Long pspId = null;
|
||||
if (!updateOnly)
|
||||
{
|
||||
pspId = ensureSetProduct(priceSetId, psvId, productCode, productName);
|
||||
pspId = ensureSetProduct(priceSetId, psvId, productCode, productName, pefId);
|
||||
}
|
||||
for (BmsProductCountry row : e.getValue())
|
||||
{
|
||||
@@ -1385,6 +1417,11 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
setProductMapper.bindDetailPspByPsvId(psvId);
|
||||
}
|
||||
if (pefId != null && (inserted > 0 || updated > 0))
|
||||
{
|
||||
List<String> codes = new ArrayList<String>(byProduct.keySet());
|
||||
setProductMapper.updatePefIdByPsvId(psvId, pefId, codes);
|
||||
}
|
||||
reportImportProgress(taskId, priceSetId, 95, "finishing");
|
||||
if (inserted == 0 && updated == 0)
|
||||
{
|
||||
@@ -1779,13 +1816,10 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
}
|
||||
detail.setPspId(pspId);
|
||||
int rows = detailMapper.updatePrcPriceSetDetail(detail);
|
||||
// non-null surcharges = replace snapshot for this detail (empty list clears)
|
||||
// non-null surcharges = replace SALES rels for this detail (empty list clears)
|
||||
if (detail.getSurcharges() != null)
|
||||
{
|
||||
versionSurchargeMapper.deleteByPsdId(detail.getPsdId());
|
||||
PrcPriceSetVersion ver = new PrcPriceSetVersion();
|
||||
ver.setPsvId(detail.getPsvId());
|
||||
snapshotVersionSurcharges(ver, java.util.Collections.singletonList(detail));
|
||||
replaceSalesSurchargeRels(java.util.Collections.singletonList(detail));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
@@ -1808,6 +1842,21 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
touchKeys.add(old.getPsvId() + "|" + old.getProductCode());
|
||||
}
|
||||
}
|
||||
if (psdIds != null && psdIds.length > 0)
|
||||
{
|
||||
List<Long> ids = new ArrayList<Long>();
|
||||
for (Long id : psdIds)
|
||||
{
|
||||
if (id != null)
|
||||
{
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
if (!ids.isEmpty())
|
||||
{
|
||||
surchargeRelMapper.deleteByDetailIdsAndPriceType(ids, PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
}
|
||||
}
|
||||
int rows = detailMapper.deletePrcPriceSetDetailByIds(psdIds);
|
||||
for (String key : touchKeys)
|
||||
{
|
||||
@@ -1824,6 +1873,12 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
List<PrcPriceSetDetail> left = detailMapper.selectPrcPriceSetDetailList(q);
|
||||
if (left == null || left.isEmpty())
|
||||
{
|
||||
Long pspId = lookupSetProductId(psvId, productCode);
|
||||
if (pspId != null)
|
||||
{
|
||||
surchargeRelMapper.deleteByProductIdsAndPriceType(
|
||||
java.util.Collections.singletonList(pspId), PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
}
|
||||
setProductMapper.deleteByPsvIdAndCode(psvId, productCode);
|
||||
}
|
||||
}
|
||||
@@ -2656,9 +2711,8 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
pq.setPsvId(version.getPsvId());
|
||||
List<PrcPriceSetProduct> products = setProductMapper.selectPrcPriceSetProductList(pq);
|
||||
version.setProducts(products == null ? new ArrayList<PrcPriceSetProduct>() : products);
|
||||
// details + surcharge snapshots are loaded on demand (edit price / detail drawer)
|
||||
// details + SALES surcharge rels are loaded on demand (edit price / detail drawer)
|
||||
version.setDetails(new ArrayList<PrcPriceSetDetail>());
|
||||
version.setSurcharges(new ArrayList<PrcPriceSetVersionSurcharge>());
|
||||
}
|
||||
|
||||
private PrcPriceSetVersion pickCurrentVersion(List<PrcPriceSetVersion> versions)
|
||||
@@ -2733,6 +2787,8 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
version.setExpireTime(db.getExpireTime());
|
||||
}
|
||||
// Draft + build mode changed: wipe old product/detail/surcharge before mode switch
|
||||
clearDraftVersionChildrenIfBuildModeChanged(db, version);
|
||||
versionMapper.updatePrcPriceSetVersion(version);
|
||||
}
|
||||
set.setVersion(version);
|
||||
@@ -2740,7 +2796,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
upsertVersionDetails(set, version, details);
|
||||
reportSaveProgress(set, 85, "saving surcharges");
|
||||
resnapshotSurchargesIfNeeded(version, details);
|
||||
replaceSalesSurchargesIfNeeded(details);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2749,6 +2805,36 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
refreshVersionStatus(set.getPriceSetId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Draft only: when priceBuildMode changes (PULL/IMPORT), delete this version's
|
||||
* product / detail / SALES surcharge rel rows. Same mode or non-draft: no-op.
|
||||
*/
|
||||
private void clearDraftVersionChildrenIfBuildModeChanged(PrcPriceSetVersion db, PrcPriceSetVersion incoming)
|
||||
{
|
||||
if (db == null || incoming == null || db.getPsvId() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!VER_DRAFT.equals(db.getStatus()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
String newMode = StringUtils.trim(incoming.getPriceBuildMode());
|
||||
if (StringUtils.isEmpty(newMode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
String oldMode = StringUtils.trim(db.getPriceBuildMode());
|
||||
if (newMode.equalsIgnoreCase(StringUtils.nvl(oldMode, "")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Long psvId = db.getPsvId();
|
||||
deleteSalesRelsByPsvId(psvId);
|
||||
detailMapper.deletePrcPriceSetDetailByPsvId(psvId);
|
||||
setProductMapper.deleteByPsvId(psvId);
|
||||
}
|
||||
|
||||
/** Prefer same effective_time, else draft, else first version of the set. */
|
||||
private PrcPriceSetVersion findReusableVersion(Long priceSetId, Date effectiveTime)
|
||||
{
|
||||
@@ -2780,8 +2866,9 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk create details + surcharge snapshots via SQL joins (no per-product HTTP roundtrips).
|
||||
* Bulk create details via SQL joins (no per-product HTTP roundtrips).
|
||||
* Idempotent: if this version already has details and forcePullLibrary!=Y, skip re-insert.
|
||||
* SALES surcharge rels are not auto-created; configure via package surcharge picker.
|
||||
*/
|
||||
private void replaceVersionDetailsFromLibrary(PrcPriceSet set, PrcPriceSetVersion version)
|
||||
{
|
||||
@@ -2795,7 +2882,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
set.setDetails(new ArrayList<PrcPriceSetDetail>());
|
||||
return;
|
||||
}
|
||||
versionSurchargeMapper.deleteByPsvId(version.getPsvId());
|
||||
deleteSalesRelsByPsvId(version.getPsvId());
|
||||
detailMapper.deletePrcPriceSetDetailByPsvId(version.getPsvId());
|
||||
setProductMapper.deleteByPsvId(version.getPsvId());
|
||||
// clean legacy rows without psv_id under this set (would look like duplicates in UI)
|
||||
@@ -2829,8 +2916,6 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
}
|
||||
setProductMapper.bindDetailPspByPsvId(version.getPsvId());
|
||||
reportSaveProgress(set, 75, "saving details " + inserted + "/" + inserted);
|
||||
reportSaveProgress(set, 85, "saving surcharges");
|
||||
versionSurchargeMapper.insertFromLibraryRels(version.getPsvId(), version.getCreateBy());
|
||||
fillVersionChildren(version);
|
||||
set.setDetails(new ArrayList<PrcPriceSetDetail>());
|
||||
}
|
||||
@@ -2903,7 +2988,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
d.setPriceSetId(set.getPriceSetId());
|
||||
d.setPsvId(version.getPsvId());
|
||||
Long pspId = ensureSetProduct(set.getPriceSetId(), version.getPsvId(),
|
||||
d.getProductCode(), d.getProductName());
|
||||
d.getProductCode(), d.getProductName(), set.getPefId());
|
||||
if (pspId != null)
|
||||
{
|
||||
d.setPspId(pspId);
|
||||
@@ -2948,10 +3033,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
}
|
||||
if (!orphanIds.isEmpty())
|
||||
{
|
||||
for (Long id : orphanIds)
|
||||
{
|
||||
versionSurchargeMapper.deleteByPsdId(id);
|
||||
}
|
||||
surchargeRelMapper.deleteByDetailIdsAndPriceType(orphanIds, PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
detailMapper.deletePrcPriceSetDetailByIds(orphanIds.toArray(new Long[0]));
|
||||
}
|
||||
Set<String> keepCodes = new HashSet<String>();
|
||||
@@ -3027,6 +3109,12 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
* Uses request-scoped cache during bulk upsert to avoid N selects on same code.
|
||||
*/
|
||||
private Long ensureSetProduct(Long priceSetId, Long psvId, String productCode, String productNameHint)
|
||||
{
|
||||
return ensureSetProduct(priceSetId, psvId, productCode, productNameHint, null);
|
||||
}
|
||||
|
||||
private Long ensureSetProduct(Long priceSetId, Long psvId, String productCode, String productNameHint,
|
||||
Long pefId)
|
||||
{
|
||||
if (psvId == null || StringUtils.isEmpty(productCode))
|
||||
{
|
||||
@@ -3037,15 +3125,32 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
Map<String, Long> cache = setProductCacheTl.get();
|
||||
if (cache != null && cache.containsKey(key))
|
||||
{
|
||||
if (pefId != null)
|
||||
{
|
||||
PrcPriceSetProduct pefPatch = new PrcPriceSetProduct();
|
||||
pefPatch.setPspId(cache.get(key));
|
||||
pefPatch.setPefId(pefId);
|
||||
setProductMapper.updatePrcPriceSetProduct(pefPatch);
|
||||
}
|
||||
return cache.get(key);
|
||||
}
|
||||
PrcPriceSetProduct existing = setProductMapper.selectByPsvIdAndCode(psvId, code);
|
||||
if (existing != null)
|
||||
{
|
||||
boolean needUpdate = false;
|
||||
if (StringUtils.isEmpty(existing.getProductName()) && StringUtils.isNotEmpty(productNameHint)
|
||||
&& !code.equals(productNameHint))
|
||||
{
|
||||
existing.setProductName(productNameHint);
|
||||
needUpdate = true;
|
||||
}
|
||||
if (pefId != null && (existing.getPefId() == null || !pefId.equals(existing.getPefId())))
|
||||
{
|
||||
existing.setPefId(pefId);
|
||||
needUpdate = true;
|
||||
}
|
||||
if (needUpdate)
|
||||
{
|
||||
setProductMapper.updatePrcPriceSetProduct(existing);
|
||||
}
|
||||
if (cache != null)
|
||||
@@ -3058,6 +3163,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
row.setPriceSetId(priceSetId);
|
||||
row.setPsvId(psvId);
|
||||
row.setProductCode(code);
|
||||
row.setPefId(pefId);
|
||||
BmsProduct lib = null;
|
||||
try
|
||||
{
|
||||
@@ -3091,8 +3197,8 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
return row.getPspId();
|
||||
}
|
||||
|
||||
/** Only rewrite surcharge snapshots for rows that explicitly sent surcharges. */
|
||||
private void resnapshotSurchargesIfNeeded(PrcPriceSetVersion version, List<PrcPriceSetDetail> details)
|
||||
/** Only rewrite SALES surcharge rels for rows that explicitly sent surcharges. */
|
||||
private void replaceSalesSurchargesIfNeeded(List<PrcPriceSetDetail> details)
|
||||
{
|
||||
if (details == null || details.isEmpty())
|
||||
{
|
||||
@@ -3103,153 +3209,296 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
if (d != null && d.getPsdId() != null && d.getSurcharges() != null)
|
||||
{
|
||||
versionSurchargeMapper.deleteByPsdId(d.getPsdId());
|
||||
withSc.add(d);
|
||||
}
|
||||
}
|
||||
if (!withSc.isEmpty())
|
||||
{
|
||||
snapshotVersionSurcharges(version, withSc);
|
||||
replaceSalesSurchargeRels(withSc);
|
||||
}
|
||||
}
|
||||
|
||||
private void snapshotVersionSurcharges(PrcPriceSetVersion version, List<PrcPriceSetDetail> details)
|
||||
/**
|
||||
* Replace SALES prc_surcharge_rel rows for the given package details.
|
||||
* product_id = psp_id, detail_id = psd_id, price_type = SALES.
|
||||
* Empty surcharges list clears associations for that detail.
|
||||
*/
|
||||
private void replaceSalesSurchargeRels(List<PrcPriceSetDetail> details)
|
||||
{
|
||||
if (details == null || details.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Set<String> codes = new HashSet<String>();
|
||||
Map<Long, PrcSurcharge> masterById = null;
|
||||
for (PrcPriceSetDetail d : details)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(d.getProductCode()))
|
||||
{
|
||||
codes.add(d.getProductCode());
|
||||
}
|
||||
}
|
||||
Map<String, List<PrcSurchargeRel>> relsByProduct = new HashMap<String, List<PrcSurchargeRel>>();
|
||||
for (String code : codes)
|
||||
{
|
||||
PrcSurchargeRel q = new PrcSurchargeRel();
|
||||
q.setProductCode(code);
|
||||
List<PrcSurchargeRel> rels = surchargeRelMapper.selectPrcSurchargeRelList(q);
|
||||
relsByProduct.put(code, rels == null ? new ArrayList<PrcSurchargeRel>() : rels);
|
||||
}
|
||||
// 勾选列表来自「价格基础 → 附加费配置」主表(prc_surcharge),不要求产品已做 rel 关联;
|
||||
// rel 里没有的勾选项,回退主表取值落快照。
|
||||
List<PrcSurcharge> surchargeMasters = java.util.Collections.emptyList();
|
||||
for (PrcPriceSetDetail d0 : details)
|
||||
{
|
||||
if (d0.getSurcharges() != null && !d0.getSurcharges().isEmpty())
|
||||
{
|
||||
surchargeMasters = surchargeMapper.selectPrcSurchargeList(new PrcSurcharge());
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<PrcPriceSetVersionSurcharge> saved = new ArrayList<PrcPriceSetVersionSurcharge>();
|
||||
for (PrcPriceSetDetail d : details)
|
||||
{
|
||||
List<PrcSurchargeRel> rels = relsByProduct.get(d.getProductCode());
|
||||
if (rels == null)
|
||||
if (d == null || d.getPsdId() == null || d.getSurcharges() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// 前端勾选结果:明细带了 surcharges 就按勾选保存(空集合 = 一条都不要);
|
||||
// 为 null 表示调用方没传勾选(如详情页新增单条明细),沿用「全部命中即快照」。
|
||||
Set<Long> pickedScIds = null;
|
||||
if (d.getSurcharges() != null)
|
||||
Long pspId = d.getPspId();
|
||||
if (pspId == null && d.getPsvId() != null && StringUtils.isNotEmpty(d.getProductCode()))
|
||||
{
|
||||
pickedScIds = new HashSet<Long>();
|
||||
for (PrcPriceSetVersionSurcharge picked : d.getSurcharges())
|
||||
{
|
||||
if (picked != null && picked.getScId() != null)
|
||||
{
|
||||
pickedScIds.add(picked.getScId());
|
||||
}
|
||||
}
|
||||
pspId = lookupSetProductId(d.getPsvId(), d.getProductCode());
|
||||
d.setPspId(pspId);
|
||||
}
|
||||
List<PrcPriceSetVersionSurcharge> rowSc = new ArrayList<PrcPriceSetVersionSurcharge>();
|
||||
if (pspId == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
surchargeRelMapper.deleteByDetailIdsAndPriceType(
|
||||
java.util.Collections.singletonList(d.getPsdId()), PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
|
||||
List<PrcSurchargeRel> saved = new ArrayList<PrcSurchargeRel>();
|
||||
Set<Long> written = new HashSet<Long>();
|
||||
for (PrcSurchargeRel rel : rels)
|
||||
for (PrcSurchargeRel picked : d.getSurcharges())
|
||||
{
|
||||
if (rel == null || StringUtils.isEmpty(rel.getScName()) || rel.getChargeValue() == null)
|
||||
if (picked == null || picked.getScId() == null || written.contains(picked.getScId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ("of".equalsIgnoreCase(rel.getSsCode()))
|
||||
PrcSurchargeRel row = buildSalesRel(d, pspId, picked.getScId(), picked.getCountryCode());
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (pickedScIds != null && !pickedScIds.contains(rel.getScId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (rel.getDetailId() != null && d.getProductCountryId() != null
|
||||
&& !rel.getDetailId().equals(d.getProductCountryId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (rel.getDetailId() != null && d.getProductCountryId() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
PrcPriceSetVersionSurcharge sc = new PrcPriceSetVersionSurcharge();
|
||||
sc.setPsvId(version.getPsvId());
|
||||
sc.setPsdId(d.getPsdId());
|
||||
sc.setScId(rel.getScId());
|
||||
sc.setProductCode(d.getProductCode());
|
||||
sc.setScName(rel.getScName());
|
||||
sc.setFeeType(StringUtils.isEmpty(rel.getFeeType()) ? "SURCHARGE" : rel.getFeeType());
|
||||
sc.setChargeType(StringUtils.isEmpty(rel.getChargeType()) ? "FIXED" : rel.getChargeType());
|
||||
sc.setChargeValue(rel.getChargeValue());
|
||||
sc.setCurrency(rel.getCurrency());
|
||||
sc.setRoundMode(rel.getRoundMode());
|
||||
sc.setCountryCode(rel.getCountryCode());
|
||||
sc.setScNote(rel.getScNote());
|
||||
sc.setCreateBy(version.getCreateBy());
|
||||
versionSurchargeMapper.insertPrcPriceSetVersionSurcharge(sc);
|
||||
saved.add(sc);
|
||||
rowSc.add(sc);
|
||||
written.add(rel.getScId());
|
||||
}
|
||||
// 勾选了但产品未关联(rel 无此 scId)的附加费:回退 prc_surcharge 主表配置
|
||||
if (pickedScIds != null)
|
||||
{
|
||||
for (PrcSurcharge m : surchargeMasters)
|
||||
{
|
||||
if (m == null || m.getScId() == null || written.contains(m.getScId())
|
||||
|| !pickedScIds.contains(m.getScId()))
|
||||
if (masterById == null)
|
||||
{
|
||||
continue;
|
||||
masterById = loadSurchargeMasterMap();
|
||||
}
|
||||
if (StringUtils.isEmpty(m.getScName()) || m.getChargeValue() == null
|
||||
PrcSurcharge m = masterById.get(picked.getScId());
|
||||
if (m == null || StringUtils.isEmpty(m.getScName()) || m.getChargeValue() == null
|
||||
|| "of".equalsIgnoreCase(m.getSsCode()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
PrcPriceSetVersionSurcharge sc = new PrcPriceSetVersionSurcharge();
|
||||
sc.setPsvId(version.getPsvId());
|
||||
sc.setPsdId(d.getPsdId());
|
||||
sc.setScId(m.getScId());
|
||||
sc.setProductCode(d.getProductCode());
|
||||
sc.setScName(m.getScName());
|
||||
sc.setFeeType(StringUtils.isEmpty(m.getFeeType()) ? "SURCHARGE" : m.getFeeType());
|
||||
sc.setChargeType(StringUtils.isEmpty(m.getChargeType()) ? "FIXED" : m.getChargeType());
|
||||
sc.setChargeValue(m.getChargeValue());
|
||||
sc.setCurrency(m.getCurrency());
|
||||
sc.setRoundMode(m.getRoundMode());
|
||||
sc.setCountryCode(m.getCountryCode());
|
||||
sc.setScNote(m.getScNote());
|
||||
sc.setCreateBy(version.getCreateBy());
|
||||
versionSurchargeMapper.insertPrcPriceSetVersionSurcharge(sc);
|
||||
saved.add(sc);
|
||||
rowSc.add(sc);
|
||||
written.add(m.getScId());
|
||||
row = new PrcSurchargeRel();
|
||||
row.setScId(m.getScId());
|
||||
row.setProductId(pspId);
|
||||
row.setProductCode(d.getProductCode());
|
||||
row.setDetailId(d.getPsdId());
|
||||
row.setPriceType(PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
row.setCountryCode(normalizeCountry(picked.getCountryCode() != null
|
||||
? picked.getCountryCode() : m.getCountryCode()));
|
||||
row.setScName(m.getScName());
|
||||
row.setFeeType(m.getFeeType());
|
||||
row.setChargeType(m.getChargeType());
|
||||
row.setChargeValue(m.getChargeValue());
|
||||
row.setCurrency(m.getCurrency());
|
||||
row.setRoundMode(m.getRoundMode());
|
||||
row.setSsCode(m.getSsCode());
|
||||
row.setScNote(m.getScNote());
|
||||
row.setCreateBy(SecurityUtils.getUsername());
|
||||
}
|
||||
surchargeRelMapper.insertPrcSurchargeRel(row);
|
||||
saved.add(row);
|
||||
written.add(picked.getScId());
|
||||
}
|
||||
d.setSurcharges(saved);
|
||||
}
|
||||
}
|
||||
|
||||
private PrcSurchargeRel buildSalesRel(PrcPriceSetDetail d, Long pspId, Long scId, String countryCode)
|
||||
{
|
||||
if (d == null || pspId == null || scId == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PrcSurcharge m = surchargeMapper.selectPrcSurchargeById(scId);
|
||||
if (m == null || StringUtils.isEmpty(m.getScName()) || m.getChargeValue() == null
|
||||
|| "of".equalsIgnoreCase(m.getSsCode()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PrcSurchargeRel row = new PrcSurchargeRel();
|
||||
row.setScId(m.getScId());
|
||||
row.setProductId(pspId);
|
||||
row.setProductCode(d.getProductCode());
|
||||
row.setDetailId(d.getPsdId());
|
||||
row.setPriceType(PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
row.setCountryCode(normalizeCountry(countryCode != null ? countryCode : m.getCountryCode()));
|
||||
row.setScName(m.getScName());
|
||||
row.setFeeType(m.getFeeType());
|
||||
row.setChargeType(m.getChargeType());
|
||||
row.setChargeValue(m.getChargeValue());
|
||||
row.setCurrency(m.getCurrency());
|
||||
row.setRoundMode(m.getRoundMode());
|
||||
row.setSsCode(m.getSsCode());
|
||||
row.setScNote(m.getScNote());
|
||||
row.setCreateBy(SecurityUtils.getUsername());
|
||||
return row;
|
||||
}
|
||||
|
||||
private Map<Long, PrcSurcharge> loadSurchargeMasterMap()
|
||||
{
|
||||
Map<Long, PrcSurcharge> map = new HashMap<Long, PrcSurcharge>();
|
||||
List<PrcSurcharge> all = surchargeMapper.selectPrcSurchargeList(new PrcSurcharge());
|
||||
if (all == null)
|
||||
{
|
||||
return map;
|
||||
}
|
||||
for (PrcSurcharge m : all)
|
||||
{
|
||||
if (m != null && m.getScId() != null)
|
||||
{
|
||||
map.put(m.getScId(), m);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private String normalizeCountry(String code)
|
||||
{
|
||||
if (StringUtils.isEmpty(code))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return code.trim().toUpperCase();
|
||||
}
|
||||
|
||||
/** Delete all SALES surcharge rels under a package version (by detail + set-product ids). */
|
||||
private void deleteSalesRelsByPsvId(Long psvId)
|
||||
{
|
||||
if (psvId == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PrcPriceSetDetail dq = new PrcPriceSetDetail();
|
||||
dq.setPsvId(psvId);
|
||||
List<PrcPriceSetDetail> details = detailMapper.selectPrcPriceSetDetailList(dq);
|
||||
if (details != null && !details.isEmpty())
|
||||
{
|
||||
List<Long> psdIds = new ArrayList<Long>();
|
||||
for (PrcPriceSetDetail d : details)
|
||||
{
|
||||
if (d != null && d.getPsdId() != null)
|
||||
{
|
||||
psdIds.add(d.getPsdId());
|
||||
}
|
||||
}
|
||||
d.setSurcharges(rowSc);
|
||||
if (!psdIds.isEmpty())
|
||||
{
|
||||
surchargeRelMapper.deleteByDetailIdsAndPriceType(psdIds, PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
}
|
||||
}
|
||||
version.setSurcharges(saved);
|
||||
PrcPriceSetProduct pq = new PrcPriceSetProduct();
|
||||
pq.setPsvId(psvId);
|
||||
List<PrcPriceSetProduct> products = setProductMapper.selectPrcPriceSetProductList(pq);
|
||||
if (products != null && !products.isEmpty())
|
||||
{
|
||||
List<Long> pspIds = new ArrayList<Long>();
|
||||
for (PrcPriceSetProduct p : products)
|
||||
{
|
||||
if (p != null && p.getPspId() != null)
|
||||
{
|
||||
pspIds.add(p.getPspId());
|
||||
}
|
||||
}
|
||||
if (!pspIds.isEmpty())
|
||||
{
|
||||
surchargeRelMapper.deleteByProductIdsAndPriceType(pspIds, PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy SALES surcharge rels from source version details onto newly copied details
|
||||
* (match by product_code + country + zone + weight + product_country_id).
|
||||
*/
|
||||
private void copySalesSurchargeRelsFromVersion(Long srcPsvId, Long newPsvId, String createBy)
|
||||
{
|
||||
if (srcPsvId == null || newPsvId == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PrcPriceSetDetail sq = new PrcPriceSetDetail();
|
||||
sq.setPsvId(srcPsvId);
|
||||
List<PrcPriceSetDetail> srcDetails = detailMapper.selectPrcPriceSetDetailList(sq);
|
||||
PrcPriceSetDetail nq = new PrcPriceSetDetail();
|
||||
nq.setPsvId(newPsvId);
|
||||
List<PrcPriceSetDetail> newDetails = detailMapper.selectPrcPriceSetDetailList(nq);
|
||||
if (srcDetails == null || srcDetails.isEmpty() || newDetails == null || newDetails.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<Long> srcPsdIds = new ArrayList<Long>();
|
||||
for (PrcPriceSetDetail d : srcDetails)
|
||||
{
|
||||
if (d != null && d.getPsdId() != null)
|
||||
{
|
||||
srcPsdIds.add(d.getPsdId());
|
||||
}
|
||||
}
|
||||
List<PrcSurchargeRel> srcRels =
|
||||
surchargeRelMapper.selectByDetailIdsAndPriceType(srcPsdIds, PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
if (srcRels == null || srcRels.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Map<Long, List<PrcSurchargeRel>> bySrcPsd = new HashMap<Long, List<PrcSurchargeRel>>();
|
||||
for (PrcSurchargeRel rel : srcRels)
|
||||
{
|
||||
if (rel == null || rel.getDetailId() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<PrcSurchargeRel> list = bySrcPsd.get(rel.getDetailId());
|
||||
if (list == null)
|
||||
{
|
||||
list = new ArrayList<PrcSurchargeRel>();
|
||||
bySrcPsd.put(rel.getDetailId(), list);
|
||||
}
|
||||
list.add(rel);
|
||||
}
|
||||
Map<String, PrcPriceSetDetail> newByKey = new HashMap<String, PrcPriceSetDetail>();
|
||||
for (PrcPriceSetDetail nd : newDetails)
|
||||
{
|
||||
if (nd != null)
|
||||
{
|
||||
newByKey.put(detailMatchKey(nd), nd);
|
||||
}
|
||||
}
|
||||
for (PrcPriceSetDetail od : srcDetails)
|
||||
{
|
||||
if (od == null || od.getPsdId() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
PrcPriceSetDetail nd = newByKey.get(detailMatchKey(od));
|
||||
if (nd == null || nd.getPsdId() == null || nd.getPspId() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<PrcSurchargeRel> rels = bySrcPsd.get(od.getPsdId());
|
||||
if (rels == null || rels.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (PrcSurchargeRel src : rels)
|
||||
{
|
||||
PrcSurchargeRel row = new PrcSurchargeRel();
|
||||
row.setScId(src.getScId());
|
||||
row.setProductId(nd.getPspId());
|
||||
row.setProductCode(nd.getProductCode());
|
||||
row.setDetailId(nd.getPsdId());
|
||||
row.setPriceType(PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
row.setCountryCode(normalizeCountry(src.getCountryCode()));
|
||||
row.setCreateBy(createBy);
|
||||
surchargeRelMapper.insertPrcSurchargeRel(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String detailMatchKey(PrcPriceSetDetail d)
|
||||
{
|
||||
if (d == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return StringUtils.nvl(d.getProductCode(), "")
|
||||
+ "|" + StringUtils.nvl(d.getCountryCode(), "")
|
||||
+ "|" + StringUtils.nvl(d.getZoneCode(), "")
|
||||
+ "|" + StringUtils.nvl(d.getWeightLabel(), "")
|
||||
+ "|" + (d.getProductCountryId() == null ? "0" : d.getProductCountryId().toString())
|
||||
+ "|" + (d.getDiscountValue() == null ? "-1" : d.getDiscountValue().toPlainString());
|
||||
}
|
||||
|
||||
/** True when package already has a true draft (status=0). Pending(3) does not block copy. */
|
||||
|
||||
+36
-1
@@ -11,7 +11,7 @@ import com.bms.price.mapper.PrcSurchargeRelMapper;
|
||||
import com.bms.price.service.IPrcSurchargeRelService;
|
||||
|
||||
/**
|
||||
* 附加费与产品/明细关联 服务层实现
|
||||
* 附加费与产品/明细/套餐关联 服务层实现
|
||||
*
|
||||
* @author bms
|
||||
*/
|
||||
@@ -23,9 +23,19 @@ public class PrcSurchargeRelServiceImpl implements IPrcSurchargeRelService
|
||||
|
||||
@Override
|
||||
public List<PrcSurchargeRel> selectRelByProductCode(String productCode)
|
||||
{
|
||||
return selectRelByProductCode(productCode, PrcSurchargeRel.PRICE_TYPE_PRODUCT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrcSurchargeRel> selectRelByProductCode(String productCode, String priceType)
|
||||
{
|
||||
PrcSurchargeRel query = new PrcSurchargeRel();
|
||||
query.setProductCode(productCode);
|
||||
if (StringUtils.isNotEmpty(priceType))
|
||||
{
|
||||
query.setPriceType(priceType.trim().toUpperCase());
|
||||
}
|
||||
return relMapper.selectPrcSurchargeRelList(query);
|
||||
}
|
||||
|
||||
@@ -39,6 +49,18 @@ public class PrcSurchargeRelServiceImpl implements IPrcSurchargeRelService
|
||||
public int insertPrcSurchargeRel(PrcSurchargeRel rel)
|
||||
{
|
||||
validate(rel);
|
||||
if (StringUtils.isEmpty(rel.getPriceType()))
|
||||
{
|
||||
rel.setPriceType(PrcSurchargeRel.PRICE_TYPE_PRODUCT);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(rel.getCountryCode()))
|
||||
{
|
||||
rel.setCountryCode(rel.getCountryCode().trim().toUpperCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
rel.setCountryCode(null);
|
||||
}
|
||||
return relMapper.insertPrcSurchargeRel(rel);
|
||||
}
|
||||
|
||||
@@ -76,5 +98,18 @@ public class PrcSurchargeRelServiceImpl implements IPrcSurchargeRelService
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.surchargeRel.productCode.empty"));
|
||||
}
|
||||
String type = StringUtils.isEmpty(rel.getPriceType())
|
||||
? PrcSurchargeRel.PRICE_TYPE_PRODUCT : rel.getPriceType().trim().toUpperCase();
|
||||
if (!PrcSurchargeRel.PRICE_TYPE_PRODUCT.equals(type)
|
||||
&& !PrcSurchargeRel.PRICE_TYPE_SALES.equals(type)
|
||||
&& !PrcSurchargeRel.PRICE_TYPE_REDLINE.equals(type))
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.surchargeRel.priceType.invalid"));
|
||||
}
|
||||
rel.setPriceType(type);
|
||||
if (PrcSurchargeRel.PRICE_TYPE_SALES.equals(type) && rel.getDetailId() == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.surchargeRel.detailId.empty"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+150
-41
@@ -25,12 +25,12 @@ import com.bms.customer.customerinfo.domain.BmsCustomer;
|
||||
import com.bms.customer.customerinfo.mapper.BmsCustomerMapper;
|
||||
import com.bms.price.domain.BmsProduct;
|
||||
import com.bms.price.domain.BmsProductCountry;
|
||||
import com.bms.price.domain.BmsRedlineProductCountry;
|
||||
import com.bms.price.domain.PrcCustomerPriceSet;
|
||||
import com.bms.price.domain.PrcPriceSet;
|
||||
import com.bms.price.domain.PrcPriceSetDetail;
|
||||
import com.bms.price.domain.PrcPriceSetProduct;
|
||||
import com.bms.price.domain.PrcPriceSetVersion;
|
||||
import com.bms.price.domain.PrcPriceSetVersionSurcharge;
|
||||
import com.bms.price.domain.PrcQuote;
|
||||
import com.bms.price.domain.PrcQuoteFee;
|
||||
import com.bms.price.domain.PrcSurchargeRel;
|
||||
@@ -43,12 +43,12 @@ import com.bms.price.domain.vo.TmsPriceQuoteResult;
|
||||
import com.bms.price.enums.BillCustomerActiveStatus;
|
||||
import com.bms.price.mapper.BmsProductCountryMapper;
|
||||
import com.bms.price.mapper.BmsProductMapper;
|
||||
import com.bms.price.mapper.BmsRedlineProductCountryMapper;
|
||||
import com.bms.price.mapper.PrcCustomerPriceSetMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetDetailMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetProductMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetVersionMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetVersionSurchargeMapper;
|
||||
import com.bms.price.mapper.PrcQuoteFeeMapper;
|
||||
import com.bms.price.mapper.PrcQuoteMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeRelMapper;
|
||||
@@ -87,9 +87,6 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
@Autowired
|
||||
private PrcPriceSetVersionMapper versionMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcPriceSetVersionSurchargeMapper versionSurchargeMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcPriceSetDetailMapper detailMapper;
|
||||
|
||||
@@ -99,6 +96,9 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
@Autowired
|
||||
private BmsProductCountryMapper productCountryMapper;
|
||||
|
||||
@Autowired
|
||||
private BmsRedlineProductCountryMapper redlineProductCountryMapper;
|
||||
|
||||
@Autowired
|
||||
private BmsProductMapper productMapper;
|
||||
|
||||
@@ -879,6 +879,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
r.setRoundMode(mode);
|
||||
r.setFromCache(false);
|
||||
fillProductAmountAndPay(r, catalog, weight, rm, mode);
|
||||
fillRedlineAmount(r, weight, rm);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -934,6 +935,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
r.setRoundMode(mode);
|
||||
r.setFromCache(false);
|
||||
fillProductAmountAndPay(r, base, weight, rm, mode);
|
||||
fillRedlineAmount(r, weight, rm);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -966,6 +968,50 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
r.setPayFeeDetails(payLines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redline catalog amount from redline_product_country (same match keys as product catalog).
|
||||
*/
|
||||
private void fillRedlineAmount(TmsPriceQuoteResult r, BigDecimal weight, RoundingMode rm)
|
||||
{
|
||||
if (r == null || weight == null || StringUtils.isEmpty(r.getProductCode()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
BmsRedlineProductCountry base = redlineProductCountryMapper.selectMatchByProductCountryWeight(
|
||||
r.getProductCode(), r.getCountryCode(), r.getCountryName(), r.getZoneCode(), weight, null);
|
||||
if (base == null || base.getFreightPrice() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (base.getDetailId() != null)
|
||||
{
|
||||
r.setRedlineCountryId(base.getDetailId());
|
||||
}
|
||||
BigDecimal baseReg = base.getRegistrationFee() == null ? BigDecimal.ZERO : base.getRegistrationFee();
|
||||
BigDecimal freight = base.getFreightPrice().multiply(weight).setScale(2, rm);
|
||||
BigDecimal regScaled = baseReg.setScale(2, rm);
|
||||
r.setRedlineAmount(freight.add(regScaled).setScale(2, rm));
|
||||
// Stash freight/reg on existing payFeeDetails for income fee-line apportionment
|
||||
if (r.getPayFeeDetails() != null)
|
||||
{
|
||||
for (TmsPriceQuoteFeeLine line : r.getPayFeeDetails())
|
||||
{
|
||||
if (line == null || line.getFeeType() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (FEE_BASIC.equals(line.getFeeType()))
|
||||
{
|
||||
line.setRedlineAmount(freight);
|
||||
}
|
||||
else if (FEE_REG.equals(line.getFeeType()))
|
||||
{
|
||||
line.setRedlineAmount(regScaled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applySurchargesAndFees(TmsPriceQuoteResult result)
|
||||
{
|
||||
BigDecimal freightAmount = nvl(result.getFreightAmount());
|
||||
@@ -973,20 +1019,27 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
RoundingMode rm = resolveRoundingMode(result.getRoundMode());
|
||||
String currency = normalizeCurrency(result.getCurrency());
|
||||
|
||||
List<PrcSurchargeRel> rels = loadMatchedSurcharges(result);
|
||||
List<PrcSurchargeRel> salesRels = loadMatchedSurcharges(result, PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
List<PrcSurchargeRel> productRels = loadMatchedSurcharges(result, PrcSurchargeRel.PRICE_TYPE_PRODUCT);
|
||||
List<PrcSurchargeRel> redlineRels = loadMatchedSurcharges(result, PrcSurchargeRel.PRICE_TYPE_REDLINE);
|
||||
|
||||
List<TmsPriceQuoteFeeLine> lines = new ArrayList<TmsPriceQuoteFeeLine>();
|
||||
BigDecimal productFreight = productAmountOf(result.getPayFeeDetails(), FEE_BASIC);
|
||||
BigDecimal productReg = productAmountOf(result.getPayFeeDetails(), FEE_REG);
|
||||
BigDecimal redlineFreight = redlineAmountOf(result.getPayFeeDetails(), FEE_BASIC);
|
||||
BigDecimal redlineReg = redlineAmountOf(result.getPayFeeDetails(), FEE_REG);
|
||||
TmsPriceQuoteFeeLine basicLine = feeLine(FEE_BASIC, feeNameOf(FEE_BASIC), 0L, freightAmount, currency, result.getRoundMode(), null);
|
||||
basicLine.setProductAmount(productFreight);
|
||||
basicLine.setRedlineAmount(redlineFreight);
|
||||
lines.add(basicLine);
|
||||
TmsPriceQuoteFeeLine regLine = feeLine(FEE_REG, feeNameOf(FEE_REG), 0L, registrationFee, currency, result.getRoundMode(), null);
|
||||
regLine.setProductAmount(productReg);
|
||||
regLine.setRedlineAmount(redlineReg);
|
||||
lines.add(regLine);
|
||||
|
||||
BigDecimal surchargeTotal = BigDecimal.ZERO;
|
||||
Map<Long, TmsPriceQuoteFeeLine> surchargeLines = new LinkedHashMap<Long, TmsPriceQuoteFeeLine>();
|
||||
for (PrcSurchargeRel rel : rels)
|
||||
for (PrcSurchargeRel rel : salesRels)
|
||||
{
|
||||
BigDecimal itemAmount = calcSurchargeAmount(rel, result.getWeight(), freightAmount);
|
||||
if (itemAmount == null)
|
||||
@@ -1017,41 +1070,90 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
result.setPayableTotal(freightAmount.add(registrationFee).add(surchargeTotal).setScale(2, rm));
|
||||
result.setIncomeTotal(result.getPayableTotal());
|
||||
result.setFeeDetails(lines);
|
||||
|
||||
BigDecimal productExtra = sumSurchargeAmounts(productRels, result.getWeight(), freightAmount, rm);
|
||||
BigDecimal redlineExtra = sumSurchargeAmounts(redlineRels, result.getWeight(), freightAmount, rm);
|
||||
if (result.getProductAmount() != null || productExtra.compareTo(BigDecimal.ZERO) > 0)
|
||||
{
|
||||
result.setProductAmount(nvl(result.getProductAmount()).add(productExtra).setScale(2, rm));
|
||||
}
|
||||
if (result.getCostAmount() != null || productExtra.compareTo(BigDecimal.ZERO) > 0)
|
||||
{
|
||||
result.setCostAmount(nvl(result.getCostAmount()).add(productExtra).setScale(2, rm));
|
||||
}
|
||||
if (result.getPayTotal() != null || productExtra.compareTo(BigDecimal.ZERO) > 0)
|
||||
{
|
||||
result.setPayTotal(nvl(result.getPayTotal()).add(productExtra).setScale(2, rm));
|
||||
}
|
||||
if (result.getRedlineAmount() != null || redlineExtra.compareTo(BigDecimal.ZERO) > 0)
|
||||
{
|
||||
result.setRedlineAmount(nvl(result.getRedlineAmount()).add(redlineExtra).setScale(2, rm));
|
||||
}
|
||||
else if (redlineExtra.compareTo(BigDecimal.ZERO) > 0)
|
||||
{
|
||||
result.setRedlineAmount(redlineExtra);
|
||||
}
|
||||
}
|
||||
|
||||
private List<PrcSurchargeRel> loadMatchedSurcharges(TmsPriceQuoteResult result)
|
||||
private BigDecimal sumSurchargeAmounts(List<PrcSurchargeRel> rels, BigDecimal weight,
|
||||
BigDecimal freightAmount, RoundingMode rm)
|
||||
{
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
if (rels == null)
|
||||
{
|
||||
return total;
|
||||
}
|
||||
for (PrcSurchargeRel rel : rels)
|
||||
{
|
||||
BigDecimal item = calcSurchargeAmount(rel, weight, freightAmount);
|
||||
if (item != null)
|
||||
{
|
||||
total = total.add(item);
|
||||
}
|
||||
}
|
||||
return total.setScale(2, rm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load matched surcharge rels by price_type.
|
||||
* SALES: package detail_id = psd_id.
|
||||
* PRODUCT / REDLINE: product catalog associations by product_code + country/detail.
|
||||
*/
|
||||
private List<PrcSurchargeRel> loadMatchedSurcharges(TmsPriceQuoteResult result, String priceType)
|
||||
{
|
||||
List<PrcSurchargeRel> matched = new ArrayList<PrcSurchargeRel>();
|
||||
if (result == null || StringUtils.isEmpty(result.getProductCode()))
|
||||
if (result == null || StringUtils.isEmpty(priceType))
|
||||
{
|
||||
return matched;
|
||||
}
|
||||
boolean packageHit = SRC_FIXED.equals(result.getMatchSource()) || SRC_DISCOUNT.equals(result.getMatchSource());
|
||||
// Package sales use version surcharge snapshot only (empty snapshot = no surcharge).
|
||||
if (packageHit)
|
||||
if (PrcSurchargeRel.PRICE_TYPE_SALES.equals(priceType))
|
||||
{
|
||||
if (result.getPsdId() == null)
|
||||
{
|
||||
return matched;
|
||||
}
|
||||
List<PrcPriceSetVersionSurcharge> snaps =
|
||||
versionSurchargeMapper.selectByPsdIds(Collections.singletonList(result.getPsdId()));
|
||||
if (snaps == null || snaps.isEmpty())
|
||||
List<PrcSurchargeRel> rels = surchargeRelMapper.selectByDetailIdsAndPriceType(
|
||||
Collections.singletonList(result.getPsdId()), PrcSurchargeRel.PRICE_TYPE_SALES);
|
||||
if (rels == null)
|
||||
{
|
||||
return matched;
|
||||
}
|
||||
for (PrcPriceSetVersionSurcharge snap : snaps)
|
||||
for (PrcSurchargeRel rel : rels)
|
||||
{
|
||||
PrcSurchargeRel rel = toRelFromVersionSnap(snap);
|
||||
if (surchargeApplies(rel, result))
|
||||
if (surchargeApplies(rel, result, true))
|
||||
{
|
||||
matched.add(rel);
|
||||
}
|
||||
}
|
||||
return matched;
|
||||
}
|
||||
if (StringUtils.isEmpty(result.getProductCode()))
|
||||
{
|
||||
return matched;
|
||||
}
|
||||
PrcSurchargeRel query = new PrcSurchargeRel();
|
||||
query.setProductCode(result.getProductCode());
|
||||
query.setPriceType(priceType);
|
||||
List<PrcSurchargeRel> rels = surchargeRelMapper.selectPrcSurchargeRelList(query);
|
||||
if (rels == null)
|
||||
{
|
||||
@@ -1059,7 +1161,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
for (PrcSurchargeRel rel : rels)
|
||||
{
|
||||
if (surchargeApplies(rel, result))
|
||||
if (surchargeApplies(rel, result, false))
|
||||
{
|
||||
matched.add(rel);
|
||||
}
|
||||
@@ -1067,28 +1169,10 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
return matched;
|
||||
}
|
||||
|
||||
private PrcSurchargeRel toRelFromVersionSnap(PrcPriceSetVersionSurcharge snap)
|
||||
{
|
||||
PrcSurchargeRel rel = new PrcSurchargeRel();
|
||||
if (snap == null)
|
||||
{
|
||||
return rel;
|
||||
}
|
||||
rel.setScId(snap.getScId());
|
||||
rel.setProductCode(snap.getProductCode());
|
||||
rel.setScName(snap.getScName());
|
||||
rel.setFeeType(snap.getFeeType());
|
||||
rel.setChargeType(snap.getChargeType());
|
||||
rel.setChargeValue(snap.getChargeValue());
|
||||
rel.setCurrency(snap.getCurrency());
|
||||
rel.setRoundMode(snap.getRoundMode());
|
||||
rel.setCountryCode(snap.getCountryCode());
|
||||
rel.setScNote(snap.getScNote());
|
||||
rel.setSsCode("on");
|
||||
return rel;
|
||||
}
|
||||
|
||||
private boolean surchargeApplies(PrcSurchargeRel rel, TmsPriceQuoteResult result)
|
||||
/**
|
||||
* @param salesRel true = SALES (detail_id already = psd_id); false = PRODUCT/REDLINE detail match
|
||||
*/
|
||||
private boolean surchargeApplies(PrcSurchargeRel rel, TmsPriceQuoteResult result, boolean salesRel)
|
||||
{
|
||||
if (rel == null)
|
||||
{
|
||||
@@ -1103,10 +1187,18 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (salesRel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (rel.getDetailId() == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (PrcSurchargeRel.PRICE_TYPE_REDLINE.equals(rel.getPriceType()))
|
||||
{
|
||||
return result.getRedlineCountryId() != null && rel.getDetailId().equals(result.getRedlineCountryId());
|
||||
}
|
||||
return result.getProductCountryId() != null && rel.getDetailId().equals(result.getProductCountryId());
|
||||
}
|
||||
|
||||
@@ -1409,6 +1501,23 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Read redline catalog amount for a fee type from payFeeDetails. */
|
||||
private static BigDecimal redlineAmountOf(List<TmsPriceQuoteFeeLine> payLines, String feeType)
|
||||
{
|
||||
if (payLines == null || feeType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (TmsPriceQuoteFeeLine line : payLines)
|
||||
{
|
||||
if (line != null && feeType.equals(line.getFeeType()))
|
||||
{
|
||||
return line.getRedlineAmount();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static TmsPriceQuoteFeeLine feeLine(String feeType, String feeName, Long scId, BigDecimal amount,
|
||||
String currency, String roundMode, String remark)
|
||||
{
|
||||
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package com.bms.price.task;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.bms.common.core.redis.RedisCache;
|
||||
import com.bms.common.utils.StringUtils;
|
||||
import com.bms.price.domain.BmsRedlineProductImportTask;
|
||||
import com.bms.price.service.IBmsRedlineProductService;
|
||||
|
||||
/**
|
||||
* Async runner for product Excel import (avoids HTTP timeout on large workbooks).
|
||||
*/
|
||||
@Component
|
||||
public class BmsRedlineProductImportAsyncRunner
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(BmsRedlineProductImportAsyncRunner.class);
|
||||
|
||||
public static final String CACHE_KEY_PREFIX = "price:redline:import:task:";
|
||||
public static final int TTL_MINUTES = 60;
|
||||
|
||||
@Autowired
|
||||
private IBmsRedlineProductService productService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/** Background all-country (Weishi catalog) import. */
|
||||
@Async("threadPoolTaskExecutor")
|
||||
public void runImportAll(String taskId, byte[] bytes, String filename, boolean updateSupport, String operName,
|
||||
Date effectiveDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
put(taskId, BmsRedlineProductImportTask.STATUS_RUNNING, 5, "parsing excel", null);
|
||||
String message = productService.importProductExcel(bytes, filename, updateSupport, operName, taskId,
|
||||
effectiveDate);
|
||||
put(taskId, BmsRedlineProductImportTask.STATUS_SUCCESS, 100, message, null);
|
||||
log.info("async product import done, taskId={}", taskId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("async product import failed, taskId={}", taskId, e);
|
||||
put(taskId, BmsRedlineProductImportTask.STATUS_FAIL, 100, "failed", errorMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
/** Background single-country cost-sheet import. */
|
||||
@Async("threadPoolTaskExecutor")
|
||||
public void runImportCountry(String taskId, byte[] bytes, String filename, String countryCode, String operName,
|
||||
Date effectiveDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
put(taskId, BmsRedlineProductImportTask.STATUS_RUNNING, 5, "parsing excel", null);
|
||||
String message = productService.importCountryProductExcel(bytes, filename, countryCode, operName, taskId,
|
||||
effectiveDate);
|
||||
put(taskId, BmsRedlineProductImportTask.STATUS_SUCCESS, 100, message, null);
|
||||
log.info("async product country import done, taskId={}, country={}", taskId, countryCode);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("async product country import failed, taskId={}, country={}", taskId, countryCode, e);
|
||||
put(taskId, BmsRedlineProductImportTask.STATUS_FAIL, 100, "failed", errorMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
public void put(String taskId, String status, int percent, String message, String error)
|
||||
{
|
||||
BmsRedlineProductImportTask task = new BmsRedlineProductImportTask();
|
||||
task.setTaskId(taskId);
|
||||
task.setStatus(status);
|
||||
task.setPercent(percent);
|
||||
task.setMessage(message);
|
||||
task.setError(error);
|
||||
redisCache.setCacheObject(CACHE_KEY_PREFIX + taskId, task, TTL_MINUTES, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
public BmsRedlineProductImportTask get(String taskId)
|
||||
{
|
||||
return redisCache.getCacheObject(CACHE_KEY_PREFIX + taskId);
|
||||
}
|
||||
|
||||
private static String errorMessage(Exception e)
|
||||
{
|
||||
String msg = e.getMessage();
|
||||
if (StringUtils.isEmpty(msg))
|
||||
{
|
||||
msg = e.getClass().getSimpleName();
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="expireDate" column="expire_date" />
|
||||
<result property="status" column="status" />
|
||||
<result property="sourceSheet" column="source_sheet" />
|
||||
<result property="pefId" column="pef_id" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="tmsId" column="tms_id" />
|
||||
<result property="createBy" column="created_by" />
|
||||
@@ -30,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<sql id="selectBmsProductVo">
|
||||
select p.product_id, p.product_code, p.product_name, p.service_level, p.cargo_attr,
|
||||
p.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status,
|
||||
p.source_sheet, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time,
|
||||
p.source_sheet, p.pef_id, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time,
|
||||
(select count(distinct c.country_name) from product_country c
|
||||
where c.product_id = p.product_id
|
||||
or (c.product_id is null and c.product_code = p.product_code
|
||||
@@ -39,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
or c.effective_date = p.effective_date
|
||||
))
|
||||
) as country_count,
|
||||
(select count(*) from prc_surcharge_rel r where r.product_id = p.product_id) as surcharge_count
|
||||
(select count(*) from prc_surcharge_rel r where r.product_id = p.product_id and r.price_type = 'PRODUCT') as surcharge_count
|
||||
from product p
|
||||
</sql>
|
||||
|
||||
@@ -139,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="expireDate != null">expire_date,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="sourceSheet != null">source_sheet,</if>
|
||||
<if test="pefId != null">pef_id,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="tmsId != null">tms_id,</if>
|
||||
<if test="createBy != null and createBy != ''">created_by,</if>
|
||||
@@ -155,6 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="expireDate != null">#{expireDate},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="sourceSheet != null">#{sourceSheet},</if>
|
||||
<if test="pefId != null">#{pefId},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="tmsId != null">#{tmsId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
@@ -176,6 +179,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
expire_date = #{expireDate},
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="sourceSheet != null">source_sheet = #{sourceSheet},</if>
|
||||
<if test="pefId != null">pef_id = #{pefId},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="tmsId != null">tms_id = #{tmsId},</if>
|
||||
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
||||
|
||||
+312
@@ -0,0 +1,312 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.BmsRedlineProductCountryMapper">
|
||||
|
||||
<resultMap type="BmsRedlineProductCountry" id="BmsRedlineProductCountryResult">
|
||||
<id property="detailId" column="detail_id" />
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="productCode" column="product_code" />
|
||||
<result property="countryName" column="country_name" />
|
||||
<result property="countryCode" column="country_code" />
|
||||
<result property="zoneId" column="zone_id" />
|
||||
<result property="zoneCode" column="zone_code" />
|
||||
<result property="zoneName" column="zone_name" />
|
||||
<result property="weightMin" column="weight_min" />
|
||||
<result property="weightMax" column="weight_max" />
|
||||
<result property="freightPrice" column="freight_price" />
|
||||
<result property="registrationFee" column="registration_fee" />
|
||||
<result property="sizeLimit" column="size_limit" />
|
||||
<result property="lastMile" column="last_mile" />
|
||||
<result property="leadTime" column="lead_time" />
|
||||
<result property="effectiveDate" column="effective_date" />
|
||||
<result property="expireDate" column="expire_date" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="effectStatus" column="status" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectVo">
|
||||
select c.detail_id, c.product_id, c.product_code, c.country_name, c.country_code,
|
||||
c.zone_id, c.zone_code, c.zone_name,
|
||||
c.weight_min, c.weight_max,
|
||||
c.freight_price, c.registration_fee, c.size_limit, c.last_mile, c.lead_time,
|
||||
c.effective_date, c.expire_date, c.status, c.create_time, c.update_time
|
||||
from redline_product_country c
|
||||
</sql>
|
||||
|
||||
<select id="selectBmsRedlineProductCountryList" parameterType="BmsRedlineProductCountry" resultMap="BmsRedlineProductCountryResult">
|
||||
<include refid="selectVo"/>
|
||||
<where>
|
||||
<if test="productId != null">
|
||||
AND c.product_id = #{productId}
|
||||
</if>
|
||||
<if test="productCode != null and productCode != ''">
|
||||
AND c.product_code = #{productCode}
|
||||
</if>
|
||||
<if test="countryName != null and countryName != ''">
|
||||
AND c.country_name like concat('%', #{countryName}, '%')
|
||||
</if>
|
||||
<if test="countryCode != null and countryCode != ''">
|
||||
AND c.country_code = #{countryCode}
|
||||
</if>
|
||||
<if test="zoneId != null">
|
||||
AND c.zone_id = #{zoneId}
|
||||
</if>
|
||||
<if test="zoneCode != null and zoneCode != ''">
|
||||
AND c.zone_code = #{zoneCode}
|
||||
</if>
|
||||
<if test="weightMin != null">
|
||||
AND c.weight_min = #{weightMin}
|
||||
</if>
|
||||
<if test="weightMax != null">
|
||||
AND c.weight_max = #{weightMax}
|
||||
</if>
|
||||
<if test="effectiveDate != null">
|
||||
AND c.effective_date = #{effectiveDate}
|
||||
</if>
|
||||
<if test="openOnly != null and openOnly">
|
||||
AND c.expire_date is null
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND c.status = #{status}
|
||||
</if>
|
||||
<if test="effectStatus != null and effectStatus != ''">
|
||||
AND c.status = #{effectStatus}
|
||||
</if>
|
||||
</where>
|
||||
order by c.effective_date desc, c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc
|
||||
</select>
|
||||
|
||||
<insert id="insertBmsRedlineProductCountry" parameterType="BmsRedlineProductCountry" useGeneratedKeys="true" keyProperty="detailId">
|
||||
insert into redline_product_country (
|
||||
product_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
|
||||
weight_min, weight_max,
|
||||
freight_price, registration_fee, size_limit, last_mile, lead_time,
|
||||
effective_date, expire_date, status, create_time
|
||||
) values (
|
||||
#{productId}, #{productCode}, #{countryName}, #{countryCode}, #{zoneId}, #{zoneCode}, #{zoneName},
|
||||
#{weightMin}, #{weightMax},
|
||||
#{freightPrice}, #{registrationFee}, #{sizeLimit}, #{lastMile}, #{leadTime},
|
||||
#{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- Detail edit dialog: frontend submits full editable fields;
|
||||
weight_max / expire_date may be null (= open-ended) -->
|
||||
<update id="updateBmsRedlineProductCountry" parameterType="BmsRedlineProductCountry">
|
||||
update redline_product_country
|
||||
set weight_min = #{weightMin},
|
||||
weight_max = #{weightMax},
|
||||
freight_price = #{freightPrice},
|
||||
registration_fee = #{registrationFee},
|
||||
size_limit = #{sizeLimit},
|
||||
last_mile = #{lastMile},
|
||||
lead_time = #{leadTime},
|
||||
effective_date = #{effectiveDate},
|
||||
expire_date = #{expireDate},
|
||||
update_time = sysdate()
|
||||
where detail_id = #{detailId}
|
||||
</update>
|
||||
|
||||
<update id="updateBmsRedlineProductCountryImport" parameterType="BmsRedlineProductCountry">
|
||||
update redline_product_country
|
||||
set product_id = #{productId},
|
||||
country_code = #{countryCode},
|
||||
zone_id = #{zoneId},
|
||||
zone_code = #{zoneCode},
|
||||
zone_name = #{zoneName},
|
||||
weight_min = #{weightMin},
|
||||
weight_max = #{weightMax},
|
||||
freight_price = #{freightPrice},
|
||||
registration_fee = #{registrationFee},
|
||||
size_limit = #{sizeLimit},
|
||||
last_mile = #{lastMile},
|
||||
lead_time = #{leadTime},
|
||||
effective_date = #{effectiveDate},
|
||||
expire_date = #{expireDate},
|
||||
status = IFNULL(#{status}, status),
|
||||
update_time = sysdate()
|
||||
where detail_id = #{detailId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductId" parameterType="Long">
|
||||
delete from redline_product_country where product_id = #{productId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByProductCode" parameterType="String">
|
||||
delete from redline_product_country where product_code = #{productCode}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByProductCodes">
|
||||
delete from redline_product_country where product_code in
|
||||
<foreach item="code" collection="array" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByProductCodeAndEffectiveDate">
|
||||
delete from redline_product_country
|
||||
where product_code = #{productCode}
|
||||
and (
|
||||
(#{effectiveDate} is null and effective_date is null)
|
||||
or effective_date = #{effectiveDate}
|
||||
)
|
||||
</delete>
|
||||
|
||||
<select id="selectMaxOpenEffectiveDate" resultType="java.util.Date">
|
||||
select max(effective_date) from redline_product_country
|
||||
where product_code = #{productCode}
|
||||
and expire_date is null
|
||||
</select>
|
||||
|
||||
<update id="expireOpenByProductCode">
|
||||
update redline_product_country
|
||||
set expire_date = #{newEffectiveDate},
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{newEffectiveDate})
|
||||
</update>
|
||||
|
||||
<update id="expireOpenByProductCodeAndCountry">
|
||||
update redline_product_country
|
||||
set expire_date = #{newEffectiveDate},
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{newEffectiveDate})
|
||||
<choose>
|
||||
<when test="countryCode != null and countryCode != ''">
|
||||
and upper(ifnull(country_code,'')) = upper(#{countryCode})
|
||||
</when>
|
||||
<otherwise>
|
||||
and country_name = #{countryName}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</update>
|
||||
|
||||
<update id="refreshStatusByDates">
|
||||
update redline_product_country
|
||||
set status = case
|
||||
when expire_date is not null and expire_date <= now() then '2'
|
||||
when effective_date is null or effective_date > now() then '0'
|
||||
else '1'
|
||||
end
|
||||
</update>
|
||||
|
||||
<delete id="deleteOpenByProductCodeAndEffectiveDate">
|
||||
delete from redline_product_country
|
||||
where product_code = #{productCode}
|
||||
and expire_date is null
|
||||
and (
|
||||
(#{effectiveDate} is null and effective_date is null)
|
||||
or effective_date = #{effectiveDate}
|
||||
)
|
||||
</delete>
|
||||
|
||||
<delete id="deleteOpenByProductCodeAndCountryOnDate">
|
||||
delete from redline_product_country
|
||||
where product_code = #{productCode}
|
||||
and expire_date is null
|
||||
and (
|
||||
(#{effectiveDate} is null and effective_date is null)
|
||||
or effective_date = #{effectiveDate}
|
||||
)
|
||||
<choose>
|
||||
<when test="countryCode != null and countryCode != ''">
|
||||
and upper(ifnull(country_code,'')) = upper(#{countryCode})
|
||||
</when>
|
||||
<otherwise>
|
||||
and country_name = #{countryName}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</delete>
|
||||
|
||||
<select id="selectMatchByProductCountryWeight" resultMap="BmsRedlineProductCountryResult">
|
||||
<include refid="selectVo"/>
|
||||
where c.product_code = #{productCode}
|
||||
and c.weight_min <= #{weight}
|
||||
and c.weight_max >= #{weight}
|
||||
<choose>
|
||||
<when test="countryCode != null and countryCode != ''">
|
||||
and upper(c.country_code) = upper(#{countryCode})
|
||||
</when>
|
||||
<when test="countryName != null and countryName != ''">
|
||||
and c.country_name = #{countryName}
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1 = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
<choose>
|
||||
<when test="zoneCode != null and zoneCode != ''">
|
||||
and upper(ifnull(c.zone_code,'')) = upper(#{zoneCode})
|
||||
</when>
|
||||
<otherwise>
|
||||
and (c.zone_code is null or c.zone_code = '')
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="bizDate != null">
|
||||
and (c.effective_date is null or c.effective_date <= #{bizDate})
|
||||
and (c.expire_date is null or c.expire_date > #{bizDate})
|
||||
</if>
|
||||
<if test="bizDate == null">
|
||||
and c.expire_date is null
|
||||
</if>
|
||||
order by c.effective_date desc, c.weight_min asc, c.detail_id asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="countZonedByProductCountry" resultType="int">
|
||||
select count(1)
|
||||
from redline_product_country
|
||||
where product_code = #{productCode}
|
||||
and zone_code is not null and zone_code <> ''
|
||||
<choose>
|
||||
<when test="countryCode != null and countryCode != ''">
|
||||
and upper(country_code) = upper(#{countryCode})
|
||||
</when>
|
||||
<when test="countryName != null and countryName != ''">
|
||||
and country_name = #{countryName}
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1 = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="bizDate != null">
|
||||
and (effective_date is null or effective_date <= #{bizDate})
|
||||
and (expire_date is null or expire_date > #{bizDate})
|
||||
</if>
|
||||
<if test="bizDate == null">
|
||||
and expire_date is null
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectOpenByProductCode" resultMap="BmsRedlineProductCountryResult">
|
||||
<include refid="selectVo"/>
|
||||
where c.product_code = #{productCode}
|
||||
and c.expire_date is null
|
||||
order by c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc
|
||||
</select>
|
||||
|
||||
<insert id="copyOpenCountries">
|
||||
insert into redline_product_country (
|
||||
product_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
|
||||
weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time,
|
||||
effective_date, expire_date, status, create_time
|
||||
)
|
||||
select
|
||||
#{productId}, product_code, country_name, country_code, zone_id, zone_code, zone_name,
|
||||
weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time,
|
||||
#{effectiveDate}, null, IFNULL(#{status}, '0'), sysdate()
|
||||
from redline_product_country
|
||||
where product_code = #{productCode}
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{effectiveDate})
|
||||
order by detail_id asc
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,219 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.BmsRedlineProductMapper">
|
||||
|
||||
<resultMap type="BmsRedlineProduct" id="BmsRedlineProductResult">
|
||||
<id property="productId" column="product_id" />
|
||||
<result property="productCode" column="product_code" />
|
||||
<result property="productName" column="product_name" />
|
||||
<result property="serviceLevel" column="service_level" />
|
||||
<result property="cargoAttr" column="cargo_attr" />
|
||||
<result property="destRegion" column="dest_region" />
|
||||
<result property="updateNote" column="update_note" />
|
||||
<result property="taxMode" column="tax_mode" />
|
||||
<result property="effectiveDate" column="effective_date" />
|
||||
<result property="expireDate" column="expire_date" />
|
||||
<result property="status" column="status" />
|
||||
<result property="sourceSheet" column="source_sheet" />
|
||||
<result property="pefId" column="pef_id" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="tmsId" column="tms_id" />
|
||||
<result property="createBy" column="created_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="updated_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="countryCount" column="country_count" />
|
||||
<result property="surchargeCount" column="surcharge_count" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectBmsRedlineProductVo">
|
||||
select p.product_id, p.product_code, p.product_name, p.service_level, p.cargo_attr,
|
||||
p.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status,
|
||||
p.source_sheet, p.pef_id, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time,
|
||||
(select count(distinct c.country_name) from redline_product_country c
|
||||
where c.product_id = p.product_id
|
||||
or (c.product_id is null and c.product_code = p.product_code
|
||||
and (
|
||||
(p.effective_date is null and c.effective_date is null)
|
||||
or c.effective_date = p.effective_date
|
||||
))
|
||||
) as country_count,
|
||||
(select count(*) from prc_surcharge_rel r where r.product_id = p.product_id and r.price_type = 'REDLINE') as surcharge_count
|
||||
from redline_product p
|
||||
</sql>
|
||||
|
||||
<select id="selectBmsRedlineProductById" parameterType="Long" resultMap="BmsRedlineProductResult">
|
||||
<include refid="selectBmsRedlineProductVo"/>
|
||||
where p.product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<select id="selectBmsRedlineProductByCode" parameterType="String" resultMap="BmsRedlineProductResult">
|
||||
<include refid="selectBmsRedlineProductVo"/>
|
||||
where p.product_code = #{productCode}
|
||||
order by p.effective_date desc, p.product_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectBmsRedlineProductByCodeAndDate" resultMap="BmsRedlineProductResult">
|
||||
<include refid="selectBmsRedlineProductVo"/>
|
||||
where p.product_code = #{productCode}
|
||||
<choose>
|
||||
<when test="effectiveDate != null">
|
||||
AND p.effective_date = #{effectiveDate}
|
||||
</when>
|
||||
<otherwise>
|
||||
AND p.effective_date is null
|
||||
</otherwise>
|
||||
</choose>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectEffectiveBmsRedlineProductByCode" resultMap="BmsRedlineProductResult">
|
||||
<include refid="selectBmsRedlineProductVo"/>
|
||||
where p.product_code = #{productCode}
|
||||
and (p.effective_date is null or #{bizDate} is null or p.effective_date <= #{bizDate})
|
||||
and (p.expire_date is null or #{bizDate} is null or p.expire_date > #{bizDate})
|
||||
order by p.effective_date desc, p.product_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectBmsRedlineProductList" parameterType="BmsRedlineProduct" resultMap="BmsRedlineProductResult">
|
||||
<include refid="selectBmsRedlineProductVo"/>
|
||||
<where>
|
||||
<if test="productCode != null and productCode != ''">
|
||||
AND p.product_code like concat('%', #{productCode}, '%')
|
||||
</if>
|
||||
<if test="productName != null and productName != ''">
|
||||
AND p.product_name like concat('%', #{productName}, '%')
|
||||
</if>
|
||||
<if test="taxMode != null and taxMode != ''">
|
||||
AND p.tax_mode = #{taxMode}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND p.status = #{status}
|
||||
</if>
|
||||
<if test="effectStatus != null and effectStatus != ''">
|
||||
AND p.status = #{effectStatus}
|
||||
</if>
|
||||
<if test="statusGroup != null and statusGroup == 'active'">
|
||||
AND p.status in ('0', '1')
|
||||
</if>
|
||||
<if test="statusGroup != null and statusGroup == 'expired'">
|
||||
AND p.status = '2'
|
||||
<if test="params != null and params.beginTime != null and params.beginTime != ''">
|
||||
AND p.expire_date >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params != null and params.endTime != null and params.endTime != ''">
|
||||
AND p.expire_date <= #{params.endTime}
|
||||
</if>
|
||||
</if>
|
||||
<if test="cargoAttr != null and cargoAttr != ''">
|
||||
AND p.cargo_attr like concat('%', #{cargoAttr}, '%')
|
||||
</if>
|
||||
<if test="params != null and params.keyword != null and params.keyword != ''">
|
||||
AND (p.product_code like concat('%', #{params.keyword}, '%')
|
||||
OR p.product_name like concat('%', #{params.keyword}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
<choose>
|
||||
<when test="statusGroup != null and statusGroup == 'expired'">
|
||||
order by p.expire_date desc, p.product_code asc, p.product_id desc
|
||||
</when>
|
||||
<otherwise>
|
||||
order by p.product_code asc, p.effective_date desc, p.product_id desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<insert id="insertBmsRedlineProduct" parameterType="BmsRedlineProduct" useGeneratedKeys="true" keyProperty="productId">
|
||||
insert into redline_product (
|
||||
<if test="productCode != null and productCode != ''">product_code,</if>
|
||||
<if test="productName != null and productName != ''">product_name,</if>
|
||||
<if test="serviceLevel != null">service_level,</if>
|
||||
<if test="cargoAttr != null">cargo_attr,</if>
|
||||
<if test="destRegion != null">dest_region,</if>
|
||||
<if test="updateNote != null">update_note,</if>
|
||||
<if test="taxMode != null and taxMode != ''">tax_mode,</if>
|
||||
<if test="effectiveDate != null">effective_date,</if>
|
||||
<if test="expireDate != null">expire_date,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="sourceSheet != null">source_sheet,</if>
|
||||
<if test="pefId != null">pef_id,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="tmsId != null">tms_id,</if>
|
||||
<if test="createBy != null and createBy != ''">created_by,</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="productCode != null and productCode != ''">#{productCode},</if>
|
||||
<if test="productName != null and productName != ''">#{productName},</if>
|
||||
<if test="serviceLevel != null">#{serviceLevel},</if>
|
||||
<if test="cargoAttr != null">#{cargoAttr},</if>
|
||||
<if test="destRegion != null">#{destRegion},</if>
|
||||
<if test="updateNote != null">#{updateNote},</if>
|
||||
<if test="taxMode != null and taxMode != ''">#{taxMode},</if>
|
||||
<if test="effectiveDate != null">#{effectiveDate},</if>
|
||||
<if test="expireDate != null">#{expireDate},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="sourceSheet != null">#{sourceSheet},</if>
|
||||
<if test="pefId != null">#{pefId},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="tmsId != null">#{tmsId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateBmsRedlineProduct" parameterType="BmsRedlineProduct">
|
||||
update product
|
||||
<set>
|
||||
<if test="productCode != null and productCode != ''">product_code = #{productCode},</if>
|
||||
<if test="productName != null and productName != ''">product_name = #{productName},</if>
|
||||
<if test="serviceLevel != null">service_level = #{serviceLevel},</if>
|
||||
<if test="cargoAttr != null">cargo_attr = #{cargoAttr},</if>
|
||||
<if test="destRegion != null">dest_region = #{destRegion},</if>
|
||||
<if test="updateNote != null">update_note = #{updateNote},</if>
|
||||
<if test="taxMode != null and taxMode != ''">tax_mode = #{taxMode},</if>
|
||||
<if test="effectiveDate != null">effective_date = #{effectiveDate},</if>
|
||||
expire_date = #{expireDate},
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="sourceSheet != null">source_sheet = #{sourceSheet},</if>
|
||||
<if test="pefId != null">pef_id = #{pefId},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="tmsId != null">tms_id = #{tmsId},</if>
|
||||
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where product_id = #{productId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBmsRedlineProductByIds" parameterType="Long">
|
||||
delete from redline_product where product_id in
|
||||
<foreach item="productId" collection="array" open="(" separator="," close=")">
|
||||
#{productId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="expireOpenByProductCode">
|
||||
update product
|
||||
set expire_date = #{newEffectiveDate},
|
||||
update_time = sysdate()
|
||||
where product_code = #{productCode}
|
||||
and expire_date is null
|
||||
and (effective_date is null or effective_date < #{newEffectiveDate})
|
||||
<if test="excludeId != null">
|
||||
and product_id <> #{excludeId}
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<update id="refreshStatusByDates">
|
||||
update product
|
||||
set status = case
|
||||
when expire_date is not null and expire_date <= now() then '2'
|
||||
when effective_date is null or effective_date > now() then '0'
|
||||
else '1'
|
||||
end
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -180,4 +180,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<delete id="deleteByBillId" parameterType="String">
|
||||
delete from prc_income_bill_fee where bill_id = #{billId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAutoFeesByBillId" parameterType="String">
|
||||
delete from prc_income_bill_fee
|
||||
where bill_id = #{billId}
|
||||
and (manual_flag is null or manual_flag <> '1')
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PrcPriceExcelFileMapper">
|
||||
|
||||
<resultMap type="PrcPriceExcelFile" id="PrcPriceExcelFileResult">
|
||||
<id property="pefId" column="pef_id" />
|
||||
<result property="excelType" column="excel_type" />
|
||||
<result property="effectiveTime" column="effective_time" />
|
||||
<result property="fileName" column="file_name" />
|
||||
<result property="filePath" column="file_path" />
|
||||
<result property="fileSize" column="file_size" />
|
||||
<result property="contentType" column="content_type" />
|
||||
<result property="fileExtension" column="file_extension" />
|
||||
<result property="ossId" column="oss_id" />
|
||||
<result property="sheetNames" column="sheet_names" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="created_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="updated_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcPriceExcelFileVo">
|
||||
select pef_id, excel_type, effective_time, file_name, file_path, file_size, content_type,
|
||||
file_extension, oss_id, sheet_names, remark, created_by, create_time, updated_by, update_time
|
||||
from prc_price_excel_file
|
||||
</sql>
|
||||
|
||||
<select id="selectPrcPriceExcelFileById" parameterType="Long" resultMap="PrcPriceExcelFileResult">
|
||||
<include refid="selectPrcPriceExcelFileVo"/>
|
||||
where pef_id = #{pefId}
|
||||
</select>
|
||||
|
||||
<select id="selectPrcPriceExcelFileList" parameterType="PrcPriceExcelFile" resultMap="PrcPriceExcelFileResult">
|
||||
<include refid="selectPrcPriceExcelFileVo"/>
|
||||
<where>
|
||||
<if test="excelType != null and excelType != ''">
|
||||
AND excel_type = #{excelType}
|
||||
</if>
|
||||
<if test="fileName != null and fileName != ''">
|
||||
AND file_name like concat('%', #{fileName}, '%')
|
||||
</if>
|
||||
</where>
|
||||
order by pef_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectByProductCode" resultMap="PrcPriceExcelFileResult">
|
||||
select distinct f.pef_id, f.excel_type, f.effective_time, f.file_name, f.file_path, f.file_size,
|
||||
f.content_type, f.file_extension, f.oss_id, f.sheet_names, f.remark,
|
||||
f.created_by, f.create_time, f.updated_by, f.update_time
|
||||
from prc_price_excel_file f
|
||||
inner join product p on p.pef_id = f.pef_id
|
||||
where p.product_code = #{productCode}
|
||||
and p.pef_id is not null
|
||||
order by f.effective_time desc, f.pef_id desc
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcPriceExcelFile" parameterType="PrcPriceExcelFile" useGeneratedKeys="true" keyProperty="pefId">
|
||||
insert into prc_price_excel_file (
|
||||
<if test="excelType != null and excelType != ''">excel_type,</if>
|
||||
<if test="effectiveTime != null">effective_time,</if>
|
||||
<if test="fileName != null and fileName != ''">file_name,</if>
|
||||
<if test="filePath != null and filePath != ''">file_path,</if>
|
||||
<if test="fileSize != null">file_size,</if>
|
||||
<if test="contentType != null">content_type,</if>
|
||||
<if test="fileExtension != null">file_extension,</if>
|
||||
<if test="ossId != null">oss_id,</if>
|
||||
<if test="sheetNames != null">sheet_names,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">created_by,</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="excelType != null and excelType != ''">#{excelType},</if>
|
||||
<if test="effectiveTime != null">#{effectiveTime},</if>
|
||||
<if test="fileName != null and fileName != ''">#{fileName},</if>
|
||||
<if test="filePath != null and filePath != ''">#{filePath},</if>
|
||||
<if test="fileSize != null">#{fileSize},</if>
|
||||
<if test="contentType != null">#{contentType},</if>
|
||||
<if test="fileExtension != null">#{fileExtension},</if>
|
||||
<if test="ossId != null">#{ossId},</if>
|
||||
<if test="sheetNames != null">#{sheetNames},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updatePrcPriceExcelFile" parameterType="PrcPriceExcelFile">
|
||||
update prc_price_excel_file
|
||||
<set>
|
||||
<if test="excelType != null and excelType != ''">excel_type = #{excelType},</if>
|
||||
<if test="effectiveTime != null">effective_time = #{effectiveTime},</if>
|
||||
<if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
|
||||
<if test="filePath != null and filePath != ''">file_path = #{filePath},</if>
|
||||
<if test="fileSize != null">file_size = #{fileSize},</if>
|
||||
<if test="contentType != null">content_type = #{contentType},</if>
|
||||
<if test="fileExtension != null">file_extension = #{fileExtension},</if>
|
||||
<if test="ossId != null">oss_id = #{ossId},</if>
|
||||
<if test="sheetNames != null">sheet_names = #{sheetNames},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where pef_id = #{pefId}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrcPriceExcelFileByIds" parameterType="Long">
|
||||
delete from prc_price_excel_file where pef_id in
|
||||
<foreach item="pefId" collection="array" open="(" separator="," close=")">
|
||||
#{pefId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="selectByRedlineProductCode" resultMap="PrcPriceExcelFileResult">
|
||||
select distinct f.pef_id, f.excel_type, f.effective_time, f.file_name, f.file_path, f.file_size,
|
||||
f.content_type, f.file_extension, f.oss_id, f.sheet_names, f.remark,
|
||||
f.created_by, f.create_time, f.updated_by, f.update_time
|
||||
from prc_price_excel_file f
|
||||
inner join redline_product p on p.pef_id = f.pef_id
|
||||
where p.product_code = #{productCode}
|
||||
and p.pef_id is not null
|
||||
order by f.effective_time desc, f.pef_id desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -17,13 +17,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="taxMode" column="tax_mode" />
|
||||
<result property="sourceProductId" column="source_product_id" />
|
||||
<result property="sourceSheet" column="source_sheet" />
|
||||
<result property="pefId" column="pef_id" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectVo">
|
||||
select psp_id, price_set_id, psv_id, product_code, product_name, service_level, cargo_attr,
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, create_time, update_time
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, pef_id,
|
||||
create_time, update_time
|
||||
from prc_price_set_product
|
||||
</sql>
|
||||
|
||||
@@ -52,10 +54,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<insert id="insertPrcPriceSetProduct" parameterType="PrcPriceSetProduct" useGeneratedKeys="true" keyProperty="pspId">
|
||||
insert into prc_price_set_product (
|
||||
price_set_id, psv_id, product_code, product_name, service_level, cargo_attr,
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, create_time
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, pef_id, create_time
|
||||
) values (
|
||||
#{priceSetId}, #{psvId}, #{productCode}, #{productName}, #{serviceLevel}, #{cargoAttr},
|
||||
#{destRegion}, #{updateNote}, #{taxMode}, #{sourceProductId}, #{sourceSheet}, sysdate()
|
||||
#{destRegion}, #{updateNote}, #{taxMode}, #{sourceProductId}, #{sourceSheet}, #{pefId}, sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -70,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="taxMode != null and taxMode != ''">tax_mode = #{taxMode},</if>
|
||||
<if test="sourceProductId != null">source_product_id = #{sourceProductId},</if>
|
||||
<if test="sourceSheet != null">source_sheet = #{sourceSheet},</if>
|
||||
<if test="pefId != null">pef_id = #{pefId},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where psp_id = #{pspId}
|
||||
@@ -88,11 +91,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<insert id="copyFromVersion">
|
||||
insert into prc_price_set_product (
|
||||
price_set_id, psv_id, product_code, product_name, service_level, cargo_attr,
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, create_time
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, pef_id, create_time
|
||||
)
|
||||
select
|
||||
price_set_id, #{newPsvId}, product_code, product_name, service_level, cargo_attr,
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, sysdate()
|
||||
dest_region, update_note, tax_mode, source_product_id, source_sheet, pef_id, sysdate()
|
||||
from prc_price_set_product
|
||||
where psv_id = #{srcPsvId}
|
||||
order by psp_id asc
|
||||
@@ -159,4 +162,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and (d.psp_id is null or d.psp_id <> sp.psp_id)
|
||||
</update>
|
||||
|
||||
<update id="updatePefIdByPsvId">
|
||||
update prc_price_set_product
|
||||
set pef_id = #{pefId}, update_time = sysdate()
|
||||
where psv_id = #{psvId}
|
||||
<if test="productCodes != null and productCodes.size() > 0">
|
||||
and product_code in
|
||||
<foreach item="code" collection="productCodes" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
-208
@@ -1,208 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PrcPriceSetVersionSurchargeMapper">
|
||||
|
||||
<resultMap type="PrcPriceSetVersionSurcharge" id="PrcPriceSetVersionSurchargeResult">
|
||||
<id property="psvsId" column="psvs_id" />
|
||||
<result property="psvId" column="psv_id" />
|
||||
<result property="scId" column="sc_id" />
|
||||
<result property="productCode" column="product_code" />
|
||||
<result property="psdId" column="psd_id" />
|
||||
<result property="scName" column="sc_name" />
|
||||
<result property="feeType" column="fee_type" />
|
||||
<result property="chargeType" column="charge_type" />
|
||||
<result property="chargeValue" column="charge_value" />
|
||||
<result property="currency" column="currency" />
|
||||
<result property="roundMode" column="round_mode" />
|
||||
<result property="countryCode" column="country_code" />
|
||||
<result property="scNote" column="sc_note" />
|
||||
<result property="createBy" column="created_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="updated_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcPriceSetVersionSurchargeVo">
|
||||
select psvs_id, psv_id, sc_id, product_code, psd_id, sc_name, fee_type, charge_type,
|
||||
charge_value, currency, round_mode, country_code, sc_note,
|
||||
created_by, create_time, updated_by, update_time
|
||||
from prc_price_set_version_surcharge
|
||||
</sql>
|
||||
|
||||
<select id="selectPrcPriceSetVersionSurchargeById" parameterType="Long" resultMap="PrcPriceSetVersionSurchargeResult">
|
||||
<include refid="selectPrcPriceSetVersionSurchargeVo"/>
|
||||
where psvs_id = #{psvsId}
|
||||
</select>
|
||||
|
||||
<select id="selectPrcPriceSetVersionSurchargeList" parameterType="PrcPriceSetVersionSurcharge" resultMap="PrcPriceSetVersionSurchargeResult">
|
||||
<include refid="selectPrcPriceSetVersionSurchargeVo"/>
|
||||
<where>
|
||||
<if test="psvId != null">
|
||||
AND psv_id = #{psvId}
|
||||
</if>
|
||||
<if test="scId != null">
|
||||
AND sc_id = #{scId}
|
||||
</if>
|
||||
<if test="productCode != null and productCode != ''">
|
||||
AND product_code = #{productCode}
|
||||
</if>
|
||||
<if test="psdId != null">
|
||||
AND psd_id = #{psdId}
|
||||
</if>
|
||||
</where>
|
||||
order by psvs_id asc
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcPriceSetVersionSurcharge" parameterType="PrcPriceSetVersionSurcharge" useGeneratedKeys="true" keyProperty="psvsId">
|
||||
insert into prc_price_set_version_surcharge (
|
||||
<if test="psvId != null">psv_id,</if>
|
||||
<if test="psdId != null">psd_id,</if>
|
||||
<if test="scId != null">sc_id,</if>
|
||||
<if test="productCode != null">product_code,</if>
|
||||
<if test="scName != null and scName != ''">sc_name,</if>
|
||||
<if test="feeType != null and feeType != ''">fee_type,</if>
|
||||
<if test="chargeType != null and chargeType != ''">charge_type,</if>
|
||||
<if test="chargeValue != null">charge_value,</if>
|
||||
<if test="currency != null and currency != ''">currency,</if>
|
||||
<if test="roundMode != null and roundMode != ''">round_mode,</if>
|
||||
<if test="countryCode != null">country_code,</if>
|
||||
<if test="scNote != null">sc_note,</if>
|
||||
<if test="createBy != null and createBy != ''">created_by,</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="psvId != null">#{psvId},</if>
|
||||
<if test="psdId != null">#{psdId},</if>
|
||||
<if test="scId != null">#{scId},</if>
|
||||
<if test="productCode != null">#{productCode},</if>
|
||||
<if test="scName != null and scName != ''">#{scName},</if>
|
||||
<if test="feeType != null and feeType != ''">#{feeType},</if>
|
||||
<if test="chargeType != null and chargeType != ''">#{chargeType},</if>
|
||||
<if test="chargeValue != null">#{chargeValue},</if>
|
||||
<if test="currency != null and currency != ''">#{currency},</if>
|
||||
<if test="roundMode != null and roundMode != ''">#{roundMode},</if>
|
||||
<if test="countryCode != null">#{countryCode},</if>
|
||||
<if test="scNote != null">#{scNote},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updatePrcPriceSetVersionSurcharge" parameterType="PrcPriceSetVersionSurcharge">
|
||||
update prc_price_set_version_surcharge
|
||||
<set>
|
||||
<if test="psdId != null">psd_id = #{psdId},</if>
|
||||
<if test="scId != null">sc_id = #{scId},</if>
|
||||
product_code = #{productCode},
|
||||
<if test="scName != null and scName != ''">sc_name = #{scName},</if>
|
||||
<if test="feeType != null and feeType != ''">fee_type = #{feeType},</if>
|
||||
<if test="chargeType != null and chargeType != ''">charge_type = #{chargeType},</if>
|
||||
<if test="chargeValue != null">charge_value = #{chargeValue},</if>
|
||||
<if test="currency != null and currency != ''">currency = #{currency},</if>
|
||||
<if test="roundMode != null and roundMode != ''">round_mode = #{roundMode},</if>
|
||||
country_code = #{countryCode},
|
||||
sc_note = #{scNote},
|
||||
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where psvs_id = #{psvsId}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrcPriceSetVersionSurchargeByIds" parameterType="Long">
|
||||
delete from prc_price_set_version_surcharge where psvs_id in
|
||||
<foreach item="psvsId" collection="array" open="(" separator="," close=")">
|
||||
#{psvsId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByPsvId" parameterType="Long">
|
||||
delete from prc_price_set_version_surcharge where psv_id = #{psvId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByPsdId" parameterType="Long">
|
||||
delete from prc_price_set_version_surcharge where psd_id = #{psdId}
|
||||
</delete>
|
||||
|
||||
<select id="selectByPsdIds" resultMap="PrcPriceSetVersionSurchargeResult">
|
||||
<include refid="selectPrcPriceSetVersionSurchargeVo"/>
|
||||
where psd_id in
|
||||
<foreach item="id" collection="psdIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
order by psvs_id asc
|
||||
</select>
|
||||
|
||||
<!-- Join detail x surcharge_rel x surcharge; skip OF fuel; product-level or same detail_id -->
|
||||
<insert id="insertFromLibraryRels">
|
||||
insert into prc_price_set_version_surcharge (
|
||||
psv_id, psd_id, sc_id, product_code, sc_name, fee_type, charge_type,
|
||||
charge_value, currency, round_mode, country_code, sc_note,
|
||||
created_by, create_time
|
||||
)
|
||||
select
|
||||
d.psv_id,
|
||||
d.psd_id,
|
||||
r.sc_id,
|
||||
d.product_code,
|
||||
s.sc_name,
|
||||
ifnull(nullif(s.fee_type, ''), 'SURCHARGE'),
|
||||
ifnull(nullif(s.charge_type, ''), 'FIXED'),
|
||||
s.charge_value,
|
||||
ifnull(nullif(s.currency, ''), 'CNY'),
|
||||
ifnull(nullif(s.round_mode, ''), 'HALF_UP'),
|
||||
s.country_code,
|
||||
s.sc_note,
|
||||
#{createBy},
|
||||
sysdate()
|
||||
from prc_price_set_detail d
|
||||
inner join prc_surcharge_rel r on r.product_code = d.product_code
|
||||
inner join prc_surcharge s on s.sc_id = r.sc_id
|
||||
where d.psv_id = #{psvId}
|
||||
and ifnull(s.sc_name, '') <> ''
|
||||
and s.charge_value is not null
|
||||
and lower(ifnull(s.ss_code, '')) not in ('of', 'vd')
|
||||
and (r.detail_id is null or r.detail_id = d.product_country_id)
|
||||
and (
|
||||
s.country_code is null or s.country_code = ''
|
||||
or d.country_code is null or d.country_code = ''
|
||||
or upper(s.country_code) = upper(d.country_code)
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="copySurchargesFromVersion">
|
||||
insert into prc_price_set_version_surcharge (
|
||||
psv_id, psd_id, sc_id, product_code, sc_name, fee_type, charge_type,
|
||||
charge_value, currency, round_mode, country_code, sc_note,
|
||||
created_by, create_time
|
||||
)
|
||||
select
|
||||
#{newPsvId},
|
||||
nd.psd_id,
|
||||
sc.sc_id,
|
||||
sc.product_code,
|
||||
sc.sc_name,
|
||||
sc.fee_type,
|
||||
sc.charge_type,
|
||||
sc.charge_value,
|
||||
sc.currency,
|
||||
sc.round_mode,
|
||||
sc.country_code,
|
||||
sc.sc_note,
|
||||
#{createBy},
|
||||
sysdate()
|
||||
from prc_price_set_version_surcharge sc
|
||||
inner join prc_price_set_detail od
|
||||
on od.psd_id = sc.psd_id and od.psv_id = #{srcPsvId}
|
||||
inner join prc_price_set_detail nd
|
||||
on nd.psv_id = #{newPsvId}
|
||||
and nd.product_code = od.product_code
|
||||
and ifnull(nd.country_code, '') = ifnull(od.country_code, '')
|
||||
and ifnull(nd.zone_code, '') = ifnull(od.zone_code, '')
|
||||
and ifnull(nd.weight_label, '') = ifnull(od.weight_label, '')
|
||||
and ifnull(nd.product_country_id, 0) = ifnull(od.product_country_id, 0)
|
||||
and ifnull(nd.discount_value, -1) = ifnull(od.discount_value, -1)
|
||||
where sc.psv_id = #{srcPsvId}
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -10,6 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="productCode" column="product_code" />
|
||||
<result property="detailId" column="detail_id" />
|
||||
<result property="priceType" column="price_type" />
|
||||
<result property="countryCode" column="country_code" />
|
||||
<result property="scName" column="sc_name" />
|
||||
<result property="feeType" column="fee_type" />
|
||||
<result property="chargeType" column="charge_type" />
|
||||
@@ -17,7 +19,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="currency" column="currency" />
|
||||
<result property="roundMode" column="round_mode" />
|
||||
<result property="ssCode" column="ss_code" />
|
||||
<result property="countryCode" column="country_code" />
|
||||
<result property="scNote" column="sc_note" />
|
||||
<result property="countryName" column="country_name" />
|
||||
<result property="weightMin" column="weight_min" />
|
||||
@@ -30,13 +31,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectPrcSurchargeRelVo">
|
||||
select r.rel_id, r.sc_id, r.product_id, r.product_code, r.detail_id,
|
||||
r.price_type, r.country_code,
|
||||
r.created_by, r.create_time, r.updated_by, r.update_time,
|
||||
s.sc_name, s.fee_type, s.charge_type, s.charge_value, s.currency,
|
||||
s.round_mode, s.ss_code, s.country_code, s.sc_note,
|
||||
c.country_name, c.weight_min, c.weight_max
|
||||
s.round_mode, s.ss_code, s.sc_note,
|
||||
ifnull(c.country_name, rc.country_name) as country_name, ifnull(c.weight_min, rc.weight_min) as weight_min, ifnull(c.weight_max, rc.weight_max) as weight_max
|
||||
from prc_surcharge_rel r
|
||||
join prc_surcharge s on s.sc_id = r.sc_id
|
||||
left join product_country c on c.detail_id = r.detail_id
|
||||
left join product_country c on c.detail_id = r.detail_id and r.price_type = 'PRODUCT'
|
||||
left join redline_product_country rc on rc.detail_id = r.detail_id and r.price_type = 'REDLINE'
|
||||
</sql>
|
||||
|
||||
<select id="selectPrcSurchargeRelList" parameterType="PrcSurchargeRel" resultMap="PrcSurchargeRelResult">
|
||||
@@ -51,17 +54,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="scId != null">
|
||||
AND r.sc_id = #{scId}
|
||||
</if>
|
||||
<if test="detailId != null">
|
||||
AND r.detail_id = #{detailId}
|
||||
</if>
|
||||
<if test="priceType != null and priceType != ''">
|
||||
AND r.price_type = #{priceType}
|
||||
</if>
|
||||
<if test="countryCode != null and countryCode != ''">
|
||||
AND r.country_code = #{countryCode}
|
||||
</if>
|
||||
</where>
|
||||
order by r.detail_id is not null, r.rel_id asc
|
||||
</select>
|
||||
|
||||
<select id="selectByDetailIdsAndPriceType" resultMap="PrcSurchargeRelResult">
|
||||
<include refid="selectPrcSurchargeRelVo"/>
|
||||
where r.price_type = #{priceType}
|
||||
and r.detail_id in
|
||||
<foreach item="id" collection="detailIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
order by r.rel_id asc
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcSurchargeRel" parameterType="PrcSurchargeRel" useGeneratedKeys="true" keyProperty="relId">
|
||||
insert into prc_surcharge_rel (
|
||||
sc_id, product_id, product_code, detail_id,
|
||||
sc_id, product_id, product_code, detail_id, price_type, country_code,
|
||||
<if test="createBy != null and createBy != ''">created_by,</if>
|
||||
create_time
|
||||
) values (
|
||||
#{scId}, #{productId}, #{productCode}, #{detailId},
|
||||
#{priceType}, #{countryCode},
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
@@ -79,6 +102,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<foreach item="code" collection="array" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
and price_type = 'PRODUCT'
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByDetailIdsAndPriceType">
|
||||
delete from prc_surcharge_rel
|
||||
where price_type = #{priceType}
|
||||
and detail_id in
|
||||
<foreach item="id" collection="detailIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByProductIdsAndPriceType">
|
||||
delete from prc_surcharge_rel
|
||||
where price_type = #{priceType}
|
||||
and product_id in
|
||||
<foreach item="id" collection="productIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 附加费版本化编辑后,产品关联重指向新记录 -->
|
||||
|
||||
+70
-35
@@ -345,6 +345,68 @@ CREATE TABLE `product_country` (
|
||||
CONSTRAINT `fk_product_country_pid` FOREIGN KEY (`product_id`) REFERENCES `product` (`product_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1609 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='产品国家服务明细-重量段+尺寸/尾程/时效(不含运费)';
|
||||
|
||||
-- redline_product / redline_product_country: mirror of product / product_country
|
||||
-- Run once on existing DB
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `redline_product` (
|
||||
`product_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '红线价产品ID',
|
||||
`product_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品对接代码,如 WSP037',
|
||||
`product_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品名称',
|
||||
`service_level` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '时效等级',
|
||||
`cargo_attr` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '走货属性',
|
||||
`dest_region` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '目的区域',
|
||||
`update_note` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新内容说明',
|
||||
`tax_mode` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'TAX_INCLUDED' COMMENT 'TAX_INCLUDED包税 TAX_EXCLUDED不包税',
|
||||
`effective_date` datetime DEFAULT NULL COMMENT '目录生效时间(到小时)',
|
||||
`expire_date` datetime DEFAULT NULL COMMENT '失效时间(空=长期)',
|
||||
`status` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '0待生效 1已生效 2已失效',
|
||||
`source_sheet` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '来源Excel sheet名',
|
||||
`pef_id` bigint(20) DEFAULT NULL COMMENT '关联导入价表Excel附件 prc_price_excel_file.pef_id',
|
||||
`remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`tms_id` int(11) DEFAULT NULL COMMENT '多租户ID',
|
||||
`created_by` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_by` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`product_id`) USING BTREE,
|
||||
UNIQUE KEY `uk_redline_product_code_eff` (`product_code`,`effective_date`),
|
||||
KEY `idx_redline_tax_status` (`tax_mode`,`status`) USING BTREE,
|
||||
KEY `idx_redline_product_code` (`product_code`),
|
||||
KEY `idx_redline_product_pef_id` (`pef_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='红线价产品主表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `redline_product_country` (
|
||||
`detail_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '明细ID',
|
||||
`product_id` bigint(20) DEFAULT NULL COMMENT '红线价产品ID redline_product.product_id',
|
||||
`product_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品代码',
|
||||
`country_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '国家中文名',
|
||||
`country_code` char(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'ISO2',
|
||||
`zone_id` bigint(20) DEFAULT NULL COMMENT 'prc_zone.zone_id',
|
||||
`zone_code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`zone_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`weight_min` decimal(10,3) DEFAULT NULL COMMENT '重量段最小值KG(含)',
|
||||
`weight_max` decimal(10,3) DEFAULT NULL COMMENT '重量段最大值KG(含)',
|
||||
`freight_price` decimal(10,4) DEFAULT NULL COMMENT '运费 RMB/KG',
|
||||
`registration_fee` decimal(10,2) DEFAULT NULL COMMENT '挂号费 RMB/票',
|
||||
`size_limit` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`last_mile` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`lead_time` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`effective_date` datetime DEFAULT NULL COMMENT '生效时间(到小时)',
|
||||
`expire_date` datetime DEFAULT NULL COMMENT '失效时间(空=开放)',
|
||||
`status` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '0待生效 1已生效 2已失效',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`detail_id`) USING BTREE,
|
||||
UNIQUE KEY `uk_redline_country_zone_weight_eff` (`product_code`,`country_name`,`zone_code`,`weight_min`,`weight_max`,`effective_date`),
|
||||
KEY `idx_redline_country_code` (`country_code`) USING BTREE,
|
||||
KEY `idx_redline_weight_match` (`product_code`,`country_code`,`weight_min`,`weight_max`) USING BTREE,
|
||||
KEY `idx_redline_product_eff` (`product_code`,`effective_date`,`expire_date`),
|
||||
KEY `idx_redline_country_pid` (`product_id`),
|
||||
KEY `idx_redline_country_zone` (`zone_id`),
|
||||
CONSTRAINT `fk_redline_country_pid` FOREIGN KEY (`product_id`) REFERENCES `redline_product` (`product_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='红线价国家服务明细';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- 表结构:`region`
|
||||
-- ----------------------------
|
||||
@@ -1351,36 +1413,6 @@ CREATE TABLE `prc_price_set_product` (
|
||||
CONSTRAINT `fk_psp_set` FOREIGN KEY (`price_set_id`) REFERENCES `prc_price_set` (`price_set_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='价格套餐产品主表-与产品库快照独立';
|
||||
|
||||
-- ----------------------------
|
||||
-- 表结构:`prc_price_set_version_surcharge`
|
||||
-- ----------------------------
|
||||
CREATE TABLE `prc_price_set_version_surcharge` (
|
||||
`psvs_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '版本附加费id',
|
||||
`psv_id` bigint(20) NOT NULL COMMENT '套餐版本id',
|
||||
`psd_id` bigint(20) NOT NULL COMMENT '套餐明细id',
|
||||
`sc_id` bigint(20) DEFAULT NULL COMMENT '来源附加费配置id',
|
||||
`product_code` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '产品代码(与明细一致)',
|
||||
`sc_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '附加费名称快照',
|
||||
`fee_type` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'SURCHARGE' COMMENT '费用类型(字典bms_fee_type)',
|
||||
`charge_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '计费方式 FIXED固定金额/WEIGHT按重量/RATE按比例',
|
||||
`charge_value` decimal(18,6) NOT NULL COMMENT '计费数值快照',
|
||||
`currency` char(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'CNY' COMMENT '币种',
|
||||
`round_mode` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'HALF_UP' COMMENT '取值方式(字典bms_round_mode)',
|
||||
`country_code` char(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '适用国家ISO2(空=全部)',
|
||||
`sc_note` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
|
||||
`created_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`updated_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`psvs_id`),
|
||||
KEY `idx_psvs_psv` (`psv_id`),
|
||||
KEY `idx_psvs_psd` (`psd_id`),
|
||||
KEY `idx_psvs_product` (`psv_id`,`product_code`),
|
||||
KEY `idx_psvs_sc` (`sc_id`),
|
||||
CONSTRAINT `fk_psvs_psd` FOREIGN KEY (`psd_id`) REFERENCES `prc_price_set_detail` (`psd_id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_psvs_psv` FOREIGN KEY (`psv_id`) REFERENCES `prc_price_set_version` (`psv_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=487 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='价格套餐版本附加费快照';
|
||||
|
||||
-- ----------------------------
|
||||
-- 表结构:`prc_quote`
|
||||
-- ----------------------------
|
||||
@@ -1488,22 +1520,25 @@ CREATE TABLE `prc_surcharge` (
|
||||
CREATE TABLE `prc_surcharge_rel` (
|
||||
`rel_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '关联ID',
|
||||
`sc_id` bigint(20) NOT NULL COMMENT '附加费配置ID prc_surcharge.sc_id',
|
||||
`product_id` bigint(20) NOT NULL COMMENT '产品ID product.product_id',
|
||||
`product_id` bigint(20) NOT NULL COMMENT '产品ID或套餐产品ID:PRODUCT/REDLINE=product.product_id;SALES=prc_price_set_product.psp_id',
|
||||
`product_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品对接代码 product.product_code',
|
||||
`detail_id` bigint(20) DEFAULT NULL COMMENT '产品明细ID product_country.detail_id(空=作用于产品全部明细)',
|
||||
`detail_id` bigint(20) DEFAULT NULL COMMENT '明细ID:PRODUCT/REDLINE=product_country.detail_id(空=产品全部);SALES=prc_price_set_detail.psd_id',
|
||||
`price_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'PRODUCT' COMMENT '价格类型 PRODUCT产品价/SALES销售价/REDLINE红线价',
|
||||
`country_code` char(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '适用国家ISO2(空=全部)',
|
||||
`created_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL,
|
||||
`updated_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`rel_id`),
|
||||
UNIQUE KEY `uk_rel_scope` (`sc_id`,`product_id`,`detail_id`),
|
||||
UNIQUE KEY `uk_rel_scope` (`sc_id`,`product_id`,`detail_id`,`price_type`,`country_code`),
|
||||
KEY `idx_rel_sc` (`sc_id`),
|
||||
KEY `idx_rel_product` (`product_id`),
|
||||
KEY `idx_rel_product_code` (`product_code`),
|
||||
KEY `idx_rel_detail` (`detail_id`),
|
||||
CONSTRAINT `fk_rel_product` FOREIGN KEY (`product_id`) REFERENCES `product` (`product_id`) ON DELETE CASCADE,
|
||||
KEY `idx_rel_price_type` (`price_type`),
|
||||
KEY `idx_rel_country` (`country_code`),
|
||||
CONSTRAINT `fk_rel_sc` FOREIGN KEY (`sc_id`) REFERENCES `prc_surcharge` (`sc_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='附加费与产品/明细关联表';
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='附加费关联表(按price_type多态关联产品或套餐)';
|
||||
|
||||
-- ----------------------------
|
||||
-- 表结构:`prc_weight_section_detail`
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
-- ------------------------------------------------------------
|
||||
-- 导入价表 Excel 附件记录(建表/字段)
|
||||
-- 用途:产品价/红线价/销售价 Excel 导入时落库文件元数据
|
||||
-- 关联:product.pef_id、prc_price_set_product.pef_id -> prc_price_excel_file.pef_id
|
||||
-- ------------------------------------------------------------
|
||||
|
||||
-- 1) 主表:导入价表 Excel 附件
|
||||
CREATE TABLE IF NOT EXISTS prc_price_excel_file (
|
||||
pef_id bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
excel_type varchar(20) NOT NULL COMMENT '价表类型 PRODUCT=产品价 REDLINE=红线价 SALES=销售价',
|
||||
effective_time datetime NOT NULL COMMENT '生效时间(导入时选择/解析)',
|
||||
file_name varchar(255) NOT NULL COMMENT '文件原始名称',
|
||||
file_path varchar(500) NOT NULL COMMENT '文件存储路径(相对路径或完整URL)',
|
||||
file_size bigint(20) DEFAULT 0 COMMENT '文件大小(字节)',
|
||||
content_type varchar(100) DEFAULT '' COMMENT 'MIME类型',
|
||||
file_extension varchar(20) DEFAULT '' COMMENT '扩展名,如 xlsx/xls',
|
||||
oss_id varchar(64) DEFAULT NULL COMMENT 'OSS/对象存储ID(可空)',
|
||||
sheet_names varchar(1000) DEFAULT NULL COMMENT '导入涉及的 sheet 名(多个逗号分隔,可空)',
|
||||
remark varchar(500) DEFAULT NULL COMMENT '备注',
|
||||
created_by varchar(64) DEFAULT '' COMMENT '创建人',
|
||||
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
||||
updated_by varchar(64) DEFAULT '' COMMENT '更新人',
|
||||
update_time datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (pef_id),
|
||||
KEY idx_pef_type_eff (excel_type, effective_time),
|
||||
KEY idx_pef_create_time (create_time)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='导入价表Excel附件';
|
||||
|
||||
-- 2) 产品主表:关联导入附件
|
||||
ALTER TABLE product
|
||||
ADD COLUMN pef_id bigint(20) DEFAULT NULL COMMENT '关联导入价表Excel附件 prc_price_excel_file.pef_id' AFTER source_sheet,
|
||||
ADD KEY idx_product_pef_id (pef_id);
|
||||
|
||||
-- 3) 套餐产品表:关联导入附件(销售价 Excel 建价)
|
||||
ALTER TABLE prc_price_set_product
|
||||
ADD COLUMN pef_id bigint(20) DEFAULT NULL COMMENT '关联导入价表Excel附件 prc_price_excel_file.pef_id' AFTER source_sheet,
|
||||
ADD KEY idx_psp_pef_id (pef_id);
|
||||
@@ -0,0 +1,80 @@
|
||||
-- prc_surcharge_rel: add price_type + country_code; drop version surcharge snapshot
|
||||
-- Run once on existing DB
|
||||
|
||||
-- 1) drop FK to product (SALES rows store psp_id in product_id)
|
||||
SET @fk_exists := (
|
||||
SELECT COUNT(1) FROM information_schema.TABLE_CONSTRAINTS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'prc_surcharge_rel'
|
||||
AND CONSTRAINT_NAME = 'fk_rel_product' AND CONSTRAINT_TYPE = 'FOREIGN KEY'
|
||||
);
|
||||
SET @sql := IF(@fk_exists > 0,
|
||||
'ALTER TABLE `prc_surcharge_rel` DROP FOREIGN KEY `fk_rel_product`',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 2) price_type
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(1) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'prc_surcharge_rel' AND COLUMN_NAME = 'price_type'
|
||||
);
|
||||
SET @sql := IF(@col_exists = 0,
|
||||
CONCAT(
|
||||
'ALTER TABLE `prc_surcharge_rel` ',
|
||||
'ADD COLUMN `price_type` varchar(20) NOT NULL DEFAULT ''PRODUCT'' ',
|
||||
'COMMENT ''价格类型 PRODUCT产品价/SALES销售价/REDLINE红线价'' AFTER `detail_id`'
|
||||
),
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 3) country_code on rel
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(1) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'prc_surcharge_rel' AND COLUMN_NAME = 'country_code'
|
||||
);
|
||||
SET @sql := IF(@col_exists = 0,
|
||||
CONCAT(
|
||||
'ALTER TABLE `prc_surcharge_rel` ',
|
||||
'ADD COLUMN `country_code` char(2) DEFAULT NULL ',
|
||||
'COMMENT ''适用国家ISO2(空=全部)'' AFTER `price_type`'
|
||||
),
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 4) backfill country from surcharge master when rel country empty
|
||||
UPDATE prc_surcharge_rel r
|
||||
INNER JOIN prc_surcharge s ON s.sc_id = r.sc_id
|
||||
SET r.country_code = s.country_code
|
||||
WHERE (r.country_code IS NULL OR r.country_code = '')
|
||||
AND s.country_code IS NOT NULL AND s.country_code <> '';
|
||||
|
||||
-- 5) rebuild unique key
|
||||
SET @uk_exists := (
|
||||
SELECT COUNT(1) FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'prc_surcharge_rel' AND INDEX_NAME = 'uk_rel_scope'
|
||||
);
|
||||
SET @sql := IF(@uk_exists > 0,
|
||||
'ALTER TABLE `prc_surcharge_rel` DROP INDEX `uk_rel_scope`',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @uk_exists2 := (
|
||||
SELECT COUNT(1) FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'prc_surcharge_rel' AND INDEX_NAME = 'uk_rel_scope'
|
||||
);
|
||||
SET @sql := IF(@uk_exists2 = 0,
|
||||
'ALTER TABLE `prc_surcharge_rel` ADD UNIQUE KEY `uk_rel_scope` (`sc_id`, `product_id`, `detail_id`, `price_type`, `country_code`)',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 6) drop version surcharge snapshot table
|
||||
DROP TABLE IF EXISTS `prc_price_set_version_surcharge`;
|
||||
@@ -0,0 +1,105 @@
|
||||
-- redline_product / redline_product_country: mirror of product / product_country
|
||||
-- Run once on existing DB
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `redline_product` (
|
||||
`product_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '红线价产品ID',
|
||||
`product_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品对接代码,如 WSP037',
|
||||
`product_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品名称',
|
||||
`service_level` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '时效等级',
|
||||
`cargo_attr` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '走货属性',
|
||||
`dest_region` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '目的区域',
|
||||
`update_note` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新内容说明',
|
||||
`tax_mode` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'TAX_INCLUDED' COMMENT 'TAX_INCLUDED包税 TAX_EXCLUDED不包税',
|
||||
`effective_date` datetime DEFAULT NULL COMMENT '目录生效时间(到小时)',
|
||||
`expire_date` datetime DEFAULT NULL COMMENT '失效时间(空=长期)',
|
||||
`status` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '0待生效 1已生效 2已失效',
|
||||
`source_sheet` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '来源Excel sheet名',
|
||||
`pef_id` bigint(20) DEFAULT NULL COMMENT '关联导入价表Excel附件 prc_price_excel_file.pef_id',
|
||||
`remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`tms_id` int(11) DEFAULT NULL COMMENT '多租户ID',
|
||||
`created_by` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_by` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`product_id`) USING BTREE,
|
||||
UNIQUE KEY `uk_redline_product_code_eff` (`product_code`,`effective_date`),
|
||||
KEY `idx_redline_tax_status` (`tax_mode`,`status`) USING BTREE,
|
||||
KEY `idx_redline_product_code` (`product_code`),
|
||||
KEY `idx_redline_product_pef_id` (`pef_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='红线价产品主表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `redline_product_country` (
|
||||
`detail_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '明细ID',
|
||||
`product_id` bigint(20) DEFAULT NULL COMMENT '红线价产品ID redline_product.product_id',
|
||||
`product_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品代码',
|
||||
`country_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '国家中文名',
|
||||
`country_code` char(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'ISO2',
|
||||
`zone_id` bigint(20) DEFAULT NULL COMMENT 'prc_zone.zone_id',
|
||||
`zone_code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`zone_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`weight_min` decimal(10,3) DEFAULT NULL COMMENT '重量段最小值KG(含)',
|
||||
`weight_max` decimal(10,3) DEFAULT NULL COMMENT '重量段最大值KG(含)',
|
||||
`freight_price` decimal(10,4) DEFAULT NULL COMMENT '运费 RMB/KG',
|
||||
`registration_fee` decimal(10,2) DEFAULT NULL COMMENT '挂号费 RMB/票',
|
||||
`size_limit` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`last_mile` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`lead_time` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`effective_date` datetime DEFAULT NULL COMMENT '生效时间(到小时)',
|
||||
`expire_date` datetime DEFAULT NULL COMMENT '失效时间(空=开放)',
|
||||
`status` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '0待生效 1已生效 2已失效',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`detail_id`) USING BTREE,
|
||||
UNIQUE KEY `uk_redline_country_zone_weight_eff` (`product_code`,`country_name`,`zone_code`,`weight_min`,`weight_max`,`effective_date`),
|
||||
KEY `idx_redline_country_code` (`country_code`) USING BTREE,
|
||||
KEY `idx_redline_weight_match` (`product_code`,`country_code`,`weight_min`,`weight_max`) USING BTREE,
|
||||
KEY `idx_redline_product_eff` (`product_code`,`effective_date`,`expire_date`),
|
||||
KEY `idx_redline_country_pid` (`product_id`),
|
||||
KEY `idx_redline_country_zone` (`zone_id`),
|
||||
CONSTRAINT `fk_redline_country_pid` FOREIGN KEY (`product_id`) REFERENCES `redline_product` (`product_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='红线价国家服务明细';
|
||||
|
||||
-- Menu: under 价栶基础 parent (lookup by path price/basic or menu_name)
|
||||
-- Adjust @parentId if your env differs
|
||||
SET @parentId := (
|
||||
SELECT menu_id FROM sys_menu
|
||||
WHERE path = 'basic' AND menu_type = 'M'
|
||||
ORDER BY menu_id ASC LIMIT 1
|
||||
);
|
||||
SET @parentId := IFNULL(@parentId, (
|
||||
SELECT parent_id FROM sys_menu
|
||||
WHERE perms = 'price:product:list' OR component LIKE '%price/basic/product%'
|
||||
ORDER BY menu_id ASC LIMIT 1
|
||||
));
|
||||
|
||||
-- skip insert if already exists
|
||||
SET @exists := (
|
||||
SELECT COUNT(1) FROM sys_menu WHERE perms = 'price:redline:list' OR component = 'price/basic/redline/index'
|
||||
);
|
||||
|
||||
-- Only insert when parent found and not exists
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
|
||||
SELECT '红线价', @parentId, 15, 'redline', 'price/basic/redline/index', 1, 0, 'C', '0', '0', 'price:redline:list', 'money', 'admin', sysdate(), '红线价目录'
|
||||
WHERE @parentId IS NOT NULL AND @exists = 0;
|
||||
|
||||
SET @menuId := (SELECT menu_id FROM sys_menu WHERE perms = 'price:redline:list' LIMIT 1);
|
||||
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
|
||||
SELECT '红线价查询', @menuId, 1, '', '', 1, 0, 'F', '0', '0', 'price:redline:query', '#', 'admin', sysdate()
|
||||
WHERE @menuId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'price:redline:query');
|
||||
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
|
||||
SELECT '红线价新增', @menuId, 2, '', '', 1, 0, 'F', '0', '0', 'price:redline:add', '#', 'admin', sysdate()
|
||||
WHERE @menuId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'price:redline:add');
|
||||
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
|
||||
SELECT '红线价修改', @menuId, 3, '', '', 1, 0, 'F', '0', '0', 'price:redline:edit', '#', 'admin', sysdate()
|
||||
WHERE @menuId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'price:redline:edit');
|
||||
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
|
||||
SELECT '红线价删除', @menuId, 4, '', '', 1, 0, 'F', '0', '0', 'price:redline:remove', '#', 'admin', sysdate()
|
||||
WHERE @menuId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'price:redline:remove');
|
||||
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time)
|
||||
SELECT '红线价导入', @menuId, 5, '', '', 1, 0, 'F', '0', '0', 'price:redline:import', '#', 'admin', sysdate()
|
||||
WHERE @menuId IS NOT NULL AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'price:redline:import');
|
||||
@@ -167,3 +167,11 @@ export async function importProductCountryExcelAsync(file, countryCode, effectiv
|
||||
}
|
||||
return pollProductImportTask(taskId, onProgress)
|
||||
}
|
||||
|
||||
/** List imported Excel attachments for product_code */
|
||||
export function listProductExcelFiles(productCode) {
|
||||
return request({
|
||||
url: '/price/product/' + encodeURIComponent(productCode) + '/excelFiles',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
/** 查询红线价列表 */
|
||||
export function listRedline(query) {
|
||||
return request({
|
||||
url: '/price/redline/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
/** 产品下拉选项(非分页,不要求 price:redline:list 权限) */
|
||||
export function listRedlineOptions(query) {
|
||||
return request({
|
||||
url: '/price/redline/optionselect',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
/** 查询产品详情 */
|
||||
export function getRedline(productId) {
|
||||
return request({
|
||||
url: '/price/redline/' + productId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/** 查询产品国家明细(优先 productId,绑定到具体产品版本行) */
|
||||
export function listRedlineCountries(productCode, effectiveDate, productId) {
|
||||
const params = {}
|
||||
if (effectiveDate) params.effectiveDate = effectiveDate
|
||||
if (productId) params.productId = productId
|
||||
return request({
|
||||
url: '/price/redline/' + productCode + '/countries',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
/** 修改产品国家明细行(重量段/运费/挂号费/尺寸/尾程/时效/生效失效日期) */
|
||||
export function updateRedlineCountry(data) {
|
||||
return request({
|
||||
url: '/price/redline/country',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
/** 新增红线价 */
|
||||
export function addRedline(data) {
|
||||
return request({
|
||||
url: '/price/redline',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
/** 修改产品 */
|
||||
export function updateRedline(data) {
|
||||
return request({
|
||||
url: '/price/redline',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除产品 */
|
||||
export function delRedline(productIds) {
|
||||
return request({
|
||||
url: '/price/redline/' + productIds,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function getRedlineImportTask(taskId) {
|
||||
return request({
|
||||
url: '/price/redline/import/task/' + taskId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
function pickImportTaskId(res) {
|
||||
if (!res) return null
|
||||
const d = res.data
|
||||
if (d && typeof d === 'object' && d.taskId) return String(d.taskId)
|
||||
if (typeof d === 'string' && d.trim()) return d.trim()
|
||||
if (typeof res.msg === 'string') {
|
||||
const m = res.msg.trim()
|
||||
if (/^[a-f0-9]{32}$/i.test(m)) return m
|
||||
if (/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(m)) {
|
||||
return m.replace(/-/g, '')
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
async function pollProductImportTask(taskId, onProgress) {
|
||||
const started = Date.now()
|
||||
const maxMs = 30 * 60 * 1000
|
||||
while (Date.now() - started < maxMs) {
|
||||
const res = await getRedlineImportTask(taskId)
|
||||
const task = res.data || {}
|
||||
if (typeof onProgress === 'function') {
|
||||
onProgress(task)
|
||||
}
|
||||
if (task.status === 'SUCCESS') {
|
||||
return { task }
|
||||
}
|
||||
if (task.status === 'FAIL') {
|
||||
const err = new Error(task.error || task.message || 'import failed')
|
||||
err.task = task
|
||||
throw err
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 800))
|
||||
}
|
||||
throw new Error('import timeout')
|
||||
}
|
||||
|
||||
/**
|
||||
* Async all-country product import; poll until done.
|
||||
* @param {File|Blob} file
|
||||
* @param {string} effectiveDate yyyy-MM-dd (required)
|
||||
* @param {(task: object) => void} [onProgress]
|
||||
*/
|
||||
export async function importRedlineExcelAsync(file, effectiveDate, onProgress) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
const params = new URLSearchParams()
|
||||
params.set('updateSupport', '0')
|
||||
if (effectiveDate) params.set('effectiveDate', effectiveDate)
|
||||
const submitRes = await request({
|
||||
url: '/price/redline/importData?' + params.toString(),
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
const taskId = pickImportTaskId(submitRes)
|
||||
if (!taskId) {
|
||||
throw new Error('missing import taskId')
|
||||
}
|
||||
return pollProductImportTask(taskId, onProgress)
|
||||
}
|
||||
|
||||
/**
|
||||
* Async single-country product import; poll until done.
|
||||
* @param {File|Blob} file
|
||||
* @param {string} countryCode
|
||||
* @param {string} effectiveDate yyyy-MM-dd
|
||||
* @param {(task: object) => void} [onProgress]
|
||||
*/
|
||||
export async function importRedlineCountryExcelAsync(file, countryCode, effectiveDate, onProgress) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
const params = new URLSearchParams()
|
||||
params.set('countryCode', countryCode)
|
||||
if (effectiveDate) params.set('effectiveDate', effectiveDate)
|
||||
const submitRes = await request({
|
||||
url: '/price/redline/importCountryData?' + params.toString(),
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
const taskId = pickImportTaskId(submitRes)
|
||||
if (!taskId) {
|
||||
throw new Error('missing import taskId')
|
||||
}
|
||||
return pollProductImportTask(taskId, onProgress)
|
||||
}
|
||||
|
||||
/** List imported Excel attachments for product_code */
|
||||
export function listProductExcelFiles(productCode) {
|
||||
return request({
|
||||
url: '/price/redline/' + encodeURIComponent(productCode) + '/excelFiles',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@@ -20,10 +20,11 @@ export function getSurcharge(scId) {
|
||||
}
|
||||
|
||||
/** 查询指定产品的附加费关联(非分页,含附加费与明细展示字段) */
|
||||
export function listSurchargeByProduct(productCode) {
|
||||
export function listSurchargeByProduct(productCode, priceType) {
|
||||
return request({
|
||||
url: '/price/surcharge/byProduct/' + productCode,
|
||||
method: 'get'
|
||||
method: 'get',
|
||||
params: priceType ? { priceType } : undefined
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<el-drawer v-model="visible" size="860px" :title="title" append-to-body>
|
||||
<el-table v-loading="loading" :data="list" border max-height="calc(100vh - 160px)" empty-text="该产品暂无导入附件">
|
||||
<el-table-column label="文件名称" prop="fileName" min-width="220" show-overflow-tooltip />
|
||||
<el-table-column label="生效时间" prop="effectiveTime" width="170" align="center" />
|
||||
<el-table-column label="大小" width="100" align="right">
|
||||
<template #default="{ row }">{{ formatSize(row.fileSize) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="上传人" prop="createBy" width="110" align="center" show-overflow-tooltip />
|
||||
<el-table-column label="上传时间" prop="createTime" width="170" align="center" />
|
||||
<el-table-column label="操作" width="90" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" :disabled="!row.filePath" @click="handleDownload(row)">下载</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { listProductExcelFiles } from '@/api/price/product'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const visible = ref(false)
|
||||
const title = ref('')
|
||||
const loading = ref(false)
|
||||
const list = ref([])
|
||||
const product = ref(null)
|
||||
|
||||
function open(row) {
|
||||
product.value = row
|
||||
title.value = (row.productCode || '') + ' · ' + (row.productName || '') + ' · 导入附件'
|
||||
visible.value = true
|
||||
loadList()
|
||||
}
|
||||
|
||||
function loadList() {
|
||||
if (!product.value || !product.value.productCode) return
|
||||
loading.value = true
|
||||
listProductExcelFiles(product.value.productCode).then(res => {
|
||||
list.value = res.data || []
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function formatSize(bytes) {
|
||||
const n = Number(bytes)
|
||||
if (!n || n < 0) return '-'
|
||||
if (n < 1024) return n + ' B'
|
||||
if (n < 1024 * 1024) return (n / 1024).toFixed(1) + ' KB'
|
||||
return (n / (1024 * 1024)).toFixed(2) + ' MB'
|
||||
}
|
||||
|
||||
function handleDownload(row) {
|
||||
if (!row || !row.filePath) {
|
||||
proxy.$modal.msgWarning('文件路径不存在')
|
||||
return
|
||||
}
|
||||
proxy.$download.resource(row.filePath)
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
@@ -52,8 +52,16 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="更新内容" prop="updateNote" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="100" align="center" fixed="right">
|
||||
<el-table-column label="操作" width="120" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
title="价格"
|
||||
icon="Document"
|
||||
@click="excelFileRef.open(row)"
|
||||
v-hasPermi="['price:product:query']"
|
||||
></el-button>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@@ -73,16 +81,19 @@
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="loadList"
|
||||
/>
|
||||
<product-excel-file-drawer ref="excelFileRef" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { listProduct } from '@/api/price/product'
|
||||
import ProductExcelFileDrawer from './ProductExcelFileDrawer.vue'
|
||||
|
||||
const emit = defineEmits(['view-country'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_product_effect_status } = useDict('bms_product_effect_status')
|
||||
|
||||
const excelFileRef = ref()
|
||||
const title = '失效价格'
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="list" border max-height="calc(100vh - 160px)" empty-text="该产品暂无关联附加费">
|
||||
<el-table-column label="附加费名称" prop="scName" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="价格类型" width="100" align="center">
|
||||
<template #default="{ row }">{{ priceTypeLabel(row.priceType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计费方式" width="110" align="center">
|
||||
<template #default="{ row }">{{ chargeTypeLabel(row.chargeType) }}</template>
|
||||
</el-table-column>
|
||||
@@ -72,7 +75,7 @@ function open(row) {
|
||||
function loadList() {
|
||||
if (!product.value) return
|
||||
loading.value = true
|
||||
listSurchargeByProduct(product.value.productCode).then(res => {
|
||||
listSurchargeByProduct(product.value.productCode, 'PRODUCT').then(res => {
|
||||
list.value = res.data || []
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
@@ -98,6 +101,12 @@ function handleRelDelete(relId) {
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function priceTypeLabel(val) {
|
||||
if (val === 'REDLINE') return '红线价'
|
||||
if (val === 'SALES') return '销售价'
|
||||
return '产品价'
|
||||
}
|
||||
|
||||
function chargeTypeLabel(val) {
|
||||
const found = bms_charge_type.value.find(c => c.value === val)
|
||||
return found ? found.label : (val || '-')
|
||||
|
||||
@@ -6,6 +6,22 @@
|
||||
<el-option v-for="s in surchargePool" :key="s.scId" :label="s.scName" :value="s.scId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="价格类型" prop="priceType">
|
||||
<el-select v-model="form.priceType" placeholder="请选择价格类型" style="width: 100%">
|
||||
<el-option label="产品价" value="PRODUCT" />
|
||||
<el-option label="红线价" value="REDLINE" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="适用国家" prop="countryCode">
|
||||
<el-select v-model="form.countryCode" clearable filterable placeholder="空=全部国家" style="width: 100%">
|
||||
<el-option
|
||||
v-for="r in regionOptions"
|
||||
:key="r.countryCode2"
|
||||
:label="(r.countryNameCn || r.countryNameEn || r.countryCode2) + ' (' + r.countryCode2 + ')'"
|
||||
:value="r.countryCode2"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="作用范围" prop="scope">
|
||||
<el-radio-group v-model="form.scope">
|
||||
<el-radio value="PRODUCT">产品级(全部明细)</el-radio>
|
||||
@@ -30,6 +46,7 @@
|
||||
<script setup>
|
||||
import { listProductCountries } from '@/api/price/product'
|
||||
import { listSurcharge, addSurchargeRel } from '@/api/price/surcharge'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
@@ -40,9 +57,11 @@ const title = ref('新增附加费关联')
|
||||
const product = ref(null)
|
||||
const surchargePool = ref([])
|
||||
const countryList = ref([])
|
||||
const regionOptions = ref([])
|
||||
const form = ref({})
|
||||
const rules = {
|
||||
scId: [{ required: true, message: '请选择附加费', trigger: 'change' }]
|
||||
scId: [{ required: true, message: '请选择附加费', trigger: 'change' }],
|
||||
priceType: [{ required: true, message: '请选择价格类型', trigger: 'change' }]
|
||||
}
|
||||
|
||||
function detailLabel(d) {
|
||||
@@ -53,6 +72,8 @@ function detailLabel(d) {
|
||||
function reset() {
|
||||
form.value = {
|
||||
scId: undefined,
|
||||
priceType: 'PRODUCT',
|
||||
countryCode: undefined,
|
||||
scope: 'PRODUCT',
|
||||
detailId: undefined
|
||||
}
|
||||
@@ -66,6 +87,9 @@ function open(row) {
|
||||
listSurcharge({ ssCode: 'on', pageNum: 1, pageSize: 1000 }).then(res => {
|
||||
surchargePool.value = res.rows || []
|
||||
})
|
||||
listRegionOptions().then(res => {
|
||||
regionOptions.value = res.data || []
|
||||
})
|
||||
if (row && row.productCode) {
|
||||
listProductCountries(row.productCode, undefined, row.productId).then(res => {
|
||||
countryList.value = res.data || []
|
||||
@@ -84,7 +108,9 @@ function submit() {
|
||||
scId: form.value.scId,
|
||||
productId: product.value ? product.value.productId : undefined,
|
||||
productCode: product.value ? product.value.productCode : undefined,
|
||||
detailId: form.value.scope === 'DETAIL' ? form.value.detailId : null
|
||||
detailId: form.value.scope === 'DETAIL' ? form.value.detailId : null,
|
||||
priceType: form.value.priceType || 'PRODUCT',
|
||||
countryCode: form.value.countryCode || null
|
||||
}
|
||||
addSurchargeRel(payload).then(() => {
|
||||
proxy.$modal.msgSuccess('关联成功')
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
</template>
|
||||
|
||||
<template #col-action="{ row }">
|
||||
<el-button link type="primary" title="价格" icon="Document" @click="excelFileRef.open(row)" v-hasPermi="['price:product:query']"></el-button>
|
||||
<el-button link type="primary" title="产品明细" icon="View" @click="countryRef.open(row)" v-hasPermi="['price:product:query']"></el-button>
|
||||
<el-button link type="primary" title="附加费" icon="Money" @click="surchargeRef.open(row)" v-hasPermi="['price:surcharge:query']"></el-button>
|
||||
<el-button title="编辑" link type="primary" icon="Edit" @click="handleUpdate(row)" v-hasPermi="['price:product:edit']"></el-button>
|
||||
@@ -54,6 +55,7 @@
|
||||
</basic-table>
|
||||
|
||||
<product-form-dialog ref="formRef" @success="() => tableRef.refresh()" />
|
||||
<product-excel-file-drawer ref="excelFileRef" />
|
||||
<product-country-drawer ref="countryRef" />
|
||||
<product-surcharge-drawer ref="surchargeRef" @success="() => tableRef.refresh()" />
|
||||
<product-expired-drawer ref="expiredRef" @view-country="(row) => countryRef.open(row)" />
|
||||
@@ -146,6 +148,7 @@
|
||||
<script setup name="PriceProduct">
|
||||
import ExcelImportDialog from '@/components/ExcelImportDialog'
|
||||
import ProductFormDialog from './components/ProductFormDialog.vue'
|
||||
import ProductExcelFileDrawer from './components/ProductExcelFileDrawer.vue'
|
||||
import ProductCountryDrawer from './components/ProductCountryDrawer.vue'
|
||||
import ProductSurchargeDrawer from './components/ProductSurchargeDrawer.vue'
|
||||
import ProductExpiredDrawer from './components/ProductExpiredDrawer.vue'
|
||||
@@ -157,6 +160,7 @@ const { bms_product_effect_status } = useDict('bms_product_effect_status')
|
||||
const extraParams = { statusGroup: 'active' }
|
||||
const tableRef = ref()
|
||||
const formRef = ref()
|
||||
const excelFileRef = ref()
|
||||
const countryRef = ref()
|
||||
const surchargeRef = ref()
|
||||
const expiredRef = ref()
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
<template>
|
||||
<el-drawer v-model="visible" size="80%" :title="title" append-to-body>
|
||||
<div class="mb8" style="display: flex; align-items: center; gap: 12px">
|
||||
<el-input v-model="keyword" placeholder="搜索国家/分区(中文名 / ISO2 / 分区)" clearable style="width: 260px" />
|
||||
</div>
|
||||
<simple-table
|
||||
:data="filteredList"
|
||||
:columns="columns"
|
||||
:loading="loading"
|
||||
border
|
||||
max-height="calc(100vh - 120px)"
|
||||
empty-text="暂无国家明细"
|
||||
:span-method="spanMethod"
|
||||
row-key="detailId"
|
||||
>
|
||||
<template #col-countryName="{ row }">
|
||||
<span class="pre-wrap">{{ row.countryName }} ({{ row.countryCode }})</span>
|
||||
</template>
|
||||
<template #col-sizeLimit="{ row }">
|
||||
<span class="pre-wrap">{{ row.sizeLimit }}</span>
|
||||
</template>
|
||||
<template #col-lastMile="{ row }">
|
||||
<span class="pre-wrap">{{ row.lastMile }}</span>
|
||||
</template>
|
||||
<template #col-action="{ row }">
|
||||
<el-button link type="primary" icon="Edit" @click="openEdit(row)" v-hasPermi="['price:redline:edit']">编辑</el-button>
|
||||
</template>
|
||||
</simple-table>
|
||||
|
||||
<!-- 编辑国家明细弹窗 -->
|
||||
<el-dialog v-model="editVisible" :title="editTitle" width="620px" append-to-body :close-on-click-modal="false">
|
||||
<div class="edit-context">国家 / 分区:<b>{{ editRow.countryName }} ({{ editRow.countryCode }})</b> · {{ editRow.zoneName || '无分区' }}</div>
|
||||
<el-form ref="editFormRef" :model="editForm" :rules="editRules" label-width="110px">
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="重量下限(KG)" prop="weightMin">
|
||||
<el-input-number v-model="editForm.weightMin" :min="0" :precision="3" :step="0.1" controls-position="right" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="重量上限(KG)" prop="weightMax">
|
||||
<el-input-number v-model="editForm.weightMax" :min="0" :precision="3" :step="0.1" controls-position="right" placeholder="留空为不封顶" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="运费(RMB/KG)" prop="freightPrice">
|
||||
<el-input-number v-model="editForm.freightPrice" :min="0" :precision="2" :step="1" controls-position="right" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="挂号费(RMB/票)" prop="registrationFee">
|
||||
<el-input-number v-model="editForm.registrationFee" :min="0" :precision="2" :step="1" controls-position="right" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="尾程" prop="lastMile">
|
||||
<el-input v-model="editForm.lastMile" placeholder="如 DHL Paket" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="时效" prop="leadTime">
|
||||
<el-input v-model="editForm.leadTime" placeholder="如 7-9工作日" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="生效时间" prop="effectiveDate">
|
||||
<el-date-picker v-model="editForm.effectiveDate" type="datetime" format="YYYY-MM-DD HH:00" value-format="YYYY-MM-DD HH:00:00" placeholder="选择时间" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="失效时间" prop="expireDate">
|
||||
<el-date-picker v-model="editForm.expireDate" type="datetime" format="YYYY-MM-DD HH:00" value-format="YYYY-MM-DD HH:00:00" placeholder="留空为长期" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="尺寸限制" prop="sizeLimit">
|
||||
<el-input v-model="editForm.sizeLimit" type="textarea" :rows="2" placeholder="如 最大尺寸 60x50x40cm" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="editVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="saveEdit">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import SimpleTable from '@/components/SimpleTable'
|
||||
import { listRedlineCountries, updateRedlineCountry } from '@/api/price/redline'
|
||||
import { formatWeightLabel } from '@/views/price/set/utils/priceSet'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const columns = [
|
||||
{ prop: 'countryName', label: '国家', width: 120, showOverflowTooltip: true },
|
||||
// { prop: 'countryCode', label: 'ISO2', width: 60, align: 'center' },
|
||||
{ prop: 'zoneName', label: '分区名称', width: 140, showOverflowTooltip: true, formatter: (row) => row.zoneName || '-' },
|
||||
{
|
||||
prop: 'weightMin',
|
||||
label: '重量段(KG)',
|
||||
width: 130,
|
||||
align: 'center',
|
||||
formatter: (row) => (row.weightMin != null || row.weightMax != null
|
||||
? formatWeightLabel(row.weightMin, row.weightMax)
|
||||
: '-')
|
||||
},
|
||||
{ prop: 'freightPrice', label: '运费(RMB/KG)', width: 110, align: 'right' },
|
||||
{ prop: 'registrationFee', label: '挂号费(RMB/票)', width: 120, align: 'right' },
|
||||
{ prop: 'sizeLimit', label: '尺寸限制', minWidth: 140 },
|
||||
{ prop: 'lastMile', label: '尾程', minWidth: 110 },
|
||||
{ prop: 'leadTime', label: '时效', width: 100, showOverflowTooltip: true },
|
||||
{ prop: 'effectiveDate', label: '生效时间', width: 160, align: 'center' },
|
||||
{ prop: 'expireDate', label: '失效时间', width: 110, align: 'center', formatter: (row) => row.expireDate || '长期' },
|
||||
{ prop: 'status', label: '状态', width: 90, align: 'center', dict: 'bms_product_effect_status' },
|
||||
// { prop: 'action', label: '操作', width: 70, fixed: 'right', slot: 'action' }
|
||||
]
|
||||
|
||||
const visible = ref(false)
|
||||
const title = ref('')
|
||||
const loading = ref(false)
|
||||
const list = ref([])
|
||||
const keyword = ref('')
|
||||
const status = ref('')
|
||||
// 当前产品行(用于编辑保存后重新加载明细)
|
||||
const currentProduct = ref(null)
|
||||
|
||||
const filteredList = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
const st = status.value
|
||||
return list.value.filter(r => {
|
||||
if (kw && !(String(r.countryName || '').toLowerCase().includes(kw) ||
|
||||
String(r.countryCode || '').toLowerCase().includes(kw) ||
|
||||
String(r.zoneCode || '').toLowerCase().includes(kw) ||
|
||||
String(r.zoneName || '').toLowerCase().includes(kw))) return false
|
||||
if (st && String(r.status) !== String(st)) return false
|
||||
return true
|
||||
})
|
||||
})
|
||||
|
||||
function formatEffDate(v) {
|
||||
if (!v) return undefined
|
||||
return String(v).slice(0, 10)
|
||||
}
|
||||
|
||||
function load() {
|
||||
if (!currentProduct.value) return
|
||||
const row = currentProduct.value
|
||||
loading.value = true
|
||||
listRedlineCountries(row.productCode, formatEffDate(row.effectiveDate), row.productId).then(res => {
|
||||
list.value = (res.data || []).slice().sort((a, b) => {
|
||||
const c = String(a.countryCode || '').localeCompare(String(b.countryCode || ''))
|
||||
if (c !== 0) return c
|
||||
return String(a.zoneCode || '').localeCompare(String(b.zoneCode || ''))
|
||||
})
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function open(row) {
|
||||
title.value = row.productCode + ' · ' + row.productName + ' · 国家服务明细'
|
||||
currentProduct.value = row
|
||||
visible.value = true
|
||||
list.value = []
|
||||
keyword.value = ''
|
||||
status.value = ''
|
||||
load()
|
||||
}
|
||||
|
||||
/* ---------- 编辑明细 ---------- */
|
||||
const editVisible = ref(false)
|
||||
const editTitle = ref('编辑国家明细')
|
||||
const editFormRef = ref()
|
||||
const saving = ref(false)
|
||||
const editRow = ref({})
|
||||
function normalizeDrawerHour(val) {
|
||||
if (val == null || val === '') return ''
|
||||
const s = String(val).trim().replace('T', ' ')
|
||||
const m = s.match(/^(\d{4}-\d{2}-\d{2})[ ](\d{2})/)
|
||||
if (m) return m[1] + ' ' + m[2] + ':00:00'
|
||||
if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return s + ' 00:00:00'
|
||||
return s
|
||||
}
|
||||
|
||||
const editForm = reactive({
|
||||
detailId: null,
|
||||
weightMin: null,
|
||||
weightMax: null,
|
||||
freightPrice: null,
|
||||
registrationFee: null,
|
||||
sizeLimit: '',
|
||||
lastMile: '',
|
||||
leadTime: '',
|
||||
effectiveDate: '',
|
||||
expireDate: ''
|
||||
})
|
||||
|
||||
const editRules = {
|
||||
weightMin: [{ required: true, message: '重量下限不能为空', trigger: 'blur' }],
|
||||
weightMax: [{
|
||||
validator: (rule, value, callback) => {
|
||||
if (value != null && editForm.weightMin != null && Number(value) <= Number(editForm.weightMin)) {
|
||||
callback(new Error('上限需大于下限'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'blur'
|
||||
}],
|
||||
freightPrice: [{ required: true, message: '运费不能为空', trigger: 'blur' }],
|
||||
effectiveDate: [{ required: true, message: '生效时间不能为空', trigger: 'change' }]
|
||||
}
|
||||
|
||||
function openEdit(row) {
|
||||
editRow.value = row
|
||||
editTitle.value = `编辑明细 · ${row.countryName}${row.zoneName ? ' · ' + row.zoneName : ''} · ${formatWeightLabel(row.weightMin, row.weightMax) || ''}`
|
||||
Object.assign(editForm, {
|
||||
detailId: row.detailId,
|
||||
weightMin: row.weightMin ?? null,
|
||||
weightMax: row.weightMax ?? null,
|
||||
freightPrice: row.freightPrice ?? null,
|
||||
registrationFee: row.registrationFee ?? null,
|
||||
sizeLimit: row.sizeLimit || '',
|
||||
lastMile: row.lastMile || '',
|
||||
leadTime: row.leadTime || '',
|
||||
effectiveDate: row.effectiveDate ? normalizeDrawerHour(row.effectiveDate) : '',
|
||||
expireDate: row.expireDate ? normalizeDrawerHour(row.expireDate) : '',
|
||||
})
|
||||
editVisible.value = true
|
||||
nextTick(() => editFormRef.value?.clearValidate())
|
||||
}
|
||||
|
||||
function saveEdit() {
|
||||
editFormRef.value.validate(valid => {
|
||||
if (!valid) return
|
||||
saving.value = true
|
||||
updateRedlineCountry({ ...editForm, expireDate: editForm.expireDate || null }).then(() => {
|
||||
proxy.$modal.msgSuccess('修改成功')
|
||||
editVisible.value = false
|
||||
load()
|
||||
}).finally(() => {
|
||||
saving.value = false
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function rowGroupKey(row) {
|
||||
return String(row?.countryCode || '') + '|' + String(row?.zoneCode || '') + '|' + String(row?.countryName || '')
|
||||
}
|
||||
|
||||
function spanMethod({ column, rowIndex }) {
|
||||
if (!['countryName', 'countryCode', 'zoneCode', 'zoneName', 'zoneId'].includes(column.property)) return
|
||||
const rows = filteredList.value
|
||||
if (!rows.length) return
|
||||
const cur = rowGroupKey(rows[rowIndex])
|
||||
if (rowIndex > 0 && rowGroupKey(rows[rowIndex - 1]) === cur) {
|
||||
return { rowspan: 0, colspan: 0 }
|
||||
}
|
||||
let count = 1
|
||||
while (rowIndex + count < rows.length && rowGroupKey(rows[rowIndex + count]) === cur) count++
|
||||
return { rowspan: count, colspan: 1 }
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mb8 { margin-bottom: 8px; }
|
||||
.pre-wrap { white-space: pre-wrap; font-size: 12px; line-height: 1.4; }
|
||||
.edit-context {
|
||||
margin-bottom: 14px;
|
||||
padding: 8px 12px;
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<el-drawer v-model="visible" size="860px" :title="title" append-to-body>
|
||||
<el-table v-loading="loading" :data="list" border max-height="calc(100vh - 160px)" empty-text="该产品暂无导入附件">
|
||||
<el-table-column label="文件名称" prop="fileName" min-width="220" show-overflow-tooltip />
|
||||
<el-table-column label="生效时间" prop="effectiveTime" width="170" align="center" />
|
||||
<el-table-column label="大小" width="100" align="right">
|
||||
<template #default="{ row }">{{ formatSize(row.fileSize) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="上传人" prop="createBy" width="110" align="center" show-overflow-tooltip />
|
||||
<el-table-column label="上传时间" prop="createTime" width="170" align="center" />
|
||||
<el-table-column label="操作" width="90" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" :disabled="!row.filePath" @click="handleDownload(row)">下载</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { listProductExcelFiles } from '@/api/price/redline'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const visible = ref(false)
|
||||
const title = ref('')
|
||||
const loading = ref(false)
|
||||
const list = ref([])
|
||||
const product = ref(null)
|
||||
|
||||
function open(row) {
|
||||
product.value = row
|
||||
title.value = (row.productCode || '') + ' · ' + (row.productName || '') + ' · 导入附件'
|
||||
visible.value = true
|
||||
loadList()
|
||||
}
|
||||
|
||||
function loadList() {
|
||||
if (!product.value || !product.value.productCode) return
|
||||
loading.value = true
|
||||
listProductExcelFiles(product.value.productCode).then(res => {
|
||||
list.value = res.data || []
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function formatSize(bytes) {
|
||||
const n = Number(bytes)
|
||||
if (!n || n < 0) return '-'
|
||||
if (n < 1024) return n + ' B'
|
||||
if (n < 1024 * 1024) return (n / 1024).toFixed(1) + ' KB'
|
||||
return (n / (1024 * 1024)).toFixed(2) + ' MB'
|
||||
}
|
||||
|
||||
function handleDownload(row) {
|
||||
if (!row || !row.filePath) {
|
||||
proxy.$modal.msgWarning('文件路径不存在')
|
||||
return
|
||||
}
|
||||
proxy.$download.resource(row.filePath)
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
@@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<el-drawer v-model="visible" size="960px" :title="title" append-to-body>
|
||||
<el-form :inline="true" @submit.prevent>
|
||||
<el-form-item label="产品代码">
|
||||
<el-input
|
||||
v-model="queryParams.productCode"
|
||||
placeholder="产品代码"
|
||||
clearable
|
||||
style="width: 160px"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品名称">
|
||||
<el-input
|
||||
v-model="queryParams.productName"
|
||||
placeholder="产品名称"
|
||||
clearable
|
||||
style="width: 160px"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="失效时间段">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="daterange"
|
||||
value-format="YYYY-MM-DD"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
style="width: 260px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="loading" :data="list" border max-height="calc(100vh - 260px)" empty-text="暂无失效产品">
|
||||
<el-table-column label="产品代码" prop="productCode" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column label="产品名称" prop="productName" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="时效等级" prop="serviceLevel" width="90" align="center" />
|
||||
<el-table-column label="走货属性" prop="cargoAttr" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column label="目的区域" prop="destRegion" width="90" align="center" />
|
||||
<el-table-column label="生效日期" prop="effectiveDate" width="120" align="center" />
|
||||
<el-table-column label="失效日期" prop="expireDate" width="120" align="center" />
|
||||
<el-table-column label="国家数" prop="countryCount" width="80" align="center" />
|
||||
<el-table-column label="附加费数" prop="surchargeCount" width="90" align="center" />
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="bms_product_effect_status" :value="row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="更新内容" prop="updateNote" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="120" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
title="价格"
|
||||
icon="Document"
|
||||
@click="excelFileRef.open(row)"
|
||||
v-hasPermi="['price:redline:query']"
|
||||
></el-button>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
title="红线价明细"
|
||||
icon="View"
|
||||
@click="emit('view-country', row)"
|
||||
v-hasPermi="['price:redline:query']"
|
||||
></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="loadList"
|
||||
/>
|
||||
<redline-excel-file-drawer ref="excelFileRef" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { listRedline } from '@/api/price/redline'
|
||||
import RedlineExcelFileDrawer from './RedlineExcelFileDrawer.vue'
|
||||
|
||||
const emit = defineEmits(['view-country'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_product_effect_status } = useDict('bms_product_effect_status')
|
||||
|
||||
const excelFileRef = ref()
|
||||
const title = '失效价格'
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const list = ref([])
|
||||
const total = ref(0)
|
||||
const dateRange = ref([])
|
||||
const queryParams = ref({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
productCode: undefined,
|
||||
productName: undefined,
|
||||
statusGroup: 'expired'
|
||||
})
|
||||
|
||||
function open() {
|
||||
visible.value = true
|
||||
resetQuery()
|
||||
}
|
||||
|
||||
function loadList() {
|
||||
loading.value = true
|
||||
const p = { ...queryParams.value }
|
||||
if (dateRange.value && dateRange.value.length === 2) {
|
||||
proxy.addDateRange(p, dateRange.value)
|
||||
}
|
||||
listRedline(p).then(res => {
|
||||
list.value = res.rows || []
|
||||
total.value = res.total || 0
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function resetQuery() {
|
||||
dateRange.value = []
|
||||
queryParams.value = {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
productCode: undefined,
|
||||
productName: undefined,
|
||||
statusGroup: 'expired'
|
||||
}
|
||||
loadList()
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
@@ -0,0 +1,167 @@
|
||||
<template>
|
||||
<el-dialog :title="title" v-model="visible" width="640px" append-to-body>
|
||||
<basic-form ref="formRef" v-model="form" :schemas="schemas" label-width="100px" />
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="visible = false">取 消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import BasicForm from '@/components/BasicForm'
|
||||
import { getRedline, addRedline, updateRedline } from '@/api/price/redline'
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const formRef = ref()
|
||||
const visible = ref(false)
|
||||
const title = ref('')
|
||||
const form = ref(emptyForm())
|
||||
|
||||
const schemas = computed(() => [
|
||||
{
|
||||
label: '产品代码',
|
||||
prop: 'productCode',
|
||||
component: 'input',
|
||||
placeholder: '如 WSP037',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
disabled: !!form.value.productId,
|
||||
props: { maxlength: 20 },
|
||||
rules: [{ required: true, message: '产品代码不能为空', trigger: 'blur' }]
|
||||
},
|
||||
{
|
||||
label: '产品名称',
|
||||
prop: 'productName',
|
||||
component: 'input',
|
||||
placeholder: '产品名称',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
props: { maxlength: 100 },
|
||||
rules: [{ required: true, message: '产品名称不能为空', trigger: 'blur' }]
|
||||
},
|
||||
{
|
||||
label: '时效等级',
|
||||
prop: 'serviceLevel',
|
||||
component: 'input',
|
||||
placeholder: '如 标准',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
props: { maxlength: 20 }
|
||||
},
|
||||
{
|
||||
label: '走货属性',
|
||||
prop: 'cargoAttr',
|
||||
component: 'input',
|
||||
placeholder: '普货/带电等',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
props: { maxlength: 100 }
|
||||
},
|
||||
{
|
||||
label: '目的区域',
|
||||
prop: 'destRegion',
|
||||
component: 'input',
|
||||
placeholder: '如 欧盟',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
props: { maxlength: 50 }
|
||||
},
|
||||
// {
|
||||
// label: '税模式',
|
||||
// prop: 'taxMode',
|
||||
// component: 'select',
|
||||
// placeholder: '请选择',
|
||||
// dict: 'bms_tax_mode',
|
||||
// span: 12,
|
||||
// width: '100%',
|
||||
// rules: [{ required: true, message: '请选择税模式', trigger: 'change' }]
|
||||
// },
|
||||
{
|
||||
label: '生效时间',
|
||||
prop: 'effectiveDate',
|
||||
component: 'datetime',
|
||||
placeholder: '选择时间',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
rules: [{ required: true, message: '生效时间不能为空', trigger: 'change' }]
|
||||
},
|
||||
{
|
||||
label: '失效时间',
|
||||
prop: 'expireDate',
|
||||
component: 'datetime',
|
||||
placeholder: '选择时间',
|
||||
span: 12,
|
||||
width: '100%'
|
||||
},
|
||||
{
|
||||
label: '更新内容',
|
||||
prop: 'updateNote',
|
||||
component: 'textarea',
|
||||
span: 24,
|
||||
width: '100%',
|
||||
props: { rows: 2, maxlength: 500 }
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
prop: 'remark',
|
||||
component: 'textarea',
|
||||
span: 24,
|
||||
width: '100%',
|
||||
props: { rows: 2, maxlength: 500 }
|
||||
}
|
||||
])
|
||||
|
||||
function emptyForm() {
|
||||
return {
|
||||
productId: undefined,
|
||||
productCode: undefined,
|
||||
productName: undefined,
|
||||
serviceLevel: undefined,
|
||||
cargoAttr: undefined,
|
||||
destRegion: undefined,
|
||||
updateNote: undefined,
|
||||
taxMode: 'TAX_INCLUDED',
|
||||
effectiveDate: undefined,
|
||||
expireDate: undefined,
|
||||
status: '0',
|
||||
remark: undefined
|
||||
}
|
||||
}
|
||||
|
||||
function reset() {
|
||||
form.value = emptyForm()
|
||||
nextTick(() => formRef.value?.clearValidate())
|
||||
}
|
||||
|
||||
function open(row) {
|
||||
reset()
|
||||
if (!row) {
|
||||
title.value = '新建红线价'
|
||||
visible.value = true
|
||||
return
|
||||
}
|
||||
getRedline(row.productId).then(res => {
|
||||
form.value = { ...emptyForm(), ...(res.data || {}) }
|
||||
title.value = '修改产品'
|
||||
visible.value = true
|
||||
nextTick(() => formRef.value?.clearValidate())
|
||||
})
|
||||
}
|
||||
|
||||
function submitForm() {
|
||||
formRef.value.validate(valid => {
|
||||
if (!valid) return
|
||||
const req = form.value.productId ? updateRedline(form.value) : addRedline(form.value)
|
||||
req.then(() => {
|
||||
proxy.$modal.msgSuccess('操作成功')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
@@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<el-drawer v-model="visible" size="920px" :title="title" append-to-body>
|
||||
<div class="mb8" style="display: flex; justify-content: space-between">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleRelAdd" v-hasPermi="['price:surcharge:add']">新增关联</el-button>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="list" border max-height="calc(100vh - 160px)" empty-text="该红线价暂无关联附加费">
|
||||
<el-table-column label="附加费名称" prop="scName" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="价格类型" width="100" align="center">
|
||||
<template #default="{ row }">{{ priceTypeLabel(row.priceType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计费方式" width="110" align="center">
|
||||
<template #default="{ row }">{{ chargeTypeLabel(row.chargeType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计费数值" width="140" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="charge-value">{{ formatChargeValue(row) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="取值方式" width="100" align="center">
|
||||
<template #default="{ row }">{{ roundModeLabel(row.roundMode) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="适用国家" width="110" align="center">
|
||||
<template #default="{ row }">{{ countryLabel(row.countryCode) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="作用范围" width="170" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.detailId == null" type="primary" size="small" effect="plain">产品级 · 全部明细</el-tag>
|
||||
<el-tag v-else type="warning" size="small" effect="plain">{{ row.countryName || '-' }} · {{ row.weightMin }}-{{ row.weightMax }}kg</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="String(row.ssCode).toLowerCase() === 'on' ? 'success' : 'info'" size="small">
|
||||
{{ String(row.ssCode).toLowerCase() === 'on' ? '有效' : '停用' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" prop="scNote" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="90" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="danger" icon="Delete" @click="handleRelDelete(row.relId)" v-hasPermi="['price:surcharge:remove']">解绑</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<redline-surcharge-rel-dialog ref="relRef" @success="handleRelSuccess" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted } from 'vue'
|
||||
import { listSurchargeByProduct, delSurchargeRel } from '@/api/price/surcharge'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
import RedlineSurchargeRelDialog from './RedlineSurchargeRelDialog.vue'
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_round_mode, bms_charge_type } = useDict('bms_round_mode', 'bms_charge_type')
|
||||
|
||||
const relRef = ref()
|
||||
const visible = ref(false)
|
||||
const title = ref('')
|
||||
const loading = ref(false)
|
||||
const list = ref([])
|
||||
const product = ref(null)
|
||||
const regionOptions = ref([])
|
||||
|
||||
function open(row) {
|
||||
product.value = row
|
||||
title.value = row.productCode + ' · ' + row.productName + ' · 附加费关联'
|
||||
visible.value = true
|
||||
loadList()
|
||||
}
|
||||
|
||||
function loadList() {
|
||||
if (!product.value) return
|
||||
loading.value = true
|
||||
listSurchargeByProduct(product.value.productCode, 'REDLINE').then(res => {
|
||||
const rows = res.data || []
|
||||
list.value = product.value && product.value.productId != null
|
||||
? rows.filter(r => Number(r.productId) === Number(product.value.productId) || r.priceType === 'REDLINE')
|
||||
: rows
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function handleRelAdd() {
|
||||
relRef.value.open(product.value)
|
||||
}
|
||||
|
||||
function handleRelSuccess() {
|
||||
loadList()
|
||||
emit('success')
|
||||
}
|
||||
|
||||
function handleRelDelete(relId) {
|
||||
proxy.$modal.confirm('是否确认解绑该附加费?').then(() => {
|
||||
return delSurchargeRel(relId)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('解绑成功')
|
||||
loadList()
|
||||
emit('success')
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function priceTypeLabel(val) {
|
||||
if (val === 'REDLINE') return '红线价'
|
||||
if (val === 'SALES') return '销售价'
|
||||
return '产品价'
|
||||
}
|
||||
|
||||
function chargeTypeLabel(val) {
|
||||
const found = bms_charge_type.value.find(c => c.value === val)
|
||||
return found ? found.label : (val || '-')
|
||||
}
|
||||
|
||||
function roundModeLabel(val) {
|
||||
const found = bms_round_mode.value.find(d => d.value === val)
|
||||
return found ? found.label : (val || '-')
|
||||
}
|
||||
|
||||
function formatChargeValue(row) {
|
||||
if (row.chargeValue == null) return '-'
|
||||
const v = Number(row.chargeValue)
|
||||
if (row.chargeType === 'RATE') return (v * 100).toFixed(2) + '%'
|
||||
return v + ' ' + (row.currency || 'CNY')
|
||||
}
|
||||
|
||||
function countryLabel(code) {
|
||||
if (!code) return '全部'
|
||||
const found = regionOptions.value.find(r => r.countryCode2 === code)
|
||||
return found ? (found.countryNameCn || found.countryNameEn || code) : code
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
listRegionOptions().then(res => {
|
||||
regionOptions.value = res.data || []
|
||||
})
|
||||
})
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mb8 { margin-bottom: 8px; }
|
||||
.charge-value { font-weight: 600; color: #d63031; }
|
||||
</style>
|
||||
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<el-dialog :title="title" v-model="visible" width="560px" append-to-body>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="附加费" prop="scId">
|
||||
<el-select v-model="form.scId" placeholder="请选择附加费" filterable style="width: 100%">
|
||||
<el-option v-for="s in surchargePool" :key="s.scId" :label="s.scName" :value="s.scId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="价格类型">
|
||||
<el-tag type="danger" effect="plain">红线价</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item label="适用国家" prop="countryCode">
|
||||
<el-select v-model="form.countryCode" clearable filterable placeholder="空=全部国家" style="width: 100%">
|
||||
<el-option
|
||||
v-for="r in regionOptions"
|
||||
:key="r.countryCode2"
|
||||
:label="(r.countryNameCn || r.countryNameEn || r.countryCode2) + ' (' + r.countryCode2 + ')'"
|
||||
:value="r.countryCode2"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="作用范围" prop="scope">
|
||||
<el-radio-group v-model="form.scope">
|
||||
<el-radio value="PRODUCT">产品级(全部明细)</el-radio>
|
||||
<el-radio value="DETAIL">明细级(指定国家×重量段)</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.scope === 'DETAIL'" label="明细" prop="detailId">
|
||||
<el-select v-model="form.detailId" placeholder="请选择明细" filterable style="width: 100%">
|
||||
<el-option v-for="d in countryList" :key="d.detailId" :label="detailLabel(d)" :value="d.detailId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
<el-button @click="visible = false">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { listRedlineCountries } from '@/api/price/redline'
|
||||
import { listSurcharge, addSurchargeRel } from '@/api/price/surcharge'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const formRef = ref()
|
||||
const visible = ref(false)
|
||||
const title = ref('新增附加费关联')
|
||||
const product = ref(null)
|
||||
const surchargePool = ref([])
|
||||
const countryList = ref([])
|
||||
const regionOptions = ref([])
|
||||
const form = ref({})
|
||||
const rules = {
|
||||
scId: [{ required: true, message: '请选择附加费', trigger: 'change' }],
|
||||
|
||||
}
|
||||
|
||||
function detailLabel(d) {
|
||||
const w = d.weightMin != null && d.weightMax != null ? (d.weightMin + '-' + d.weightMax + 'kg') : '-'
|
||||
return (d.countryName || d.countryCode || '-') + ' · ' + w
|
||||
}
|
||||
|
||||
function reset() {
|
||||
form.value = {
|
||||
scId: undefined,
|
||||
priceType: 'REDLINE',
|
||||
countryCode: undefined,
|
||||
scope: 'PRODUCT',
|
||||
detailId: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
function open(row) {
|
||||
product.value = row
|
||||
reset()
|
||||
visible.value = true
|
||||
listSurcharge({ ssCode: 'on', pageNum: 1, pageSize: 1000 }).then(res => {
|
||||
surchargePool.value = res.rows || []
|
||||
})
|
||||
listRegionOptions().then(res => {
|
||||
regionOptions.value = res.data || []
|
||||
})
|
||||
if (row && row.productCode) {
|
||||
listRedlineCountries(row.productCode, undefined, row.productId).then(res => {
|
||||
countryList.value = res.data || []
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function submit() {
|
||||
formRef.value.validate(valid => {
|
||||
if (!valid) return
|
||||
if (form.value.scope === 'DETAIL' && !form.value.detailId) {
|
||||
proxy.$modal.msgError('请选择明细')
|
||||
return
|
||||
}
|
||||
const payload = {
|
||||
scId: form.value.scId,
|
||||
productId: product.value ? product.value.productId : undefined,
|
||||
productCode: product.value ? product.value.productCode : undefined,
|
||||
detailId: form.value.scope === 'DETAIL' ? form.value.detailId : null,
|
||||
priceType: 'REDLINE',
|
||||
countryCode: form.value.countryCode || null
|
||||
}
|
||||
addSurchargeRel(payload).then(() => {
|
||||
proxy.$modal.msgSuccess('关联成功')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
@@ -0,0 +1,375 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-alert
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb16"
|
||||
title="导入前须先选择生效时间;红线价与国家明细均按此时间落库,上一版产品/明细失效时间设为该时间。多国家价表用「全部导入」,单国专线成本价用「按国家导入」。相同产品代码+生效日期不覆盖主数据。"
|
||||
/>
|
||||
|
||||
<basic-table
|
||||
ref="tableRef"
|
||||
:extra-params="extraParams"
|
||||
:columns="columns"
|
||||
:search-columns="searchColumns"
|
||||
:query="queryList"
|
||||
row-key="productId"
|
||||
>
|
||||
<template #toolbar="{ selection }">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['price:redline:add']">新建红线价</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-dropdown @command="handleImportCommand">
|
||||
<el-button type="info" plain icon="Upload" v-hasPermi="['price:redline:import']">
|
||||
导入 Excel<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="all">全部导入(多国家价表)</el-dropdown-item>
|
||||
<el-dropdown-item command="country">按国家导入(单国专线成本价)</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button plain icon="Clock" @click="expiredRef.open()" v-hasPermi="['price:redline:list']">失效价格</el-button>
|
||||
</el-col>
|
||||
</template>
|
||||
|
||||
<template #col-cargoAttr="{ row }">
|
||||
<el-tag type="primary" size="small" effect="plain">{{ row.cargoAttr || '-' }}</el-tag>
|
||||
</template>
|
||||
|
||||
<template #col-status="{ row }">
|
||||
<dict-tag :options="bms_product_effect_status" :value="row.status" />
|
||||
</template>
|
||||
|
||||
<template #col-action="{ row }">
|
||||
<el-button link type="primary" title="价格" icon="Document" @click="excelFileRef.open(row)" v-hasPermi="['price:redline:query']"></el-button>
|
||||
<el-button link type="primary" title="红线价明细" icon="View" @click="countryRef.open(row)" v-hasPermi="['price:redline:query']"></el-button>
|
||||
<el-button link type="primary" title="附加费" icon="Money" @click="surchargeRef.open(row)" v-hasPermi="['price:surcharge:query']"></el-button>
|
||||
<el-button title="编辑" link type="primary" icon="Edit" @click="handleUpdate(row)" v-hasPermi="['price:redline:edit']"></el-button>
|
||||
</template>
|
||||
</basic-table>
|
||||
|
||||
<redline-form-dialog ref="formRef" @success="() => tableRef.refresh()" />
|
||||
<redline-excel-file-drawer ref="excelFileRef" />
|
||||
<redline-country-drawer ref="countryRef" />
|
||||
<redline-surcharge-drawer ref="surchargeRef" @success="() => tableRef.refresh()" />
|
||||
<redline-expired-drawer ref="expiredRef" @view-country="(row) => countryRef.open(row)" />
|
||||
<excel-import-dialog
|
||||
ref="importRef"
|
||||
title="红线价 Excel 导入"
|
||||
width="560px"
|
||||
:show-update-support="false"
|
||||
template-url="/templates/product/product-import-all-template.xlsx"
|
||||
template-file-name="产品多国家价表导入模板"
|
||||
:import-desc="allImportDesc"
|
||||
:before-submit="validateImportEffectiveDate"
|
||||
:submit-handler="runImportAllAsync"
|
||||
@success="() => tableRef.refresh()"
|
||||
>
|
||||
<template #extra>
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="生效时间" required>
|
||||
<el-date-picker
|
||||
v-model="importEffectiveDate"
|
||||
type="datetime"
|
||||
format="YYYY-MM-DD HH:00"
|
||||
value-format="YYYY-MM-DD HH:00:00"
|
||||
popper-class="redline-import-hour-picker"
|
||||
placeholder="请选择生效时间"
|
||||
style="width: 100%"
|
||||
@change="onImportEffectiveTimeChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
</excel-import-dialog>
|
||||
<excel-import-dialog
|
||||
ref="countryImportRef"
|
||||
title="按国家导入"
|
||||
width="560px"
|
||||
:show-update-support="false"
|
||||
:before-submit="validateCountryImport"
|
||||
:import-desc="countryImportDesc"
|
||||
template-url="/templates/product/product-import-country-template.xlsx"
|
||||
template-file-name="产品按国家导入模板"
|
||||
:submit-handler="runImportCountryAsync"
|
||||
@success="() => tableRef.refresh()"
|
||||
>
|
||||
<template #extra>
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="生效时间" required>
|
||||
<el-date-picker
|
||||
v-model="importEffectiveDate"
|
||||
type="datetime"
|
||||
format="YYYY-MM-DD HH:00"
|
||||
value-format="YYYY-MM-DD HH:00:00"
|
||||
popper-class="redline-import-hour-picker"
|
||||
placeholder="请选择生效时间"
|
||||
style="width: 100%"
|
||||
@change="onImportEffectiveTimeChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="目的国家" required>
|
||||
<el-select v-model="importCountryCode" filterable clearable placeholder="请选择国家" style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in regionOptions"
|
||||
:key="item.countryCode2"
|
||||
:label="regionLabel(item)"
|
||||
:value="item.countryCode2"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
</excel-import-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="importProgressVisible"
|
||||
title="正在导入产品"
|
||||
width="420px"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
:show-close="false"
|
||||
append-to-body
|
||||
>
|
||||
<div class="import-progress">
|
||||
<el-progress :percentage="importProgressPercent" :status="importProgressStatus" />
|
||||
<div class="import-progress-msg">{{ importProgressMessage }}</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PriceProduct">
|
||||
import ExcelImportDialog from '@/components/ExcelImportDialog'
|
||||
import RedlineFormDialog from './components/RedlineFormDialog.vue'
|
||||
import RedlineExcelFileDrawer from './components/RedlineExcelFileDrawer.vue'
|
||||
import RedlineCountryDrawer from './components/RedlineCountryDrawer.vue'
|
||||
import RedlineSurchargeDrawer from './components/RedlineSurchargeDrawer.vue'
|
||||
import RedlineExpiredDrawer from './components/RedlineExpiredDrawer.vue'
|
||||
import { listRedline, importRedlineExcelAsync, importRedlineCountryExcelAsync } from '@/api/price/redline'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
|
||||
const { bms_product_effect_status } = useDict('bms_product_effect_status')
|
||||
|
||||
const extraParams = { statusGroup: 'active' }
|
||||
const tableRef = ref()
|
||||
const formRef = ref()
|
||||
const excelFileRef = ref()
|
||||
const countryRef = ref()
|
||||
const surchargeRef = ref()
|
||||
const expiredRef = ref()
|
||||
const importRef = ref()
|
||||
const countryImportRef = ref()
|
||||
const importCountryCode = ref('')
|
||||
const importEffectiveDate = ref('')
|
||||
|
||||
function pad2(n) {
|
||||
return String(n).padStart(2, '0')
|
||||
}
|
||||
|
||||
function formatImportHour(d) {
|
||||
if (!d || Number.isNaN(d.getTime())) return undefined
|
||||
return d.getFullYear() + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate())
|
||||
+ ' ' + pad2(d.getHours()) + ':00:00'
|
||||
}
|
||||
|
||||
function normalizeImportToHour(val) {
|
||||
if (val == null || val === '') return val
|
||||
if (val instanceof Date) return formatImportHour(val)
|
||||
const s = String(val).trim().replace('T', ' ')
|
||||
const m = s.match(/^(\d{4}-\d{2}-\d{2})[ ](\d{2})/)
|
||||
if (m) return m[1] + ' ' + m[2] + ':00:00'
|
||||
if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return s + ' 00:00:00'
|
||||
return formatImportHour(new Date(s.replace(/-/g, '/'))) || val
|
||||
}
|
||||
|
||||
function onImportEffectiveTimeChange(val) {
|
||||
importEffectiveDate.value = normalizeImportToHour(val) || ''
|
||||
}
|
||||
const regionOptions = ref([])
|
||||
const importProgressVisible = ref(false)
|
||||
const importProgressPercent = ref(0)
|
||||
const importProgressMessage = ref('')
|
||||
const importProgressStatus = ref(undefined)
|
||||
const allImportDesc = [
|
||||
'适用多国家价表(B2C 小包价表等),按目录 sheet 匹配国家导入。',
|
||||
'必选生效时间:产品与 product_country 明细均按此时间计费;上一版产品/明细失效时间设为该时间。',
|
||||
'请在弹窗底部下载模板,按模板格式整理后上传。相同产品代码+生效日期不覆盖主数据。'
|
||||
]
|
||||
const countryImportDesc = [
|
||||
'选择目的国家后上传专线成本价表,目录中的产品都会记到该国家。',
|
||||
'必选生效时间:产品与 product_country 明细均按此时间计费;上一版产品/明细失效时间设为该时间。',
|
||||
'邮编、赔偿标准等 sheet 不导入。可在弹窗底部下载模板。'
|
||||
]
|
||||
|
||||
const columns = [
|
||||
{ prop: 'productCode', label: '产品代码', minWidth: 110 },
|
||||
{ prop: 'productName', label: '产品名称', minWidth: 140, showOverflowTooltip: true },
|
||||
{ prop: 'serviceLevel', label: '时效等级', width: 90, align: 'center' },
|
||||
{ prop: 'cargoAttr', label: '走货属性', minWidth: 120, slot: 'cargoAttr' },
|
||||
{ prop: 'destRegion', label: '目的区域', width: 90, align: 'center' },
|
||||
{ prop: 'effectiveDate', label: '生效时间', width: 160, align: 'center' },
|
||||
{ prop: 'expireDate', label: '失效时间', width: 160, align: 'center' },
|
||||
{ prop: 'countryCount', label: '国家数', width: 80, align: 'center' },
|
||||
{ prop: 'surchargeCount', label: '附加费数', width: 90, align: 'center' },
|
||||
{ prop: 'status', label: '状态', width: 90, align: 'center', slot: 'status' },
|
||||
{ prop: 'updateNote', label: '更新内容', minWidth: 160, showOverflowTooltip: true },
|
||||
{ prop: 'action', label: '操作', width: 240, fixed: 'right', slot: 'action' }
|
||||
]
|
||||
|
||||
const searchColumns = [
|
||||
{ prop: 'productCode', label: '产品代码', component: 'input', placeholder: '产品代码' },
|
||||
{ prop: 'productName', label: '产品名称', component: 'input', placeholder: '产品名称' }
|
||||
]
|
||||
|
||||
function queryList(params) {
|
||||
return listRedline(params)
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
formRef.value.open()
|
||||
}
|
||||
|
||||
function handleUpdate(row) {
|
||||
formRef.value.open(row)
|
||||
}
|
||||
|
||||
function handleImportCommand(command) {
|
||||
if (command === 'country') {
|
||||
handleCountryImport()
|
||||
return
|
||||
}
|
||||
handleImport()
|
||||
}
|
||||
|
||||
function handleImport() {
|
||||
importEffectiveDate.value = ''
|
||||
importRef.value.open()
|
||||
}
|
||||
|
||||
function regionLabel(item) {
|
||||
const name = item.countryNameCn || item.countryNameEn || ''
|
||||
const code = item.countryCode2 || ''
|
||||
return name && code ? name + ' (' + code + ')' : (name || code)
|
||||
}
|
||||
|
||||
function loadRegionOptions() {
|
||||
if (regionOptions.value.length) return
|
||||
listRegionOptions().then(res => {
|
||||
regionOptions.value = res.data || []
|
||||
})
|
||||
}
|
||||
|
||||
function handleCountryImport() {
|
||||
importCountryCode.value = ''
|
||||
importEffectiveDate.value = ''
|
||||
loadRegionOptions()
|
||||
countryImportRef.value.open()
|
||||
}
|
||||
|
||||
function validateImportEffectiveDate() {
|
||||
if (!importEffectiveDate.value) {
|
||||
return '请先选择生效时间'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function validateCountryImport() {
|
||||
const effErr = validateImportEffectiveDate()
|
||||
if (effErr) return effErr
|
||||
if (!importCountryCode.value) {
|
||||
return '请先选择目的国家'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function applyImportProgress(t) {
|
||||
importProgressPercent.value = Math.min(100, Number(t.percent) || 0)
|
||||
if (t.status === 'PENDING') importProgressMessage.value = '排队中…'
|
||||
else if (t.status === 'RUNNING') {
|
||||
const m = t.message || ''
|
||||
if (m === 'parsing excel') importProgressMessage.value = '正在解析价表…'
|
||||
else if (m === 'finishing') importProgressMessage.value = '收尾中…'
|
||||
else if (m === 'queued') importProgressMessage.value = '排队中…'
|
||||
else if (m.indexOf('importing ') === 0) {
|
||||
const rest = m.slice('importing '.length)
|
||||
importProgressMessage.value = '正在导入产品 ' + rest
|
||||
} else importProgressMessage.value = m || '正在导入…'
|
||||
} else if (t.status === 'SUCCESS') {
|
||||
importProgressMessage.value = t.message || '导入完成'
|
||||
importProgressStatus.value = 'success'
|
||||
} else if (t.status === 'FAIL') {
|
||||
importProgressMessage.value = t.error || t.message || '导入失败'
|
||||
importProgressStatus.value = 'exception'
|
||||
}
|
||||
}
|
||||
|
||||
async function runImportWithProgress(runner) {
|
||||
importProgressVisible.value = true
|
||||
importProgressPercent.value = 0
|
||||
importProgressMessage.value = '上传并解析中…'
|
||||
importProgressStatus.value = undefined
|
||||
try {
|
||||
const { task } = await runner(applyImportProgress)
|
||||
importProgressPercent.value = 100
|
||||
importProgressStatus.value = 'success'
|
||||
return (task && task.message) ? task.message : '导入完成'
|
||||
} catch (e) {
|
||||
importProgressStatus.value = 'exception'
|
||||
const tip = (e && e.task && e.task.error) || (e && e.message) || '导入失败'
|
||||
importProgressMessage.value = tip
|
||||
await new Promise(resolve => setTimeout(resolve, 600))
|
||||
throw e
|
||||
} finally {
|
||||
importProgressVisible.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function runImportAllAsync(uploadFile) {
|
||||
const raw = uploadFile && (uploadFile.raw || uploadFile)
|
||||
if (!raw) {
|
||||
throw new Error('请先选择文件')
|
||||
}
|
||||
if (!importEffectiveDate.value) {
|
||||
throw new Error('请先选择生效时间')
|
||||
}
|
||||
const eff = importEffectiveDate.value
|
||||
return runImportWithProgress((onProgress) => importRedlineExcelAsync(raw, eff, onProgress))
|
||||
}
|
||||
|
||||
async function runImportCountryAsync(uploadFile) {
|
||||
const raw = uploadFile && (uploadFile.raw || uploadFile)
|
||||
if (!raw) {
|
||||
throw new Error('请先选择文件')
|
||||
}
|
||||
if (!importEffectiveDate.value) {
|
||||
throw new Error('请先选择生效时间')
|
||||
}
|
||||
if (!importCountryCode.value) {
|
||||
throw new Error('请先选择目的国家')
|
||||
}
|
||||
const code = importCountryCode.value
|
||||
const eff = importEffectiveDate.value
|
||||
return runImportWithProgress((onProgress) => importRedlineCountryExcelAsync(raw, code, eff, onProgress))
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mb16 { margin-bottom: 16px; }
|
||||
.import-progress { padding: 8px 4px 4px; }
|
||||
.import-progress-msg {
|
||||
margin-top: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
word-break: break-word;
|
||||
max-height: 160px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -11,13 +11,14 @@
|
||||
</div>
|
||||
<div class="panel-actions">
|
||||
<el-button @click="close">关闭</el-button>
|
||||
<el-button type="primary" :disabled="!priceSetId" @click="close">完成</el-button>
|
||||
<el-button type="primary" :loading="saving" :disabled="!priceSetId" @click="finish">完成</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<step-details
|
||||
v-if="loaded"
|
||||
ref="detailsRef"
|
||||
:details="details"
|
||||
:products="products"
|
||||
:price-set-id="priceSetId"
|
||||
@@ -25,9 +26,13 @@
|
||||
@update:psv-id="v => { if (v != null && v !== '') version.psvId = v }"
|
||||
:set-type="setType"
|
||||
:price-build-mode="version.priceBuildMode"
|
||||
@update:price-build-mode="onPriceBuildModeUpdate"
|
||||
:effective-time="version.effectiveTime"
|
||||
:version-no="version.versionNo"
|
||||
:version-status="version.status"
|
||||
:ref-data="refData"
|
||||
:live-persist="true"
|
||||
:build-mode-dirty="buildModeDirty"
|
||||
header-title="编辑产品价格"
|
||||
/>
|
||||
</div>
|
||||
@@ -38,7 +43,8 @@
|
||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
||||
import StepDetails from './StepDetails.vue'
|
||||
import { usePriceSetRefData } from '../../composables/usePriceSetRefData'
|
||||
import { getPriceSet } from '@/api/price/set'
|
||||
import { isBuildModeLockedVersion } from '../../utils/priceSet'
|
||||
import { getPriceSet, savePriceSetAsync } from '@/api/price/set'
|
||||
|
||||
const props = defineProps({
|
||||
priceSetId: { type: [Number, String], default: undefined },
|
||||
@@ -53,9 +59,18 @@ const refData = usePriceSetRefData()
|
||||
const loading = ref(false)
|
||||
const loaded = ref(false)
|
||||
const setType = ref('FIXED')
|
||||
const version = reactive({ psvId: undefined, versionNo: 'V1', effectiveTime: undefined, priceBuildMode: undefined })
|
||||
const priceSetName = ref('')
|
||||
const version = reactive({ psvId: undefined, versionNo: 'V1', effectiveTime: undefined, status: undefined, priceBuildMode: undefined })
|
||||
const savedPriceBuildMode = ref(undefined)
|
||||
const saving = ref(false)
|
||||
const details = ref([])
|
||||
const products = ref([])
|
||||
const detailsRef = ref()
|
||||
/** Snapshot of products under the last saved build mode (restore if switch back before Complete) */
|
||||
const savedProductsSnapshot = ref([])
|
||||
const buildModeDirty = computed(() =>
|
||||
String(version.priceBuildMode || '') !== String(savedPriceBuildMode.value || '')
|
||||
)
|
||||
|
||||
const title = computed(() => '编辑产品价格 · ' + (version.versionNo || ''))
|
||||
|
||||
@@ -70,6 +85,7 @@ function load() {
|
||||
getPriceSet(id).then(res => {
|
||||
const data = res.data || {}
|
||||
setType.value = data.setType || 'FIXED'
|
||||
priceSetName.value = data.priceSetName || ''
|
||||
|
||||
const versions = data.versions || []
|
||||
const qPsv = props.psvId
|
||||
@@ -78,16 +94,107 @@ function load() {
|
||||
version.psvId = current.psvId
|
||||
version.versionNo = current.versionNo || 'V1'
|
||||
version.effectiveTime = current.effectiveTime
|
||||
version.status = current.status
|
||||
version.priceBuildMode = current.priceBuildMode
|
||||
savedPriceBuildMode.value = current.priceBuildMode
|
||||
|
||||
details.value = []
|
||||
products.value = (current.products || []).map(p => ({ ...p }))
|
||||
savedProductsSnapshot.value = products.value.map(p => ({ ...p }))
|
||||
loaded.value = true
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function onPriceBuildModeUpdate(mode) {
|
||||
if (!mode || isBuildModeLockedVersion(version.status)) return
|
||||
if (mode === version.priceBuildMode) return
|
||||
const leavingSaved = String(version.priceBuildMode || '') === String(savedPriceBuildMode.value || '')
|
||||
if (leavingSaved) {
|
||||
savedProductsSnapshot.value = (products.value || []).map(p => ({ ...p }))
|
||||
}
|
||||
version.priceBuildMode = mode
|
||||
if (detailsRef.value && detailsRef.value.clearLocalDraft) {
|
||||
detailsRef.value.clearLocalDraft()
|
||||
}
|
||||
details.value = []
|
||||
const backToSaved = String(mode || '') === String(savedPriceBuildMode.value || '')
|
||||
if (backToSaved) {
|
||||
products.value = (savedProductsSnapshot.value || []).map(p => ({ ...p }))
|
||||
if (!products.value.length) {
|
||||
reloadSavedProducts()
|
||||
} else {
|
||||
proxy.$modal.msgSuccess("已恢复原建价方式及产品列表(未保存,库数据未变)")
|
||||
}
|
||||
return
|
||||
}
|
||||
products.value = []
|
||||
proxy.$modal.msgSuccess("已切换建价方式(本地),请点「完成」保存后再拉取或导入;切回原方式可恢复列表")
|
||||
}
|
||||
|
||||
function reloadSavedProducts() {
|
||||
const id = props.priceSetId
|
||||
if (!id) return
|
||||
loading.value = true
|
||||
getPriceSet(id).then(res => {
|
||||
const data = res.data || {}
|
||||
const versions = data.versions || []
|
||||
const qPsv = props.psvId || version.psvId
|
||||
const byQuery = qPsv != null ? versions.find(v => String(v.psvId) === String(qPsv)) : null
|
||||
const current = byQuery || data.version || versions[0] || {}
|
||||
products.value = (current.products || []).map(p => ({ ...p }))
|
||||
savedProductsSnapshot.value = products.value.map(p => ({ ...p }))
|
||||
proxy.$modal.msgSuccess("已恢复原建价方式及产品列表(未保存,库数据未变)")
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
async function finish() {
|
||||
if (!props.priceSetId) {
|
||||
close()
|
||||
return
|
||||
}
|
||||
if (!buildModeDirty.value) {
|
||||
close()
|
||||
return
|
||||
}
|
||||
if (!version.priceBuildMode) {
|
||||
proxy.$modal.msgWarning("请先选择创建价格方式")
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
const payload = {
|
||||
priceSetId: props.priceSetId,
|
||||
priceSetName: priceSetName.value,
|
||||
setType: setType.value || 'FIXED',
|
||||
version: {
|
||||
psvId: version.psvId,
|
||||
versionNo: version.versionNo,
|
||||
priceBuildMode: version.priceBuildMode
|
||||
}
|
||||
}
|
||||
await savePriceSetAsync(payload)
|
||||
savedPriceBuildMode.value = version.priceBuildMode
|
||||
savedProductsSnapshot.value = (products.value || []).map(p => ({ ...p }))
|
||||
await nextTick()
|
||||
if (version.priceBuildMode === 'PULL' && detailsRef.value && detailsRef.value.pullAllFromLibrary) {
|
||||
await detailsRef.value.pullAllFromLibrary({ silent: true })
|
||||
proxy.$modal.msgSuccess("建价方式已保存并清空旧明细,已重新拉取产品列表")
|
||||
} else {
|
||||
proxy.$modal.msgSuccess("建价方式已保存并清空旧明细,可导入 Excel 建价")
|
||||
}
|
||||
close()
|
||||
} catch (e) {
|
||||
const msg = (e && e.task && e.task.error) || (e && e.message) || "保存失败"
|
||||
proxy.$modal.msgError(msg)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
@@ -17,21 +17,21 @@
|
||||
v-if="showImportAction"
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="(livePersist && !priceSetId) || pulling"
|
||||
:disabled="(livePersist && !priceSetId) || pulling || buildModeDirty"
|
||||
@click="openImport"
|
||||
>{{ importActionLabel }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-if="showBuildChoice" class="build-choice">
|
||||
<div class="build-choice">
|
||||
<p class="build-choice__tip">创建价格方式</p>
|
||||
<div class="build-choice__cards">
|
||||
<button
|
||||
type="button"
|
||||
class="build-card build-card--pull"
|
||||
:class="{ selected: isPullBuildMode(priceBuildMode) }"
|
||||
:disabled="choosingMode"
|
||||
:disabled="buildModeLocked || choosingMode"
|
||||
@click="chooseBuildMode('PULL')"
|
||||
>
|
||||
<div class="build-card__title">按产品价建价</div>
|
||||
@@ -41,7 +41,7 @@
|
||||
type="button"
|
||||
class="build-card build-card--import"
|
||||
:class="{ selected: isImportBuildMode(priceBuildMode) }"
|
||||
:disabled="!isFixedType(setType) || choosingMode"
|
||||
:disabled="buildModeLocked || !isFixedType(setType) || choosingMode"
|
||||
@click="chooseBuildMode('IMPORT')"
|
||||
>
|
||||
<div class="build-card__title">Excel 导入建价</div>
|
||||
@@ -152,6 +152,7 @@ import { useDetailCascade } from '../../composables/usePriceSetRefData'
|
||||
import {
|
||||
createEmptyDetailRow,
|
||||
formatWeightLabel,
|
||||
isBuildModeLockedVersion,
|
||||
isDiscountType,
|
||||
isFixedType,
|
||||
isImportBuildMode,
|
||||
@@ -174,10 +175,14 @@ const props = defineProps({
|
||||
refData: { type: Object, required: true },
|
||||
headerTitle: { type: String, default: '第 2 步 · 编辑产品价格' },
|
||||
/** true=edit live DB; false=create local draft until finish */
|
||||
livePersist: { type: Boolean, default: true }
|
||||
livePersist: { type: Boolean, default: true },
|
||||
/** Version status: draft can change build mode; started versions lock it */
|
||||
versionStatus: { type: [String, Number], default: undefined },
|
||||
/** True when build mode changed locally and not saved yet */
|
||||
buildModeDirty: { type: Boolean, default: false }
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:psvId', 'update:priceBuildMode'])
|
||||
const emit = defineEmits(['update:psvId', 'update:priceBuildMode', 'update:pefId'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_tax_mode } = useDict('bms_tax_mode')
|
||||
const { hydrateRow } = useDetailCascade(props.refData)
|
||||
@@ -221,14 +226,11 @@ const importProgressStatus = ref(undefined)
|
||||
const progressDialogTitle = ref('正在导入价格')
|
||||
const hasBuildMode = computed(() => {
|
||||
if (isPullBuildMode(props.priceBuildMode) || isImportBuildMode(props.priceBuildMode)) return true
|
||||
// Legacy / already has products: skip choice cards
|
||||
// Legacy / already has products: treat as build mode ready
|
||||
return (props.products || []).some(p => p && p.productCode)
|
||||
})
|
||||
/** Create/newVersion only: show choice until a mode is picked */
|
||||
const showBuildChoice = computed(() => {
|
||||
if (props.livePersist) return false
|
||||
return !isPullBuildMode(props.priceBuildMode) && !isImportBuildMode(props.priceBuildMode)
|
||||
})
|
||||
/** Started (non-draft) versions: show cards but disable switching */
|
||||
const buildModeLocked = computed(() => isBuildModeLockedVersion(props.versionStatus))
|
||||
const choosingMode = ref(false)
|
||||
const isModifyImport = computed(() => {
|
||||
if (isPullBuildMode(props.priceBuildMode)) return true
|
||||
@@ -255,7 +257,6 @@ const importDesc = computed(() => {
|
||||
})
|
||||
|
||||
const typeHint = computed(() => {
|
||||
if (props.livePersist) return ''
|
||||
if (isPullBuildMode(props.priceBuildMode)) return '· 按产品价建价'
|
||||
if (isImportBuildMode(props.priceBuildMode)) return '· Excel 导入'
|
||||
if (hasBuildMode.value) return '· 当前:' + setTypeLabel(props.setType)
|
||||
@@ -367,7 +368,7 @@ const pulling = ref(false)
|
||||
function noop() {}
|
||||
|
||||
async function chooseBuildMode(mode) {
|
||||
if (!mode || choosingMode.value || props.livePersist) return
|
||||
if (!mode || choosingMode.value || buildModeLocked.value) return
|
||||
if (mode === props.priceBuildMode) return
|
||||
choosingMode.value = true
|
||||
try {
|
||||
@@ -405,6 +406,10 @@ function applyLocalDraft(products, details) {
|
||||
}
|
||||
|
||||
async function openImport() {
|
||||
if (props.buildModeDirty) {
|
||||
proxy.$modal.msgWarning("请先点「完成」保存建价方式")
|
||||
return
|
||||
}
|
||||
if (props.livePersist && !props.priceSetId) {
|
||||
proxy.$modal.msgWarning('缺少套餐ID')
|
||||
return
|
||||
@@ -442,6 +447,9 @@ async function runImportAsync(uploadFile) {
|
||||
details: isModifyImport.value ? (props.details || []) : undefined
|
||||
})
|
||||
const data = res.data || {}
|
||||
if (data.pefId != null) {
|
||||
emit('update:pefId', data.pefId)
|
||||
}
|
||||
const products = isModifyImport.value ? (props.products || []) : (data.products || [])
|
||||
applyLocalDraft(products, data.details || [])
|
||||
importProgressPercent.value = 100
|
||||
|
||||
@@ -314,7 +314,7 @@ export function useDetailCascade(refData) {
|
||||
const row = toEditableDetailRow(d)
|
||||
if (!row.productCode) return row
|
||||
// Do NOT prefetch /surcharge/byProduct here: applySetData hydrates every detail row
|
||||
// on step-1 load; use version snapshot row.surcharges instead. Fetch on demand in picker.
|
||||
// on step-1 load; use SALES rels on row.surcharges instead. Fetch on demand in picker.
|
||||
if (setType !== 'FIXED') return row
|
||||
// Bulk load from DB already has productCountryId + weight bounds: normalize locally,
|
||||
// do not fire /countries per detail row (was stampeding thousands of identical requests).
|
||||
|
||||
@@ -26,9 +26,12 @@
|
||||
:set-type="form.basic.setType"
|
||||
:price-build-mode="form.version.priceBuildMode"
|
||||
@update:price-build-mode="onPriceBuildModeUpdate"
|
||||
@update:pef-id="v => { draftPefId.value = v }"
|
||||
:version-no="form.version.versionNo"
|
||||
:version-status="form.version.status"
|
||||
:ref-data="refData"
|
||||
:live-persist="livePersist"
|
||||
:build-mode-dirty="buildModeDirty"
|
||||
:header-title="detailsHeaderTitle"
|
||||
/>
|
||||
|
||||
@@ -64,6 +67,7 @@ import StepDetails from './components/create/StepDetails.vue'
|
||||
import { usePriceSetRefData } from './composables/usePriceSetRefData'
|
||||
import {
|
||||
createEmptyBasicInfo,
|
||||
isBuildModeLockedVersion,
|
||||
nextVersionNo,
|
||||
toCustomerPayload,
|
||||
toDetailPayload
|
||||
@@ -102,11 +106,18 @@ const detailsHeaderTitle = computed(() =>
|
||||
const form = reactive({
|
||||
priceSetId: undefined,
|
||||
basic: createEmptyBasicInfo(),
|
||||
version: { psvId: undefined, versionNo: 'V1', effectiveTime: undefined, expireTime: undefined, priceBuildMode: undefined },
|
||||
version: { psvId: undefined, versionNo: 'V1', effectiveTime: undefined, expireTime: undefined, status: undefined, priceBuildMode: undefined },
|
||||
details: [],
|
||||
products: [],
|
||||
customers: []
|
||||
})
|
||||
/** Draft IMPORT Excel attachment id; stamped onto prc_price_set_product on finish */
|
||||
const draftPefId = ref(undefined)
|
||||
const savedPriceBuildMode = ref(undefined)
|
||||
const savedProductsSnapshot = ref([])
|
||||
const buildModeDirty = computed(() =>
|
||||
String(form.version.priceBuildMode || '') !== String(savedPriceBuildMode.value || '')
|
||||
)
|
||||
|
||||
function mapSaveProgressMessage(message) {
|
||||
const m = message || ''
|
||||
@@ -178,7 +189,33 @@ async function finishEdit() {
|
||||
goBack()
|
||||
return
|
||||
}
|
||||
proxy.$modal.msgSuccess('修改已实时落库')
|
||||
if (buildModeDirty.value) {
|
||||
if (!form.version.priceBuildMode) {
|
||||
proxy.$modal.msgWarning("请先选择创建价格方式")
|
||||
return
|
||||
}
|
||||
creating.value = true
|
||||
try {
|
||||
const payload = buildPayload()
|
||||
delete payload.pullFromLibrary
|
||||
delete payload.forcePullLibrary
|
||||
delete payload.details
|
||||
await runSaveWithProgress(payload)
|
||||
savedPriceBuildMode.value = form.version.priceBuildMode
|
||||
savedProductsSnapshot.value = (form.products || []).map(p => ({ ...p }))
|
||||
await nextTick()
|
||||
if (form.version.priceBuildMode === 'PULL' && detailsRef.value && detailsRef.value.pullAllFromLibrary) {
|
||||
await detailsRef.value.pullAllFromLibrary({ silent: true })
|
||||
}
|
||||
proxy.$modal.msgSuccess("建价方式已保存")
|
||||
} catch (e) {
|
||||
return
|
||||
} finally {
|
||||
creating.value = false
|
||||
}
|
||||
} else {
|
||||
proxy.$modal.msgSuccess("修改已实时落库")
|
||||
}
|
||||
const obj = {
|
||||
path: '/customer/setDetail',
|
||||
query: { priceSetId: form.priceSetId }
|
||||
@@ -264,6 +301,9 @@ function buildPayload(opts = {}) {
|
||||
priceBuildMode: version.priceBuildMode || undefined
|
||||
}
|
||||
}
|
||||
if (draftPefId.value != null) {
|
||||
payload.pefId = draftPefId.value
|
||||
}
|
||||
if (opts.forceDetails || hasUnsavedDetail) {
|
||||
payload.details = detailRows.map(d => {
|
||||
const p = toDetailPayload(d)
|
||||
@@ -299,42 +339,62 @@ function onPsvIdUpdate(psvId) {
|
||||
}
|
||||
|
||||
/** Step2 chose PULL / IMPORT: edit live-saves mode; create only local + optional preview pull. */
|
||||
async function onPriceBuildModeUpdate(mode) {
|
||||
function onPriceBuildModeUpdate(mode) {
|
||||
if (!mode) return
|
||||
const prev = form.version.priceBuildMode
|
||||
if (prev === mode) return
|
||||
form.version.priceBuildMode = mode
|
||||
try {
|
||||
// Create/copy: switching build mode clears the product table before reload/import.
|
||||
if (!livePersist.value && prev) {
|
||||
form.details.splice(0, form.details.length)
|
||||
form.products.splice(0, form.products.length)
|
||||
if (detailsRef.value && detailsRef.value.clearLocalDraft) {
|
||||
detailsRef.value.clearLocalDraft()
|
||||
}
|
||||
}
|
||||
if (livePersist.value) {
|
||||
const payload = buildPayload()
|
||||
delete payload.pullFromLibrary
|
||||
delete payload.forcePullLibrary
|
||||
delete payload.details
|
||||
await runSaveWithProgress(payload)
|
||||
}
|
||||
await nextTick()
|
||||
if (mode === 'PULL' && detailsRef.value && detailsRef.value.pullAllFromLibrary) {
|
||||
const hasProducts = (form.products || []).some(p => p && p.productCode)
|
||||
if (!hasProducts) {
|
||||
await detailsRef.value.pullAllFromLibrary({ silent: true })
|
||||
proxy.$modal.msgSuccess('已拉取产品列表,可继续编辑价格')
|
||||
} else if (prev !== mode) {
|
||||
proxy.$modal.msgSuccess('已切换为按产品价建价,可导入 Excel 修改价格')
|
||||
}
|
||||
} else if (mode === 'IMPORT' && prev !== mode) {
|
||||
proxy.$modal.msgSuccess('请导入 Excel 建价')
|
||||
}
|
||||
} catch (e) {
|
||||
form.version.priceBuildMode = prev
|
||||
if (isBuildModeLockedVersion(form.version.status)) return
|
||||
if (mode === form.version.priceBuildMode) return
|
||||
const leavingSaved = livePersist.value
|
||||
&& String(form.version.priceBuildMode || '') === String(savedPriceBuildMode.value || '')
|
||||
if (leavingSaved) {
|
||||
savedProductsSnapshot.value = (form.products || []).map(p => ({ ...p }))
|
||||
}
|
||||
form.version.priceBuildMode = mode
|
||||
if (mode !== 'IMPORT') {
|
||||
draftPefId.value = undefined
|
||||
}
|
||||
form.details.splice(0, form.details.length)
|
||||
if (detailsRef.value && detailsRef.value.clearLocalDraft) {
|
||||
detailsRef.value.clearLocalDraft()
|
||||
}
|
||||
if (livePersist.value) {
|
||||
const backToSaved = String(mode || '') === String(savedPriceBuildMode.value || '')
|
||||
if (backToSaved) {
|
||||
form.products.splice(0, form.products.length, ...(savedProductsSnapshot.value || []).map(p => ({ ...p })))
|
||||
if (!form.products.length && form.priceSetId) {
|
||||
reloadSavedProductsForCreate()
|
||||
} else {
|
||||
proxy.$modal.msgSuccess("已恢复原建价方式及产品列表(未保存,库数据未变)")
|
||||
}
|
||||
return
|
||||
}
|
||||
form.products.splice(0, form.products.length)
|
||||
proxy.$modal.msgSuccess("已切换建价方式(本地),请点「完成」保存后再拉取或导入;切回原方式可恢复列表")
|
||||
return
|
||||
}
|
||||
form.products.splice(0, form.products.length)
|
||||
if (mode === 'PULL' && detailsRef.value && detailsRef.value.pullAllFromLibrary) {
|
||||
nextTick(() => {
|
||||
detailsRef.value.pullAllFromLibrary({ silent: true }).then(() => {
|
||||
proxy.$modal.msgSuccess("已拉取产品列表,可继续编辑价格")
|
||||
}).catch(() => {})
|
||||
})
|
||||
} else if (mode === 'IMPORT') {
|
||||
proxy.$modal.msgSuccess("请导入 Excel 建价")
|
||||
}
|
||||
}
|
||||
|
||||
function reloadSavedProductsForCreate() {
|
||||
getPriceSet(form.priceSetId).then(res => {
|
||||
const data = res.data || {}
|
||||
const versions = data.versions || []
|
||||
const qPsv = form.version.psvId
|
||||
const byQuery = qPsv != null ? versions.find(v => String(v.psvId) === String(qPsv)) : null
|
||||
const current = byQuery || data.version || versions[0] || {}
|
||||
const list = (current.products || []).map(p => ({ ...p }))
|
||||
form.products.splice(0, form.products.length, ...list)
|
||||
savedProductsSnapshot.value = list.map(p => ({ ...p }))
|
||||
proxy.$modal.msgSuccess("已恢复原建价方式及产品列表(未保存,库数据未变)")
|
||||
})
|
||||
}
|
||||
|
||||
function applySetData(data, asCopy, asNewVersion) {
|
||||
@@ -355,7 +415,10 @@ function applySetData(data, asCopy, asNewVersion) {
|
||||
form.version.versionNo = nextVersionNo(versions)
|
||||
form.version.effectiveTime = undefined
|
||||
form.version.expireTime = undefined
|
||||
form.version.status = undefined
|
||||
form.version.priceBuildMode = undefined
|
||||
draftPefId.value = undefined
|
||||
savedPriceBuildMode.value = undefined
|
||||
form.details = []
|
||||
form.products = []
|
||||
} else if (asNewVersion) {
|
||||
@@ -364,7 +427,10 @@ function applySetData(data, asCopy, asNewVersion) {
|
||||
form.version.versionNo = current.versionNo || nextVersionNo(versions)
|
||||
form.version.effectiveTime = undefined
|
||||
form.version.expireTime = undefined
|
||||
form.version.status = current.status || '0'
|
||||
form.version.priceBuildMode = undefined
|
||||
draftPefId.value = undefined
|
||||
savedPriceBuildMode.value = undefined
|
||||
form.details = []
|
||||
form.products = []
|
||||
} else {
|
||||
@@ -372,9 +438,13 @@ function applySetData(data, asCopy, asNewVersion) {
|
||||
form.version.versionNo = current.versionNo || nextVersionNo(versions)
|
||||
form.version.effectiveTime = current.effectiveTime
|
||||
form.version.expireTime = current.expireTime
|
||||
form.version.status = current.status
|
||||
form.version.priceBuildMode = current.priceBuildMode || undefined
|
||||
draftPefId.value = undefined
|
||||
savedPriceBuildMode.value = current.priceBuildMode || undefined
|
||||
form.details = []
|
||||
form.products = (current.products || []).map(p => ({ ...p }))
|
||||
savedProductsSnapshot.value = form.products.map(p => ({ ...p }))
|
||||
}
|
||||
form.customers = (data.customers || []).map(c => ({ ...c }))
|
||||
}
|
||||
|
||||
@@ -91,6 +91,17 @@ export function isPriceEditableVersion(row) {
|
||||
return isDraftVersion(row) || isPendingVersion(row)
|
||||
}
|
||||
|
||||
/**
|
||||
* Build-mode cards stay visible; locked for enabled/expired versions (已生效/已失效).
|
||||
* Draft / pending / create wizard remain selectable.
|
||||
*/
|
||||
export function isBuildModeLockedVersion(rowOrStatus) {
|
||||
const s = rowOrStatus && typeof rowOrStatus === 'object' ? rowOrStatus.status : rowOrStatus
|
||||
if (s == null || s === '') return false
|
||||
const status = String(s)
|
||||
return status === VER_STATUS.EFFECT || status === VER_STATUS.EXPIRED
|
||||
}
|
||||
|
||||
export function nextVersionNo(versions) {
|
||||
const seqs = (versions || []).map(v => Number(v.versionSeq) || 0)
|
||||
const max = seqs.length ? Math.max.apply(null, seqs) : 0
|
||||
@@ -290,8 +301,7 @@ export function surchargeScopeLabel(s) {
|
||||
|
||||
/**
|
||||
* 产品关联附加费(prc_surcharge_rel)是否作用于该明细行
|
||||
* 与后端 snapshotVersionSurcharges 的过滤口径保持一致:
|
||||
* 国家三字码一致 + 产品级(detailId 空)直接命中,明细级需 productCountryId 相同
|
||||
* 产品关联:国家 + productCountryId;SALES:detailId=psdId
|
||||
*/
|
||||
export function surchargeAppliesToRow(rel, row) {
|
||||
if (!rel || !row) return false
|
||||
@@ -299,6 +309,14 @@ export function surchargeAppliesToRow(rel, row) {
|
||||
&& String(rel.countryCode).toUpperCase() !== String(row.countryCode).toUpperCase()) {
|
||||
return false
|
||||
}
|
||||
// SALES rel: detail_id = psd_id
|
||||
if (rel.priceType === 'SALES') {
|
||||
if (rel.detailId != null && row.psdId != null) {
|
||||
return Number(rel.detailId) === Number(row.psdId)
|
||||
}
|
||||
return true
|
||||
}
|
||||
// PRODUCT / REDLINE: product_country detail or product-level
|
||||
if (rel.detailId == null) return true
|
||||
return row.productCountryId != null && Number(rel.detailId) === Number(row.productCountryId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user