diff --git a/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/PayProductController.java b/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/PayProductController.java index b2b579e8..086e73ec 100644 --- a/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/PayProductController.java +++ b/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/PayProductController.java @@ -114,17 +114,18 @@ public class PayProductController extends BaseController return success(payProductService.selectTemplateOptions(payType)); } - /** 渠道当前价格副本 */ + /** 渠道当前价格副本;payType 默认应付 AP */ @PreAuthorize("@ss.hasAnyPermi('price:pay:query,data:serviceChannel:query,data:serviceChannel:edit')") @GetMapping("/channel/{channelId}") - public AjaxResult channelPrice(@PathVariable String channelId) + public AjaxResult channelPrice(@PathVariable String channelId, + @RequestParam(value = "payType", required = false) String payType) { - return success(payProductService.selectChannelPrice(channelId)); + return success(payProductService.selectChannelPrice(channelId, payType)); } - /** 渠道只绑定产品编号,以后按有效期取价 */ + /** 渠道只绑定产品编号,以后按有效期取价;支持应收 AR 与应付 AP */ @PreAuthorize("@ss.hasAnyPermi('price:pay:edit,data:serviceChannel:edit')") - @Log(title = "渠道应付产品", businessType = BusinessType.UPDATE) + @Log(title = "渠道产品绑定", businessType = BusinessType.UPDATE) @PutMapping("/channel/{channelId}/bind") public AjaxResult bindChannel(@PathVariable String channelId, @RequestBody ChannelProductMap link) { @@ -135,7 +136,7 @@ public class PayProductController extends BaseController return success(); } payProductService.bindChannel(channelId, link.getProductId(), link.getPriceSetId(), payType); - return success(payProductService.selectChannelPrice(channelId)); + return success(payProductService.selectChannelPrice(channelId, payType)); } /** 对照两个价格版本 */ diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/ChannelProductMap.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/ChannelProductMap.java index adb921a7..07e9f724 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/ChannelProductMap.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/ChannelProductMap.java @@ -15,6 +15,9 @@ public class ChannelProductMap /** 渠道表主键 srv_service_channel.id */ private String channelId; + /** 渠道编码,对应 srv_service_channel.channel_code */ + private String channelCode; + private Long productId; /** 应收套餐 prc_price_set.price_set_id */ diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/PayProductMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/PayProductMapper.java index ab7b6fb2..dca13d49 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/PayProductMapper.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/mapper/PayProductMapper.java @@ -22,7 +22,7 @@ public interface PayProductMapper Long selectTemplateId(@Param("dictValue") String dictValue); - List selectTemplateOptions(); + List selectTemplateOptions(@Param("payType") String payType); Integer selectMaxVersion(@Param("originId") Long originId); diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/IPayProductService.java b/bms-back/bms-system/src/main/java/com/bms/price/service/IPayProductService.java index cd32d070..5ce504bb 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/IPayProductService.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/IPayProductService.java @@ -47,10 +47,13 @@ public interface IPayProductService /** 公共模板下拉。payType 为空时按应付 AP */ List selectTemplateOptions(String payType); - /** 渠道绑定的产品。返回的 originId 是不变的产品编号,价格是当前有效版 */ + /** 渠道绑定的产品。返回的 originId 是不变的产品编号,价格是当前有效版;默认应付 AP */ PayProduct selectChannelPrice(String channelId); - /** 只绑定产品编号,不产生新版本。payType 为空时按应付 AP */ + /** 按收付类型查询渠道绑定产品,payType 为空时按应付 AP */ + PayProduct selectChannelPrice(String channelId, String payType); + + /** 只绑定产品编号,不产生新版本;同时落 channel_code。payType 为空时按应付 AP */ void bindChannel(String channelId, Long productId, Long priceSetId, String payType); /** 取消渠道上指定收付类型的产品。payType 为空时按应付 AP */ diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PayProductServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PayProductServiceImpl.java index ae0382b7..209ba71e 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PayProductServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PayProductServiceImpl.java @@ -35,6 +35,8 @@ import com.bms.price.domain.PayProductTerm; import com.bms.price.domain.PaySaveCommand; import com.bms.price.domain.PaySurcharge; import com.bms.price.domain.PayWeightBand; +import com.bms.masterdata.domain.ServiceChannel; +import com.bms.masterdata.mapper.ServiceChannelMapper; import com.bms.price.mapper.ChannelProductMapMapper; import com.bms.price.mapper.PayProductMapper; import com.bms.price.mapper.PayProductTermMapper; @@ -63,6 +65,9 @@ public class PayProductServiceImpl implements IPayProductService @Autowired private ChannelProductMapMapper channelProductMapMapper; + @Autowired + private ServiceChannelMapper serviceChannelMapper; + @Autowired private PayProductTermMapper payProductTermMapper; @@ -276,21 +281,23 @@ public class PayProductServiceImpl implements IPayProductService @Override public List selectTemplateOptions(String payType) { - if (!PAY_TYPE_AP.equals(payTypeOf(payType))) - { - return Collections.emptyList(); - } - return payProductMapper.selectTemplateOptions(); + return payProductMapper.selectTemplateOptions(payTypeOf(payType)); } @Override public PayProduct selectChannelPrice(String channelId) + { + return selectChannelPrice(channelId, PAY_TYPE_AP); + } + + @Override + public PayProduct selectChannelPrice(String channelId, String payType) { if (isBlank(channelId)) { return null; } - Long root = channelProductRoot(channelId); + Long root = channelProductRoot(channelId, payTypeOf(payType)); if (root == null) { return null; @@ -937,10 +944,16 @@ public class PayProductServiceImpl implements IPayProductService { throw new ServiceException("请先保存渠道,再选择产品"); } + ServiceChannel channel = serviceChannelMapper.selectServiceChannelById(channelId); + if (channel == null || isBlank(channel.getChannelCode())) + { + throw new ServiceException("渠道不存在或渠道编码为空"); + } String type = payTypeOf(payType); - Long storedId = PAY_TYPE_AP.equals(type) ? resolveRoot(productId) : productId; + Long storedId = resolveRoot(productId); ChannelProductMap row = new ChannelProductMap(); row.setChannelId(channelId); + row.setChannelCode(channel.getChannelCode()); row.setProductId(storedId); row.setPriceSetId(priceSetId); row.setPayType(type); @@ -1035,10 +1048,15 @@ public class PayProductServiceImpl implements IPayProductService return saved; } - /** 渠道应付绑定记在映射表,产品编号是不变的根产品。 */ + /** 渠道产品绑定记在映射表,产品编号是不变的根产品。 */ private Long channelProductRoot(String channelId) { - ChannelProductMap link = channelProductMapMapper.selectByChannelAndType(channelId, PAY_TYPE_AP); + return channelProductRoot(channelId, PAY_TYPE_AP); + } + + private Long channelProductRoot(String channelId, String payType) + { + ChannelProductMap link = channelProductMapMapper.selectByChannelAndType(channelId, payType); if (link == null || link.getProductId() == null) { return null; diff --git a/bms-back/bms-system/src/main/resources/mapper/price/ChannelProductMapMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/ChannelProductMapMapper.xml index 67b37d14..72ec12d2 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/ChannelProductMapMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/ChannelProductMapMapper.xml @@ -5,8 +5,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/bms-back/sql/price/srv_channel_product_map.sql b/bms-back/sql/price/srv_channel_product_map.sql index 59bdfb73..37ca22af 100644 --- a/bms-back/sql/price/srv_channel_product_map.sql +++ b/bms-back/sql/price/srv_channel_product_map.sql @@ -4,7 +4,8 @@ SET NAMES utf8mb4; CREATE TABLE IF NOT EXISTS `srv_channel_product_map` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `channel_id` varchar(50) NOT NULL COMMENT '渠道ID,对应 srv_service_channel.id', - `product_id` bigint(20) NOT NULL COMMENT '产品ID,应付时为价卡产品编号', + `channel_code` varchar(64) DEFAULT NULL COMMENT '渠道编码,对应 srv_service_channel.channel_code', + `product_id` bigint(20) NOT NULL COMMENT '产品ID,应付/应收时为价卡产品编号', `price_set_id` bigint(20) DEFAULT NULL COMMENT '应收套餐ID,对应 prc_price_set.price_set_id', `pay_type` varchar(10) NOT NULL COMMENT '收付类型,字典 bms_pay_type:AR应收 AP应付', `create_by` varchar(64) DEFAULT NULL COMMENT '创建者', @@ -14,7 +15,8 @@ CREATE TABLE IF NOT EXISTS `srv_channel_product_map` ( PRIMARY KEY (`id`), UNIQUE KEY `uk_channel_pay_type` (`channel_id`, `pay_type`), KEY `idx_channel_product_map_product` (`product_id`), - KEY `idx_channel_product_map_price_set` (`price_set_id`) + KEY `idx_channel_product_map_price_set` (`price_set_id`), + KEY `idx_channel_product_map_channel_code` (`channel_code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='渠道产品关系映射'; SET @sql = ( @@ -30,6 +32,24 @@ PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt; +SET @sql_channel_code = ( + SELECT IF( + COUNT(*) = 0, + 'ALTER TABLE srv_channel_product_map ADD COLUMN channel_code varchar(64) DEFAULT NULL COMMENT ''渠道编码,对应 srv_service_channel.channel_code'' AFTER channel_id, ADD KEY idx_channel_product_map_channel_code (channel_code)', + 'SELECT 1' + ) + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'srv_channel_product_map' AND COLUMN_NAME = 'channel_code' +); +PREPARE stmt FROM @sql_channel_code; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; + +UPDATE srv_channel_product_map m +INNER JOIN srv_service_channel c ON c.id = m.channel_id +SET m.channel_code = c.channel_code +WHERE m.channel_code IS NULL OR m.channel_code = ''; + SET @copy_sql = ( SELECT IF( COUNT(*) > 0, diff --git a/bms-front/src/api/price/pay.js b/bms-front/src/api/price/pay.js index 145290d7..25277a19 100644 --- a/bms-front/src/api/price/pay.js +++ b/bms-front/src/api/price/pay.js @@ -80,10 +80,11 @@ export function comparePay(leftId, rightId) { }) } -export function getChannelPay(channelId) { +export function getChannelPay(channelId, payType = 'AP') { return request({ url: '/price/pay/channel/' + channelId, - method: 'get' + method: 'get', + params: { payType } }) } diff --git a/bms-front/src/views/data/serviceChannel/index.vue b/bms-front/src/views/data/serviceChannel/index.vue index 30a2de31..13290b60 100644 --- a/bms-front/src/views/data/serviceChannel/index.vue +++ b/bms-front/src/views/data/serviceChannel/index.vue @@ -149,6 +149,14 @@
{{ payTip }}
+ + + + + +
{{ arTip }}
+
+