SYS PARAM 常量
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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("页面路径未配置");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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前无异常
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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())) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user