| @@ -22,13 +22,21 @@ import tk.mybatis.spring.annotation.MapperScan; | |||||
| @EnableRocketMQ | @EnableRocketMQ | ||||
| public class UserApplication { | public class UserApplication { | ||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| @Value("${fm.open}") | |||||
| private boolean fmOpen; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| @Bean | |||||
| public boolean isFmOpen() { | |||||
| return fmOpen; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| SpringApplication.run(UserApplication.class, args); | SpringApplication.run(UserApplication.class, args); | ||||
| @@ -74,20 +74,6 @@ public class WxAppinfoController extends BaseController { | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxAppinfoService.getById(id)); | return new ResultData(Result.SUCCESS, "查询成功", wxAppinfoService.getById(id)); | ||||
| } | } | ||||
| @ApiOperation("C端更新AccessToken, 无限制二维码生成需要更新token") | |||||
| @GetMapping("/accessTokenUpdate") | |||||
| public ResultData ctokenUpdate() { | |||||
| logger.debug("[" + getIpAddr() + "] WxAppinfoController::ctokenUpdate"); | |||||
| try { | |||||
| wxAppinfoService.ctokenUpdate(getTenantId()); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation(value = "下载二维码", notes = "参数{\"pageUrl\":\"String\", \"sceneParam\":\"二维码参数\", \"type\":0:有限二维码,1:无限二维码,\"withText\":int(0:不带字, 1:加一行字,2:加两行字),\"text1\":\"String\",\"text2\":\"String\"}") | @ApiOperation(value = "下载二维码", notes = "参数{\"pageUrl\":\"String\", \"sceneParam\":\"二维码参数\", \"type\":0:有限二维码,1:无限二维码,\"withText\":int(0:不带字, 1:加一行字,2:加两行字),\"text1\":\"String\",\"text2\":\"String\"}") | ||||
| @PostMapping("/downQrCode") | @PostMapping("/downQrCode") | ||||
| public ResultData downQrCode(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> params) { | public ResultData downQrCode(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> params) { | ||||
| @@ -87,7 +87,6 @@ public class WxCreditHistoryController extends BaseController | |||||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::findById"); | logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::findById"); | ||||
| return new ResultData(Result.SUCCESS,"查询成功",wxCreditHistoryService.getById(id)); | return new ResultData(Result.SUCCESS,"查询成功",wxCreditHistoryService.getById(id)); | ||||
| } | } | ||||
| } | } | ||||
| @@ -22,7 +22,7 @@ spring: | |||||
| poolPreparedStatements: true | poolPreparedStatements: true | ||||
| maxOpenPreparedStatements: 20 | maxOpenPreparedStatements: 20 | ||||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | ||||
| #jackson: | |||||
| #jackson: | |||||
| #date-format: yyyy-MM-dd HH:mm:ss | #date-format: yyyy-MM-dd HH:mm:ss | ||||
| # REDIS | # REDIS | ||||
| redis: | redis: | ||||
| @@ -85,6 +85,25 @@ wechat: | |||||
| appId: "wxe31beafbfd8295ba" | appId: "wxe31beafbfd8295ba" | ||||
| secret: "c689fabf3c4c9f5b6424ff2a36a26727" | secret: "c689fabf3c4c9f5b6424ff2a36a26727" | ||||
| url: "https://mall.youlane.cn" | url: "https://mall.youlane.cn" | ||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 500 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| jasypt: | jasypt: | ||||
| encryptor: | encryptor: | ||||
| @@ -92,6 +111,8 @@ jasypt: | |||||
| fm: | fm: | ||||
| exception: false | exception: false | ||||
| deploy: 1 | |||||
| open: false | |||||
| ueditor: | ueditor: | ||||
| config: config.json | config: config.json | ||||
| @@ -44,13 +44,13 @@ spring: | |||||
| password: ENC(APQMO9XQRzMKd0eap+oSSOYH9MQe/r5K0YFF9A9mizU=) # 授权密码 | password: ENC(APQMO9XQRzMKd0eap+oSSOYH9MQe/r5K0YFF9A9mizU=) # 授权密码 | ||||
| properties: | properties: | ||||
| mail: | mail: | ||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| socketFactory: | |||||
| port: 465 | |||||
| class: javax.net.ssl.SSLSocketFactory | |||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| socketFactory: | |||||
| port: 465 | |||||
| class: javax.net.ssl.SSLSocketFactory | |||||
| # RABBITMQ | # RABBITMQ | ||||
| rabbitmq: | rabbitmq: | ||||
| host: localhost | host: localhost | ||||
| @@ -73,9 +73,30 @@ wechat: | |||||
| appId: "wx9cc4ca09eb20fe03" | appId: "wx9cc4ca09eb20fe03" | ||||
| secret: "af1d7f7a1268022a73cb4ce0b9cf0985" | secret: "af1d7f7a1268022a73cb4ce0b9cf0985" | ||||
| url: "https://admin.malls.iformall.com" | url: "https://admin.malls.iformall.com" | ||||
| open: | |||||
| componentAppId: ENC(b3JG0MUZgQfz5Zj+DC2ZM1zDeLOiGTmmeokfe2O8kaM=) | |||||
| componentSecret: ENC(QVyc4BPGdnSjXGs2ivgpDBE1v8wPWHLLRMYI7Vv8uYwC0SiZHQz0QpyyQV/b48Pb) | |||||
| componentToken: ENC(rkxj0733WxFFDLgA9x01m2s5Fi2L+0PC) | |||||
| componentAesKey: ENC(EIbJUBpbYOrLb4YQ/HXLQmxlxgAqIp2ZmpnGICC8pu5xiTz3Cqfkbwd2S8raCcK/IvYcX2GmedI=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 3 | |||||
| open: true | |||||
| ueditor: | ueditor: | ||||
| config: config.json | config: config.json | ||||
| @@ -73,9 +73,30 @@ wechat: | |||||
| appId: "wx091907dd0bfd3f6b" | appId: "wx091907dd0bfd3f6b" | ||||
| secret: "2a2ca10738998b9ef92c1fe8a4d366a6" | secret: "2a2ca10738998b9ef92c1fe8a4d366a6" | ||||
| url: "https://admintest.malls.iformall.com" | url: "https://admintest.malls.iformall.com" | ||||
| open: | |||||
| componentAppId: ENC(hnH31XdNzArfMfikKgBFpqQuJUl6rVOPFFcAVyb595o=) | |||||
| componentSecret: ENC(t/GUVX5L+U7LCwSvZ5WmxAnmTMrc/Uy1nljsrokuzzsBL2j6BEVnrS/n7DCdGc/G) | |||||
| componentToken: ENC(gUF1m0YgCCI2IY54fX6sGLZVlCswA8tG) | |||||
| componentAesKey: ENC(TYHcrIkICtfrCfGq4HW6s1b/pHf7OD2uyPN11SzJNB0acqJ/4JVX1nuljo/cAtgMG4O05TImLQc=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 2 | |||||
| open: true | |||||
| ueditor: | ueditor: | ||||
| config: config.json | config: config.json | ||||
| @@ -21,11 +21,19 @@ public class BApplication { | |||||
| @Value("${fm.exception}") | @Value("${fm.exception}") | ||||
| private boolean fmException; | private boolean fmException; | ||||
| @Value("${fm.open}") | |||||
| private boolean fmOpen; | |||||
| @Bean | @Bean | ||||
| public boolean isFmException() { | public boolean isFmException() { | ||||
| return fmException; | return fmException; | ||||
| } | } | ||||
| @Bean | |||||
| public boolean isFmOpen() { | |||||
| return fmOpen; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| SpringApplication.run(BApplication.class, args); | SpringApplication.run(BApplication.class, args); | ||||
| @@ -12,6 +12,7 @@ import com.iformall.domain.po.WxMerchantBUser; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxMerchantBUserService; | import com.iformall.service.WxMerchantBUserService; | ||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.IPUtil; | import com.iformall.utils.IPUtil; | ||||
| import com.iformall.utils.MaUtil; | import com.iformall.utils.MaUtil; | ||||
| @@ -26,12 +27,17 @@ import javax.servlet.http.HttpServletRequest; | |||||
| @RestController | @RestController | ||||
| public class BaseController { | public class BaseController { | ||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | @Autowired | ||||
| private WxMerchantBUserService wxMerchantBUserService; | private WxMerchantBUserService wxMerchantBUserService; | ||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| private FmOpenService openService; | |||||
| @InitBinder | @InitBinder | ||||
| public void InitBinder(WebDataBinder dataBinder) { | public void InitBinder(WebDataBinder dataBinder) { | ||||
| dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | ||||
| @@ -79,14 +85,21 @@ public class BaseController { | |||||
| } | } | ||||
| public WxMaService getWeappService(String appId) { | public WxMaService getWeappService(String appId) { | ||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); | |||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| if(isFmOpen) { | |||||
| return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| } else { | |||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); | |||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | |||||
| } | } | ||||
| public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | ||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| if(!isFmOpen) { | |||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | |||||
| return null; | |||||
| } | } | ||||
| public String getIpAddr() { | public String getIpAddr() { | ||||
| @@ -41,6 +41,9 @@ import java.util.Map; | |||||
| public class WxInfoController extends BaseController { | public class WxInfoController extends BaseController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoService wxAppinfoService; | WxAppinfoService wxAppinfoService; | ||||
| @@ -115,28 +118,14 @@ public class WxInfoController extends BaseController { | |||||
| private Map<String,String> getOpenIdInfo(String appId, String code) { | private Map<String,String> getOpenIdInfo(String appId, String code) { | ||||
| WxAppinfo wxAppinfo = getAppInfo(appId); | WxAppinfo wxAppinfo = getAppInfo(appId); | ||||
| WxMaService wxMaService = getWeappServiceByAppInfo(wxAppinfo); | |||||
| if(StringUtils.isBlank(wxAppinfo.getAccessToken())) { | |||||
| // 如果没有accessToken,主动获取保存到数据库中,下次访问可以拿来使用 | |||||
| try { | |||||
| String accessToken = wxMaService.getAccessToken(true); | |||||
| wxAppinfo.setAccessToken(accessToken); | |||||
| wxAppinfo.setLastTokenTime(new Date()); | |||||
| wxAppinfo.setExpiresIn(7200); | |||||
| wxAppinfoService.saveOrUpdate(wxAppinfo); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| wxMaService = getWeappServiceByAppInfo(wxAppinfo); | |||||
| WxMaService wxMaService = null; | |||||
| if(isFmOpen) { | |||||
| wxMaService = getWeappService(appId); | |||||
| } else { | } else { | ||||
| // 检查token是否已过期, 小时就重新获取 | |||||
| Date curDate = new Date(); | |||||
| if(curDate.getTime() > wxAppinfo.getLastTokenTime().getTime() + Constant.C_EXPIRE) { | |||||
| wxMaService = getWeappServiceByAppInfo(wxAppinfo); | |||||
| if(StringUtils.isBlank(wxAppinfo.getAccessToken())) { | |||||
| // 如果没有accessToken,主动获取保存到数据库中,下次访问可以拿来使用 | |||||
| try { | try { | ||||
| String accessToken = wxMaService.getAccessToken(true); | String accessToken = wxMaService.getAccessToken(true); | ||||
| wxAppinfo.setAccessToken(accessToken); | wxAppinfo.setAccessToken(accessToken); | ||||
| @@ -148,7 +137,26 @@ public class WxInfoController extends BaseController { | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| } | } | ||||
| wxMaService = getWeappServiceByAppInfo(wxAppinfo); | wxMaService = getWeappServiceByAppInfo(wxAppinfo); | ||||
| } else { | |||||
| // 检查token是否已过期, 小时就重新获取 | |||||
| Date curDate = new Date(); | |||||
| if(curDate.getTime() > wxAppinfo.getLastTokenTime().getTime() + Constant.C_EXPIRE) { | |||||
| try { | |||||
| String accessToken = wxMaService.getAccessToken(true); | |||||
| wxAppinfo.setAccessToken(accessToken); | |||||
| wxAppinfo.setLastTokenTime(new Date()); | |||||
| wxAppinfo.setExpiresIn(7200); | |||||
| wxAppinfoService.saveOrUpdate(wxAppinfo); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| wxMaService = getWeappServiceByAppInfo(wxAppinfo); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -23,7 +23,6 @@ spring: | |||||
| maxOpenPreparedStatements: 20 | maxOpenPreparedStatements: 20 | ||||
| #jackson: | #jackson: | ||||
| #date-format: yyyy-MM-dd HH:mm:ss | #date-format: yyyy-MM-dd HH:mm:ss | ||||
| # REDIS | # REDIS | ||||
| redis: | redis: | ||||
| host: 202.165.179.86 | host: 202.165.179.86 | ||||
| @@ -63,8 +62,31 @@ jasypt: | |||||
| encryptor: | encryptor: | ||||
| password: oRqdnDbK5pj3eMmB | password: oRqdnDbK5pj3eMmB | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 500 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: false | exception: false | ||||
| deploy: 1 | |||||
| open: false | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -65,8 +65,31 @@ aws: | |||||
| access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | ||||
| secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: ENC(b3JG0MUZgQfz5Zj+DC2ZM1zDeLOiGTmmeokfe2O8kaM=) | |||||
| componentSecret: ENC(QVyc4BPGdnSjXGs2ivgpDBE1v8wPWHLLRMYI7Vv8uYwC0SiZHQz0QpyyQV/b48Pb) | |||||
| componentToken: ENC(rkxj0733WxFFDLgA9x01m2s5Fi2L+0PC) | |||||
| componentAesKey: ENC(EIbJUBpbYOrLb4YQ/HXLQmxlxgAqIp2ZmpnGICC8pu5xiTz3Cqfkbwd2S8raCcK/IvYcX2GmedI=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 3 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -65,8 +65,31 @@ aws: | |||||
| access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | ||||
| secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: ENC(hnH31XdNzArfMfikKgBFpqQuJUl6rVOPFFcAVyb595o=) | |||||
| componentSecret: ENC(t/GUVX5L+U7LCwSvZ5WmxAnmTMrc/Uy1nljsrokuzzsBL2j6BEVnrS/n7DCdGc/G) | |||||
| componentToken: ENC(gUF1m0YgCCI2IY54fX6sGLZVlCswA8tG) | |||||
| componentAesKey: ENC(TYHcrIkICtfrCfGq4HW6s1b/pHf7OD2uyPN11SzJNB0acqJ/4JVX1nuljo/cAtgMG4O05TImLQc=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 2 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -21,11 +21,19 @@ public class CApplication { | |||||
| @Value("${fm.exception}") | @Value("${fm.exception}") | ||||
| private boolean fmException; | private boolean fmException; | ||||
| @Value("${fm.open}") | |||||
| private boolean fmOpen; | |||||
| @Bean | @Bean | ||||
| public boolean isFmException() { | public boolean isFmException() { | ||||
| return fmException; | return fmException; | ||||
| } | } | ||||
| @Bean | |||||
| public boolean isFmOpen() { | |||||
| return fmOpen; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| SpringApplication.run(CApplication.class, args); | SpringApplication.run(CApplication.class, args); | ||||
| @@ -9,6 +9,7 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| import com.iformall.service.WxCUserService; | import com.iformall.service.WxCUserService; | ||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.IPUtil; | import com.iformall.utils.IPUtil; | ||||
| import com.iformall.utils.MaUtil; | import com.iformall.utils.MaUtil; | ||||
| @@ -29,12 +30,18 @@ import java.util.List; | |||||
| @RestController | @RestController | ||||
| public class BaseController { | public class BaseController { | ||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserService wxCUserService; | private WxCUserService wxCUserService; | ||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | private WxCUserBasicInfoService wxCUserBasicInfoService; | ||||
| @@ -88,17 +95,25 @@ public class BaseController { | |||||
| } | } | ||||
| public WxMaService getWeappService(String appId) { | public WxMaService getWeappService(String appId) { | ||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); | |||||
| if (appinfo == null) { | |||||
| return null; | |||||
| if(isFmOpen) { | |||||
| return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| } else { | |||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); | |||||
| if (appinfo == null) { | |||||
| return null; | |||||
| } | |||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | } | ||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | } | ||||
| public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | ||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| if(!isFmOpen) { | |||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | |||||
| return null; | |||||
| } | } | ||||
| @@ -18,6 +18,7 @@ import com.iformall.enums.EnumAssignTagsTrigger; | |||||
| import com.iformall.enums.EnumLevelConfigDiscountStatus; | import com.iformall.enums.EnumLevelConfigDiscountStatus; | ||||
| import com.iformall.enums.EnumScoreType; | import com.iformall.enums.EnumScoreType; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.IPUtil; | import com.iformall.utils.IPUtil; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| @@ -47,6 +48,9 @@ import java.util.Map; | |||||
| public class WxUserGrantController extends BaseController { | public class WxUserGrantController extends BaseController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserTokenService userTokenService; | private WxCUserTokenService userTokenService; | ||||
| @@ -71,6 +75,9 @@ public class WxUserGrantController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoService wxAppinfoService; | WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| WxMerchantService wxMerchantService; | WxMerchantService wxMerchantService; | ||||
| @@ -108,19 +115,25 @@ public class WxUserGrantController extends BaseController { | |||||
| if(wxAppinfo == null) { | if(wxAppinfo == null) { | ||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| WxMaService wxMaService = getWeappServiceByAppInfo(wxAppinfo); | |||||
| WxMaService wxMaService = null; | |||||
| if(StringUtils.isBlank(wxAppinfo.getAccessToken())) { | |||||
| // 如果没有accessToken,主动获取保存到数据库中,下次访问可以拿来使用 | |||||
| updateAppAccessToken(wxAppinfo, wxMaService); | |||||
| if(isFmOpen) { | |||||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| } else { | |||||
| wxMaService = getWeappServiceByAppInfo(wxAppinfo); | wxMaService = getWeappServiceByAppInfo(wxAppinfo); | ||||
| } else { | |||||
| // 检查token是否已过期, 1小时就重新获取 | |||||
| Date curDate = new Date(); | |||||
| if(curDate.getTime() > wxAppinfo.getLastTokenTime().getTime() + Constant.C_EXPIRE) { | |||||
| if(StringUtils.isBlank(wxAppinfo.getAccessToken())) { | |||||
| // 如果没有accessToken,主动获取保存到数据库中,下次访问可以拿来使用 | |||||
| updateAppAccessToken(wxAppinfo, wxMaService); | updateAppAccessToken(wxAppinfo, wxMaService); | ||||
| wxMaService = getWeappServiceByAppInfo(wxAppinfo); | wxMaService = getWeappServiceByAppInfo(wxAppinfo); | ||||
| } else { | |||||
| // 检查token是否已过期, 1小时就重新获取 | |||||
| Date curDate = new Date(); | |||||
| if(curDate.getTime() > wxAppinfo.getLastTokenTime().getTime() + Constant.C_EXPIRE) { | |||||
| updateAppAccessToken(wxAppinfo, wxMaService); | |||||
| wxMaService = getWeappServiceByAppInfo(wxAppinfo); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -58,6 +58,26 @@ aws: | |||||
| access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | ||||
| secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 500 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| jasypt: | jasypt: | ||||
| encryptor: | encryptor: | ||||
| @@ -65,6 +85,8 @@ jasypt: | |||||
| fm: | fm: | ||||
| exception: false | exception: false | ||||
| deploy: 1 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -65,10 +65,31 @@ aws: | |||||
| access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | ||||
| secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: ENC(b3JG0MUZgQfz5Zj+DC2ZM1zDeLOiGTmmeokfe2O8kaM=) | |||||
| componentSecret: ENC(QVyc4BPGdnSjXGs2ivgpDBE1v8wPWHLLRMYI7Vv8uYwC0SiZHQz0QpyyQV/b48Pb) | |||||
| componentToken: ENC(rkxj0733WxFFDLgA9x01m2s5Fi2L+0PC) | |||||
| componentAesKey: ENC(EIbJUBpbYOrLb4YQ/HXLQmxlxgAqIp2ZmpnGICC8pu5xiTz3Cqfkbwd2S8raCcK/IvYcX2GmedI=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 3 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -65,8 +65,31 @@ aws: | |||||
| access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | ||||
| secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: ENC(hnH31XdNzArfMfikKgBFpqQuJUl6rVOPFFcAVyb595o=) | |||||
| componentSecret: ENC(t/GUVX5L+U7LCwSvZ5WmxAnmTMrc/Uy1nljsrokuzzsBL2j6BEVnrS/n7DCdGc/G) | |||||
| componentToken: ENC(gUF1m0YgCCI2IY54fX6sGLZVlCswA8tG) | |||||
| componentAesKey: ENC(TYHcrIkICtfrCfGq4HW6s1b/pHf7OD2uyPN11SzJNB0acqJ/4JVX1nuljo/cAtgMG4O05TImLQc=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 2 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -20,13 +20,21 @@ import tk.mybatis.spring.annotation.MapperScan; | |||||
| @EnableEncryptableProperties | @EnableEncryptableProperties | ||||
| public class ConsumerApplication { | public class ConsumerApplication { | ||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| @Value("${fm.open}") | |||||
| private boolean fmOpen; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| @Bean | |||||
| public boolean isFmOpen() { | |||||
| return fmOpen; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| @@ -77,6 +77,26 @@ aws: | |||||
| access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | ||||
| secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 500 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| jasypt: | jasypt: | ||||
| encryptor: | encryptor: | ||||
| @@ -84,6 +104,8 @@ jasypt: | |||||
| fm: | fm: | ||||
| exception: false | exception: false | ||||
| deploy: 1 | |||||
| open: false | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -66,10 +66,31 @@ aws: | |||||
| access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | ||||
| secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: ENC(b3JG0MUZgQfz5Zj+DC2ZM1zDeLOiGTmmeokfe2O8kaM=) | |||||
| componentSecret: ENC(QVyc4BPGdnSjXGs2ivgpDBE1v8wPWHLLRMYI7Vv8uYwC0SiZHQz0QpyyQV/b48Pb) | |||||
| componentToken: ENC(rkxj0733WxFFDLgA9x01m2s5Fi2L+0PC) | |||||
| componentAesKey: ENC(EIbJUBpbYOrLb4YQ/HXLQmxlxgAqIp2ZmpnGICC8pu5xiTz3Cqfkbwd2S8raCcK/IvYcX2GmedI=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 3 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -66,8 +66,31 @@ aws: | |||||
| access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | ||||
| secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: ENC(hnH31XdNzArfMfikKgBFpqQuJUl6rVOPFFcAVyb595o=) | |||||
| componentSecret: ENC(t/GUVX5L+U7LCwSvZ5WmxAnmTMrc/Uy1nljsrokuzzsBL2j6BEVnrS/n7DCdGc/G) | |||||
| componentToken: ENC(gUF1m0YgCCI2IY54fX6sGLZVlCswA8tG) | |||||
| componentAesKey: ENC(TYHcrIkICtfrCfGq4HW6s1b/pHf7OD2uyPN11SzJNB0acqJ/4JVX1nuljo/cAtgMG4O05TImLQc=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 2 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -20,13 +20,21 @@ import tk.mybatis.spring.annotation.MapperScan; | |||||
| @EnableEncryptableProperties | @EnableEncryptableProperties | ||||
| public class ScheduleApplication { | public class ScheduleApplication { | ||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| @Value("${fm.open}") | |||||
| private boolean fmOpen; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| @Bean | |||||
| public boolean isFmOpen() { | |||||
| return fmOpen; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| @@ -19,6 +19,9 @@ public class WeChatAccessTokenSchedule { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoMapper wxAppinfoMapper; | WxAppinfoMapper wxAppinfoMapper; | ||||
| @@ -27,12 +30,14 @@ public class WeChatAccessTokenSchedule { | |||||
| public void getAccessTokens() { | public void getAccessTokens() { | ||||
| logger.info("微信访问AccessToken获取定时任务启动"); | logger.info("微信访问AccessToken获取定时任务启动"); | ||||
| if(!isFmOpen) { | |||||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||||
| List<WxAppinfo> appList = wxAppinfoMapper.findList(appinfoQ); | |||||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||||
| List<WxAppinfo> appList = wxAppinfoMapper.findList(appinfoQ); | |||||
| for (WxAppinfo appinfo : appList) { | |||||
| resetAccessToken(appinfo); | |||||
| for (WxAppinfo appinfo : appList) { | |||||
| resetAccessToken(appinfo); | |||||
| } | |||||
| } | } | ||||
| logger.info("微信访问AccessToken获取定时任务结束"); | logger.info("微信访问AccessToken获取定时任务结束"); | ||||
| @@ -5,6 +5,7 @@ import java.util.*; | |||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
| import cn.binarywang.wx.miniapp.bean.analysis.WxMaVisitTrend; | import cn.binarywang.wx.miniapp.bean.analysis.WxMaVisitTrend; | ||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import com.iformall.utils.MaUtil; | import com.iformall.utils.MaUtil; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -24,12 +25,18 @@ import com.iformall.service.WxUserVisitService; | |||||
| @Component | @Component | ||||
| public class WxAppVisitSchedule { | public class WxAppVisitSchedule { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | |||||
| private WxUserVisitService wxUserVisitService; | |||||
| @Autowired | |||||
| private WxUserVisitService wxUserVisitService; | |||||
| @Autowired | |||||
| private WxAppinfoService WxAppinfoService; | |||||
| @Autowired | |||||
| private WxAppinfoService WxAppinfoService; | |||||
| @Autowired | |||||
| private FmOpenService openService; | |||||
| @Scheduled(cron = "0 0 9 * * ? ") //早晨9点做一次,获取前一日,微信时间为GMT | @Scheduled(cron = "0 0 9 * * ? ") //早晨9点做一次,获取前一日,微信时间为GMT | ||||
| @@ -96,7 +103,12 @@ public class WxAppVisitSchedule { | |||||
| } | } | ||||
| private void getData(Date lastDate,WxAppinfo appInfo) throws Exception { | private void getData(Date lastDate,WxAppinfo appInfo) throws Exception { | ||||
| WxMaService wxMaService = MaUtil.getWeappService(appInfo); | |||||
| WxMaService wxMaService = null; | |||||
| if(isFmOpen) { | |||||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appInfo.getAppId()); | |||||
| } else { | |||||
| wxMaService = MaUtil.getWeappService(appInfo); | |||||
| } | |||||
| try { | try { | ||||
| List<WxMaVisitTrend> vtList = wxMaService.getAnalysisService().getDailyVisitTrend(lastDate, lastDate); | List<WxMaVisitTrend> vtList = wxMaService.getAnalysisService().getDailyVisitTrend(lastDate, lastDate); | ||||
| logger.info(vtList.toString()); | logger.info(vtList.toString()); | ||||
| @@ -60,6 +60,26 @@ aws: | |||||
| access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | ||||
| secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 500 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| jasypt: | jasypt: | ||||
| encryptor: | encryptor: | ||||
| @@ -67,6 +87,8 @@ jasypt: | |||||
| fm: | fm: | ||||
| exception: false | exception: false | ||||
| deploy: 1 | |||||
| open: false | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -66,10 +66,31 @@ aws: | |||||
| access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | ||||
| secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: ENC(b3JG0MUZgQfz5Zj+DC2ZM1zDeLOiGTmmeokfe2O8kaM=) | |||||
| componentSecret: ENC(QVyc4BPGdnSjXGs2ivgpDBE1v8wPWHLLRMYI7Vv8uYwC0SiZHQz0QpyyQV/b48Pb) | |||||
| componentToken: ENC(rkxj0733WxFFDLgA9x01m2s5Fi2L+0PC) | |||||
| componentAesKey: ENC(EIbJUBpbYOrLb4YQ/HXLQmxlxgAqIp2ZmpnGICC8pu5xiTz3Cqfkbwd2S8raCcK/IvYcX2GmedI=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 3 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -66,8 +66,31 @@ aws: | |||||
| access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | ||||
| secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: ENC(hnH31XdNzArfMfikKgBFpqQuJUl6rVOPFFcAVyb595o=) | |||||
| componentSecret: ENC(t/GUVX5L+U7LCwSvZ5WmxAnmTMrc/Uy1nljsrokuzzsBL2j6BEVnrS/n7DCdGc/G) | |||||
| componentToken: ENC(gUF1m0YgCCI2IY54fX6sGLZVlCswA8tG) | |||||
| componentAesKey: ENC(TYHcrIkICtfrCfGq4HW6s1b/pHf7OD2uyPN11SzJNB0acqJ/4JVX1nuljo/cAtgMG4O05TImLQc=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 2 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -37,8 +37,8 @@ import java.util.concurrent.atomic.AtomicBoolean; | |||||
| * | * | ||||
| * @author Andy.Huo | * @author Andy.Huo | ||||
| */ | */ | ||||
| public class MipHttpClientBuilder implements ApacheHttpClientBuilder { | |||||
| protected final Logger log = LoggerFactory.getLogger(MipHttpClientBuilder.class); | |||||
| public class FmHttpClientBuilder implements ApacheHttpClientBuilder { | |||||
| protected final Logger log = LoggerFactory.getLogger(FmHttpClientBuilder.class); | |||||
| private final AtomicBoolean prepared = new AtomicBoolean(false); | private final AtomicBoolean prepared = new AtomicBoolean(false); | ||||
| private int connectionRequestTimeout = 3000; | private int connectionRequestTimeout = 3000; | ||||
| private int connectionTimeout = 5000; | private int connectionTimeout = 5000; | ||||
| @@ -85,11 +85,11 @@ public class MipHttpClientBuilder implements ApacheHttpClientBuilder { | |||||
| private IdleConnectionMonitorThread idleConnectionMonitorThread; | private IdleConnectionMonitorThread idleConnectionMonitorThread; | ||||
| private HttpClientBuilder httpClientBuilder; | private HttpClientBuilder httpClientBuilder; | ||||
| private MipHttpClientBuilder() { | |||||
| private FmHttpClientBuilder() { | |||||
| } | } | ||||
| public static MipHttpClientBuilder get() { | |||||
| return new MipHttpClientBuilder(); | |||||
| public static FmHttpClientBuilder get() { | |||||
| return new FmHttpClientBuilder(); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -0,0 +1,69 @@ | |||||
| package com.iformall.config; | |||||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
| import org.apache.commons.lang3.builder.ToStringStyle; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| /** | |||||
| * Stormeye | |||||
| */ | |||||
| @ConfigurationProperties(prefix = "wechat.open") | |||||
| public class WechatOpenProperties { | |||||
| /** | |||||
| * 设置微信三方平台的appid | |||||
| */ | |||||
| private String componentAppId; | |||||
| /** | |||||
| * 设置微信三方平台的app secret | |||||
| */ | |||||
| private String componentSecret; | |||||
| /** | |||||
| * 设置微信三方平台的token | |||||
| */ | |||||
| private String componentToken; | |||||
| /** | |||||
| * 设置微信三方平台的EncodingAESKey | |||||
| */ | |||||
| private String componentAesKey; | |||||
| public String getComponentAppId() { | |||||
| return componentAppId; | |||||
| } | |||||
| public void setComponentAppId(String componentAppId) { | |||||
| this.componentAppId = componentAppId; | |||||
| } | |||||
| public String getComponentSecret() { | |||||
| return componentSecret; | |||||
| } | |||||
| public void setComponentSecret(String componentSecret) { | |||||
| this.componentSecret = componentSecret; | |||||
| } | |||||
| public String getComponentToken() { | |||||
| return componentToken; | |||||
| } | |||||
| public void setComponentToken(String componentToken) { | |||||
| this.componentToken = componentToken; | |||||
| } | |||||
| public String getComponentAesKey() { | |||||
| return componentAesKey; | |||||
| } | |||||
| public void setComponentAesKey(String componentAesKey) { | |||||
| this.componentAesKey = componentAesKey; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return ToStringBuilder.reflectionToString(this, | |||||
| ToStringStyle.MULTI_LINE_STYLE); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,124 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import redis.clients.jedis.JedisPoolConfig; | |||||
| import redis.clients.jedis.Protocol; | |||||
| import javax.net.ssl.HostnameVerifier; | |||||
| import javax.net.ssl.SSLParameters; | |||||
| import javax.net.ssl.SSLSocketFactory; | |||||
| /** | |||||
| * Stormeye | |||||
| */ | |||||
| @ConfigurationProperties(prefix = "wechat.redis") | |||||
| public class WechatRedisProperies extends JedisPoolConfig { | |||||
| private String host = Protocol.DEFAULT_HOST; | |||||
| private int port = Protocol.DEFAULT_PORT; | |||||
| private String password; | |||||
| private int database = 1; | |||||
| private int connectionTimeout = Protocol.DEFAULT_TIMEOUT; | |||||
| private int soTimeout = Protocol.DEFAULT_TIMEOUT; | |||||
| private String clientName; | |||||
| private boolean ssl; | |||||
| private SSLSocketFactory sslSocketFactory; | |||||
| private SSLParameters sslParameters; | |||||
| private HostnameVerifier hostnameVerifier; | |||||
| public boolean isSsl() { | |||||
| return ssl; | |||||
| } | |||||
| public void setSsl(boolean ssl) { | |||||
| this.ssl = ssl; | |||||
| } | |||||
| public SSLSocketFactory getSslSocketFactory() { | |||||
| return sslSocketFactory; | |||||
| } | |||||
| public void setSslSocketFactory(SSLSocketFactory sslSocketFactory) { | |||||
| this.sslSocketFactory = sslSocketFactory; | |||||
| } | |||||
| public SSLParameters getSslParameters() { | |||||
| return sslParameters; | |||||
| } | |||||
| public void setSslParameters(SSLParameters sslParameters) { | |||||
| this.sslParameters = sslParameters; | |||||
| } | |||||
| public HostnameVerifier getHostnameVerifier() { | |||||
| return hostnameVerifier; | |||||
| } | |||||
| public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { | |||||
| this.hostnameVerifier = hostnameVerifier; | |||||
| } | |||||
| public String getHost() { | |||||
| return host; | |||||
| } | |||||
| public void setHost(String host) { | |||||
| if (host == null || "".equals(host)) { | |||||
| host = Protocol.DEFAULT_HOST; | |||||
| } | |||||
| this.host = host; | |||||
| } | |||||
| public int getPort() { | |||||
| return port; | |||||
| } | |||||
| public void setPort(int port) { | |||||
| this.port = port; | |||||
| } | |||||
| public String getPassword() { | |||||
| return password; | |||||
| } | |||||
| public void setPassword(String password) { | |||||
| if ("".equals(password)) { | |||||
| password = null; | |||||
| } | |||||
| this.password = password; | |||||
| } | |||||
| public int getDatabase() { | |||||
| return database; | |||||
| } | |||||
| public void setDatabase(int database) { | |||||
| this.database = database; | |||||
| } | |||||
| public String getClientName() { | |||||
| return clientName; | |||||
| } | |||||
| public void setClientName(String clientName) { | |||||
| if ("".equals(clientName)) { | |||||
| clientName = null; | |||||
| } | |||||
| this.clientName = clientName; | |||||
| } | |||||
| public int getConnectionTimeout() { | |||||
| return connectionTimeout; | |||||
| } | |||||
| public void setConnectionTimeout(int connectionTimeout) { | |||||
| this.connectionTimeout = connectionTimeout; | |||||
| } | |||||
| public int getSoTimeout() { | |||||
| return soTimeout; | |||||
| } | |||||
| public void setSoTimeout(int soTimeout) { | |||||
| this.soTimeout = soTimeout; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,36 @@ | |||||
| package com.iformall.domain.dto; | |||||
| import java.io.Serializable; | |||||
| public class WxCouponMerchantDto implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| Long merchantId; | |||||
| String parameter; | |||||
| Integer business; | |||||
| public Long getMerchantId() { | |||||
| return merchantId; | |||||
| } | |||||
| public void setMerchantId(Long merchantId) { | |||||
| this.merchantId = merchantId; | |||||
| } | |||||
| public String getParameter() { | |||||
| return parameter; | |||||
| } | |||||
| public void setParameter(String parameter) { | |||||
| this.parameter = parameter; | |||||
| } | |||||
| public Integer getBusiness() { | |||||
| return business; | |||||
| } | |||||
| public void setBusiness(Integer business) { | |||||
| this.business = business; | |||||
| } | |||||
| } | |||||
| @@ -71,7 +71,7 @@ public class WxCoupon implements Serializable { | |||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | ||||
| private String tenantId; | private String tenantId; | ||||
| /**券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,100.消费卡)**/ | /**券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,100.消费卡)**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,10.积分券,11积分停车券,100.消费卡)",name="type") | |||||
| @io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51积分停车券,100.消费卡)",name="type") | |||||
| private Integer type; | private Integer type; | ||||
| /**封面图**/ | /**封面图**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg") | @io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg") | ||||
| @@ -51,7 +51,7 @@ public class WxCreditHistory implements Serializable { | |||||
| @io.swagger.annotations.ApiModelProperty(value="每笔积分明细",name="creditNum") | @io.swagger.annotations.ApiModelProperty(value="每笔积分明细",name="creditNum") | ||||
| private Integer creditNum; | private Integer creditNum; | ||||
| /**积分类型*/ | /**积分类型*/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="积分类型",name="creditType") | |||||
| @io.swagger.annotations.ApiModelProperty(value="积分类型 1每日登录,2消费,3绑车牌,4连接WIFI,5微信用户昵称授权,6微信用户手机授权,7完善个人信息,8积分导入,10消费积分,11积分兑换",name="creditType") | |||||
| private Integer creditType; | private Integer creditType; | ||||
| /**创建日期*/ | /**创建日期*/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="创建日期",name="createDate") | @io.swagger.annotations.ApiModelProperty(value="创建日期",name="createDate") | ||||
| @@ -77,6 +77,9 @@ public class WxCreditHistory implements Serializable { | |||||
| /**花费*/ | /**花费*/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="花费",name="spend") | @io.swagger.annotations.ApiModelProperty(value="花费",name="spend") | ||||
| private Integer spend; | private Integer spend; | ||||
| /**兑换用途*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="兑换用途",name="changePurpose") | |||||
| private String changePurpose; | |||||
| @@ -9,9 +9,19 @@ public interface WxAuthorizerInfoMapper extends CommonMapper<WxAuthorizerInfo, L | |||||
| List<WxAuthorizerInfo> findList(WxAuthorizerInfo wxAuthorizerInfo); | List<WxAuthorizerInfo> findList(WxAuthorizerInfo wxAuthorizerInfo); | ||||
| List<WxWeappInfo> findWeappList(); | |||||
| List<WxWeappInfo> findWxMpList(); | |||||
| List<WxWeappInfo> findVoList(WxWeappInfo wxWeappInfo); | List<WxWeappInfo> findVoList(WxWeappInfo wxWeappInfo); | ||||
| void updateReleaseInfo(WxAuthorizerInfo wxAuthorizerInfo); | |||||
| WxWeappInfo findVo(WxWeappInfo wxWeappInfo); | |||||
| int updateReleaseInfo(WxAuthorizerInfo wxAuthorizerInfo); | |||||
| int updateRefreshToken(WxAuthorizerInfo wxAuthorizerInfo); | |||||
| int updateAccessToken(WxAuthorizerInfo wxAuthorizerInfo); | |||||
| @@ -7,10 +7,8 @@ import com.iformall.domain.po.WxComponentVerifyTicket; | |||||
| public interface WxComponentVerifyTicketMapper extends CommonMapper<WxComponentVerifyTicket, Long> { | public interface WxComponentVerifyTicketMapper extends CommonMapper<WxComponentVerifyTicket, Long> { | ||||
| List<WxComponentVerifyTicket> findList(WxComponentVerifyTicket wxComponentVerifyTicket); | List<WxComponentVerifyTicket> findList(WxComponentVerifyTicket wxComponentVerifyTicket); | ||||
| int updateAccessToken(WxComponentVerifyTicket wxComponentVerifyTicket); | |||||
| } | } | ||||
| @@ -63,13 +63,6 @@ public interface WxAppinfoService { | |||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| /** | |||||
| * 更新accessToken | |||||
| * @param appId | |||||
| */ | |||||
| void ctokenUpdate(String appId); | |||||
| /** | /** | ||||
| * 位置码/导购码生成 | * 位置码/导购码生成 | ||||
| */ | */ | ||||
| @@ -8,6 +8,7 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxTemplateMsgMapper; | import com.iformall.mapper.WxTemplateMsgMapper; | ||||
| import com.iformall.service.MsgSendService; | import com.iformall.service.MsgSendService; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import com.iformall.utils.MaUtil; | import com.iformall.utils.MaUtil; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -24,18 +25,28 @@ import java.util.List; | |||||
| public class SendSmartAppMsgServiceImpl implements MsgSendService { | public class SendSmartAppMsgServiceImpl implements MsgSendService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @Autowired | ||||
| private boolean isFmOpen; | |||||
| @Autowired | |||||
| private WxTemplateMsgMapper wxTemplateMsgMapper; | private WxTemplateMsgMapper wxTemplateMsgMapper; | ||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| private FmOpenService openService; | |||||
| @Override | @Override | ||||
| public void send(BaseMsg baseMsg) throws Exception{ | public void send(BaseMsg baseMsg) throws Exception{ | ||||
| SmartAppMsg smartAppMsg = (SmartAppMsg)baseMsg; | SmartAppMsg smartAppMsg = (SmartAppMsg)baseMsg; | ||||
| WxTemplateMsg msg = null; | WxTemplateMsg msg = null; | ||||
| WxMaTemplateMessage templateMessage; | WxMaTemplateMessage templateMessage; | ||||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(smartAppMsg.getAppId()); | |||||
| WxMaService wxMaService = MaUtil.getWeappService(appInfo); | |||||
| WxMaService wxMaService = null; | |||||
| if(isFmOpen) { | |||||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(smartAppMsg.getAppId()); | |||||
| } else { | |||||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(smartAppMsg.getAppId()); | |||||
| wxMaService = MaUtil.getWeappService(appInfo); | |||||
| } | |||||
| //查询信息模板 | //查询信息模板 | ||||
| WxTemplateMsg msgQ = new WxTemplateMsg(); | WxTemplateMsg msgQ = new WxTemplateMsg(); | ||||
| @@ -87,43 +87,6 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { | |||||
| wxAppinfoMapper.deleteByPrimaryKey(id); | wxAppinfoMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| /** | |||||
| * 租户c端小程序更新token | |||||
| * @param tenantId | |||||
| */ | |||||
| @Override | |||||
| public void ctokenUpdate(String tenantId) { | |||||
| WxAppinfo appQ = new WxAppinfo(); | |||||
| appQ.setTenantId(tenantId); | |||||
| appQ.setType(EnumAppType.C.getCode()); | |||||
| List<WxAppinfo> appList = wxAppinfoMapper.findList(appQ); | |||||
| if (appList.size() <= 0) { | |||||
| return; | |||||
| } | |||||
| WxAppinfo appinfo = appList.get(0); | |||||
| if(appinfo == null) { | |||||
| return; | |||||
| } | |||||
| // get access_token | |||||
| WxMaService wxMaService = MaUtil.getWeappService(appinfo); | |||||
| if(wxMaService == null) { | |||||
| return; | |||||
| } | |||||
| String access_token = ""; | |||||
| try{ | |||||
| access_token = wxMaService.getAccessToken(); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| Date date = new Date(); | |||||
| // update db | |||||
| appinfo.setAccessToken(access_token); | |||||
| appinfo.setLastTokenTime(date); | |||||
| wxAppinfoMapper.updateByPrimaryKeySelective(appinfo); | |||||
| } | |||||
| private void downFile(String filePath, String filename, HttpServletResponse response, HttpServletRequest req) throws IOException { | private void downFile(String filePath, String filename, HttpServletResponse response, HttpServletRequest req) throws IOException { | ||||
| try { | try { | ||||
| response.reset(); | response.reset(); | ||||
| @@ -6,6 +6,7 @@ import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; | |||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; | import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; | ||||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; | import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.google.common.collect.Lists; | import com.google.common.collect.Lists; | ||||
| @@ -445,13 +446,25 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| WxAppinfo wxAppinfo = wxAppinfoService.getCAppInfo(couponOrder.getTenantId()); | WxAppinfo wxAppinfo = wxAppinfoService.getCAppInfo(couponOrder.getTenantId()); | ||||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(wxAppinfo.getPayId()); | WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(wxAppinfo.getPayId()); | ||||
| Integer subsidyNum; | |||||
| String parameter = couponMerchant.getParameter(); | |||||
| JSONObject jParameter; | |||||
| try { | |||||
| jParameter = JSONObject.parseObject(parameter); | |||||
| } catch (Exception e) { | |||||
| jParameter = null; | |||||
| } | |||||
| // 本张券的补贴额 | |||||
| Integer subsidyFee = coupon.getSubsidyNum(); | |||||
| if (subsidyFee > 0) { | |||||
| if (jParameter != null) { | |||||
| subsidyNum = jParameter.getIntValue("subsidyNum"); | |||||
| } else { | |||||
| // 本张券的补贴额 | |||||
| subsidyNum = coupon.getSubsidyNum(); | |||||
| } | |||||
| if (subsidyNum > 0) { | |||||
| // 有补贴时入库 | // 有补贴时入库 | ||||
| Double dSubChargeFee = Math.ceil(subsidyFee * 1.0D * payAccount.getRate() / 10000); | |||||
| Integer realSubsidyFee = subsidyFee - dSubChargeFee.intValue(); | |||||
| Double dSubChargeFee = Math.ceil(subsidyNum * 1.0D * payAccount.getRate() / 10000); | |||||
| Integer realSubsidyFee = subsidyNum - dSubChargeFee.intValue(); | |||||
| Double priceChargeFee = Math.ceil(coupon.getSalePrice() * 1.0D * payAccount.getRate() / 10000); | Double priceChargeFee = Math.ceil(coupon.getSalePrice() * 1.0D * payAccount.getRate() / 10000); | ||||
| Integer realPayment = coupon.getSalePrice() - priceChargeFee.intValue(); | Integer realPayment = coupon.getSalePrice() - priceChargeFee.intValue(); | ||||
| @@ -463,11 +476,11 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| merchantSubsidy.setOrderType(EnumOrderType.COUPON.getCode()); | merchantSubsidy.setOrderType(EnumOrderType.COUPON.getCode()); | ||||
| merchantSubsidy.setMerchantId(merchantId); | merchantSubsidy.setMerchantId(merchantId); | ||||
| merchantSubsidy.setCouponOrderId(couponOrder.getId()); | merchantSubsidy.setCouponOrderId(couponOrder.getId()); | ||||
| merchantSubsidy.setCouponType(EnumCouponType.COUPON_MULTIMCH.getCode()); | |||||
| merchantSubsidy.setCouponType(couponOrder.getCouponType()); | |||||
| merchantSubsidy.setOrderPayment(coupon.getPrice()); | merchantSubsidy.setOrderPayment(coupon.getPrice()); | ||||
| merchantSubsidy.setReceiverPayment(coupon.getSalePrice()); | merchantSubsidy.setReceiverPayment(coupon.getSalePrice()); | ||||
| merchantSubsidy.setRealPayment(realPayment); | merchantSubsidy.setRealPayment(realPayment); | ||||
| merchantSubsidy.setSubsidy(subsidyFee); | |||||
| merchantSubsidy.setSubsidy(subsidyNum); | |||||
| merchantSubsidy.setRealSubsidy(realSubsidyFee); | merchantSubsidy.setRealSubsidy(realSubsidyFee); | ||||
| merchantSubsidy.setStatus(EnumMerchantSubsidyStatus.NOT_SUBSIDY.getCode()); | merchantSubsidy.setStatus(EnumMerchantSubsidyStatus.NOT_SUBSIDY.getCode()); | ||||
| merchantSubsidy.setCreateDate(new Date()); | merchantSubsidy.setCreateDate(new Date()); | ||||
| @@ -7,6 +7,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.dto.WxCouponMerchantDto; | |||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.po.WxCouponMerchant; | import com.iformall.domain.po.WxCouponMerchant; | ||||
| @@ -14,6 +15,7 @@ import com.iformall.domain.vo.WxCouponCVo; | |||||
| import com.iformall.domain.vo.WxCouponStatisVo; | import com.iformall.domain.vo.WxCouponStatisVo; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | import com.iformall.domain.vo.WxMerchantVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.mapper.WxCouponMapper; | import com.iformall.mapper.WxCouponMapper; | ||||
| import com.iformall.mapper.WxCouponMerchantMapper; | import com.iformall.mapper.WxCouponMerchantMapper; | ||||
| @@ -157,6 +159,22 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return Integer.valueOf(merchantParam.getString("businessId")); | return Integer.valueOf(merchantParam.getString("businessId")); | ||||
| } | } | ||||
| private WxCouponMerchantDto parseMerchantParam(JSONObject merchantParam){ | |||||
| WxCouponMerchantDto wxCouponMerchantDto = new WxCouponMerchantDto(); | |||||
| try { | |||||
| wxCouponMerchantDto.setMerchantId(parseMerchantId(merchantParam)); | |||||
| wxCouponMerchantDto.setParameter(parseParameter(merchantParam)); | |||||
| wxCouponMerchantDto.setBusiness(parseBusiness(merchantParam)); | |||||
| }catch (Exception e) { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| if (wxCouponMerchantDto.getBusiness()==null || wxCouponMerchantDto.getMerchantId()==null) { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| return wxCouponMerchantDto; | |||||
| } | |||||
| @Override | @Override | ||||
| @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | ||||
| public ResultData saveOrUpdate(WxCoupon record) { | public ResultData saveOrUpdate(WxCoupon record) { | ||||
| @@ -190,47 +208,44 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| // check 卡券补贴设置 | // check 卡券补贴设置 | ||||
| if(record.getType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || | |||||
| record.getType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { | |||||
| Integer subsidyType = record.getSubsidyType(); | |||||
| Integer subsidyNum = record.getSubsidyNum(); | |||||
| if(subsidyType == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写补贴类型"); | |||||
| } | |||||
| if(subsidyNum == null) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写补贴金额"); | |||||
| } | |||||
| if(subsidyType.equals(EnumCouponSubsidyType.WECHAT_COUPON.getCode())) { | |||||
| Integer subsidyType = record.getSubsidyType(); | |||||
| Integer subsidyNum = record.getSubsidyNum(); | |||||
| if(subsidyType != null && subsidyNum != null) { | |||||
| if (subsidyType.equals(EnumCouponSubsidyType.WECHAT_COUPON.getCode())) { | |||||
| // 微信 立减 | // 微信 立减 | ||||
| if(subsidyNum > record.getSalePrice()) { | |||||
| if (subsidyNum > record.getSalePrice()) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "补贴额大于售价"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "补贴额大于售价"); | ||||
| } | } | ||||
| } else if(subsidyType.equals(EnumCouponSubsidyType.OFFLINE_SUBSIDY.getCode())) { | |||||
| } else if (subsidyType.equals(EnumCouponSubsidyType.OFFLINE_SUBSIDY.getCode())) { | |||||
| // 线下补贴 | // 线下补贴 | ||||
| int subsidy_num = record.getPrice() - record.getSalePrice(); | int subsidy_num = record.getPrice() - record.getSalePrice(); | ||||
| if(subsidyNum > subsidy_num) { | |||||
| if (subsidyNum > subsidy_num) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "补贴额大于面额与售价的差值"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "补贴额大于面额与售价的差值"); | ||||
| } | } | ||||
| } else if(subsidyType.equals(EnumCouponSubsidyType.WECHAT_MCHPAY.getCode())) { | |||||
| } else if (subsidyType.equals(EnumCouponSubsidyType.WECHAT_MCHPAY.getCode())) { | |||||
| // TODO 微信转账到银行卡 | // TODO 微信转账到银行卡 | ||||
| } | } | ||||
| } else if ((subsidyType == null && subsidyNum != null) | |||||
| || (subsidyType != null && subsidyNum == null)){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | } | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| if (record.getMerchantParams() != null) { | |||||
| List<JSONObject> merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | |||||
| List<JSONObject> merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | |||||
| if (merchantParamList != null) { | |||||
| List<Integer> businessList= new ArrayList<>(); | List<Integer> businessList= new ArrayList<>(); | ||||
| merchantParamList.forEach(merchantParam -> { | merchantParamList.forEach(merchantParam -> { | ||||
| WxCouponMerchant cm = new WxCouponMerchant(); | WxCouponMerchant cm = new WxCouponMerchant(); | ||||
| WxCouponMerchantDto wxCouponMerchantDto = parseMerchantParam(merchantParam); | |||||
| cm.setId(idWorker.nextId()); | cm.setId(idWorker.nextId()); | ||||
| cm.setMerchantId(parseMerchantId(merchantParam)); | |||||
| cm.setParameter(parseParameter(merchantParam)); | |||||
| cm.setMerchantId(wxCouponMerchantDto.getMerchantId()); | |||||
| cm.setParameter(wxCouponMerchantDto.getParameter()); | |||||
| cm.setProductId(record.getId()); | cm.setProductId(record.getId()); | ||||
| cm.setCreateDate(new Date()); | cm.setCreateDate(new Date()); | ||||
| cm.setUpdateDate(new Date()); | cm.setUpdateDate(new Date()); | ||||
| cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| businessList.add(parseBusiness(merchantParam)); | |||||
| businessList.add(wxCouponMerchantDto.getBusiness()); | |||||
| wxCouponMerchantMapper.insertSelective(cm); | wxCouponMerchantMapper.insertSelective(cm); | ||||
| }); | }); | ||||
| if (businessList.stream().distinct().count() > 1) { | if (businessList.stream().distinct().count() > 1) { | ||||
| @@ -257,27 +272,27 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| List<Integer> businessList= new ArrayList<>(); | List<Integer> businessList= new ArrayList<>(); | ||||
| merchantParamList.stream().forEach(merchantParam -> { | merchantParamList.stream().forEach(merchantParam -> { | ||||
| WxCouponMerchant cm = new WxCouponMerchant(); | WxCouponMerchant cm = new WxCouponMerchant(); | ||||
| cm.setMerchantId(parseMerchantId(merchantParam)); | |||||
| WxCouponMerchantDto wxCouponMerchantDto = parseMerchantParam(merchantParam); | |||||
| cm.setMerchantId(wxCouponMerchantDto.getMerchantId()); | |||||
| cm.setProductId(record.getId()); | cm.setProductId(record.getId()); | ||||
| WxCouponMerchant rcm = wxCouponMerchantMapper.selectOne(cm); | WxCouponMerchant rcm = wxCouponMerchantMapper.selectOne(cm); | ||||
| if (rcm != null) { | if (rcm != null) { | ||||
| rcm.setMerchantId(Long.valueOf(parseMerchantId(merchantParam))); | |||||
| rcm.setParameter(parseParameter(merchantParam)); | |||||
| rcm.setParameter(wxCouponMerchantDto.getParameter()); | |||||
| rcm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | rcm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| rcm.setUpdateDate(new Date()); | rcm.setUpdateDate(new Date()); | ||||
| wxCouponMerchantMapper.updateByPrimaryKeySelective(rcm); | wxCouponMerchantMapper.updateByPrimaryKeySelective(rcm); | ||||
| }else { | }else { | ||||
| cm.setId(idWorker.nextId()); | cm.setId(idWorker.nextId()); | ||||
| cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| cm.setParameter(parseParameter(merchantParam)); | |||||
| cm.setParameter(wxCouponMerchantDto.getParameter()); | |||||
| cm.setCreateDate(new Date()); | cm.setCreateDate(new Date()); | ||||
| cm.setUpdateDate(new Date()); | cm.setUpdateDate(new Date()); | ||||
| wxCouponMerchantMapper.insertSelective(cm); | wxCouponMerchantMapper.insertSelective(cm); | ||||
| } | } | ||||
| businessList.add(Integer.valueOf(parseBusiness(merchantParam))); | |||||
| businessList.add(Integer.valueOf(wxCouponMerchantDto.getBusiness())); | |||||
| oldList.removeIf( | oldList.removeIf( | ||||
| old->old.getProductId().equals(record.getId()) && | old->old.getProductId().equals(record.getId()) && | ||||
| old.getMerchantId().equals(Long.valueOf(parseMerchantId(merchantParam)))); | |||||
| old.getMerchantId().equals(wxCouponMerchantDto.getMerchantId())); | |||||
| }); | }); | ||||
| oldList.stream().forEach(old->{ | oldList.stream().forEach(old->{ | ||||
| @@ -24,6 +24,8 @@ import lombok.extern.slf4j.Slf4j; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import org.springframework.transaction.annotation.Propagation; | |||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| @Service | @Service | ||||
| @Slf4j | @Slf4j | ||||
| @@ -129,6 +131,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public ResultData saveOrUpdate(WxCreditHistory record) { | public ResultData saveOrUpdate(WxCreditHistory record) { | ||||
| WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(record.getCUserId()); | WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(record.getCUserId()); | ||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectByPrimaryKey(record.getCUserId()); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectByPrimaryKey(record.getCUserId()); | ||||
| @@ -137,7 +140,14 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | return new ResultData(ErrorCode.USER_IS_EMPTY); | ||||
| } | } | ||||
| //获取当前用户总积分 | //获取当前用户总积分 | ||||
| int currentCreditAmount = wxCreditHistoryMapper.creditAmount(record.getCUserId()); | |||||
| //int currentCreditAmount = wxCreditHistoryMapper.creditAmount(record.getCUserId()); | |||||
| int currentCreditAmount = 0; | |||||
| //获取当前用户总积分规则:优先获取wxCUserBasicInfo中数据 若不存在 再获取wxCUser表中数据 | |||||
| if (wxCUserBasicInfo != null && wxCUserBasicInfo.getCredit() > 0) { | |||||
| currentCreditAmount = wxCUserBasicInfo.getCredit(); | |||||
| } else if (wxCUser != null && wxCUser.getCredit() > 0) { | |||||
| currentCreditAmount = wxCUser.getCredit(); | |||||
| } | |||||
| //计算出需要新增或减少的积分 | //计算出需要新增或减少的积分 | ||||
| int creditChangeNum = creditIncrement(record); | int creditChangeNum = creditIncrement(record); | ||||
| @@ -155,7 +165,14 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| wxCreditHistoryMapper.insertSelective(record); | wxCreditHistoryMapper.insertSelective(record); | ||||
| //将计算出来新的总积分 更新到两张用户表里 | //将计算出来新的总积分 更新到两张用户表里 | ||||
| updateCredit(wxCUser,wxCUserBasicInfo,record.getCreditAmount()); | |||||
| if (wxCUser != null) { | |||||
| wxCUser.setCredit(record.getCreditAmount()); | |||||
| wxCUserMapper.updateByPrimaryKeySelective(wxCUser); | |||||
| } | |||||
| if (wxCUserBasicInfo != null) { | |||||
| wxCUserBasicInfo.setCredit(record.getCreditAmount()); | |||||
| wxCUserBasicInfoMapper.updateByPrimaryKeySelective(wxCUserBasicInfo); | |||||
| } | |||||
| } else { | } else { | ||||
| //wxCreditHistoryMapper.updateByPrimaryKeySelective(record); | //wxCreditHistoryMapper.updateByPrimaryKeySelective(record); | ||||
| } | } | ||||
| @@ -327,20 +344,4 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| return addCreditNumber; | return addCreditNumber; | ||||
| } | } | ||||
| /** | |||||
| * 更新两个表中的最新总积分 | |||||
| * @param creditAmount 用户最新总积分 | |||||
| */ | |||||
| private void updateCredit(WxCUser wxCUser, WxCUserBasicInfo wxCUserBasicInfo, int creditAmount) { | |||||
| if (wxCUser != null) { | |||||
| wxCUser.setCredit(creditAmount); | |||||
| wxCUserMapper.updateByPrimaryKeySelective(wxCUser); | |||||
| } | |||||
| if (wxCUserBasicInfo != null) { | |||||
| wxCUserBasicInfo.setCredit(creditAmount); | |||||
| wxCUserBasicInfoMapper.updateByPrimaryKeySelective(wxCUserBasicInfo); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -269,7 +269,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| long merchantId = idWorker.nextId(); | long merchantId = idWorker.nextId(); | ||||
| //保存商户商铺的关联 | //保存商户商铺的关联 | ||||
| List<Long> shopidlist = wxMerchant.getShopids(); | List<Long> shopidlist = wxMerchant.getShopids(); | ||||
| if (!shopidlist.isEmpty()) { | |||||
| if (shopidlist.isEmpty()) { | |||||
| return new ResultData(ErrorCode.SHOP_NOT_SELECTED); | return new ResultData(ErrorCode.SHOP_NOT_SELECTED); | ||||
| } | } | ||||
| //先检查是否存在已出租的商铺 | //先检查是否存在已出租的商铺 | ||||
| @@ -296,6 +296,8 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| wxMerchantShop.setId(idWorker.nextId()); | wxMerchantShop.setId(idWorker.nextId()); | ||||
| wxMerchantShop.setMerchantId(merchantId); | wxMerchantShop.setMerchantId(merchantId); | ||||
| wxMerchantShop.setTenantId(wxMerchant.getTenantId()); | wxMerchantShop.setTenantId(wxMerchant.getTenantId()); | ||||
| wxMerchantShop.setShopId(shopid); | |||||
| wxMerchantShop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||||
| Date shopdate = new Date(); | Date shopdate = new Date(); | ||||
| wxMerchantShop.setUpdateDate(shopdate); | wxMerchantShop.setUpdateDate(shopdate); | ||||
| wxMerchantShop.setCreateDate(shopdate); | wxMerchantShop.setCreateDate(shopdate); | ||||
| @@ -198,9 +198,18 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); | BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); | ||||
| BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); | BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); | ||||
| record.setPrice(price.multiply(hundred).intValue()); | record.setPrice(price.multiply(hundred).intValue()); | ||||
| } else { | |||||
| if (StringUtils.isNotEmpty(record.getPriceStr())) { | |||||
| record.setPrice(new BigDecimal(record.getPriceStr()).multiply(new BigDecimal(100)).intValue()); | |||||
| } else { | |||||
| record.setPrice(0); | |||||
| } | |||||
| } | |||||
| if (StringUtils.isNotEmpty(record.getDepositStr())) { | |||||
| record.setDeposit(new BigDecimal(record.getDepositStr()).multiply(new BigDecimal(100)).intValue()); | |||||
| } else { | |||||
| record.setDeposit(0); | |||||
| } | } | ||||
| record.setPrice(record.getPrice() == null ? 0 : record.getPrice()); | |||||
| record.setDeposit(record.getDeposit() == null ? 0 : record.getDeposit()); | |||||
| Date date = new Date(); | Date date = new Date(); | ||||
| record.setCreatetime(date); | record.setCreatetime(date); | ||||
| @@ -397,9 +406,19 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); | BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(new BigDecimal(10000)); | ||||
| BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); | BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); | ||||
| record.setPrice(price.multiply(hundred).intValue()); | record.setPrice(price.multiply(hundred).intValue()); | ||||
| } else { | |||||
| if (StringUtils.isNotEmpty(record.getPriceStr())) { | |||||
| record.setPrice(new BigDecimal(record.getPriceStr()).multiply(new BigDecimal(100)).intValue()); | |||||
| } else { | |||||
| record.setPrice(0); | |||||
| } | |||||
| } | |||||
| if (StringUtils.isNotEmpty(record.getDepositStr())) { | |||||
| record.setDeposit(new BigDecimal(record.getDepositStr()).multiply(new BigDecimal(100)).intValue()); | |||||
| } else { | |||||
| record.setDeposit(0); | |||||
| } | } | ||||
| record.setPrice(record.getPrice() == null ? 0 : record.getPrice()); | |||||
| record.setDeposit(record.getDeposit() == null ? 0 : record.getDeposit()); | |||||
| record.setUpdatetime(new Date()); | record.setUpdatetime(new Date()); | ||||
| @@ -564,7 +583,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| int[] priceArr = new int[arraySize]; | int[] priceArr = new int[arraySize]; | ||||
| for (int i = 0; i < arraySize; i++) { | for (int i = 0; i < arraySize; i++) { | ||||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | ||||
| priceArr[i] = new BigDecimal(rentInfoObject.getIntValue("price")).multiply(new BigDecimal(100)).intValue(); | |||||
| priceArr[i] = new BigDecimal(rentInfoObject.getString("price")).multiply(new BigDecimal(100)).intValue(); | |||||
| } | } | ||||
| priceList.add(priceArr); | priceList.add(priceArr); | ||||
| //大于一年 | //大于一年 | ||||
| @@ -577,7 +596,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| for (int j = 0; j < arraySize; j++) { | for (int j = 0; j < arraySize; j++) { | ||||
| rentInfoObject = rentInfoArray.getJSONObject(j); | rentInfoObject = rentInfoArray.getJSONObject(j); | ||||
| adjustRatio = rentInfoObject.getJSONArray("adjustRatio"); | adjustRatio = rentInfoObject.getJSONArray("adjustRatio"); | ||||
| BigDecimal multiply = new BigDecimal(priceList.get(i)[j]).multiply(new BigDecimal(adjustRatio.getIntValue(i)).divide(new BigDecimal(100))); | |||||
| BigDecimal multiply = new BigDecimal(priceList.get(i)[j]).multiply(new BigDecimal(adjustRatio.getString(i)).divide(new BigDecimal(100))); | |||||
| BigDecimal price = new BigDecimal(priceList.get(i)[j]).add(multiply); | BigDecimal price = new BigDecimal(priceList.get(i)[j]).add(multiply); | ||||
| priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).intValue(); | priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).intValue(); | ||||
| } | } | ||||
| @@ -612,7 +631,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| int[] ints = priceList.get(i); | int[] ints = priceList.get(i); | ||||
| for (int j = 0; j < ints.length; j++) { | for (int j = 0; j < ints.length; j++) { | ||||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(j); | JSONObject rentInfoObject = rentInfoArray.getJSONObject(j); | ||||
| shopInfo.put(rentInfoObject.getString("shopNumber"), ints[j]); | |||||
| String s = new BigDecimal(ints[j]).divide(new BigDecimal(100)).toPlainString(); | |||||
| shopInfo.put(rentInfoObject.getString("shopNumber"), s); | |||||
| } | } | ||||
| shopInfos.add(shopInfo); | shopInfos.add(shopInfo); | ||||
| } | } | ||||
| @@ -13,13 +13,13 @@ import com.iformall.domain.po.WxCouponChannel; | |||||
| import com.iformall.domain.po.WxScreenAd; | import com.iformall.domain.po.WxScreenAd; | ||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.enums.EnumCouponChannelType; | import com.iformall.enums.EnumCouponChannelType; | ||||
| import com.iformall.enums.EnumCouponType; | |||||
| import com.iformall.enums.EnumScreenAdType; | import com.iformall.enums.EnumScreenAdType; | ||||
| import com.iformall.mapper.WxCampaignMapper; | import com.iformall.mapper.WxCampaignMapper; | ||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.mapper.WxScreenAdMapper; | import com.iformall.mapper.WxScreenAdMapper; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxScreenAdService; | import com.iformall.service.WxScreenAdService; | ||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import com.iformall.utils.MaUtil; | import com.iformall.utils.MaUtil; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -33,6 +33,9 @@ import java.util.List; | |||||
| @Service | @Service | ||||
| public class WxScreenAdServiceImpl implements WxScreenAdService { | public class WxScreenAdServiceImpl implements WxScreenAdService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | @Autowired | ||||
| WxScreenAdMapper wxScreenAdMapper; | WxScreenAdMapper wxScreenAdMapper; | ||||
| @@ -40,6 +43,9 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoService wxAppinfoService; | WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| WxCouponChannelMapper wxCouponChannelMapper; | WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @@ -162,12 +168,18 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { | |||||
| private static String QRCODE_JUMP_CMD_COUPON = "JC"; | private static String QRCODE_JUMP_CMD_COUPON = "JC"; | ||||
| private static String QRCODE_JUMP_CMD_GROUP = "JG"; | private static String QRCODE_JUMP_CMD_GROUP = "JG"; | ||||
| private static String QRCODE_JUMP_CMD_CAMPGIN = "JB"; | private static String QRCODE_JUMP_CMD_CAMPGIN = "JB"; | ||||
| private byte[] getQrcode(Long id, int type, int subType, WxAppinfo appInfo) throws Exception { | private byte[] getQrcode(Long id, int type, int subType, WxAppinfo appInfo) throws Exception { | ||||
| if(appInfo == null) { | if(appInfo == null) { | ||||
| logger.error("QRCODE get error: appinfo is null"); | logger.error("QRCODE get error: appinfo is null"); | ||||
| return null; | return null; | ||||
| } | } | ||||
| WxMaService wxMaService = MaUtil.getWeappService(appInfo); | |||||
| WxMaService wxMaService = null; | |||||
| if(isFmOpen) { | |||||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appInfo.getAppId()); | |||||
| } else { | |||||
| wxMaService = MaUtil.getWeappService(appInfo); | |||||
| } | |||||
| String scene = ""; | String scene = ""; | ||||
| if (EnumScreenAdType.COUPON.getCode().equals(type)) { | if (EnumScreenAdType.COUPON.getCode().equals(type)) { | ||||
| @@ -0,0 +1,253 @@ | |||||
| package com.iformall.service.wechat; | |||||
| import com.iformall.common.FmHttpClientBuilder; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.domain.po.WxComponentVerifyTicket; | |||||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | |||||
| import com.iformall.mapper.WxComponentVerifyTicketMapper; | |||||
| import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | |||||
| import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; | |||||
| import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import redis.clients.jedis.Jedis; | |||||
| import redis.clients.jedis.JedisPool; | |||||
| import redis.clients.util.Pool; | |||||
| import java.util.Date; | |||||
| public class FmOpenInRedisDBConfigStorage extends WxOpenInMemoryConfigStorage { | |||||
| private final static String COMPONENT_VERIFY_TICKET_KEY = "wechat_component_verify_ticket:"; | |||||
| private final static String COMPONENT_ACCESS_TOKEN_KEY = "wechat_component_access_token:"; | |||||
| private final static String AUTHORIZER_REFRESH_TOKEN_KEY = "wechat_authorizer_refresh_token:"; | |||||
| private final static String AUTHORIZER_ACCESS_TOKEN_KEY = "wechat_authorizer_access_token:"; | |||||
| private final static String JSAPI_TICKET_KEY = "wechat_jsapi_ticket:"; | |||||
| private final static String CARD_API_TICKET_KEY = "wechat_card_api_ticket:"; | |||||
| protected final Pool<Jedis> jedisPool; | |||||
| private WxComponentVerifyTicketMapper wxComponentVerifyTicketMapper; | |||||
| private WxAuthorizerInfoMapper wxAuthorizerInfoMapper; | |||||
| /** | |||||
| * redis 存储的 key 的前缀,可为空 | |||||
| */ | |||||
| private String keyPrefix; | |||||
| private String componentVerifyTicketKey; | |||||
| private String componentAccessTokenKey; | |||||
| private String authorizerRefreshTokenKey; | |||||
| private String authorizerAccessTokenKey; | |||||
| private String jsapiTicketKey; | |||||
| private String cardApiTicket; | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| public FmOpenInRedisDBConfigStorage(Pool<Jedis> jedisPool) { | |||||
| this.jedisPool = jedisPool; | |||||
| } | |||||
| public FmOpenInRedisDBConfigStorage(Pool<Jedis> jedisPool, String keyPrefix) { | |||||
| this.jedisPool = jedisPool; | |||||
| this.keyPrefix = keyPrefix; | |||||
| } | |||||
| public FmOpenInRedisDBConfigStorage(JedisPool jedisPool, WxComponentVerifyTicketMapper componentVerifyTicketMapper, WxAuthorizerInfoMapper authorizerInfoMapper) { | |||||
| this.jedisPool = jedisPool; | |||||
| this.wxComponentVerifyTicketMapper = componentVerifyTicketMapper; | |||||
| this.wxAuthorizerInfoMapper = authorizerInfoMapper; | |||||
| } | |||||
| @Override | |||||
| public void setComponentAppId(String componentAppId) { | |||||
| super.setComponentAppId(componentAppId); | |||||
| String prefix = StringUtils.isBlank(keyPrefix) ? "" : | |||||
| (StringUtils.endsWith(keyPrefix, ":") ? keyPrefix : (keyPrefix + ":")); | |||||
| componentVerifyTicketKey = prefix + COMPONENT_VERIFY_TICKET_KEY.concat(componentAppId); | |||||
| componentAccessTokenKey = prefix + COMPONENT_ACCESS_TOKEN_KEY.concat(componentAppId); | |||||
| authorizerRefreshTokenKey = prefix + AUTHORIZER_REFRESH_TOKEN_KEY.concat(componentAppId); | |||||
| authorizerAccessTokenKey = prefix + AUTHORIZER_ACCESS_TOKEN_KEY.concat(componentAppId); | |||||
| this.jsapiTicketKey = JSAPI_TICKET_KEY.concat(componentAppId); | |||||
| this.cardApiTicket = CARD_API_TICKET_KEY.concat(componentAppId); | |||||
| } | |||||
| @Override | |||||
| public String getComponentVerifyTicket() { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.componentVerifyTicketKey); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void setComponentVerifyTicket(String componentVerifyTicket) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.set(this.componentVerifyTicketKey, componentVerifyTicket); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public String getComponentAccessToken() { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.componentAccessTokenKey); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean isComponentAccessTokenExpired() { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.ttl(this.componentAccessTokenKey) < 2; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void expireComponentAccessToken(){ | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.expire(this.componentAccessTokenKey, 0); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void updateComponentAccessTokent(String componentAccessToken, int expiresInSeconds) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.setex(this.componentAccessTokenKey, expiresInSeconds - 200, componentAccessToken); | |||||
| WxComponentVerifyTicket ticket = new WxComponentVerifyTicket(); | |||||
| ticket.setComponentAppid(getComponentAppId()); | |||||
| ticket.setAccessToken(componentAccessToken); | |||||
| ticket.setAccessTokenExpire(new Date(Long.valueOf(System.currentTimeMillis() + (expiresInSeconds * 1000)))); | |||||
| int num = wxComponentVerifyTicketMapper.updateAccessToken(ticket); | |||||
| logger.info("updateComponentVerifyTicketAccessToken rows: " + num); | |||||
| } | |||||
| } | |||||
| private String getKey(String prefix, String appId) { | |||||
| return prefix.endsWith(":") ? prefix.concat(appId) : prefix.concat(":").concat(appId); | |||||
| } | |||||
| @Override | |||||
| public String getAuthorizerRefreshToken(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.getKey(this.authorizerRefreshTokenKey, appId)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void setAuthorizerRefreshToken(String appId, String authorizerRefreshToken) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.set(this.getKey(this.authorizerRefreshTokenKey, appId), authorizerRefreshToken); | |||||
| WxAuthorizerInfo authorizerInfo = new WxAuthorizerInfo(); | |||||
| authorizerInfo.setAuthorizerAppid(appId); | |||||
| authorizerInfo.setRefreshToken(authorizerRefreshToken); | |||||
| int num = wxAuthorizerInfoMapper.updateRefreshToken(authorizerInfo); | |||||
| logger.info("setAuthorizerRefreshToken " + appId + " rows: " + num); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public String getAuthorizerAccessToken(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.getKey(this.authorizerAccessTokenKey, appId)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean isAuthorizerAccessTokenExpired(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.ttl(this.getKey(this.authorizerAccessTokenKey, appId)) < 2; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void expireAuthorizerAccessToken(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.expire(this.getKey(this.authorizerAccessTokenKey, appId), 0); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void updateAuthorizerAccessToken(String appId, WxOpenAuthorizerAccessToken authorizerAccessToken) { | |||||
| this.updateAuthorizerAccessToken(appId, authorizerAccessToken.getAuthorizerAccessToken(), authorizerAccessToken.getExpiresIn()); | |||||
| WxAuthorizerInfo authorizerInfo = new WxAuthorizerInfo(); | |||||
| authorizerInfo.setAuthorizerAppid(appId); | |||||
| authorizerInfo.setAccessToken(authorizerAccessToken.getAuthorizerAccessToken()); | |||||
| authorizerInfo.setAccessTokenExpire(new Date(Long.valueOf(System.currentTimeMillis() + (authorizerAccessToken.getExpiresIn() * 1000)))); | |||||
| int num = wxAuthorizerInfoMapper.updateAccessToken(authorizerInfo); | |||||
| logger.info("updateAuthorizerAccessToken " + appId + " rows: " + num); | |||||
| } | |||||
| @Override | |||||
| public void updateAuthorizerAccessToken(String appId, String authorizerAccessToken, int expiresInSeconds) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.setex(this.getKey(this.authorizerAccessTokenKey, appId), expiresInSeconds - 200, authorizerAccessToken); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public String getJsapiTicket(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.getKey(this.jsapiTicketKey, appId)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean isJsapiTicketExpired(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.ttl(this.getKey(this.jsapiTicketKey, appId)) < 2; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void expireJsapiTicket(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.expire(this.getKey(this.jsapiTicketKey, appId), 0); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void updateJsapiTicket(String appId, String jsapiTicket, int expiresInSeconds) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.setex(this.getKey(this.jsapiTicketKey, appId), expiresInSeconds - 200, jsapiTicket); | |||||
| } | |||||
| // TODO update to DB | |||||
| } | |||||
| @Override | |||||
| public String getCardApiTicket(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.getKey(this.cardApiTicket, appId)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean isCardApiTicketExpired(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.ttl(this.getKey(this.cardApiTicket, appId)) < 2; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void expireCardApiTicket(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.expire(this.getKey(this.cardApiTicket, appId), 0); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void updateCardApiTicket(String appId, String cardApiTicket, int expiresInSeconds) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.setex(this.getKey(this.cardApiTicket, appId), expiresInSeconds - 200, cardApiTicket); | |||||
| } | |||||
| // TODO update to DB | |||||
| } | |||||
| @Override | |||||
| public ApacheHttpClientBuilder getApacheHttpClientBuilder() { | |||||
| return FmHttpClientBuilder.get(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,73 @@ | |||||
| package com.iformall.service.wechat; | |||||
| import com.iformall.config.WechatOpenProperties; | |||||
| import com.iformall.config.WechatRedisProperies; | |||||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | |||||
| import com.iformall.mapper.WxComponentVerifyTicketMapper; | |||||
| import me.chanjar.weixin.open.api.impl.WxOpenMessageRouter; | |||||
| import me.chanjar.weixin.open.api.impl.WxOpenServiceImpl; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||||
| import org.springframework.stereotype.Service; | |||||
| import redis.clients.jedis.JedisPool; | |||||
| import javax.annotation.PostConstruct; | |||||
| /** | |||||
| * Stormeye WU | |||||
| */ | |||||
| @Service | |||||
| @EnableConfigurationProperties({WechatOpenProperties.class, WechatRedisProperies.class}) | |||||
| public class FmOpenService extends WxOpenServiceImpl { | |||||
| private Logger logger = LoggerFactory.getLogger(getClass()); | |||||
| @Autowired | |||||
| private WechatOpenProperties wechatProperties; | |||||
| @Autowired | |||||
| private WechatRedisProperies redisProperies; | |||||
| @Autowired | |||||
| private WxComponentVerifyTicketMapper componentVerifyTicketMapper; | |||||
| @Autowired | |||||
| private WxAuthorizerInfoMapper authorizerInfoMapper; | |||||
| private static JedisPool pool; | |||||
| private WxOpenMessageRouter wxOpenMessageRouter; | |||||
| @PostConstruct | |||||
| public void init() { | |||||
| FmOpenInRedisDBConfigStorage configStorage = new FmOpenInRedisDBConfigStorage(getJedisPool(), componentVerifyTicketMapper, authorizerInfoMapper); | |||||
| configStorage.setComponentAppId(wechatProperties.getComponentAppId()); | |||||
| configStorage.setComponentAppSecret(wechatProperties.getComponentSecret()); | |||||
| configStorage.setComponentToken(wechatProperties.getComponentToken()); | |||||
| configStorage.setComponentAesKey(wechatProperties.getComponentAesKey()); | |||||
| setWxOpenConfigStorage(configStorage); | |||||
| wxOpenMessageRouter = new WxOpenMessageRouter(this); | |||||
| wxOpenMessageRouter.rule().handler((wxMpXmlMessage, map, wxMpService, wxSessionManager) -> { | |||||
| logger.info("\n接收到 {} 公众号请求消息,内容:{}", wxMpService.getWxMpConfigStorage().getAppId(), wxMpXmlMessage); | |||||
| return null; | |||||
| }).next(); | |||||
| } | |||||
| public WxOpenMessageRouter getWxOpenMessageRouter() { | |||||
| return wxOpenMessageRouter; | |||||
| } | |||||
| private JedisPool getJedisPool() { | |||||
| if (pool == null) { | |||||
| synchronized (FmOpenService.class) { | |||||
| if (pool == null) { | |||||
| pool = new JedisPool(redisProperies, redisProperies.getHost(), | |||||
| redisProperies.getPort(), redisProperies.getConnectionTimeout(), | |||||
| redisProperies.getSoTimeout(), redisProperies.getPassword(), | |||||
| redisProperies.getDatabase(), redisProperies.getClientName(), | |||||
| redisProperies.isSsl(), redisProperies.getSslSocketFactory(), | |||||
| redisProperies.getSslParameters(), redisProperies.getHostnameVerifier()); | |||||
| } | |||||
| } | |||||
| } | |||||
| return pool; | |||||
| } | |||||
| } | |||||
| @@ -3,7 +3,7 @@ package com.iformall.utils; | |||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
| import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; | import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; | ||||
| import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig; | import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig; | ||||
| import com.iformall.common.MipHttpClientBuilder; | |||||
| import com.iformall.common.FmHttpClientBuilder; | |||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -20,7 +20,7 @@ public class MaUtil { | |||||
| config.setAccessToken(appinfo.getAccessToken()); | config.setAccessToken(appinfo.getAccessToken()); | ||||
| config.setExpiresTime(appinfo.getLastTokenTime().getTime()+appinfo.getExpiresIn()*1000); | config.setExpiresTime(appinfo.getLastTokenTime().getTime()+appinfo.getExpiresIn()*1000); | ||||
| } | } | ||||
| config.setApacheHttpClientBuilder(MipHttpClientBuilder.get()); | |||||
| config.setApacheHttpClientBuilder(FmHttpClientBuilder.get()); | |||||
| WxMaService service = new WxMaServiceImpl(); | WxMaService service = new WxMaServiceImpl(); | ||||
| service.setWxMaConfig(config); | service.setWxMaConfig(config); | ||||
| return service; | return service; | ||||
| @@ -246,6 +246,14 @@ | |||||
| <include refid="dynamicVWhereConditions" /> | <include refid="dynamicVWhereConditions" /> | ||||
| </select> | </select> | ||||
| <select id="findVo" parameterType="com.iformall.domain.vo.WxWeappInfo" resultMap="VBaseResultMap"> | |||||
| select | |||||
| <include refid="allVColumns"/> | |||||
| from wx_authorizer_info ai | |||||
| left join wx_appinfo a on ai.`authorizer_appid` = a.app_id | |||||
| where ai.`authorizer_appid` = #{authorizerAppid} | |||||
| </select> | |||||
| <select id="findWeappList" resultMap="BaseResultMap"> | <select id="findWeappList" resultMap="BaseResultMap"> | ||||
| select | select | ||||
| <include refid="allVColumns"/> | <include refid="allVColumns"/> | ||||
| @@ -32,6 +32,8 @@ | |||||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | ||||
| <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | ||||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | ||||
| <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/> | |||||
| <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/> | |||||
| </resultMap> | </resultMap> | ||||
| <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo"> | <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo"> | ||||
| @@ -81,7 +83,7 @@ | |||||
| `id`,`tenant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`, | `id`,`tenant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`, | ||||
| `valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`, | `valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`, | ||||
| `remark`,`status`,`create_date`,`update_date`,`business`,`support_transfer`,`subsidy_num`,`subsidy_type`, | `remark`,`status`,`create_date`,`update_date`,`business`,`support_transfer`,`subsidy_num`,`subsidy_type`, | ||||
| `press_limit_num`, `press_limit_hours`, `auto_refund` | |||||
| `press_limit_num`, `press_limit_hours`, `auto_refund`,`credit_price`,`credit_refund` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -207,6 +209,14 @@ | |||||
| and `auto_refund` = #{autoRefund} | and `auto_refund` = #{autoRefund} | ||||
| </if> | </if> | ||||
| <if test=" null != creditPrice "> | |||||
| and `credit_price` = #{creditPrice} | |||||
| </if> | |||||
| <if test=" null != creditRefund "> | |||||
| and `credit_refund` = #{creditRefund} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| @@ -16,10 +16,11 @@ | |||||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | ||||
| <result column="business_id" jdbcType="BIGINT" property="businessId" /> | <result column="business_id" jdbcType="BIGINT" property="businessId" /> | ||||
| <result column="spend" jdbcType="INTEGER" property="spend" /> | <result column="spend" jdbcType="INTEGER" property="spend" /> | ||||
| <result column="change_purpose" jdbcType="VARCHAR" property="changePurpose" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`c_user_id`,`credit_amount`,`credit_num`,`credit_type`,`credate_date`,`receipt_url`,`operator_type`,`operator_id`,`merchant_id`,`coupon_id`,`business_id`,`spend` | |||||
| `id`,`tenant_id`,`c_user_id`,`credit_amount`,`credit_num`,`credit_type`,`credate_date`,`receipt_url`,`operator_type`,`operator_id`,`merchant_id`,`coupon_id`,`business_id`,`spend`,`change_purpose` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -60,6 +61,9 @@ | |||||
| <if test=" null != spend "> | <if test=" null != spend "> | ||||
| and `spend` = #{spend} | and `spend` = #{spend} | ||||
| </if> | </if> | ||||
| <if test=" null != changePurpose "> | |||||
| and `change_purpose` = #{changePurpose} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| @@ -19,13 +19,21 @@ import tk.mybatis.spring.annotation.MapperScan; | |||||
| @EnableEncryptableProperties | @EnableEncryptableProperties | ||||
| public class SocketServerApplication { | public class SocketServerApplication { | ||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| @Value("${fm.open}") | |||||
| private boolean fmOpen; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| @Bean | |||||
| public boolean isFmOpen() { | |||||
| return fmOpen; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| @@ -10,6 +10,7 @@ import com.iformall.interceptor.AuthHandshakeInterceptor; | |||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| import com.iformall.service.WxCUserService; | import com.iformall.service.WxCUserService; | ||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import com.iformall.utils.IPUtil; | import com.iformall.utils.IPUtil; | ||||
| import com.iformall.utils.MaUtil; | import com.iformall.utils.MaUtil; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -29,12 +30,18 @@ import java.util.List; | |||||
| @RestController | @RestController | ||||
| public class BaseController { | public class BaseController { | ||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserService wxCUserService; | private WxCUserService wxCUserService; | ||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | private WxCUserBasicInfoService wxCUserBasicInfoService; | ||||
| @@ -86,17 +93,24 @@ public class BaseController { | |||||
| } | } | ||||
| public WxMaService getWeappService(String appId) { | public WxMaService getWeappService(String appId) { | ||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); | |||||
| if (appinfo == null) { | |||||
| return null; | |||||
| if(isFmOpen) { | |||||
| return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| } else { | |||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); | |||||
| if (appinfo == null) { | |||||
| return null; | |||||
| } | |||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | } | ||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | } | ||||
| public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | ||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| if(!isFmOpen) { | |||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | |||||
| return null; | |||||
| } | } | ||||
| @@ -74,6 +74,26 @@ aws: | |||||
| access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | ||||
| secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 500 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| jasypt: | jasypt: | ||||
| encryptor: | encryptor: | ||||
| @@ -81,6 +101,8 @@ jasypt: | |||||
| fm: | fm: | ||||
| exception: false | exception: false | ||||
| deploy: 1 | |||||
| open: false | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -63,10 +63,31 @@ aws: | |||||
| access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | ||||
| secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: ENC(b3JG0MUZgQfz5Zj+DC2ZM1zDeLOiGTmmeokfe2O8kaM=) | |||||
| componentSecret: ENC(QVyc4BPGdnSjXGs2ivgpDBE1v8wPWHLLRMYI7Vv8uYwC0SiZHQz0QpyyQV/b48Pb) | |||||
| componentToken: ENC(rkxj0733WxFFDLgA9x01m2s5Fi2L+0PC) | |||||
| componentAesKey: ENC(EIbJUBpbYOrLb4YQ/HXLQmxlxgAqIp2ZmpnGICC8pu5xiTz3Cqfkbwd2S8raCcK/IvYcX2GmedI=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 3 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -63,8 +63,31 @@ aws: | |||||
| access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | ||||
| secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: ENC(hnH31XdNzArfMfikKgBFpqQuJUl6rVOPFFcAVyb595o=) | |||||
| componentSecret: ENC(t/GUVX5L+U7LCwSvZ5WmxAnmTMrc/Uy1nljsrokuzzsBL2j6BEVnrS/n7DCdGc/G) | |||||
| componentToken: ENC(gUF1m0YgCCI2IY54fX6sGLZVlCswA8tG) | |||||
| componentAesKey: ENC(TYHcrIkICtfrCfGq4HW6s1b/pHf7OD2uyPN11SzJNB0acqJ/4JVX1nuljo/cAtgMG4O05TImLQc=) | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| deploy: 2 | |||||
| open: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| @@ -33,6 +33,7 @@ | |||||
| <weixin-java-mp.version>3.3.0</weixin-java-mp.version> | <weixin-java-mp.version>3.3.0</weixin-java-mp.version> | ||||
| <weixin-java-miniapp.version>3.3.0</weixin-java-miniapp.version> | <weixin-java-miniapp.version>3.3.0</weixin-java-miniapp.version> | ||||
| <weixin-java-pay.version>3.3.0</weixin-java-pay.version> | <weixin-java-pay.version>3.3.0</weixin-java-pay.version> | ||||
| <weixin-java-open.version>3.3.0</weixin-java-open.version> | |||||
| <quartz.version>2.3.0</quartz.version> | <quartz.version>2.3.0</quartz.version> | ||||
| </properties> | </properties> | ||||
| @@ -337,6 +338,12 @@ | |||||
| <version>${weixin-java-pay.version}</version> | <version>${weixin-java-pay.version}</version> | ||||
| </dependency> | </dependency> | ||||
| <dependency> | |||||
| <groupId>com.github.binarywang</groupId> | |||||
| <artifactId>weixin-java-open</artifactId> | |||||
| <version>${weixin-java-open.version}</version> | |||||
| </dependency> | |||||
| <dependency> | <dependency> | ||||
| <groupId>com.github.ulisesbocchio</groupId> | <groupId>com.github.ulisesbocchio</groupId> | ||||
| <artifactId>jasypt-spring-boot</artifactId> | <artifactId>jasypt-spring-boot</artifactId> | ||||