SYS PARAM 常量

This commit is contained in:
2025-12-22 17:06:36 +08:00
parent f1b91cf536
commit 004cf75e22
25 changed files with 438 additions and 360 deletions

View File

@@ -3,6 +3,7 @@ package com.czg.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import com.czg.annotation.Debounce;
import com.czg.constants.ParamCodeCst;
import com.czg.market.service.OrderInfoService;
import com.czg.order.dto.CheckOrderPay;
import com.czg.order.entity.OrderInfo;
@@ -10,7 +11,6 @@ import com.czg.order.service.OrderInfoCustomService;
import com.czg.resp.CzgResult;
import com.czg.service.order.dto.OrderPayParamDTO;
import com.czg.service.order.service.PayService;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil;
import com.czg.utils.ServletUtil;
@@ -160,7 +160,7 @@ public class OrderPayController {
OrderInfo orderInfo = orderInfoCustomService.checkOrderPay(checkOrderPay);
map.put("payAmount", orderInfo.getOrderAmount());
}
String baseUrl = paramsService.getSysParamValue(SysParamCodeEnum.SHOP_ORDER_PAY_BASE_URL.getCode());
String baseUrl = paramsService.getSysParamValue(ParamCodeCst.System.SHOP_ORDER_PAY_BASE_URL);
String buildUrl = URLUtil.buildQuery(map, Charset.defaultCharset());
String fullUrl = baseUrl.concat("?").concat(buildUrl);
return CzgResult.success(fullUrl);

View File

