From eaf2ffac7efe8a9b7fc08d21d46ecbbd17714aca Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Mon, 1 Apr 2019 09:34:10 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=85=AC=E4=BC=97=E5=8F=B7=E7=94=A8=E6=88=B7]?= =?UTF-8?q?[=E4=BF=AE=E6=94=B9]:fans=E5=90=8C=E6=AD=A5=E5=8F=8A=E5=85=B3?= =?UTF-8?q?=E6=B3=A8=E6=B7=BB=E5=8A=A0=E5=88=B0wx=5Fc=5Fuser=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/dto/WxCUserBasicInfoDto.java | 144 +++++ .../java/com/iformall/domain/po/WxCUser.java | 587 ++++++++++++++++++ .../com/iformall/domain/po/WxPayAccount.java | 20 +- .../iformall/enums/EnumWechatSubscribe.java | 38 ++ .../mapper/WxAuthorizerInfoMapper.java | 2 + .../com/iformall/mapper/WxCUserMapper.java | 27 + .../service/WxAuthorizerInfoService.java | 8 + .../com/iformall/service/WxCUserService.java | 67 ++ .../impl/WxAuthorizerInfoServiceImpl.java | 13 + .../service/impl/WxCUserServiceImpl.java | 89 +++ .../java/com/iformall/utils/Constant.java | 10 + .../resources/mapper/MallPermissionMapper.xml | 182 +++--- .../resources/mapper/MallUserInfoMapper.xml | 2 +- .../main/resources/mapper/WxAppinfoMapper.xml | 3 +- .../mapper/WxAuthorizerInfoMapper.xml | 215 ++++--- .../main/resources/mapper/WxCUserMapper.xml | 289 +++++++++ .../mapper/WxComponentVerifyTicketMapper.xml | 92 ++- .../resources/mapper/WxTemplateMsgMapper.xml | 114 ++-- .../mapper/WxWeappAuditStatusMapper.xml | 118 ++-- .../mapper/WxWeappBasicSetMapper.xml | 88 ++- .../mapper/WxWeappCodeStatusMapper.xml | 113 ++-- .../resources/mapper/WxWeappExtSetMapper.xml | 92 ++- .../mapper/WxWeappReleaseStatusMapper.xml | 113 ++-- .../mp/controller/WxMemController.java | 72 ++- .../iformall/mp/handler/SubscribeHandler.java | 43 +- .../schedule/UserUnionIdSchedule.java | 7 +- 26 files changed, 1965 insertions(+), 583 deletions(-) create mode 100644 mallinkService/src/main/java/com/iformall/domain/dto/WxCUserBasicInfoDto.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumWechatSubscribe.java create mode 100644 mallinkService/src/main/java/com/iformall/mapper/WxCUserMapper.java create mode 100644 mallinkService/src/main/java/com/iformall/service/WxCUserService.java create mode 100644 mallinkService/src/main/java/com/iformall/service/impl/WxCUserServiceImpl.java create mode 100644 mallinkService/src/main/resources/mapper/WxCUserMapper.xml diff --git a/mallinkService/src/main/java/com/iformall/domain/dto/WxCUserBasicInfoDto.java b/mallinkService/src/main/java/com/iformall/domain/dto/WxCUserBasicInfoDto.java new file mode 100644 index 0000000..903032b --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/dto/WxCUserBasicInfoDto.java @@ -0,0 +1,144 @@ +package com.iformall.domain.dto; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Id; +import javax.persistence.Transient; +/** + * 用户查询dto + * @author jinguo + * + */ +public class WxCUserBasicInfoDto implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = -1116465873573690766L; + + @Id + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="开始时间",name="startTime") + private Date startTime; + + @io.swagger.annotations.ApiModelProperty(value="结束时间",name="endTime") + private Date endTime; + + @io.swagger.annotations.ApiModelProperty(value="手机号",name="phone") + private String phone; + + @io.swagger.annotations.ApiModelProperty(value="姓名",name="name") + private String name; + + /*租户id**/ +// @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId") + @Transient + private String tenantId; + + @Transient + private Date birthStartTime; + + @Transient + private Date birthEndTime; + + @Transient + private Integer levelStartScore; + @Transient + private Integer levelEndScore; + + @Transient + private Integer sex; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Date getBirthStartTime() { + return birthStartTime; + } + + public void setBirthStartTime(Date birthStartTime) { + this.birthStartTime = birthStartTime; + } + + public Date getBirthEndTime() { + return birthEndTime; + } + + public void setBirthEndTime(Date birthEndTime) { + this.birthEndTime = birthEndTime; + } + + public Integer getSex() { + return sex; + } + + public void setSex(Integer sex) { + this.sex = sex; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + + public Integer getLevelEndScore() { + return levelEndScore; + } + + public void setLevelEndScore(Integer levelEndScore) { + this.levelEndScore = levelEndScore; + } + + public Integer getLevelStartScore() { + + return levelStartScore; + } + + public void setLevelStartScore(Integer levelStartScore) { + this.levelStartScore = levelStartScore; + } + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java new file mode 100644 index 0000000..5d8f057 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java @@ -0,0 +1,587 @@ +package com.iformall.domain.po; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.iformall.utils.Constant; + +import javax.persistence.*; +import java.util.*; +import java.math.*; +import javax.persistence.Transient; +import java.util.List; +import javax.persistence.Id; +import java.io.Serializable; + +@Table(name = "wx_c_user") +@JsonIgnoreProperties(ignoreUnknown = true) +public class WxCUser implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + protected Long id; + + @Transient + protected List ids; + @Transient + protected String sortColumns; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getSortColumns() { + return sortColumns; + } + + public List getIds() { + return ids; + } + + public void setIds(List ids) { + this.ids = ids; + } + + + + /*租户ID**/ + @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") + private String tenantId; + /*微信openId**/ + @io.swagger.annotations.ApiModelProperty(value="微信openId",name="openId") + private String openId; + /*微信unionId**/ + @io.swagger.annotations.ApiModelProperty(value="微信unionId",name="unionId") + private String unionId; + /*用户昵称**/ + @io.swagger.annotations.ApiModelProperty(value="用户昵称",name="nickName") + private String nickName; + /*用户性别**/ + @io.swagger.annotations.ApiModelProperty(value="用户性别",name="gender") + private Integer gender; + /*用户头像地址**/ + @io.swagger.annotations.ApiModelProperty(value="用户头像地址",name="avatarUrl") + private String avatarUrl; + /*用户绑定的手机号**/ + @io.swagger.annotations.ApiModelProperty(value="用户绑定的手机号",name="phone") + private String phone; + /*用户没有区号的手机号**/ + @io.swagger.annotations.ApiModelProperty(value="用户没有区号的手机号",name="purePhone") + private String purePhone; + /*用户所在城市**/ + @io.swagger.annotations.ApiModelProperty(value="用户所在城市",name="city") + private String city; + /*用户所在省份**/ + @io.swagger.annotations.ApiModelProperty(value="用户所在省份",name="province") + private String province; + /*用户所在语言**/ + @io.swagger.annotations.ApiModelProperty(value="用户所在语言",name="language") + private String language; + /*用户手机区号**/ + @io.swagger.annotations.ApiModelProperty(value="用户手机区号",name="countryCode") + private String countryCode; + /*用户注册IP**/ + @io.swagger.annotations.ApiModelProperty(value="用户注册IP",name="registerIp") + private String registerIp; + /***/ + @io.swagger.annotations.ApiModelProperty(value="",name="verifyCodePhone") + private String verifyCodePhone; + /*注册时记录用户扫码渠道,如朋友圈广告**/ + @io.swagger.annotations.ApiModelProperty(value="注册时记录用户扫码渠道,如朋友圈广告",name="qrcodeSource") + private String qrcodeSource; + /*二维码来源,小程序**/ + @io.swagger.annotations.ApiModelProperty(value="二维码来源,小程序",name="scene") + private String scene; + /*渠道,小程序**/ + @io.swagger.annotations.ApiModelProperty(value="渠道,小程序",name="sceneAddress") + private String sceneAddress; + /*session key for 微信小程序**/ + @io.swagger.annotations.ApiModelProperty(value="session key for 微信小程序",name="sessionKey") + private String sessionKey; + /*成长值**/ + @io.swagger.annotations.ApiModelProperty(value="成长值",name="score") + private Integer score; + /*更新时间**/ + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; + /*创建时间**/ + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + /*小程序的appId**/ + @io.swagger.annotations.ApiModelProperty(value="小程序的appId",name="appId") + private String appId; + /*用户登录用token**/ + @io.swagger.annotations.ApiModelProperty(value="用户登录用token",name="token") + private String token; + /*用户过期时间**/ + @io.swagger.annotations.ApiModelProperty(value="用户过期时间",name="expireTime") + private Date expireTime; + /*经度**/ + @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") + private BigDecimal longitude; + /*纬度**/ + @io.swagger.annotations.ApiModelProperty(value="纬度",name="latitude") + private BigDecimal latitude; + /*登录次数**/ + @io.swagger.annotations.ApiModelProperty(value="登录次数",name="loginCount") + private Integer loginCount; + /*附加信息**/ + @io.swagger.annotations.ApiModelProperty(value="附加信息",name="extraInfo") + private String extraInfo; + /**是否关注公众号**/ + @io.swagger.annotations.ApiModelProperty(value="是否关注公众号",name="isSubscribe") + private Integer isSubscribe; + + @io.swagger.annotations.ApiModelProperty(value="微信开放平台appId",name="openAppId") + private String openAppId; + @io.swagger.annotations.ApiModelProperty(value="服务号openId",name="mpOpenId") + private String mpOpenId; + @io.swagger.annotations.ApiModelProperty(value="服务号appId",name="mpAppId") + private String mpAppId; + @io.swagger.annotations.ApiModelProperty(value="是否关注服务号",name="mpSubscribe") + private Integer mpSubscribe; + @io.swagger.annotations.ApiModelProperty(value="关注服务号时间",name="mpSubscribeTime") + private Date mpSubscribeTime; + @io.swagger.annotations.ApiModelProperty(value="关注服务号Scene",name="mpSubscribeScene") + private String mpSubscribeScene; + @io.swagger.annotations.ApiModelProperty(value="订阅号openId",name="subsOpenId") + private String subsOpenId; + @io.swagger.annotations.ApiModelProperty(value="订阅号appId",name="subsAppId") + private String subsAppId; + @io.swagger.annotations.ApiModelProperty(value="是否关注订阅号",name="subsSubscribe") + private Integer subsSubscribe; + @io.swagger.annotations.ApiModelProperty(value="关注订阅号时间",name="subsSubscribeTime") + private Date subsSubscribeTime; + @io.swagger.annotations.ApiModelProperty(value="关注订阅号Scene",name="subsSubscribeScene") + private String subsSubscribeScene; + + + //渠道名称 + @Transient + private String channelName; + //渠道描述 + @Transient + protected String sceneDescription; + + @Transient + List sceneList; + + @Transient + protected Date startDate; + + @Transient + protected Date endDate; + + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate) { + this.startDate = startDate; + } + + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + public List getSceneList() { + return sceneList; + } + + public void setSceneList(List sceneList) { + this.sceneList = sceneList; + } + + public String getChannelName() { + return channelName; + } + + public void setChannelName(String channelName) { + this.channelName = channelName; + } + + public String getTenantId() { + return tenantId; + } + public void setTenantId(String _tenantId) { + tenantId = _tenantId; + } + public String getOpenId() { + return openId; + } + public void setOpenId(String _openId) { + openId = _openId; + } + public String getUnionId() { + return unionId; + } + public void setUnionId(String _unionId) { + unionId = _unionId; + } + public String getNickName() { + return nickName; + } + public void setNickName(String _nickName) { + nickName = _nickName; + } + public Integer getGender() { + return gender; + } + public void setGender(Integer _gender) { + gender = _gender; + } + public String getAvatarUrl() { + return avatarUrl; + } + public void setAvatarUrl(String _avatarUrl) { + avatarUrl = _avatarUrl; + } + public String getPhone() { + return phone; + } + public void setPhone(String _phone) { + phone = _phone; + } + public String getPurePhone() { + return purePhone; + } + public void setPurePhone(String _purePhone) { + purePhone = _purePhone; + } + public String getCity() { + return city; + } + public void setCity(String _city) { + city = _city; + } + public String getProvince() { + return province; + } + public void setProvince(String _province) { + province = _province; + } + public String getLanguage() { + return language; + } + public void setLanguage(String _language) { + language = _language; + } + public String getCountryCode() { + return countryCode; + } + public void setCountryCode(String _countryCode) { + countryCode = _countryCode; + } + public String getRegisterIp() { + return registerIp; + } + public void setRegisterIp(String _registerIp) { + registerIp = _registerIp; + } + public String getVerifyCodePhone() { + return verifyCodePhone; + } + public void setVerifyCodePhone(String _verifyCodePhone) { + verifyCodePhone = _verifyCodePhone; + } + public String getQrcodeSource() { + return qrcodeSource; + } + public void setQrcodeSource(String _qrcodeSource) { + qrcodeSource = _qrcodeSource; + } + public String getScene() { + return scene; + } + public void setScene(String _scene) { + scene = _scene; + } + public String getSceneAddress() { + return sceneAddress; + } + public void setSceneAddress(String _sceneAddress) { + sceneAddress = _sceneAddress; + } + public String getSessionKey() { + return sessionKey; + } + public void setSessionKey(String _sessionKey) { + sessionKey = _sessionKey; + } + public Integer getScore() { + return score; + } + public void setScore(Integer _score) { + score = _score; + } + public Date getUpdateDate() { + return updateDate; + } + public void setUpdateDate(Date _updateDate) { + updateDate = _updateDate; + } + public Date getCreateDate() { + return createDate; + } + public void setCreateDate(Date _createDate) { + createDate = _createDate; + } + public String getAppId() { + return appId; + } + public void setAppId(String _appId) { + appId = _appId; + } + public String getToken() { + return token; + } + public void setToken(String _token) { + token = _token; + } + public Date getExpireTime() { + return expireTime; + } + public void setExpireTime(Date _expireTime) { + expireTime = _expireTime; + } + + public BigDecimal getLongitude() { + return longitude; + } + + public void setLongitude(BigDecimal longitude) { + this.longitude = longitude; + } + + public BigDecimal getLatitude() { + return latitude; + } + + public void setLatitude(BigDecimal latitude) { + this.latitude = latitude; + } + + public Integer getLoginCount() { + return loginCount; + } + + public void setLoginCount(Integer loginCount) { + this.loginCount = loginCount; + } + + public String getSceneDescription() { + return sceneDescription; + } + + public void setSceneDescription(String sceneDescription) { + this.sceneDescription = sceneDescription; + } + + public String getExtraInfo() { + return extraInfo; + } + + public void setExtraInfo(String extraInfo) { + this.extraInfo = extraInfo; + } + + public Integer getIsSubscribe() { + return isSubscribe; + } + + public void setIsSubscribe(Integer isSubscribe) { + this.isSubscribe = isSubscribe; + } + + public String getOpenAppId() { + return openAppId; + } + + public void setOpenAppId(String openAppId) { + this.openAppId = openAppId; + } + + public String getMpOpenId() { + return mpOpenId; + } + + public void setMpOpenId(String mpOpenId) { + this.mpOpenId = mpOpenId; + } + + public String getMpAppId() { + return mpAppId; + } + + public void setMpAppId(String mpAppId) { + this.mpAppId = mpAppId; + } + + public Integer getMpSubscribe() { + return mpSubscribe; + } + + public void setMpSubscribe(Integer mpSubscribe) { + this.mpSubscribe = mpSubscribe; + } + + public Date getMpSubscribeTime() { + return mpSubscribeTime; + } + + public void setMpSubscribeTime(Date mpSubscribeTime) { + this.mpSubscribeTime = mpSubscribeTime; + } + + public String getMpSubscribeScene() { + return mpSubscribeScene; + } + + public void setMpSubscribeScene(String mpSubscribeScene) { + this.mpSubscribeScene = mpSubscribeScene; + } + + public String getSubsOpenId() { + return subsOpenId; + } + + public void setSubsOpenId(String subsOpenId) { + this.subsOpenId = subsOpenId; + } + + public String getSubsAppId() { + return subsAppId; + } + + public void setSubsAppId(String subsAppId) { + this.subsAppId = subsAppId; + } + + public Integer getSubsSubscribe() { + return subsSubscribe; + } + + public void setSubsSubscribe(Integer subsSubscribe) { + this.subsSubscribe = subsSubscribe; + } + + public Date getSubsSubscribeTime() { + return subsSubscribeTime; + } + + public void setSubsSubscribeTime(Date subsSubscribeTime) { + this.subsSubscribeTime = subsSubscribeTime; + } + + public String getSubsSubscribeScene() { + return subsSubscribeScene; + } + + public void setSubsSubscribeScene(String subsSubscribeScene) { + this.subsSubscribeScene = subsSubscribeScene; + } + + public static enum Field + { + Id_ASC("`id` ASC"),Id_DESC("`id` DESC") + ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") + ,OpenId_ASC("`open_id` ASC"),OpenId_DESC("`open_id` DESC") + ,UnionId_ASC("`union_id` ASC"),UnionId_DESC("`union_id` DESC") + ,NickName_ASC("`nick_name` ASC"),NickName_DESC("`nick_name` DESC") + ,Gender_ASC("`gender` ASC"),Gender_DESC("`gender` DESC") + ,AvatarUrl_ASC("`avatar_url` ASC"),AvatarUrl_DESC("`avatar_url` DESC") + ,Phone_ASC("`phone` ASC"),Phone_DESC("`phone` DESC") + ,PurePhone_ASC("`pure_phone` ASC"),PurePhone_DESC("`pure_phone` DESC") + ,City_ASC("`city` ASC"),City_DESC("`city` DESC") + ,Province_ASC("`province` ASC"),Province_DESC("`province` DESC") + ,Language_ASC("`language` ASC"),Language_DESC("`language` DESC") + ,CountryCode_ASC("`country_code` ASC"),CountryCode_DESC("`country_code` DESC") + ,RegisterIp_ASC("`register_ip` ASC"),RegisterIp_DESC("`register_ip` DESC") + ,VerifyCodePhone_ASC("`verify_code_phone` ASC"),VerifyCodePhone_DESC("`verify_code_phone` DESC") + ,QrcodeSource_ASC("`qrcode_source` ASC"),QrcodeSource_DESC("`qrcode_source` DESC") + ,Scene_ASC("`scene` ASC"),Scene_DESC("`scene` DESC") + ,SceneAddress_ASC("`scene_address` ASC"),SceneAddress_DESC("`scene_address` DESC") + ,SessionKey_ASC("`session_key` ASC"),SessionKey_DESC("`session_key` DESC") + ,Score_ASC("`score` ASC"),Score_DESC("`score` DESC") + ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") + ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") + ,AppId_ASC("`app_id` ASC"),AppId_DESC("`app_id` DESC") + ,Token_ASC("`token` ASC"),Token_DESC("`token` DESC") + ,ExpireTime_ASC("`expire_time` ASC"),ExpireTime_DESC("`expire_time` DESC") + ,Longitude_ASC("`longitude` ASC"),Longitude_DESC("`longitude` DESC") + ,Latitude_ASC("`latitude` ASC"),Latitude_DESC("`latitude` DESC") + ,LoginCount_ASC("`login_count` ASC"),LoginCount_DESC("`login_count` DESC") + ,ExtraInfo_ASC("`extra_info` ASC"),ExtraInfo_DESC("`extra_info` DESC") + ,IsSubscribe_ASC("`is_subscribe` ASC"),IsSubscribe_DESC("`is_subscribe` DESC") + ; + private String value; + Field(String value){ + this.value = value; + } + public String getValue() { + return value; + } + public void setCol(String value) { + this.value = value; + } + @Override + public String toString() { + return this.getValue(); + } + } + + public void setSortColumns(WxCUser.Field... fields) + { + if (fields == null || fields.length == 0) { + return; + } + for (int k = 0; k < fields.length; k++) { + if (fields[k] == null) { + return; + } + } + StringBuilder sb = new StringBuilder(fields[0].toString()); + for (int k = 1; k < fields.length; k++) { + sb.append(","); + sb.append(fields[k].toString()); + } + + this.sortColumns = sb.toString(); + + } + + public void setSortColumns(String sortColumns) + { + if (sortColumns == null || "".equals(sortColumns.trim())) { + return; + } + if (sortColumns.contains(",")) { + String[] cols = sortColumns.split(","); + java.util.List fList = new java.util.ArrayList(); + for (int k = 0; k < cols.length; k++) { + fList.add(Field.valueOf(cols[k])); + } + this.setSortColumns(fList.toArray(new Field[fList.size()])); + } else { + this.setSortColumns(Field.valueOf(sortColumns)); + } + } + + public String createToken(Date currentDate) { + if (expireTime == null || expireTime.getTime() < currentDate.getTime()) + { + //生成一个token + this.token = UUID.randomUUID().toString(); + //过期时间 + this.expireTime = new Date(currentDate.getTime() + Constant.EXPIRE * 1000); + } + return this.token; + } +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java index 7629bff..47b0df4 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java @@ -48,6 +48,9 @@ public class WxPayAccount implements Serializable { /**微信服务商号*/ @io.swagger.annotations.ApiModelProperty(value="微信服务商号",name="subMchId") private String subMchId; + + @io.swagger.annotations.ApiModelProperty(value="微信服务商号",name="parentMchId") + private String parentMchId; /**支付密钥**/ @io.swagger.annotations.ApiModelProperty(value="支付密钥",name="apiKey") private String apiKey; @@ -90,7 +93,15 @@ public class WxPayAccount implements Serializable { this.subMchId = subMchId; } - public String getApiKey() { + public String getParentMchId() { + return parentMchId; + } + + public void setParentMchId(String parentMchId) { + this.parentMchId = parentMchId; + } + + public String getApiKey() { return apiKey; } public void setApiKey(String _apiKey) { @@ -111,9 +122,10 @@ public class WxPayAccount implements Serializable { public Integer getType() { return type; } - public void setType(Integer type) { - this.type = type; - } + + public void setType(Integer type) { + this.type = type; + } public Integer getShare() { return share; } diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumWechatSubscribe.java b/mallinkService/src/main/java/com/iformall/enums/EnumWechatSubscribe.java new file mode 100644 index 0000000..70d798b --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumWechatSubscribe.java @@ -0,0 +1,38 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumWechatSubscribe { + + // 0为未关注,1为关注, 2再次关注 + NO(0, "未关注"), + YES(1, "关注"), + AGAIN(2, "再次关注"), + ; + + public static EnumWechatSubscribe getEnum(Integer code) { + for (EnumWechatSubscribe value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumWechatSubscribe(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxAuthorizerInfoMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxAuthorizerInfoMapper.java index 1c4d3a4..51df519 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxAuthorizerInfoMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxAuthorizerInfoMapper.java @@ -15,6 +15,8 @@ public interface WxAuthorizerInfoMapper extends CommonMapper findVoList(WxWeappInfo wxWeappInfo); + WxWeappInfo findVo(WxWeappInfo wxWeappInfo); + int updateReleaseInfo(WxAuthorizerInfo wxAuthorizerInfo); int updateRefreshToken(WxAuthorizerInfo wxAuthorizerInfo); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCUserMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCUserMapper.java new file mode 100644 index 0000000..ff4f073 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCUserMapper.java @@ -0,0 +1,27 @@ +package com.iformall.mapper; + +import java.util.HashMap; +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.dto.WxCUserBasicInfoDto; +import com.iformall.domain.po.WxCUser; + +public interface WxCUserMapper extends CommonMapper { + + List findList(WxCUser wxCUser); + + WxCUser findByOpenId(WxCUser record); + + WxCUser findByUnionId(WxCUser record); + + WxCUser findByToken(String token); + + long findCount(WxCUserBasicInfoDto dto); + + List listByChannel(WxCUser wxCUser); + + long countByChannel(WxCUser wxCUser); +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxAuthorizerInfoService.java b/mallinkService/src/main/java/com/iformall/service/WxAuthorizerInfoService.java index c093986..3b3da52 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxAuthorizerInfoService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxAuthorizerInfoService.java @@ -50,6 +50,14 @@ public interface WxAuthorizerInfoService { * @return */ WxAuthorizerInfo getByAppId(String appId); + + /** + * 根据appId获得实体 + * + * @param appId + * @return + */ + WxWeappInfo getWeappByAppId(String appId); /** * 保存或更新实体 diff --git a/mallinkService/src/main/java/com/iformall/service/WxCUserService.java b/mallinkService/src/main/java/com/iformall/service/WxCUserService.java new file mode 100644 index 0000000..4a2a719 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/WxCUserService.java @@ -0,0 +1,67 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.domain.dto.WxCUserBasicInfoDto; +import com.iformall.domain.po.WxCUser; + +public interface WxCUserService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(WxCUser record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + WxCUser getById(Long id); + + /** + * 根据openId获得实体 + * + * @param record + * @return + */ + WxCUser getByOpenId(WxCUser record); + + /** + * 保存或更新实体 + * + * @param record + */ + int saveOrUpdate(WxCUser record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + /** + * 统计数量 + * @param dto + * @return + */ + long findCount(WxCUserBasicInfoDto dto); + + + /** + * 通过渠道获取会员信息 + * @param user + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listByChannel(WxCUser user, Integer pageIndex, Integer pageSize); + + long countByChannel(WxCUser user); +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxAuthorizerInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxAuthorizerInfoServiceImpl.java index 9ddce66..3acaa50 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxAuthorizerInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxAuthorizerInfoServiceImpl.java @@ -66,6 +66,19 @@ public class WxAuthorizerInfoServiceImpl implements WxAuthorizerInfoService { return null; } + @Override + public WxWeappInfo getWeappByAppId(String appId) { + WxWeappInfo authQ = new WxWeappInfo(); + authQ.setAuthorizerAppid(appId); + try { + WxWeappInfo authorizerInfo = authorizerInfoMapper.findVo(authQ); + return authorizerInfo; + } catch (Exception e) { + logger.error(e.getMessage()); + } + return null; + } + @Override public void saveOrUpdate(WxAuthorizerInfo record) { // 1. 添加到wx_authorizer_info表中 diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserServiceImpl.java new file mode 100644 index 0000000..6e05c67 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserServiceImpl.java @@ -0,0 +1,89 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.common.IdWorker; +import com.iformall.domain.dto.WxCUserBasicInfoDto; +import com.iformall.domain.po.WxCUser; +import com.iformall.mapper.WxCUserMapper; +import com.iformall.service.WxCUserService; +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.Service; + +import java.util.Date; + +@Service +public class WxCUserServiceImpl implements WxCUserService { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + WxCUserMapper wxCUserMapper; + + @Override + public PageInfo listAsPage(WxCUser record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserMapper.findList(record)); + } + + @Override + public WxCUser getById(Long id) { + return wxCUserMapper.selectByPrimaryKey(id); + } + + @Override + public WxCUser getByOpenId(WxCUser record) { + return wxCUserMapper.findByOpenId(record); + } + + @Override + public int saveOrUpdate(WxCUser user) { + int ret = 0; + Date curr = new Date(); + if (user.getId() == null) { + // 检查用户是否已有同一微信开放平台账号 + if(StringUtils.isNotBlank(user.getUnionId()) && StringUtils.isNotBlank(user.getOpenAppId())) { + WxCUser oldUser = wxCUserMapper.findByUnionId(user); + if(oldUser != null) { + // 已有,更新 + user.setId(oldUser.getId()); + // TODO 是否其他信息需要更新 + ret = wxCUserMapper.updateByPrimaryKeySelective(user); + return ret; + } + } + final IdWorker idWorker = IdWorker.get(); + user.setId(idWorker.nextId()); + user.setLoginCount(1); + user.setCreateDate(curr); + user.setUpdateDate(curr); + ret = wxCUserMapper.insertSelective(user); + } else { + user.setUpdateDate(curr); + ret = wxCUserMapper.updateByPrimaryKeySelective(user); + } + + return ret; + } + + @Override + public void deleteById(Long id) { + wxCUserMapper.deleteByPrimaryKey(id); + } + + @Override + public long findCount(WxCUserBasicInfoDto dto) { + return wxCUserMapper.findCount(dto); + } + + @Override + public PageInfo listByChannel(WxCUser user, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserMapper.listByChannel(user)); + } + + @Override + public long countByChannel(WxCUser user) { + return wxCUserMapper.countByChannel(user); + } +} diff --git a/mallinkService/src/main/java/com/iformall/utils/Constant.java b/mallinkService/src/main/java/com/iformall/utils/Constant.java index bdbce4d..d5fb7b8 100644 --- a/mallinkService/src/main/java/com/iformall/utils/Constant.java +++ b/mallinkService/src/main/java/com/iformall/utils/Constant.java @@ -2,6 +2,16 @@ package com.iformall.utils; public class Constant { + // 1小时过期, + public final static int C_EXPIRE = 3600000; + + // TOKEN过期时间, 24小时后过期 + public final static int EXPIRE = 3600 * 24; + + // C端token + public static final String LOGIN_USER_KEY = "LOGIN_USER_KEY"; + public static final String TENANT_ID = "TENANT_ID"; + public static final String fileDirectory = "./uploads/"; public static final String importMemPrev = "importmem/"; public static final String adminPage = "http://admin.malls.iformall.com"; diff --git a/mallinkService/src/main/resources/mapper/MallPermissionMapper.xml b/mallinkService/src/main/resources/mapper/MallPermissionMapper.xml index 7285671..f94081d 100644 --- a/mallinkService/src/main/resources/mapper/MallPermissionMapper.xml +++ b/mallinkService/src/main/resources/mapper/MallPermissionMapper.xml @@ -1,99 +1,97 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + `id`,`name`,`available`,`parent_id`,`parent_ids`,`permission`,`resource_type`,`url`,`sort` - - where 1 = 1 - - - and `id` = #{id} - - - - - and `name` like concat('%', #{name},'%') - - - and `name` like concat('%', #{nameLike},'%') - - - and `available` like concat('%', #{available},'%') - - - - - and `parent_id` = #{parentId} - - - - - and `parent_ids` like concat('%', #{parentIds},'%') - - - - - and `permission` like concat('%', #{permission},'%') - - - - and `permission` in - - #{item_permission} - - - - - and `resource_type` like concat('%', #{resourceType},'%') - - - - - and `url` like concat('%', #{url},'%') - - - - - and `sort` = #{sort} - - - and `sort` >= #{sortFrom} - and #{sortTo} >= `sort` - and `sort` >= #{sortGte} - and `sort` > #{sortGt} - and #{sortLte} >= `sort` - and #{sortLt} > `sort` - - and id in - - #{idItem} - - - order by ${sortColumns} - - - - - - - - - + + where 1 = 1 + + + and `id` = #{id} + + + + + and `name` like concat('%', #{name},'%') + + + and `name` like concat('%', #{nameLike},'%') + + + and `available` like concat('%', #{available},'%') + + + + + and `parent_id` = #{parentId} + + + + + and `parent_ids` like concat('%', #{parentIds},'%') + + + + + and `permission` like concat('%', #{permission},'%') + + + + and `permission` in + + #{item_permission} + + + + + and `resource_type` like concat('%', #{resourceType},'%') + + + + + and `url` like concat('%', #{url},'%') + + + + + and `sort` = #{sort} + + + and `sort` >= #{sortFrom} + and #{sortTo} >= `sort` + and `sort` >= #{sortGte} + and `sort` > #{sortGt} + and #{sortLte} >= `sort` + and #{sortLt} > `sort` + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + diff --git a/mallinkService/src/main/resources/mapper/MallUserInfoMapper.xml b/mallinkService/src/main/resources/mapper/MallUserInfoMapper.xml index bf30fd4..a190279 100644 --- a/mallinkService/src/main/resources/mapper/MallUserInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/MallUserInfoMapper.xml @@ -153,7 +153,7 @@ - + update mall_user_info set `web_open_id` = null where 1=1 diff --git a/mallinkService/src/main/resources/mapper/WxAppinfoMapper.xml b/mallinkService/src/main/resources/mapper/WxAppinfoMapper.xml index b852e23..c162a95 100644 --- a/mallinkService/src/main/resources/mapper/WxAppinfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAppinfoMapper.xml @@ -17,7 +17,6 @@ - @@ -36,7 +35,7 @@ - and `app_id` = #{appId} + and `app_id` = #{appId} and `parent_app_id` like concat('%', #{parentAppId},'%') diff --git a/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml index 9c45d6d..2d49138 100644 --- a/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml @@ -1,35 +1,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `id`,`authorizer_appid`,`head_img`,`alias`,`qrcode_url`,`create_time`,`authorization_status`,`auth_time`, `base_status`, `base_time`, `domain_status`, `domain_time`, `webdomain_status`, `webdomain_time`, `template_status`, `template_time`, `current_version`,`current_desc`,`release_time`, @@ -37,32 +37,32 @@ `access_token`,`access_token_expire` - - where 1 = 1 - - and `id` = #{id} - - - and `authorizer_appid` = #{authorizerAppid} - - - and `head_img` like concat('%', #{headImg},'%') - - - and `alias` like concat('%', #{alias},'%') - - - and `qrcode_url` like concat('%', #{qrcodeUrl},'%') - - - and `create_time` = #{createTime} - + + where 1 = 1 + + and `id` = #{id} + + + and `authorizer_appid` = #{authorizerAppid} + + + and `head_img` like concat('%', #{headImg},'%') + + + and `alias` like concat('%', #{alias},'%') + + + and `qrcode_url` like concat('%', #{qrcodeUrl},'%') + + + and `create_time` = #{createTime} + and `update_time` = #{updateTime} - - and `authorization_status` = #{authorizationStatus} - + + and `authorization_status` = #{authorizationStatus} + and `auth_time` = #{authTime} @@ -94,7 +94,7 @@ and `current_version` = #{currentVersion} - and `current_desc` like concat('%', #{currentDesc},'%') + and `current_desc` like concat('%', #{currentDesc},'%') and `release_time` = #{releaseTime} @@ -105,64 +105,66 @@ and `bind_open_time` = #{bindOpenTime} - - and id in - - #{idItem} - - - order by ${sortColumns} - - - + + and id in + + #{idItem} + + + order by ${sortColumns} + + + - + update wx_authorizer_info set `current_version` = #{currentVersion}, `current_desc` = #{currentDesc}, `release_time` = #{releaseTime}, `update_time` = #{updateTime} where `authorizer_appid` = #{authorizerAppid} - + update wx_authorizer_info set `refresh_token` = #{refreshToken} where `authorizer_appid` = #{authorizerAppid} - + update wx_authorizer_info set `access_token` = #{accessToken}, `access_token_expire` = #{accessTokenExpire} where `authorizer_appid` = #{authorizerAppid} - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -233,29 +235,40 @@ #{idItem} - order by ${sortColumns} + order by ${sortColumns} + + - - + + diff --git a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml new file mode 100644 index 0000000..f2d5b54 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`, + `city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`, + `qrcode_source`,`scene`,`scene_address`,`session_key`,`score`, + `update_date`,`create_date`,`app_id`,`token`,`expire_time`,`latitude`, `longitude`, + `login_count`, `extra_info`, `is_subscribe`, + `open_app_id`, + `mp_open_id`,`mp_app_id`,`mp_subscribe`,`mp_subscribe_time`,`mp_subscribe_scene`, + `subs_open_id`,`subs_app_id`,`subs_subscribe`,`subs_subscribe_time`,`subs_subscribe_scene` + + + + where 1 = 1 + + + and `id` = #{id} + + + + and `tenant_id`= #{tenantId} + + + + and `open_id` like concat('%', #{openId},'%') + + + + and `union_id` like concat('%', #{unionId},'%') + + + + and `nick_name` like concat('%', #{nickName},'%') + + + + and `gender` = #{gender} + + + + and `avatar_url` like concat('%', #{avatarUrl},'%') + + + + and `phone` like concat('%', #{phone},'%') + + + + and `pure_phone` like concat('%', #{purePhone},'%') + + + + and `city` like concat('%', #{city},'%') + + + + and `province` like concat('%', #{province},'%') + + + + and `language` like concat('%', #{language},'%') + + + + and `country_code` like concat('%', #{countryCode},'%') + + + + and `register_ip` like concat('%', #{registerIp},'%') + + + + and `verify_code_phone` like concat('%', #{verifyCodePhone},'%') + + + + and `qrcode_source` like concat('%', #{qrcodeSource},'%') + + + + and `scene` like concat('%', #{scene},'%') + + + + and `scene_address` like concat('%', #{sceneAddress},'%') + + + + and `session_key` like concat('%', #{sessionKey},'%') + + + + and `score` = #{score} + + + + and `update_date` = #{updateDate} + + + + and `create_date` = #{createDate} + + + + and `app_id` like concat('%', #{appId},'%') + + + + and `token` like concat('%', #{token},'%') + + + + and `expire_time` = #{expireTime} + + + + and `latitude` = #{latitude} + + + + and `longitude` = #{longitude} + + + + and `login_count` = #{loginCount} + + + + and `extra_info` = #{extraInfo} + + + + and `is_subscribe` = #{isSubscribe} + + + + and `open_app_id` = #{openAppId} + + + + and `mp_open_id` = #{mpOpenId} + + + + and `mp_app_id` = #{mpAppId} + + + + and `subs_open_id` = #{subsOpenId} + + + + and `subs_app_id` = #{subsAppId} + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + + + + + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxComponentVerifyTicketMapper.xml b/mallinkService/src/main/resources/mapper/WxComponentVerifyTicketMapper.xml index 4a8f56d..527580c 100644 --- a/mallinkService/src/main/resources/mapper/WxComponentVerifyTicketMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxComponentVerifyTicketMapper.xml @@ -1,60 +1,58 @@ - - - - - - - - - - - + + + + + + + + + + + `id`,`component_appid`,`component_verify_ticket`,`create_time`,`deadline` - - where 1 = 1 - - and `id` = #{id} - - - and `component_appid` = #{componentAppid} - - - and `component_verify_ticket` like concat('%', #{componentVerifyTicket},'%') - - - and `create_time` = #{createTime} - - - and `deadline` = #{deadline} - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - + + where 1 = 1 + + and `id` = #{id} + + + and `component_appid` = #{componentAppid} + + + and `component_verify_ticket` like concat('%', #{componentVerifyTicket},'%') + + + and `create_time` = #{createTime} + + + and `deadline` = #{deadline} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + update wx_component_verify_ticket set `access_token` = #{accessToken}, `access_token_expire` = #{accessTokenExpire} where component_appid = #{componentAppid} - - - - - - + + diff --git a/mallinkService/src/main/resources/mapper/WxTemplateMsgMapper.xml b/mallinkService/src/main/resources/mapper/WxTemplateMsgMapper.xml index 35266ad..a410904 100644 --- a/mallinkService/src/main/resources/mapper/WxTemplateMsgMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxTemplateMsgMapper.xml @@ -1,68 +1,60 @@ - - - - - - - - - - + + + + + + + + + + `id`,`tenant_id`,`template_id`,`type`,`create_date`,`update_date` - - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id` = #{tenantId} - - - - - and `template_id` like concat('%', #{templateId},'%') - - - - - and `type` = #{type} - - - - - and `create_date` = #{createDate} - - - - - and `update_date` = #{updateDate} - - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - - - - - - - + + where 1 = 1 + + + and `id` = #{id} + + + + and `tenant_id` = #{tenantId} + + + + and `template_id` = #{templateId} + + + + and `type` = #{type} + + + + and `create_date` = #{createDate} + + + + and `update_date` = #{updateDate} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxWeappAuditStatusMapper.xml b/mallinkService/src/main/resources/mapper/WxWeappAuditStatusMapper.xml index 8ca60e5..3a17876 100644 --- a/mallinkService/src/main/resources/mapper/WxWeappAuditStatusMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxWeappAuditStatusMapper.xml @@ -1,37 +1,37 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + `id`,`tenant_id`,`app_id`,`type`,`user_version`,`version_desc`, `audit_status`,`audit_err_code`,`audit_time` - - where 1 = 1 - - and `id` = #{id} - + + where 1 = 1 + + and `id` = #{id} + and `tenant_id` = #{tenantId} - - and `app_id` = #{appId} - - - and `type` = #{type} - + + and `app_id` = #{appId} + + + and `type` = #{type} + and `user_version` = #{userVersion} @@ -41,32 +41,33 @@ and `audit_status` = #{auditStatus} - - and `audit_time` = #{auditTime} - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - + + and `audit_time` = #{auditTime} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + - + update wx_weapp_audit_status set `user_version` = #{userVersion}, `version_desc` = #{versionDesc}, `audit_status` = #{auditStatus}, `audit_err_code` = #{auditErrCode}, `audit_time` = #{auditTime} where `app_id` = #{appId} and `type` = #{type} - select user_version as version from wx_weapp_audit_status where 1=1 @@ -80,16 +81,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -130,14 +131,15 @@ #{idItem} - order by ${sortColumns} + order by ${sortColumns} - + diff --git a/mallinkService/src/main/resources/mapper/WxWeappBasicSetMapper.xml b/mallinkService/src/main/resources/mapper/WxWeappBasicSetMapper.xml index 50b757a..fdaf5d3 100644 --- a/mallinkService/src/main/resources/mapper/WxWeappBasicSetMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxWeappBasicSetMapper.xml @@ -1,55 +1,53 @@ - - - - - - - - - - - - + + + + + + + + + + + + `id`,`type`,`domain_url`,`version`,`template_info`,`create_date`,`update_date` - - where 1 = 1 - - and `id` = #{id} - - - and `type` = #{type} - + + where 1 = 1 + + and `id` = #{id} + + + and `type` = #{type} + and `deploy` = #{deploy} - - and `create_date` = #{createDate} - - - and `update_date` = #{updateDate} - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - - - - - - - + + and `create_date` = #{createDate} + + + and `update_date` = #{updateDate} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxWeappCodeStatusMapper.xml b/mallinkService/src/main/resources/mapper/WxWeappCodeStatusMapper.xml index 744f2e1..bcd8f1f 100644 --- a/mallinkService/src/main/resources/mapper/WxWeappCodeStatusMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxWeappCodeStatusMapper.xml @@ -1,67 +1,69 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + `id`,`tenant_id`,`app_id`,`type`,`user_version`,`version_desc`,`code_status`,`code_err_code`,`code_time` - - where 1 = 1 - - and `id` = #{id} - + + where 1 = 1 + + and `id` = #{id} + and `tenant_id` = #{tenantId} - - and `app_id` = #{appId} - - - and `type` = #{type} - + + and `app_id` = #{appId} + + + and `type` = #{type} + and `user_version` = #{userVersion} and `code_status` = #{codeStatus} - - and `code_time` = #{codeTime} - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - + + and `code_time` = #{codeTime} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + - + update wx_weapp_code_status set `user_version` = #{userVersion}, `version_desc`= #{versionDesc}, `code_status` = #{codeStatus}, `code_err_code` = #{codeErrCode}, `code_time` = #{codeTime} where `app_id` = #{appId} and `type` = #{type} - select user_version as version from wx_weapp_code_status where 1=1 @@ -72,16 +74,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -117,13 +119,14 @@ #{idItem} - order by ${sortColumns} + order by ${sortColumns} diff --git a/mallinkService/src/main/resources/mapper/WxWeappExtSetMapper.xml b/mallinkService/src/main/resources/mapper/WxWeappExtSetMapper.xml index 71de37b..700b10a 100644 --- a/mallinkService/src/main/resources/mapper/WxWeappExtSetMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxWeappExtSetMapper.xml @@ -1,54 +1,52 @@ - - - - - - - - - - - + + + + + + + + + + + `id`,`app_id`,`type`,`ext_json`,`release_json`,`create_date`,`update_date` - - where 1 = 1 - - and `id` = #{id} - - - and `app_id` = #{appId} - - - and `type` = #{type} - - - and `create_date` = #{createDate} - - - and `update_date` = #{updateDate} - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - - - - - - - + + where 1 = 1 + + and `id` = #{id} + + + and `app_id` = #{appId} + + + and `type` = #{type} + + + and `create_date` = #{createDate} + + + and `update_date` = #{updateDate} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxWeappReleaseStatusMapper.xml b/mallinkService/src/main/resources/mapper/WxWeappReleaseStatusMapper.xml index dedf3bc..35a4071 100644 --- a/mallinkService/src/main/resources/mapper/WxWeappReleaseStatusMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxWeappReleaseStatusMapper.xml @@ -1,67 +1,69 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + `id`,`tenant_id`,`app_id`,`type`,`user_version`,`version_desc`,`release_status`,`release_err_code`,`release_time` - - where 1 = 1 - - and `id` = #{id} - + + where 1 = 1 + + and `id` = #{id} + and `tenant_id` = #{tenantId} - and `app_id` = #{appId} - - - and `type` = #{type} - + and `app_id` = #{appId} + + + and `type` = #{type} + and `user_version` = #{userVersion} and `release_status` = #{releaseStatus} - - and `release_time` = #{releaseTime} - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - + + and `release_time` = #{releaseTime} + + + and id in + + #{idItem} + + + order by ${sortColumns} + - + + + update wx_weapp_release_status set `user_version` = #{userVersion}, `version_desc` = #{versionDesc}, `release_status` = #{releaseStatus}, `release_err_code` = #{releaseErrCode}, `release_time` = #{releaseTime} where `app_id` = #{appId} and `type` = #{type} - select user_version as version from wx_weapp_release_status where 1 = 1 @@ -72,16 +74,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -122,14 +124,15 @@ #{idItem} - order by ${sortColumns} + order by ${sortColumns} - + diff --git a/mlWechatOpen/src/main/java/com/iformall/mp/controller/WxMemController.java b/mlWechatOpen/src/main/java/com/iformall/mp/controller/WxMemController.java index 4664107..b3a23bf 100644 --- a/mlWechatOpen/src/main/java/com/iformall/mp/controller/WxMemController.java +++ b/mlWechatOpen/src/main/java/com/iformall/mp/controller/WxMemController.java @@ -1,7 +1,13 @@ package com.iformall.mp.controller; import com.iformall.common.ResultData; +import com.iformall.domain.po.WxCUser; +import com.iformall.domain.vo.WxWeappInfo; +import com.iformall.enums.EnumAppType; +import com.iformall.enums.EnumWechatSubscribe; import com.iformall.mp.manager.WxMpManager; +import com.iformall.service.WxAuthorizerInfoService; +import com.iformall.service.WxCUserService; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.result.WxMpUser; @@ -15,6 +21,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Date; import java.util.List; /** @@ -25,25 +32,68 @@ import java.util.List; public class WxMemController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Autowired + private WxAuthorizerInfoService authorizerInfoService; + + @Autowired + private WxCUserService userService; + @Autowired private WxMpManager wxMpManager; @GetMapping("/syncAccountFansList") public ResultData syncAccountFansList(@PathVariable String appId) throws WxErrorException { - final WxMpService wxService = wxMpManager.getMpService(appId); + final WxWeappInfo weappInfo = authorizerInfoService.getWeappByAppId(appId); + if(weappInfo.getType().equals(EnumAppType.MP_S.getCode()) || weappInfo.getType().equals(EnumAppType.MP_P.getCode())) { + final WxMpService wxService = wxMpManager.getMpService(appId); - WxMpUserList mpUserList = wxService.getUserService().userList(null); - logger.info(mpUserList.toString()); - List userList = wxService.getUserService().userInfoList(mpUserList.getOpenids()); - logger.info(userList.toString()); - while(StringUtils.isNotBlank(mpUserList.getNextOpenid())) { - mpUserList = wxService.getUserService().userList(mpUserList.getNextOpenid()); - logger.info(mpUserList.toString()); - if(mpUserList.getOpenids().size() > 0) { - userList = wxService.getUserService().userInfoList(mpUserList.getOpenids()); - logger.info(userList.toString()); + String nextOpenId = null; + while(true) { + nextOpenId = syncUsers(wxService, weappInfo, nextOpenId); + if(StringUtils.isBlank(nextOpenId)) + break; } } return new ResultData(); } + + private String syncUsers(WxMpService wxMpService, WxWeappInfo appinfo, String nextOpenId) throws WxErrorException { + WxMpUserList mpUserList = wxMpService.getUserService().userList(nextOpenId); + logger.info(mpUserList.toString()); + if(mpUserList.getOpenids().size() <= 0){ + return mpUserList.getNextOpenid(); + } + List userList = wxMpService.getUserService().userInfoList(mpUserList.getOpenids()); + logger.info(userList.toString()); + userList.stream().forEach(mpuser -> { + WxCUser user = new WxCUser(); + user.setUnionId(mpuser.getUnionId()); + user.setOpenAppId(appinfo.getOpenAppid()); + if(appinfo.getType().equals(EnumAppType.MP_S.getCode())) { + user.setMpAppId(appinfo.getAuthorizerAppid()); + user.setMpOpenId(mpuser.getOpenId()); + user.setMpSubscribe(EnumWechatSubscribe.YES.getCode()); + user.setMpSubscribeTime(new Date(mpuser.getSubscribeTime())); + user.setMpSubscribeScene(mpuser.getSubscribeScene()); + } else if(appinfo.getType().equals(EnumAppType.MP_S.getCode())) { + user.setSubsAppId(appinfo.getAuthorizerAppid()); + user.setSubsOpenId(mpuser.getOpenId()); + user.setSubsSubscribe(EnumWechatSubscribe.YES.getCode()); + user.setSubsSubscribeTime(new Date(mpuser.getSubscribeTime())); + user.setSubsSubscribeScene(mpuser.getSubscribeScene()); + } + user.setNickName(mpuser.getNickname()); + user.setGender(mpuser.getSex()); + user.setLanguage(mpuser.getLanguage()); + user.setCity(mpuser.getCity()); + user.setProvince(mpuser.getProvince()); + user.setCountryCode(mpuser.getCountry()); + user.setAvatarUrl(mpuser.getHeadImgUrl()); + user.setScene(mpuser.getQrScene()); + user.setSceneAddress(mpuser.getQrSceneStr()); + userService.saveOrUpdate(user); + + }); + return mpUserList.getNextOpenid(); + } } diff --git a/mlWechatOpen/src/main/java/com/iformall/mp/handler/SubscribeHandler.java b/mlWechatOpen/src/main/java/com/iformall/mp/handler/SubscribeHandler.java index 21c3b2a..541bd64 100644 --- a/mlWechatOpen/src/main/java/com/iformall/mp/handler/SubscribeHandler.java +++ b/mlWechatOpen/src/main/java/com/iformall/mp/handler/SubscribeHandler.java @@ -1,14 +1,22 @@ package com.iformall.mp.handler; +import com.iformall.domain.po.WxCUser; +import com.iformall.domain.vo.WxWeappInfo; +import com.iformall.enums.EnumAppType; +import com.iformall.enums.EnumWechatSubscribe; import com.iformall.mp.builder.TextBuilder; +import com.iformall.service.WxAuthorizerInfoService; +import com.iformall.service.WxCUserService; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; import me.chanjar.weixin.mp.bean.result.WxMpUser; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.Date; import java.util.Map; /** @@ -17,6 +25,12 @@ import java.util.Map; @Component public class SubscribeHandler extends AbstractHandler { + @Autowired + private WxAuthorizerInfoService authorizerInfoService; + + @Autowired + private WxCUserService userService; + @Override public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService weixinService, @@ -24,12 +38,39 @@ public class SubscribeHandler extends AbstractHandler { this.logger.info("新关注用户 OPENID: " + wxMessage.getFromUser()); + WxWeappInfo weappInfo = authorizerInfoService.getWeappByAppId(weixinService.getWxMpConfigStorage().getAppId()); + // 获取微信用户基本信息 try { WxMpUser userWxInfo = weixinService.getUserService() .userInfo(wxMessage.getFromUser(), null); if (userWxInfo != null) { - // TODO 可以添加关注用户到本地数据库 + WxCUser user = new WxCUser(); + user.setUnionId(userWxInfo.getUnionId()); + user.setOpenAppId(weappInfo.getOpenAppid()); + if(weappInfo.getType().equals(EnumAppType.MP_S.getCode())) { + user.setMpAppId(weappInfo.getAuthorizerAppid()); + user.setMpOpenId(userWxInfo.getOpenId()); + user.setMpSubscribe(EnumWechatSubscribe.YES.getCode()); + user.setMpSubscribeTime(new Date(userWxInfo.getSubscribeTime())); + user.setMpSubscribeScene(userWxInfo.getSubscribeScene()); + } else if(weappInfo.getType().equals(EnumAppType.MP_S.getCode())) { + user.setSubsAppId(weappInfo.getAuthorizerAppid()); + user.setSubsOpenId(userWxInfo.getOpenId()); + user.setSubsSubscribe(EnumWechatSubscribe.YES.getCode()); + user.setSubsSubscribeTime(new Date(userWxInfo.getSubscribeTime())); + user.setSubsSubscribeScene(userWxInfo.getSubscribeScene()); + } + user.setNickName(userWxInfo.getNickname()); + user.setGender(userWxInfo.getSex()); + user.setLanguage(userWxInfo.getLanguage()); + user.setCity(userWxInfo.getCity()); + user.setProvince(userWxInfo.getProvince()); + user.setCountryCode(userWxInfo.getCountry()); + user.setAvatarUrl(userWxInfo.getHeadImgUrl()); + user.setScene(userWxInfo.getQrScene()); + user.setSceneAddress(userWxInfo.getQrSceneStr()); + userService.saveOrUpdate(user); } } catch (WxErrorException e) { if (e.getError().getErrorCode() == 48001) { diff --git a/mlWechatOpen/src/main/java/com/iformall/schedule/UserUnionIdSchedule.java b/mlWechatOpen/src/main/java/com/iformall/schedule/UserUnionIdSchedule.java index bae4942..f7e4a6b 100644 --- a/mlWechatOpen/src/main/java/com/iformall/schedule/UserUnionIdSchedule.java +++ b/mlWechatOpen/src/main/java/com/iformall/schedule/UserUnionIdSchedule.java @@ -34,13 +34,14 @@ public class UserUnionIdSchedule { private final int TIME_OUT_VALUE = 4 * 60 * 1000; //4分钟 @Autowired - WxPayOrderMapper payOrderMapper; + private WxPayOrderMapper payOrderMapper; @Autowired - private WxOpenService openService; + private WxPayAccountMapper payAccountMapper; @Autowired - private WxPayAccountMapper payAccountMapper; + private WxOpenService openService; + @Autowired WxAppinfoService wxAppinfoService;