Compare commits
4 Commits
85a3752107
...
5fe2351990
| Author | SHA1 | Date | |
|---|---|---|---|
| 5fe2351990 | |||
| f76c90643e | |||
| c7f7f943d2 | |||
| 4441aa12bf |
+2
-1
@@ -78,7 +78,8 @@ public class TmsPriceController extends BaseController
|
||||
|
||||
/**
|
||||
* Sync order and persist prc_order_bill / prc_income_bill_fee.
|
||||
* Same price match as quote. Same orderNo upserts.
|
||||
* Same price match as quote (bound set + active version by bizDate, else default).
|
||||
* Same orderNo upserts.
|
||||
*/
|
||||
@PostMapping("/bill")
|
||||
public AjaxResult bill(
|
||||
|
||||
+46
-2
@@ -1,6 +1,8 @@
|
||||
package com.ruoyi.web.controller.price;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -17,9 +19,11 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.price.domain.PrcCustomerPriceSet;
|
||||
import com.ruoyi.price.domain.PrcPriceSet;
|
||||
import com.ruoyi.price.domain.PrcPriceSetDetail;
|
||||
import com.ruoyi.price.domain.PrcPriceSetSaveTask;
|
||||
import com.ruoyi.price.service.IPrcPriceSetService;
|
||||
|
||||
/**
|
||||
@@ -57,8 +61,23 @@ public class PriceSetController extends BaseController
|
||||
{
|
||||
set.setCreateBy(getUsername());
|
||||
set.setUpdateBy(getUsername());
|
||||
Long id = priceSetService.savePrcPriceSet(set);
|
||||
return success(id);
|
||||
String taskId = priceSetService.submitSaveAsync(set);
|
||||
// Do not pass bare String to success(): overload puts it into msg, not data.
|
||||
Map<String, Object> payload = new HashMap<String, Object>();
|
||||
payload.put("taskId", taskId);
|
||||
return success(payload);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:set:query')")
|
||||
@GetMapping("/save/task/{taskId}")
|
||||
public AjaxResult getSaveTask(@PathVariable String taskId)
|
||||
{
|
||||
PrcPriceSetSaveTask task = priceSetService.getSaveTask(taskId);
|
||||
if (task == null)
|
||||
{
|
||||
return error(MessageUtils.message("price.set.save.task.notExists"));
|
||||
}
|
||||
return success(task);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:set:edit')")
|
||||
@@ -102,6 +121,31 @@ public class PriceSetController extends BaseController
|
||||
return toAjax(priceSetService.reject(priceSetId, getUsername()));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:set:edit')")
|
||||
@Log(title = "Price set version activate", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/version/activate/{psvId}")
|
||||
public AjaxResult activateVersion(@PathVariable Long psvId)
|
||||
{
|
||||
return toAjax(priceSetService.activateVersion(psvId, getUsername()));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:set:add')")
|
||||
@Log(title = "Price set version copy", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/version/copy/{psvId}")
|
||||
public AjaxResult copyVersion(@PathVariable Long psvId)
|
||||
{
|
||||
Long newPsvId = priceSetService.copyVersion(psvId, getUsername());
|
||||
return success(newPsvId);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:set:edit')")
|
||||
@Log(title = "Price set version delete", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/version/{psvId}")
|
||||
public AjaxResult deleteVersion(@PathVariable Long psvId)
|
||||
{
|
||||
return toAjax(priceSetService.deleteVersion(psvId, getUsername()));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:set:audit')")
|
||||
@Log(title = "价格套餐停用", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/disable/{priceSetId}")
|
||||
|
||||
+2
-1
@@ -33,7 +33,8 @@ public class PriceStatusController extends BaseController
|
||||
{
|
||||
int[] counts = refreshTask.refreshNow();
|
||||
String msg = MessageUtils.message("price.status.refresh.success",
|
||||
String.valueOf(counts[0]), String.valueOf(counts[1]));
|
||||
String.valueOf(counts[0]), String.valueOf(counts[1]),
|
||||
String.valueOf(counts.length > 2 ? counts[2] : 0));
|
||||
return success(msg);
|
||||
}
|
||||
}
|
||||
+13
@@ -63,6 +63,19 @@ public class SurchargeController extends BaseController
|
||||
return success(surchargeRelService.selectRelByProductCode(productCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 附加费配置全量(非分页,供套餐明细勾选使用)
|
||||
*
|
||||
* 不要求 price:surcharge:list 权限,套餐维护角色(price:set:*)也能读,避免套餐页拿到 403 空列表。
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:surcharge:list') or @ss.hasPermi('price:surcharge:query')"
|
||||
+ " or @ss.hasPermi('price:set:query') or @ss.hasPermi('price:set:add') or @ss.hasPermi('price:set:edit')")
|
||||
@GetMapping("/options")
|
||||
public AjaxResult listOptions(PrcSurcharge surcharge)
|
||||
{
|
||||
return success(surchargeService.selectPrcSurchargeList(surcharge));
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定附加费到产品/明细(body: scId, productId, productCode, detailId;detailId 空=产品级)
|
||||
*/
|
||||
|
||||
@@ -136,9 +136,20 @@ price.quote.quoteIdRequired=报价ID为空
|
||||
price.quote.hitCustomerFixedPackageDetail=命中客户套餐固定价格明细
|
||||
|
||||
# ---- 状态自动刷新 ----
|
||||
price.status.refresh.success=状态刷新完成:bms_product 更新 {0} 行,bms_product_country 更新 {1} 行
|
||||
price.status.refresh.success=状态刷新完成:bms_product 更新 {0} 行,bms_product_country 更新 {1} 行,价格套餐版本 {2} 套
|
||||
# receivable bill
|
||||
price.bill.orderNoRequired=订单号为空
|
||||
price.bill.billIdRequired=计费ID为空
|
||||
price.bill.notFound=计费记录不存在
|
||||
price.bill.bizDateRequired=业务日期为空
|
||||
|
||||
price.set.version.effectiveTime.empty=版本生效时间不能为空
|
||||
price.set.version.notExists=套餐版本不存在
|
||||
price.set.version.activate.statusNotAllowed=仅草稿版本可启动
|
||||
price.set.version.delete.statusNotAllowed=仅草稿版本可删除
|
||||
price.set.save.task.notExists=保存任务不存在或已过期
|
||||
price.set.library.empty=产品库无可用价格明细,请检查产品国家配置
|
||||
price.set.detail.duplicate.fixed=产品{0} 国家{1} 重量段{2} {3}(共{4}条)
|
||||
price.set.detail.duplicate.discount=产品{0}(共{1}条)
|
||||
price.set.detail.duplicate.hasZone=有分区({0})
|
||||
price.set.detail.duplicate.noZone=无分区
|
||||
|
||||
@@ -37,6 +37,15 @@ public class PrcPriceSet extends BaseEntity
|
||||
private Boolean expired;
|
||||
private String keyword;
|
||||
private String submitFlag;
|
||||
/** current version on create/edit save */
|
||||
private PrcPriceSetVersion version;
|
||||
private List<PrcPriceSetDetail> details;
|
||||
private List<PrcPriceSetVersion> versions;
|
||||
private List<PrcCustomerPriceSet> customers;
|
||||
/** async save task id (not persisted) */
|
||||
private String saveTaskId;
|
||||
/** Y: backend joins product library into details (skip front pull) */
|
||||
private String pullFromLibrary;
|
||||
/** Y: even if version already has details, delete+re-pull from library */
|
||||
private String forcePullLibrary;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.price.domain;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -14,6 +15,8 @@ public class PrcPriceSetDetail implements Serializable
|
||||
|
||||
private Long psdId;
|
||||
private Long priceSetId;
|
||||
/** prc_price_set_version.psv_id */
|
||||
private Long psvId;
|
||||
private String productCode;
|
||||
private String productName;
|
||||
private String countryCode;
|
||||
@@ -27,6 +30,9 @@ public class PrcPriceSetDetail implements Serializable
|
||||
private Long zdId;
|
||||
private Long wsdId;
|
||||
private String weightLabel;
|
||||
/** KG inclusive, same as bms_product_country */
|
||||
private BigDecimal weightMin;
|
||||
private BigDecimal weightMax;
|
||||
/** bms_product_country.detail_id */
|
||||
private Long productCountryId;
|
||||
private BigDecimal fvValue;
|
||||
@@ -35,8 +41,22 @@ public class PrcPriceSetDetail implements Serializable
|
||||
/** UP / DOWN / HALF_UP */
|
||||
private String roundMode;
|
||||
private Integer prId;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date effectiveDate;
|
||||
/** null = open */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date expireDate;
|
||||
private List<PrcPriceSetVersionSurcharge> surcharges;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
/** query only: product/country/zone/weight keyword */
|
||||
private String keyword;
|
||||
/** query only: product code/name like */
|
||||
private String productKeyword;
|
||||
/** query only: country code/name like */
|
||||
private String countryKeyword;
|
||||
/** query only: zone code/name like */
|
||||
private String zoneKeyword;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.ruoyi.price.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Async save progress for price set (Redis).
|
||||
*/
|
||||
public class PrcPriceSetSaveTask 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 Long priceSetId;
|
||||
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 Long getPriceSetId()
|
||||
{
|
||||
return priceSetId;
|
||||
}
|
||||
|
||||
public void setPriceSetId(Long priceSetId)
|
||||
{
|
||||
this.priceSetId = priceSetId;
|
||||
}
|
||||
|
||||
public String getError()
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error)
|
||||
{
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.ruoyi.price.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/** Price set version prc_price_set_version */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PrcPriceSetVersion extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long psvId;
|
||||
private Long priceSetId;
|
||||
/** V1 / V2 */
|
||||
private String versionNo;
|
||||
private Integer versionSeq;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date effectiveTime;
|
||||
/** null = open; set to next version effective_time when that version starts */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date expireTime;
|
||||
/** 0 draft / 1 active / 2 expired */
|
||||
private String status;
|
||||
|
||||
private List<PrcPriceSetDetail> details;
|
||||
private List<PrcPriceSetVersionSurcharge> surcharges;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.ruoyi.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.ruoyi.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;
|
||||
}
|
||||
@@ -25,6 +25,12 @@ public class TmsPriceQuoteResult implements Serializable
|
||||
private String setType;
|
||||
private Integer bindPriority;
|
||||
private Long customerPricesetId;
|
||||
/** Hit package version id (prc_price_set_version.psv_id) */
|
||||
private Long psvId;
|
||||
/** Hit package version no (e.g. V1) */
|
||||
private String versionNo;
|
||||
/** Hit package detail id when package version detail matched */
|
||||
private Long psdId;
|
||||
|
||||
private String productCode;
|
||||
private String productName;
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public interface PrcCustomerPriceSetMapper
|
||||
@Param("endDate") java.util.Date endDate);
|
||||
|
||||
/**
|
||||
* 客户在业务日有效、且套餐状态为生效(E) 的绑定,按优先级升序
|
||||
* Customer binds valid on bizDate; package not stopped. Version match is done in quote service.
|
||||
*/
|
||||
public java.util.List<PrcCustomerPriceSet> selectEffectiveByCustomer(
|
||||
@Param("customerId") Long customerId,
|
||||
|
||||
+30
-2
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.price.mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.ruoyi.price.domain.PrcPriceSetDetail;
|
||||
@@ -23,13 +24,39 @@ public interface PrcPriceSetDetailMapper
|
||||
|
||||
public int deletePrcPriceSetDetailByPriceSetId(Long priceSetId);
|
||||
|
||||
public int deletePrcPriceSetDetailByPsvId(Long psvId);
|
||||
|
||||
/** legacy rows: price_set_id match but psv_id is null */
|
||||
public int deleteOrphanDetailsByPriceSetId(Long priceSetId);
|
||||
|
||||
public int countProductByPriceSetId(Long priceSetId);
|
||||
|
||||
public int countByPriceSetId(Long priceSetId);
|
||||
|
||||
/** FIXED: product + country + zone + productCountryId / weight */
|
||||
public int countByPsvId(Long psvId);
|
||||
|
||||
/** Copy all details from src version into new version (new psd_id, same price_set_id) */
|
||||
public int copyDetailsFromVersion(@Param("srcPsvId") Long srcPsvId, @Param("newPsvId") Long newPsvId);
|
||||
|
||||
/**
|
||||
* FIXED: insert details from active product + country library (asOf window or openOnly fallback).
|
||||
* @return inserted row count
|
||||
*/
|
||||
public int insertFixedDetailsFromLibrary(
|
||||
@Param("priceSetId") Long priceSetId,
|
||||
@Param("psvId") Long psvId,
|
||||
@Param("asOf") Date asOf,
|
||||
@Param("openOnly") boolean openOnly);
|
||||
|
||||
/** DISCOUNT: one detail row per active product */
|
||||
public int insertDiscountDetailsFromLibrary(
|
||||
@Param("priceSetId") Long priceSetId,
|
||||
@Param("psvId") Long psvId);
|
||||
|
||||
/** FIXED: product + country + zone + productCountryId / weight; optional psvId scopes to version */
|
||||
public PrcPriceSetDetail selectFixedMatch(
|
||||
@Param("priceSetId") Long priceSetId,
|
||||
@Param("psvId") Long psvId,
|
||||
@Param("productCode") String productCode,
|
||||
@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName,
|
||||
@@ -37,8 +64,9 @@ public interface PrcPriceSetDetailMapper
|
||||
@Param("productCountryId") Long productCountryId,
|
||||
@Param("weightLabel") String weightLabel);
|
||||
|
||||
/** DISCOUNT:按产品命中明细折扣(可空) */
|
||||
/** DISCOUNT by product; optional psvId scopes to version */
|
||||
public PrcPriceSetDetail selectDiscountMatch(
|
||||
@Param("priceSetId") Long priceSetId,
|
||||
@Param("psvId") Long psvId,
|
||||
@Param("productCode") String productCode);
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.price.mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.ruoyi.price.domain.PrcPriceSetVersion;
|
||||
|
||||
/**
|
||||
* Price set version
|
||||
*/
|
||||
public interface PrcPriceSetVersionMapper
|
||||
{
|
||||
public PrcPriceSetVersion selectPrcPriceSetVersionById(Long psvId);
|
||||
|
||||
public List<PrcPriceSetVersion> selectPrcPriceSetVersionList(PrcPriceSetVersion version);
|
||||
|
||||
public Integer selectMaxVersionSeq(@Param("priceSetId") Long priceSetId);
|
||||
|
||||
public int insertPrcPriceSetVersion(PrcPriceSetVersion version);
|
||||
|
||||
public int updatePrcPriceSetVersion(PrcPriceSetVersion version);
|
||||
|
||||
public int deletePrcPriceSetVersionByIds(Long[] psvIds);
|
||||
|
||||
public int deletePrcPriceSetVersionByPriceSetId(Long priceSetId);
|
||||
|
||||
public List<Long> selectPriceSetIds();
|
||||
|
||||
/**
|
||||
* Version effective at asOf: effective_time <= asOf and (expire_time null or > asOf).
|
||||
* Prefer latest effective_time.
|
||||
*/
|
||||
public PrcPriceSetVersion selectActiveByPriceSetAt(
|
||||
@Param("priceSetId") Long priceSetId,
|
||||
@Param("asOf") Date asOf);
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.ruoyi.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,6 +5,7 @@ import com.ruoyi.price.domain.PrcCustomerPriceSet;
|
||||
import com.ruoyi.price.domain.PrcPriceSet;
|
||||
import com.ruoyi.price.domain.PrcPriceSetCheckItem;
|
||||
import com.ruoyi.price.domain.PrcPriceSetDetail;
|
||||
import com.ruoyi.price.domain.PrcPriceSetSaveTask;
|
||||
|
||||
/**
|
||||
* 价格套餐 服务层
|
||||
@@ -31,6 +32,19 @@ public interface IPrcPriceSetService
|
||||
|
||||
public int disable(Long priceSetId, String updateBy);
|
||||
|
||||
/** Activate a draft version: set effective_time=now, refresh version 0/1/2 */
|
||||
public int activateVersion(Long psvId, String updateBy);
|
||||
|
||||
/**
|
||||
* Copy source version into a new draft version under the same package:
|
||||
* insert prc_price_set_version + copy prc_price_set_detail (+ surcharge snapshots).
|
||||
* @return new psvId
|
||||
*/
|
||||
public Long copyVersion(Long sourcePsvId, String createBy);
|
||||
|
||||
/** Delete a draft version and its details / surcharge snapshots */
|
||||
public int deleteVersion(Long psvId, String updateBy);
|
||||
|
||||
public Long copy(Long priceSetId, String createBy);
|
||||
|
||||
public List<PrcPriceSetCheckItem> validate(PrcPriceSet set);
|
||||
@@ -50,4 +64,13 @@ public interface IPrcPriceSetService
|
||||
public int updateCustomer(PrcCustomerPriceSet customer);
|
||||
|
||||
public int deleteCustomerByIds(Long[] customerPricesetIds);
|
||||
|
||||
/** chain expire_time = next version effective_time, then refresh 0/1/2 */
|
||||
public int refreshAllVersionStatus();
|
||||
|
||||
/** submit async save, return taskId immediately */
|
||||
public String submitSaveAsync(PrcPriceSet set);
|
||||
|
||||
/** poll async save progress */
|
||||
public PrcPriceSetSaveTask getSaveTask(String taskId);
|
||||
}
|
||||
|
||||
+7
-4
@@ -6,11 +6,14 @@ import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TMS freight quote service.
|
||||
* TMS freight quote / bill calc service (shared by console trial and upstream bill).
|
||||
*
|
||||
* Match order: effective customer package (bind_priority ASC) FIXED override
|
||||
* then DISCOUNT, else bms_product_country default freight/registration.
|
||||
* After calc, persist fee lines by bms_fee_type; same trial params return stored result.
|
||||
* Match order:
|
||||
* 1) Customer binds (not stopped), bind_priority ASC
|
||||
* 2) Active package version at bill-time end-of-day (effective_time / expire_time)
|
||||
* 3) FIXED detail override, else DISCOUNT on that version
|
||||
* 4) Else bms_product_country default
|
||||
* Package hit uses version surcharge snapshot when present; else product library.
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
|
||||
+1171
-92
File diff suppressed because it is too large
Load Diff
+109
-15
@@ -5,6 +5,7 @@ import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -25,6 +26,8 @@ import com.ruoyi.price.domain.BmsProductCountry;
|
||||
import com.ruoyi.price.domain.PrcCustomerPriceSet;
|
||||
import com.ruoyi.price.domain.PrcPriceSet;
|
||||
import com.ruoyi.price.domain.PrcPriceSetDetail;
|
||||
import com.ruoyi.price.domain.PrcPriceSetVersion;
|
||||
import com.ruoyi.price.domain.PrcPriceSetVersionSurcharge;
|
||||
import com.ruoyi.price.domain.PrcQuote;
|
||||
import com.ruoyi.price.domain.PrcQuoteFee;
|
||||
import com.ruoyi.price.domain.PrcSurchargeRel;
|
||||
@@ -38,6 +41,8 @@ import com.ruoyi.price.mapper.BmsProductMapper;
|
||||
import com.ruoyi.price.mapper.PrcCustomerPriceSetMapper;
|
||||
import com.ruoyi.price.mapper.PrcPriceSetDetailMapper;
|
||||
import com.ruoyi.price.mapper.PrcPriceSetMapper;
|
||||
import com.ruoyi.price.mapper.PrcPriceSetVersionMapper;
|
||||
import com.ruoyi.price.mapper.PrcPriceSetVersionSurchargeMapper;
|
||||
import com.ruoyi.price.mapper.PrcQuoteFeeMapper;
|
||||
import com.ruoyi.price.mapper.PrcQuoteMapper;
|
||||
import com.ruoyi.price.mapper.PrcSurchargeRelMapper;
|
||||
@@ -47,8 +52,8 @@ import com.ruoyi.price.search.IBillSearchStore;
|
||||
import com.ruoyi.price.service.ITmsPriceQuoteService;
|
||||
|
||||
/**
|
||||
* TMS freight quote: customer package first, then product default.
|
||||
* After calc: persist fee lines by bms_fee_type; same trial params return stored rows.
|
||||
* Shared quote/bill calc: bound set + active version by bizDate, else product default.
|
||||
* Quote persists prc_quote; bill path calls calculate() then persists prc_order_bill.
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@@ -71,6 +76,12 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
@Autowired
|
||||
private PrcPriceSetMapper priceSetMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcPriceSetVersionMapper versionMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcPriceSetVersionSurchargeMapper versionSurchargeMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcPriceSetDetailMapper detailMapper;
|
||||
|
||||
@@ -249,17 +260,24 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
|
||||
if (binds != null)
|
||||
{
|
||||
Date asOf = endOfDay(bizDate);
|
||||
for (PrcCustomerPriceSet bind : binds)
|
||||
{
|
||||
PrcPriceSet set = priceSetMapper.selectPrcPriceSetById(bind.getPriceSetId());
|
||||
if (set == null || !"E".equals(set.getStatus()))
|
||||
if (set == null || "S".equals(set.getStatus()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
PrcPriceSetVersion version = versionMapper.selectActiveByPriceSetAt(set.getPriceSetId(), asOf);
|
||||
if (version == null || version.getPsvId() == null)
|
||||
{
|
||||
// Bound package but no version effective at bill time -> try next bind / default
|
||||
continue;
|
||||
}
|
||||
String setType = StringUtils.isEmpty(set.getSetType()) ? TYPE_FIXED : set.getSetType();
|
||||
if (TYPE_FIXED.equals(setType))
|
||||
{
|
||||
TmsPriceQuoteResult hit = tryFixed(bind, set, base, productCode, productName, weight);
|
||||
TmsPriceQuoteResult hit = tryFixed(bind, set, version, base, productCode, productName, weight);
|
||||
if (hit != null)
|
||||
{
|
||||
stampRequestMeta(request, hit);
|
||||
@@ -268,7 +286,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
else if (TYPE_DISCOUNT.equals(setType))
|
||||
{
|
||||
TmsPriceQuoteResult hit = tryDiscount(bind, set, base, productCode, productName, weight);
|
||||
TmsPriceQuoteResult hit = tryDiscount(bind, set, version, base, productCode, productName, weight);
|
||||
if (hit != null)
|
||||
{
|
||||
stampRequestMeta(request, hit);
|
||||
@@ -334,23 +352,25 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
return n;
|
||||
}
|
||||
|
||||
private TmsPriceQuoteResult tryFixed(PrcCustomerPriceSet bind, PrcPriceSet set,
|
||||
private TmsPriceQuoteResult tryFixed(PrcCustomerPriceSet bind, PrcPriceSet set, PrcPriceSetVersion version,
|
||||
BmsProductCountry base, String productCode, String productName, BigDecimal weight)
|
||||
{
|
||||
int detailCount = detailMapper.countByPriceSetId(set.getPriceSetId());
|
||||
Long psvId = version.getPsvId();
|
||||
int detailCount = detailMapper.countByPsvId(psvId);
|
||||
if (detailCount == 0)
|
||||
{
|
||||
TmsPriceQuoteResult r = buildFromRates(SRC_DEFAULT, base.getFreightPrice(), null, null,
|
||||
base.getRegistrationFee(), base, productCode, productName, weight, null);
|
||||
fillPackage(r, bind, set);
|
||||
// 套餐固定价格没有明细,使用产品默认价格
|
||||
stampVersion(r, version, null);
|
||||
// Package fixed has no version details; use product default rates
|
||||
r.setMatchMessage(MessageUtils.message("price.quote.fixedPackageNoDetails"));
|
||||
r.setCustomerId(bind.getCustomerId());
|
||||
return r;
|
||||
}
|
||||
|
||||
PrcPriceSetDetail detail = detailMapper.selectFixedMatch(
|
||||
set.getPriceSetId(), productCode,
|
||||
set.getPriceSetId(), psvId, productCode,
|
||||
base.getCountryCode(), base.getCountryName(), base.getZoneCode(),
|
||||
base.getDetailId(),
|
||||
formatWeightLabel(base.getWeightMin(), base.getWeightMax()));
|
||||
@@ -365,6 +385,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
TmsPriceQuoteResult r = buildFromRates(SRC_FIXED, detail.getFvValue(), null, null,
|
||||
detail.getFvRegistrationFee(), base, productCode, productName, weight, detail.getRoundMode());
|
||||
fillPackage(r, bind, set);
|
||||
stampVersion(r, version, detail.getPsdId());
|
||||
if (StringUtils.isNotEmpty(detail.getProductName()))
|
||||
{
|
||||
r.setProductName(detail.getProductName());
|
||||
@@ -377,25 +398,28 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
{
|
||||
r.setProductCountryId(detail.getProductCountryId());
|
||||
}
|
||||
// 命中客户套餐固定价格明细
|
||||
r.setMatchMessage(MessageUtils.message("price.quote.hitCustomerFixedPackageDetail"));
|
||||
r.setMatchMessage(MessageUtils.message("price.quote.hitCustomerFixedPackageDetail")
|
||||
+ " [" + (version.getVersionNo() == null ? ("psv=" + psvId) : version.getVersionNo()) + "]");
|
||||
r.setCustomerId(bind.getCustomerId());
|
||||
return r;
|
||||
}
|
||||
|
||||
private TmsPriceQuoteResult tryDiscount(PrcCustomerPriceSet bind, PrcPriceSet set,
|
||||
private TmsPriceQuoteResult tryDiscount(PrcCustomerPriceSet bind, PrcPriceSet set, PrcPriceSetVersion version,
|
||||
BmsProductCountry base, String productCode, String productName, BigDecimal weight)
|
||||
{
|
||||
int detailCount = detailMapper.countByPriceSetId(set.getPriceSetId());
|
||||
Long psvId = version.getPsvId();
|
||||
int detailCount = detailMapper.countByPsvId(psvId);
|
||||
BigDecimal discount = set.getDefaultDiscount();
|
||||
String roundMode = null;
|
||||
Long psdId = null;
|
||||
if (detailCount > 0)
|
||||
{
|
||||
PrcPriceSetDetail detail = detailMapper.selectDiscountMatch(set.getPriceSetId(), productCode);
|
||||
PrcPriceSetDetail detail = detailMapper.selectDiscountMatch(set.getPriceSetId(), psvId, productCode);
|
||||
if (detail == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
psdId = detail.getPsdId();
|
||||
if (detail.getDiscountValue() != null)
|
||||
{
|
||||
discount = detail.getDiscountValue();
|
||||
@@ -419,11 +443,25 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
TmsPriceQuoteResult r = buildFromRates(SRC_DISCOUNT, rate, baseRate, discount,
|
||||
base.getRegistrationFee(), base, productCode, productName, weight, roundMode);
|
||||
fillPackage(r, bind, set);
|
||||
r.setMatchMessage("hit customer DISCOUNT package; freight = default * discount%");
|
||||
stampVersion(r, version, psdId);
|
||||
r.setMatchMessage("hit customer DISCOUNT package version "
|
||||
+ (version.getVersionNo() == null ? String.valueOf(psvId) : version.getVersionNo())
|
||||
+ "; freight = default * discount%");
|
||||
r.setCustomerId(bind.getCustomerId());
|
||||
return r;
|
||||
}
|
||||
|
||||
private void stampVersion(TmsPriceQuoteResult result, PrcPriceSetVersion version, Long psdId)
|
||||
{
|
||||
if (result == null || version == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
result.setPsvId(version.getPsvId());
|
||||
result.setVersionNo(version.getVersionNo());
|
||||
result.setPsdId(psdId);
|
||||
}
|
||||
|
||||
private TmsPriceQuoteResult buildDefault(Long customerId, BmsProductCountry base,
|
||||
String productCode, String productName, BigDecimal weight, String message)
|
||||
{
|
||||
@@ -538,6 +576,23 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
{
|
||||
return matched;
|
||||
}
|
||||
if (result.getPsdId() != null)
|
||||
{
|
||||
List<PrcPriceSetVersionSurcharge> snaps =
|
||||
versionSurchargeMapper.selectByPsdIds(Collections.singletonList(result.getPsdId()));
|
||||
if (snaps != null && !snaps.isEmpty())
|
||||
{
|
||||
for (PrcPriceSetVersionSurcharge snap : snaps)
|
||||
{
|
||||
PrcSurchargeRel rel = toRelFromVersionSnap(snap);
|
||||
if (surchargeApplies(rel, result))
|
||||
{
|
||||
matched.add(rel);
|
||||
}
|
||||
}
|
||||
return matched;
|
||||
}
|
||||
}
|
||||
PrcSurchargeRel query = new PrcSurchargeRel();
|
||||
query.setProductCode(result.getProductCode());
|
||||
List<PrcSurchargeRel> rels = surchargeRelMapper.selectPrcSurchargeRelList(query);
|
||||
@@ -555,6 +610,27 @@ 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)
|
||||
{
|
||||
if (rel == null)
|
||||
@@ -961,6 +1037,24 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
}
|
||||
|
||||
/** Use end of bill day so same-day version activate still matches that day's quote. */
|
||||
private static Date endOfDay(Date day)
|
||||
{
|
||||
if (day == null)
|
||||
{
|
||||
return new Date();
|
||||
}
|
||||
try
|
||||
{
|
||||
String d = new SimpleDateFormat("yyyy-MM-dd").format(day);
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(d + " 23:59:59");
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
return day;
|
||||
}
|
||||
}
|
||||
|
||||
private String resolveProductName(String productCode, Date bizDate)
|
||||
{
|
||||
BmsProduct p = productMapper.selectEffectiveBmsProductByCode(productCode, bizDate);
|
||||
|
||||
@@ -3,10 +3,13 @@ package com.ruoyi.price.task;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.ruoyi.price.mapper.BmsProductCountryMapper;
|
||||
import com.ruoyi.price.mapper.BmsProductMapper;
|
||||
import com.ruoyi.price.service.IPrcPriceSetService;
|
||||
|
||||
/**
|
||||
* bms_product / bms_product_country 状态自动刷新
|
||||
@@ -26,7 +29,7 @@ import com.ruoyi.price.mapper.BmsProductMapper;
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
public class BmsStatusRefreshTask
|
||||
public class BmsStatusRefreshTask implements ApplicationRunner
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(BmsStatusRefreshTask.class);
|
||||
|
||||
@@ -36,6 +39,9 @@ public class BmsStatusRefreshTask
|
||||
@Autowired
|
||||
private BmsProductCountryMapper productCountryMapper;
|
||||
|
||||
@Autowired
|
||||
private IPrcPriceSetService priceSetService;
|
||||
|
||||
/** 每天 02:00 跑(cron: sec min hour DOM month DOW) */
|
||||
@Scheduled(cron = "0 0 2 * * ?")
|
||||
public void scheduled()
|
||||
@@ -43,16 +49,31 @@ public class BmsStatusRefreshTask
|
||||
refreshNow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args)
|
||||
{
|
||||
try
|
||||
{
|
||||
int n = priceSetService.refreshAllVersionStatus();
|
||||
log.info("startup prc_price_set_version expire/status refreshed, sets={}", n);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("startup prc_price_set_version refresh failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 立即刷新两表状态。返回 [product 影响行数, country 影响行数]。
|
||||
* 异常时打印 ERROR 并原样抛出,便于调用方(手动触发接口)回滚事务。
|
||||
* Refresh product/country status and chain version expire_time.
|
||||
* Returns [product rows, country rows, price-set count].
|
||||
*/
|
||||
public int[] refreshNow()
|
||||
{
|
||||
int productCount = productMapper.refreshStatusByDates();
|
||||
int countryCount = productCountryMapper.refreshStatusByDates();
|
||||
log.info("BmsStatusRefreshTask done: bms_product={}, bms_product_country={}",
|
||||
productCount, countryCount);
|
||||
return new int[] { productCount, countryCount };
|
||||
int versionSets = priceSetService.refreshAllVersionStatus();
|
||||
log.info("BmsStatusRefreshTask done: bms_product={}, bms_product_country={}, price_set_version_sets={}",
|
||||
productCount, countryCount, versionSets);
|
||||
return new int[] { productCount, countryCount, versionSets };
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.ruoyi.price.task;
|
||||
|
||||
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.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.price.domain.PrcPriceSet;
|
||||
import com.ruoyi.price.domain.PrcPriceSetSaveTask;
|
||||
import com.ruoyi.price.service.IPrcPriceSetService;
|
||||
|
||||
/**
|
||||
* Async runner for price-set save (avoids HTTP timeout on large detail snapshots).
|
||||
*/
|
||||
@Component
|
||||
public class PrcPriceSetSaveAsyncRunner
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(PrcPriceSetSaveAsyncRunner.class);
|
||||
|
||||
public static final String CACHE_KEY_PREFIX = "price:set:save:task:";
|
||||
public static final int TTL_MINUTES = 60;
|
||||
|
||||
@Autowired
|
||||
private IPrcPriceSetService priceSetService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Async("threadPoolTaskExecutor")
|
||||
public void run(String taskId, PrcPriceSet set)
|
||||
{
|
||||
try
|
||||
{
|
||||
put(taskId, PrcPriceSetSaveTask.STATUS_RUNNING, 8, "saving basic", null, null);
|
||||
set.setSaveTaskId(taskId);
|
||||
Long id = priceSetService.savePrcPriceSet(set);
|
||||
put(taskId, PrcPriceSetSaveTask.STATUS_SUCCESS, 100, "done", id, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("async save price set failed, taskId={}", taskId, e);
|
||||
String msg = e.getMessage();
|
||||
if (StringUtils.isEmpty(msg))
|
||||
{
|
||||
msg = e.getClass().getSimpleName();
|
||||
}
|
||||
put(taskId, PrcPriceSetSaveTask.STATUS_FAIL, 100, "failed", null, msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void put(String taskId, String status, int percent, String message, Long priceSetId, String error)
|
||||
{
|
||||
PrcPriceSetSaveTask task = new PrcPriceSetSaveTask();
|
||||
task.setTaskId(taskId);
|
||||
task.setStatus(status);
|
||||
task.setPercent(percent);
|
||||
task.setMessage(message);
|
||||
task.setPriceSetId(priceSetId);
|
||||
task.setError(error);
|
||||
redisCache.setCacheObject(CACHE_KEY_PREFIX + taskId, task, TTL_MINUTES, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
public PrcPriceSetSaveTask get(String taskId)
|
||||
{
|
||||
return redisCache.getCacheObject(CACHE_KEY_PREFIX + taskId);
|
||||
}
|
||||
}
|
||||
@@ -97,8 +97,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from prc_customer_price_set c
|
||||
inner join prc_price_set s on s.price_set_id = c.price_set_id
|
||||
where c.customer_id = #{customerId}
|
||||
and s.status = 'E'
|
||||
and c.pr_begindate <= #{bizDate}
|
||||
and ifnull(s.status, 'D') <> 'S'
|
||||
and (c.pr_begindate is null or c.pr_begindate <= #{bizDate})
|
||||
and ifnull(c.pr_enddate, '9999-12-31') >= #{bizDate}
|
||||
order by c.bind_priority asc, c.pr_begindate desc, c.customer_priceset_id asc
|
||||
</select>
|
||||
@@ -110,8 +110,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from prc_customer_price_set c
|
||||
inner join prc_price_set s on s.price_set_id = c.price_set_id
|
||||
where c.customer_code = #{customerCode}
|
||||
and s.status = 'E'
|
||||
and c.pr_begindate <= #{bizDate}
|
||||
and ifnull(s.status, 'D') <> 'S'
|
||||
and (c.pr_begindate is null or c.pr_begindate <= #{bizDate})
|
||||
and ifnull(c.pr_enddate, '9999-12-31') >= #{bizDate}
|
||||
order by c.bind_priority asc, c.pr_begindate desc, c.customer_priceset_id asc
|
||||
</select>
|
||||
|
||||
@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<resultMap type="PrcPriceSetDetail" id="PrcPriceSetDetailResult">
|
||||
<id property="psdId" column="psd_id" />
|
||||
<result property="priceSetId" column="price_set_id" />
|
||||
<result property="psvId" column="psv_id" />
|
||||
<result property="productCode" column="product_code" />
|
||||
<result property="productName" column="product_name" />
|
||||
<result property="countryCode" column="country_code" />
|
||||
@@ -17,21 +18,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="zdId" column="zd_id" />
|
||||
<result property="wsdId" column="wsd_id" />
|
||||
<result property="weightLabel" column="weight_label" />
|
||||
<result property="weightMin" column="weight_min" />
|
||||
<result property="weightMax" column="weight_max" />
|
||||
<result property="productCountryId" column="product_country_id" />
|
||||
<result property="fvValue" column="fv_value" />
|
||||
<result property="fvRegistrationFee" column="fv_registration_fee" />
|
||||
<result property="discountValue" column="discount_value" />
|
||||
<result property="roundMode" column="round_mode" />
|
||||
<result property="prId" column="pr_id" />
|
||||
<result property="effectiveDate" column="effective_date" />
|
||||
<result property="expireDate" column="expire_date" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcPriceSetDetailVo">
|
||||
select psd_id, price_set_id, product_code, product_name, country_code, country_name,
|
||||
select psd_id, price_set_id, psv_id, product_code, product_name, country_code, country_name,
|
||||
zone_id, zone_code, zone_name,
|
||||
zd_id, wsd_id, weight_label, product_country_id, fv_value, fv_registration_fee,
|
||||
discount_value, round_mode, pr_id, create_time, update_time
|
||||
zd_id, wsd_id, weight_label, weight_min, weight_max, product_country_id, fv_value, fv_registration_fee,
|
||||
discount_value, round_mode, pr_id, effective_date, expire_date, create_time, update_time
|
||||
from prc_price_set_detail
|
||||
</sql>
|
||||
|
||||
@@ -46,6 +51,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="priceSetId != null">
|
||||
AND price_set_id = #{priceSetId}
|
||||
</if>
|
||||
<if test="psvId != null">
|
||||
AND psv_id = #{psvId}
|
||||
</if>
|
||||
<if test="productCode != null and productCode != ''">
|
||||
AND product_code = #{productCode}
|
||||
</if>
|
||||
@@ -55,6 +63,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="zoneCode != null and zoneCode != ''">
|
||||
AND zone_code = #{zoneCode}
|
||||
</if>
|
||||
<if test="productKeyword != null and productKeyword != ''">
|
||||
AND (
|
||||
product_code like concat('%', #{productKeyword}, '%')
|
||||
or product_name like concat('%', #{productKeyword}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="countryKeyword != null and countryKeyword != ''">
|
||||
AND (
|
||||
country_code like concat('%', #{countryKeyword}, '%')
|
||||
or country_name like concat('%', #{countryKeyword}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="zoneKeyword != null and zoneKeyword != ''">
|
||||
AND (
|
||||
zone_code like concat('%', #{zoneKeyword}, '%')
|
||||
or zone_name like concat('%', #{zoneKeyword}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (
|
||||
product_code like concat('%', #{keyword}, '%')
|
||||
or product_name like concat('%', #{keyword}, '%')
|
||||
or country_code like concat('%', #{keyword}, '%')
|
||||
or country_name like concat('%', #{keyword}, '%')
|
||||
or zone_code like concat('%', #{keyword}, '%')
|
||||
or zone_name like concat('%', #{keyword}, '%')
|
||||
or weight_label like concat('%', #{keyword}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
order by psd_id asc
|
||||
</select>
|
||||
@@ -67,9 +104,90 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select count(1) from prc_price_set_detail where price_set_id = #{priceSetId}
|
||||
</select>
|
||||
|
||||
<select id="countByPsvId" parameterType="Long" resultType="int">
|
||||
select count(1) from prc_price_set_detail where psv_id = #{psvId}
|
||||
</select>
|
||||
|
||||
<!-- FIXED: join active products + country by product_id only (avoid OR-join row explosion) -->
|
||||
<insert id="insertFixedDetailsFromLibrary">
|
||||
insert ignore into prc_price_set_detail (
|
||||
price_set_id, psv_id, product_code, product_name,
|
||||
country_code, country_name, zone_id, zone_code, zone_name,
|
||||
weight_label, weight_min, weight_max, product_country_id,
|
||||
fv_value, fv_registration_fee, round_mode,
|
||||
effective_date, expire_date, create_time
|
||||
)
|
||||
select
|
||||
#{priceSetId},
|
||||
#{psvId},
|
||||
p.product_code,
|
||||
p.product_name,
|
||||
c.country_code,
|
||||
c.country_name,
|
||||
c.zone_id,
|
||||
c.zone_code,
|
||||
c.zone_name,
|
||||
case
|
||||
when c.weight_min is null and c.weight_max is null then null
|
||||
else concat(
|
||||
ifnull(trim(trailing '0' from trim(trailing '.' from cast(c.weight_min as char))), ''),
|
||||
'<W≤',
|
||||
ifnull(trim(trailing '0' from trim(trailing '.' from cast(c.weight_max as char))), '')
|
||||
)
|
||||
end,
|
||||
c.weight_min,
|
||||
c.weight_max,
|
||||
c.detail_id,
|
||||
c.freight_price,
|
||||
c.registration_fee,
|
||||
'HALF_UP',
|
||||
c.effective_date,
|
||||
c.expire_date,
|
||||
sysdate()
|
||||
from bms_product p
|
||||
inner join bms_product_country c on c.product_id = p.product_id
|
||||
where p.status = '1'
|
||||
and p.product_id = (
|
||||
select max(p2.product_id) from bms_product p2
|
||||
where p2.product_code = p.product_code and p2.status = '1'
|
||||
)
|
||||
and ifnull(c.status, '1') <> '2'
|
||||
<choose>
|
||||
<when test="openOnly">
|
||||
and (c.expire_date is null or date(c.expire_date) > curdate())
|
||||
</when>
|
||||
<otherwise>
|
||||
and date(c.effective_date) <= date(#{asOf})
|
||||
and (c.expire_date is null or date(c.expire_date) > date(#{asOf}))
|
||||
</otherwise>
|
||||
</choose>
|
||||
order by p.product_code asc, c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc
|
||||
</insert>
|
||||
|
||||
<insert id="insertDiscountDetailsFromLibrary">
|
||||
insert ignore into prc_price_set_detail (
|
||||
price_set_id, psv_id, product_code, product_name, round_mode, create_time
|
||||
)
|
||||
select
|
||||
#{priceSetId},
|
||||
#{psvId},
|
||||
p.product_code,
|
||||
p.product_name,
|
||||
'HALF_UP',
|
||||
sysdate()
|
||||
from bms_product p
|
||||
where p.status = '1'
|
||||
and p.product_id = (
|
||||
select max(p2.product_id) from bms_product p2
|
||||
where p2.product_code = p.product_code and p2.status = '1'
|
||||
)
|
||||
order by p.product_code asc
|
||||
</insert>
|
||||
|
||||
<insert id="insertPrcPriceSetDetail" parameterType="PrcPriceSetDetail" useGeneratedKeys="true" keyProperty="psdId">
|
||||
insert into prc_price_set_detail (
|
||||
<if test="priceSetId != null">price_set_id,</if>
|
||||
<if test="psvId != null">psv_id,</if>
|
||||
<if test="productCode != null and productCode != ''">product_code,</if>
|
||||
<if test="productName != null">product_name,</if>
|
||||
<if test="countryCode != null">country_code,</if>
|
||||
@@ -80,15 +198,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="zdId != null">zd_id,</if>
|
||||
<if test="wsdId != null">wsd_id,</if>
|
||||
<if test="weightLabel != null">weight_label,</if>
|
||||
<if test="weightMin != null">weight_min,</if>
|
||||
<if test="weightMax != null">weight_max,</if>
|
||||
<if test="productCountryId != null">product_country_id,</if>
|
||||
<if test="fvValue != null">fv_value,</if>
|
||||
<if test="fvRegistrationFee != null">fv_registration_fee,</if>
|
||||
<if test="discountValue != null">discount_value,</if>
|
||||
<if test="roundMode != null and roundMode != ''">round_mode,</if>
|
||||
<if test="prId != null">pr_id,</if>
|
||||
<if test="effectiveDate != null">effective_date,</if>
|
||||
expire_date,
|
||||
create_time
|
||||
) values (
|
||||
<if test="priceSetId != null">#{priceSetId},</if>
|
||||
<if test="psvId != null">#{psvId},</if>
|
||||
<if test="productCode != null and productCode != ''">#{productCode},</if>
|
||||
<if test="productName != null">#{productName},</if>
|
||||
<if test="countryCode != null">#{countryCode},</if>
|
||||
@@ -99,12 +222,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="zdId != null">#{zdId},</if>
|
||||
<if test="wsdId != null">#{wsdId},</if>
|
||||
<if test="weightLabel != null">#{weightLabel},</if>
|
||||
<if test="weightMin != null">#{weightMin},</if>
|
||||
<if test="weightMax != null">#{weightMax},</if>
|
||||
<if test="productCountryId != null">#{productCountryId},</if>
|
||||
<if test="fvValue != null">#{fvValue},</if>
|
||||
<if test="fvRegistrationFee != null">#{fvRegistrationFee},</if>
|
||||
<if test="discountValue != null">#{discountValue},</if>
|
||||
<if test="roundMode != null and roundMode != ''">#{roundMode},</if>
|
||||
<if test="prId != null">#{prId},</if>
|
||||
<if test="effectiveDate != null">#{effectiveDate},</if>
|
||||
#{expireDate},
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
@@ -112,6 +239,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updatePrcPriceSetDetail" parameterType="PrcPriceSetDetail">
|
||||
update prc_price_set_detail
|
||||
<set>
|
||||
<if test="psvId != null">psv_id = #{psvId},</if>
|
||||
<if test="productCode != null and productCode != ''">product_code = #{productCode},</if>
|
||||
<if test="productName != null">product_name = #{productName},</if>
|
||||
country_code = #{countryCode},
|
||||
@@ -122,12 +250,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
zd_id = #{zdId},
|
||||
wsd_id = #{wsdId},
|
||||
weight_label = #{weightLabel},
|
||||
weight_min = #{weightMin},
|
||||
weight_max = #{weightMax},
|
||||
product_country_id = #{productCountryId},
|
||||
fv_value = #{fvValue},
|
||||
fv_registration_fee = #{fvRegistrationFee},
|
||||
discount_value = #{discountValue},
|
||||
<if test="roundMode != null and roundMode != ''">round_mode = #{roundMode},</if>
|
||||
pr_id = #{prId},
|
||||
effective_date = #{effectiveDate},
|
||||
expire_date = #{expireDate},
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where psd_id = #{psdId}
|
||||
@@ -144,9 +276,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
delete from prc_price_set_detail where price_set_id = #{priceSetId}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrcPriceSetDetailByPsvId" parameterType="Long">
|
||||
delete from prc_price_set_detail where psv_id = #{psvId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteOrphanDetailsByPriceSetId" parameterType="Long">
|
||||
delete from prc_price_set_detail where price_set_id = #{priceSetId} and psv_id is null
|
||||
</delete>
|
||||
|
||||
<select id="selectFixedMatch" resultMap="PrcPriceSetDetailResult">
|
||||
<include refid="selectPrcPriceSetDetailVo"/>
|
||||
where price_set_id = #{priceSetId}
|
||||
<if test="psvId != null">
|
||||
and psv_id = #{psvId}
|
||||
</if>
|
||||
and product_code = #{productCode}
|
||||
and (
|
||||
<if test="productCountryId != null">
|
||||
@@ -184,9 +327,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectDiscountMatch" resultMap="PrcPriceSetDetailResult">
|
||||
<include refid="selectPrcPriceSetDetailVo"/>
|
||||
where price_set_id = #{priceSetId}
|
||||
<if test="psvId != null">
|
||||
and psv_id = #{psvId}
|
||||
</if>
|
||||
and product_code = #{productCode}
|
||||
order by psd_id asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="copyDetailsFromVersion">
|
||||
insert into prc_price_set_detail (
|
||||
price_set_id, psv_id, product_code, product_name, country_code, country_name,
|
||||
zone_id, zone_code, zone_name, zd_id, wsd_id, weight_label, weight_min, weight_max,
|
||||
product_country_id, fv_value, fv_registration_fee, discount_value, round_mode,
|
||||
pr_id, effective_date, expire_date, create_time
|
||||
)
|
||||
select
|
||||
price_set_id, #{newPsvId}, product_code, product_name, country_code, country_name,
|
||||
zone_id, zone_code, zone_name, zd_id, wsd_id, weight_label, weight_min, weight_max,
|
||||
product_country_id, fv_value, fv_registration_fee, discount_value, round_mode,
|
||||
pr_id, effective_date, expire_date, sysdate()
|
||||
from prc_price_set_detail
|
||||
where psv_id = #{srcPsvId}
|
||||
order by psd_id asc
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -140,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update prc_price_set
|
||||
<set>
|
||||
status = #{status},
|
||||
<if test="effectiveDate != null">effective_date = #{effectiveDate},</if>
|
||||
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
<?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.ruoyi.price.mapper.PrcPriceSetVersionMapper">
|
||||
|
||||
<resultMap type="PrcPriceSetVersion" id="PrcPriceSetVersionResult">
|
||||
<id property="psvId" column="psv_id" />
|
||||
<result property="priceSetId" column="price_set_id" />
|
||||
<result property="versionNo" column="version_no" />
|
||||
<result property="versionSeq" column="version_seq" />
|
||||
<result property="effectiveTime" column="effective_time" />
|
||||
<result property="expireTime" column="expire_time" />
|
||||
<result property="status" column="status" />
|
||||
<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="selectPrcPriceSetVersionVo">
|
||||
select psv_id, price_set_id, version_no, version_seq, effective_time, expire_time, status,
|
||||
created_by, create_time, updated_by, update_time
|
||||
from prc_price_set_version
|
||||
</sql>
|
||||
|
||||
<select id="selectPrcPriceSetVersionById" parameterType="Long" resultMap="PrcPriceSetVersionResult">
|
||||
<include refid="selectPrcPriceSetVersionVo"/>
|
||||
where psv_id = #{psvId}
|
||||
</select>
|
||||
|
||||
<select id="selectPrcPriceSetVersionList" parameterType="PrcPriceSetVersion" resultMap="PrcPriceSetVersionResult">
|
||||
<include refid="selectPrcPriceSetVersionVo"/>
|
||||
<where>
|
||||
<if test="priceSetId != null">
|
||||
AND price_set_id = #{priceSetId}
|
||||
</if>
|
||||
<if test="versionNo != null and versionNo != ''">
|
||||
AND version_no = #{versionNo}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
order by version_seq desc
|
||||
</select>
|
||||
|
||||
<select id="selectMaxVersionSeq" resultType="java.lang.Integer">
|
||||
select max(version_seq) from prc_price_set_version where price_set_id = #{priceSetId}
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcPriceSetVersion" parameterType="PrcPriceSetVersion" useGeneratedKeys="true" keyProperty="psvId">
|
||||
insert into prc_price_set_version (
|
||||
<if test="priceSetId != null">price_set_id,</if>
|
||||
<if test="versionNo != null and versionNo != ''">version_no,</if>
|
||||
<if test="versionSeq != null">version_seq,</if>
|
||||
<if test="effectiveTime != null">effective_time,</if>
|
||||
<if test="expireTime != null">expire_time,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="createBy != null and createBy != ''">created_by,</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="priceSetId != null">#{priceSetId},</if>
|
||||
<if test="versionNo != null and versionNo != ''">#{versionNo},</if>
|
||||
<if test="versionSeq != null">#{versionSeq},</if>
|
||||
<if test="effectiveTime != null">#{effectiveTime},</if>
|
||||
<if test="expireTime != null">#{expireTime},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updatePrcPriceSetVersion" parameterType="PrcPriceSetVersion">
|
||||
update prc_price_set_version
|
||||
<set>
|
||||
<if test="versionNo != null and versionNo != ''">version_no = #{versionNo},</if>
|
||||
<if test="versionSeq != null">version_seq = #{versionSeq},</if>
|
||||
<if test="effectiveTime != null">effective_time = #{effectiveTime},</if>
|
||||
expire_time = #{expireTime},
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where psv_id = #{psvId}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrcPriceSetVersionByIds" parameterType="Long">
|
||||
delete from prc_price_set_version where psv_id in
|
||||
<foreach item="psvId" collection="array" open="(" separator="," close=")">
|
||||
#{psvId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrcPriceSetVersionByPriceSetId" parameterType="Long">
|
||||
delete from prc_price_set_version where price_set_id = #{priceSetId}
|
||||
</delete>
|
||||
|
||||
<select id="selectPriceSetIds" resultType="Long">
|
||||
select distinct price_set_id from prc_price_set_version
|
||||
</select>
|
||||
|
||||
<select id="selectActiveByPriceSetAt" resultMap="PrcPriceSetVersionResult">
|
||||
<include refid="selectPrcPriceSetVersionVo"/>
|
||||
where price_set_id = #{priceSetId}
|
||||
and effective_time is not null
|
||||
and effective_time <= #{asOf}
|
||||
and (expire_time is null or expire_time > #{asOf})
|
||||
order by effective_time desc, version_seq desc, psv_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
<?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.ruoyi.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, '')) <> 'of'
|
||||
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>
|
||||
@@ -0,0 +1,34 @@
|
||||
# Price set version tables
|
||||
|
||||
## Wizard (2 steps)
|
||||
|
||||
1. Basic info + view bound customers (read-only)
|
||||
2. Edit product prices (library pull on next)
|
||||
|
||||
- No manual effective_time input.
|
||||
- Draft version: status=0, effective_time null until activate.
|
||||
- Activate: sets effective_time=now; previous version expires. Does not change package header status.
|
||||
- Copy as new version: `POST /price/set/version/copy/{psvId}` inserts new draft `prc_price_set_version` and copies `prc_price_set_detail` (+ surcharge snapshots) from source psv_id.
|
||||
- Audit submit/approve/reject removed from UI save path.
|
||||
|
||||
## Graph
|
||||
|
||||
```
|
||||
prc_price_set
|
||||
-> prc_price_set_version draft / active / expired
|
||||
-> prc_price_set_detail product prices (psv_id)
|
||||
-> prc_price_set_version_surcharge
|
||||
```
|
||||
|
||||
## Status
|
||||
|
||||
Version: 0 draft, 1 active, 2 expired. Active when effective_time <= now and (expire_time null or > now).
|
||||
|
||||
## SQL
|
||||
|
||||
1. `price_set_version.sql`
|
||||
2. `price_set_version_eff_nullable.sql` (allow null `prc_price_set.effective_date` and `prc_price_set_version.effective_time` for drafts)
|
||||
|
||||
## Billing
|
||||
|
||||
Match by price_set_id; multi-version quote should filter active psv_id by bill time.
|
||||
@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS prc_price_set (
|
||||
default_discount DECIMAL(5,2) DEFAULT NULL COMMENT '默认折扣百分数 1-99,仅 DISCOUNT',
|
||||
default_type CHAR(1) DEFAULT NULL COMMENT '默认套餐 Y=默认',
|
||||
calculate_sign CHAR(1) DEFAULT NULL COMMENT '试算标记 Y=外部试算套餐',
|
||||
effective_date DATE NOT NULL COMMENT '生效日期',
|
||||
effective_date DATE DEFAULT NULL COMMENT 'effective date (null until activate)',
|
||||
expire_date DATE DEFAULT NULL COMMENT '失效日期(空=长期)',
|
||||
status CHAR(1) NOT NULL DEFAULT 'D' COMMENT 'D草稿 A审核中 E生效 R驳回 S停用',
|
||||
tms_id BIGINT(20) DEFAULT NULL COMMENT '多租户系统ID',
|
||||
@@ -46,17 +46,23 @@ CREATE TABLE IF NOT EXISTS prc_price_set_detail (
|
||||
zd_id BIGINT(20) DEFAULT NULL COMMENT 'legacy zone division id',
|
||||
wsd_id BIGINT(20) DEFAULT NULL COMMENT '重量段明细id',
|
||||
weight_label VARCHAR(50) DEFAULT NULL COMMENT '重量段展示',
|
||||
weight_min DECIMAL(10,3) DEFAULT NULL COMMENT '重量段最小值KG(含)',
|
||||
weight_max DECIMAL(10,3) DEFAULT NULL COMMENT '重量段最大值KG(含)',
|
||||
product_country_id BIGINT(20) DEFAULT NULL COMMENT '关联 bms_product_country.detail_id',
|
||||
fv_value DECIMAL(10,4) DEFAULT NULL COMMENT '运费单价 RMB/KG',
|
||||
fv_registration_fee DECIMAL(10,2) DEFAULT NULL COMMENT '挂号费 RMB/票',
|
||||
discount_value DECIMAL(5,2) DEFAULT NULL COMMENT '明细折扣百分数,DISCOUNT 可覆盖默认',
|
||||
round_mode VARCHAR(20) NOT NULL DEFAULT 'HALF_UP' COMMENT '取值方式(字典bms_round_mode)',
|
||||
pr_id INT(11) DEFAULT NULL COMMENT '关联价格规则id',
|
||||
effective_date DATE DEFAULT NULL COMMENT '生效日期',
|
||||
expire_date DATE DEFAULT NULL COMMENT '失效日期(空=长期)',
|
||||
create_time DATETIME DEFAULT NULL COMMENT '创建时间',
|
||||
update_time DATETIME DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (psd_id),
|
||||
INDEX idx_psd_set (price_set_id),
|
||||
INDEX idx_psd_product (price_set_id, product_code, country_code),
|
||||
INDEX idx_psd_weight_match (price_set_id, product_code, country_code, weight_min, weight_max),
|
||||
INDEX idx_psd_eff (price_set_id, effective_date, expire_date),
|
||||
INDEX idx_psd_product_country (product_country_id),
|
||||
CONSTRAINT fk_psd_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='价格套餐明细-固定价/折扣范围';
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
-- Prevent duplicate FIXED details within one version (same product_country snapshot row)
|
||||
-- MySQL allows multiple NULLs in UNIQUE, so DISCOUNT rows (product_country_id null) are OK.
|
||||
SET NAMES utf8mb4;
|
||||
SET @db := DATABASE();
|
||||
|
||||
-- Clean exact duplicates before adding unique key (keep min psd_id)
|
||||
DELETE d1 FROM prc_price_set_detail d1
|
||||
INNER JOIN prc_price_set_detail d2
|
||||
ON d1.psv_id = d2.psv_id
|
||||
AND d1.product_country_id = d2.product_country_id
|
||||
AND d1.psd_id > d2.psd_id
|
||||
WHERE d1.psv_id IS NOT NULL
|
||||
AND d1.product_country_id IS NOT NULL;
|
||||
|
||||
SET @has := (
|
||||
SELECT COUNT(*) FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_price_set_detail' AND INDEX_NAME = 'uk_psd_psv_product_country'
|
||||
);
|
||||
SET @sql := IF(@has = 0,
|
||||
'ALTER TABLE prc_price_set_detail ADD UNIQUE KEY uk_psd_psv_product_country (psv_id, product_country_id)',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
@@ -0,0 +1,38 @@
|
||||
-- prc_price_set_detail: weight_min/weight_max + effective_date/expire_date
|
||||
-- same types as bms_product_country
|
||||
SET NAMES utf8mb4;
|
||||
SET @db := DATABASE();
|
||||
|
||||
SET @has := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='prc_price_set_detail' AND COLUMN_NAME='weight_min');
|
||||
SET @sql := IF(@has=0, 'ALTER TABLE prc_price_set_detail ADD COLUMN weight_min DECIMAL(10,3) DEFAULT NULL COMMENT ''重量段最小值KG(含)'' AFTER weight_label', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @has := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='prc_price_set_detail' AND COLUMN_NAME='weight_max');
|
||||
SET @sql := IF(@has=0, 'ALTER TABLE prc_price_set_detail ADD COLUMN weight_max DECIMAL(10,3) DEFAULT NULL COMMENT ''重量段最大值KG(含)'' AFTER weight_min', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @has := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='prc_price_set_detail' AND COLUMN_NAME='effective_date');
|
||||
SET @sql := IF(@has=0, 'ALTER TABLE prc_price_set_detail ADD COLUMN effective_date DATE DEFAULT NULL COMMENT ''生效日期'' AFTER pr_id', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @has := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='prc_price_set_detail' AND COLUMN_NAME='expire_date');
|
||||
SET @sql := IF(@has=0, 'ALTER TABLE prc_price_set_detail ADD COLUMN expire_date DATE DEFAULT NULL COMMENT ''失效日期(空=长期)'' AFTER effective_date', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @has := (SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='prc_price_set_detail' AND INDEX_NAME='idx_psd_weight_match');
|
||||
SET @sql := IF(@has=0, 'ALTER TABLE prc_price_set_detail ADD INDEX idx_psd_weight_match (price_set_id, product_code, country_code, weight_min, weight_max)', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @has := (SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=@db AND TABLE_NAME='prc_price_set_detail' AND INDEX_NAME='idx_psd_eff');
|
||||
SET @sql := IF(@has=0, 'ALTER TABLE prc_price_set_detail ADD INDEX idx_psd_eff (price_set_id, effective_date, expire_date)', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 回填: 从 bms_product_country 带入重量段与有效期
|
||||
UPDATE prc_price_set_detail d
|
||||
INNER JOIN bms_product_country c ON c.detail_id = d.product_country_id
|
||||
SET
|
||||
d.weight_min = IFNULL(d.weight_min, c.weight_min),
|
||||
d.weight_max = IFNULL(d.weight_max, c.weight_max),
|
||||
d.effective_date = IFNULL(d.effective_date, c.effective_date),
|
||||
d.expire_date = IFNULL(d.expire_date, c.expire_date)
|
||||
WHERE d.product_country_id IS NOT NULL;
|
||||
@@ -0,0 +1,152 @@
|
||||
-- 价格套餐版本中间表 + 版本附加费
|
||||
-- 关系:
|
||||
-- prc_price_set
|
||||
-- -> prc_price_set_version (步骤2: 版本号自动生成, 生效时间)
|
||||
-- -> prc_price_set_detail (步骤3: 产品价格, 通过 psv_id)
|
||||
-- -> prc_price_set_version_surcharge (psd_id 关联明细)
|
||||
-- 可重复执行
|
||||
SET NAMES utf8mb4;
|
||||
SET @db := DATABASE();
|
||||
|
||||
CREATE TABLE IF NOT EXISTS prc_price_set_version (
|
||||
psv_id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '套餐版本id',
|
||||
price_set_id BIGINT(20) NOT NULL COMMENT '价格套餐id',
|
||||
version_no VARCHAR(20) NOT NULL COMMENT '版本号 V1/V2,自动+1',
|
||||
version_seq INT(11) NOT NULL COMMENT '版本序号,用于自动+1',
|
||||
effective_time DATETIME DEFAULT NULL COMMENT 'version start time (null until activate)',
|
||||
expire_time DATETIME DEFAULT NULL COMMENT '失效时间(空=长期;下一版本启动时写入该启动时间)',
|
||||
status CHAR(1) NOT NULL DEFAULT '0' COMMENT '0草稿 1生效 2失效',
|
||||
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 (psv_id),
|
||||
UNIQUE KEY uk_psv_set_no (price_set_id, version_no),
|
||||
UNIQUE KEY uk_psv_set_seq (price_set_id, version_seq),
|
||||
INDEX idx_psv_set_eff (price_set_id, effective_time),
|
||||
INDEX idx_psv_status (status),
|
||||
CONSTRAINT fk_psv_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='价格套餐版本';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS 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) DEFAULT NULL COMMENT '产品代码(与明细一致)',
|
||||
sc_name VARCHAR(100) NOT NULL COMMENT '附加费名称快照',
|
||||
fee_type VARCHAR(30) NOT NULL DEFAULT 'SURCHARGE' COMMENT '费用类型(字典bms_fee_type)',
|
||||
charge_type VARCHAR(20) NOT NULL COMMENT '计费方式 FIXED固定金额/WEIGHT按重量/RATE按比例',
|
||||
charge_value DECIMAL(18,6) NOT NULL COMMENT '计费数值快照',
|
||||
currency CHAR(3) NOT NULL DEFAULT 'CNY' COMMENT '币种',
|
||||
round_mode VARCHAR(20) NOT NULL DEFAULT 'HALF_UP' COMMENT '取值方式(字典bms_round_mode)',
|
||||
country_code CHAR(2) DEFAULT NULL COMMENT '适用国家ISO2(空=全部)',
|
||||
sc_note 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 (psvs_id),
|
||||
INDEX idx_psvs_psv (psv_id),
|
||||
INDEX idx_psvs_psd (psd_id),
|
||||
INDEX idx_psvs_product (psv_id, product_code),
|
||||
INDEX idx_psvs_sc (sc_id),
|
||||
CONSTRAINT fk_psvs_psv FOREIGN KEY (psv_id) REFERENCES prc_price_set_version (psv_id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_psvs_psd FOREIGN KEY (psd_id) REFERENCES prc_price_set_detail (psd_id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='价格套餐版本附加费快照';
|
||||
|
||||
|
||||
-- expire_time: previous version expire = next version effective_time (start)
|
||||
SET @has := (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_price_set_version' AND COLUMN_NAME = 'expire_time'
|
||||
);
|
||||
SET @sql := IF(@has = 0,
|
||||
'ALTER TABLE prc_price_set_version ADD COLUMN expire_time DATETIME DEFAULT NULL COMMENT ''失效时间(空=长期;下一版本启动时写入该启动时间)'' AFTER effective_time',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- backfill: expire_time = next version start time (by version_seq)
|
||||
UPDATE prc_price_set_version cur
|
||||
INNER JOIN prc_price_set_version nxt
|
||||
ON nxt.price_set_id = cur.price_set_id
|
||||
AND nxt.version_seq = cur.version_seq + 1
|
||||
SET cur.expire_time = nxt.effective_time;
|
||||
|
||||
-- prc_price_set_detail.psv_id
|
||||
SET @has := (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_price_set_detail' AND COLUMN_NAME = 'psv_id'
|
||||
);
|
||||
SET @sql := IF(@has = 0,
|
||||
'ALTER TABLE prc_price_set_detail ADD COLUMN psv_id BIGINT(20) DEFAULT NULL COMMENT ''套餐版本id'' AFTER price_set_id',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @has := (
|
||||
SELECT COUNT(*) FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_price_set_detail' AND INDEX_NAME = 'idx_psd_psv'
|
||||
);
|
||||
SET @sql := IF(@has = 0,
|
||||
'ALTER TABLE prc_price_set_detail ADD INDEX idx_psd_psv (psv_id)',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @has := (
|
||||
SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_price_set_detail' AND CONSTRAINT_NAME = 'fk_psd_psv'
|
||||
);
|
||||
SET @sql := IF(@has = 0,
|
||||
'ALTER TABLE prc_price_set_detail ADD CONSTRAINT fk_psd_psv FOREIGN KEY (psv_id) REFERENCES prc_price_set_version (psv_id) ON DELETE CASCADE',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 已建表补关联: 附加费.psd_id -> 套餐明细
|
||||
DELETE FROM prc_price_set_version_surcharge
|
||||
WHERE psd_id IS NULL
|
||||
OR NOT EXISTS (
|
||||
SELECT 1 FROM prc_price_set_detail d WHERE d.psd_id = prc_price_set_version_surcharge.psd_id
|
||||
);
|
||||
|
||||
SET @sql := CONCAT(
|
||||
'ALTER TABLE prc_price_set_version_surcharge MODIFY COLUMN psd_id BIGINT(20) NOT NULL COMMENT ''套餐明细id'''
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @has := (
|
||||
SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_price_set_version_surcharge' AND CONSTRAINT_NAME = 'fk_psvs_psd'
|
||||
);
|
||||
SET @sql := IF(@has = 0,
|
||||
'ALTER TABLE prc_price_set_version_surcharge ADD CONSTRAINT fk_psvs_psd FOREIGN KEY (psd_id) REFERENCES prc_price_set_detail (psd_id) ON DELETE CASCADE',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 回填: 每个已有套餐生成一条 V1
|
||||
INSERT INTO prc_price_set_version (
|
||||
price_set_id, version_no, version_seq, effective_time, status, created_by, create_time
|
||||
)
|
||||
SELECT
|
||||
s.price_set_id,
|
||||
'V1',
|
||||
1,
|
||||
COALESCE(CAST(s.effective_date AS DATETIME), s.create_time, NOW()),
|
||||
CASE
|
||||
WHEN s.status = 'S' THEN '2'
|
||||
WHEN s.expire_date IS NOT NULL AND s.expire_date <= CURDATE() THEN '2'
|
||||
WHEN s.status = 'E' AND (s.effective_date IS NULL OR s.effective_date <= CURDATE()) THEN '1'
|
||||
ELSE '0'
|
||||
END,
|
||||
IFNULL(s.created_by, ''),
|
||||
NOW()
|
||||
FROM prc_price_set s
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM prc_price_set_version v WHERE v.price_set_id = s.price_set_id
|
||||
);
|
||||
|
||||
-- 将已有明细绑定到同一套餐的 V1
|
||||
UPDATE prc_price_set_detail d
|
||||
INNER JOIN prc_price_set_version v
|
||||
ON v.price_set_id = d.price_set_id AND v.version_seq = 1
|
||||
SET d.psv_id = v.psv_id
|
||||
WHERE d.psv_id IS NULL;
|
||||
@@ -0,0 +1,23 @@
|
||||
-- Draft package / version: effective dates nullable until activate
|
||||
SET NAMES utf8mb4;
|
||||
SET @db := DATABASE();
|
||||
|
||||
-- prc_price_set.effective_date
|
||||
SET @nullable := (
|
||||
SELECT IS_NULLABLE FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_price_set' AND COLUMN_NAME = 'effective_date'
|
||||
);
|
||||
SET @sql := IF(@nullable = 'NO',
|
||||
'ALTER TABLE prc_price_set MODIFY COLUMN effective_date DATE DEFAULT NULL COMMENT ''effective date (null until version activate)''',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- prc_price_set_version.effective_time
|
||||
SET @nullable := (
|
||||
SELECT IS_NULLABLE FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_price_set_version' AND COLUMN_NAME = 'effective_time'
|
||||
);
|
||||
SET @sql := IF(@nullable = 'NO',
|
||||
'ALTER TABLE prc_price_set_version MODIFY COLUMN effective_time DATETIME DEFAULT NULL COMMENT ''version start time (null until activate)''',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
@@ -23,6 +23,60 @@ export function savePriceSet(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getPriceSetSaveTask(taskId) {
|
||||
return request({
|
||||
url: '/price/set/save/task/' + taskId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit save async and poll Redis progress until SUCCESS/FAIL.
|
||||
* @returns {Promise<{ priceSetId: number|string, task: object }>}
|
||||
*/
|
||||
export async function savePriceSetAsync(data, onProgress) {
|
||||
const submitRes = await savePriceSet(data)
|
||||
const taskId = pickSaveTaskId(submitRes)
|
||||
if (!taskId) {
|
||||
throw new Error('missing save taskId')
|
||||
}
|
||||
const started = Date.now()
|
||||
const maxMs = 30 * 60 * 1000
|
||||
while (Date.now() - started < maxMs) {
|
||||
const res = await getPriceSetSaveTask(taskId)
|
||||
const task = res.data || {}
|
||||
if (typeof onProgress === 'function') {
|
||||
onProgress(task)
|
||||
}
|
||||
if (task.status === 'SUCCESS') {
|
||||
return { priceSetId: task.priceSetId, task }
|
||||
}
|
||||
if (task.status === 'FAIL') {
|
||||
const err = new Error(task.error || task.message || 'save failed')
|
||||
err.task = task
|
||||
throw err
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 800))
|
||||
}
|
||||
throw new Error('save timeout')
|
||||
}
|
||||
|
||||
/** Accept data.taskId / data string / legacy msg UUID (RuoYi String overload). */
|
||||
function pickSaveTaskId(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
|
||||
}
|
||||
|
||||
export function updatePriceSet(data) {
|
||||
return request({
|
||||
url: '/price/set',
|
||||
@@ -59,6 +113,27 @@ export function rejectPriceSet(priceSetId) {
|
||||
})
|
||||
}
|
||||
|
||||
export function activatePriceSetVersion(psvId) {
|
||||
return request({
|
||||
url: '/price/set/version/activate/' + psvId,
|
||||
method: 'put'
|
||||
})
|
||||
}
|
||||
|
||||
export function copyPriceSetVersion(psvId) {
|
||||
return request({
|
||||
url: '/price/set/version/copy/' + psvId,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
export function deletePriceSetVersion(psvId) {
|
||||
return request({
|
||||
url: '/price/set/version/' + psvId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function disablePriceSet(priceSetId) {
|
||||
return request({
|
||||
url: '/price/set/disable/' + priceSetId,
|
||||
|
||||
@@ -27,6 +27,15 @@ export function listSurchargeByProduct(productCode) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 附加费配置全量(非分页,套餐明细勾选用;不要求 price:surcharge:list 权限) */
|
||||
export function listSurchargeOptions(query) {
|
||||
return request({
|
||||
url: '/price/surcharge/options',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
/** 绑定附加费到产品/明细(scId + productCode + detailId) */
|
||||
export function addSurchargeRel(data) {
|
||||
return request({
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
<el-tag size="small" :type="sourceTagType(detail.matchSource)">{{ sourceLabel(detail.matchSource) }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="套餐">{{ priceSetLabel(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="套餐版本">{{ detail.versionNo || (detail.psvId ? ('psv=' + detail.psvId) : '-') }}</el-descriptions-item>
|
||||
<el-descriptions-item label="币种">
|
||||
<dict-tag :options="bms_currency" :value="displayCurrency(detail.currency)" />
|
||||
</el-descriptions-item>
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
<el-descriptions-item label="套餐编号">{{ result.priceSetCode || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="套餐名称">{{ result.priceSetName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="套餐类型">{{ result.setType || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="套餐版本">{{ result.versionNo || (result.psvId ? ('psv=' + result.psvId) : '-') }}</el-descriptions-item>
|
||||
<el-descriptions-item label="币种">
|
||||
<dict-tag :options="bms_currency" :value="displayCurrency(result.currency)" />
|
||||
</el-descriptions-item>
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="mask" :class="{ open: modelValue }" @click="close"></div>
|
||||
<div class="drawer" :class="{ open: modelValue }">
|
||||
<div class="drawer-hd">
|
||||
<span>{{ title }}</span>
|
||||
<div class="hd-actions">
|
||||
<el-button size="small" @click="close">关闭</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="drawer-bd">
|
||||
<el-alert type="info" :closable="false" show-icon class="mb12" :title="hint" />
|
||||
<div class="filters">
|
||||
<el-input v-model="keyword" clearable :placeholder="phSearch" style="width: 240px" />
|
||||
</div>
|
||||
<el-table
|
||||
:data="displayRows"
|
||||
border
|
||||
size="small"
|
||||
:span-method="spanMethod"
|
||||
:row-class-name="rowClass"
|
||||
>
|
||||
<el-table-column :label="colCountry" min-width="100">
|
||||
<template #default="{ row }">{{ countryLabel(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colZone" min-width="90">
|
||||
<template #default="{ row }">{{ row.zoneName || row.zoneCode || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colWeight" prop="weightLabel" min-width="120" />
|
||||
<el-table-column :label="colSetFv" width="160" align="center">
|
||||
<template #default="{ row }">
|
||||
<div class="price-cell">
|
||||
<template v-if="editingKey !== cellKey(row, 'fv')">
|
||||
<span class="price-text">{{ formatNum(row.fvValue, 4) }}</span>
|
||||
<el-button link type="primary" icon="Edit" class="edit-ico" @click="startEdit(row, 'fv')" />
|
||||
</template>
|
||||
<el-input-number
|
||||
v-else
|
||||
:ref="el => setEditRef(el, row, 'fv')"
|
||||
v-model="row.fvValue"
|
||||
:min="0"
|
||||
:precision="4"
|
||||
:controls="false"
|
||||
size="small"
|
||||
style="width: 110px"
|
||||
@blur="() => commitEdit(row, 'fv')"
|
||||
@keyup.enter="() => commitEdit(row, 'fv')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colSetReg" width="150" align="center">
|
||||
<template #default="{ row }">
|
||||
<div class="price-cell">
|
||||
<template v-if="editingKey !== cellKey(row, 'reg')">
|
||||
<span class="price-text">{{ formatNum(row.fvRegistrationFee, 2) }}</span>
|
||||
<el-button link type="primary" icon="Edit" class="edit-ico" @click="startEdit(row, 'reg')" />
|
||||
</template>
|
||||
<el-input-number
|
||||
v-else
|
||||
:ref="el => setEditRef(el, row, 'reg')"
|
||||
v-model="row.fvRegistrationFee"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:controls="false"
|
||||
size="small"
|
||||
style="width: 100px"
|
||||
@blur="() => commitEdit(row, 'reg')"
|
||||
@keyup.enter="() => commitEdit(row, 'reg')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colSurcharge" width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<surcharge-count-cell :list="row.surcharges || []" @click="pickSurcharge(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colAction" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="pickSurcharge(row)">附加费</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PriceEditDrawer">
|
||||
import SurchargeCountCell from './SurchargeCountCell.vue'
|
||||
import { isDetailPriceChanged } from '../../utils/priceSet'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: Boolean, default: false },
|
||||
productCode: { type: String, default: '' },
|
||||
productName: { type: String, default: '' },
|
||||
rows: { type: Array, default: () => [] }
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue', 'pick-surcharge', 'row-change'])
|
||||
|
||||
const keyword = ref('')
|
||||
const editingKey = ref('')
|
||||
const committing = ref(false)
|
||||
const editInputRefs = {}
|
||||
|
||||
const title = computed(() => {
|
||||
const code = props.productCode || ''
|
||||
const name = props.productName || ''
|
||||
return code + ' · ' + name + ' · 国家服务价格'
|
||||
})
|
||||
const hint = '黄色行=已改价;点编辑图标后修改,失焦即刻写入数据库。单位:运费 RMB/KG,挂号费 RMB/票。'
|
||||
const phSearch = '搜索国家/分区'
|
||||
const colCountry = '国家'
|
||||
const colZone = '分区'
|
||||
const colWeight = '重量段'
|
||||
const colSetFv = '套餐运费'
|
||||
const colSetReg = '套餐挂号费'
|
||||
const colSurcharge = '附加费'
|
||||
const colAction = '操作'
|
||||
|
||||
function cellKey(row, field) {
|
||||
return String(row && row.psdId != null ? row.psdId : row && row.productCountryId) + ':' + field
|
||||
}
|
||||
|
||||
function formatNum(v, precision) {
|
||||
if (v == null || v === '') return '-'
|
||||
const n = Number(v)
|
||||
if (Number.isNaN(n)) return '-'
|
||||
return n.toFixed(precision)
|
||||
}
|
||||
|
||||
function setEditRef(el, row, field) {
|
||||
if (el) editInputRefs[cellKey(row, field)] = el
|
||||
}
|
||||
|
||||
function startEdit(row, field) {
|
||||
if (!row) return
|
||||
editingKey.value = cellKey(row, field)
|
||||
nextTick(() => {
|
||||
const el = editInputRefs[editingKey.value]
|
||||
if (el && typeof el.focus === 'function') el.focus()
|
||||
})
|
||||
}
|
||||
|
||||
async function commitEdit(row, field) {
|
||||
if (committing.value) return
|
||||
if (editingKey.value !== cellKey(row, field)) return
|
||||
editingKey.value = ''
|
||||
if (!row || !row.psdId) return
|
||||
committing.value = true
|
||||
try {
|
||||
emit('row-change', row)
|
||||
} finally {
|
||||
committing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function pickSurcharge(row) {
|
||||
emit('pick-surcharge', row || null)
|
||||
}
|
||||
|
||||
function countryKey(row) {
|
||||
return String(row.countryCode || row.countryName || '').toUpperCase()
|
||||
}
|
||||
|
||||
function countryLabel(row) {
|
||||
return row.countryName || row.countryCode || '-'
|
||||
}
|
||||
|
||||
const displayRows = computed(() => {
|
||||
const q = (keyword.value || '').trim().toLowerCase()
|
||||
let list = [...(props.rows || [])]
|
||||
if (q) {
|
||||
list = list.filter(r => {
|
||||
const blob = [r.countryName, r.countryCode, r.zoneName, r.zoneCode, r.weightLabel]
|
||||
.filter(Boolean).join(' ').toLowerCase()
|
||||
return blob.includes(q)
|
||||
})
|
||||
}
|
||||
list.sort((a, b) => {
|
||||
const ca = countryKey(a)
|
||||
const cb = countryKey(b)
|
||||
if (ca !== cb) return ca.localeCompare(cb)
|
||||
const za = String(a.zoneCode || a.zoneName || '')
|
||||
const zb = String(b.zoneCode || b.zoneName || '')
|
||||
if (za !== zb) return za.localeCompare(zb)
|
||||
return String(a.weightLabel || '').localeCompare(String(b.weightLabel || ''))
|
||||
})
|
||||
return list
|
||||
})
|
||||
|
||||
function buildSpans(rows, keyOf) {
|
||||
const spans = new Array(rows.length).fill(1)
|
||||
let i = 0
|
||||
while (i < rows.length) {
|
||||
let j = i + 1
|
||||
const key = keyOf(rows[i])
|
||||
while (j < rows.length && keyOf(rows[j]) === key) j++
|
||||
spans[i] = j - i
|
||||
for (let k = i + 1; k < j; k++) spans[k] = 0
|
||||
i = j
|
||||
}
|
||||
return spans
|
||||
}
|
||||
|
||||
function zoneKey(row) {
|
||||
return String(row.zoneCode || row.zoneName || '')
|
||||
}
|
||||
|
||||
const countrySpans = computed(() => buildSpans(displayRows.value, countryKey))
|
||||
const zoneSpans = computed(() => buildSpans(displayRows.value, r => countryKey(r) + '|' + zoneKey(r)))
|
||||
|
||||
function spanMethod({ columnIndex, rowIndex }) {
|
||||
if (columnIndex === 0) return spanOf(countrySpans.value, rowIndex)
|
||||
if (columnIndex === 1) return spanOf(zoneSpans.value, rowIndex)
|
||||
return { rowspan: 1, colspan: 1 }
|
||||
}
|
||||
|
||||
function spanOf(spans, rowIndex) {
|
||||
const rowspan = spans[rowIndex] || 0
|
||||
return rowspan > 0 ? { rowspan, colspan: 1 } : { rowspan: 0, colspan: 0 }
|
||||
}
|
||||
|
||||
function rowClass({ row }) {
|
||||
return isDetailPriceChanged(row) ? 'changed-row' : ''
|
||||
}
|
||||
|
||||
function close() {
|
||||
editingKey.value = ''
|
||||
emit('update:modelValue', false)
|
||||
}
|
||||
|
||||
watch(() => props.modelValue, v => {
|
||||
if (v) {
|
||||
keyword.value = ''
|
||||
editingKey.value = ''
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.35);
|
||||
z-index: 1999;
|
||||
display: none;
|
||||
}
|
||||
.mask.open { display: block; }
|
||||
.drawer {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: min(960px, 96vw);
|
||||
height: 100%;
|
||||
background: #fff;
|
||||
box-shadow: -4px 0 16px rgba(0, 0, 0, 0.12);
|
||||
transform: translateX(100%);
|
||||
transition: 0.25s;
|
||||
z-index: 2000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.drawer.open { transform: translateX(0); }
|
||||
.drawer-hd {
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.hd-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.drawer-bd {
|
||||
padding: 16px 20px;
|
||||
overflow: auto;
|
||||
flex: 1;
|
||||
}
|
||||
.mb12 { margin-bottom: 12px; }
|
||||
.filters { margin-bottom: 12px; }
|
||||
.price-cell {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
min-height: 28px;
|
||||
}
|
||||
.price-text {
|
||||
font-variant-numeric: tabular-nums;
|
||||
min-width: 64px;
|
||||
text-align: right;
|
||||
}
|
||||
.edit-ico {
|
||||
padding: 0 2px !important;
|
||||
}
|
||||
:deep(.changed-row > td) {
|
||||
background: #fffbe6 !important;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<div class="price-edit-panel" v-loading="loading">
|
||||
<div class="panel-head">
|
||||
<div class="panel-title">
|
||||
<el-button link type="primary" @click="close">
|
||||
<el-icon><arrow-left /></el-icon>
|
||||
返回详情
|
||||
</el-button>
|
||||
<i class="panel-bar" />
|
||||
<span>{{ title }}</span>
|
||||
</div>
|
||||
<div class="panel-actions">
|
||||
<el-button @click="close">关闭</el-button>
|
||||
<el-button type="primary" :disabled="!priceSetId" @click="close">完成</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<step-details
|
||||
v-if="loaded"
|
||||
:details="details"
|
||||
:price-set-id="priceSetId"
|
||||
:set-type="setType"
|
||||
:effective-time="version.effectiveTime"
|
||||
:version-no="version.versionNo"
|
||||
:ref-data="refData"
|
||||
header-title="编辑产品价格"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PriceEditPanel">
|
||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
||||
import StepDetails from './StepDetails.vue'
|
||||
import { usePriceSetRefData, useDetailCascade } from '../../composables/usePriceSetRefData'
|
||||
import { getPriceSet } from '@/api/price/set'
|
||||
|
||||
const props = defineProps({
|
||||
priceSetId: { type: [Number, String], default: undefined },
|
||||
psvId: { type: [Number, String], default: undefined }
|
||||
})
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const refData = usePriceSetRefData()
|
||||
const cascade = useDetailCascade(refData)
|
||||
|
||||
const loading = ref(false)
|
||||
const loaded = ref(false)
|
||||
const setType = ref('FIXED')
|
||||
const version = reactive({ psvId: undefined, versionNo: 'V1', effectiveTime: undefined })
|
||||
const details = ref([])
|
||||
|
||||
const title = computed(() => '编辑产品价格 · ' + (version.versionNo || ''))
|
||||
|
||||
function load() {
|
||||
const id = props.priceSetId
|
||||
if (!id) {
|
||||
proxy.$modal.msgError('缺少套餐ID')
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
loaded.value = false
|
||||
getPriceSet(id).then(res => {
|
||||
const data = res.data || {}
|
||||
setType.value = data.setType || 'FIXED'
|
||||
|
||||
const versions = data.versions || []
|
||||
const qPsv = props.psvId
|
||||
const byQuery = qPsv != null ? versions.find(v => String(v.psvId) === String(qPsv)) : null
|
||||
const current = byQuery || data.version || versions[0] || {}
|
||||
version.psvId = current.psvId
|
||||
version.versionNo = current.versionNo || 'V1'
|
||||
version.effectiveTime = current.effectiveTime
|
||||
|
||||
const src = (current.details && current.details.length) ? current.details : (data.details || [])
|
||||
details.value = src.map(d => cascade.hydrateRow(d, setType.value))
|
||||
loaded.value = true
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function close() {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
refData.loadProducts().finally(load)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.price-edit-panel {
|
||||
background: #fff;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.panel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
}
|
||||
.panel-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
.panel-bar {
|
||||
width: 3px;
|
||||
height: 14px;
|
||||
border-radius: 2px;
|
||||
background: #1890ff;
|
||||
flex: none;
|
||||
}
|
||||
.panel-title span {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
.panel-actions {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.panel-body {
|
||||
padding: 16px;
|
||||
}</style>
|
||||
@@ -41,15 +41,6 @@
|
||||
<div class="form-hint">范围 1~99,88 表示默认价 × 0.88;FIXED 模式此值忽略</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="生效日期" prop="effectiveDate">
|
||||
<el-date-picker v-model="basic.effectiveDate" type="date" value-format="YYYY-MM-DD" placeholder="生效日期" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="失效日期" prop="expireDate">
|
||||
<el-date-picker v-model="basic.expireDate" type="date" value-format="YYYY-MM-DD" placeholder="空表示长期有效" />
|
||||
<div class="form-hint">空表示长期有效</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="说明备注" prop="priceSetNote">
|
||||
<el-input v-model="basic.priceSetNote" type="textarea" :rows="3" maxlength="200" placeholder="套餐业务说明,显示给客户与运营" />
|
||||
</el-form-item>
|
||||
@@ -69,7 +60,6 @@ const formRef = ref()
|
||||
const rules = {
|
||||
priceSetName: [{ required: true, message: '套餐名称不能为空', trigger: 'blur' }],
|
||||
setType: [{ required: true, message: '请选择计价类型', trigger: 'change' }],
|
||||
effectiveDate: [{ required: true, message: '生效日期不能为空', trigger: 'change' }]
|
||||
}
|
||||
|
||||
/** 供父级在下一步 / 保存前调用 */
|
||||
|
||||
@@ -2,95 +2,23 @@
|
||||
<el-card shadow="never" class="step-card">
|
||||
<template #header>
|
||||
<div class="card-head">
|
||||
<span>第 3 步 · 绑定客户<span class="sub">可选,可后续补充</span></span>
|
||||
<el-button type="primary" size="small" icon="Plus" @click="addRow">添加客户</el-button>
|
||||
<span>已绑定客户<span class="sub">仅查看,请到套餐详情页维护绑定</span></span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-alert
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb12"
|
||||
title="套餐创建后处于草稿状态,可暂不绑定客户。一个客户只能绑定一个套餐。"
|
||||
/>
|
||||
|
||||
<el-table :data="customers" border empty-text="暂未绑定客户">
|
||||
<el-table-column label="客户" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<customer-select
|
||||
v-model="row.customerCode"
|
||||
value-key="customerCode"
|
||||
placeholder="请选择客户"
|
||||
@change="(code, item) => onCustomerChange(row, code, item)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="客户代码" prop="customerCode" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="客户名称" prop="customerName" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="优先级" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.bindPriority" :min="1" controls-position="right" style="width: 100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="生效日期" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<el-date-picker v-model="row.prBegindate" type="date" value-format="YYYY-MM-DD" style="width: 100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="失效日期" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<el-date-picker v-model="row.prEnddate" type="date" value-format="YYYY-MM-DD" style="width: 100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80" align="center">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="danger" @click="customers.splice($index, 1)">移除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="客户代码" prop="customerCode" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="客户名称" prop="customerName" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="优先级" prop="bindPriority" width="110" align="center" />
|
||||
</el-table>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script setup name="StepCustomers">
|
||||
/**
|
||||
* 第 3 步 · 绑定客户
|
||||
* customers 为父级 form.customers 的同一数组引用;新行默认继承套餐生效/失效日期。
|
||||
*/
|
||||
import { createEmptyCustomerRow } from '../../utils/priceSet'
|
||||
|
||||
const props = defineProps({
|
||||
/** 客户绑定行数组(父级 form.customers) */
|
||||
customers: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
/** 套餐生效日期,用于新行默认值 */
|
||||
effectiveDate: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
/** 套餐失效日期,用于新行默认值 */
|
||||
expireDate: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
defineProps({
|
||||
customers: { type: Array, required: true },
|
||||
readOnly: { type: Boolean, default: true }
|
||||
})
|
||||
|
||||
function addRow() {
|
||||
props.customers.push(createEmptyCustomerRow({
|
||||
effectiveDate: props.effectiveDate,
|
||||
expireDate: props.expireDate,
|
||||
seq: props.customers.length + 1
|
||||
}))
|
||||
}
|
||||
|
||||
/** 下拉选中客户后回填代码 / 名称 / ID */
|
||||
function onCustomerChange(row, code, item) {
|
||||
row.customerCode = code || undefined
|
||||
row.customerName = item ? item.customerName : ''
|
||||
row.customerId = item ? item.customerId : undefined
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -105,7 +33,4 @@ function onCustomerChange(row, code, item) {
|
||||
font-weight: normal;
|
||||
font-size: 13px;
|
||||
}
|
||||
.mb12 {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,191 +1,473 @@
|
||||
<template>
|
||||
<el-card shadow="never" class="step-card">
|
||||
<el-card shadow="never" class="step-card" v-loading="pulling" :element-loading-text="loadingText">
|
||||
<template #header>
|
||||
<div class="card-head">
|
||||
<span>
|
||||
第 2 步 · 套餐明细
|
||||
<span class="sub">当前:{{ setTypeLabel(setType) }}模式</span>
|
||||
{{ headerTitle }}
|
||||
<span class="sub">{{ typeHint }}</span>
|
||||
</span>
|
||||
<el-button type="primary" size="small" icon="Plus" @click="addRow">添加明细行</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-alert
|
||||
v-if="isFixedType(setType)"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb12"
|
||||
title="FIXED 模式:可不填明细(计费取 bms_product_country 默认运费/挂号费);有明细时按产品×国家×分区×重量段覆盖固定价。附加费来自产品关联,只读展示。"
|
||||
/>
|
||||
<el-alert
|
||||
v-else
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb12"
|
||||
title="DISCOUNT 模式:可不填明细(全部产品适用默认折扣),或按产品限定折扣范围。"
|
||||
/>
|
||||
<el-alert type="info" :closable="false" show-icon class="mb12" :title="metaText" />
|
||||
|
||||
<el-table :data="details" border empty-text="暂无明细,点击添加明细行">
|
||||
<el-table-column label="产品" min-width="180">
|
||||
<div class="filters">
|
||||
<el-input v-model="query.keyword" clearable :placeholder="phKeyword" style="width: 180px" />
|
||||
<el-select v-model="query.taxMode" clearable :placeholder="phTax" style="width: 140px">
|
||||
<el-option v-for="d in bms_tax_mode" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
<el-button size="small" @click="noop">查询</el-button>
|
||||
</div>
|
||||
|
||||
<el-table :data="filteredProducts" border empty-text="暂无产品价格明细">
|
||||
<el-table-column :label="colCode" min-width="80">
|
||||
<template #default="{ row }"><b>{{ row.productCode }}</b></template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colName" prop="productName" min-width="80" show-overflow-tooltip />
|
||||
<el-table-column :label="colLevel" prop="serviceLevel" width="90" align="center" />
|
||||
<el-table-column :label="colCargo" width="200" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select
|
||||
v-model="row.productCode"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="选择产品"
|
||||
style="width: 100%"
|
||||
@change="onProductChange(row, setType)"
|
||||
>
|
||||
<el-option v-for="p in refData.productOptions.value" :key="p.value" :label="p.label" :value="p.value" />
|
||||
</el-select>
|
||||
<el-tag v-if="row.cargoAttr" type="primary" size="small" effect="plain">{{ row.cargoAttr }}</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column v-if="isFixedType(setType)" label="国家" min-width="140">
|
||||
<el-table-column :label="colRegion" prop="destRegion" width="90" align="center" />
|
||||
<el-table-column :label="colTax" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select
|
||||
v-model="row._countryKey"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="选择国家"
|
||||
style="width: 100%"
|
||||
:disabled="!row.productCode"
|
||||
@change="onCountryChange(row)"
|
||||
>
|
||||
<el-option
|
||||
v-for="c in refData.countryOptionsOf(row)"
|
||||
:key="c.key"
|
||||
:label="c.label"
|
||||
:value="c.key"
|
||||
/>
|
||||
</el-select>
|
||||
<dict-tag :options="bms_tax_mode" :value="row.taxMode" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column v-if="isFixedType(setType)" label="分区" min-width="140">
|
||||
<el-table-column :label="colSurcharge" width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select
|
||||
v-if="refData.hasZonesOf(row)"
|
||||
v-model="row.zoneCode"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="选择分区"
|
||||
style="width: 100%"
|
||||
:disabled="!row._countryKey"
|
||||
@change="onZoneChange(row)"
|
||||
>
|
||||
<el-option
|
||||
v-for="z in refData.zoneOptionsOf(row)"
|
||||
:key="z.key"
|
||||
:label="z.label"
|
||||
:value="z.zoneCode"
|
||||
/>
|
||||
</el-select>
|
||||
<span v-else class="muted">-</span>
|
||||
<surcharge-count-cell :list="productSurcharges(row)" @click="openSurcharge(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column v-if="isFixedType(setType)" label="重量段" min-width="150">
|
||||
<el-table-column :label="colAction" width="220" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-select
|
||||
v-model="row.weightLabel"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="选择重量段"
|
||||
style="width: 100%"
|
||||
:disabled="!row._countryKey || (refData.hasZonesOf(row) && !row.zoneCode)"
|
||||
@change="onWeightChange(row)"
|
||||
>
|
||||
<el-option
|
||||
v-for="w in refData.weightOptionsOf(row)"
|
||||
:key="w.value"
|
||||
:label="w.label"
|
||||
:value="w.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column v-if="isFixedType(setType)" label="运费单价(RMB/KG)" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.fvValue" :min="0" :precision="4" :step="1" controls-position="right" style="width: 100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column v-if="isFixedType(setType)" label="挂号费(RMB/票)" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.fvRegistrationFee" :min="0" :precision="2" :step="1" controls-position="right" style="width: 100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column v-if="isDiscountType(setType)" label="产品折扣%" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.discountValue" :min="1" :max="99" :precision="2" controls-position="right" style="width: 100%" placeholder="空=默认折扣" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="附加费" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<div v-if="!row.productCode" class="muted">-</div>
|
||||
<surcharge-tags v-else :list="surchargesOf(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="取值方式" min-width="130">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.roundMode" placeholder="取值方式" style="width: 100%">
|
||||
<el-option v-for="d in bms_round_mode" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" width="80" align="center">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="danger" @click="details.splice($index, 1)">删除</el-button>
|
||||
<el-button link type="primary" @click="openPrice(row)">编辑价格</el-button>
|
||||
<el-button link type="primary" @click="openSurcharge(row)">附加费</el-button>
|
||||
<el-button link type="danger" @click="removeProduct(row.productCode)">移除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<surcharge-picker-dialog
|
||||
v-model="scVisible"
|
||||
:title="scTitle"
|
||||
:list="scList"
|
||||
:selected-ids="scPickedIds"
|
||||
@confirm="onSurchargeConfirm"
|
||||
/>
|
||||
|
||||
<el-dialog v-model="discVisible" :title="discTitle" width="420px" append-to-body>
|
||||
<el-form label-width="100px">
|
||||
<el-form-item :label="colDiscount">
|
||||
<el-input-number v-model="discValue" :min="1" :max="99" :precision="2" controls-position="right" />
|
||||
<span class="unit">%</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="discVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="saveDiscount">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<price-edit-drawer
|
||||
v-model="priceVisible"
|
||||
:product-code="editCode"
|
||||
:product-name="editName"
|
||||
:rows="editRows"
|
||||
@row-change="onRowPriceChange"
|
||||
@pick-surcharge="openSurchargeFromDrawer"
|
||||
/>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script setup name="StepDetails">
|
||||
/**
|
||||
* 第 2 步 · 套餐明细
|
||||
* details 为父级 form.details 的同一数组引用,增删行直接原地操作。
|
||||
*/
|
||||
import SurchargeTags from '../SurchargeTags.vue'
|
||||
import PriceEditDrawer from './PriceEditDrawer.vue'
|
||||
import SurchargeCountCell from './SurchargeCountCell.vue'
|
||||
import SurchargePickerDialog from './SurchargePickerDialog.vue'
|
||||
import { useDetailCascade } from '../../composables/usePriceSetRefData'
|
||||
import { createEmptyDetailRow, isDiscountType, isFixedType, setTypeLabel } from '../../utils/priceSet'
|
||||
import {
|
||||
createEmptyDetailRow,
|
||||
formatWeightLabel,
|
||||
isDiscountType,
|
||||
isFixedType,
|
||||
setTypeLabel,
|
||||
surchargeAppliesToRow,
|
||||
toDetailPayload
|
||||
} from '../../utils/priceSet'
|
||||
import { updateSetDetail, delSetDetail } from '@/api/price/set'
|
||||
|
||||
const props = defineProps({
|
||||
/** 明细行数组(父级 form.details) */
|
||||
details: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
/** 计价类型 FIXED / DISCOUNT */
|
||||
setType: {
|
||||
type: String,
|
||||
default: 'FIXED'
|
||||
},
|
||||
/** 页面共享的参考数据(usePriceSetRefData 返回值) */
|
||||
refData: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
details: { type: Array, required: true },
|
||||
priceSetId: { type: [Number, String], default: undefined },
|
||||
setType: { type: String, default: 'FIXED' },
|
||||
effectiveTime: { type: String, default: undefined },
|
||||
versionNo: { type: String, default: '' },
|
||||
refData: { type: Object, required: true },
|
||||
headerTitle: { type: String, default: '第 2 步 · 编辑产品价格' }
|
||||
})
|
||||
|
||||
const { bms_round_mode } = useDict('bms_round_mode')
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_tax_mode } = useDict('bms_tax_mode')
|
||||
const { hydrateRow } = useDetailCascade(props.refData)
|
||||
|
||||
/** 参考数据来自父页面,缓存与请求去重全页面共享 */
|
||||
const { productOptions, surchargesOf, countryOptionsOf, weightOptionsOf } = props.refData
|
||||
const { onProductChange, onCountryChange, onZoneChange, onWeightChange } = useDetailCascade(props.refData)
|
||||
const loadingText = '正在全量拉取产品价格…'
|
||||
const phKeyword = '产品代码/名称'
|
||||
const phTax = '全部税模式'
|
||||
const colCode = '产品代码'
|
||||
const colName = '产品名称'
|
||||
const colLevel = '时效等级'
|
||||
const colCargo = '走货属性'
|
||||
const colRegion = '目的区域'
|
||||
const colTax = '税模式'
|
||||
const colSurcharge = '附加费'
|
||||
const colAction = '操作'
|
||||
const colDiscount = '产品折扣'
|
||||
|
||||
function addRow() {
|
||||
props.details.push(createEmptyDetailRow())
|
||||
const query = reactive({ keyword: '', taxMode: undefined })
|
||||
const priceVisible = ref(false)
|
||||
const editCode = ref('')
|
||||
const editName = ref('')
|
||||
const editRows = ref([])
|
||||
/** 抽屉当前对应的产品分组(抽屉内点附加费时用它打开勾选弹窗) */
|
||||
const editGroup = ref(null)
|
||||
const scVisible = ref(false)
|
||||
const scTitle = ref('附加费')
|
||||
const scList = ref([])
|
||||
const scRows = ref([])
|
||||
const scPickedIds = ref([])
|
||||
/** 作用范围:null=产品级(覆盖全部明细行),否则=行级键(只写回国家+重量段那一行) */
|
||||
const scScopeKey = ref(null)
|
||||
const scScopeName = ref('')
|
||||
const discVisible = ref(false)
|
||||
const discTitle = ref('编辑价格')
|
||||
const discValue = ref(undefined)
|
||||
const discCode = ref('')
|
||||
|
||||
const typeHint = computed(() => '· 当前:' + setTypeLabel(props.setType))
|
||||
|
||||
const metaText = computed(() => {
|
||||
const ver = props.versionNo || 'V?'
|
||||
return ver + ' · 数据已落库,编辑价格/附加费会立即写入数据库。'
|
||||
})
|
||||
|
||||
const productGroups = computed(() => {
|
||||
const map = new Map()
|
||||
for (const d of props.details) {
|
||||
if (!d.productCode) continue
|
||||
if (!map.has(d.productCode)) {
|
||||
const meta = props.refData.productMetaOf(d.productCode) || {}
|
||||
map.set(d.productCode, {
|
||||
productCode: d.productCode,
|
||||
productName: d.productName || meta.name || d.productCode,
|
||||
serviceLevel: meta.serviceLevel,
|
||||
cargoAttr: meta.cargoAttr,
|
||||
destRegion: meta.destRegion,
|
||||
taxMode: meta.taxMode,
|
||||
rows: []
|
||||
})
|
||||
}
|
||||
map.get(d.productCode).rows.push(d)
|
||||
}
|
||||
return [...map.values()]
|
||||
})
|
||||
|
||||
const filteredProducts = computed(() => {
|
||||
const kw = (query.keyword || '').trim().toLowerCase()
|
||||
return productGroups.value.filter(p => {
|
||||
if (query.taxMode && p.taxMode !== query.taxMode) return false
|
||||
if (!kw) return true
|
||||
const blob = [p.productCode, p.productName].filter(Boolean).join(' ').toLowerCase()
|
||||
return blob.includes(kw)
|
||||
})
|
||||
})
|
||||
|
||||
const pulling = ref(false)
|
||||
|
||||
function noop() {}
|
||||
|
||||
/** 该产品所有明细行附加费的并集(按 scId 去重),列表列展示用 */
|
||||
function productSurcharges(row) {
|
||||
const seen = new Set()
|
||||
const list = []
|
||||
;((row && row.rows) || []).forEach(r => {
|
||||
(r.surcharges || []).forEach(s => {
|
||||
const key = s && s.scId != null ? String(s.scId) : (s && s.scName)
|
||||
if (!key || seen.has(key)) return
|
||||
seen.add(key)
|
||||
list.push(s)
|
||||
})
|
||||
})
|
||||
return list
|
||||
}
|
||||
|
||||
/** enter step 3: pull all library products + country prices (skip already added) */
|
||||
async function pullAllFromLibrary(opts = {}) {
|
||||
const silent = !!opts.silent
|
||||
const replace = !!opts.replace
|
||||
if (!(props.refData.productOptions.value || []).length) {
|
||||
await props.refData.loadProducts()
|
||||
}
|
||||
const products = props.refData.productOptions.value || []
|
||||
if (!products.length) {
|
||||
if (!silent) proxy.$modal.msgWarning('产品库无可用产品')
|
||||
return { added: 0 }
|
||||
}
|
||||
if (replace) {
|
||||
props.details.splice(0, props.details.length)
|
||||
}
|
||||
const used = new Set((props.details || []).map(d => d.productCode).filter(Boolean))
|
||||
const toAdd = products.filter(p => !used.has(p.value))
|
||||
if (!toAdd.length) return { added: 0 }
|
||||
|
||||
pulling.value = true
|
||||
let added = 0
|
||||
try {
|
||||
// parallel fetch countries/surcharges, then push rows
|
||||
await Promise.all(toAdd.map(async (p) => {
|
||||
const code = p.value
|
||||
const name = p.name || props.refData.productNameOf(code)
|
||||
await props.refData.ensureSurcharges(code)
|
||||
if (isDiscountType(props.setType)) {
|
||||
const row = createEmptyDetailRow()
|
||||
row.productCode = code
|
||||
row.productName = name
|
||||
row.surcharges = props.refData.surchargesOf(row)
|
||||
props.details.push(row)
|
||||
added++
|
||||
return
|
||||
}
|
||||
const open = await props.refData.ensureCountries(code, props.effectiveTime)
|
||||
if (!open.length) return
|
||||
open.forEach(item => {
|
||||
const row = countryToDetail(item, code, name)
|
||||
row.surcharges = props.refData.surchargesOf(row)
|
||||
props.details.push(row)
|
||||
})
|
||||
added++
|
||||
}))
|
||||
if (!silent) {
|
||||
if (added > 0) proxy.$modal.msgSuccess('已从产品库全量拉取 ' + added + ' 个产品')
|
||||
else proxy.$modal.msgWarning('未拉取到可展示的产品价格明细,请检查产品库国家配置')
|
||||
}
|
||||
} finally {
|
||||
pulling.value = false
|
||||
}
|
||||
return { added }
|
||||
}
|
||||
|
||||
function countryToDetail(item, productCode, productName) {
|
||||
const row = createEmptyDetailRow()
|
||||
row.productCode = productCode
|
||||
row.productName = productName
|
||||
row.countryCode = item.countryCode
|
||||
row.countryName = item.countryName
|
||||
row.zoneId = item.zoneId
|
||||
row.zoneCode = item.zoneCode
|
||||
row.zoneName = item.zoneName
|
||||
row.weightMin = item.weightMin
|
||||
row.weightMax = item.weightMax
|
||||
row.weightLabel = formatWeightLabel(item.weightMin, item.weightMax)
|
||||
row.productCountryId = item.detailId
|
||||
const baseFv = item.freightPrice != null ? Number(item.freightPrice) : undefined
|
||||
const baseReg = item.registrationFee != null ? Number(item.registrationFee) : undefined
|
||||
row._baseFreight = baseFv
|
||||
row._baseReg = baseReg
|
||||
row.fvValue = baseFv
|
||||
row.fvRegistrationFee = baseReg
|
||||
row.effectiveDate = item.effectiveDate
|
||||
row.expireDate = item.expireDate
|
||||
row._countryKey = item.countryCode || (item.countryName ? 'N:' + item.countryName : undefined)
|
||||
return hydrateRow(row, props.setType)
|
||||
}
|
||||
|
||||
function openPrice(row) {
|
||||
if (isDiscountType(props.setType)) {
|
||||
discCode.value = row.productCode
|
||||
discTitle.value = row.productCode + ' · ' + (row.productName || '') + ' · 产品折扣'
|
||||
const hit = (props.details || []).find(d => d.productCode === row.productCode)
|
||||
discValue.value = hit && hit.discountValue != null ? Number(hit.discountValue) : undefined
|
||||
discVisible.value = true
|
||||
return
|
||||
}
|
||||
editCode.value = row.productCode
|
||||
editName.value = row.productName || ''
|
||||
editRows.value = (row.rows || []).map(r => {
|
||||
if (r._baseFreight == null && r.fvValue != null) r._baseFreight = Number(r.fvValue)
|
||||
if (r._baseReg == null && r.fvRegistrationFee != null) r._baseReg = Number(r.fvRegistrationFee)
|
||||
return r
|
||||
})
|
||||
editGroup.value = row
|
||||
priceVisible.value = true
|
||||
}
|
||||
|
||||
/** 抽屉里点附加费:带行 = 行级(只改该行,国家+重量段),不带 = 产品级(覆盖全部明细行) */
|
||||
function openSurchargeFromDrawer(row) {
|
||||
const group = editGroup.value || { productCode: editCode.value, rows: editRows.value }
|
||||
if (row && (row.countryCode || row.countryName)) {
|
||||
openSurcharge(group, rowScopeKey(row), rowScopeLabel(row))
|
||||
} else {
|
||||
openSurcharge(group)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** persist one detail row to DB immediately */
|
||||
async function persistDetail(row, withSurcharge) {
|
||||
if (!row || !row.psdId || !props.priceSetId) return
|
||||
const payload = toDetailPayload(row)
|
||||
payload.priceSetId = props.priceSetId
|
||||
if (!withSurcharge) delete payload.surcharges
|
||||
await updateSetDetail(payload)
|
||||
}
|
||||
|
||||
/** drawer field change -> immediate DB update */
|
||||
async function onRowPriceChange(row) {
|
||||
if (!row || !row.psdId) return
|
||||
try {
|
||||
await persistDetail(row, false)
|
||||
proxy.$modal.msgSuccess('价格已更新')
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
async function saveDiscount() {
|
||||
const hit = (props.details || []).find(d => d.productCode === discCode.value)
|
||||
if (hit) {
|
||||
hit.discountValue = discValue.value
|
||||
try {
|
||||
await persistDetail(hit, false)
|
||||
proxy.$modal.msgSuccess('折扣已写入数据库')
|
||||
} catch (e) {}
|
||||
}
|
||||
discVisible.value = false
|
||||
}
|
||||
|
||||
/** 明细行的国家 key(与 countryToDetail 的 _countryKey 同口径,大写便于比较) */
|
||||
function rowCountryKey(r) {
|
||||
if (!r) return ''
|
||||
return String(r.countryCode || (r.countryName ? 'N:' + r.countryName : '')).toUpperCase()
|
||||
}
|
||||
|
||||
/** 明细行的行级唯一键(国家 + 分区 + 重量段),用于精确定位「只改这一行」 */
|
||||
function rowScopeKey(r) {
|
||||
if (!r) return ''
|
||||
const c = rowCountryKey(r)
|
||||
const z = String(r.zoneCode || r.zoneName || '')
|
||||
const w = String(r.weightLabel || r.weightMin || r.weightMax || '')
|
||||
return `${c}|${z}|${w}`
|
||||
}
|
||||
|
||||
/** 行级作用域展示文案,如「荷兰 · 0.3-2kg」 */
|
||||
function rowScopeLabel(r) {
|
||||
if (!r) return ''
|
||||
const c = r.countryName || r.countryCode || ''
|
||||
const z = r.zoneName || r.zoneCode || ''
|
||||
const w = r.weightLabel || ''
|
||||
return [c, z, w].filter(Boolean).join(' · ')
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开附加费勾选弹窗
|
||||
* 列表 = 价格基础 → 附加费配置 主表全量(不要求产品已做关联);
|
||||
* 勾选回显 = 作用范围内明细行当前附加费的并集;
|
||||
* scopeKey 传行级键时只作用于该行(国家+重量段),不传则产品级全覆盖。
|
||||
*/
|
||||
async function openSurcharge(row, scopeKey, scopeName) {
|
||||
await props.refData.ensureAllSurcharges()
|
||||
scRows.value = row.rows || []
|
||||
scScopeKey.value = scopeKey || null
|
||||
const targets = scScopeKey.value
|
||||
? scRows.value.filter(r => rowScopeKey(r) === scScopeKey.value)
|
||||
: scRows.value
|
||||
scScopeName.value = scopeName || (scScopeKey.value
|
||||
? ((targets[0] && rowScopeLabel(targets[0])) || '')
|
||||
: '')
|
||||
scList.value = props.refData.allSurchargeConfigs()
|
||||
const picked = new Set()
|
||||
targets.forEach(r => {
|
||||
(r.surcharges || []).forEach(s => {
|
||||
if (s && s.scId != null) picked.add(String(s.scId))
|
||||
})
|
||||
})
|
||||
scPickedIds.value = [...picked]
|
||||
scTitle.value = row.productCode
|
||||
+ (scScopeName.value ? ' · ' + scScopeName.value : '')
|
||||
+ ' · 附加费'
|
||||
scVisible.value = true
|
||||
}
|
||||
|
||||
/**
|
||||
* 勾选结果写回:行级只改该行(国家+重量段),产品级覆盖该产品全部明细行;同一附加费只留一条。
|
||||
*
|
||||
* 校验口径:附加费的 country_code 是它自身的计费适用国家(如「燃油附加费 RO」仅对罗马
|
||||
* 尼亚计费),勾选挂载时【按目标明细行的国家做适用性校验】——国家码不匹配的附加费
|
||||
* 不落到该行(该行计费时也不会命中它,见 TmsPriceQuoteServiceImpl.surchargeApplies),
|
||||
* 并统计不匹配数提示用户。country_code 为空 = 全部国家,直接适用。
|
||||
*/
|
||||
function onSurchargeConfirm(picked) {
|
||||
const ids = new Set((picked || []).map(s => String(s.scId)))
|
||||
const targets = scScopeKey.value
|
||||
? scRows.value.filter(r => rowScopeKey(r) === scScopeKey.value)
|
||||
: scRows.value
|
||||
let applied = 0
|
||||
let skipped = 0
|
||||
targets.forEach(r => {
|
||||
const seen = new Set()
|
||||
const list = []
|
||||
scList.value.forEach(rel => {
|
||||
const key = String(rel.scId)
|
||||
if (!ids.has(key) || seen.has(key)) return
|
||||
if (!surchargeAppliesToRow(rel, r)) {
|
||||
skipped++
|
||||
return
|
||||
}
|
||||
seen.add(key)
|
||||
list.push(rel)
|
||||
})
|
||||
r.surcharges = list
|
||||
applied += list.length
|
||||
})
|
||||
const scopeText = scScopeName.value ? `(仅 ${scScopeName.value})` : ''
|
||||
if (!scList.value.length) {
|
||||
proxy.$modal.msgWarning('附加费配置列表为空,请先到「价格基础 → 附加费配置」维护')
|
||||
return
|
||||
}
|
||||
if (ids.size && !applied) {
|
||||
proxy.$modal.msgWarning('已勾选但未生效:这些附加费配置了适用国家/重量段,与当前明细行不匹配')
|
||||
return
|
||||
}
|
||||
if (skipped > 0) {
|
||||
Promise.all(targets.filter(r => r.psdId).map(r => persistDetail(r, true))).finally(() => {
|
||||
proxy.$modal.msgWarning(`已纳入 ${applied} 项附加费${scopeText};${skipped} 项因适用国家不匹配被跳过(已写库)`)
|
||||
})
|
||||
return
|
||||
}
|
||||
const okText = ids.size ? `已纳入 ${ids.size} 项附加费${scopeText}` : `已清空附加费${scopeText}`
|
||||
Promise.all(targets.filter(r => r.psdId).map(r => persistDetail(r, true))).then(() => {
|
||||
proxy.$modal.msgSuccess(okText + ',已写入数据库')
|
||||
}).catch(() => {
|
||||
proxy.$modal.msgSuccess(okText)
|
||||
})
|
||||
}
|
||||
|
||||
async function removeProduct(code) {
|
||||
const ids = props.details.filter(d => d.productCode === code && d.psdId).map(d => d.psdId)
|
||||
if (ids.length) {
|
||||
try {
|
||||
await delSetDetail(ids.join(','))
|
||||
} catch (e) {
|
||||
return
|
||||
}
|
||||
}
|
||||
for (let i = props.details.length - 1; i >= 0; i--) {
|
||||
if (props.details[i].productCode === code) props.details.splice(i, 1)
|
||||
}
|
||||
proxy.$modal.msgSuccess('已移除产品明细')
|
||||
}
|
||||
|
||||
defineExpose({ pullAllFromLibrary })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -193,6 +475,7 @@ function addRow() {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.sub {
|
||||
margin-left: 8px;
|
||||
@@ -200,10 +483,16 @@ function addRow() {
|
||||
font-weight: normal;
|
||||
font-size: 13px;
|
||||
}
|
||||
.mb12 {
|
||||
.mb12 { margin-bottom: 12px; }
|
||||
.filters {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.muted {
|
||||
color: #c0c4cc;
|
||||
.unit {
|
||||
margin-left: 8px;
|
||||
color: #909399;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<div class="step-version">
|
||||
<el-card shadow="never" class="step-card summary-card">
|
||||
<template #header>
|
||||
<div class="card-head">
|
||||
<span>{{ summaryTitle }}</span>
|
||||
<el-tag size="small" type="info" effect="plain">{{ summaryHint }}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-descriptions :column="2" border class="summary">
|
||||
<el-descriptions-item :label="labelName">{{ basic.priceSetName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="labelType">{{ setTypeLabel(basic.setType) }}</el-descriptions-item>
|
||||
<el-descriptions-item v-if="isDiscountType(basic.setType)" :label="labelDiscount">
|
||||
{{ basic.defaultDiscount }}%
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="labelNote" :span="2">{{ basic.priceSetNote || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div class="customer-block">
|
||||
<div class="customer-head">
|
||||
<span class="customer-title">{{ customerTitle }}</span>
|
||||
<span class="customer-count">{{ boundCustomers.length }}</span>
|
||||
</div>
|
||||
<el-table :data="boundCustomers" border size="small" empty-text="暂未绑定客户">
|
||||
<el-table-column :label="colCode" prop="customerCode" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column :label="colName" prop="customerName" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column :label="colPriority" prop="bindPriority" width="110" align="center" />
|
||||
</el-table>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="step-card version-card">
|
||||
<template #header><span>{{ title }}</span></template>
|
||||
<el-form ref="formRef" :model="version" :rules="rules" label-width="120px" class="max-form">
|
||||
<el-form-item :label="labelVersionNo">
|
||||
<el-input :model-value="version.versionNo" disabled style="width: 280px" />
|
||||
<div class="form-hint">{{ hintVersionNo }}</div>
|
||||
</el-form-item>
|
||||
<el-form-item :label="labelEffTime" prop="effectiveTime">
|
||||
<el-date-picker
|
||||
v-model="version.effectiveTime"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
:placeholder="phEffTime"
|
||||
style="width: 280px"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="StepVersion">
|
||||
import { isDiscountType, setTypeLabel } from '../../utils/priceSet'
|
||||
|
||||
const version = defineModel({ type: Object, required: true })
|
||||
const props = defineProps({
|
||||
basic: { type: Object, required: true },
|
||||
customers: { type: Array, default: () => [] }
|
||||
})
|
||||
|
||||
const formRef = ref()
|
||||
const title = '第 2 步 · 版本与生效时间'
|
||||
const labelVersionNo = '版本号'
|
||||
const hintVersionNo = '自动生成,下一个版本 +1'
|
||||
const labelEffTime = '生效时间'
|
||||
const phEffTime = '请选择版本生效时间'
|
||||
const summaryTitle = '第 1 步信息回显'
|
||||
const summaryHint = '仅回显,不可编辑'
|
||||
const labelName = '套餐名称'
|
||||
const labelType = '计价类型'
|
||||
const labelDiscount = '默认折扣'
|
||||
const labelNote = '说明'
|
||||
const customerTitle = '已绑定客户'
|
||||
const colCode = '客户代码'
|
||||
const colName = '客户名称'
|
||||
const colPriority = '优先级'
|
||||
|
||||
const rules = {
|
||||
effectiveTime: [{ required: true, message: '请填写版本生效时间', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const boundCustomers = computed(() => (props.customers || []).filter(c => c.customerCode))
|
||||
|
||||
function validate() {
|
||||
return new Promise(resolve => {
|
||||
if (!formRef.value) return resolve(false)
|
||||
formRef.value.validate(valid => resolve(!!valid))
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ validate })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.step-version {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
.card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.max-form {
|
||||
max-width: 760px;
|
||||
}
|
||||
.form-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
line-height: 1.4;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.summary-card :deep(.el-card__body) {
|
||||
padding-top: 12px;
|
||||
}
|
||||
.customer-block {
|
||||
margin-top: 16px;
|
||||
}
|
||||
.customer-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.customer-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
.customer-count {
|
||||
margin-left: auto;
|
||||
min-width: 22px;
|
||||
height: 22px;
|
||||
line-height: 22px;
|
||||
text-align: center;
|
||||
border-radius: 11px;
|
||||
background: #f0f2f5;
|
||||
color: #606266;
|
||||
font-size: 12px;
|
||||
padding: 0 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<div class="sc-count">
|
||||
<el-popover
|
||||
v-if="list.length"
|
||||
placement="top"
|
||||
:width="380"
|
||||
trigger="hover"
|
||||
>
|
||||
<template #default>
|
||||
<div class="sc-count__pop-title">已纳入 {{ list.length }} 项附加费</div>
|
||||
<surcharge-tags :list="list" :popover="false" empty-text="-" />
|
||||
</template>
|
||||
<template #reference>
|
||||
<el-link type="primary" :underline="false" @click="emit('click')">
|
||||
{{ list.length }} 项
|
||||
</el-link>
|
||||
</template>
|
||||
</el-popover>
|
||||
<el-link v-else type="info" :underline="false" @click="emit('click')">0</el-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="SurchargeCountCell">
|
||||
/**
|
||||
* 套餐 · 附加费数量单元格(新建第 3 步产品列表 / 价格编辑抽屉共用)
|
||||
*
|
||||
* 显示当前数量(默认 0);hover 气泡看具体是哪几项,点击进入勾选弹窗调整。
|
||||
*/
|
||||
import SurchargeTags from '../SurchargeTags.vue'
|
||||
|
||||
defineProps({
|
||||
/** 该行 / 该产品当前纳入的附加费列表 */
|
||||
list: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['click'])
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sc-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.sc-count__pop-title {
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #606266;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="title"
|
||||
width="1000px"
|
||||
append-to-body
|
||||
class="ps-dialog"
|
||||
>
|
||||
<div class="ps-picker-bar">
|
||||
<span>共 {{ rows.length }} 项附加费配置,勾选后写入所选范围的明细行</span>
|
||||
<span class="ps-picker-bar__picked">已选 {{ picked.length }} 项</span>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
:data="rows"
|
||||
row-key="scId"
|
||||
border
|
||||
size="small"
|
||||
max-height="400"
|
||||
empty-text="暂无附加费配置"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="46" />
|
||||
<el-table-column label="附加费名称" prop="scName" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column label="计费方式" width="200" align="center">
|
||||
<template #default="{ row }">{{ chargeTypeLabel(row.chargeType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计费值" width="130" align="right">
|
||||
<template #default="{ row }">{{ formatChargeValue(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="作用范围" min-width="170" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.scopeText }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="ps-hint ps-hint--block">取消勾选即不纳入本套餐;「作用范围」表示该附加费自身计费适用的国家(如「燃油附加费 RO」仅对罗马尼亚计费),勾选后按所选范围写回明细行,计费时再按国家匹配。</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup name="SurchargePickerDialog">
|
||||
/**
|
||||
* 套餐 · 附加费勾选弹窗(新建流程第 3 步)
|
||||
*
|
||||
* 数据来源:产品已关联的附加费配置(prc_surcharge_rel ∩ prc_surcharge),
|
||||
* 与明细表格里「附加费」列展示的口径一致;勾选结果由父级写回该产品的明细行。
|
||||
*/
|
||||
import { formatChargeValue, surchargeScopeLabel } from '../../utils/priceSet'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: Boolean, default: false },
|
||||
title: { type: String, default: '附加费' },
|
||||
/** 附加费配置主表全量(refData.allSurchargeConfigs()) */
|
||||
list: { type: Array, default: () => [] },
|
||||
/** 当前已勾选的 scId 集合,用于打开时回显 */
|
||||
selectedIds: { type: Array, default: () => [] }
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue', 'confirm'])
|
||||
|
||||
const { bms_charge_type } = useDict('bms_charge_type')
|
||||
|
||||
const tableRef = ref()
|
||||
const picked = ref([])
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: v => emit('update:modelValue', v)
|
||||
})
|
||||
|
||||
/** 同一附加费可能同时挂在产品级与国家/重量段上,按 scId 合并成一行,作用范围拼接展示 */
|
||||
const rows = computed(() => {
|
||||
const map = new Map()
|
||||
;(props.list || []).forEach(rel => {
|
||||
if (!rel || rel.scId == null) return
|
||||
const key = String(rel.scId)
|
||||
if (!map.has(key)) {
|
||||
map.set(key, { ...rel, scopeTexts: [] })
|
||||
}
|
||||
const item = map.get(key)
|
||||
const text = surchargeScopeLabel(rel)
|
||||
if (!item.scopeTexts.includes(text)) item.scopeTexts.push(text)
|
||||
})
|
||||
return [...map.values()].map(item => ({
|
||||
...item,
|
||||
scopeText: item.scopeTexts.join(' / ')
|
||||
}))
|
||||
})
|
||||
|
||||
function chargeTypeLabel(val) {
|
||||
const found = (bms_charge_type.value || []).find(c => c.value === val)
|
||||
return found ? found.label : (val || '-')
|
||||
}
|
||||
|
||||
function onSelectionChange(selection) {
|
||||
picked.value = selection
|
||||
}
|
||||
|
||||
/** 确定:以表格当前选中为准(回显/重渲染可能清掉 selection,不能只信 selection-change 的快照) */
|
||||
function submit() {
|
||||
const table = tableRef.value
|
||||
let list = picked.value
|
||||
if (table && typeof table.getSelection === 'function') {
|
||||
const cur = table.getSelection() || []
|
||||
if (cur.length || !list.length) list = cur
|
||||
}
|
||||
emit('confirm', list)
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
/** 回显勾选:首次打开时 el-dialog 内容才挂载,取不到表格就再等一帧(最多 5 帧) */
|
||||
function applySelection(ids, tries) {
|
||||
const table = tableRef.value
|
||||
if (!table) {
|
||||
if ((tries || 0) < 5) nextTick(() => applySelection(ids, (tries || 0) + 1))
|
||||
return
|
||||
}
|
||||
table.clearSelection()
|
||||
rows.value.forEach(row => {
|
||||
table.toggleRowSelection(row, ids.includes(String(row.scId)))
|
||||
})
|
||||
picked.value = rows.value.filter(row => ids.includes(String(row.scId)))
|
||||
}
|
||||
|
||||
watch(() => props.modelValue, v => {
|
||||
if (!v) return
|
||||
const ids = (props.selectedIds || []).map(id => String(id))
|
||||
nextTick(() => applySelection(ids, 0))
|
||||
})
|
||||
</script>
|
||||
|
||||
<!-- 非 scoped:弹窗被 append-to-body 传送到 body,样式需全局生效;.ps-picker-bar 工具类见 styles/dialog.scss -->
|
||||
<style lang="scss" src="../../styles/dialog.scss"></style>
|
||||
@@ -22,10 +22,7 @@
|
||||
*/
|
||||
import SetSectionCard from './SetSectionCard.vue'
|
||||
import {
|
||||
formatDateRange,
|
||||
isDiscountType,
|
||||
setStatusLabel,
|
||||
setStatusTagType,
|
||||
setTypeLabel
|
||||
} from '../../utils/priceSet'
|
||||
|
||||
@@ -50,8 +47,6 @@ const items = computed(() => {
|
||||
value: discount ? `${s.defaultDiscount}%` : '不适用(FIXED)',
|
||||
muted: !discount
|
||||
},
|
||||
{ label: '状态', value: setStatusLabel(s), tag: setStatusTagType(s) },
|
||||
{ label: '有效期', value: formatDateRange(s.effectiveDate, s.expireDate) },
|
||||
{ label: '创建人', value: s.createBy || '-' },
|
||||
{ label: '创建时间', value: s.createTime || '-' },
|
||||
{ label: '最后更新', value: (s.updateTime || '-') + ' ' + updater }
|
||||
|
||||
@@ -5,17 +5,6 @@
|
||||
:count="customers.length"
|
||||
sub="一个客户只能绑定一个套餐"
|
||||
>
|
||||
<template #action>
|
||||
<el-button
|
||||
v-if="editable"
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="Plus"
|
||||
@click="dialogRef.open()"
|
||||
v-hasPermi="['price:set:edit']"
|
||||
>添加客户</el-button>
|
||||
</template>
|
||||
|
||||
<el-table :data="customers" border class="customer-table" empty-text="暂未绑定客户">
|
||||
<el-table-column label="客户代码" prop="customerCode" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
@@ -29,62 +18,18 @@
|
||||
<span v-else class="priority">{{ row.bindPriority }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="有效期" min-width="220">
|
||||
<template #default="{ row }">{{ formatDateRange(row.prBegindate, row.prEnddate) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="editable" label="操作" width="120" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="dialogRef.open(row)" v-hasPermi="['price:set:edit']">编辑</el-button>
|
||||
<el-button link type="danger" @click="remove(row)" v-hasPermi="['price:set:edit']">解绑</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="table-hint">解绑后该客户可绑定其他套餐;生效中的套餐修改绑定会即时影响计费命中。</div>
|
||||
|
||||
<set-customer-dialog
|
||||
ref="dialogRef"
|
||||
:price-set-id="set.priceSetId"
|
||||
:default-begindate="set.effectiveDate"
|
||||
:default-enddate="set.expireDate"
|
||||
@success="emit('refresh')"
|
||||
/>
|
||||
</set-section-card>
|
||||
</template>
|
||||
|
||||
<script setup name="SetCustomerTable">
|
||||
/**
|
||||
* 套餐详情 · 绑定客户表格
|
||||
* 自带新增 / 编辑弹窗与解绑,数据变更后 emit('refresh') 由页面重新拉取详情。
|
||||
*/
|
||||
import SetSectionCard from './SetSectionCard.vue'
|
||||
import SetCustomerDialog from './SetCustomerDialog.vue'
|
||||
import { formatDateRange, isChildEditable } from '../../utils/priceSet'
|
||||
import { delSetCustomer } from '@/api/price/set'
|
||||
|
||||
const props = defineProps({
|
||||
/** 套餐详情对象 */
|
||||
set: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
set: { type: Object, required: true }
|
||||
})
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const dialogRef = ref()
|
||||
|
||||
const customers = computed(() => props.set.customers || [])
|
||||
const editable = computed(() => isChildEditable(props.set.status))
|
||||
|
||||
function remove(row) {
|
||||
proxy.$modal.confirm('确认解绑该客户?').then(() => delSetCustomer(row.customerPricesetId)).then(() => {
|
||||
proxy.$modal.msgSuccess('已解绑')
|
||||
emit('refresh')
|
||||
}).catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -104,10 +49,4 @@ function remove(row) {
|
||||
.priority {
|
||||
color: #303133;
|
||||
}
|
||||
.table-hint {
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
/>
|
||||
<span class="ps-field__unit">RMB/KG</span>
|
||||
</div>
|
||||
<div class="ps-hint">可留空:原基础表无值时表示不覆盖运费,按产品基础价计费</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
|
||||
@@ -6,60 +6,40 @@
|
||||
<span v-if="set.priceSetCode" class="hd-code">{{ set.priceSetCode }}</span>
|
||||
</div>
|
||||
<div class="hd-line hd-meta">
|
||||
<el-tag :type="statusTagType" size="small" effect="dark">{{ statusText }}</el-tag>
|
||||
<el-tag :type="isFixedType(set.setType) ? 'warning' : 'primary'" size="small" effect="plain">
|
||||
{{ setTypeLabel(set.setType) }}
|
||||
</el-tag>
|
||||
<span class="hd-range">
|
||||
<el-icon class="hd-icon"><Calendar /></el-icon>
|
||||
{{ dateRange }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hd-actions">
|
||||
<el-button @click="emit('back')">返回列表</el-button>
|
||||
<template v-if="editableStatus">
|
||||
<el-button type="primary" @click="emit('edit')" v-hasPermi="['price:set:edit']">继续配置</el-button>
|
||||
<el-button type="primary" plain @click="emit('submit')" v-hasPermi="['price:set:audit']">提交审核</el-button>
|
||||
</template>
|
||||
<template v-else-if="set.status === 'A'">
|
||||
<el-button type="success" @click="emit('approve')" v-hasPermi="['price:set:audit']">审批生效</el-button>
|
||||
<el-button type="warning" plain @click="emit('reject')" v-hasPermi="['price:set:audit']">驳回</el-button>
|
||||
</template>
|
||||
<el-button
|
||||
v-else-if="set.status === 'E' && !set.expired"
|
||||
v-if="set.status === 'E' && !set.expired"
|
||||
type="danger"
|
||||
plain
|
||||
@click="emit('disable')"
|
||||
v-hasPermi="['price:set:audit']"
|
||||
>停用</el-button>
|
||||
<el-button v-else-if="set.status === 'S'" type="primary" plain @click="emit('copy')" v-hasPermi="['price:set:add']">复用新建</el-button>
|
||||
<el-button
|
||||
v-else-if="set.status === 'S'"
|
||||
type="primary"
|
||||
plain
|
||||
@click="emit('copy')"
|
||||
v-hasPermi="['price:set:add']"
|
||||
>复用新建</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="SetDetailHeader">
|
||||
/**
|
||||
* 套餐详情 · 页头
|
||||
* 只负责展示套餐标识 / 状态与派发操作事件,接口调用与确认框由页面处理。
|
||||
*/
|
||||
import { SET_STATUS, formatDateRange, isFixedType, setStatusLabel, setStatusTagType, setTypeLabel } from '../../utils/priceSet'
|
||||
import { isFixedType, setTypeLabel } from '../../utils/priceSet'
|
||||
|
||||
const props = defineProps({
|
||||
/** 套餐详情对象 */
|
||||
set: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
defineProps({
|
||||
set: { type: Object, required: true }
|
||||
})
|
||||
|
||||
const emit = defineEmits(['back', 'edit', 'submit', 'approve', 'reject', 'disable', 'copy'])
|
||||
|
||||
const statusText = computed(() => setStatusLabel(props.set))
|
||||
const statusTagType = computed(() => setStatusTagType(props.set))
|
||||
const dateRange = computed(() => formatDateRange(props.set.effectiveDate, props.set.expireDate))
|
||||
const editableStatus = computed(() => [SET_STATUS.DRAFT, SET_STATUS.REJECT].includes(props.set.status))
|
||||
const emit = defineEmits(['back', 'disable', 'copy'])
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -76,9 +56,7 @@ const editableStatus = computed(() => [SET_STATUS.DRAFT, SET_STATUS.REJECT].incl
|
||||
border-left: 3px solid #1890ff;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.hd-main {
|
||||
min-width: 0;
|
||||
}
|
||||
.hd-main { min-width: 0; }
|
||||
.hd-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -101,19 +79,7 @@ const editableStatus = computed(() => [SET_STATUS.DRAFT, SET_STATUS.REJECT].incl
|
||||
border-radius: 4px;
|
||||
padding: 1px 8px;
|
||||
}
|
||||
.hd-meta {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.hd-range {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
.hd-icon {
|
||||
font-size: 14px;
|
||||
}
|
||||
.hd-meta { margin-top: 10px; }
|
||||
.hd-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -36,8 +36,13 @@
|
||||
<el-table-column label="重量段" prop="weightLabel" min-width="130" />
|
||||
<el-table-column label="运费单价" min-width="130" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="hl">{{ row.fvValue }}</span>
|
||||
<span class="unit"> RMB/KG</span>
|
||||
<template v-if="row.fvValue == null">
|
||||
<span class="unit">未覆盖</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="hl">{{ row.fvValue }}</span>
|
||||
<span class="unit"> RMB/KG</span>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="挂号费" min-width="120" align="right">
|
||||
@@ -57,7 +62,7 @@
|
||||
|
||||
<el-table-column label="附加费" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<surcharge-tags :list="surchargesOf(row)" />
|
||||
<surcharge-tags :list="surchargesOfRow(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -116,6 +121,11 @@ const { bms_round_mode } = useDict('bms_round_mode')
|
||||
|
||||
const { surchargesOf } = props.refData
|
||||
|
||||
function surchargesOfRow(row) {
|
||||
if (row && row.surcharges && row.surcharges.length) return row.surcharges
|
||||
return surchargesOf(row)
|
||||
}
|
||||
|
||||
const dialogRef = ref()
|
||||
|
||||
const details = computed(() => props.set.details || [])
|
||||
@@ -126,7 +136,7 @@ const subTitle = computed(() => isFixedType(props.set.setType)
|
||||
: '按产品限定折扣,留空走套餐默认折扣')
|
||||
|
||||
const hint = computed(() => isFixedType(props.set.setType)
|
||||
? '运费单价单位 RMB/KG,挂号费单位 RMB/票;附加费来自产品关联配置,此处只读展示。'
|
||||
? '运费单价单位 RMB/KG(留空表示不覆盖,按产品基础价计费),挂号费单位 RMB/票;附加费来自产品关联配置,此处只读展示。'
|
||||
: '未配置明细时全部在售产品均适用套餐默认折扣。')
|
||||
|
||||
function roundModeLabel(mode) {
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
<template>
|
||||
<el-drawer
|
||||
:model-value="modelValue"
|
||||
:title="title"
|
||||
size="72%"
|
||||
destroy-on-close
|
||||
@close="close"
|
||||
>
|
||||
<div class="drawer-body" v-loading="loading">
|
||||
<div class="toolbar">
|
||||
<el-input
|
||||
v-model="query.productKeyword"
|
||||
clearable
|
||||
:placeholder="phProduct"
|
||||
style="width: 160px"
|
||||
@keyup.enter="search"
|
||||
/>
|
||||
<el-input
|
||||
v-if="isFixed"
|
||||
v-model="query.countryKeyword"
|
||||
clearable
|
||||
:placeholder="phCountry"
|
||||
style="width: 140px"
|
||||
@keyup.enter="search"
|
||||
/>
|
||||
<el-input
|
||||
v-if="isFixed"
|
||||
v-model="query.zoneKeyword"
|
||||
clearable
|
||||
:placeholder="phZone"
|
||||
style="width: 140px"
|
||||
@keyup.enter="search"
|
||||
/>
|
||||
<el-button type="primary" @click="search">查询</el-button>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
</div>
|
||||
|
||||
<el-table :data="rows" border height="calc(100vh - 220px)" empty-text="暂无明细">
|
||||
<el-table-column :label="colProduct" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="cell-product">
|
||||
<span class="p-code">{{ row.productCode }}</span>
|
||||
<span class="p-name">{{ row.productName || '' }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<template v-if="isFixed">
|
||||
<el-table-column :label="colCountry" min-width="120">
|
||||
<template #default="{ row }">{{ row.countryName || row.countryCode || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colZone" min-width="110">
|
||||
<template #default="{ row }">{{ row.zoneName || row.zoneCode || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colWeight" prop="weightLabel" min-width="120" />
|
||||
<el-table-column :label="colFv" min-width="130" align="right">
|
||||
<template #default="{ row }">
|
||||
<template v-if="row.fvValue == null">
|
||||
<span class="unit">未覆盖</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="hl">{{ row.fvValue }}</span>
|
||||
<span class="unit"> RMB/KG</span>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colReg" min-width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="reg">{{ row.fvRegistrationFee }}</span>
|
||||
<span class="unit"> RMB/票</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
|
||||
<el-table-column v-else :label="colDisc" min-width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.discountValue == null" size="small" type="info" effect="plain">默认折扣</el-tag>
|
||||
<span v-else class="pct">{{ row.discountValue }}%</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="colSc" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<surcharge-tags :list="row.surcharges || []" :empty-text="noneSc" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="colRound" min-width="100" align="center">
|
||||
<template #default="{ row }">{{ roundModeLabel(row.roundMode) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="pager">
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="query.pageNum"
|
||||
v-model:limit="query.pageSize"
|
||||
@pagination="load"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="close">关闭</el-button>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup name="SetVersionDetailDrawer">
|
||||
import SurchargeTags from '../SurchargeTags.vue'
|
||||
import { isFixedType } from '../../utils/priceSet'
|
||||
import { listSetDetail } from '@/api/price/set'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: Boolean, default: false },
|
||||
version: { type: Object, default: null },
|
||||
setType: { type: String, default: 'FIXED' }
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const { bms_round_mode } = useDict('bms_round_mode')
|
||||
|
||||
const loading = ref(false)
|
||||
const rows = ref([])
|
||||
const total = ref(0)
|
||||
const query = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
productKeyword: '',
|
||||
countryKeyword: '',
|
||||
zoneKeyword: ''
|
||||
})
|
||||
|
||||
const phProduct = '产品代码/名称'
|
||||
const phCountry = '国家'
|
||||
const phZone = '分区'
|
||||
const colProduct = '产品'
|
||||
const colCountry = '国家'
|
||||
const colZone = '分区'
|
||||
const colWeight = '重量段'
|
||||
const colFv = '运费单价'
|
||||
const colReg = '挂号费'
|
||||
const colDisc = '产品折扣'
|
||||
const colSc = '附加费'
|
||||
const colRound = '取值方式'
|
||||
const noneSc = '无'
|
||||
|
||||
const isFixed = computed(() => isFixedType(props.setType))
|
||||
const title = computed(() => {
|
||||
const v = props.version || {}
|
||||
return (v.versionNo || '-') + ' · 版本明细'
|
||||
})
|
||||
|
||||
function roundModeLabel(mode) {
|
||||
const hit = (bms_round_mode.value || []).find(d => d.value === mode)
|
||||
return hit ? hit.label : (mode || '四舍五入')
|
||||
}
|
||||
|
||||
function close() {
|
||||
emit('update:modelValue', false)
|
||||
}
|
||||
|
||||
function search() {
|
||||
query.pageNum = 1
|
||||
load()
|
||||
}
|
||||
|
||||
function reset() {
|
||||
query.productKeyword = ''
|
||||
query.countryKeyword = ''
|
||||
query.zoneKeyword = ''
|
||||
query.pageNum = 1
|
||||
load()
|
||||
}
|
||||
|
||||
function load() {
|
||||
const psvId = props.version && props.version.psvId
|
||||
if (!psvId) {
|
||||
rows.value = []
|
||||
total.value = 0
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
listSetDetail({
|
||||
psvId,
|
||||
productKeyword: query.productKeyword || undefined,
|
||||
countryKeyword: isFixed.value ? (query.countryKeyword || undefined) : undefined,
|
||||
zoneKeyword: isFixed.value ? (query.zoneKeyword || undefined) : undefined,
|
||||
pageNum: query.pageNum,
|
||||
pageSize: query.pageSize
|
||||
}).then(res => {
|
||||
rows.value = res.rows || []
|
||||
total.value = res.total || 0
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.modelValue, props.version && props.version.psvId],
|
||||
([open]) => {
|
||||
if (open) {
|
||||
query.pageNum = 1
|
||||
query.productKeyword = ''
|
||||
query.countryKeyword = ''
|
||||
query.zoneKeyword = ''
|
||||
load()
|
||||
}
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.drawer-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
.toolbar {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
.pager {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.cell-product {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
}
|
||||
.p-code {
|
||||
font-family: Consolas, Monaco, monospace;
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
background: #f4f4f5;
|
||||
border-radius: 3px;
|
||||
padding: 0 6px;
|
||||
}
|
||||
.p-name { color: #303133; }
|
||||
.hl { color: #1890ff; font-weight: 600; }
|
||||
.reg { color: #d48806; font-weight: 600; }
|
||||
.pct { color: #1890ff; font-weight: 600; }
|
||||
.unit { font-size: 12px; color: #909399; }
|
||||
</style>
|
||||
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<set-section-card :title="title" tone="green" :count="filteredVersions.length">
|
||||
<el-tabs v-model="statusTab" class="ver-tabs">
|
||||
<el-tab-pane :label="tabLabel('all')" name="all" />
|
||||
<el-tab-pane :label="tabLabel('0')" name="0" />
|
||||
<el-tab-pane :label="tabLabel('1')" name="1" />
|
||||
<el-tab-pane :label="tabLabel('2')" name="2" />
|
||||
</el-tabs>
|
||||
|
||||
<el-table :data="filteredVersions" border empty-text="暂无版本">
|
||||
<el-table-column :label="colNo" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openDetails(row)">{{ row.versionNo || '-' }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colEff" min-width="170">
|
||||
<template #default="{ row }">{{ row.effectiveTime || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colExp" min-width="170">
|
||||
<template #default="{ row }">{{ row.expireTime || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colStatus" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="versionStatusTag(row.status)" size="small">{{ versionStatusLabel(row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colRows" width="100" align="center">
|
||||
<template #default="{ row }">{{ detailCount(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colAction" width="320" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openDetails(row)">查看详情</el-button>
|
||||
<el-button
|
||||
v-if="String(row.status) === '0'"
|
||||
link
|
||||
type="primary"
|
||||
@click="emit('edit', row)"
|
||||
v-hasPermi="['price:set:edit']"
|
||||
>继续配置</el-button>
|
||||
<el-button
|
||||
v-if="String(row.status) === '0'"
|
||||
link
|
||||
type="success"
|
||||
@click="emit('activate', row)"
|
||||
v-hasPermi="['price:set:edit']"
|
||||
>启动</el-button>
|
||||
<el-button
|
||||
v-if="String(row.status) === '0'"
|
||||
link
|
||||
type="danger"
|
||||
@click="emit('remove', row)"
|
||||
v-hasPermi="['price:set:edit']"
|
||||
>删除</el-button>
|
||||
<el-button
|
||||
v-if="String(row.status) === '1'"
|
||||
link
|
||||
type="primary"
|
||||
@click="emit('copy-version', row)"
|
||||
v-hasPermi="['price:set:add']"
|
||||
>复制为新版本</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</set-section-card>
|
||||
</template>
|
||||
|
||||
<script setup name="SetVersionTable">
|
||||
import SetSectionCard from './SetSectionCard.vue'
|
||||
import { versionStatusLabel, versionStatusTag } from '../../utils/priceSet'
|
||||
|
||||
const props = defineProps({
|
||||
versions: { type: Array, default: () => [] },
|
||||
modelValue: { type: [Number, String], default: undefined }
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue', 'copy-version', 'open-details', 'activate', 'edit', 'remove'])
|
||||
|
||||
const title = '套餐版本'
|
||||
const colNo = '版本号'
|
||||
const colEff = '生效时间'
|
||||
const colExp = '失效时间'
|
||||
const colStatus = '状态'
|
||||
const colRows = '明细行数'
|
||||
const colAction = '操作'
|
||||
const statusTab = ref('all')
|
||||
|
||||
const counts = computed(() => {
|
||||
const map = { all: 0, '0': 0, '1': 0, '2': 0 }
|
||||
;(props.versions || []).forEach(v => {
|
||||
map.all++
|
||||
const s = String(v.status == null ? '' : v.status)
|
||||
if (map[s] != null) map[s]++
|
||||
})
|
||||
return map
|
||||
})
|
||||
|
||||
function tabLabel(key) {
|
||||
const labels = {
|
||||
all: '全部',
|
||||
'0': '草稿',
|
||||
'1': '生效',
|
||||
'2': '失效'
|
||||
}
|
||||
return labels[key] + ' (' + (counts.value[key] || 0) + ')'
|
||||
}
|
||||
|
||||
const filteredVersions = computed(() => {
|
||||
const list = props.versions || []
|
||||
if (statusTab.value === 'all') return list
|
||||
return list.filter(v => String(v.status) === statusTab.value)
|
||||
})
|
||||
|
||||
function detailCount(row) {
|
||||
if (row && row.detailCount != null) return row.detailCount
|
||||
return (row && row.details || []).length
|
||||
}
|
||||
|
||||
function openDetails(row) {
|
||||
if (!row || row.psvId == null) return
|
||||
emit('update:modelValue', row.psvId)
|
||||
emit('open-details', row)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.ver-tabs {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.ver-tabs :deep(.el-tabs__header) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -5,7 +5,7 @@
|
||||
* 避免产品 / 产品国家 / 附加费 被重复请求。
|
||||
*/
|
||||
import { listProduct, listProductCountries } from '@/api/price/product'
|
||||
import { listSurchargeByProduct } from '@/api/price/surcharge'
|
||||
import { listSurchargeByProduct, listSurchargeOptions } from '@/api/price/surcharge'
|
||||
import {
|
||||
buildCountryOptions,
|
||||
buildZoneOptions,
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
countryKeyOf,
|
||||
formatWeightLabel,
|
||||
matchCountryZone,
|
||||
surchargeAppliesToRow,
|
||||
toEditableDetailRow
|
||||
} from '../utils/priceSet'
|
||||
|
||||
@@ -25,20 +26,30 @@ export function usePriceSetRefData() {
|
||||
const productOptions = ref([])
|
||||
/** productCode -> bms_product_country 行 */
|
||||
const countryCache = reactive({})
|
||||
/** productCode -> 进行中的国家明细请求(去重,避免 hydrate 按行打爆接口) */
|
||||
const countryPending = {}
|
||||
/** productCode -> 有效附加费关联 */
|
||||
const surchargeCache = reactive({})
|
||||
/** productCode -> 进行中的请求 */
|
||||
const surchargePending = {}
|
||||
/** 价格基础 → 附加费配置 主表全量(勾选弹窗数据源,页面内共享一份) */
|
||||
const allSurchargeList = ref(null)
|
||||
let allSurchargePending = null
|
||||
|
||||
const productMap = computed(() => new Map(productOptions.value.map(p => [p.value, p])))
|
||||
|
||||
/** 加载可选产品(已生效) */
|
||||
/** 加载可选产品(已生效),保留列表展示字段 */
|
||||
function loadProducts() {
|
||||
return listProduct({ status: '1', pageNum: 1, pageSize: 1000 }).then(res => {
|
||||
productOptions.value = (res.rows || []).map(p => ({
|
||||
value: p.productCode,
|
||||
label: `${p.productCode} ${p.productName || ''}`.trim(),
|
||||
name: p.productName
|
||||
name: p.productName,
|
||||
serviceLevel: p.serviceLevel,
|
||||
cargoAttr: p.cargoAttr,
|
||||
destRegion: p.destRegion,
|
||||
taxMode: p.taxMode,
|
||||
countryCount: p.countryCount
|
||||
}))
|
||||
return productOptions.value
|
||||
})
|
||||
@@ -50,15 +61,72 @@ export function usePriceSetRefData() {
|
||||
return hit ? hit.name : productCode
|
||||
}
|
||||
|
||||
/** 确保产品的国家×重量段配置已加载(过滤已失效配置) */
|
||||
function ensureCountries(productCode) {
|
||||
/** product meta for step-3 product list */
|
||||
function productMetaOf(productCode) {
|
||||
return productMap.value.get(productCode) || null
|
||||
}
|
||||
|
||||
/** YYYY-MM-DD from datetime / date */
|
||||
function dateOnly(v) {
|
||||
if (!v) return null
|
||||
return String(v).slice(0, 10)
|
||||
}
|
||||
|
||||
/**
|
||||
* Country row active at asOf (version effective time).
|
||||
* Window: effective_date <= asOf AND (expire_date is null OR expire_date > asOf)
|
||||
*/
|
||||
function isCountryActiveAt(item, asOf) {
|
||||
const t = dateOnly(asOf)
|
||||
if (!t) return true
|
||||
const eff = dateOnly(item.effectiveDate)
|
||||
const exp = dateOnly(item.expireDate)
|
||||
if (eff && eff > t) return false
|
||||
if (exp && exp <= t) return false
|
||||
return true
|
||||
}
|
||||
|
||||
/** currently open country rows (not expired) */
|
||||
function isCountryOpen(item) {
|
||||
if (String(item.status) === '2') return false
|
||||
const exp = dateOnly(item.expireDate)
|
||||
if (!exp) return true
|
||||
const today = dateOnly(new Date().toISOString())
|
||||
return exp > today
|
||||
}
|
||||
|
||||
/**
|
||||
* Load product country×weight rows.
|
||||
* Cache keeps full list; pass asOf (version effective_time) to filter the active window.
|
||||
* If asOf match is empty, fall back to currently open rows so step-3 can still show full product prices.
|
||||
* In-flight requests are deduped per productCode (hydrateRow is per-detail-row).
|
||||
*/
|
||||
function ensureCountries(productCode, asOf) {
|
||||
if (!productCode) return Promise.resolve([])
|
||||
if (countryCache[productCode]) return Promise.resolve(countryCache[productCode])
|
||||
return listProductCountries(productCode).then(res => {
|
||||
const rows = (res.data || []).filter(item => !item.expireDate)
|
||||
const filterRows = (rows) => {
|
||||
const all = rows || []
|
||||
if (!asOf) return all.filter(isCountryOpen)
|
||||
const hit = all.filter(item => isCountryActiveAt(item, asOf))
|
||||
if (hit.length) return hit
|
||||
return all.filter(isCountryOpen)
|
||||
}
|
||||
if (countryCache[productCode]) {
|
||||
return Promise.resolve(filterRows(countryCache[productCode]))
|
||||
}
|
||||
if (countryPending[productCode]) {
|
||||
return countryPending[productCode].then(filterRows)
|
||||
}
|
||||
countryPending[productCode] = listProductCountries(productCode).then(res => {
|
||||
const rows = res.data || []
|
||||
countryCache[productCode] = rows
|
||||
return rows
|
||||
}).catch(() => {
|
||||
// do not cache failure; allow later retry without stampeding while in-flight
|
||||
return []
|
||||
}).finally(() => {
|
||||
delete countryPending[productCode]
|
||||
})
|
||||
return countryPending[productCode].then(filterRows)
|
||||
}
|
||||
|
||||
/** 确保产品的有效附加费已加载(剔除 OF 燃油,结果缓存 + 请求去重) */
|
||||
@@ -71,7 +139,7 @@ export function usePriceSetRefData() {
|
||||
surchargeCache[productCode] = rows
|
||||
return rows
|
||||
}).catch(() => {
|
||||
surchargeCache[productCode] = []
|
||||
// 失败不写缓存,后续可重试(避免一次抖动就让该产品永久显示无附加费)
|
||||
return []
|
||||
}).finally(() => {
|
||||
delete surchargePending[productCode]
|
||||
@@ -79,18 +147,41 @@ export function usePriceSetRefData() {
|
||||
return surchargePending[productCode]
|
||||
}
|
||||
|
||||
/** 产品已关联的附加费全量(不按国家/重量段过滤),供套餐勾选使用 */
|
||||
function allSurchargesOf(productCode) {
|
||||
if (!productCode) return []
|
||||
return surchargeCache[productCode] || []
|
||||
}
|
||||
|
||||
/** 确保附加费配置主表已加载(剔除 OF 燃油,页面内共享一份缓存) */
|
||||
function ensureAllSurcharges() {
|
||||
if (allSurchargeList.value) return Promise.resolve(allSurchargeList.value)
|
||||
if (!allSurchargePending) {
|
||||
allSurchargePending = listSurchargeOptions().then(res => {
|
||||
// /options 返回 AjaxResult(data),兼容分页接口的 rows 写法
|
||||
const raw = res.data || res.rows || []
|
||||
const rows = raw.filter(item => String(item.ssCode || '').toLowerCase() !== 'of')
|
||||
allSurchargeList.value = rows
|
||||
return rows
|
||||
}).catch(() => {
|
||||
// 失败不缓存,允许下次重试;调用方拿空数组也不至于报错中断
|
||||
return []
|
||||
}).finally(() => {
|
||||
allSurchargePending = null
|
||||
})
|
||||
}
|
||||
return allSurchargePending
|
||||
}
|
||||
|
||||
/** 附加费配置主表全量(需先 ensureAllSurcharges) */
|
||||
function allSurchargeConfigs() {
|
||||
return allSurchargeList.value || []
|
||||
}
|
||||
|
||||
/** 明细行命中的附加费(按产品 + 国家 + 重量段过滤) */
|
||||
function surchargesOf(row) {
|
||||
if (!row || !row.productCode) return []
|
||||
const all = surchargeCache[row.productCode] || []
|
||||
return all.filter(s => {
|
||||
if (s.countryCode && row.countryCode && String(s.countryCode).toUpperCase() !== String(row.countryCode).toUpperCase()) {
|
||||
return false
|
||||
}
|
||||
if (s.detailId == null) return true
|
||||
if (row.productCountryId != null && Number(s.detailId) === Number(row.productCountryId)) return true
|
||||
return false
|
||||
})
|
||||
return (surchargeCache[row.productCode] || []).filter(s => surchargeAppliesToRow(s, row))
|
||||
}
|
||||
|
||||
/** 明细行可选国家 */
|
||||
@@ -115,8 +206,12 @@ export function usePriceSetRefData() {
|
||||
productOptions,
|
||||
loadProducts,
|
||||
productNameOf,
|
||||
productMetaOf,
|
||||
ensureCountries,
|
||||
ensureSurcharges,
|
||||
allSurchargesOf,
|
||||
ensureAllSurcharges,
|
||||
allSurchargeConfigs,
|
||||
surchargesOf,
|
||||
countryOptionsOf,
|
||||
zoneOptionsOf,
|
||||
@@ -140,9 +235,13 @@ export function useDetailCascade(refData) {
|
||||
row.zoneCode = undefined
|
||||
row.zoneName = undefined
|
||||
row.weightLabel = undefined
|
||||
row.weightMin = undefined
|
||||
row.weightMax = undefined
|
||||
row.productCountryId = undefined
|
||||
row.fvValue = undefined
|
||||
row.fvRegistrationFee = undefined
|
||||
row.effectiveDate = undefined
|
||||
row.expireDate = undefined
|
||||
}
|
||||
|
||||
/** 选择产品:回填名称、清空级联、预取附加费与国家配置 */
|
||||
@@ -163,9 +262,13 @@ export function useDetailCascade(refData) {
|
||||
row.zoneCode = undefined
|
||||
row.zoneName = undefined
|
||||
row.weightLabel = undefined
|
||||
row.weightMin = undefined
|
||||
row.weightMax = undefined
|
||||
row.productCountryId = undefined
|
||||
row.fvValue = undefined
|
||||
row.fvRegistrationFee = undefined
|
||||
row.effectiveDate = undefined
|
||||
row.expireDate = undefined
|
||||
}
|
||||
|
||||
function onZoneChange(row) {
|
||||
@@ -174,9 +277,13 @@ export function useDetailCascade(refData) {
|
||||
row.zoneCode = opt ? opt.zoneCode : undefined
|
||||
row.zoneName = opt ? opt.zoneName : undefined
|
||||
row.weightLabel = undefined
|
||||
row.weightMin = undefined
|
||||
row.weightMax = undefined
|
||||
row.productCountryId = undefined
|
||||
row.fvValue = undefined
|
||||
row.fvRegistrationFee = undefined
|
||||
row.effectiveDate = undefined
|
||||
row.expireDate = undefined
|
||||
}
|
||||
|
||||
/** 选择重量段:绑定产品国家明细,并带出默认运费 / 挂号费 */
|
||||
@@ -184,6 +291,10 @@ export function useDetailCascade(refData) {
|
||||
const opt = refData.weightOptionsOf(row).find(w => w.value === row.weightLabel)
|
||||
if (!opt) {
|
||||
row.productCountryId = undefined
|
||||
row.weightMin = undefined
|
||||
row.weightMax = undefined
|
||||
row.effectiveDate = undefined
|
||||
row.expireDate = undefined
|
||||
return
|
||||
}
|
||||
row.productCountryId = opt.detailId
|
||||
@@ -192,14 +303,32 @@ export function useDetailCascade(refData) {
|
||||
if (opt.zoneName) row.zoneName = opt.zoneName
|
||||
if (opt.freightPrice != null) row.fvValue = Number(opt.freightPrice)
|
||||
if (opt.registrationFee != null) row.fvRegistrationFee = Number(opt.registrationFee)
|
||||
row.weightMin = opt.weightMin
|
||||
row.weightMax = opt.weightMax
|
||||
row.effectiveDate = opt.effectiveDate
|
||||
row.expireDate = opt.expireDate
|
||||
}
|
||||
|
||||
/** hydrate detail row; normalize weight label to min<W\u2264max */
|
||||
function hydrateRow(d, setType) {
|
||||
const row = toEditableDetailRow(d)
|
||||
if (!row.productCode) return row
|
||||
refData.ensureSurcharges(row.productCode)
|
||||
// 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.
|
||||
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).
|
||||
if (row.productCountryId != null && (row.weightMin != null || row.weightMax != null || row.weightLabel)) {
|
||||
if (row.weightMin != null || row.weightMax != null) {
|
||||
row.weightLabel = formatWeightLabel(row.weightMin, row.weightMax)
|
||||
}
|
||||
row._countryKey = countryKeyOf(row)
|
||||
// Snapshot from DB: treat current package price as baseline so drawer cells stay editable
|
||||
// and yellow "changed" highlight still works after first edit.
|
||||
if (row._baseFreight == null && row.fvValue != null) row._baseFreight = Number(row.fvValue)
|
||||
if (row._baseReg == null && row.fvRegistrationFee != null) row._baseReg = Number(row.fvRegistrationFee)
|
||||
return row
|
||||
}
|
||||
refData.ensureCountries(row.productCode).then(rows => {
|
||||
if (!row.weightLabel) return
|
||||
const hit = rows.find(item => {
|
||||
@@ -217,6 +346,12 @@ export function useDetailCascade(refData) {
|
||||
if (hit.zoneId != null) row.zoneId = hit.zoneId
|
||||
if (hit.zoneCode) row.zoneCode = hit.zoneCode
|
||||
if (hit.zoneName) row.zoneName = hit.zoneName
|
||||
row.weightMin = hit.weightMin
|
||||
row.weightMax = hit.weightMax
|
||||
row.effectiveDate = hit.effectiveDate
|
||||
row.expireDate = hit.expireDate
|
||||
if (row._baseFreight == null && hit.freightPrice != null) row._baseFreight = Number(hit.freightPrice)
|
||||
if (row._baseReg == null && hit.registrationFee != null) row._baseReg = Number(hit.registrationFee)
|
||||
})
|
||||
return row
|
||||
}
|
||||
|
||||
@@ -1,59 +1,61 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-steps :active="active" finish-status="success" align-center class="wizard-steps">
|
||||
<el-step title="基本信息" />
|
||||
<el-step title="套餐明细" />
|
||||
<el-step title="绑定客户" />
|
||||
<el-step :title="step1Title" />
|
||||
<el-step :title="step2Title" />
|
||||
</el-steps>
|
||||
|
||||
<!-- 第 1 步 -->
|
||||
<step-basic-info v-show="active === 0" ref="basicRef" v-model="form.basic" />
|
||||
<div v-show="active === 0">
|
||||
<step-basic-info ref="basicRef" v-model="form.basic" />
|
||||
</div>
|
||||
|
||||
<!-- 第 2 步 -->
|
||||
<step-details
|
||||
v-show="active === 1"
|
||||
ref="detailsRef"
|
||||
:details="form.details"
|
||||
:price-set-id="form.priceSetId"
|
||||
:set-type="form.basic.setType"
|
||||
:version-no="form.version.versionNo"
|
||||
:ref-data="refData"
|
||||
/>
|
||||
|
||||
<!-- 第 3 步 -->
|
||||
<step-customers
|
||||
v-show="active === 2"
|
||||
:customers="form.customers"
|
||||
:effective-date="form.basic.effectiveDate"
|
||||
:expire-date="form.basic.expireDate"
|
||||
/>
|
||||
|
||||
<div class="wizard-actions">
|
||||
<el-button @click="goBack">取消</el-button>
|
||||
<el-button v-if="active > 0" @click="active--">上一步</el-button>
|
||||
<el-button v-if="active < 2" type="primary" @click="nextStep">下一步</el-button>
|
||||
<el-button type="info" :loading="saving" @click="saveDraft">保存草稿</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="saveAndSubmit">保存并提交审核</el-button>
|
||||
<el-button v-if="active > 0 && !directStep2" @click="active--">上一步</el-button>
|
||||
<el-button v-if="active === 0" type="primary" :loading="creating" @click="goStep2">创建套餐价格</el-button>
|
||||
<el-button v-if="active === 0" type="info" :loading="saving" @click="saveDraft">保存草稿</el-button>
|
||||
<el-button v-if="active === 1" type="primary" @click="finishEdit">完成</el-button>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="progressVisible"
|
||||
:title="'正在保存套餐'"
|
||||
width="420px"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
:show-close="false"
|
||||
append-to-body
|
||||
>
|
||||
<div class="save-progress">
|
||||
<el-progress :percentage="progressPercent" :status="progressStatus" />
|
||||
<p class="save-progress__msg">{{ progressMessage }}</p>
|
||||
<p class="save-progress__hint">请勿关闭页面,大量明细保存可能需要一些时间</p>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PriceSetCreate">
|
||||
/**
|
||||
* 新建 / 编辑套餐 · 流程编排
|
||||
*
|
||||
* 三步表单已拆分到 components/,页面只负责:
|
||||
* 步骤切换、保存前校验、payload 组装、路由返回。
|
||||
* 参考数据(产品 / 国家 / 附加费)由 composables 提供,整页共享一份缓存。
|
||||
*/
|
||||
import StepBasicInfo from './components/create/StepBasicInfo.vue'
|
||||
import StepDetails from './components/create/StepDetails.vue'
|
||||
import StepCustomers from './components/create/StepCustomers.vue'
|
||||
import { usePriceSetRefData, useDetailCascade } from './composables/usePriceSetRefData'
|
||||
import {
|
||||
createEmptyBasicInfo,
|
||||
createEmptyDetailRow,
|
||||
nextVersionNo,
|
||||
toCustomerPayload,
|
||||
toDetailPayload
|
||||
} from './utils/priceSet'
|
||||
import { getPriceSet, savePriceSet } from '@/api/price/set'
|
||||
import { getPriceSet, savePriceSetAsync } from '@/api/price/set'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const route = useRoute()
|
||||
@@ -63,72 +65,175 @@ const cascade = useDetailCascade(refData)
|
||||
|
||||
const active = ref(0)
|
||||
const saving = ref(false)
|
||||
const creating = ref(false)
|
||||
const progressVisible = ref(false)
|
||||
const progressPercent = ref(0)
|
||||
const progressMessage = ref('')
|
||||
const progressStatus = ref(undefined)
|
||||
const basicRef = ref()
|
||||
const detailsRef = ref()
|
||||
const copyMode = computed(() => String(route.query.copyVersion || '') === '1')
|
||||
/** Entered from detail: continue-config / copy-version jump to step2 — hide 上一步 */
|
||||
const directStep2 = computed(() => copyMode.value || String(route.query.step || '') === '2')
|
||||
|
||||
const step1Title = '基本信息'
|
||||
const step2Title = '编辑产品价格'
|
||||
|
||||
/** 整个套餐表单:基本信息 / 明细 / 绑定客户 */
|
||||
const form = reactive({
|
||||
priceSetId: undefined,
|
||||
basic: createEmptyBasicInfo(),
|
||||
version: { psvId: undefined, versionNo: 'V1', effectiveTime: undefined, expireTime: undefined },
|
||||
details: [],
|
||||
customers: []
|
||||
})
|
||||
|
||||
/** 下一步:仅第 1 步需要校验 */
|
||||
async function nextStep() {
|
||||
if (active.value === 0) {
|
||||
const valid = await basicRef.value.validate()
|
||||
if (!valid) return
|
||||
function mapSaveProgressMessage(message) {
|
||||
const m = message || ''
|
||||
if (!m) return ''
|
||||
if (m === 'queued') return '排队中'
|
||||
if (m === 'pulling library') return '拉取产品库'
|
||||
if (m === 'details exist, skip pull') return '明细已存在,跳过拉取'
|
||||
if (m === 'saving basic') return '保存基本信息'
|
||||
if (m === 'saving version') return '保存版本'
|
||||
if (m.startsWith('saving details ')) return '保存明细 ' + m.slice('saving details '.length)
|
||||
if (m === 'saving surcharges') return '保存附加费'
|
||||
if (m === 'details unchanged') return '明细未变更'
|
||||
if (m === 'saving customers') return '保存客户'
|
||||
if (m === 'finishing') return '收尾中'
|
||||
if (m === 'done') return '完成'
|
||||
if (m === 'failed') return '失败'
|
||||
return m
|
||||
}
|
||||
|
||||
async function runSaveWithProgress(payload) {
|
||||
progressVisible.value = true
|
||||
progressPercent.value = 0
|
||||
progressMessage.value = ''
|
||||
progressStatus.value = undefined
|
||||
try {
|
||||
const result = await savePriceSetAsync(payload, (task) => {
|
||||
progressPercent.value = Math.min(100, Number(task.percent) || 0)
|
||||
progressMessage.value = mapSaveProgressMessage(task.message)
|
||||
if (task.status === 'FAIL') {
|
||||
progressStatus.value = 'exception'
|
||||
} else if (task.status === 'SUCCESS') {
|
||||
progressStatus.value = 'success'
|
||||
} else {
|
||||
progressStatus.value = undefined
|
||||
}
|
||||
})
|
||||
progressPercent.value = 100
|
||||
progressStatus.value = 'success'
|
||||
return result.priceSetId
|
||||
} catch (e) {
|
||||
progressStatus.value = 'exception'
|
||||
const msg = (e && e.task && e.task.error) || (e && e.message) || '保存失败'
|
||||
progressMessage.value = msg
|
||||
if (proxy && proxy.$modal) {
|
||||
proxy.$modal.msgError(msg)
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 800))
|
||||
throw e
|
||||
} finally {
|
||||
progressVisible.value = false
|
||||
}
|
||||
active.value++
|
||||
}
|
||||
|
||||
function saveDraft() {
|
||||
save(false)
|
||||
/** Step1 -> Step2: create package prices from library when needed */
|
||||
async function goStep2() {
|
||||
const validBasic = await basicRef.value.validate()
|
||||
if (!validBasic) return
|
||||
|
||||
const hasPersistedDetails = (form.details || []).some(d => d && d.psdId)
|
||||
if (form.priceSetId && form.version.psvId && hasPersistedDetails) {
|
||||
active.value = 1
|
||||
return
|
||||
}
|
||||
|
||||
creating.value = true
|
||||
try {
|
||||
form.details.splice(0, form.details.length)
|
||||
const priceSetId = await runSaveWithProgress({
|
||||
...buildPayload(),
|
||||
details: [],
|
||||
pullFromLibrary: 'Y'
|
||||
})
|
||||
form.priceSetId = priceSetId
|
||||
const fresh = await getPriceSet(priceSetId)
|
||||
applySetData(fresh.data || {}, false)
|
||||
active.value = 1
|
||||
proxy.$modal.msgSuccess('已创建套餐价格,可在第 2 步编辑')
|
||||
} catch (e) {
|
||||
// surfaced
|
||||
} finally {
|
||||
creating.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function saveAndSubmit() {
|
||||
save(true)
|
||||
/** Step2: prices already live-saved via PUT /detail; go to detail page. */
|
||||
function finishEdit() {
|
||||
if (!form.priceSetId) {
|
||||
goBack()
|
||||
return
|
||||
}
|
||||
proxy.$modal.msgSuccess('修改已实时落库')
|
||||
const obj = {
|
||||
path: '/customer/setDetail',
|
||||
query: { priceSetId: form.priceSetId }
|
||||
}
|
||||
if (proxy.$tab) {
|
||||
proxy.$tab.closeOpenPage(obj)
|
||||
} else {
|
||||
proxy.$router.push(obj)
|
||||
}
|
||||
}
|
||||
|
||||
/** 校验 + 保存;校验失败回到第 1 步 */
|
||||
async function save(submit) {
|
||||
const valid = await basicRef.value.validate()
|
||||
if (!valid) {
|
||||
/** Step0 only: persist basic draft (no detail wipe). */
|
||||
async function saveDraft() {
|
||||
const validBasic = await basicRef.value.validate()
|
||||
if (!validBasic) {
|
||||
active.value = 0
|
||||
return
|
||||
}
|
||||
const ids = form.customers.filter(c => c.customerId).map(c => String(c.customerId))
|
||||
if (new Set(ids).size !== ids.length) {
|
||||
proxy.$modal.msgError('该客户已绑定套餐,一个客户只能绑定一个套餐')
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
savePriceSet(buildPayload(submit)).then(res => {
|
||||
form.priceSetId = res.data
|
||||
proxy.$modal.msgSuccess(submit ? '已保存并提交审核' : '草稿已保存,套餐ID=' + res.data)
|
||||
try {
|
||||
const priceSetId = await runSaveWithProgress(buildPayload())
|
||||
form.priceSetId = priceSetId
|
||||
proxy.$modal.msgSuccess('草稿已保存,套餐ID=' + priceSetId)
|
||||
goBack()
|
||||
}).catch(() => {
|
||||
// 错误提示由请求拦截器统一处理
|
||||
}).finally(() => {
|
||||
} catch (e) {
|
||||
// surfaced
|
||||
} finally {
|
||||
saving.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/** 表单 -> 后端 payload */
|
||||
function buildPayload(submitFlag) {
|
||||
const { basic } = form
|
||||
return {
|
||||
function buildPayload() {
|
||||
const { basic, version } = form
|
||||
const detailRows = form.details.filter(d => d && d.productCode)
|
||||
// Price edits already persist via PUT /detail; product remove uses DELETE.
|
||||
// Omit details when all rows already have psdId so save only updates header/version.
|
||||
const hasUnsavedDetail = detailRows.some(d => d.psdId == null)
|
||||
const payload = {
|
||||
priceSetId: form.priceSetId,
|
||||
priceSetName: basic.priceSetName,
|
||||
setType: basic.setType,
|
||||
defaultDiscount: basic.setType === 'DISCOUNT' ? basic.defaultDiscount : undefined,
|
||||
effectiveDate: basic.effectiveDate,
|
||||
expireDate: basic.expireDate || undefined,
|
||||
priceSetNote: basic.priceSetNote,
|
||||
details: form.details.filter(d => d.productCode).map(toDetailPayload),
|
||||
customers: form.customers.filter(c => c.customerCode).map(toCustomerPayload),
|
||||
submitFlag: submitFlag ? 'Y' : undefined
|
||||
version: {
|
||||
psvId: copyMode.value ? undefined : version.psvId,
|
||||
versionNo: version.versionNo
|
||||
}
|
||||
}
|
||||
if (hasUnsavedDetail) {
|
||||
payload.details = detailRows.map(toDetailPayload)
|
||||
}
|
||||
// Customer bind is managed on detail page APIs; only send when present to avoid wipe.
|
||||
const customers = form.customers.filter(c => c && c.customerCode).map(toCustomerPayload)
|
||||
if (customers.length) {
|
||||
payload.customers = customers
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
@@ -140,21 +245,44 @@ function goBack() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑 / 复用新建:回显已有套餐 */
|
||||
function loadExisting(id) {
|
||||
function applySetData(data, asCopy) {
|
||||
form.priceSetId = data.priceSetId
|
||||
Object.assign(form.basic, {
|
||||
priceSetName: data.priceSetName,
|
||||
setType: data.setType || 'FIXED',
|
||||
defaultDiscount: data.defaultDiscount != null ? Number(data.defaultDiscount) : 88,
|
||||
priceSetNote: data.priceSetNote
|
||||
})
|
||||
const versions = data.versions || []
|
||||
const qPsv = route.query.psvId
|
||||
const byQuery = qPsv != null ? versions.find(v => String(v.psvId) === String(qPsv)) : null
|
||||
const current = byQuery || data.version || versions[0] || {}
|
||||
if (asCopy) {
|
||||
form.version.psvId = undefined
|
||||
form.version.versionNo = nextVersionNo(versions)
|
||||
form.version.effectiveTime = undefined
|
||||
form.version.expireTime = undefined
|
||||
} else {
|
||||
form.version.psvId = current.psvId
|
||||
form.version.versionNo = current.versionNo || nextVersionNo(versions)
|
||||
form.version.effectiveTime = current.effectiveTime
|
||||
form.version.expireTime = current.expireTime
|
||||
}
|
||||
const srcDetails = (current.details && current.details.length) ? current.details : (data.details || [])
|
||||
form.details = srcDetails.map(d => {
|
||||
const row = cascade.hydrateRow(d, form.basic.setType)
|
||||
if (asCopy) row.psdId = undefined
|
||||
return row
|
||||
})
|
||||
form.customers = (data.customers || []).map(c => ({ ...c }))
|
||||
}
|
||||
|
||||
function loadExisting(id, asCopy) {
|
||||
getPriceSet(id).then(res => {
|
||||
const data = res.data || {}
|
||||
form.priceSetId = data.priceSetId
|
||||
Object.assign(form.basic, {
|
||||
priceSetName: data.priceSetName,
|
||||
setType: data.setType || 'FIXED',
|
||||
defaultDiscount: data.defaultDiscount != null ? Number(data.defaultDiscount) : 88,
|
||||
effectiveDate: data.effectiveDate,
|
||||
expireDate: data.expireDate,
|
||||
priceSetNote: data.priceSetNote
|
||||
})
|
||||
form.details = (data.details || []).map(d => cascade.hydrateRow(d, form.basic.setType))
|
||||
form.customers = (data.customers || []).map(c => ({ ...c }))
|
||||
applySetData(res.data || {}, asCopy)
|
||||
if (asCopy || String(route.query.step || '') === '2') {
|
||||
active.value = 1
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -162,9 +290,7 @@ onMounted(() => {
|
||||
refData.loadProducts().finally(() => {
|
||||
const id = route.query.priceSetId
|
||||
if (id) {
|
||||
loadExisting(id)
|
||||
} else {
|
||||
form.details.push(createEmptyDetailRow())
|
||||
loadExisting(id, copyMode.value)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -177,11 +303,19 @@ onMounted(() => {
|
||||
padding: 20px 12px 12px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.step-card {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.wizard-actions {
|
||||
text-align: center;
|
||||
padding: 8px 0 24px;
|
||||
}
|
||||
.save-progress__msg {
|
||||
margin: 12px 0 4px;
|
||||
color: #606266;
|
||||
font-size: 13px;
|
||||
word-break: break-all;
|
||||
}
|
||||
.save-progress__hint {
|
||||
margin: 0;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,64 +1,87 @@
|
||||
<template>
|
||||
<div class="app-container" v-loading="loading">
|
||||
<set-detail-header
|
||||
:set="set"
|
||||
@back="goList"
|
||||
@edit="goEdit"
|
||||
@submit="onSubmit"
|
||||
@approve="onApprove"
|
||||
@reject="onReject"
|
||||
@disable="onDisable"
|
||||
@copy="onCopy"
|
||||
<!-- 编辑模式:整屏切换,等同独立页面 -->
|
||||
<price-edit-panel
|
||||
v-if="editVisible"
|
||||
:price-set-id="set.priceSetId"
|
||||
:psv-id="editPsvId"
|
||||
@close="closeEdit"
|
||||
/>
|
||||
|
||||
<set-basic-info-card :set="set" />
|
||||
<template v-else>
|
||||
<set-detail-header
|
||||
:set="set"
|
||||
@back="goList"
|
||||
@disable="onDisable"
|
||||
@copy="onCopy"
|
||||
/>
|
||||
|
||||
<set-detail-table :set="set" :ref-data="refData" @refresh="load" />
|
||||
<set-basic-info-card :set="set" />
|
||||
|
||||
<set-customer-table :set="set" @refresh="load" />
|
||||
<set-customer-table :set="set" />
|
||||
|
||||
<set-version-table
|
||||
v-model="currentPsvId"
|
||||
:versions="set.versions || []"
|
||||
@copy-version="onCopyVersion"
|
||||
@open-details="onOpenVersionDetails"
|
||||
@activate="onActivateVersion"
|
||||
@edit="onEditVersion"
|
||||
@remove="onRemoveVersion"
|
||||
/>
|
||||
|
||||
<set-version-detail-drawer
|
||||
v-model="detailDrawerVisible"
|
||||
:version="detailVersion"
|
||||
:set-type="set.setType"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PriceSetDetail">
|
||||
/**
|
||||
* 套餐详情 · 页面编排
|
||||
*
|
||||
* 展示区拆到 components/:页头、基本信息、明细表(含明细弹窗)、客户表(含客户弹窗);
|
||||
* 本页只负责:加载详情、状态流转操作、向子组件下发共享参考数据。
|
||||
*/
|
||||
import SetDetailHeader from './components/detail/SetDetailHeader.vue'
|
||||
import SetBasicInfoCard from './components/detail/SetBasicInfoCard.vue'
|
||||
import SetDetailTable from './components/detail/SetDetailTable.vue'
|
||||
import SetCustomerTable from './components/detail/SetCustomerTable.vue'
|
||||
import SetVersionTable from './components/detail/SetVersionTable.vue'
|
||||
import SetVersionDetailDrawer from './components/detail/SetVersionDetailDrawer.vue'
|
||||
import PriceEditPanel from './components/create/PriceEditPanel.vue'
|
||||
import { usePriceSetRefData } from './composables/usePriceSetRefData'
|
||||
import {
|
||||
getPriceSet, submitPriceSet, approvePriceSet, rejectPriceSet, disablePriceSet, copyPriceSet
|
||||
getPriceSet, disablePriceSet, copyPriceSet, activatePriceSetVersion, copyPriceSetVersion, deletePriceSetVersion
|
||||
} from '@/api/price/set'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const route = useRoute()
|
||||
|
||||
/** 产品 / 国家 / 附加费 参考数据与明细弹窗级联共用,与新建页同一套实现 */
|
||||
const refData = usePriceSetRefData()
|
||||
|
||||
const loading = ref(false)
|
||||
const set = ref({})
|
||||
const currentPsvId = ref()
|
||||
const detailDrawerVisible = ref(false)
|
||||
const detailVersion = ref(null)
|
||||
const editVisible = ref(false)
|
||||
const editPsvId = ref(undefined)
|
||||
|
||||
function onOpenVersionDetails(row) {
|
||||
detailVersion.value = row || null
|
||||
detailDrawerVisible.value = true
|
||||
}
|
||||
|
||||
/** 拉取套餐详情,并预取明细涉及产品的附加费 */
|
||||
function load() {
|
||||
const id = route.query.priceSetId
|
||||
if (!id) return
|
||||
loading.value = true
|
||||
getPriceSet(id).then(res => {
|
||||
set.value = res.data || {}
|
||||
const codes = [...new Set((set.value.details || []).map(d => d.productCode).filter(Boolean))]
|
||||
codes.forEach(code => refData.ensureSurcharges(code))
|
||||
const versions = set.value.versions || []
|
||||
const cur = set.value.version || versions[0]
|
||||
currentPsvId.value = cur ? cur.psvId : undefined
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/** 二次确认 -> 调接口 -> 提示 -> 刷新(或跳转) */
|
||||
function confirmAction(text, request, successText, done) {
|
||||
proxy.$modal.confirm(text).then(() => request()).then(() => {
|
||||
proxy.$modal.msgSuccess(successText)
|
||||
@@ -66,30 +89,56 @@ function confirmAction(text, request, successText, done) {
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
confirmAction('确认提交审核?', () => submitPriceSet(set.value.priceSetId), '已提交审核')
|
||||
}
|
||||
|
||||
function onApprove() {
|
||||
confirmAction('确认审批生效?', () => approvePriceSet(set.value.priceSetId), '套餐已生效')
|
||||
}
|
||||
|
||||
function onReject() {
|
||||
confirmAction('确认驳回该套餐?', () => rejectPriceSet(set.value.priceSetId), '已驳回')
|
||||
}
|
||||
|
||||
function onDisable() {
|
||||
confirmAction('停用后不再参与计费命中,确认停用?', () => disablePriceSet(set.value.priceSetId), '已停用')
|
||||
}
|
||||
|
||||
/** 复用新建:复制为草稿后跳转到新建页 */
|
||||
function onActivateVersion(row) {
|
||||
if (!row || row.psvId == null) return
|
||||
confirmAction(
|
||||
'确认启动版本 ' + (row.versionNo || '') + '?启动后将以当前时间生效,上一版本自动失效。',
|
||||
() => activatePriceSetVersion(row.psvId),
|
||||
'版本已启动'
|
||||
)
|
||||
}
|
||||
function onCopy() {
|
||||
copyPriceSet(set.value.priceSetId).then(res => {
|
||||
proxy.$modal.msgSuccess('已复制为草稿')
|
||||
proxy.$router.push({ path: '/customer/setCreate', query: { priceSetId: res.data } })
|
||||
})
|
||||
}
|
||||
function onCopyVersion(row) {
|
||||
if (!row || row.psvId == null) return
|
||||
proxy.$modal.confirm(
|
||||
'确认复制版本 ' + (row.versionNo || '') + '为新草稿?将新增版本并拷贝全部明细。'
|
||||
).then(() => copyPriceSetVersion(row.psvId)).then(res => {
|
||||
proxy.$modal.msgSuccess('已复制为新版本')
|
||||
const newPsvId = res.data
|
||||
load()
|
||||
if (newPsvId != null) {
|
||||
editPsvId.value = newPsvId
|
||||
editVisible.value = true
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
function onRemoveVersion(row) {
|
||||
if (!row || row.psvId == null) return
|
||||
proxy.$modal.confirm(
|
||||
'确认删除草稿版本 ' + (row.versionNo || '') + '?其明细与附加费将一并删除。'
|
||||
).then(() => deletePriceSetVersion(row.psvId)).then(() => {
|
||||
proxy.$modal.msgSuccess('版本已删除')
|
||||
load()
|
||||
}).catch(() => {})
|
||||
}
|
||||
function onEditVersion(row) {
|
||||
editPsvId.value = row && row.psvId != null ? row.psvId : undefined
|
||||
editVisible.value = true
|
||||
}
|
||||
|
||||
/** 关闭内嵌编辑面板,刷新版本列表(明细数、状态可能变化) */
|
||||
function closeEdit() {
|
||||
editVisible.value = false
|
||||
load()
|
||||
}
|
||||
function goList() {
|
||||
const obj = { path: '/customer/set' }
|
||||
if (proxy.$tab) {
|
||||
@@ -99,10 +148,6 @@ function goList() {
|
||||
}
|
||||
}
|
||||
|
||||
function goEdit() {
|
||||
proxy.$router.push({ path: '/customer/setCreate', query: { priceSetId: set.value.priceSetId } })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
refData.loadProducts()
|
||||
load()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
:query="queryList"
|
||||
row-key="priceSetId"
|
||||
>
|
||||
<template #toolbar="{ selection, ids }">
|
||||
<template #toolbar>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
@@ -17,16 +17,6 @@
|
||||
v-hasPermi="['price:set:add']"
|
||||
>新建套餐</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="!selection.length"
|
||||
@click="handleDelete(ids)"
|
||||
v-hasPermi="['price:set:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
</template>
|
||||
|
||||
<template #col-setType="{ row }">
|
||||
@@ -43,61 +33,42 @@
|
||||
<el-tag :type="statusTag(row)" size="small">{{ statusLabel(row) }}</el-tag>
|
||||
</template>
|
||||
|
||||
<template #col-activeDetail="{ row }">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
:loading="activeLoadingId === row.priceSetId"
|
||||
@click="handleActiveDetail(row)"
|
||||
v-hasPermi="['price:set:query']"
|
||||
>查看明细</el-button>
|
||||
</template>
|
||||
|
||||
<template #col-action="{ row }">
|
||||
<el-button link type="primary" @click="handleDetail(row)" v-hasPermi="['price:set:query']">详情</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'D' || row.status === 'R'"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleEdit(row)"
|
||||
v-hasPermi="['price:set:edit']"
|
||||
>{{ row.status === 'D' ? '继续配置' : '编辑' }}</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'D' || row.status === 'R'"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleSubmit(row)"
|
||||
v-hasPermi="['price:set:audit']"
|
||||
>提交审核</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'A'"
|
||||
link
|
||||
type="success"
|
||||
@click="handleApprove(row)"
|
||||
v-hasPermi="['price:set:audit']"
|
||||
>审批</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'E' && !row.expired"
|
||||
link
|
||||
type="warning"
|
||||
@click="handleDisable(row)"
|
||||
v-hasPermi="['price:set:audit']"
|
||||
>停用</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'S'"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleCopy(row)"
|
||||
v-hasPermi="['price:set:add']"
|
||||
>复用</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'D' || row.status === 'R'"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(row.priceSetId)"
|
||||
v-hasPermi="['price:set:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</basic-table>
|
||||
|
||||
<set-version-detail-drawer
|
||||
v-model="drawerVisible"
|
||||
:version="activeVersion"
|
||||
:set-type="drawerSetType"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PriceSet">
|
||||
import {
|
||||
listPriceSet, delPriceSet, submitPriceSet, approvePriceSet, disablePriceSet, copyPriceSet
|
||||
listPriceSet, disablePriceSet, copyPriceSet, getPriceSet
|
||||
} from '@/api/price/set'
|
||||
import { parseTime } from '@/utils/ruoyi'
|
||||
import SetVersionDetailDrawer from './components/detail/SetVersionDetailDrawer.vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const tableRef = ref()
|
||||
@@ -120,10 +91,7 @@ const searchColumns = [
|
||||
prop: 'status',
|
||||
component: 'select',
|
||||
options: [
|
||||
{ label: '草稿', value: 'D' },
|
||||
{ label: '审核中', value: 'A' },
|
||||
{ label: '生效', value: 'E' },
|
||||
{ label: '驳回', value: 'R' },
|
||||
{ label: '已停用', value: 'S' }
|
||||
],
|
||||
placeholder: '全部状态',
|
||||
@@ -137,11 +105,8 @@ const columns = [
|
||||
{ label: '套餐名称', prop: 'priceSetName', minWidth: 160 },
|
||||
{ label: '类型', prop: 'setType', width: 140 },
|
||||
{ label: '说明', prop: 'priceSetNote', minWidth: 160 },
|
||||
{ label: '产品数', prop: 'productCount', width: 80 },
|
||||
{ label: '客户数', prop: 'customerCount', width: 80 },
|
||||
{ label: '生效日期', prop: 'dateRange', minWidth: 200 },
|
||||
{ label: '状态', prop: 'status', width: 90 },
|
||||
{ label: '操作', prop: 'action', width: 280, showInToolbar: false }
|
||||
{ label: '生效明细', prop: 'activeDetail', width: 100 },
|
||||
{ label: '操作', prop: 'action', width: 160, showInToolbar: false }
|
||||
]
|
||||
|
||||
function queryList(params) {
|
||||
@@ -172,10 +137,31 @@ function handleDetail(row) {
|
||||
proxy.$router.push({ path: '/customer/setDetail', query: { priceSetId: row.priceSetId } })
|
||||
}
|
||||
|
||||
function handleEdit(row) {
|
||||
proxy.$router.push({ path: '/customer/setCreate', query: { priceSetId: row.priceSetId } })
|
||||
/** 生效明细:拉详情找生效版本(status=1)弹抽屉 */
|
||||
const drawerVisible = ref(false)
|
||||
const activeVersion = ref(null)
|
||||
const drawerSetType = ref('FIXED')
|
||||
const activeLoadingId = ref(null)
|
||||
|
||||
function handleActiveDetail(row) {
|
||||
activeLoadingId.value = row.priceSetId
|
||||
getPriceSet(row.priceSetId).then(res => {
|
||||
const data = res.data || {}
|
||||
const versions = data.versions || []
|
||||
const active = versions.find(v => String(v.status) === '1')
|
||||
if (!active || active.psvId == null) {
|
||||
proxy.$modal.msgWarning('该套餐暂无生效版本')
|
||||
return
|
||||
}
|
||||
drawerSetType.value = row.setType
|
||||
activeVersion.value = { psvId: active.psvId, versionNo: active.versionNo }
|
||||
drawerVisible.value = true
|
||||
}).finally(() => {
|
||||
activeLoadingId.value = null
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function refresh() {
|
||||
tableRef.value?.refresh()
|
||||
}
|
||||
@@ -188,32 +174,6 @@ onActivated(() => {
|
||||
tableRef.value?.reload()
|
||||
})
|
||||
|
||||
function handleDelete(ids) {
|
||||
proxy.$modal.confirm('是否确认删除套餐编号为 "' + ids + '" 的数据项?').then(() => {
|
||||
return delPriceSet(ids)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
refresh()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function handleSubmit(row) {
|
||||
proxy.$modal.confirm('确认提交套餐【' + row.priceSetName + '】审核?').then(() => {
|
||||
return submitPriceSet(row.priceSetId)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已提交审核')
|
||||
refresh()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function handleApprove(row) {
|
||||
proxy.$modal.confirm('确认将套餐【' + row.priceSetName + '】审批生效?').then(() => {
|
||||
return approvePriceSet(row.priceSetId)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('套餐已生效')
|
||||
refresh()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function handleDisable(row) {
|
||||
proxy.$modal.confirm('停用后该套餐不再参与计费命中,确认停用【' + row.priceSetName + '】?').then(() => {
|
||||
|
||||
@@ -212,3 +212,24 @@
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 弹窗顶部说明条:左侧口径说明 + 右侧已选计数(附加费勾选弹窗) */
|
||||
.ps-picker-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
|
||||
&__picked {
|
||||
flex: none;
|
||||
padding: 0 8px;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
color: #1890ff;
|
||||
background: #ecf5ff;
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,29 @@ const STATUS_TAG = {
|
||||
/** 默认取值方式 */
|
||||
export const DEFAULT_ROUND_MODE = 'HALF_UP'
|
||||
|
||||
/** version status: 0 draft / 1 active / 2 expired */
|
||||
export const VER_STATUS = {
|
||||
DRAFT: '0',
|
||||
EFFECT: '1',
|
||||
EXPIRED: '2'
|
||||
}
|
||||
|
||||
export function versionStatusLabel(status) {
|
||||
const map = { '0': '草稿', '1': '生效', '2': '失效' }
|
||||
return map[status] || status || '-'
|
||||
}
|
||||
|
||||
export function versionStatusTag(status) {
|
||||
const map = { '0': 'warning', '1': 'success', '2': 'info' }
|
||||
return map[status] || 'info'
|
||||
}
|
||||
|
||||
export function nextVersionNo(versions) {
|
||||
const seqs = (versions || []).map(v => Number(v.versionSeq) || 0)
|
||||
const max = seqs.length ? Math.max.apply(null, seqs) : 0
|
||||
return 'V' + (max + 1)
|
||||
}
|
||||
|
||||
/** 状态文案(已过期优先) */
|
||||
export function setStatusLabel(set) {
|
||||
if (set && set.expired) return '已过期'
|
||||
@@ -201,7 +224,11 @@ export function buildWeightOptions(rows, row) {
|
||||
zoneCode: item.zoneCode,
|
||||
zoneName: item.zoneName,
|
||||
freightPrice: item.freightPrice,
|
||||
registrationFee: item.registrationFee
|
||||
registrationFee: item.registrationFee,
|
||||
weightMin: item.weightMin,
|
||||
weightMax: item.weightMax,
|
||||
effectiveDate: item.effectiveDate,
|
||||
expireDate: item.expireDate
|
||||
})
|
||||
})
|
||||
return [...map.values()]
|
||||
@@ -217,11 +244,29 @@ export function formatChargeValue(row) {
|
||||
|
||||
/** 附加费作用范围文案 */
|
||||
export function surchargeScopeLabel(s) {
|
||||
if (s.detailId == null) return '产品级'
|
||||
// 主表(prc_surcharge)数据:country_code 有值 = 该国专属(计费归属),空 = 全部国家
|
||||
if (s.detailId == null && s.psdId == null) {
|
||||
return s.countryCode ? `国家 ${s.countryCode}` : '全部国家'
|
||||
}
|
||||
const w = s.weightMin != null && s.weightMax != null ? `${s.weightMin}-${s.weightMax}kg` : '-'
|
||||
return `${s.countryName || '-'} · ${w}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品关联附加费(prc_surcharge_rel)是否作用于该明细行
|
||||
* 与后端 snapshotVersionSurcharges 的过滤口径保持一致:
|
||||
* 国家三字码一致 + 产品级(detailId 空)直接命中,明细级需 productCountryId 相同
|
||||
*/
|
||||
export function surchargeAppliesToRow(rel, row) {
|
||||
if (!rel || !row) return false
|
||||
if (rel.countryCode && row.countryCode
|
||||
&& String(rel.countryCode).toUpperCase() !== String(row.countryCode).toUpperCase()) {
|
||||
return false
|
||||
}
|
||||
if (rel.detailId == null) return true
|
||||
return row.productCountryId != null && Number(rel.detailId) === Number(row.productCountryId)
|
||||
}
|
||||
|
||||
/** 附加费标签文案 */
|
||||
export function surchargeTagLabel(s) {
|
||||
return `${s.scName} ${formatChargeValue(s)}`
|
||||
@@ -239,11 +284,19 @@ export function createEmptyDetailRow() {
|
||||
zoneCode: undefined,
|
||||
zoneName: undefined,
|
||||
weightLabel: undefined,
|
||||
weightMin: undefined,
|
||||
weightMax: undefined,
|
||||
productCountryId: undefined,
|
||||
fvValue: undefined,
|
||||
fvRegistrationFee: undefined,
|
||||
/** product default freight when copied from bms_product_country */
|
||||
_baseFreight: undefined,
|
||||
/** product default registration fee */
|
||||
_baseReg: undefined,
|
||||
discountValue: undefined,
|
||||
roundMode: DEFAULT_ROUND_MODE
|
||||
roundMode: DEFAULT_ROUND_MODE,
|
||||
effectiveDate: undefined,
|
||||
expireDate: undefined
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,10 +305,20 @@ export function toEditableDetailRow(row) {
|
||||
return {
|
||||
...row,
|
||||
roundMode: row.roundMode || DEFAULT_ROUND_MODE,
|
||||
_countryKey: countryKeyOf(row)
|
||||
_countryKey: countryKeyOf(row),
|
||||
_baseFreight: row._baseFreight != null ? row._baseFreight : undefined,
|
||||
_baseReg: row._baseReg != null ? row._baseReg : undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** FIXED row changed vs product default */
|
||||
export function isDetailPriceChanged(row) {
|
||||
if (!row) return false
|
||||
if (row._baseFreight != null && Number(row.fvValue) !== Number(row._baseFreight)) return true
|
||||
if (row._baseReg != null && Number(row.fvRegistrationFee) !== Number(row._baseReg)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
/** 新增一条空客户绑定行 */
|
||||
export function createEmptyCustomerRow({ effectiveDate, expireDate, seq = 1 } = {}) {
|
||||
return {
|
||||
@@ -283,6 +346,9 @@ export function createEmptyBasicInfo() {
|
||||
/** 明细行 -> 提交后端的 payload */
|
||||
export function toDetailPayload(d) {
|
||||
return {
|
||||
psdId: d.psdId || undefined,
|
||||
psvId: d.psvId || undefined,
|
||||
priceSetId: d.priceSetId || undefined,
|
||||
productCode: d.productCode,
|
||||
productName: d.productName,
|
||||
countryCode: d.countryCode || undefined,
|
||||
@@ -291,11 +357,17 @@ export function toDetailPayload(d) {
|
||||
zoneCode: d.zoneCode || undefined,
|
||||
zoneName: d.zoneName || undefined,
|
||||
weightLabel: d.weightLabel || undefined,
|
||||
weightMin: d.weightMin,
|
||||
weightMax: d.weightMax,
|
||||
productCountryId: d.productCountryId || undefined,
|
||||
fvValue: d.fvValue,
|
||||
fvRegistrationFee: d.fvRegistrationFee,
|
||||
discountValue: d.discountValue,
|
||||
roundMode: d.roundMode || DEFAULT_ROUND_MODE
|
||||
roundMode: d.roundMode || DEFAULT_ROUND_MODE,
|
||||
effectiveDate: d.effectiveDate || undefined,
|
||||
expireDate: d.expireDate || undefined,
|
||||
/** 勾选保存的附加费:带数组即按勾选落快照,空数组=一条都不选 */
|
||||
surcharges: Array.isArray(d.surcharges) ? d.surcharges.map(s => ({ scId: s.scId })) : undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user