From 6df5f0e82666decfde29980c11bdf9c5be1c606d Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Wed, 10 Apr 2019 13:11:54 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=85=AC=E4=BC=97=E5=8F=B7=E4=BC=9A=E5=91=98]?= =?UTF-8?q?[=E6=96=B0=E5=A2=9E]:=E5=85=AC=E4=BC=97=E5=8F=B7=E4=BC=9A?= =?UTF-8?q?=E5=91=98=E5=90=8C=E6=AD=A5=E3=80=81=E5=85=B3=E6=B3=A8=E3=80=81?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=85=B3=E6=B3=A8=E7=AD=89=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/dto/WxCUserBasicInfoDto.java | 144 +++++ .../iformall/domain/po/WxAuthorizerInfo.java | 6 + .../java/com/iformall/domain/po/WxCUser.java | 600 ++++++++++++++++++ .../com/iformall/domain/vo/WxWeappInfo.java | 8 +- .../mapper/WxAuthorizerInfoMapper.java | 17 +- .../com/iformall/mapper/WxCUserMapper.java | 27 + .../com/iformall/service/WxCUserService.java | 85 +++ .../service/impl/WxCUserServiceImpl.java | 140 ++++ .../java/com/iformall/utils/Constant.java | 10 + .../mapper/WxAuthorizerInfoMapper.xml | 245 +++---- .../main/resources/mapper/WxCUserMapper.xml | 294 +++++++++ .../mapper/WxComponentVerifyTicketMapper.xml | 92 ++- .../resources/mapper/WxPayAccountMapper.xml | 10 +- .../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 | 43 +- .../iformall/mp/handler/SubscribeHandler.java | 19 +- .../mp/handler/UnsubscribeHandler.java | 24 +- 22 files changed, 1896 insertions(+), 506 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/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/WxAuthorizerInfo.java b/mallinkService/src/main/java/com/iformall/domain/po/WxAuthorizerInfo.java index a016961..01a03e8 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxAuthorizerInfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxAuthorizerInfo.java @@ -21,6 +21,10 @@ public class WxAuthorizerInfo implements Serializable { @Transient protected String sortColumns; + @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") + private String tenantId; + @io.swagger.annotations.ApiModelProperty(value="1B端2C端",name="type") + private Integer type; @io.swagger.annotations.ApiModelProperty(value="授权方appid",name="authorizerAppid") private String authorizerAppid; @io.swagger.annotations.ApiModelProperty(value="授权方头像",name="headImg") @@ -75,6 +79,7 @@ public class WxAuthorizerInfo implements Serializable { public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") + ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") ,AuthorizerAppid_ASC("`authorizer_appid` ASC"),AuthorizerAppid_DESC("`authorizer_appid` DESC") ,HeadImg_ASC("`head_img` ASC"),HeadImg_DESC("`head_img` DESC") ,Alias_ASC("`alias` ASC"),Alias_DESC("`alias` DESC") @@ -96,6 +101,7 @@ public class WxAuthorizerInfo implements Serializable { ,ReleaseTime_ASC("`release_time` ASC"),ReleaseTime_DESC("`release_time` DESC") ,OpenAppId_ASC("`open_appid` ASC"),OpenAppId_DESC("`open_appid` DESC") ,BindOpenTime_ASC("`bind_open_time` ASC"),BindOpen_DESC("`bind_open_time` DESC") + ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") ; private String value; Field(String value){ 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..04471c0 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java @@ -0,0 +1,600 @@ +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; + /**积分**/ + @io.swagger.annotations.ApiModelProperty(value="积分",name="credit") + private Integer credit; + + + //渠道名称 + @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 Integer getCredit() { + return credit; + } + + public void setCredit(Integer credit) { + this.credit = credit; + } + + 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") + ,Credit_ASC("`credit` ASC"),Credit_DESC("`credit` 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() - Constant.H_EXPIRE < currentDate.getTime()) + { + //生成一个token + this.token = UUID.randomUUID().toString(); + //过期时间 + this.expireTime = new Date(currentDate.getTime() + Constant.EXPIRE); + } + return this.token; + } +} diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxWeappInfo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxWeappInfo.java index 06d360f..1be27ae 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxWeappInfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxWeappInfo.java @@ -11,16 +11,14 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) public class WxWeappInfo extends WxAuthorizerInfo { - @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") - private String tenantId; - @io.swagger.annotations.ApiModelProperty(value="小程序类型(1-B端 2-C端)",name="type") - private Integer type; @io.swagger.annotations.ApiModelProperty(value="小程序名称",name="name") private String name; public static enum Field { Id_ASC("ai.`id` ASC"),Id_DESC("ai.`id` DESC") + ,TenantID_ASC("ai.`tenant_id` ASC"),TenantID_DESC("ai.`tenant_id` DESC") + ,Type_ASC("ai.`type` ASC"),Type_DESC("ai.`type` DESC") ,AuthorizerAppid_ASC("ai.`authorizer_appid` ASC"),AuthorizerAppid_DESC("ai.`authorizer_appid` DESC") ,HeadImg_ASC("ai.`head_img` ASC"),HeadImg_DESC("ai.`head_img` DESC") ,Alias_ASC("ai.`alias` ASC"),Alias_DESC("ai.`alias` DESC") @@ -43,8 +41,6 @@ public class WxWeappInfo extends WxAuthorizerInfo { ,OpenAppid_ASC("ai.`open_appid` ASC"),OpenAppid_DESC("ai.`open_appid` DESC") ,BindOpenTime_ASC("ai.`bind_open_time` ASC"),BindOpenTime_DESC("ai.`bind_open_time` DESC") ,Name_ASC("a.`name` ASC"),Name_DESC("a.`name` DESC") - ,TenantID_ASC("a.`tenant_id` ASC"),TenantID_DESC("a.`tenant_id` DESC") - ,Type_ASC("a.`type` ASC"),Type_DESC("a.`type` DESC") ; private String value; Field(String value){ diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxAuthorizerInfoMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxAuthorizerInfoMapper.java index 1c4d3a4..ffe24d6 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxAuthorizerInfoMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxAuthorizerInfoMapper.java @@ -9,21 +9,22 @@ public interface WxAuthorizerInfoMapper extends CommonMapper findList(WxAuthorizerInfo wxAuthorizerInfo); - List findWeappList(); - - List findWxMpList(); + WxAuthorizerInfo findMp(WxAuthorizerInfo wxAuthorizerInfo); - List findVoList(WxWeappInfo wxWeappInfo); + WxAuthorizerInfo findWeChatMp(WxAuthorizerInfo wxAuthorizerInfo); int updateReleaseInfo(WxAuthorizerInfo wxAuthorizerInfo); int updateRefreshToken(WxAuthorizerInfo wxAuthorizerInfo); int updateAccessToken(WxAuthorizerInfo wxAuthorizerInfo); - - - - + List findWeappList(); + + List findWxMpList(); + + List findVoList(WxWeappInfo wxWeappInfo); + + } 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/WxCUserService.java b/mallinkService/src/main/java/com/iformall/service/WxCUserService.java new file mode 100644 index 0000000..572ed99 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/WxCUserService.java @@ -0,0 +1,85 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.domain.dto.WxCUserBasicInfoDto; +import com.iformall.domain.po.WxAuthorizerInfo; +import com.iformall.domain.po.WxCUser; +import me.chanjar.weixin.mp.bean.result.WxMpUser; + +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); + + /** + * 根据object获得实体 + * + * @param record + * @return + */ + WxCUser getByObject(WxCUser record); + + /** + * 保存或更新实体 + * + * @param record + */ + int saveOrUpdate(WxCUser record); + + /** + * 保存或更新实体 + * + * @param mpUser + * @param authorizerInfo + */ + int saveOrUpdateMpUser(WxMpUser mpUser, WxAuthorizerInfo authorizerInfo); + + /** + * 根据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/WxCUserServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserServiceImpl.java new file mode 100644 index 0000000..5e12cb8 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserServiceImpl.java @@ -0,0 +1,140 @@ +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.WxAuthorizerInfo; +import com.iformall.domain.po.WxCUser; +import com.iformall.enums.EnumAppType; +import com.iformall.mapper.WxCUserMapper; +import com.iformall.service.WxCUserService; +import me.chanjar.weixin.mp.bean.result.WxMpUser; +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 WxCUser getByObject(WxCUser record) { + try { + return wxCUserMapper.selectOne(record); + } catch (Exception e) { + logger.error("NOT found: " + e.getMessage()); + } + return null; + } + + @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 int saveOrUpdateMpUser(WxMpUser mpUser, WxAuthorizerInfo authorizerInfo) { + // 1. check user exist + WxCUser userQ = new WxCUser(); + userQ.setTenantId(authorizerInfo.getTenantId()); + userQ.setUnionId(mpUser.getUnionId()); + userQ.setOpenAppId(authorizerInfo.getOpenAppid()); + if(authorizerInfo.getType().equals(EnumAppType.MP_S.getCode())) { + userQ.setMpOpenId(mpUser.getOpenId()); + userQ.setMpAppId(authorizerInfo.getAuthorizerAppid()); + } else if(authorizerInfo.getType().equals(EnumAppType.MP_P.getCode())) { + userQ.setSubsOpenId(mpUser.getOpenId()); + userQ.setSubsAppId(authorizerInfo.getAuthorizerAppid()); + } + WxCUser oldUser = getByObject(userQ); + if(oldUser != null) { + userQ.setId(oldUser.getId()); + } + if(StringUtils.isBlank(oldUser.getNickName()) && StringUtils.isNotBlank(mpUser.getNickname())) { + userQ.setNickName(mpUser.getNickname()); + userQ.setGender(mpUser.getSex()); + userQ.setAvatarUrl(mpUser.getHeadImgUrl()); + userQ.setCity(mpUser.getCity()); + userQ.setProvince(mpUser.getProvince()); + userQ.setLanguage(mpUser.getLanguage()); + } + if(authorizerInfo.getType().equals(EnumAppType.MP_S.getCode())) { + userQ.setMpSubscribe(mpUser.getSubscribe()?1:0); + userQ.setMpSubscribeScene(mpUser.getSubscribeScene()); + userQ.setMpSubscribeTime(new Date(mpUser.getSubscribeTime())); + } else if(authorizerInfo.getType().equals(EnumAppType.MP_P.getCode())) { + userQ.setSubsSubscribe(mpUser.getSubscribe()?1:0); + userQ.setSubsSubscribeScene(mpUser.getSubscribeScene()); + userQ.setMpSubscribeTime(new Date(mpUser.getSubscribeTime())); + } + return saveOrUpdate(userQ); + } + + @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..42f7d2e 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 H_EXPIRE = 3600000; + + // TOKEN过期时间, 24小时后过期 + public final static int EXPIRE = H_EXPIRE * 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/WxAuthorizerInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml index 9c45d6d..e5b181b 100644 --- a/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml @@ -1,68 +1,76 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - `id`,`authorizer_appid`,`head_img`,`alias`,`qrcode_url`,`create_time`,`authorization_status`,`auth_time`, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`type`,`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`, `open_appid`,`bind_open_time`,`refresh_token`, `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 `tenant_id` = #{tenantId} + + + and `type` = #{type} + + + 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 +102,7 @@ and `current_version` = #{currentVersion} - and `current_desc` like concat('%', #{currentDesc},'%') + and `current_desc` like concat('%', #{currentDesc},'%') and `release_time` = #{releaseTime} @@ -105,68 +113,85 @@ 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} + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - ai.`id`,ai.`authorizer_appid`,ai.`head_img`,ai.`alias`,ai.`qrcode_url`,ai.`create_time`,ai.`update_time`, + ai.`id`,ai.`tenant_id`,ai.`type`,ai.`authorizer_appid`,ai.`head_img`,ai.`alias`,ai.`qrcode_url`,ai.`create_time`,ai.`update_time`, ai.`authorization_status`,ai.`auth_time`, ai.`base_status`,ai.`base_time`, ai.`domain_status`,ai.`domain_time`, @@ -174,7 +199,7 @@ ai.`template_status`,ai.`template_time`, ai.`current_version`,ai.`current_desc`,ai.`release_time`, ai.`open_appid`,ai.`bind_open_time`, - a.`tenant_id`,a.`type`,a.`name` + a.`name` @@ -185,8 +210,11 @@ and a.`name` like concat('%', #{name},'%') + + and ai.`tenant_id` = #{tenantId} + - and a.`type` = #{type} + and ai.`type` = #{type} and ai.`authorizer_appid` = #{authorizerAppid} @@ -233,29 +261,32 @@ #{idItem} - order by ${sortColumns} + order by ${sortColumns} - + select + from wx_authorizer_info ai left join wx_appinfo a on ai.`authorizer_appid` = a.app_id where a.type = 1 or a.type = 2 - + select + from wx_authorizer_info ai left join wx_appinfo a on ai.`authorizer_appid` = a.app_id where a.type = 3 or a.type = 4 - - + + diff --git a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml new file mode 100644 index 0000000..5972914 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `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`,`credit` + + + + 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 `credit` = #{credit} + + + + 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/WxPayAccountMapper.xml b/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml index 301d78a..1bd9d5c 100644 --- a/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml @@ -4,7 +4,7 @@ - + @@ -14,7 +14,7 @@ - `id`,`mch_id`,`parent_mch_id`,`api_key`,`notify_url`,`cert_path`,`type`,`share`,`rate` + `id`,`mch_id`,`sub_mch_id`,`api_key`,`notify_url`,`cert_path`,`type`,`share`,`rate` @@ -25,11 +25,11 @@ - and `mch_id` like concat('%', #{mchId},'%') + and `mch_id` = #{mchId} - - and `parent_mch_id` like concat('%', #{parentMchId},'%') + + and `sub_mch_id` = #{subMchId} 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..67e87c2 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.WxAuthorizerInfo; +import com.iformall.domain.po.WxCUser; +import com.iformall.enums.EnumAppType; +import com.iformall.mapper.WxAuthorizerInfoMapper; +import com.iformall.mapper.WxCUserMapper; import com.iformall.mp.manager.WxMpManager; +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; /** @@ -28,22 +35,40 @@ public class WxMemController { @Autowired private WxMpManager wxMpManager; + @Autowired + private WxAuthorizerInfoMapper wxAuthorizerInfoMapper; + + @Autowired + private WxCUserService userService; + @GetMapping("/syncAccountFansList") public ResultData syncAccountFansList(@PathVariable String appId) throws WxErrorException { 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()); + + WxAuthorizerInfo authQ = new WxAuthorizerInfo(); + authQ.setAuthorizerAppid(appId); + WxAuthorizerInfo authorizerInfo = wxAuthorizerInfoMapper.findWeChatMp(authQ); + + String nextOpenId = null; + + while (true) { + WxMpUserList mpUserList = wxService.getUserService().userList(nextOpenId); logger.info(mpUserList.toString()); - if(mpUserList.getOpenids().size() > 0) { - userList = wxService.getUserService().userInfoList(mpUserList.getOpenids()); - logger.info(userList.toString()); + List userList = wxService.getUserService().userInfoList(mpUserList.getOpenids()); + logger.info(userList.toString()); + saveToDB(userList, authorizerInfo); + nextOpenId = mpUserList.getNextOpenid(); + if(StringUtils.isBlank(nextOpenId)) { + break; } } return new ResultData(); } + + private void saveToDB(List userList, WxAuthorizerInfo authorizerInfo) { + for(WxMpUser mpUser: userList) { + userService.saveOrUpdateMpUser(mpUser, authorizerInfo); + } + } } 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..5278436 100644 --- a/mlWechatOpen/src/main/java/com/iformall/mp/handler/SubscribeHandler.java +++ b/mlWechatOpen/src/main/java/com/iformall/mp/handler/SubscribeHandler.java @@ -1,12 +1,16 @@ package com.iformall.mp.handler; +import com.iformall.domain.po.WxAuthorizerInfo; +import com.iformall.mapper.WxAuthorizerInfoMapper; import com.iformall.mp.builder.TextBuilder; +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.Map; @@ -17,6 +21,12 @@ import java.util.Map; @Component public class SubscribeHandler extends AbstractHandler { + @Autowired + private WxAuthorizerInfoMapper wxAuthorizerInfoMapper; + + @Autowired + private WxCUserService userService; + @Override public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService weixinService, @@ -24,12 +34,17 @@ public class SubscribeHandler extends AbstractHandler { this.logger.info("新关注用户 OPENID: " + wxMessage.getFromUser()); + String appId = weixinService.getWxMpConfigStorage().getAppId(); + WxAuthorizerInfo authQ = new WxAuthorizerInfo(); + authQ.setAuthorizerAppid(appId); + WxAuthorizerInfo authorizerInfo = wxAuthorizerInfoMapper.findWeChatMp(authQ); + // 获取微信用户基本信息 try { WxMpUser userWxInfo = weixinService.getUserService() - .userInfo(wxMessage.getFromUser(), null); + .userInfo(wxMessage.getFromUser()); if (userWxInfo != null) { - // TODO 可以添加关注用户到本地数据库 + userService.saveOrUpdateMpUser(userWxInfo, authorizerInfo); } } catch (WxErrorException e) { if (e.getError().getErrorCode() == 48001) { diff --git a/mlWechatOpen/src/main/java/com/iformall/mp/handler/UnsubscribeHandler.java b/mlWechatOpen/src/main/java/com/iformall/mp/handler/UnsubscribeHandler.java index 9fa0f70..a20d9a6 100644 --- a/mlWechatOpen/src/main/java/com/iformall/mp/handler/UnsubscribeHandler.java +++ b/mlWechatOpen/src/main/java/com/iformall/mp/handler/UnsubscribeHandler.java @@ -1,9 +1,14 @@ package com.iformall.mp.handler; +import com.iformall.domain.po.WxAuthorizerInfo; +import com.iformall.mapper.WxAuthorizerInfoMapper; +import com.iformall.service.WxCUserService; 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.Map; @@ -14,13 +19,30 @@ import java.util.Map; @Component public class UnsubscribeHandler extends AbstractHandler { + @Autowired + private WxAuthorizerInfoMapper wxAuthorizerInfoMapper; + + @Autowired + private WxCUserService userService; + @Override public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map context, WxMpService wxMpService, WxSessionManager sessionManager) { String openId = wxMessage.getFromUser(); this.logger.info("取消关注用户 OPENID: " + openId); - // TODO 可以更新本地数据库为取消关注状态 + String appId = wxMpService.getWxMpConfigStorage().getAppId(); + WxAuthorizerInfo authQ = new WxAuthorizerInfo(); + authQ.setAuthorizerAppid(appId); + WxAuthorizerInfo authorizerInfo = wxAuthorizerInfoMapper.findWeChatMp(authQ); + + WxMpUser mpUser = new WxMpUser(); + mpUser.setOpenId(wxMessage.getFromUser()); + mpUser.setSubscribe(false); + mpUser.setSubscribeTime(wxMessage.getCreateTime()); + + userService.saveOrUpdateMpUser(mpUser, authorizerInfo); + return null; }