数云接口对接

master
382696293@qq.com 2 years ago
parent 635f8fb43a
commit 5936caef59

@ -50,6 +50,34 @@ public class ShuYunMember {
*/
private String guideId;
/**
*
*/
private String gainedPoint;
/**
*
*/
private String point;
/**
*
*/
private String expiredPoint;
/**
*
*/
private String consumedPoint;
/**
* ID
*/
private String memberId;
public ShuYunMember() {
}
@ -81,6 +109,9 @@ public class ShuYunMember {
this.shopId = shopId;
}
/**
*
*/
public ShuYunMember(String id, String platCode, String shopId, String mobile) {
this.id = id;
this.platCode = platCode;
@ -171,4 +202,64 @@ public class ShuYunMember {
public void setGuideId(String guideId) {
this.guideId = guideId;
}
public String getGainedPoint() {
return gainedPoint;
}
public void setGainedPoint(String gainedPoint) {
this.gainedPoint = gainedPoint;
}
public String getPoint() {
return point;
}
public void setPoint(String point) {
this.point = point;
}
public String getExpiredPoint() {
return expiredPoint;
}
public void setExpiredPoint(String expiredPoint) {
this.expiredPoint = expiredPoint;
}
public String getConsumedPoint() {
return consumedPoint;
}
public void setConsumedPoint(String consumedPoint) {
this.consumedPoint = consumedPoint;
}
public String getMemberId() {
return memberId;
}
public void setMemberId(String memberId) {
this.memberId = memberId;
}
@Override
public String toString() {
return "ShuYunMember{" +
"id='" + id + '\'' +
", platCode='" + platCode + '\'' +
", shopId='" + shopId + '\'' +
", name='" + name + '\'' +
", mobile='" + mobile + '\'' +
", birthday='" + birthday + '\'' +
", gender='" + gender + '\'' +
", created='" + created + '\'' +
", guideId='" + guideId + '\'' +
", gainedPoint='" + gainedPoint + '\'' +
", point='" + point + '\'' +
", expiredPoint='" + expiredPoint + '\'' +
", consumedPoint='" + consumedPoint + '\'' +
", memberId='" + memberId + '\'' +
'}';
}
}

@ -0,0 +1,122 @@
package com.flossom.common.core.domain.shuyun;
public class ShuYunPageReq {
/**
*
*/
private String id;
/**
* ID
*/
private String memberId;
/**
*
*/
private String platCode;
/**
*
*/
private String shopId;
/**
*
*/
private String pageSize;
/**
*
*/
private String currentPage;
/**
* yyyy-MM-dd HH:mm:ss
*/
private String startCreated;
/**
* yyyy-MM-dd HH:mm:ss
*/
private String endCreated;
public ShuYunPageReq() {
}
public ShuYunPageReq(String id, String platCode, String shopId, String pageSize, String currentPage) {
this.id = id;
this.platCode = platCode;
this.shopId = shopId;
this.pageSize = pageSize;
this.currentPage = currentPage;
}
public ShuYunPageReq(String id, String memberId, String platCode, String shopId, String pageSize, String currentPage, String startCreated, String endCreated) {
this.id = id;
this.memberId = memberId;
this.platCode = platCode;
this.shopId = shopId;
this.pageSize = pageSize;
this.currentPage = currentPage;
this.startCreated = startCreated;
this.endCreated = endCreated;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getMemberId() {
return memberId;
}
public void setMemberId(String memberId) {
this.memberId = memberId;
}
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 getStartCreated() {
return startCreated;
}
public void setStartCreated(String startCreated) {
this.startCreated = startCreated;
}
public String getEndCreated() {
return endCreated;
}
public void setEndCreated(String endCreated) {
this.endCreated = endCreated;
}
public String getPageSize() {
return pageSize;
}
public void setPageSize(String pageSize) {
this.pageSize = pageSize;
}
public String getCurrentPage() {
return currentPage;
}
public void setCurrentPage(String currentPage) {
this.currentPage = currentPage;
}
}

@ -0,0 +1,79 @@
package com.flossom.common.core.domain.shuyun;
import java.util.List;
public class ShuYunPageUtil<T> {
/**
*
*/
private int totalPageCount;
/**
*
*/
private int totals;
/**
*
*/
private int pageSize = 10;
/**
*
*/
private int pageNum = 1;
/**
*
*/
private List<T> list;
public ShuYunPageUtil() {
}
public ShuYunPageUtil(int totals, int pageSize, int pageNum, List<T> list) {
this.totals = totals;
this.pageSize = pageSize;
this.pageNum = pageNum;
this.list = list;
}
public int getTotalPageCount() {
return totalPageCount;
}
public void setTotalPageCount(int totalPageCount) {
this.totalPageCount = totalPageCount;
}
public int getTotals() {
return totals;
}
public void setTotals(int totals) {
this.totals = totals;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
}

@ -101,6 +101,12 @@ public class ShuYunPointChange {
this.desc = desc;
}
public ShuYunPointChange(String id, String platCode, String shopId) {
this.id = id;
this.platCode = platCode;
this.shopId = shopId;
}
public String getId() {
return id;
}

@ -0,0 +1,249 @@
package com.flossom.common.core.domain.shuyun;
/**
*
*/
public class ShuYunPointChangeLog {
/**
*
*/
private String id;
/**
* yyyy-MM-dd HH:mm:ss
*/
private String created;
/**
*
*/
private String source;
/**
* changeType
*/
private String partnerSequence;
/**
*
*/
private String changePoint;
/**
*
*/
private String version;
private String operator;
/**
*
*/
private String point;
private String changeTime;
/**
* ID
*/
private String recordId;
private String platCode;
/**
* changeType
*/
private String sequence;
/**
* yyyy-MM-dd HH:mm:ss
*/
private String expired;
/**
*
*/
private String partner;
private String ouid;
/**
* ID
*/
private String shopId;
/**
*
*/
private String desc;
/**
* ID
*/
private String memberId;
/**
* ,
*/
private String changeType;
public ShuYunPointChangeLog() {
}
public ShuYunPointChangeLog(String id, String created, String source, String partnerSequence, String changePoint, String version, String operator, String point, String changeTime, String recordId, String platCode, String sequence, String expired, String partner, String ouid, String shopId, String desc, String memberId, String changeType) {
this.id = id;
this.created = created;
this.source = source;
this.partnerSequence = partnerSequence;
this.changePoint = changePoint;
this.version = version;
this.operator = operator;
this.point = point;
this.changeTime = changeTime;
this.recordId = recordId;
this.platCode = platCode;
this.sequence = sequence;
this.expired = expired;
this.partner = partner;
this.ouid = ouid;
this.shopId = shopId;
this.desc = desc;
this.memberId = memberId;
this.changeType = changeType;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getPartnerSequence() {
return partnerSequence;
}
public void setPartnerSequence(String partnerSequence) {
this.partnerSequence = partnerSequence;
}
public String getChangePoint() {
return changePoint;
}
public void setChangePoint(String changePoint) {
this.changePoint = changePoint;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public String getPoint() {
return point;
}
public void setPoint(String point) {
this.point = point;
}
public String getChangeTime() {
return changeTime;
}
public void setChangeTime(String changeTime) {
this.changeTime = changeTime;
}
public String getRecordId() {
return recordId;
}
public void setRecordId(String recordId) {
this.recordId = recordId;
}
public String getPlatCode() {
return platCode;
}
public void setPlatCode(String platCode) {
this.platCode = platCode;
}
public String getSequence() {
return sequence;
}
public void setSequence(String sequence) {
this.sequence = sequence;
}
public String getExpired() {
return expired;
}
public void setExpired(String expired) {
this.expired = expired;
}
public String getPartner() {
return partner;
}
public void setPartner(String partner) {
this.partner = partner;
}
public String getOuid() {
return ouid;
}
public void setOuid(String ouid) {
this.ouid = ouid;
}
public String getShopId() {
return shopId;
}
public void setShopId(String shopId) {
this.shopId = shopId;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getMemberId() {
return memberId;
}
public void setMemberId(String memberId) {
this.memberId = memberId;
}
public String getChangeType() {
return changeType;
}
public void setChangeType(String changeType) {
this.changeType = changeType;
}
}

@ -0,0 +1,142 @@
package com.flossom.common.core.domain.shuyun;
public class ShuYunTag {
/**
* id
*/
private Integer groupId;
/**
*
*/
private String tagName;
/**
* 0, 1(), 2:, 3:, 4:, 5:(), 6:, 7:8:
*/
private Integer valueType;
/**
* (0://, 1:/)
* 34, "0":"整数","1":"小数",
*/
private Integer optionType;
/**
*
* (24
*/
private String optionalValues;
/**
* 24(0:1)
*/
private Integer valueNumberOption;
/**
* -1
* ,validPeriodType使
*/
private Integer validPeriod;
/**
* (0:, 1:, 2:,-1:)
*/
private Integer validPeriodType;
/**
*
*/
private String description;
public ShuYunTag() {
}
public ShuYunTag(Integer groupId, String tagName, Integer valueType, Integer optionType, Integer valueNumberOption, Integer validPeriod, Integer validPeriodType, String description) {
this.groupId = groupId;
this.tagName = tagName;
this.valueType = valueType;
this.optionType = optionType;
this.valueNumberOption = valueNumberOption;
this.validPeriod = validPeriod;
this.validPeriodType = validPeriodType;
this.description = description;
}
public ShuYunTag(Integer groupId, String tagName, Integer valueType, Integer optionType, String optionalValues, Integer valueNumberOption, Integer validPeriod, Integer validPeriodType, String description) {
this.groupId = groupId;
this.tagName = tagName;
this.valueType = valueType;
this.optionType = optionType;
this.optionalValues = optionalValues;
this.valueNumberOption = valueNumberOption;
this.validPeriod = validPeriod;
this.validPeriodType = validPeriodType;
this.description = description;
}
public Integer getGroupId() {
return groupId;
}
public void setGroupId(Integer groupId) {
this.groupId = groupId;
}
public String getTagName() {
return tagName;
}
public void setTagName(String tagName) {
this.tagName = tagName;
}
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 String getOptionalValues() {
return optionalValues;
}
public void setOptionalValues(String optionalValues) {
this.optionalValues = optionalValues;
}
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 String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

@ -0,0 +1,45 @@
package com.flossom.common.core.enums;
/**
* {@link com.flossom.common.core.domain.shuyun.ShuYunPointChange#source}
*
* TRADE:
* REFUND:退
* SERVICE:
* CONSUME:
* EXPIRE:
* IMPORT:
* MALL:
* BRAND:
* OTHER
*/
public enum ShuYunPointSourceEnum {
TRADE("TRADE", "订单赠送"),
REFUND("REFUND", "退单扣减"),
SERVICE("SERVICE", "客服"),
CONSUME("CONSUME", "消费"),
EXPIRE("EXPIRE", "过期"),
IMPORT("IMPORT", "导入"),
MALL("MALL", "手淘互动"),
BRAND("BRAND", "会员通"),
OTHER("OTHER", "其他"),
;
private final String source;
private final String info;
ShuYunPointSourceEnum(String source, String info) {
this.source = source;
this.info = info;
}
public String getSource() {
return source;
}
public String getInfo() {
return info;
}
}

@ -11,17 +11,17 @@ public class ActionMethod {
private String accessToken;
/**
*
*
*/
private String queryMember;
/**
*
*
*/
private String registerMember;
/**
*
*
*/
private String modifyMember;
@ -40,6 +40,54 @@ public class ActionMethod {
*/
private String pointChange;
/**
*
*/
private String pointChangeLogSearch;
/**
*
*/
private String pointWillDueSearch;
/**
*
*/
private String tagCreate;
/**
*
*/
private String tagDelete;
/**
*
*/
private String tagSearch;
/**
*
*/
private String tagUpdate;
/**
*
*/
private String markUserTagCreate;
/**
*
*/
private String batchMarkUserTagCreate;
/**
*
*/
private String markUserTagDelete;
/**
*
*/
private String batchMarkUserTagDelete;
/**
*
*/
private String markUserTagSearch;
public String getAccessToken() {
return accessToken;
}
@ -95,4 +143,92 @@ public class ActionMethod {
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 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 void setMarkUserTagDelete(String markUserTagDelete) {
this.markUserTagDelete = markUserTagDelete;
}
public String getBatchMarkUserTagDelete() {
return batchMarkUserTagDelete;
}
public void setBatchMarkUserTagDelete(String batchMarkUserTagDelete) {
this.batchMarkUserTagDelete = batchMarkUserTagDelete;
}
public String getMarkUserTagSearch() {
return markUserTagSearch;
}
public void setMarkUserTagSearch(String markUserTagSearch) {
this.markUserTagSearch = markUserTagSearch;
}
}

@ -1,11 +1,11 @@
package com.flossom.system.utils.shuyun;
import cn.hutool.core.bean.BeanUtil;
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.AccessToken;
import com.flossom.common.core.domain.shuyun.ShuYunMember;
import com.flossom.common.core.domain.shuyun.ShuYunPointChange;
import com.flossom.common.core.domain.shuyun.*;
import com.flossom.common.core.exception.ServiceException;
import com.flossom.common.redis.service.RedisService;
import com.flossom.system.utils.HttpClientUtils;
@ -47,6 +47,21 @@ public class ShuYunApiUtils {
ShuYunApiUtils.redisService = redisService;
}
/**
* httpcode
*/
public class ShuYunHttpStatusConstants {
/**
*
*/
public static final int SUCCESS = 10000;
/**
*
*/
public static final int HALF_SUCCESS = 14000;
}
/**
* accessToken accessToken
*/
@ -63,7 +78,7 @@ public class ShuYunApiUtils {
logger.error("请求数云接口获取accessToken失败将直接使用旧的accessToken失败原因{}", result);
}
} catch (Exception e) {
logger.error("请求数云接口获取accessToken失败将直接使用旧的accessToken失败原因{}", e);
logger.error("请求数云接口获取accessToken失败将直接使用旧的accessToken失败原因{}", e.getMessage());
}
}
String accessTokenStr = redisService.getCacheMapValue(CacheConstants.SHUYUN_ACCESS_TOKEN_CACHE, CacheConstants.SHUYUN_ACCESS_TOKEN_CACHE_VALUE);
@ -99,11 +114,11 @@ public class ShuYunApiUtils {
actionMethod);
logger.info("返回响应:{}", result);
R r = JSON.parseObject(result, R.class);
if (r.getCode() == 10000 || r.getCode() == 14000) {
if (r.getCode() == ShuYunHttpStatusConstants.SUCCESS || r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) {
return r;
} else {
logger.error("调用数云接口发生未知错误:{}", result);
throw new ServiceException("调用数云接口发生未知错误");
throw new ServiceException(r.getMsg());
}
}
@ -116,7 +131,7 @@ public class ShuYunApiUtils {
shuYunHttpRequest(HttpMethod.POST, null, JSON.toJSONString(member),
shuYunConfig.getActionMethod().getRegisterMember());
} catch (Exception e) {
logger.error("请求数云接口注册会员失败:{}", e);
logger.error("请求数云接口注册会员失败:{}", e.getMessage());
throw new ServiceException("请求数云接口注册会员失败");
}
}
@ -128,12 +143,16 @@ public class ShuYunApiUtils {
try {
R r = shuYunHttpRequest(HttpMethod.POST, null, JSON.toJSONString(member),
shuYunConfig.getActionMethod().getQueryMember());
if (r.getCode() == 10000) {
if (r.getCode() == ShuYunHttpStatusConstants.SUCCESS) {
return JSON.parseObject(r.getData().toString(), ShuYunMember.class);
}
return null;
if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) {
return null;
}
logger.error("请求数云接口-会员积分查询失败:{}", r.getMsg());
throw new ServiceException("请求数云接口-会员积分查询失败");
} catch (Exception e) {
logger.error("请求数云接口-查询会员信息失败:{}", e);
logger.error("请求数云接口-查询会员信息失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-查询会员信息失败");
}
}
@ -147,7 +166,7 @@ public class ShuYunApiUtils {
shuYunHttpRequest(HttpMethod.PUT, null, JSON.toJSONString(member),
shuYunConfig.getActionMethod().getModifyMember());
} catch (Exception e) {
logger.error("请求数云接口-修改会员信息(除手机号)失败:{}", e);
logger.error("请求数云接口-修改会员信息(除手机号)失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-修改会员信息(除手机号)失败");
}
}
@ -160,7 +179,7 @@ public class ShuYunApiUtils {
shuYunHttpRequest(HttpMethod.PUT, null, JSON.toJSONString(member),
shuYunConfig.getActionMethod().getModifyMemberMobile());
} catch (Exception e) {
logger.error("请求数云接口-修改会员手机号失败:{}", e);
logger.error("请求数云接口-修改会员手机号失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-修改会员手机号失败");
}
}
@ -173,22 +192,98 @@ public class ShuYunApiUtils {
shuYunHttpRequest(HttpMethod.POST, null, JSON.toJSONString(member),
shuYunConfig.getActionMethod().getUnbindMember());
} catch (Exception e) {
logger.error("请求数云接口-解绑会员失败:{}", e);
logger.error("请求数云接口-解绑会员失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-解绑会员失败");
}
}
/**
*
*
*/
public static void pointChange(ShuYunPointChange shuYunPointChange) {
try {
shuYunHttpRequest(HttpMethod.POST, null, JSON.toJSONString(shuYunPointChange),
shuYunConfig.getActionMethod().getPointChange());
} catch (Exception e) {
logger.error("请求数云接口-会员积分变更失败:{}", e);
logger.error("请求数云接口-会员积分变更失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-会员积分变更失败");
}
}
/**
* ()
*/
public static ShuYunPageUtil<ShuYunPointChangeLog> pointChangeLogSearch(ShuYunPageReq shuYunPageReq) {
try {
R r = shuYunHttpRequest(HttpMethod.GET, BeanUtil.beanToMap(shuYunPageReq), null,
shuYunConfig.getActionMethod().getPointChangeLogSearch());
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<ShuYunPageUtil<ShuYunPointChangeLog>>(){});
} catch (Exception e) {
logger.error("请求数云接口-会员积分变更记录查询失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-会员积分变更记录查询失败");
}
}
/**
*
* TODO:()
*/
public static int pointWillDueSearch(Map map) {
try {
R r = shuYunHttpRequest(HttpMethod.GET, map, null,
shuYunConfig.getActionMethod().getPointWillDueSearch());
if (r.getCode() == ShuYunHttpStatusConstants.HALF_SUCCESS) {
logger.info("查询成功,没有数据");
}
if (r.getCode() != ShuYunHttpStatusConstants.SUCCESS) {
logger.error("请求数云接口-查询会员即将过期积分失败:{}", r.getMsg());
}
return 0;
} catch (Exception e) {
logger.error("请求数云接口-查询会员即将过期积分失败:{}", e.getMessage());
throw new ServiceException("请求数云接口-查询会员即将过期积分失败");
}
}
/**
*
*/
public static void tagCreate(ShuYunTag shuYunTag) {
try {
R r = shuYunHttpRequest(HttpMethod.POST, null, JSON.toJSONString(shuYunTag),
shuYunConfig.getActionMethod().getTagCreate());
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 tagSearch(Map params) {
try {
R r = shuYunHttpRequest(HttpMethod.GET, params, null,
shuYunConfig.getActionMethod().getTagSearch());
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