From c28040543289e96749397839739d89bc5bae2030 Mon Sep 17 00:00:00 2001 From: "382696293@qq.com" <382696293@qq.com> Date: Fri, 29 Mar 2024 10:31:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E4=BA=91=E6=8E=A5=E5=8F=A3=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E5=B7=A5=E5=85=B7=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/shuyun/ActionMethod.java | 210 ++++++++ .../utils/shuyun/ShuYunApiUtils.java | 469 ++++++++++++++++++ .../utils/shuyun/ShuYunConfig.java | 99 ++++ .../system/utils/shuyun/ShuYunApiUtils.java | 13 +- 4 files changed, 789 insertions(+), 2 deletions(-) create mode 100644 flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ActionMethod.java create mode 100644 flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ShuYunApiUtils.java create mode 100644 flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ShuYunConfig.java diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ActionMethod.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ActionMethod.java new file mode 100644 index 0000000..fd9cd4f --- /dev/null +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ActionMethod.java @@ -0,0 +1,210 @@ +package com.flossom.miniProgram.utils.shuyun; + +/** + * 数云接口方法名称 + */ +public class ActionMethod { + + /** + * 获取token路径标识 + */ + private String accessToken; + + /** + * 查询会员信息(单个会员) + */ + private String queryMember; + + /** + * 注册会员 + */ + private String registerMember; + + /** + * 修改会员信息 + */ + private String modifyMember; + + /** + * 修改会员手机号 + */ + private String modifyMemberMobile; + + /** + * 解绑会员 + */ + private String unbindMember; + + /** + * 积分变更 + */ + private String pointChange; + + /** + * 积分变更记录查询 + */ + private String pointChangeLogSearch; + + /** + * 即将过期积分查询 + */ + private String pointWillDueSearch; + + /** + * 创建标签 + */ + private String tagCreate; + /** + * 删除标签 + */ + private String tagDelete; + /** + * 搜索标签 + */ + private String tagSearch; + /** + * 更改标签 + */ + private String tagUpdate; + + /** + * 给会员标记标签 + */ + private String markUserTag; + /** + * 删除用户标签 + */ + private String deleteUserTag; + /** + * 查询用户标签 + */ + private String searchUserTag; + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public String getQueryMember() { + return queryMember; + } + + public void setQueryMember(String queryMember) { + this.queryMember = queryMember; + } + + public String getRegisterMember() { + return registerMember; + } + + public void setRegisterMember(String registerMember) { + this.registerMember = registerMember; + } + + public String getModifyMember() { + return modifyMember; + } + + public void setModifyMember(String modifyMember) { + this.modifyMember = modifyMember; + } + + public String getModifyMemberMobile() { + return modifyMemberMobile; + } + + public void setModifyMemberMobile(String modifyMemberMobile) { + this.modifyMemberMobile = modifyMemberMobile; + } + + public String getUnbindMember() { + return unbindMember; + } + + public void setUnbindMember(String unbindMember) { + this.unbindMember = unbindMember; + } + + public String getPointChange() { + return pointChange; + } + + public void setPointChange(String pointChange) { + this.pointChange = pointChange; + } + + public String getPointChangeLogSearch() { + return pointChangeLogSearch; + } + + public void setPointChangeLogSearch(String pointChangeLogSearch) { + this.pointChangeLogSearch = pointChangeLogSearch; + } + + public String getPointWillDueSearch() { + return pointWillDueSearch; + } + + public void setPointWillDueSearch(String pointWillDueSearch) { + this.pointWillDueSearch = pointWillDueSearch; + } + + public String getTagCreate() { + return tagCreate; + } + + public void setTagCreate(String tagCreate) { + this.tagCreate = tagCreate; + } + + public String getTagDelete() { + return tagDelete; + } + + public void setTagDelete(String tagDelete) { + this.tagDelete = tagDelete; + } + + public String getTagSearch() { + return tagSearch; + } + + public void setTagSearch(String tagSearch) { + this.tagSearch = tagSearch; + } + + public String getTagUpdate() { + return tagUpdate; + } + + public void setTagUpdate(String tagUpdate) { + this.tagUpdate = tagUpdate; + } + + public String getMarkUserTag() { + return markUserTag; + } + + public void setMarkUserTag(String markUserTag) { + this.markUserTag = markUserTag; + } + + public String getDeleteUserTag() { + return deleteUserTag; + } + + public void setDeleteUserTag(String deleteUserTag) { + this.deleteUserTag = deleteUserTag; + } + + public String getSearchUserTag() { + return searchUserTag; + } + + public void setSearchUserTag(String searchUserTag) { + this.searchUserTag = searchUserTag; + } +} diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ShuYunApiUtils.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ShuYunApiUtils.java new file mode 100644 index 0000000..83e70ef --- /dev/null +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ShuYunApiUtils.java @@ -0,0 +1,469 @@ +package com.flossom.miniProgram.utils.shuyun; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.map.MapUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.flossom.common.core.constant.CacheConstants; +import com.flossom.common.core.domain.R; +import com.flossom.common.core.domain.shuyun.*; +import com.flossom.common.core.exception.ServiceException; +import com.flossom.common.redis.service.RedisService; +import com.flossom.miniProgram.utils.HttpClientUtils; +import com.shuyun.open.sdk.bean.HttpMethod; +import com.shuyun.open.sdk.core.GateWayClient; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.List; +import java.util.Map; + + +/** + * 数云工具类 + */ +@Component +public class ShuYunApiUtils { + + protected final static Logger logger = LoggerFactory.getLogger(ShuYunApiUtils.class); + + /** + * 数云配置类 + */ + private static ShuYunConfig shuYunConfig; + + private static RedisService redisService; + + @Autowired + public void setShuYunConfig(ShuYunConfig shuYunConfig) { + ShuYunApiUtils.shuYunConfig = shuYunConfig; + } + + @Autowired + public void setRedisService(RedisService redisService) { + ShuYunApiUtils.redisService = redisService; + } + + /** + * 数云http请求code + */ + public class ShuYunHttpStatusConstants { + /** + * 请求成功 + */ + public static final int SUCCESS = 10000; + + /** + * 请求成功,但是业务处理错误,或者执行结果不符合预期 + * 但不是处理异常 + */ + public static final int HALF_SUCCESS = 14000; + } + + /** + * 获取 accessToken,缓存没有就请求数云回调接口,通过异步回调将 accessToken 传递过来 + */ + public static String getAccessToken() { + Long expiryTime = redisService.getCacheMapValue(CacheConstants.SHUYUN_ACCESS_TOKEN_CACHE, CacheConstants.SHUYUN_ACCESS_TOKEN_CACHE_EXPIRY); + if (expiryTime == null || expiryTime == 0 || LocalDateTime.now().atZone(ZoneId.systemDefault()).toEpochSecond() > expiryTime) { + String accessTokenUrl = StringUtils.replace(shuYunConfig.getActionMethod().getAccessToken(), "{appid}", shuYunConfig.getAppid()); + logger.info("刷新 accessToken 地址:{}", accessTokenUrl); + try { + String result = HttpClientUtils.get(accessTokenUrl); + logger.info("请求数云接口获取 accessToken 结果:{}", result); + R r = JSON.parseObject(result, R.class); + if (r.getCode() != R.SUCCESS) { + logger.error("请求数云接口获取accessToken失败,将直接使用旧的accessToken,失败原因:{}", result); + } + } catch (Exception e) { + logger.error("请求数云接口获取accessToken失败,将直接使用旧的accessToken,失败原因:{}", e.getMessage()); + } + } + String accessTokenStr = redisService.getCacheMapValue(CacheConstants.SHUYUN_ACCESS_TOKEN_CACHE, CacheConstants.SHUYUN_ACCESS_TOKEN_CACHE_VALUE); + if (StringUtils.isNotBlank(accessTokenStr)) { + AccessToken accessToken = JSON.parseObject(accessTokenStr, AccessToken.class); + return accessToken.getAccessToken(); + } + /** + * 第一次获取会失败,因为回调是异步的,如果还没回调回来,我们就从 redis 获取缓存了 + */ + logger.error("从 redis 获取数云 accessToken 失败,缓存中没有 accessToken,有可能是第一次调用"); + throw new ServiceException("从 redis 获取数云 accessToken 失败,缓存中没有 accessToken,有可能是第一次调用"); + } + + /** + * 请求基础封装方法 (增加泛型适配) + * + * @param httpMethod 请求方式 + * @param queryParams get请求时,url地址后的参数 + * @param bodyParams post、put 请求时,请求体的数据 + * @param actionMethod 请求方法地址 + */ + public static R shuYunHttpRequest(HttpMethod httpMethod, Map queryParams, Object bodyParams, String actionMethod, Class clazz) throws ServiceException { + logger.info("数云接口请求地址:{},参数:queryParams = {}、bodyParams = {}", actionMethod, queryParams, JSON.toJSONString(bodyParams)); + String result = GateWayClient.askGateWay( + httpMethod, shuYunConfig.getUrl(), + queryParams, JSON.toJSONString(bodyParams), + shuYunConfig.getAppid(), shuYunConfig.getSecurity(), + getAccessToken(), actionMethod); + logger.info("返回响应:{}", result); + R r = JSON.parseObject(result, new TypeReference>(clazz) { + }); + if (r.getCode() == ShuYunHttpStatusConstants.SUCCESS || r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + return r; + } else { + logger.error("调用数云接口发生未知错误:{}", result); + throw new ServiceException(r.getMsg()); + } + } + + /** + * 保留旧版本 + */ + @Deprecated + public static R shuYunHttpRequest2(HttpMethod httpMethod, Map queryParams, Object bodyParams, String actionMethod) throws ServiceException { + logger.info("数云接口请求地址:{},参数:queryParams = {}、bodyParams = {}", actionMethod, queryParams, JSON.toJSONString(bodyParams)); + String result = GateWayClient.askGateWay( + httpMethod, shuYunConfig.getUrl(), + queryParams, JSON.toJSONString(bodyParams), + shuYunConfig.getAppid(), shuYunConfig.getSecurity(), + getAccessToken(), actionMethod); + logger.info("返回响应:{}", result); + R r = JSON.parseObject(result, R.class); + if (r.getCode() == ShuYunHttpStatusConstants.SUCCESS || r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + return r; + } else { + logger.error("调用数云接口发生未知错误:{}", result); + throw new ServiceException(r.getMsg()); + } + } + + public static R httpQueryParamsRequest(HttpMethod httpMethod, Map queryParams, String actionMethod, Class clazz) throws ServiceException { + return shuYunHttpRequest(httpMethod, queryParams, null, actionMethod, clazz); + } + + public static R httpBodyParamsRequest(HttpMethod httpMethod, Object bodyParams, String actionMethod, Class clazz) throws ServiceException { + return shuYunHttpRequest(httpMethod, null, bodyParams, actionMethod, clazz); + } + + + /** + * 会员注册 + * https://open.shuyun.com/#/apidoc?type=41&apiId=40 + */ + public static R registerMember(ShuYunMember member) { + try { + return httpBodyParamsRequest(HttpMethod.POST, member, shuYunConfig.getActionMethod().getRegisterMember(), Object.class); + } catch (Exception e) { + logger.error("请求数云接口注册会员失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口注册会员失败"); + } + } + + /** + * 会员信息查询(单查询) + * https://open.shuyun.com/#/apidoc?type=41&apiId=149 + */ + public static ShuYunMember queryMember(String memberId, String platCode, String shopId) { + Map params = MapUtil.newHashMap(); + params.put("id", memberId); + params.put("platCode", platCode); + params.put("shopId", shopId); + try { + R r = httpBodyParamsRequest(HttpMethod.POST, params, shuYunConfig.getActionMethod().getQueryMember(), ShuYunMember.class); + if (r.getCode() == ShuYunHttpStatusConstants.SUCCESS) { + return r.getData(); + } + if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + return null; + } + logger.error("请求数云接口-会员信息查询失败:{}", r.getMsg()); + throw new ServiceException("请求数云接口-会员信息查询失败"); + } catch (Exception e) { + logger.error("请求数云接口-会员信息查询失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-会员信息查询失败"); + } + } + + /** + * 修改会员信息 + * 注意:手机号不能修改 + * https://open.shuyun.com/#/apidoc?type=41&apiId=36 + */ + public static R modifyMember(ShuYunMember member) { + try { + return httpBodyParamsRequest(HttpMethod.PUT, member, shuYunConfig.getActionMethod().getModifyMember(), Object.class); + } catch (Exception e) { + logger.error("请求数云接口-修改会员信息(除手机号)失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-修改会员信息(除手机号)失败"); + } + } + + /** + * 修改会员手机号 + * https://open.shuyun.com/#/apidoc?type=41&apiId=37 + */ + public static R modifyMemberMobile(String memberId, String platCode, String shopId, String mobile) { + Map params = MapUtil.newHashMap(); + params.put("id", memberId); + params.put("platCode", platCode); + params.put("shopId", shopId); + params.put("mobile", mobile); + try { + return httpBodyParamsRequest(HttpMethod.PUT, params, shuYunConfig.getActionMethod().getModifyMemberMobile(), Object.class); + } catch (Exception e) { + logger.error("请求数云接口-修改会员手机号失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-修改会员手机号失败"); + } + } + + /** + * 解绑会员 + * https://open.shuyun.com/#/apidoc?type=41&apiId=74 + */ + public static R unbindMember(String memberId, String platCode, String shopId) { + Map params = MapUtil.newHashMap(); + params.put("id", memberId); + params.put("platCode", platCode); + params.put("shopId", shopId); + try { + return httpBodyParamsRequest(HttpMethod.POST, params, shuYunConfig.getActionMethod().getUnbindMember(), Object.class); + } catch (Exception e) { + logger.error("请求数云接口-解绑会员失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-解绑会员失败"); + } + } + + /** + * 会员积分变更 + * https://open.shuyun.com/#/apidoc?type=41&apiId=34 + */ + public static R pointChange(ShuYunPointChange shuYunPointChange) { + try { + return httpBodyParamsRequest(HttpMethod.POST, shuYunPointChange, shuYunConfig.getActionMethod().getPointChange(), Object.class); + } catch (Exception e) { + logger.error("请求数云接口-会员积分变更失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-会员积分变更失败"); + } + } + + /** + * 积分变更记录查询(分页) + * https://open.shuyun.com/#/apidoc?type=41&apiId=33 + */ + public static ShuYunPageUtil pointChangeLogSearch(ShuYunPageReq shuYunPageReq) { + try { + R r = httpQueryParamsRequest(HttpMethod.GET, BeanUtil.beanToMap(shuYunPageReq), + shuYunConfig.getActionMethod().getPointChangeLogSearch(), Object.class); + if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + logger.info("查询成功,没有数据"); + return new ShuYunPageUtil<>(); + } + if (r.getCode() != ShuYunHttpStatusConstants.SUCCESS) { + logger.error("请求数云接口-会员积分变更记录查询失败:{}", r.getMsg()); + } + return JSON.parseObject(r.getData().toString(), new TypeReference>() { + }); + } catch (Exception e) { + logger.error("请求数云接口-会员积分变更记录查询失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-会员积分变更记录查询失败"); + } + } + + /** + * 查询即将过期积分 + * https://open.shuyun.com/#/apidoc?type=41&apiId=249 + */ + public static Integer pointWillDueSearch(String tenant, String platId, String cardPlanId, String timeType, String startTime, String endTime) { + Map params = MapUtil.newHashMap(); + params.put("tenant", tenant); + params.put("platId", platId); + params.put("platCode", shuYunConfig.getPlatCode()); + params.put("shopId", shuYunConfig.getShopId()); + params.put("cardPlanId", cardPlanId); + params.put("timeType", timeType); + params.put("startTime", startTime); + params.put("endTime", endTime); + try { + R r = httpQueryParamsRequest(HttpMethod.GET, params, shuYunConfig.getActionMethod().getPointWillDueSearch(), Integer.class); + if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + logger.info("查询成功,没有数据"); + } + if (r.getCode() != ShuYunHttpStatusConstants.SUCCESS) { + logger.error("请求数云接口-查询会员即将过期积分失败:{}", r.getMsg()); + } + return r.getData(); + } catch (Exception e) { + logger.error("请求数云接口-查询会员即将过期积分失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-查询会员即将过期积分失败"); + } + } + + + /** + * 创建标签 + * https://open.shuyun.com/#/apidoc?type=23&apiId=86 + */ + public static Integer tagCreate(ShuYunTag shuYunTag) { + try { + R r = httpBodyParamsRequest(HttpMethod.POST, shuYunTag, shuYunConfig.getActionMethod().getTagCreate(), Map.class); + if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + logger.error("请求数云接口-创建标签失败:{}", r.getMsg()); + throw new ServiceException("请求数云接口-创建标签失败"); + } + if (r.getData() != null) { + return (Integer) (r.getData().get("tagId")); + } + return null; + } catch (Exception e) { + logger.error("请求数云接口-创建标签失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-创建标签失败"); + } + } + + /** + * 查询标签 + * https://open.shuyun.com/#/apidoc?type=23&apiId=85 + * + * @param type 标签类型:1(自定义) + * @param allValueType 标签显示:true(全部标签);false(基本标签) + */ + public static List tagSearch(String type, String allValueType) { + Map params = MapUtil.newHashMap(); + params.put("type", type); + params.put("allValueType", allValueType); + try { + R r = httpQueryParamsRequest(HttpMethod.GET, params, shuYunConfig.getActionMethod().getTagSearch(), Object.class); + if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + logger.error("请求数云接口-创建标签失败:{}", r.getMsg()); + throw new ServiceException("请求数云接口-创建标签失败"); + } + return JSON.parseObject(r.getData().toString(), new TypeReference>() { + }); + } catch (Exception e) { + logger.error("请求数云接口-创建标签失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-创建标签失败"); + } + } + + /** + * 删除标签 + * https://open.shuyun.com/#/apidoc?type=23&apiId=153 + */ + public static R tagDelete(String tagId) { + Map params = MapUtil.newHashMap(); + params.put("tagId", tagId); + try { + R r = httpBodyParamsRequest(HttpMethod.DELETE, params, + shuYunConfig.getActionMethod().getTagDelete(), Object.class); + if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + logger.error("请求数云接口-删除标签失败:{}", r.getMsg()); + throw new ServiceException("请求数云接口-删除标签失败"); + } + return r; + } catch (Exception e) { + logger.error("请求数云接口-删除标签失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-删除标签失败"); + } + } + + /** + * 修改标签 + * https://open.shuyun.com/#/apidoc?type=23&apiId=198 + */ + public static R tagUpdate(ShuYunTag shuYunTag) { + try { + R r = httpBodyParamsRequest(HttpMethod.PUT, shuYunTag, + shuYunConfig.getActionMethod().getTagUpdate(), Object.class); + if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + logger.error("请求数云接口-修改标签失败:{}", r.getMsg()); + throw new ServiceException("请求数云接口-修改标签失败"); + } + return r; + } catch (Exception e) { + logger.error("请求数云接口-修改标签失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-修改标签失败"); + } + } + + /** + * 给客户打上单个标签 + */ + public static R markUserTag(ShuYunUserTagReq shuYunUserTagReq) { + try { + R r = httpBodyParamsRequest(HttpMethod.POST, shuYunUserTagReq, + shuYunConfig.getActionMethod().getMarkUserTag(), Object.class); + if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + logger.error("请求数云接口-给客户打上单个标签失败:{}", r.getMsg()); + throw new ServiceException("请求数云接口-给客户打上单个标签失败"); + } + return r; + } catch (Exception e) { + logger.error("请求数云接口-给客户打上单个标签失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-给客户打上单个标签失败"); + } + } + + /** + * 查询客户已经被打上的标签 + */ + public static List searchUserTag(String tagType, String platCode, String shopId, String platAccount, String allValueType) { + Map params = MapUtil.newHashMap(); + // 标签类型:0:云标签, 1:自定义标签 + params.put("tagType", tagType); + // 平台代码 + params.put("platCode", platCode); + // 店铺ID(数云内部店铺ID) + params.put("shopId", shopId); + // 平台账号 + params.put("platAccount", platAccount); + // 标签显示:true(全部标签);false(基本标签) + params.put("allValueType", allValueType); + try { + R r = httpQueryParamsRequest(HttpMethod.GET, params, + shuYunConfig.getActionMethod().getSearchUserTag(), Object.class); + if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + logger.error("请求数云接口-查询客户已经被打上的标签失败:{}", r.getMsg()); + throw new ServiceException("请求数云接口-查询客户已经被打上的标签标签失败"); + } + return JSON.parseObject(r.getData().toString(), new TypeReference>() { + }); + } catch (Exception e) { + logger.error("请求数云接口-查询客户已经被打上的标签失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-查询客户已经被打上的标签失败"); + } + } + + /** + * 删除客户已经被打上的标签 + */ + public static R deleteUserTag(String platCode, String shopId, String platAccount, Integer tagId) { + Map params = MapUtil.newHashMap(); + // 平台代码 + params.put("platCode", platCode); + // 店铺ID(数云内部店铺ID) + params.put("shopId", shopId); + // 平台账号 + params.put("platAccount", platAccount); + // 标签ID + params.put("tagId", tagId); + try { + R r = httpBodyParamsRequest(HttpMethod.DELETE, params, + shuYunConfig.getActionMethod().getDeleteUserTag(), Object.class); + if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { + logger.error("请求数云接口-删除客户已经被打上的标签失败:{}", r.getMsg()); + throw new ServiceException("请求数云接口-删除客户已经被打上的标签失败"); + } + return r; + } catch (Exception e) { + logger.error("请求数云接口-删除客户已经被打上的标签失败:{}", e.getMessage()); + throw new ServiceException("请求数云接口-删除客户已经被打上的标签失败"); + } + } + +} diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ShuYunConfig.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ShuYunConfig.java new file mode 100644 index 0000000..f95d8d3 --- /dev/null +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/utils/shuyun/ShuYunConfig.java @@ -0,0 +1,99 @@ +package com.flossom.miniProgram.utils.shuyun; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.Configuration; + +/** + * 数云接口配置 + * + * @author flossom + */ +@Configuration +@RefreshScope +@ConfigurationProperties(prefix = "shuyun") +public class ShuYunConfig { + + /** + * 接口地址 + */ + private String url; + + /** + * 数云 appid + */ + private String appid; + + /** + * 数云 security + */ + private String security; + + /** + * 租户名 + */ + private String authValue; + + private String platCode; + + private String shopId; + + private ActionMethod actionMethod; + + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getAppid() { + return appid; + } + + public void setAppid(String appid) { + this.appid = appid; + } + + public String getSecurity() { + return security; + } + + public void setSecurity(String security) { + this.security = security; + } + + public ActionMethod getActionMethod() { + return actionMethod; + } + + public void setActionMethod(ActionMethod actionMethod) { + this.actionMethod = actionMethod; + } + + public String getPlatCode() { + return platCode; + } + + public void setPlatCode(String platCode) { + this.platCode = platCode; + } + + public String getShopId() { + return shopId; + } + + public void setShopId(String shopId) { + this.shopId = shopId; + } + + public String getAuthValue() { + return authValue; + } + + public void setAuthValue(String authValue) { + this.authValue = authValue; + } +} diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/utils/shuyun/ShuYunApiUtils.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/utils/shuyun/ShuYunApiUtils.java index ff744a8..c3faf5d 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/utils/shuyun/ShuYunApiUtils.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/utils/shuyun/ShuYunApiUtils.java @@ -279,9 +279,18 @@ public class ShuYunApiUtils { * 查询即将过期积分 * https://open.shuyun.com/#/apidoc?type=41&apiId=249 */ - public static Integer pointWillDueSearch(Map map) { + public static Integer pointWillDueSearch(String tenant, String platId, String cardPlanId, String timeType, String startTime, String endTime) { + Map params = MapUtil.newHashMap(); + params.put("tenant", tenant); + params.put("platId", platId); + params.put("platCode", shuYunConfig.getPlatCode()); + params.put("shopId", shuYunConfig.getShopId()); + params.put("cardPlanId", cardPlanId); + params.put("timeType", timeType); + params.put("startTime", startTime); + params.put("endTime", endTime); try { - R r = httpQueryParamsRequest(HttpMethod.GET, map, shuYunConfig.getActionMethod().getPointWillDueSearch(), Integer.class); + R r = httpQueryParamsRequest(HttpMethod.GET, params, shuYunConfig.getActionMethod().getPointWillDueSearch(), Integer.class); if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) { logger.info("查询成功,没有数据"); }