@@ -2,9 +2,9 @@ package com.czg.controller.admin;
import com.aliyun.sts20150401.models.AssumeRoleResponse;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.constants.ParamCodeCst;
import com.czg.resp.CzgResult;
import com.czg.system.dto.VersionDTO;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.czg.system.service.VersionService;
import com.czg.validator.group.InsertGroup;
@@ -96,16 +96,16 @@ public class VersionController {
try {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
.setAccessKeyId(paramsService.getSysParamValue(SysParamCodeEnum.ALI_OSS_ACCESS_KEY.getCode()))
.setAccessKeyId(paramsService.getSysParamValue(ParamCodeCst.AliYun.ALI_OSS_ACCESS_KEY))
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret(paramsService.getSysParamValue(SysParamCodeEnum.ALI_OSS_ACCESS_SECRET.getCode()));
.setAccessKeySecret(paramsService.getSysParamValue(ParamCodeCst.AliYun.ALI_OSS_ACCESS_SECRET));
// Endpoint 请参考 https://api.aliyun.com/product/Sts
config.endpoint = paramsService.getSysParamValue(SysParamCodeEnum.ALI_OSS_ENDPOINT.getCode());
config.endpoint = paramsService.getSysParamValue(ParamCodeCst.AliYun.ALI_OSS_ENDPOINT);
com.aliyun.sts20150401.Client client = new com.aliyun.sts20150401.Client(config);
com.aliyun.sts20150401.models.AssumeRoleRequest assumeRoleRequest = new com.aliyun.sts20150401.models.AssumeRoleRequest();
assumeRoleRequest.setRoleArn(paramsService.getSysParamValue(SysParamCodeEnum.ALI_OSS_ROLE_ARN.getCode()));
assumeRoleRequest.setRoleArn(paramsService.getSysParamValue(ParamCodeCst.AliYun.ALI_OSS_ROLE_ARN));
assumeRoleRequest.setRoleSessionName("test");
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
// 复制代码运行请自行打印 API 的返回值

View File

@@ -1,7 +1,7 @@
package com.czg.account.entity;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.annotation.JSONField;
import com.czg.utils.CzgRandomUtils;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
@@ -199,4 +199,8 @@ public class ShopUser implements Serializable {
// 重新拼接字符串
distributionShops = String.join(",", shopSet);
}
public static String generateCode() {
return CzgRandomUtils.randomNumber(10, true);
}
}

View File

@@ -0,0 +1,324 @@
package com.czg.constants;
/**
* 系统参数编码常量类
*
* @author ww
* @date 2025/12/22
* @since 1.0.0
*/
public interface ParamCodeCst {
/**
* 系统通用配置项
* <p>存放跨业务模块的通用系统配置</p>
*/
class System {
/**
* 超掌柜支付回调地址
* <p>支付宝/微信支付完成后,支付平台回调我方系统的地址</p>
*/
public static String PAY_CZG_NOTIFY_URL = "pay_czg_notify_url";
/**
* 排队到号通知
*/
public static String WX_MINI_MSG_CALL_CURRENT = "wx_mini_msg_call_current";
/**
* 排队即将到号提醒
*/
public static String WX_MINI_MSG_CALL_NEAR = "wx_mini_msg_call_near";
/**
* 排队提醒
*/
public static String WX_MINI_MSG_CALL_PASS = "wx_mini_msg_call_pass";
/**
* 小程序会员页面地址
* <p>微信小程序中会员中心页面的跳转地址 分享时 使用</p>
*/
public static String WX_MINI_VIP_URL = "wx_mini_vip_url";
/**
* 桌码生成路径
* <p>餐厅桌码图片生成的基础路径/域名</p>
*/
public static String TABLE_CODE_URL = "table_code_url";
/**
* 短信费用
* <p>单条短信发送的成本费用(单位:元)</p>
*/
public static String SMS_FEE = "sms_fee";
/**
* 店铺订单支付BaseUrl
* <p>店铺订单支付页面的基础域名</p>
*/
public static String SHOP_ORDER_PAY_BASE_URL = "shop_order_pay_base_url";
/**
* 平台名称
* <p>系统对外展示的平台名称(如:超掌柜)</p>
*/
public static String PLATE_NAME = "plate_name";
/**
* 超掌柜退款回调地址
* <p>支付平台处理退款后,回调我方系统的地址</p>
*/
public static String PAY_CZG_REFUND_NOTIFY_URL = "pay_czg_refund_notify_url";
/**
* 超掌柜支付域名
* <p>超掌柜支付相关接口的根域名</p>
*/
public static String PAY_CZG_DOMAIN = "pay_czg_domain";
/**
* 叫号页面地址
* <p>餐厅叫号系统的前端页面地址</p>
*/
public static String CALL_PAGE_URL = "call_page_url";
/**
* 微信原生回调地址
* <p>微信原生支付接口的回调地址(区别于超掌柜封装的回调)</p>
*/
public static String NATIVE_NOTIFY_URL = "native_notify_url";
/**
* 公众号关注位置
* <p>公众号关注入口的展示位置可选值mine-我的页面、order-订单页面、eat-就餐页面</p>
*/
public static String FOLLOW_INDEX = "follow_index";
}
/**
* 微信相关配置项
* <p>包含公众号、小程序、微信支付三大模块的配置</p>
*/
interface Wechat {
/**
* 微信公众号(银收客)配置项
* <p>银收客公众号相关配置,用于发送订阅消息等场景</p>
*/
class Ac {
/**
* 商家每日可创建次数
* <p>商家通过公众号创建订单/活动等的每日上限次数</p>
*/
public static String AC_DAY_COUNT = "ac_day_count";
/**
* 微信公众号AppId银收客主号
* <p>银收客主体公众号的AppId用于发送商品/耗材库存等订阅消息</p>
* wx_account_app_id
*/
public static String SHOP_WX_AC_APP_ID = "shop_wx_ac_app_id";
/**
* 微信公众号Secret银收客主号
* <p>银收客主体公众号的Secret用于获取access_token</p>
*/
public static String SHOP_WX_AC_SECRETE = "shop_wx_ac_secrete";
/**
* 用户订阅公众号AppId银收客CZg
* <p>用户侧订阅的银收客CZg公众号AppId</p>
* wechat_ac_appid
*/
public static String USER_WX_AC_APP_ID = "user_wx_ac_app_id";//
/**
* 用户订阅公众号Secret银收客CZg
* <p>用户侧订阅的银收客CZg公众号Secret</p>
*/
public static String USER_WX_AC_SECRETE = "user_wx_ac_secrete";//
}
/**
* 微信小程序配置项
* <p>包含商家端和用户端小程序的密钥、AppId等配置</p>
*/
class Mini {
/**
* 商家端小程序AppId
* <p>商家管理端微信小程序的AppId</p>
*/
public static String SHOP_WX_APP_ID = "shop_wx_app_id";
/**
* 商家端小程序Secret
* <p>商家管理端微信小程序的Secret</p>
*/
public static String SHOP_WX_SECRETE = "shop_wx_secrete";
/**
* 用户微信小程序AppId
* <p>普通用户使用的微信小程序AppId</p>
*/
public static String USER_WX_APP_ID = "user_wx_app_id";
/**
* 用户微信小程序Secret
* <p>普通用户使用的微信小程序Secret</p>
*/
public static String USER_WX_SECRETE = "user_wx_secrete";
}
/**
* 微信支付配置项
* <p>微信支付V3接口相关的证书、密钥、商户号等配置</p>
*/
class Pay {
/**
* 微信API支付证书PEM
* <p>微信支付V3接口所需的api_client_cert.pem证书内容</p>
*/
public static String WX_API_CLIENT_CERT = "wx_api_client_cert";
/**
* 微信API支付证书密钥PEM
* <p>微信支付V3接口所需的api_client_key.pem私钥内容</p>
*/
public static String WX_API_CLIENT_KEY = "wx_api_client_key";
/**
* 微信支付商户号
* <p>微信支付平台分配的商户编号</p>
*/
public static String WX_MCH_ID = "wx_mch_id";
/**
* 微信公钥
* <p>微信支付平台公钥,用于验签回调通知</p>
*/
public static String WX_PUB_KEY = "wx_pub_key";
/**
* 微信公钥ID
* <p>微信支付平台公钥对应的唯一标识用于V3接口验签</p>
*/
public static String WX_PUB_KEY_ID = "wx_pub_key_id";
/**
* 微信V3密钥
* <p>微信支付V3接口的APIv3密钥用于加密/解密回调数据</p>
*/
public static String WX_V3_KEY = "wx_v3_key";
}
}
/**
* 支付宝相关配置项
* <p>包含网页端、小程序端的支付宝配置</p>
*/
interface Alipay {
/**
* 支付宝网页端配置项
* <p>PC/网页端支付宝支付相关配置</p>
*/
class Web {
/**
* 支付宝网页端AppId
* <p>支付宝开放平台分配的网页应用AppId</p>
*/
public static String ALI_ACCOUNT_APP_ID = "ali_account_app_id";
/**
* 支付宝商户私钥
* <p>商户侧生成的RSA私钥用于签名请求</p>
*/
public static String ALI_ACCOUNT_PRIVATE_KEY = "ali_account_private_key";
/**
* 支付宝公钥
* <p>支付宝开放平台提供的公钥,用于验签回调通知</p>
*/
public static String ALI_ACCOUNT_PUBLIC_KEY = "ali_account_public_key";
/**
* 阿里AES加密串
* <p>支付宝接口数据加密所需的AES密钥</p>
*/
public static String ALI_ENCRYPT_KEY = "ali_encrypt_key";
/**
* 支付宝网关
* <p>支付宝开放平台接口网关地址(沙箱/生产环境)</p>
*/
public static String ALI_GATEWAY = "ali_gateway";
}
/**
* 支付宝小程序配置项
* <p>支付宝小程序支付相关配置</p>
*/
class Mini {
/**
* 支付宝小程序AppId
* <p>支付宝开放平台分配的小程序AppId</p>
*/
public static String ALI_MINI_APP_ID = "ali_mini_app_id";
/**
* 支付宝小程序支付私钥
* <p>小程序支付专用的商户RSA私钥</p>
*/
public static String ALI_MINI_PRIVATE_KEY = "ali_mini_private_key";
/**
* 支付宝小程序公钥
* <p>支付宝开放平台提供的小程序专用公钥</p>
*/
public static String ALI_MINI_PUBLIC_KEY = "ali_mini_public_key";
}
}
/**
* 阿里云相关配置项
* <p>包含OSS对象存储、短信服务等阿里云产品配置</p>
*/
class AliYun {
/**
* 阿里云OSS AccessSecret
* <p>阿里云OSS服务的访问密钥Secret</p>
*/
public static String ALI_OSS_ACCESS_SECRET = "ali_oss_access_secret";
/**
* 阿里云短信模板码
* <p>阿里云短信服务审核通过的模板编号</p>
*/
public static String ALI_SMS_TEMPLATE_CODE = "ali_sms_template_code";
/**
* 阿里云短信Secret
* <p>阿里云短信服务的访问密钥Secret</p>
*/
public static String ALI_SMS_SECRET = "ali_sms_secret";
/**
* 阿里云短信Key
* <p>阿里云短信服务的访问密钥Key</p>
*/
public static String ALI_SMS_KEY = "ali_sms_key";
/**
* 阿里云OSS角色ARN
* <p>阿里云RAM角色的资源描述符用于临时授权访问OSS</p>
*/
public static String ALI_OSS_ROLE_ARN = "ali_oss_role_arn";
/**
* 阿里云OSS Endpoint
* <p>阿里云OSS服务的地域节点地址</p>
*/
public static String ALI_OSS_ENDPOINT = "ali_oss_endpoint";
/**
* 阿里云OSS AccessKey
* <p>阿里云OSS服务的访问密钥Key</p>
*/
public static String ALI_OSS_ACCESS_KEY = "ali_oss_access_key";
}
}

View File

@@ -1,6 +1,7 @@
package com.czg.constants;
import com.czg.account.entity.ShopInfo;
import com.czg.utils.SerializableFunction;
/**
* 店铺 开关枚举

View File

@@ -1,73 +0,0 @@
package com.czg.system.enums;
import lombok.Getter;
/**
* @author ww
*/
@Getter
public enum SysParamCodeEnum {
// 微信公众号(用户订阅相关)
WECHAT_AC_SECRETE("wechat_ac_secrete", "用户订阅公众号secret"),
WECHAT_AC_APPID("wechat_ac_appid", "用户订阅公众号appid"),
// 公众号关注位置
FOLLOW_INDEX("follow_index", "公众号关注位置 mine-我的 order-订单 eat-就餐"),
// 商家配置
AC_DAY_COUNT("ac_day_count", "商家每日可创建次数"),
// 短信相关
SMS_FEE("sms_fee", "短信费用"),
ALI_SMS_KEY("ali_sms_key", "阿里云短信key"),
ALI_SMS_TEMPLATE_CODE("ali_sms_template_code", "阿里云短信模板"),
ALI_SMS_SECRET("ali_sms_secret", "阿里云短信secret"),
// 微信相关(公众号/小程序)
WX_ACCOUNT_APP_ID("wx_account_app_id", "微信公众号appId"),
WX_ACCOUNT_SECRETE("wx_account_secrete", "微信公众号密钥"),
WX_MINI_APP_ID("wx_mini_app_id", "微信小程序appId"),
WX_MINI_SECRETE("wx_mini_secrete", "微信小程序密钥"),
// 页面地址相关
WX_MINI_VIP_URL("wx_mini_vip_url", "小程序会员页面地址"),
TABLE_CODE_URL("table_code_url", "桌码生成路径"),
CALL_PAGE_URL("call_page_url", "叫号页面地址"),
SHOP_ORDER_PAY_BASE_URL("shop_order_pay_base_url", "店铺订单支付BaseUrl"),
// 支付相关(超掌柜)
PAY_CZG_DOMAIN("pay_czg_domain", "超掌柜支付域名"),
PAY_CZG_NOTIFY_URL("pay_czg_notify_url", "超掌柜支付回调地址"),
PAY_CZG_REFUND_NOTIFY_URL("pay_czg_refund_notify_url", "超掌柜退款回调地址"),
// 阿里云OSS相关
ALI_OSS_ACCESS_KEY("ali_oss_access_key", "阿里云oss_ACCESS_KEY"),
ALI_OSS_ACCESS_SECRET("ali_oss_access_secret", "阿里云oss_secret"),
ALI_OSS_ENDPOINT("ali_oss_endpoint", "阿里云endpoint"),
ALI_OSS_ROLE_ARN("ali_oss_role_arn", "阿里云roleArn"),
// 支付宝相关(小程序/网页)
ALI_MINI_PUBLIC_KEY("ali_mini_public_key", "支付宝小程序公钥"),
ALI_MINI_PRIVATE_KEY("ali_mini_private_key", "支付宝小程序支付私钥"),
ALI_MINI_APP_ID("ali_mini_app_id", "支付宝小程序id"),
ALI_GATEWAY("ali_gateway", "支付宝网关"),
ALI_ENCRYPT_KEY("ali_encrypt_key", "阿里AES加密串"),
ALI_ACCOUNT_PUBLIC_KEY("ali_account_public_key", "支付宝网页公钥"),
ALI_ACCOUNT_PRIVATE_KEY("ali_account_private_key", "支付宝网页私钥"),
ALI_ACCOUNT_APP_ID("ali_account_app_id", "支付宝网页appid"),
// 平台信息
PLATE_NAME("plate_name", "平台名称")
;
private final String code;
private final String msg;
SysParamCodeEnum(String code, String msg) {
this.code = code;
this.msg = msg;
}
}

View File

@@ -15,6 +15,14 @@ import java.util.List;
*/
public interface SysParamsService extends IService<SysParams> {
/**
* 根据参数类型获取参数
*
* @param type 参数类型
* @return 参数列表
*/
CzgResult<List<SysParamsDTO>> getParamsByType(Integer type);
/**
* 新增参数
*
@@ -41,7 +49,7 @@ public interface SysParamsService extends IService<SysParams> {
/**
* 根据参数编码获取参数
* {@link com.czg.system.enums.SysParamCodeEnum}
* {@link com.czg.constants.ParamCodeCst}
*
* @param code 参数编码
* @return 参数
@@ -49,21 +57,9 @@ public interface SysParamsService extends IService<SysParams> {
CzgResult<SysParamsDTO> getParamsByCode(String code);
/**
* {@link com.czg.system.enums.SysParamCodeEnum}
*/
SysParams getSysParam(String code);
/**
* {@link com.czg.system.enums.SysParamCodeEnum}
* 根据参数编码获取参数值
* {@link com.czg.constants.ParamCodeCst}
*/
String getSysParamValue(String code);
/**
* 根据参数类型获取参数
*
* @param type 参数类型
* @return 参数列表
*/
CzgResult<List<SysParamsDTO>> getParamsByType(Integer type);
}

View File

@@ -1,4 +1,4 @@
package com.czg.constants;
package com.czg.utils;
import java.io.Serial;
import java.io.Serializable;

View File

@@ -2,7 +2,6 @@ package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.shopuser.*;
import com.czg.account.entity.ShopUser;
@@ -16,15 +15,13 @@ import com.czg.market.entity.MemberLevelConfig;
import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.entity.SmsPushEventUser;
import com.czg.market.service.MemberLevelConfigService;
import com.czg.market.service.MkShopConsumeDiscountRecordService;
import com.czg.market.service.MkShopCouponRecordService;
import com.czg.market.service.OrderInfoService;
import com.czg.market.service.TbMemberConfigService;
import com.czg.market.vo.MemberConfigVO;
import com.czg.order.entity.OrderInfo;
import com.czg.market.service.OrderInfoService;
import com.czg.sa.StpKit;
import com.czg.service.account.mapper.ShopUserMapper;
import com.czg.system.entity.SysParams;
import com.czg.system.service.SysParamsService;
import com.czg.utils.PageUtil;
import com.github.pagehelper.PageHelper;
@@ -34,7 +31,6 @@ import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -167,7 +163,7 @@ public class AShopUserServiceImpl implements AShopUserService {
}
ShopUser shopUser = BeanUtil.copyProperties(shopUserAddDTO, ShopUser.class);
shopUser.setCode(generateCode(shopId));
shopUser.setCode(ShopUser.generateCode());
shopUser.setSourceShopId(shopId);
shopUser.setUserId(userInfo.getId());
shopUser.setMainShopId(shopInfoService.getMainIdByShopId(shopId));
@@ -216,7 +212,7 @@ public class AShopUserServiceImpl implements AShopUserService {
.limit(1).orderBy(MemberLevelConfig::getExperienceValue, true));
if (config != null) {
shopUserDTO.setNextExperience(config.getExperienceValue() - (shopUser.getExperience() == null ? 0 : shopUser.getExperience()));
shopUserDTO.setNextExperience(shopUserDTO.getNextExperience() < 0 ? 0: shopUserDTO.getNextExperience());
shopUserDTO.setNextExperience(shopUserDTO.getNextExperience() < 0 ? 0 : shopUserDTO.getNextExperience());
shopUserDTO.setNextMemberLevelName(config.getName());
}
return shopUserDTO;
@@ -227,43 +223,4 @@ public class AShopUserServiceImpl implements AShopUserService {
return shopUserService.updateMoney(shopUserEditDTO);
}
public String generateCode(long shopId) {
String code = "shop_user_code_val%d".formatted(shopId);
SysParams sysParam = sysParamsService.getOne(new QueryWrapper().eq(SysParams::getParamCode, code));
if (sysParam == null) {
SysParams sysParams = new SysParams()
.setParamValue("1")
.setParamType(1)
.setCreateTime(DateUtil.date().toLocalDateTime())
.setParamCode(code);
sysParamsService.save(sysParams);
return generateRandomCode(1);
}
long parseLong = Long.parseLong(sysParam.getParamValue());
long l = ++parseLong;
sysParam.setParamValue(String.valueOf(l));
sysParamsService.updateById(sysParam);
return generateRandomCode(l);
}
// 使用Hutool生成十六进制代码并随机填充字母
private String generateRandomCode(long value) {
// 生成十六进制代码确保为10位
String hexCode = String.format("%010X", value);
// 计算需要补充的字母数量
int missingLength = 10 - hexCode.length();
StringBuilder codeBuilder = new StringBuilder(hexCode);
for (int i = 0; i < missingLength; i++) {
// 生成随机字母
char randomChar = RandomUtil.randomChar("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
codeBuilder.append(randomChar);
}
return codeBuilder.toString();
}
}

View File

@@ -11,6 +11,7 @@ import com.czg.account.service.*;
import com.czg.account.vo.CallQueueInfoVO;
import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException;
import com.czg.resp.CzgResult;
import com.czg.service.account.mapper.CallQueueMapper;
@@ -264,7 +265,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// 生成二维码图片,输出到字节数组输出流
CzgResult<SysParamsDTO> paramsByCode = sysParamsService.getParamsByCode("call_page_url");
CzgResult<SysParamsDTO> paramsByCode = sysParamsService.getParamsByCode(ParamCodeCst.System.CALL_PAGE_URL);
if (paramsByCode.getData() == null) {
throw new CzgException("页面路径未配置");
}

View File

@@ -13,8 +13,9 @@ import com.czg.account.enums.ShopTypeEnum;
import com.czg.account.service.*;
import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.constants.SystemConstants;
import com.czg.constants.ParamCodeCst;
import com.czg.constants.ShopSwitchTypeEnum;
import com.czg.constants.SystemConstants;
import com.czg.exception.CzgException;
import com.czg.resp.CzgResult;
import com.czg.sa.MyStpLogic;
@@ -38,7 +39,6 @@ import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
@@ -341,7 +341,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
ShopDetailDTO shopDetailDTO = BeanUtil.copyProperties(shopInfo, ShopDetailDTO.class);
SysUser sysUser = sysUserService.getById(shopInfo.getId());
shopDetailDTO.setAccount(sysUser.getAccount());
CzgResult<SysParamsDTO> shopOrderPayBaseUrl = sysParamsService.getParamsByCode("shop_order_pay_base_url");
CzgResult<SysParamsDTO> shopOrderPayBaseUrl = sysParamsService.getParamsByCode(ParamCodeCst.System.SHOP_ORDER_PAY_BASE_URL);
shopDetailDTO.setPaymentQrcode(shopOrderPayBaseUrl.getData().getParamValue() + "?shopId=" + id);
BeanUtil.copyProperties(shopConfig, shopDetailDTO);
return shopDetailDTO;

View File

@@ -18,11 +18,11 @@ import com.czg.account.service.ShopTableAreaService;
import com.czg.account.service.ShopTableCodeService;
import com.czg.account.service.ShopTableService;
import com.czg.account.vo.ShopTableVO;
import com.czg.constants.ParamCodeCst;
import com.czg.enums.ShopTableStatusEnum;
import com.czg.exception.CzgException;
import com.czg.sa.StpKit;
import com.czg.service.account.mapper.ShopTableMapper;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.czg.utils.PageUtil;
import com.github.pagehelper.PageHelper;
@@ -195,7 +195,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
File qrFile = new File(dir, tableCode + ".png");
// 生成二维码图片
QrCodeUtil.generate(sysParamsService.getSysParamValue(SysParamCodeEnum.TABLE_CODE_URL.getCode()) + tableCode, 300, 300, qrFile);
QrCodeUtil.generate(sysParamsService.getSysParamValue(ParamCodeCst.System.TABLE_CODE_URL) + tableCode, 300, 300, qrFile);
}
// 先保存数据库记录确保生成ZIP前无异常

