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 dc33d573b..dad1ab0bd 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxAuthorizerInfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxAuthorizerInfo.java @@ -59,6 +59,10 @@ public class WxAuthorizerInfo implements Serializable { private String currentDesc; @io.swagger.annotations.ApiModelProperty(value="当前版本发布时间",name="releaseTime") private Date releaseTime; + @io.swagger.annotations.ApiModelProperty(value="微信开放平台appId",name="openAppid") + private String openAppid; + @io.swagger.annotations.ApiModelProperty(value="绑定开发平台时间",name="bindOpenTime") + private Date bindOpenTime; @@ -84,6 +88,8 @@ public class WxAuthorizerInfo implements Serializable { ,CurrentVersion_ASC("`current_version` ASC"),CurrentVersion_DESC("`current_version` DESC") ,CurrentDesc_ASC("`current_desc` ASC"),CurrentDesc_DESC("`current_desc` DESC") ,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") ; private String value; Field(String value){ 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 e831bd387..9838377f0 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxWeappInfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxWeappInfo.java @@ -41,6 +41,8 @@ public class WxWeappInfo extends WxAuthorizerInfo { ,CurrentVersion_ASC("ai.`current_version` ASC"),CurrentVersion_DESC("ai.`current_version` DESC") ,CurrentDesc_ASC("ai.`current_desc` ASC"),CurrentDesc_DESC("ai.`current_desc` DESC") ,ReleaseTime_ASC("ai.`release_time` ASC"),ReleaseTime_DESC("ai.`release_time` DESC") + ,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") ,Type_ASC("a.`type` ASC"),Type_DESC("a.`type` DESC") ; diff --git a/mallinkService/src/main/java/com/iformall/service/WxAuthorizerInfoService.java b/mallinkService/src/main/java/com/iformall/service/WxAuthorizerInfoService.java index 6faaf948f..c09398677 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxAuthorizerInfoService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxAuthorizerInfoService.java @@ -75,5 +75,7 @@ public interface WxAuthorizerInfoService { void updateWebDomainUrl(WxAuthorizerInfo record); void updateTemplate(WxAuthorizerInfo record); - + + void updateOpenAppid(WxAuthorizerInfo record); + } 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 8c54ccb5d..9ddce662d 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxAuthorizerInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxAuthorizerInfoServiceImpl.java @@ -165,6 +165,16 @@ public class WxAuthorizerInfoServiceImpl implements WxAuthorizerInfoService { info.setUpdateTime(curDate); authorizerInfoMapper.updateByPrimaryKeySelective(record); } + + @Override + public void updateOpenAppid(WxAuthorizerInfo record) { + Date curDate = new Date(); + WxAuthorizerInfo info = new WxAuthorizerInfo(); + info.setId(record.getId()); + info.setOpenAppid(record.getOpenAppid()); + info.setBindOpenTime(curDate); + authorizerInfoMapper.updateByPrimaryKeySelective(record); + } diff --git a/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml index 0a3a7cd68..95ac1376b 100644 --- a/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml @@ -22,12 +22,15 @@ + + `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` + `current_version`,`current_desc`,`release_time`, + `open_appid`,`bind_open_time` @@ -91,6 +94,12 @@ and `release_time` = #{releaseTime} + + + and `open_appid` = #{openAppid} + + + and `bind_open_time` = #{bindOpenTime} and id in @@ -112,7 +121,6 @@ where `authorizer_appid` = #{authorizerAppid} - @@ -134,6 +142,8 @@ + + @@ -146,6 +156,7 @@ ai.`webdomain_status`,ai.`webdomain_time`, ai.`template_status`,ai.`template_time`, ai.`current_version`,ai.`current_desc`,ai.`release_time`, + ai.`open_appid`,ai.`bind_open_time`, a.`type`,a.`name` @@ -196,6 +207,9 @@ and ai.`current_version` = #{currentVersion} + + and ai.`open_appid` = #{openAppid} + and ai.id in diff --git a/mallinkWechatOpen/src/main/java/com/iformall/controller/WechatCalllbackController.java b/mallinkWechatOpen/src/main/java/com/iformall/controller/WechatCalllbackController.java index 2802e179c..f5c850d7b 100644 --- a/mallinkWechatOpen/src/main/java/com/iformall/controller/WechatCalllbackController.java +++ b/mallinkWechatOpen/src/main/java/com/iformall/controller/WechatCalllbackController.java @@ -1,5 +1,9 @@ package com.iformall.controller; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.iformall.common.Result; +import com.iformall.common.ResultData; import com.iformall.domain.po.*; import com.iformall.enums.EnumWeappAuditStatus; import com.iformall.enums.EnumWxAuthorizationInfoType; @@ -14,7 +18,9 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage; import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; +import me.chanjar.weixin.open.bean.result.WxOpenPlatformResult; import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; +import me.chanjar.weixin.open.bean.result.WxOpenResult; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -312,53 +318,78 @@ public class WechatCalllbackController extends BaseController { @GetMapping(value = "/createOpenPlatform") @ApiOperation("创建微信开放平台") - public String createOpenPlatform(@RequestParam(value="appId") String appId) { + public ResultData createOpenPlatform(@RequestParam(value="appId") String appId) { + Gson gson = new GsonBuilder().create(); try { - String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).createOpenPlatform(appId); - logger.info(llstr); - return llstr; + String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).createOpenPlatform(appId); + logger.info(responseStr); + WxOpenPlatformResult openPlatformResult = gson.fromJson(responseStr, WxOpenPlatformResult.class); + if(openPlatformResult.isSuccess()) { + WxAuthorizerInfo authorizerInfo = authorizerInfoService.getByAppId(appId); + if(authorizerInfo != null) { + authorizerInfo.setId(authorizerInfo.getId()); + authorizerInfo.setOpenAppid(openPlatformResult.getOpenAppid()); + authorizerInfoService.updateOpenAppid(authorizerInfo); + } + } + return new ResultData(responseStr); } catch (WxErrorException e) { logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); } - return null; } @GetMapping(value = "/bindOpenPlatform") @ApiOperation("绑定微信开放平台") - public String bindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { + public ResultData bindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { + Gson gson = new GsonBuilder().create(); try { - String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).bindOpenPlatform(appId, openAppId); - logger.info(llstr); - return llstr; + String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).bindOpenPlatform(appId, openAppId); + logger.info(responseStr); + WxOpenResult openResult = gson.fromJson(responseStr, WxOpenResult.class); + if(openResult.isSuccess()) { + return new ResultData(); + } + return new ResultData(Result.ERROR, responseStr); } catch (WxErrorException e) { logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); } - return null; } @GetMapping(value = "/unbindOpenPlatform") @ApiOperation("解绑微信开放平台") - public String unbindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { + public ResultData unbindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { + Gson gson = new GsonBuilder().create(); try { - String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).unbindOpenPlatform(appId, openAppId); - logger.info(llstr); - return llstr; + String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).unbindOpenPlatform(appId, openAppId); + logger.info(responseStr); + WxOpenResult openResult = gson.fromJson(responseStr, WxOpenResult.class); + if(openResult.isSuccess()) { + return new ResultData(); + } + return new ResultData(Result.ERROR, responseStr); } catch (WxErrorException e) { logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); } - return null; } @GetMapping(value = "/getOpenPlatform") - @ApiOperation("获取微信开放平台") - public String getOpenPlatform(@RequestParam(value = "appId") String appId) { + @ApiOperation("获取微信开放平台appId") + public ResultData getOpenPlatform(@RequestParam(value = "appId") String appId) { + Gson gson = new GsonBuilder().create(); try { - String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getBindOpenPlatform(appId); - logger.info(llstr); - return llstr; + String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getBindOpenPlatform(appId); + logger.info(responseStr); + WxOpenPlatformResult openPlatformResult = gson.fromJson(responseStr, WxOpenPlatformResult.class); + if(openPlatformResult.isSuccess()) { + return new ResultData(openPlatformResult.getOpenAppid()); + } + return new ResultData(Result.ERROR, responseStr); } catch (WxErrorException e) { logger.error(e.getMessage()); + return new ResultData(Result.ERROR, e.getMessage()); } - return null; } }