数云接口调用封装工具类

master
382696293@qq.com 2 years ago
parent 2274dafa55
commit 41a62803aa

@ -0,0 +1,63 @@
package com.flossom.common.core.domain.shuyun;
import java.util.List;
public class ShuYunGroupTag {
/**
* ID
*/
private Integer groupId;
/**
*
*/
private String groupName;
/**
* (0:, 1:)0
*/
private Integer status;
private List<ShuYunTag> tagList;
public ShuYunGroupTag() {
}
public ShuYunGroupTag(Integer groupId, String groupName, Integer status, List<ShuYunTag> tagList) {
this.groupId = groupId;
this.groupName = groupName;
this.status = status;
this.tagList = tagList;
}
public Integer getGroupId() {
return groupId;
}
public void setGroupId(Integer groupId) {
this.groupId = groupId;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public List<ShuYunTag> getTagList() {
return tagList;
}
public void setTagList(List<ShuYunTag> tagList) {
this.tagList = tagList;
}
}

@ -1,7 +1,13 @@
package com.flossom.common.core.domain.shuyun;
import java.util.List;
public class ShuYunTag {
/**
* ID
*/
private Integer tagId;
/**
* id
*/
@ -42,11 +48,29 @@ public class ShuYunTag {
*/
private String description;
/**
* (0:, 1:, 2:)
*/
private String valueScope;
/**
* (0, 1(), 2:, 3:, 4:, 5:(), 6:, 7:8:)
*/
private String tagType;
private List<ShuYunTagValue> tagValue;
private Integer permission;
private List<ShuYunTag> relatedTagInfo;
private List<ShuYunTag> childTags;
public ShuYunTag() {
}
public ShuYunTag(Integer groupId, String tagName, Integer valueType, Integer optionType, Integer valueNumberOption, Integer validPeriod, Integer validPeriodType, String description) {
public ShuYunTag(Integer groupId, Integer tagId, String tagName, Integer valueType, Integer optionType, Integer valueNumberOption, Integer validPeriod, Integer validPeriodType, String description) {
this.groupId = groupId;
this.tagId = tagId;
this.tagName = tagName;
this.valueType = valueType;
this.optionType = optionType;
@ -56,8 +80,9 @@ public class ShuYunTag {
this.description = description;
}
public ShuYunTag(Integer groupId, String tagName, Integer valueType, Integer optionType, String optionalValues, Integer valueNumberOption, Integer validPeriod, Integer validPeriodType, String description) {
public ShuYunTag(Integer groupId, Integer tagId, String tagName, Integer valueType, Integer optionType, String optionalValues, Integer valueNumberOption, Integer validPeriod, Integer validPeriodType, String description) {
this.groupId = groupId;
this.tagId = tagId;
this.tagName = tagName;
this.valueType = valueType;
this.optionType = optionType;
@ -139,4 +164,61 @@ public class ShuYunTag {
public void setDescription(String description) {
this.description = description;
}
public Integer getTagId() {
return tagId;
}
public void setTagId(Integer tagId) {
this.tagId = tagId;
}
public String getValueScope() {
return valueScope;
}
public void setValueScope(String valueScope) {
this.valueScope = valueScope;
}
public String getTagType() {
return tagType;
}
public void setTagType(String tagType) {
this.tagType = tagType;
}
public List<ShuYunTagValue> getTagValue() {
return tagValue;
}
public void setTagValue(List<ShuYunTagValue> tagValue) {
this.tagValue = tagValue;
}
public Integer getPermission() {
return permission;
}
public void setPermission(Integer permission) {
this.permission = permission;
}
public List<ShuYunTag> getRelatedTagInfo() {
return relatedTagInfo;
}
public void setRelatedTagInfo(List<ShuYunTag> relatedTagInfo) {
this.relatedTagInfo = relatedTagInfo;
}
public List<ShuYunTag> getChildTags() {
return childTags;
}
public void setChildTags(List<ShuYunTag> childTags) {
this.childTags = childTags;
}
}

@ -7,7 +7,7 @@ import java.util.Date;
/**
*
*/
public class ShuYunTagCreate {
public class ShuYunTagCreateCallbackReq {
/**
* ID
@ -24,10 +24,10 @@ public class ShuYunTagCreate {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date addTime;
public ShuYunTagCreate() {
public ShuYunTagCreateCallbackReq() {
}
public ShuYunTagCreate(String tagId, String tagName, Date addTime) {
public ShuYunTagCreateCallbackReq(String tagId, String tagName, Date addTime) {
this.tagId = tagId;
this.tagName = tagName;
this.addTime = addTime;

@ -0,0 +1,196 @@
package com.flossom.common.core.domain.shuyun;
import java.util.List;
public class ShuYunTagResponse {
/**
* ID
*/
private Integer tagId;
/**
*
*/
private String tagName;
/**
* 0, 1
*/
private String tagType;
/**
* 0, 1(), 2:, 3:, 4:, 5:(), 6:, 7:8:
*/
private Integer valueType;
/**
* 3:4:, "0":"整数","1":"小数",
* 0,(0://, 1:/)
*/
private Integer optionType;
/**
* (0:1, null:)24:
*/
private Integer valueNumberOption;
/**
* -1
* ,validPeriodType使
*/
private Integer validPeriod;
/**
* (0:, 1:, 2:,-1:)
*/
private Integer validPeriodType;
private List<String> displayTagValue;
private String markTime;
/**
*
*/
private List<String> tagValue;
/**
*
*/
private List<childTag> childTags;
public class childTag {
private String instanceName;
private List<ShuYunTagResponse> tags;
public childTag() {
}
public childTag(String instanceName, List<ShuYunTagResponse> tags) {
this.instanceName = instanceName;
this.tags = tags;
}
public String getInstanceName() {
return instanceName;
}
public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}
public List<ShuYunTagResponse> getTags() {
return tags;
}
public void setTags(List<ShuYunTagResponse> tags) {
this.tags = tags;
}
}
public ShuYunTagResponse() {
}
public ShuYunTagResponse(Integer tagId, String tagName, String tagType, Integer valueType, Integer optionType, Integer valueNumberOption, Integer validPeriod, Integer validPeriodType, List<String> displayTagValue, String markTime, List<String> tagValue, List<childTag> childTags) {
this.tagId = tagId;
this.tagName = tagName;
this.tagType = tagType;
this.valueType = valueType;
this.optionType = optionType;
this.valueNumberOption = valueNumberOption;
this.validPeriod = validPeriod;
this.validPeriodType = validPeriodType;
this.displayTagValue = displayTagValue;
this.markTime = markTime;
this.tagValue = tagValue;
this.childTags = childTags;
}
public Integer getTagId() {
return tagId;
}
public void setTagId(Integer tagId) {
this.tagId = tagId;
}
public String getTagName() {
return tagName;
}
public void setTagName(String tagName) {
this.tagName = tagName;
}
public String getTagType() {
return tagType;
}
public void setTagType(String tagType) {
this.tagType = tagType;
}
public Integer getValueType() {
return valueType;
}
public void setValueType(Integer valueType) {
this.valueType = valueType;
}
public Integer getOptionType() {
return optionType;
}
public void setOptionType(Integer optionType) {
this.optionType = optionType;
}
public Integer getValueNumberOption() {
return valueNumberOption;
}
public void setValueNumberOption(Integer valueNumberOption) {
this.valueNumberOption = valueNumberOption;
}
public Integer getValidPeriod() {
return validPeriod;
}
public void setValidPeriod(Integer validPeriod) {
this.validPeriod = validPeriod;
}
public Integer getValidPeriodType() {
return validPeriodType;
}
public void setValidPeriodType(Integer validPeriodType) {
this.validPeriodType = validPeriodType;
}
public List<String> getDisplayTagValue() {
return displayTagValue;
}
public void setDisplayTagValue(List<String> displayTagValue) {
this.displayTagValue = displayTagValue;
}
public String getMarkTime() {
return markTime;
}
public void setMarkTime(String markTime) {
this.markTime = markTime;
}
public List<String> getTagValue() {
return tagValue;
}
public void setTagValue(List<String> tagValue) {
this.tagValue = tagValue;
}
public List<childTag> getChildTags() {
return childTags;
}
public void setChildTags(List<childTag> childTags) {
this.childTags = childTags;
}
}

@ -0,0 +1,38 @@
package com.flossom.common.core.domain.shuyun;
public class ShuYunTagValue {
/**
* ID
*/
private Integer itemId;
/**
*
*/
private String itemVal;
public ShuYunTagValue() {
}
public ShuYunTagValue(Integer itemId, String itemVal) {
this.itemId = itemId;
this.itemVal = itemVal;
}
public Integer getItemId() {
return itemId;
}
public void setItemId(Integer itemId) {
this.itemId = itemId;
}
public String getItemVal() {
return itemVal;
}
public void setItemVal(String itemVal) {
this.itemVal = itemVal;
}
}

@ -4,22 +4,25 @@ import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
*
*
*/
public class ShuYunUserTag {
public class ShuYunUserTagCallbackReq {
@NotBlank(message = "外部标签ID不能为空")
private String tagId;
/**
* unionId
*/
@NotBlank(message = "会员信息不能为空")
private String platAccount;
private Date addTime;
public ShuYunUserTag() {
public ShuYunUserTagCallbackReq() {
}
public ShuYunUserTag(String tagId, String platAccount, Date addTime) {
public ShuYunUserTagCallbackReq(String tagId, String platAccount, Date addTime) {
this.tagId = tagId;
this.platAccount = platAccount;
this.addTime = addTime;

@ -0,0 +1,139 @@
package com.flossom.common.core.domain.shuyun;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;
/**
*
*/
public class ShuYunUserTagReq<T> {
/**
* CODE
*/
private String platCode;
/**
* ID
*/
private String shopId;
/**
* ,unionId
*/
private String platAccount;
/**
* ID
*/
private Integer tagId;
/**
* /(0://, 1:/)
*/
private List<T> tagValue;
/**
*
*/
private List<ShuYunUserTagReq<T>> tagsMark;
/**
* OUTER_SYSTEM
*/
private String markScene;
/**
* ID
*/
private Integer parentTagId;
/**
*
*/
private String instanceName;
public ShuYunUserTagReq() {
}
public ShuYunUserTagReq(String platCode, String shopId, String platAccount, Integer tagId, List<T> tagValue) {
this.platCode = platCode;
this.shopId = shopId;
this.platAccount = platAccount;
this.tagId = tagId;
this.tagValue = tagValue;
}
public ShuYunUserTagReq(String platCode, String shopId, String platAccount, List<ShuYunUserTagReq<T>> tagsMark) {
this.platCode = platCode;
this.shopId = shopId;
this.platAccount = platAccount;
this.tagsMark = tagsMark;
}
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 getPlatAccount() {
return platAccount;
}
public void setPlatAccount(String platAccount) {
this.platAccount = platAccount;
}
public Integer getTagId() {
return tagId;
}
public void setTagId(Integer tagId) {
this.tagId = tagId;
}
public List<T> getTagValue() {
return tagValue;
}
public void setTagValue(List<T> tagValue) {
this.tagValue = tagValue;
}
public String getMarkScene() {
return markScene;
}
public void setMarkScene(String markScene) {
this.markScene = markScene;
}
public Integer getParentTagId() {
return parentTagId;
}
public void setParentTagId(Integer parentTagId) {
this.parentTagId = parentTagId;
}
public String getInstanceName() {
return instanceName;
}
public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}
public List<ShuYunUserTagReq<T>> getTagsMark() {
return tagsMark;
}
public void setTagsMark(List<ShuYunUserTagReq<T>> tagsMark) {
this.tagsMark = tagsMark;
}
}

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSONObject;
import com.flossom.common.core.domain.entity.*;
import com.flossom.common.core.domain.req.WxNursingLogReq;
import com.flossom.common.core.domain.ret.WxNursingStatisticsRet;
@ -20,6 +21,8 @@ import com.flossom.common.core.utils.StringUtils;
import com.flossom.common.security.utils.DictUtils;
import com.flossom.common.security.utils.SecurityUtils;
import com.flossom.miniProgram.service.IWxNursingLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -33,6 +36,8 @@ import org.springframework.stereotype.Service;
@Service
public class WxNursingLogServiceImpl implements IWxNursingLogService {
protected final static Logger logger = LoggerFactory.getLogger(WxNursingLogServiceImpl.class);
@Autowired
private WxNursingLogMapper wxNursingLogMapper;
@ -82,7 +87,7 @@ public class WxNursingLogServiceImpl implements IWxNursingLogService {
if (instrumentId != null) {
wxNursingLog.setInstrumentId(instrumentId);
}
if(queryDate != null) {
if (queryDate != null) {
wxNursingLog.getParams().put("endTime", queryDate);
}
wxNursingLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
@ -160,6 +165,38 @@ public class WxNursingLogServiceImpl implements IWxNursingLogService {
}
}
}
/**
* FR200
*/
if (StringUtils.equals(wxInstrument.getModel(), "FR200")) {
WxMode wxMode = wxModeMapper.selectWxModeById(wxNursingLogReq.getModeId());
if (wxMode == null) {
logger.error("模式ID{} 查询数据为空", wxNursingLogReq.getModeId());
throw new ServiceException("请求数据有误");
}
String modeType = wxMode.getModeType();
// 水分测试
if (StringUtils.equals(modeType, "moistureTest")) {
updateNursingLog.setNursingData(wxNursingLogReq.getNursingData());
}
// 能量图谱
if (StringUtils.equals(modeType, "face") || StringUtils.equals(modeType, "eyes")
|| StringUtils.equals(modeType, "nasolabialFold") || StringUtils.equals(modeType, "mandibularLine")
|| StringUtils.equals(modeType, "headLiftingPro")) {
String nursingData = wxNursingLog.getNursingData();
if (StringUtils.isBlank(nursingData)) {
updateNursingLog.setNursingData(wxNursingLogReq.getNursingData());
} else {
JSONObject nursingDatajsonObject = JSONObject.parseObject(nursingData);
Object o = (Object[])nursingDatajsonObject.get("GearData");
if (nursingDatajsonObject.get("GearData") != null) {
}
}
}
}
updateNursingLog.setId(wxNursingLog.getId());
updateNursingLog.setUpdateBy(SecurityUtils.getLoginUser().getWxUserMember().getNickname());
updateNursingLog.setUpdateTime(DateUtils.getNowDate());

@ -4,8 +4,8 @@ import com.alibaba.fastjson.JSON;
import com.flossom.common.core.constant.CacheConstants;
import com.flossom.common.core.domain.R;
import com.flossom.common.core.domain.shuyun.AccessToken;
import com.flossom.common.core.domain.shuyun.ShuYunTagCreate;
import com.flossom.common.core.domain.shuyun.ShuYunUserTag;
import com.flossom.common.core.domain.shuyun.ShuYunTagCreateCallbackReq;
import com.flossom.common.core.domain.shuyun.ShuYunUserTagCallbackReq;
import com.flossom.common.redis.service.RedisService;
import com.flossom.system.service.IShuYunService;
import com.flossom.system.utils.shuyun.ShuYunConfig;
@ -69,21 +69,21 @@ public class ShuYunController {
}
@PostMapping(value = "/tagCreate")
public R tagCreate(@RequestBody ShuYunTagCreate shuYunTagCreate) {
public R tagCreate(@RequestBody ShuYunTagCreateCallbackReq shuYunTagCreate) {
logger.info("数云新增标签: {}", JSON.toJSONString(shuYunTagCreate));
shuYunService.tagCreate(shuYunTagCreate);
return R.ok();
}
@PostMapping(value = "markUserTag/")
public R markUserTag(@RequestBody ShuYunUserTag shuYunUserTag) {
public R markUserTag(@RequestBody ShuYunUserTagCallbackReq shuYunUserTag) {
logger.info("数云标记用户标签: {}", JSON.toJSONString(shuYunUserTag));
shuYunService.markUserTag(shuYunUserTag);
return R.ok();
}
@PostMapping(value = "delUserTag/")
public R delUserTag(@RequestBody ShuYunUserTag shuYunUserTag) {
public R delUserTag(@RequestBody ShuYunUserTagCallbackReq shuYunUserTag) {
logger.info("数云删除用户标签: {}", JSON.toJSONString(shuYunUserTag));
shuYunService.delUserTag(shuYunUserTag);
return R.ok();

@ -1,12 +1,12 @@
package com.flossom.system.service;
import com.flossom.common.core.domain.shuyun.ShuYunTagCreate;
import com.flossom.common.core.domain.shuyun.ShuYunUserTag;
import com.flossom.common.core.domain.shuyun.ShuYunTagCreateCallbackReq;
import com.flossom.common.core.domain.shuyun.ShuYunUserTagCallbackReq;
public interface IShuYunService {
void tagCreate(ShuYunTagCreate shuYunTagCreate);
void tagCreate(ShuYunTagCreateCallbackReq shuYunTagCreate);
void markUserTag(ShuYunUserTag shuYunUserTag);
void markUserTag(ShuYunUserTagCallbackReq shuYunUserTag);
void delUserTag(ShuYunUserTag shuYunUserTag);
void delUserTag(ShuYunUserTagCallbackReq shuYunUserTag);
}

@ -2,8 +2,8 @@ package com.flossom.system.service.impl;
import com.flossom.common.core.domain.entity.SysTag;
import com.flossom.common.core.domain.entity.WxUserMember;
import com.flossom.common.core.domain.shuyun.ShuYunTagCreate;
import com.flossom.common.core.domain.shuyun.ShuYunUserTag;
import com.flossom.common.core.domain.shuyun.ShuYunTagCreateCallbackReq;
import com.flossom.common.core.domain.shuyun.ShuYunUserTagCallbackReq;
import com.flossom.common.core.enums.Status;
import com.flossom.common.core.exception.ServiceException;
import com.flossom.common.core.mapper.SysTagMapper;
@ -33,7 +33,7 @@ public class ShuYunServiceImpl implements IShuYunService {
private IWxUserMemberService wxUserMemberService;
@Override
public void tagCreate(ShuYunTagCreate shuYunTagCreate) {
public void tagCreate(ShuYunTagCreateCallbackReq shuYunTagCreate) {
SysTag sysTag = new SysTag();
sysTag.setTagName(shuYunTagCreate.getTagName());
SysTag parentTag = sysTagMapper.selectDeptById(1L);
@ -54,7 +54,7 @@ public class ShuYunServiceImpl implements IShuYunService {
}
@Override
public void markUserTag(ShuYunUserTag shuYunUserTag) {
public void markUserTag(ShuYunUserTagCallbackReq shuYunUserTag) {
// 查询会员信息
WxUserMember wxUserMember = wxUserMemberMapper.selectUserMemberByUnionId(shuYunUserTag.getPlatAccount());
if (wxUserMember == null) {
@ -71,7 +71,7 @@ public class ShuYunServiceImpl implements IShuYunService {
}
@Override
public void delUserTag(ShuYunUserTag shuYunUserTag) {
public void delUserTag(ShuYunUserTagCallbackReq shuYunUserTag) {
// 查询会员信息
WxUserMember wxUserMember = wxUserMemberMapper.selectUserMemberByUnionId(shuYunUserTag.getPlatAccount());
if (wxUserMember == null) {

@ -70,23 +70,15 @@ public class ActionMethod {
/**
*
*/
private String markUserTagCreate;
/**
*
*/
private String batchMarkUserTagCreate;
private String markUserTag;
/**
*
*/
private String markUserTagDelete;
/**
*
*/
private String batchMarkUserTagDelete;
private String deleteUserTag;
/**
*
*/
private String markUserTagSearch;
private String searchUserTag;
public String getAccessToken() {
return accessToken;
@ -192,43 +184,27 @@ public class ActionMethod {
this.tagUpdate = tagUpdate;
}
public String getMarkUserTagCreate() {
return markUserTagCreate;
}
public void setMarkUserTagCreate(String markUserTagCreate) {
this.markUserTagCreate = markUserTagCreate;
}
public String getBatchMarkUserTagCreate() {
return batchMarkUserTagCreate;
}
public void setBatchMarkUserTagCreate(String batchMarkUserTagCreate) {
this.batchMarkUserTagCreate = batchMarkUserTagCreate;
}
public String getMarkUserTagDelete() {
return markUserTagDelete;
public String getMarkUserTag() {
return markUserTag;
}
public void setMarkUserTagDelete(String markUserTagDelete) {
this.markUserTagDelete = markUserTagDelete;
public void setMarkUserTag(String markUserTag) {
this.markUserTag = markUserTag;
}
public String getBatchMarkUserTagDelete() {
return batchMarkUserTagDelete;
public String getDeleteUserTag() {
return deleteUserTag;
}
public void setBatchMarkUserTagDelete(String batchMarkUserTagDelete) {
this.batchMarkUserTagDelete = batchMarkUserTagDelete;
public void setDeleteUserTag(String deleteUserTag) {
this.deleteUserTag = deleteUserTag;
}
public String getMarkUserTagSearch() {
return markUserTagSearch;
public String getSearchUserTag() {
return searchUserTag;
}
public void setMarkUserTagSearch(String markUserTagSearch) {
this.markUserTagSearch = markUserTagSearch;
public void setSearchUserTag(String searchUserTag) {
this.searchUserTag = searchUserTag;
}
}

@ -1,7 +1,9 @@
package com.flossom.system.utils.shuyun;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.flossom.common.core.constant.CacheConstants;
import com.flossom.common.core.domain.R;
@ -19,6 +21,7 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import java.util.Map;
@ -57,22 +60,23 @@ public class ShuYunApiUtils {
public static final int SUCCESS = 10000;
/**
*
*
*
*/
public static final int HALF_SUCCESS = 14000;
}
/**
* accessTokenaccessToken
* accessTokenaccessToken
*/
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);
logger.info("刷新 accessToken 地址:{}", accessTokenUrl);
try {
String result = HttpClientUtils.get(accessTokenUrl);
logger.info("请求数云接口获取accessToken结果{}", result);
logger.info("请求数云接口获取 accessToken 结果:{}", result);
R r = JSON.parseObject(result, R.class);
if (r.getCode() != R.SUCCESS) {
logger.error("请求数云接口获取accessToken失败将直接使用旧的accessToken失败原因{}", result);
@ -87,31 +91,27 @@ public class ShuYunApiUtils {
return accessToken.getAccessToken();
}
/**
* redis
* redis
*/
logger.error("从redis获取数云accessToken失败缓存中没有accessToken有可能是第一次调用");
throw new ServiceException("从redis获取数云accessToken失败缓存中没有accessToken有可能是第一次调用");
logger.error("从 redis 获取数云 accessToken 失败,缓存中没有 accessToken有可能是第一次调用");
throw new ServiceException("从 redis 获取数云 accessToken 失败,缓存中没有 accessToken有可能是第一次调用");
}
/**
*
*
* @param httpMethod
* @param requestParams geturl
* @param requestBody postput
* @param actionMethod
* @param httpMethod
* @param queryParams geturl
* @param bodyParams postput
* @param actionMethod
*/
public static R shuYunHttpRequest(HttpMethod httpMethod, Map requestParams, String requestBody, String actionMethod) throws ServiceException {
logger.info("数云接口请求地址:{},参数:requestParams = {}、requestBody = {}", actionMethod, requestParams, requestBody);
public static R shuYunHttpRequest(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(),
requestParams,
requestBody,
shuYunConfig.getAppid(),
shuYunConfig.getSecurity(),
getAccessToken(),
actionMethod);
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) {
@ -122,13 +122,21 @@ public class ShuYunApiUtils {
}
}
public static R shuYunHttpRequest(HttpMethod httpMethod, Map queryParams, String actionMethod) throws ServiceException {
return shuYunHttpRequest(httpMethod, queryParams, null, actionMethod);
}
public static R shuYunHttpRequest(HttpMethod httpMethod, String bodyParams, String actionMethod) throws ServiceException {
return shuYunHttpRequest(httpMethod, null, bodyParams, actionMethod);
}
/**
*
*/
public static void registerMember(ShuYunMember member) {
try {
shuYunHttpRequest(HttpMethod.POST, null, JSON.toJSONString(member),
shuYunHttpRequest(HttpMethod.POST, null, member,
shuYunConfig.getActionMethod().getRegisterMember());
} catch (Exception e) {
logger.error("请求数云接口注册会员失败:{}", e.getMessage());
@ -141,7 +149,7 @@ public class ShuYunApiUtils {
*/
public static ShuYunMember queryMember(ShuYunMember member) {
try {
R r = shuYunHttpRequest(HttpMethod.POST, null, JSON.toJSONString(member),
R r = shuYunHttpRequest(HttpMethod.POST, null, member,
shuYunConfig.getActionMethod().getQueryMember());
if (r.getCode() == ShuYunHttpStatusConstants.SUCCESS) {
return JSON.parseObject(r.getData().toString(), ShuYunMember.class);
@ -163,7 +171,7 @@ public class ShuYunApiUtils {
*/
public static void modifyMember(ShuYunMember member) {
try {
shuYunHttpRequest(HttpMethod.PUT, null, JSON.toJSONString(member),
shuYunHttpRequest(HttpMethod.PUT, null, member,
shuYunConfig.getActionMethod().getModifyMember());
} catch (Exception e) {
logger.error("请求数云接口-修改会员信息(除手机号)失败:{}", e.getMessage());
@ -176,7 +184,7 @@ public class ShuYunApiUtils {
*/
public static void modifyMemberMobile(ShuYunMember member) {
try {
shuYunHttpRequest(HttpMethod.PUT, null, JSON.toJSONString(member),
shuYunHttpRequest(HttpMethod.PUT, null, member,
shuYunConfig.getActionMethod().getModifyMemberMobile());
} catch (Exception e) {
logger.error("请求数云接口-修改会员手机号失败:{}", e.getMessage());
@ -189,7 +197,7 @@ public class ShuYunApiUtils {
*/
public static void unbindMember(ShuYunMember member) {
try {
shuYunHttpRequest(HttpMethod.POST, null, JSON.toJSONString(member),
shuYunHttpRequest(HttpMethod.POST, null, member,
shuYunConfig.getActionMethod().getUnbindMember());
} catch (Exception e) {
logger.error("请求数云接口-解绑会员失败:{}", e.getMessage());
@ -202,7 +210,7 @@ public class ShuYunApiUtils {
*/
public static void pointChange(ShuYunPointChange shuYunPointChange) {
try {
shuYunHttpRequest(HttpMethod.POST, null, JSON.toJSONString(shuYunPointChange),
shuYunHttpRequest(HttpMethod.POST, null, shuYunPointChange,
shuYunConfig.getActionMethod().getPointChange());
} catch (Exception e) {
logger.error("请求数云接口-会员积分变更失败:{}", e.getMessage());
@ -225,7 +233,8 @@ public class ShuYunApiUtils {
if (r.getCode() != ShuYunHttpStatusConstants.SUCCESS) {
logger.error("请求数云接口-会员积分变更记录查询失败:{}", r.getMsg());
}
return JSON.parseObject(r.getData().toString(), new TypeReference<ShuYunPageUtil<ShuYunPointChangeLog>>(){});
return JSON.parseObject(r.getData().toString(), new TypeReference<ShuYunPageUtil<ShuYunPointChangeLog>>() {
});
} catch (Exception e) {
logger.error("请求数云接口-会员积分变更记录查询失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-会员积分变更记录查询失败");
@ -257,21 +266,35 @@ public class ShuYunApiUtils {
/**
*
*/
public static void tagCreate(ShuYunTag shuYunTag) {
public static String tagCreate(ShuYunTag shuYunTag) {
try {
R r = shuYunHttpRequest(HttpMethod.POST, null, JSON.toJSONString(shuYunTag),
R r = shuYunHttpRequest(HttpMethod.POST, null, shuYunTag,
shuYunConfig.getActionMethod().getTagCreate());
if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) {
logger.error("请求数云接口-创建标签失败:{}", r.getMsg());
throw new ServiceException("请求数云接口-创建标签失败");
}
if (r.getData() != null) {
JSONObject map = (JSONObject) r.getData();
return String.valueOf(map.get("tagId"));
}
return null;
} catch (Exception e) {
logger.error("请求数云接口-创建标签失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-创建标签失败");
}
}
public static void tagSearch(Map params) {
/**
*
*
* @param type 1()
* @param allValueType true()false()
*/
public static List<ShuYunGroupTag> tagSearch(String type, String allValueType) {
Map<String, String> params = MapUtil.newHashMap();
params.put("type", type);
params.put("allValueType", allValueType);
try {
R r = shuYunHttpRequest(HttpMethod.GET, params, null,
shuYunConfig.getActionMethod().getTagSearch());
@ -279,11 +302,121 @@ public class ShuYunApiUtils {
logger.error("请求数云接口-创建标签失败:{}", r.getMsg());
throw new ServiceException("请求数云接口-创建标签失败");
}
return JSON.parseObject(r.getData().toString(), new TypeReference<List<ShuYunGroupTag>>() {
});
} catch (Exception e) {
logger.error("请求数云接口-创建标签失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-创建标签失败");
}
}
/**
*
*/
public static void tagDelete(String tagId) {
Map<String, String> params = MapUtil.newHashMap();
params.put("tagId", tagId);
try {
R r = shuYunHttpRequest(HttpMethod.DELETE, null, params,
shuYunConfig.getActionMethod().getTagDelete());
if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) {
logger.error("请求数云接口-删除标签失败:{}", r.getMsg());
throw new ServiceException("请求数云接口-删除标签失败");
}
} catch (Exception e) {
logger.error("请求数云接口-删除标签失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-删除标签失败");
}
}
/**
*
*/
public static void tagUpdate(ShuYunTag shuYunTag) {
try {
R r = shuYunHttpRequest(HttpMethod.PUT, null, shuYunTag,
shuYunConfig.getActionMethod().getTagUpdate());
if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) {
logger.error("请求数云接口-修改标签失败:{}", r.getMsg());
throw new ServiceException("请求数云接口-修改标签失败");
}
} catch (Exception e) {
logger.error("请求数云接口-修改标签失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-修改标签失败");
}
}
/**
*
*/
public static void markUserTag(ShuYunUserTagReq shuYunUserTagReq) {
try {
R r = shuYunHttpRequest(HttpMethod.POST, null, shuYunUserTagReq,
shuYunConfig.getActionMethod().getMarkUserTag());
if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) {
logger.error("请求数云接口-给客户打上单个标签失败:{}", r.getMsg());
throw new ServiceException("请求数云接口-给客户打上单个标签失败");
}
} catch (Exception e) {
logger.error("请求数云接口-给客户打上单个标签失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-给客户打上单个标签失败");
}
}
/**
*
*/
public static List<ShuYunTagResponse> searchUserTag(String tagType, String platCode, String shopId, String platAccount, String allValueType) {
Map<String, Object> 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 = shuYunHttpRequest(HttpMethod.GET, params, null,
shuYunConfig.getActionMethod().getSearchUserTag());
if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) {
logger.error("请求数云接口-查询客户已经被打上的标签失败:{}", r.getMsg());
throw new ServiceException("请求数云接口-查询客户已经被打上的标签标签失败");
}
return JSON.parseObject(r.getData().toString(), new TypeReference<List<ShuYunTagResponse>>() {
});
} catch (Exception e) {
logger.error("请求数云接口-查询客户已经被打上的标签失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-查询客户已经被打上的标签失败");
}
}
/**
*
*/
public static void deleteUserTag(String platCode, String shopId, String platAccount, Integer tagId) {
Map<String, Object> 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 = shuYunHttpRequest(HttpMethod.DELETE, null, params,
shuYunConfig.getActionMethod().getDeleteUserTag());
if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) {
logger.error("请求数云接口-删除客户已经被打上的标签失败:{}", r.getMsg());
throw new ServiceException("请求数云接口-删除客户已经被打上的标签失败");
}
} catch (Exception e) {
logger.error("请求数云接口-删除客户已经被打上的标签失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-删除客户已经被打上的标签失败");
}
}
}

Loading…
Cancel
Save