From cf8dc9ea458b5efc54d6d6d9d8e89db49ca6cf0f Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Tue, 23 Jun 2026 22:02:11 +0800
Subject: [PATCH] feat(system): 添加汇率配置管理功能
---
src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java | 183 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 159 insertions(+), 24 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java b/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java
index bef7b04..76e08b9 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/AdminSystemController.java
@@ -1,16 +1,23 @@
package cc.mrbird.febs.mall.controller;
import cc.mrbird.febs.common.annotation.ControllerEndpoint;
+import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.FebsResponse;
+import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
+import cc.mrbird.febs.common.utils.AppContants;
import cc.mrbird.febs.mall.dto.*;
import cc.mrbird.febs.mall.entity.DataDictionaryCustom;
+import cc.mrbird.febs.mall.entity.MallCountryDelivery;
+import cc.mrbird.febs.mall.entity.MallNewsInfo;
import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper;
import cc.mrbird.febs.mall.service.ICommonService;
+import cc.mrbird.febs.mall.service.IMallCountryDeliveryService;
import cc.mrbird.febs.mall.service.ISystemService;
import cc.mrbird.febs.pay.model.HeaderDto;
import cc.mrbird.febs.pay.service.WxFaPiaoService;
import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
@@ -21,15 +28,21 @@
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.math.BigDecimal;
import java.security.KeyPair;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,7 +51,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin/system")
-public class AdminSystemController {
+public class AdminSystemController extends BaseController {
@Autowired
private ISystemService systemService;
@@ -46,6 +59,7 @@
private final ICommonService commonService;
private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
private final WxFaPiaoService wxFaPiaoService;
+ private final IMallCountryDeliveryService countryDeliveryService;
@PostMapping(value = "/bonusSystemSetting")
public FebsResponse bonusSystemSetting(@RequestBody Map<String, Object> map) {
@@ -57,6 +71,132 @@
public FebsResponse cashOutSetting(CashOutSettingDto cashOutSettingDto) {
commonService.addDataDic(DataDictionaryEnum.CASHOUT_SETTING.getType(), DataDictionaryEnum.CASHOUT_SETTING.getCode(), cashOutSettingDto, "提现设置");
return new FebsResponse().success();
+ }
+
+ @PostMapping(value = "/lwPayConfig")
+ @ControllerEndpoint(operation = "保存LWPAY配置")
+ public FebsResponse lwPayConfig(LwPayConfigDto dto) {
+ if (StrUtil.isBlank(dto.getMemberId())) {
+ return new FebsResponse().fail().message("商户号不能为空");
+ }
+ if (StrUtil.isBlank(dto.getSecretKey())) {
+ return new FebsResponse().fail().message("签名密钥不能为空");
+ }
+ if (StrUtil.isBlank(dto.getNotifyUrl())) {
+ return new FebsResponse().fail().message("回调地址不能为空");
+ }
+ if (StrUtil.isBlank(dto.getReturnUrl())) {
+ return new FebsResponse().fail().message("跳转地址不能为空");
+ }
+ commonService.addDataDic("LWPAY_CONFIG", "MEMBER_ID", dto.getMemberId(), "LWPAY商户号", false);
+ commonService.addDataDic("LWPAY_CONFIG", "SECRET_KEY", dto.getSecretKey(), "LWPAY签名密钥", false);
+ commonService.addDataDic("LWPAY_CONFIG", "NOTIFY_URL", dto.getNotifyUrl(), "LWPAY异步回调地址", false);
+ commonService.addDataDic("LWPAY_CONFIG", "RETURN_URL", dto.getReturnUrl(), "LWPAY支付完成跳转地址", false);
+ return new FebsResponse().success().message("保存成功");
+ }
+
+ @PostMapping(value = "/tokenviewConfig")
+ @ControllerEndpoint(operation = "保存Tokenview配置")
+ public FebsResponse tokenviewConfig(TokenviewConfigDto dto) {
+ if (StrUtil.isBlank(dto.getWebhookSecret())) {
+ return new FebsResponse().fail().message("签名密钥不能为空");
+ }
+ if (StrUtil.isBlank(dto.getTrc20UsdtAddress())) {
+ return new FebsResponse().fail().message("收款地址不能为空");
+ }
+ commonService.addDataDic("TOKENVIEW_CONFIG", "WEBHOOK_SECRET", dto.getWebhookSecret(), "Tokenview Webhook签名密钥", false);
+ commonService.addDataDic("TOKENVIEW_CONFIG", "TRC20_USDT_ADDRESS", dto.getTrc20UsdtAddress(), "TRC20 USDT收款地址", false);
+ commonService.addDataDic("SALES_SERVICE", "TRC_ADDRESS", dto.getTrc20UsdtAddress(), "TRC20 USDT收款地址", false);
+ return new FebsResponse().success().message("保存成功");
+ }
+
+ @PostMapping(value = "/salesService")
+ @ControllerEndpoint(operation = "保存售后服务配置")
+ public FebsResponse salesService(SalesServiceDto dto) {
+ if (StrUtil.isBlank(dto.getWhatsApp())) {
+ return new FebsResponse().fail().message("WhatsApp不能为空");
+ }
+ if (StrUtil.isBlank(dto.getPhone())) {
+ return new FebsResponse().fail().message("联系电话不能为空");
+ }
+ if (StrUtil.isBlank(dto.getEmail())) {
+ return new FebsResponse().fail().message("联系邮箱不能为空");
+ }
+ if (StrUtil.isBlank(dto.getAddress())) {
+ return new FebsResponse().fail().message("联系地址不能为空");
+ }
+ if (StrUtil.isBlank(dto.getWorkingHours())) {
+ return new FebsResponse().fail().message("工作时间不能为空");
+ }
+ commonService.addDataDic("SALES_SERVICE", "WHATSAPP", dto.getWhatsApp(), "WhatsApp号码", false);
+ commonService.addDataDic("SALES_SERVICE", "PHONE", dto.getPhone(), "联系电话", false);
+ commonService.addDataDic("SALES_SERVICE", "EMAIL", dto.getEmail(), "联系邮箱", false);
+ commonService.addDataDic("SALES_SERVICE", "ADDRESS", dto.getAddress(), "联系地址", false);
+ commonService.addDataDic("SALES_SERVICE", "WORKINGHOURS", dto.getWorkingHours(), "工作时间", false);
+ return new FebsResponse().success().message("保存成功");
+ }
+
+ @GetMapping(value = "/moneyChangeList")
+ public FebsResponse moneyChangeList() {
+ List<DataDictionaryCustom> list = dataDictionaryCustomMapper.selectDicByType("MONEY_CHANGE");
+ Map<String, Object> data = new HashMap<>();
+ data.put("rows", list);
+ data.put("total", list.size());
+ return new FebsResponse().success().data(data);
+ }
+
+ @PostMapping(value = "/moneyChangeSave")
+ @ControllerEndpoint(operation = "保存汇率配置")
+ public FebsResponse moneyChangeSave(@RequestParam Map<String, String> params) {
+ String id = params.get("id");
+ String code = params.get("code");
+ String value = params.get("value");
+ String description = params.get("description");
+
+ if (StrUtil.isBlank(code)) return new FebsResponse().fail().message("货币编码不能为空");
+ if (StrUtil.isBlank(value)) return new FebsResponse().fail().message("汇率不能为空");
+ if (StrUtil.isBlank(description)) return new FebsResponse().fail().message("符号不能为空");
+
+ code = code.toUpperCase();
+
+ // 编辑模式:先删旧记录
+ if (StrUtil.isNotBlank(id)) {
+ dataDictionaryCustomMapper.deleteById(Long.valueOf(id));
+ }
+
+ // 检查编码是否已存在(避免重复)
+ DataDictionaryCustom exist = dataDictionaryCustomMapper.selectDicDataByTypeAndCode("MONEY_CHANGE", code);
+ if (exist != null) {
+ return new FebsResponse().fail().message("货币编码 " + code + " 已存在");
+ }
+
+ commonService.addDataDic("MONEY_CHANGE", code, value, description, false);
+ return new FebsResponse().success().message("保存成功");
+ }
+
+ @GetMapping(value = "/moneyChangeDelete/{id}")
+ @ControllerEndpoint(operation = "删除汇率配置")
+ public FebsResponse moneyChangeDelete(@PathVariable Long id) {
+ dataDictionaryCustomMapper.deleteById(id);
+ return new FebsResponse().success().message("删除成功");
+ }
+
+ @GetMapping("countryDeliveryList")
+ public FebsResponse countryDeliveryList(MallCountryDelivery dto, QueryRequest request) {
+ Map<String, Object> data = getDataTable(countryDeliveryService.countryDeliveryList(dto, request));
+ return new FebsResponse().success().data(data);
+ }
+
+ @PostMapping(value = "/countryDeliverySave")
+ @ControllerEndpoint(operation = "保存国家运费配置")
+ public FebsResponse countryDeliverySave(@Validated CountryDeliveryDto dto) {
+ return countryDeliveryService.saveOrUpdate(dto);
+ }
+
+ @GetMapping(value = "/countryDeliveryDelete/{id}")
+ @ControllerEndpoint(operation = "删除国家运费配置")
+ public FebsResponse countryDeliveryDelete(@PathVariable Long id) {
+ return countryDeliveryService.delete(id);
}
@PostMapping(value = "/agentAmountSetSetting")
@@ -136,39 +276,34 @@
DataDictionaryEnum.FP_CALLBACK_URL.getCode(),
faPiaoDto.getCallbackUrl()
);
- KeyPair privateKey = wxFaPiaoService.getPrivateKey();
HeaderDto headerDto = new HeaderDto();
- headerDto.setCallback_url(faPiaoDto.getCallbackUrl());
+ headerDto.setCallback_url("https://api.blnka.cn/api/xcxPay/fapiaoCallBack");
headerDto.setShow_fapiao_cell(false);
String parseObj = JSONUtil.parseObj(headerDto).toString();
String baseUrl = "https://api.mch.weixin.qq.com";
String canonicalUrl = "/v3/new-tax-control-fapiao/merchant/development-config";
- String postStr = wxFaPiaoService.createAuthorization(
- "POST",
- canonicalUrl,
- parseObj,
- privateKey
- );
- // 创建httppost
+ String postStr = null;
try {
- HttpClient httpClient = new HttpClient();
- PostMethod post = new PostMethod(baseUrl+canonicalUrl);
- post.setRequestHeader("Accept", "application/json");
- post.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36");
- post.setRequestHeader("Content-Type", "application/json");
- post.setRequestHeader("Connection", "keep-alive");
- post.setRequestHeader("Authorization", "WECHATPAY2-SHA256-RSA2048 "+postStr);
- RequestEntity entity = new StringRequestEntity(parseObj, "text/html", "utf-8");
- post.setRequestEntity(entity);
- httpClient.executeMethod(post);
- String responseBodyAsString = post.getResponseBodyAsString();
- cn.hutool.json.JSONObject maps = JSONUtil.parseObj(responseBodyAsString);
- System.out.println(maps);
+
+ PrivateKey privateKey = wxFaPiaoService.getPrivateKeyV3();
+ postStr = wxFaPiaoService.createAuthorization(
+ "PATCH",
+ baseUrl+canonicalUrl,
+ parseObj,
+ privateKey
+ );
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
- return new FebsResponse().success().message("操作成功");
+ String token = AppContants.FP_TOKEN_HEADER_TYPE+postStr;
+ System.out.println("WECHATPAY2-SHA256-RSA2048 "+postStr);
+ String s = wxFaPiaoService.sendPatch(baseUrl + canonicalUrl, parseObj, token);
+ log.info("配置开发选项:"+s);
+
+ return new FebsResponse().success().message(s);
}
@PostMapping(value = "/agentDetail")
--
Gitblit v1.9.1