增加一个渠道绑定

This commit is contained in:
wuweihua
2026-11-10 16:21:07 +08:00
parent e6a9fcf0a2
commit 1a0483c7fe
20 changed files with 940 additions and 147 deletions
@@ -2,6 +2,7 @@ package com.bms.web.controller.price;
import java.util.Date;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -173,6 +174,15 @@ public class LabelPackageController extends BaseController
return success(payload);
}
@PreAuthorize("@ss.hasPermi('price:label:remove')")
@Log(title = "打单套餐删除版本", businessType = BusinessType.DELETE)
@DeleteMapping("/{priceSetId}/versions/{versionNo}")
public AjaxResult deleteVersion(@PathVariable Long priceSetId, @PathVariable Integer versionNo)
{
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
return toAjax(payProductService.deleteLabelVersion(priceSetId, versionNo));
}
@PreAuthorize("@ss.hasPermi('price:label:list')")
@GetMapping("/{priceSetId}/products")
public AjaxResult products(@PathVariable Long priceSetId,
@@ -207,6 +217,55 @@ public class LabelPackageController extends BaseController
return toAjax(payProductService.removeLabelProducts(priceSetId, productIds));
}
@PreAuthorize("@ss.hasPermi('price:label:query')")
@GetMapping("/{priceSetId}/channels")
public AjaxResult listChannels(@PathVariable Long priceSetId)
{
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
return success(payProductService.listLabelChannels(priceSetId));
}
@PreAuthorize("@ss.hasPermi('price:label:edit')")
@Log(title = "打单套餐绑定渠道", businessType = BusinessType.UPDATE)
@PutMapping("/{priceSetId}/channels")
public AjaxResult bindChannels(@PathVariable Long priceSetId, @RequestBody Map<String, Object> body)
{
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
List<String> channelIds = new ArrayList<String>();
Object rawIds = body == null ? null : body.get("channelIds");
if (rawIds instanceof List<?>)
{
for (Object item : (List<?>) rawIds)
{
if (item != null && !String.valueOf(item).trim().isEmpty())
{
channelIds.add(String.valueOf(item).trim());
}
}
}
Long productId = null;
Object rawProductId = body == null ? null : body.get("productId");
if (rawProductId instanceof Number)
{
productId = ((Number) rawProductId).longValue();
}
else if (rawProductId != null && !String.valueOf(rawProductId).trim().isEmpty()
&& !"null".equalsIgnoreCase(String.valueOf(rawProductId).trim()))
{
productId = Long.valueOf(String.valueOf(rawProductId).trim());
}
return success(payProductService.bindLabelChannels(priceSetId, channelIds, productId));
}
@PreAuthorize("@ss.hasPermi('price:label:edit')")
@Log(title = "打单套餐解绑渠道", businessType = BusinessType.DELETE)
@DeleteMapping("/{priceSetId}/channels/{channelId}")
public AjaxResult unbindChannel(@PathVariable Long priceSetId, @PathVariable String channelId)
{
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
return toAjax(payProductService.unbindLabelChannel(priceSetId, channelId));
}
@PreAuthorize("@ss.hasPermi('price:label:list')")
@GetMapping("/customer/list")
public TableDataInfo customerList(PrcCustomerPriceSet customer)
@@ -289,8 +348,8 @@ public class LabelPackageController extends BaseController
{
return null;
}
// 兼容 yyyy-MM-dd / yyyy-MM-dd HH:mm:ss
if (text.length() >= 19)
// 兼容 yyyy-MM-dd / yyyy-MM-dd HH:mm / yyyy-MM-dd HH:mm:ss
if (text.length() >= 16)
{
return com.bms.common.utils.DateUtils.parseDate(text);
}
@@ -1,6 +1,8 @@
package com.bms.web.controller.price;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Locale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -139,6 +141,29 @@ public class PayProductController extends BaseController
return success(payProductService.selectChannelPrice(channelId, payType));
}
/** 批量绑定渠道应收/应付产品 */
@PreAuthorize("@ss.hasAnyPermi('price:pay:edit,data:serviceChannel:edit')")
@Log(title = "渠道批量绑定产品", businessType = BusinessType.UPDATE)
@PutMapping("/channel/batchBind")
public AjaxResult batchBindChannel(@RequestBody Map<String, Object> body)
{
List<String> channelIds = new ArrayList<String>();
Object rawIds = body == null ? null : body.get("channelIds");
if (rawIds instanceof List<?>)
{
for (Object item : (List<?>) rawIds)
{
if (item != null && !String.valueOf(item).trim().isEmpty())
{
channelIds.add(String.valueOf(item).trim());
}
}
}
Long apProductId = toLong(body == null ? null : body.get("apProductId"));
Long arProductId = toLong(body == null ? null : body.get("arProductId"));
return success(payProductService.batchBindChannel(channelIds, apProductId, arProductId));
}
/** 对照两个价格版本 */
@PreAuthorize("@ss.hasPermi('price:pay:query')")
@GetMapping("/compare")
@@ -247,4 +272,22 @@ public class PayProductController extends BaseController
throw new ServiceException("价卡文件不能超过30MB");
}
}
private Long toLong(Object raw)
{
if (raw == null)
{
return null;
}
if (raw instanceof Number)
{
return ((Number) raw).longValue();
}
String text = String.valueOf(raw).trim();
if (text.isEmpty() || "null".equalsIgnoreCase(text))
{
return null;
}
return Long.valueOf(text);
}
}