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
|
||||
|
||||
Reference in New Issue
Block a user