View File

@@ -2,7 +2,6 @@ package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.czg.account.dto.shopuser.ShopUserAddDTO;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
import com.czg.account.entity.ShopUser;
@@ -15,18 +14,14 @@ import com.czg.account.service.UserInfoService;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.CzgException;
import com.czg.market.entity.MemberLevelConfig;
import com.czg.market.entity.MkPointsUser;
import com.czg.market.entity.SmsPushEventUser;
import com.czg.market.service.MemberLevelConfigService;
import com.czg.market.service.MkPointsUserService;
import com.czg.market.service.OrderInfoService;
import com.czg.market.service.TbMemberConfigService;
import com.czg.market.vo.InviteUserVO;
import com.czg.market.vo.MemberConfigVO;
import com.czg.order.entity.OrderInfo;
import com.czg.service.account.mapper.ShopUserMapper;
import com.czg.system.entity.SysParams;
import com.czg.system.service.SysParamsService;
import com.czg.utils.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -39,10 +34,10 @@ import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.transaction.annotation.Transactional;
import java.awt.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
@@ -66,9 +61,6 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
private MemberLevelConfigService memberLevelConfigService;
@DubboReference
private TbMemberConfigService memberConfigService;
@DubboReference
private SysParamsService sysParamsService;
private ShopUser getUserInfo(Long shopUserId) {
ShopUser shopUser = queryChain().eq(ShopUser::getId, shopUserId).one();
if (shopUser == null) {
@@ -114,7 +106,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
if (configVO.getIsOpen().equals(1L)) {
shopUser.setIsMemberPrice(configVO.getIsMemberPrice());
shopUser.setDiscount(memberLevelConfig.getDiscount());
}else {
} else {
shopUser.setIsMemberPrice(0);
shopUser.setDiscount(100);
}
@@ -241,57 +233,16 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
BeanUtil.copyProperties(shopUserAddDTO, shopUser, "accountPoints", "amount");
BeanUtil.copyProperties(shopUserAddDTO, userInfo);
userInfoService.updateById(userInfo);
if (cn.hutool.core.util.StrUtil.isBlank(shopUser.getCode())) {
shopUser.setCode(generateCode(shopId));
if (StrUtil.isBlank(shopUser.getCode())) {
shopUser.setCode(ShopUser.generateCode());
}
if (cn.hutool.core.util.StrUtil.isBlank(shopUser.getBirthDay())) {
if (StrUtil.isBlank(shopUser.getBirthDay())) {
shopUser.setBirthDay(null);
}
shopUser.setNickName(userInfo.getNickName());
shopUser.setJoinTime(shopUser.getJoinTime() == null ? DateUtil.date().toLocalDateTime() : shopUser.getJoinTime());
if (shopUser.getJoinTime() == null) {
shopUser.setJoinTime(LocalDateTime.now());
}
return saveOrUpdate(shopUser);
}
public String generateCode(long shopId) {
String code = "shop_user_code_val%d".formatted(shopId);
SysParams sysParam = sysParamsService.getOne(new QueryWrapper().eq(SysParams::getParamCode, code));
if (sysParam == null) {
SysParams sysParams = new SysParams()
.setParamValue("1")
.setParamType(1)
.setCreateTime(DateUtil.date().toLocalDateTime())
.setParamCode(code);
sysParamsService.save(sysParams);
return generateRandomCode(1);
}
long parseLong = Long.parseLong(sysParam.getParamValue());
long l = ++parseLong;
sysParam.setParamValue(String.valueOf(l));
sysParamsService.updateById(sysParam);
return generateRandomCode(l);
}
// 使用Hutool生成十六进制代码并随机填充字母
private String generateRandomCode(long value) {
// 生成十六进制代码确保为10位
String hexCode = String.format("%010X", value);
// 计算需要补充的字母数量
int missingLength = 10 - hexCode.length();
StringBuilder codeBuilder = new StringBuilder(hexCode);
for (int i = 0; i < missingLength; i++) {
// 生成随机字母
char randomChar = RandomUtil.randomChar("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
codeBuilder.append(randomChar);
}
return codeBuilder.toString();
}
}

View File

@@ -10,6 +10,7 @@ import com.czg.account.dto.auth.WechatRawDataDTO;
import com.czg.account.entity.UserInfo;
import com.czg.account.service.UserAuthorizationService;
import com.czg.account.service.UserInfoService;
import com.czg.constants.ParamCodeCst;
import com.czg.constants.SystemConstants;
import com.czg.enums.UserAuthSourceEnum;
import com.czg.exception.CzgException;
@@ -17,7 +18,6 @@ import com.czg.sa.MyStpLogic;
import com.czg.sa.StpKit;
import com.czg.service.account.util.AlipayUtil;
import com.czg.service.account.util.WechatAuthUtil;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
@@ -120,7 +120,7 @@ public class UserAuthorizationServiceImpl implements UserAuthorizationService {
userInfoService.initAc(userInfo);
// StpKit.USER.login(userInfo.getId());
StpKit.USER.login(userInfo.getId(), openId, null, null, null, MyStpLogic.LoginType.USER, false, "userMini", false);
String followIndex = paramsService.getSysParamValue(SysParamCodeEnum.FOLLOW_INDEX.getCode());
String followIndex = paramsService.getSysParamValue(ParamCodeCst.System.FOLLOW_INDEX);
return new LoginTokenDTO(StpKit.USER.getTokenValue(), followIndex, userInfo);
}
}

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.czg.constants.ParamCodeCst;
import com.czg.service.RedisService;
import com.czg.system.service.SysParamsService;
import jakarta.annotation.Resource;
@@ -89,8 +90,8 @@ public class AcAccountUtil {
if (StrUtil.isNotEmpty(accessToken)) {
return accessToken;
}
String acAppId = paramsService.getSysParamValue("wechat_ac_appid");
String acSecrete = paramsService.getSysParamValue("wechat_ac_secrete");
String acAppId = paramsService.getSysParamValue(ParamCodeCst.Wechat.Ac.USER_WX_AC_APP_ID);
String acSecrete = paramsService.getSysParamValue(ParamCodeCst.Wechat.Ac.USER_WX_AC_SECRETE);
String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", acAppId, acSecrete));
JSONObject respInfo = JSONObject.parseObject(resp);
if (!respInfo.containsKey("access_token")) {

View File

@@ -10,8 +10,7 @@ import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipayEncrypt;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import com.czg.resp.CzgResult;
import com.czg.system.dto.SysParamsDTO;
import com.czg.constants.ParamCodeCst;
import com.czg.system.service.SysParamsService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
@@ -38,20 +37,13 @@ public class AlipayUtil {
*/
@SneakyThrows
public AlipayClient createClient(boolean isAccount) {
CzgResult<SysParamsDTO> aliGateway = sysParamsService.getParamsByCode("ali_gateway");
CzgResult<SysParamsDTO> aliMiniAppId = sysParamsService.getParamsByCode("ali_mini_app_id");
CzgResult<SysParamsDTO> aliMiniPrivateKey = sysParamsService.getParamsByCode("ali_mini_private_key");
CzgResult<SysParamsDTO> aliMiniPublicKey = sysParamsService.getParamsByCode("ali_mini_public_key");
CzgResult<SysParamsDTO> aliAccountAppId = sysParamsService.getParamsByCode("ali_account_app_id");
CzgResult<SysParamsDTO> aliAccountPrivateKey = sysParamsService.getParamsByCode("ali_account_private_key");
CzgResult<SysParamsDTO> aliAccountPublicKey = sysParamsService.getParamsByCode("ali_account_public_key");
String serverUrl = aliGateway.getData().getParamValue();
String appId = aliMiniAppId.getData().getParamValue();
String privateKey = aliMiniPrivateKey.getData().getParamValue();
String alipayPublicKey = aliMiniPublicKey.getData().getParamValue();
String accountAppId = aliAccountAppId.getData().getParamValue();
String accountPrivateKey = aliAccountPrivateKey.getData().getParamValue();
String accountPublicKey = aliAccountPublicKey.getData().getParamValue();
String serverUrl = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Web.ALI_GATEWAY);
String appId = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Mini.ALI_MINI_APP_ID);
String privateKey = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Mini.ALI_MINI_PRIVATE_KEY);
String alipayPublicKey = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Mini.ALI_MINI_PUBLIC_KEY);
String accountAppId = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Web.ALI_ACCOUNT_APP_ID);
String accountPrivateKey = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Web.ALI_ACCOUNT_PRIVATE_KEY);
String accountPublicKey = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Web.ALI_ACCOUNT_PUBLIC_KEY);
AlipayConfig alipayConfig = new AlipayConfig();
//设置网关地址
alipayConfig.setServerUrl(serverUrl);
@@ -100,8 +92,7 @@ public class AlipayUtil {
throw new RuntimeException("加密数据不能为空");
}
try {
CzgResult<SysParamsDTO> aliEncryptKey = sysParamsService.getParamsByCode("ali_encrypt_key");
String encryptKey = aliEncryptKey.getData().getParamValue();
String encryptKey = sysParamsService.getSysParamValue(ParamCodeCst.Alipay.Web.ALI_ENCRYPT_KEY);
log.info("解密前的数据,返回结果:{}", encryptedData);
String resp = AlipayEncrypt.decryptContent(encryptedData, "AES", encryptKey, "UTF-8");

View File

@@ -7,10 +7,8 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.czg.config.RedisCst;
import com.czg.resp.CzgResult;
import com.czg.constants.ParamCodeCst;
import com.czg.service.RedisService;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.google.gson.JsonObject;
import jakarta.annotation.Resource;
@@ -58,10 +56,8 @@ public class WechatAuthUtil {
}
public String getAccountOpenId(String code) {
CzgResult<SysParamsDTO> wxAccountAppId = sysParamsService.getParamsByCode("wx_account_app_id");
CzgResult<SysParamsDTO> wxAccountSecrete = sysParamsService.getParamsByCode("wx_account_secrete");
String accountAppId = wxAccountAppId.getData().getParamValue();
String accountSecrete = wxAccountSecrete.getData().getParamValue();
String accountAppId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_APP_ID);
String accountSecrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_SECRETE);
String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?";
Map<String, Object> requestUrlParam = new HashMap<>();
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
@@ -82,10 +78,8 @@ public class WechatAuthUtil {
//获取小程序token
private String getAccessToken() {
CzgResult<SysParamsDTO> wxMiniAppId = sysParamsService.getParamsByCode("wx_mini_app_id");
CzgResult<SysParamsDTO> wxMiniSecrete = sysParamsService.getParamsByCode("wx_mini_secrete");
String appId = wxMiniAppId.getData().getParamValue();
String secrete = wxMiniSecrete.getData().getParamValue();
String appId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
String secrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE);
String url = String.format("%s?grant_type=client_credential&appid=%s&secret=%s", TOKEN_URL, appId, secrete);
String response = HttpUtil.get(url);
com.alibaba.fastjson.JSONObject jsonResponse = com.alibaba.fastjson.JSONObject.parseObject(response);
@@ -109,7 +103,7 @@ public class WechatAuthUtil {
private InputStream fetchQrCode(Map<String, Object> params) {
JsonObject jsonObject = new JsonObject();
//路径
jsonObject.addProperty("path", sysParamsService.getSysParamValue(SysParamCodeEnum.WX_MINI_VIP_URL.getCode()) + "?shopId=" + params.get("shopId"));
jsonObject.addProperty("path", sysParamsService.getSysParamValue(ParamCodeCst.System.WX_MINI_VIP_URL) + "?shopId=" + params.get("shopId"));
//是否需要透明底色,为 true 时,生成透明底色的小程序码
jsonObject.addProperty("is_hyaline", true);
//正式版为 release体验版为 trial开发版为 develop
@@ -126,10 +120,8 @@ public class WechatAuthUtil {
public JSONObject getSession(String code) {
CzgResult<SysParamsDTO> wxMiniSecrete = sysParamsService.getParamsByCode("wx_mini_secrete");
CzgResult<SysParamsDTO> wxMiniAppId = sysParamsService.getParamsByCode("wx_mini_app_id");
String appId = wxMiniAppId.getData().getParamValue();
String secrete = wxMiniSecrete.getData().getParamValue();
String appId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
String secrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE);
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
Map<String, Object> requestUrlParam = new HashMap<>();
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN

View File

@@ -10,10 +10,10 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.czg.config.RedisCst;
import com.czg.constants.ParamCodeCst;
import com.czg.resp.CzgResult;
import com.czg.service.RedisService;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.google.gson.JsonObject;
import jakarta.annotation.Resource;
@@ -84,8 +84,8 @@ public class WechatMiniMsgUtil {
}
public void sendCurrentOrNearCallMsg(String shopName, String state, String callNum, String currentNum, String note, String openId, boolean isNear) {
CzgResult<SysParamsDTO> callNear = sysParamsService.getParamsByCode("wx_mini_msg_call_near");
CzgResult<SysParamsDTO> callCurrent = sysParamsService.getParamsByCode("wx_mini_msg_call_current");
CzgResult<SysParamsDTO> callNear = sysParamsService.getParamsByCode(ParamCodeCst.System.WX_MINI_MSG_CALL_NEAR);
CzgResult<SysParamsDTO> callCurrent = sysParamsService.getParamsByCode(ParamCodeCst.System.WX_MINI_MSG_CALL_CURRENT);
Map<String, Object> data = new HashMap<String, Object>() {{
put("thing1", new HashMap<String, Object>() {{
@@ -112,7 +112,7 @@ public class WechatMiniMsgUtil {
}
public void sendPassCallMsg(String shopName, String state, String callNum, String currentNum, String note, String openId) {
CzgResult<SysParamsDTO> callPass = sysParamsService.getParamsByCode("wx_mini_msg_call_pass");
CzgResult<SysParamsDTO> callPass = sysParamsService.getParamsByCode(ParamCodeCst.System.WX_MINI_MSG_CALL_PASS);
Map<String, Object> data = new HashMap<String, Object>() {{
put("thing1", new HashMap<String, Object>() {{
@@ -139,10 +139,8 @@ public class WechatMiniMsgUtil {
}
public String getAccountOpenId(String code) {
CzgResult<SysParamsDTO> wxAccountAppId = sysParamsService.getParamsByCode("wx_account_app_id");
CzgResult<SysParamsDTO> wxAccountSecrete = sysParamsService.getParamsByCode("wx_account_secrete");
String accountAppId = wxAccountAppId.getData().getParamValue();
String accountSecrete = wxAccountSecrete.getData().getParamValue();
String accountAppId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_APP_ID);
String accountSecrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_SECRETE);
String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?";
Map<String, Object> requestUrlParam = new HashMap<>();
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
@@ -167,10 +165,9 @@ public class WechatMiniMsgUtil {
if (StrUtil.isNotEmpty(accessToken)) {
return accessToken;
}
CzgResult<SysParamsDTO> wxMiniAppId = sysParamsService.getParamsByCode("wx_mini_app_id");
CzgResult<SysParamsDTO> wxMiniSecrete = sysParamsService.getParamsByCode("wx_mini_secrete");
String appId = wxMiniAppId.getData().getParamValue();
String secrete = wxMiniSecrete.getData().getParamValue();
String appId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
String secrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE);
String url = String.format("%s?grant_type=client_credential&appid=%s&secret=%s", TOKEN_URL, appId, secrete);
String response = HttpUtil.get(url);
JSONObject jsonResponse = JSONObject.parseObject(response);
@@ -197,7 +194,7 @@ public class WechatMiniMsgUtil {
private InputStream fetchQrCode(Map<String, Object> params) {
JsonObject jsonObject = new JsonObject();
//路径
jsonObject.addProperty("path", sysParamsService.getSysParamValue(SysParamCodeEnum.WX_MINI_VIP_URL.getCode()) + "?shopId=" + params.get("shopId"));
jsonObject.addProperty("path", sysParamsService.getSysParamValue(ParamCodeCst.System.WX_MINI_VIP_URL) + "?shopId=" + params.get("shopId"));
//是否需要透明底色,为 true 时,生成透明底色的小程序码
jsonObject.addProperty("is_hyaline", true);
//正式版为 release体验版为 trial开发版为 develop
@@ -214,10 +211,8 @@ public class WechatMiniMsgUtil {
public JSONObject getSession(String code) {
CzgResult<SysParamsDTO> wxMiniSecrete = sysParamsService.getParamsByCode("wx_mini_secrete");
CzgResult<SysParamsDTO> wxMiniAppId = sysParamsService.getParamsByCode("wx_mini_app_id");
String appId = wxMiniAppId.getData().getParamValue();
String secrete = wxMiniSecrete.getData().getParamValue();
String appId = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
String secrete = sysParamsService.getSysParamValue(ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE);
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
Map<String, Object> requestUrlParam = new HashMap<>();
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN

View File

@@ -1,15 +1,14 @@
package com.czg.service.market.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.service.ShopInfoService;
import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException;
import com.czg.market.dto.AcPushEventDTO;
import com.czg.market.entity.AcPushEvent;
import com.czg.market.entity.SmsPushEvent;
import com.czg.market.entity.SmsPushEventUser;
import com.czg.market.service.AcPushEventService;
import com.czg.market.service.MkShopCouponRecordService;
@@ -28,7 +27,6 @@ import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 公众号推送任务 服务层实现。
@@ -170,7 +168,7 @@ public class AcPushEventServiceImpl extends ServiceImpl<AcPushEventMapper, AcPus
}
private void checkPushEventSendCount(Long shopId) {
String maxSendCount = paramsService.getSysParamValue("ac_day_count");
String maxSendCount = paramsService.getSysParamValue(ParamCodeCst.Wechat.Ac.AC_DAY_COUNT);
if (StrUtil.isBlank(maxSendCount)) {
return;
}

View File

@@ -185,38 +185,6 @@ public abstract class BaseWx {
}
}
public static void main(String[] args) throws Exception {
String key = "-----BEGIN PUBLIC KEY-----\n" +
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7sdF3xWrWPCYRjwulCpY\n" +
"KeER1+deVRLWqsMxibarVXt9+hJpMwZtqyEW5/KQrK8CIpefEVuiZuHM5SXZsL7X\n" +
"xWi24WY3wMqxnnrbcVmw4IA4OhVekajXnU4EBMqHzRXTwQpkv0qLfp7J5wEify7u\n" +
"y02j0t38k57IToCEwOY5cP/1vt/bZPJOpeefldaOnmIncF6xklywdGztncSMIzli\n" +
"rs1+Jnbrjx9DnhWmBJSa6yWL7sZjBa8YvZBvQBBHC1b82LFawjwKHKDBZlT+kFnp\n" +
"aboDHKhR4+DbXREkwlU4In70tcMUbitkKt6T2qpErskeKy2uF4iUDQxo3NGMC4AX\n" +
"vQIDAQAB\n" +
"-----END PUBLIC KEY-----";
String timestamp = "1761731254";
String nonce = "z0PqTTIyTE6vLkZWzX3RmBlS5yodUY5J";
String serialNo = "PUB_KEY_ID_0117300912032025102500112177000200";
String signature = "yMBK0e54XUS9lzmgeuWzg0Xw4UIQg3/f2o3BreByipvnaJcb2eiSU/gdL8MnJWXgXYaVE/c5NgXAsagbGQhgKS6RQ37ZlUhWTun+jFGfFi5V2Djd01JaSMHHzGHWXApIV8DJnJlr2uCeJtX3U0SNXovWxlkeId8SPFPQRK4DNIjiDJsmzlB33VZ+ma8QtGsUg5E+dP9wz42xfUbGpnMjjKuyK7sUeSrgRaSqQ6fb1sUNGy1yaCs/ZS/KpMJL3d3eZbB9cRIP7eanlHx11Xi8tboLPmyVSTm01LHYdCBAAQzK3QlbtCMaK0dzpFepEABpVt42ajH0GfVPsyvep7k5/A==";
String result = "{\"id\":\"3946093d-5053-5d9d-9821-3b52acccac06\",\"create_time\":\"2025-10-29T17:47:29+08:00\",\"resource_type\":\"encrypt-resource\",\"event_type\":\"MCHTRANSFER.BILL.FINISHED\",\"summary\":\"商家转账单据终态通知\",\"resource\":{\"original_type\":\"mch_payment\",\"algorithm\":\"AEAD_AES_256_GCM\",\"ciphertext\":\"mWr+e0tYehbdV7nIMXeFTe/moALfDh+ky48XWBd0Oc0mb99JhTnHgbfIfRijNdTPKm1NMAO0/l4oJ78rCiLnanW2u2Dx7Rme9JjJ41PqXaQKuQeNSaEez2yK1uwagpu1bWL5fStNXFHDpgzzd+2fFPCv+9pTWD6BhbPq5L2WKjOpFNe4wsl4cozUS2hzyU63nv+QbIlEOyQgXu/cXc0fU4AKUO1mApnBILIA9pHNJaDZiktfyYKHz01u39iVnVJSWDKllWKIEeEhlzKrQvP1vdArj/ifvaymlwYRyFmRz2TNkYxw4LLEWj772wFEibRZTp0mbW/78gDP/yxOreIgdI75VrxJx46JYfT9lWHD7BTDH/c97CnWQlRq2EH4E14Es4bQYqnuWJIrrB6XZ1duOvVS86hP2dq2nMFKYN6niRKeTfCJ3yRU0A==\",\"associated_data\":\"mch_payment\",\"nonce\":\"PwmzF2cR2MRD\"}}";
boolean b = WxPayKit.verifySignature(signature, result, nonce, timestamp, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7sdF3xWrWPCYRjwulCpY\n" +
"KeER1+deVRLWqsMxibarVXt9+hJpMwZtqyEW5/KQrK8CIpefEVuiZuHM5SXZsL7X\n" +
"xWi24WY3wMqxnnrbcVmw4IA4OhVekajXnU4EBMqHzRXTwQpkv0qLfp7J5wEify7u\n" +
"y02j0t38k57IToCEwOY5cP/1vt/bZPJOpeefldaOnmIncF6xklywdGztncSMIzli\n" +
"rs1+Jnbrjx9DnhWmBJSa6yWL7sZjBa8YvZBvQBBHC1b82LFawjwKHKDBZlT+kFnp\n" +
"aboDHKhR4+DbXREkwlU4In70tcMUbitkKt6T2qpErskeKy2uF4iUDQxo3NGMC4AX\n" +
"vQIDAQAB");
JSONObject jsonObject = JSONObject.parseObject(result);
JSONObject resource = jsonObject.getJSONObject("resource");
String associatedData = resource.getString("associated_data");
String ciphertext = resource.getString("ciphertext");
String nonceStr = resource.getString("nonce");
}
public String decryptToString(String associatedData, String nonceStr, String ciphertext) {
AesUtil aesUtil = new AesUtil(config.getApiV3Key().getBytes(StandardCharsets.UTF_8));
try {

View File

@@ -10,6 +10,7 @@ import com.czg.account.dto.PrintOrderDetailDTO;
import com.czg.account.entity.*;
import com.czg.account.service.*;
import com.czg.config.RedisCst;
import com.czg.constants.ParamCodeCst;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.OrderDetail;
import com.czg.order.entity.OrderInfo;
@@ -546,7 +547,7 @@ public abstract class PrinterHandler {
return;
}
CzgResult<SysParamsDTO> paramsByCode = sysParamsService.getParamsByCode("call_page_url");
CzgResult<SysParamsDTO> paramsByCode = sysParamsService.getParamsByCode(ParamCodeCst.System.CALL_PAGE_URL);
SysParamsDTO params = paramsByCode.getData();
String callUrl = null;
if (params != null && StrUtil.isNotBlank(params.getParamValue())) {

View File

@@ -13,7 +13,8 @@ import com.czg.account.entity.*;
import com.czg.account.service.*;
import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.constant.TableValueConstant;
import com.czg.constants.ParamCodeCst;
import com.czg.constants.PayTypeConstants;
import com.czg.entity.req.*;
import com.czg.entity.resp.*;
import com.czg.enums.ShopUserFlowBizEnum;
@@ -32,7 +33,6 @@ import com.czg.order.entity.OrderDetail;
import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment;
import com.czg.order.enums.PayEnums;
import com.czg.constants.PayTypeConstants;
import com.czg.order.service.CreditBuyerOrderService;
import com.czg.order.service.OrderDetailService;
import com.czg.order.service.OrderInfoCustomService;
@@ -48,7 +48,6 @@ import com.czg.service.order.dto.VipRefundDTO;
import com.czg.service.order.enums.OrderStatusEnums;
import com.czg.service.order.mapper.OrderPaymentMapper;
import com.czg.service.order.service.PayService;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil;
import com.czg.utils.CzgRandomUtils;
@@ -60,8 +59,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -924,7 +921,7 @@ public class PayServiceImpl implements PayService {
private CzgResult<Map<String, Object>> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData) {
ShopMerchant shopMerchant = getMerchant(shopId);
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_NOTIFY_URL));
CzgResult<CzgH5PayResp> h5PayRespCzgResult = czgPayService.h5Pay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
return execPayResult(h5PayRespCzgResult);
}
@@ -934,7 +931,7 @@ public class PayServiceImpl implements PayService {
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_NOTIFY_URL));
bizData.setPayType("aliPay".equals(payType) ? "ALIPAY" : "WECHAT");
CzgResult<CzgJsPayResp> jsPayRespCzgResult = czgPayService.jsPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
return execPayResult(jsPayRespCzgResult);
@@ -945,7 +942,7 @@ public class PayServiceImpl implements PayService {
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_NOTIFY_URL));
CzgResult<CzgLtPayResp> ltPayRespCzgResult = czgPayService.ltPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
return execPayResult(ltPayRespCzgResult);
}
@@ -953,7 +950,7 @@ public class PayServiceImpl implements PayService {
private CzgResult<Map<String, Object>> scanPay(@NonNull Long shopId, CzgScanPayReq bizData) {
ShopMerchant shopMerchant = getMerchant(shopId);
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_NOTIFY_URL));
CzgResult<CzgScanPayResp> scanPayRespCzgResult = czgPayService.scanPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
return execPayResult(scanPayRespCzgResult);
}
@@ -965,7 +962,7 @@ public class PayServiceImpl implements PayService {
}
ShopMerchant shopMerchant = getMerchant(shopId);
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_NOTIFY_URL.getCode()));
sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_NOTIFY_URL));
String firstTwoDigitsStr = bizData.getAuthCode().substring(0, 2);
// 将截取的字符串转换为整数
int firstTwoDigits = Integer.parseInt(firstTwoDigitsStr);
@@ -986,7 +983,7 @@ public class PayServiceImpl implements PayService {
private CzgResult<CzgRefundResp> refund(@NonNull Long shopId, CzgRefundReq bizData) {
ShopMerchant shopMerchant = getMerchant(shopId);
bizData.setNotifyUrl(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_REFUND_NOTIFY_URL.getCode()));
bizData.setNotifyUrl(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_REFUND_NOTIFY_URL));
return czgPayService.refundOrder(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
}

View File

@@ -1,13 +1,11 @@
package com.czg.service.Impl;
import com.czg.CzgPayUtils;
import com.czg.entity.notify.CzgPayNotifyDTO;
import com.czg.entity.notify.CzgRefundNotifyDTO;
import com.czg.constants.ParamCodeCst;
import com.czg.entity.req.*;
import com.czg.entity.resp.*;
import com.czg.resp.CzgResult;
import com.czg.service.CzgPayService;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import lombok.NonNull;
import org.apache.dubbo.config.annotation.DubboReference;
@@ -25,42 +23,42 @@ public class CzgPayServiceImpl implements CzgPayService {
@Override
public CzgResult<CzgH5PayResp> h5Pay(@NonNull String appId, @NonNull String appSecret, CzgH5PayReq bizData) {
return CzgPayUtils.h5Pay(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_DOMAIN.getCode()), appId, appSecret, bizData);
return CzgPayUtils.h5Pay(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
}
@Override
public CzgResult<CzgJsPayResp> jsPay(@NonNull String appId, @NonNull String appSecret, CzgJsPayReq bizData) {
return CzgPayUtils.jsPay(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_DOMAIN.getCode()), appId, appSecret, bizData);
return CzgPayUtils.jsPay(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
}
@Override
public CzgResult<CzgLtPayResp> ltPay(@NonNull String appId, @NonNull String appSecret, CzgLtPayReq bizData) {
return CzgPayUtils.ltPay(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_DOMAIN.getCode()), appId, appSecret, bizData);
return CzgPayUtils.ltPay(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
}
@Override
public CzgResult<CzgScanPayResp> scanPay(@NonNull String appId, @NonNull String appSecret, CzgScanPayReq bizData) {
return CzgPayUtils.scanPay(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_DOMAIN.getCode()), appId, appSecret, bizData);
return CzgPayUtils.scanPay(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
}
@Override
public CzgResult<CzgMicroPayResp> microPay(@NonNull String appId, @NonNull String appSecret, CzgMicroPayReq bizData) {
return CzgPayUtils.microPay(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_DOMAIN.getCode()), appId, appSecret, bizData);
return CzgPayUtils.microPay(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
}
@Override
public CzgResult<CzgBaseResp> queryPayOrder(@NonNull String appId, @NonNull String appSecret, String payOrderId, String mchOrderNo) {
return CzgPayUtils.queryPayOrder(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_DOMAIN.getCode()), appId, appSecret, payOrderId, mchOrderNo);
return CzgPayUtils.queryPayOrder(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, payOrderId, mchOrderNo);
}
@Override
public CzgResult<CzgRefundResp> refundOrder(@NonNull String appId, @NonNull String appSecret, CzgRefundReq bizData) {
return CzgPayUtils.refundOrder(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_DOMAIN.getCode()), appId, appSecret, bizData);
return CzgPayUtils.refundOrder(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
}
@Override
public CzgResult<CzgRefundResp> queryRefundOrder(@NonNull String appId, @NonNull String appSecret, String mchRefundNo, String refundOrderId) {
return CzgPayUtils.queryRefundOrder(sysParamsService.getSysParamValue(SysParamCodeEnum.PAY_CZG_DOMAIN.getCode()), appId, appSecret, mchRefundNo, refundOrderId);
return CzgPayUtils.queryRefundOrder(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, mchRefundNo, refundOrderId);
}
}

View File

@@ -3,9 +3,8 @@ package com.czg.service.system.service.impl;
import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.teaopenapi.models.Config;
import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException;
import com.czg.resp.CzgResult;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.service.SmsService;
import com.czg.system.service.SysParamsService;
import jakarta.annotation.PostConstruct;
@@ -27,27 +26,21 @@ public class SmsServiceImpl implements SmsService {
/**
* 阿里云key
*/
// @Value("${alipay.sms.key}")
private String key;
/**
* 阿里云secret
*/
// @Value("${alipay.sms.secret}")
private String secret;
/**
* 短信模板id
*/
// @Value("${alipay.sms.templateCode}")
private String templateCode;
@PostConstruct
public void init() {
CzgResult<SysParamsDTO> aliSmsKey = sysParamsService.getParamsByCode("ali_sms_key");
CzgResult<SysParamsDTO> aliSmsSecret = sysParamsService.getParamsByCode("ali_sms_secret");
CzgResult<SysParamsDTO> aliSmsTemplateCode = sysParamsService.getParamsByCode("ali_sms_template_code");
key = aliSmsKey.getData().getParamValue();
secret = aliSmsSecret.getData().getParamValue();
templateCode = aliSmsTemplateCode.getData().getParamValue();
key = sysParamsService.getSysParamValue(ParamCodeCst.AliYun.ALI_SMS_KEY);
secret = sysParamsService.getSysParamValue(ParamCodeCst.AliYun.ALI_SMS_SECRET);
templateCode = sysParamsService.getSysParamValue(ParamCodeCst.AliYun.ALI_SMS_TEMPLATE_CODE);
log.info("短信工具类初始化完毕key: {}, secret: {}, templateCode: {}", key, secret, templateCode);
}
@@ -58,6 +51,7 @@ public class SmsServiceImpl implements SmsService {
return new Client(config);
}
@Override
public void sendCode(String phone, String checkCode) {
try {
Client client = createClient();
@@ -77,20 +71,4 @@ public class SmsServiceImpl implements SmsService {
log.info("发送短信失败", e);
}
}
public static void main(String[] args) throws Exception {
Config config = new Config();
config.accessKeyId = "LTAI5tPdEfYSZcqHbjCrtPRD";
config.accessKeySecret = "DZjyHBq3nTujF0NMLxnZgsecU8ZCvy";
Client client = new Client(config);
// 1.发送短信
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest()
.setSignName("银收客")
.setTemplateCode("SMS_244665149")
.setTemplateParam("{\"code\":" + "'" + "23123" + "'" + "}")
.setPhoneNumbers("19502966242");
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
System.out.println(sendSmsResponse);
}
}

View File

@@ -7,7 +7,6 @@ import com.czg.service.system.mapper.SysParamsMapper;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.entity.SysParams;
import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
@@ -29,6 +28,16 @@ import java.util.List;
@CacheConfig(cacheNames = "params")
public class SysParamsServiceImpl extends ServiceImpl<SysParamsMapper, SysParams> implements SysParamsService {
@Override
public CzgResult<List<SysParamsDTO>> getParamsByType(Integer type) {
List<SysParams> sysParamsList = list(new QueryWrapper().eq(SysParams::getParamType, type));
List<SysParamsDTO> sysParamsDTOList = new ArrayList<>();
for (SysParams sysParams : sysParamsList) {
sysParamsDTOList.add(BeanUtil.toBean(sysParams, SysParamsDTO.class));
}
return CzgResult.success(sysParamsDTOList);
}
@Override
public CzgResult<String> insertParams(SysParamsDTO paramsDTO) {
// 查询 paramCode 是否存在
@@ -104,8 +113,7 @@ public class SysParamsServiceImpl extends ServiceImpl<SysParamsMapper, SysParams
return CzgResult.success(sysParamsDTO);
}
@Override
public SysParams getSysParam(String code) {
private SysParams getSysParam(String code) {
return getMapper().getSysParam(code);
}
@@ -122,14 +130,4 @@ public class SysParamsServiceImpl extends ServiceImpl<SysParamsMapper, SysParams
}
return sysParam.getParamValue();
}
@Override
public CzgResult<List<SysParamsDTO>> getParamsByType(Integer type) {
List<SysParams> sysParamsList = list(new QueryWrapper().eq(SysParams::getParamType, type));
List<SysParamsDTO> sysParamsDTOList = new ArrayList<>();
for (SysParams sysParams : sysParamsList) {
sysParamsDTOList.add(BeanUtil.toBean(sysParams, SysParamsDTO.class));
}
return CzgResult.success(sysParamsDTOList);
}
}