From 94d11d1dfc7cb98c70bf1dedf18d0c0b332d9f8e Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Thu, 29 Nov 2018 21:39:54 +0800 Subject: [PATCH 1/9] =?UTF-8?q?[=E5=BE=AE=E4=BF=A1=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E5=BC=80=E6=94=BE=E5=B9=B3=E5=8F=B0][=E6=96=B0?= =?UTF-8?q?=E5=A2=9E]:=E6=8E=A5=E6=94=B6=E5=9B=9E=E8=B0=83=E5=8F=8A?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mallinkAdmin/pom.xml | 9 ++ .../com/iformall/config/RedisProperies.java | 124 ++++++++++++++++++ .../iformall/config/WechatOpenProperties.java | 69 ++++++++++ .../controller/WechatApiController.java | 72 ++++++++++ .../controller/WechatCalllbackController.java | 108 +++++++++++++++ .../com/iformall/service/WxOpenService.java | 65 +++++++++ .../src/main/resources/application.yml | 21 +++ 7 files changed, 468 insertions(+) create mode 100644 mallinkAdmin/src/main/java/com/iformall/config/RedisProperies.java create mode 100644 mallinkAdmin/src/main/java/com/iformall/config/WechatOpenProperties.java create mode 100644 mallinkAdmin/src/main/java/com/iformall/controller/WechatApiController.java create mode 100644 mallinkAdmin/src/main/java/com/iformall/controller/WechatCalllbackController.java create mode 100644 mallinkAdmin/src/main/java/com/iformall/service/WxOpenService.java diff --git a/mallinkAdmin/pom.xml b/mallinkAdmin/pom.xml index ec65f306d..820d917af 100644 --- a/mallinkAdmin/pom.xml +++ b/mallinkAdmin/pom.xml @@ -12,6 +12,10 @@ mallinkAdmin + + 3.2.0 + + com.iformall @@ -23,6 +27,11 @@ mybatis-multi-tenancy 1.0 + + com.github.binarywang + weixin-java-open + ${weixin-java-open.version} + diff --git a/mallinkAdmin/src/main/java/com/iformall/config/RedisProperies.java b/mallinkAdmin/src/main/java/com/iformall/config/RedisProperies.java new file mode 100644 index 000000000..21602ae47 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/config/RedisProperies.java @@ -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 RedisProperies 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; + } +} diff --git a/mallinkAdmin/src/main/java/com/iformall/config/WechatOpenProperties.java b/mallinkAdmin/src/main/java/com/iformall/config/WechatOpenProperties.java new file mode 100644 index 000000000..e19dfc4eb --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/config/WechatOpenProperties.java @@ -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); + } +} diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WechatApiController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WechatApiController.java new file mode 100644 index 000000000..217a0f509 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WechatApiController.java @@ -0,0 +1,72 @@ +package com.iformall.controller; + +import com.iformall.service.WxOpenService; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; +import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * Stormeye Wu + */ +@Controller +@RequestMapping("/wtauth") +public class WechatApiController { + private final Logger logger = LoggerFactory.getLogger(getClass()); + @Autowired + private WxOpenService wxOpenService; + + @GetMapping("/goto_auth_url_show") + @ResponseBody + public String gotoPreAuthUrlShow() { + return "go"; + } + + @GetMapping("/goto_auth_url") + public void gotoPreAuthUrl(HttpServletRequest request, HttpServletResponse response) { + String host = request.getHeader("host"); + String url = "http://" + host + "/api/auth/jump"; + try { + url = wxOpenService.getWxOpenComponentService().getPreAuthUrl(url); + response.sendRedirect(url); + } catch (WxErrorException | IOException e) { + logger.error("gotoPreAuthUrl", e); + throw new RuntimeException(e); + } + } + + @GetMapping("/jump") + @ResponseBody + public WxOpenQueryAuthResult jump(@RequestParam("auth_code") String authorizationCode) { + try { + WxOpenQueryAuthResult queryAuthResult = wxOpenService.getWxOpenComponentService().getQueryAuth(authorizationCode); + logger.info("getQueryAuth", queryAuthResult); + return queryAuthResult; + } catch (WxErrorException e) { + logger.error("gotoPreAuthUrl", e); + throw new RuntimeException(e); + } + } + + @GetMapping("/get_authorizer_info") + @ResponseBody + public WxOpenAuthorizerInfoResult getAuthorizerInfo(@RequestParam String appId) { + try { + return wxOpenService.getWxOpenComponentService().getAuthorizerInfo(appId); + } catch (WxErrorException e) { + logger.error("getAuthorizerInfo", e); + throw new RuntimeException(e); + } + } +} diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WechatCalllbackController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WechatCalllbackController.java new file mode 100644 index 000000000..c0cac16db --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WechatCalllbackController.java @@ -0,0 +1,108 @@ +package com.iformall.controller; + +import com.iformall.service.WxOpenService; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("wxOpen") +public class WechatCalllbackController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + protected WxOpenService wxOpenService; + + @RequestMapping("/notify") + public Object receiveTicket(@RequestBody(required = false) String requestBody, @RequestParam("timestamp") String timestamp, + @RequestParam("nonce") String nonce, @RequestParam("signature") String signature, + @RequestParam(name = "encrypt_type", required = false) String encType, + @RequestParam(name = "msg_signature", required = false) String msgSignature) { + logger.info( + "\n接收微信请求:[signature=[{}], encType=[{}], msgSignature=[{}]," + + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ", + signature, encType, msgSignature, timestamp, nonce, requestBody); + + if (!StringUtils.equalsIgnoreCase("aes", encType) + || !wxOpenService.getWxOpenComponentService().checkSignature(timestamp, nonce, signature)) { + throw new IllegalArgumentException("非法请求,可能属于伪造的请求!"); + } + + // aes加密的消息 + WxOpenXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedXml(requestBody, + wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature); + this.logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString()); + try { + String out = wxOpenService.getWxOpenComponentService().route(inMessage); + this.logger.debug("\n组装回复信息:{}", out); + } catch (WxErrorException e) { + this.logger.error("notify", e); + } + + + return "success"; + } + + @RequestMapping("callback/{appId}") + public Object callback(@RequestBody(required = false) String requestBody, + @PathVariable("appId") String appId, + @RequestParam("signature") String signature, + @RequestParam("timestamp") String timestamp, + @RequestParam("nonce") String nonce, + @RequestParam("openid") String openid, + @RequestParam("encrypt_type") String encType, + @RequestParam("msg_signature") String msgSignature) { + logger.info( + "\n接收微信请求:[appId=[{}], openid=[{}], signature=[{}], encType=[{}], msgSignature=[{}]," + + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ", + appId, openid, signature, encType, msgSignature, timestamp, nonce, requestBody); + if (!StringUtils.equalsIgnoreCase("aes", encType) + || !wxOpenService.getWxOpenComponentService().checkSignature(timestamp, nonce, signature)) { + throw new IllegalArgumentException("非法请求,可能属于伪造的请求!"); + } + + String out = ""; + // aes加密的消息 + WxMpXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedMpXml(requestBody, + wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature); + this.logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString()); + // 全网发布测试用例 + if (StringUtils.equalsAnyIgnoreCase(appId, "wxd101a85aa106f53e", "wx570bc396a51b8ff8")) { + try { + if (StringUtils.equals(inMessage.getMsgType(), "text")) { + if (StringUtils.equals(inMessage.getContent(), "TESTCOMPONENT_MSG_TYPE_TEXT")) { + out = WxOpenXmlMessage.wxMpOutXmlMessageToEncryptedXml( + WxMpXmlOutMessage.TEXT().content("TESTCOMPONENT_MSG_TYPE_TEXT_callback") + .fromUser(inMessage.getToUser()) + .toUser(inMessage.getFromUser()) + .build(), + wxOpenService.getWxOpenConfigStorage() + ); + } else if (StringUtils.startsWith(inMessage.getContent(), "QUERY_AUTH_CODE:")) { + String msg = inMessage.getContent().replace("QUERY_AUTH_CODE:", "") + "_from_api"; + WxMpKefuMessage kefuMessage = WxMpKefuMessage.TEXT().content(msg).toUser(inMessage.getFromUser()).build(); + wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getKefuService().sendKefuMessage(kefuMessage); + } + } else if (StringUtils.equals(inMessage.getMsgType(), "event")) { + WxMpKefuMessage kefuMessage = WxMpKefuMessage.TEXT().content(inMessage.getEvent() + "from_callback").toUser(inMessage.getFromUser()).build(); + wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getKefuService().sendKefuMessage(kefuMessage); + } + } catch (WxErrorException e) { + logger.error("callback", e); + } + } else { + WxMpXmlOutMessage outMessage = wxOpenService.getWxOpenMessageRouter().route(inMessage, appId); + if (outMessage != null) { + out = WxOpenXmlMessage.wxMpOutXmlMessageToEncryptedXml(outMessage, wxOpenService.getWxOpenConfigStorage()); + } + } + return out; + } +} diff --git a/mallinkAdmin/src/main/java/com/iformall/service/WxOpenService.java b/mallinkAdmin/src/main/java/com/iformall/service/WxOpenService.java new file mode 100644 index 000000000..4c428fbb6 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/service/WxOpenService.java @@ -0,0 +1,65 @@ +package com.iformall.service; + +import com.iformall.config.RedisProperies; +import com.iformall.config.WechatOpenProperties; +import me.chanjar.weixin.open.api.impl.WxOpenInRedisConfigStorage; +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; + +/** + * @author 007 + */ +@Service +@EnableConfigurationProperties({WechatOpenProperties.class, RedisProperies.class}) +public class WxOpenService extends WxOpenServiceImpl { + private Logger logger = LoggerFactory.getLogger(getClass()); + @Autowired + private WechatOpenProperties wechatOpenProperties; + @Autowired + private RedisProperies redisProperies; + private static JedisPool pool; + private WxOpenMessageRouter wxOpenMessageRouter; + + @PostConstruct + public void init() { + WxOpenInRedisConfigStorage inRedisConfigStorage = new WxOpenInRedisConfigStorage(getJedisPool()); + inRedisConfigStorage.setComponentAppId(wechatOpenProperties.getComponentAppId()); + inRedisConfigStorage.setComponentAppSecret(wechatOpenProperties.getComponentSecret()); + inRedisConfigStorage.setComponentToken(wechatOpenProperties.getComponentToken()); + inRedisConfigStorage.setComponentAesKey(wechatOpenProperties.getComponentAesKey()); + setWxOpenConfigStorage(inRedisConfigStorage); + 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 (WxOpenService.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; + } +} diff --git a/mallinkAdmin/src/main/resources/application.yml b/mallinkAdmin/src/main/resources/application.yml index 8b2dca921..2587cdd4c 100644 --- a/mallinkAdmin/src/main/resources/application.yml +++ b/mallinkAdmin/src/main/resources/application.yml @@ -67,6 +67,27 @@ aws: access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) 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: 1 + defaultExpiration: 2592000 # 默认生命周期30天 + jedis: + pool: + max-active: 100 + max-idle: 500 + max-wait: -1 + min-idle: 10 + jasypt: encryptor: password: oRqdnDbK5pj3eMmB From ae800f012e76915ea1a3d8277fd9273f2448f640 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Thu, 29 Nov 2018 21:54:23 +0800 Subject: [PATCH 2/9] =?UTF-8?q?[B=E7=AB=AF=E5=88=B7=E5=8D=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=88=86=E8=B4=A6][=E4=BF=AE=E6=94=B9]:=E5=BB=B6?= =?UTF-8?q?=E8=BF=9F10=E7=A7=92=E5=90=8E=E5=8F=91=E8=B5=B7=E5=88=86?= =?UTF-8?q?=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/service/impl/WxPayOrderServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java index 9b3c56c0c..ee2956aff 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java @@ -1301,13 +1301,13 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { } logger.info("订单刷卡发券 结束"); - // 延迟3秒后分账 + // 延迟10秒后分账 new Thread(() -> { String tenantId = record.getTenantId(); Long orderId = record.getOrderId(); Long payOrderId = record.getId(); try { - Thread.currentThread().sleep(3000); + Thread.currentThread().sleep(10000); } catch (Exception e) { logger.error("sleep error: " + e.getMessage()); } From 834f88ddc4d62899e6dd4507bacbdd8715045412 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Fri, 30 Nov 2018 01:06:14 +0800 Subject: [PATCH 3/9] =?UTF-8?q?[=E7=89=A9=E4=B8=9A=E5=90=88=E5=90=8C][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E9=A1=B5=E9=9D=A2=E5=B1=95=E7=A4=BA]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WxPropertyContractServiceImpl.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java index 333897dca..c5ec3dbdd 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -393,11 +393,20 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService Map resultData = new HashMap(); //商铺信息 - Map shopparams = new HashMap<>(); - shopparams.put("tenantId", tenantId); - shopparams.put("status", EnumShopStatus.NOT_RENT.getCode()); - Map shopLeftInfo = wxShopMapper.queryShopLeftInfo(shopparams); - resultData.put("shopLeftInfo", shopLeftInfo); + WxShop wxShop = new WxShop(); + wxShop.setTenantId(tenantId); + wxShop.setStatus(EnumShopStatus.RENT.getCode()); + List rentedList = wxShopMapper.findList(wxShop); + wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); + List unrentedList = wxShopMapper.findList(wxShop); + + HashMap shopMap = new HashMap<>(3); + int rentedCount = rentedList.size(); + int unrentedCount = unrentedList.size(); + shopMap.put("rentedCount",rentedCount); + shopMap.put("unrentedCount",unrentedCount); + shopMap.put("allCount",rentedCount+unrentedCount); + resultData.put("shopCountInfo", shopMap); //需要更新的状态 resultData.putAll(updateStatus(tenantId)); @@ -480,6 +489,10 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService WxPropertyContract wxRentContract = new WxPropertyContract(); wxRentContract.setTenantId(tenantId); + + int allCount = wxPropertyContractMapper.selectCount(wxRentContract); + resultData.put("allCount", allCount); + //作废合同 wxRentContract.setStatus(EnumRentContractStatus.INVALID.getCode()); wxPropertyContractMapper.updateRentInvalidStatus(wxRentContract); From e7a104a8d927f4fa500ec3722cc2619b9e3b0cae Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Fri, 30 Nov 2018 02:32:45 +0800 Subject: [PATCH 4/9] =?UTF-8?q?[=E5=BE=AE=E4=BF=A1=E5=85=AC=E4=BC=97?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0][=E6=96=B0=E5=A2=9E]:=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8E=A5=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mallinkAdmin/src/main/java/com/iformall/config/ShiroConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/mallinkAdmin/src/main/java/com/iformall/config/ShiroConfig.java b/mallinkAdmin/src/main/java/com/iformall/config/ShiroConfig.java index 4fa507ec5..4b628cfac 100644 --- a/mallinkAdmin/src/main/java/com/iformall/config/ShiroConfig.java +++ b/mallinkAdmin/src/main/java/com/iformall/config/ShiroConfig.java @@ -116,6 +116,7 @@ public class ShiroConfig { // } filterChainDefinitionMap.put("/swagger-ui.html", "anon"); filterChainDefinitionMap.put("/wxPay/notify/**", "anon"); + filterChainDefinitionMap.put("/wxOpen/**", "anon"); filterChainDefinitionMap.put("/wxPayBill/notify/**", "anon"); filterChainDefinitionMap.put("/v2/**", "anon"); filterChainDefinitionMap.put("/swagger-resources/**", "anon"); From 960810a5ca731f89902bc8eec891b0dadcffbf8f Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Fri, 30 Nov 2018 14:33:24 +0800 Subject: [PATCH 5/9] =?UTF-8?q?[=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8D][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E6=97=A0=E5=90=8E=E7=BC=80?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/controller/UploadController.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/UploadController.java b/mallinkAdmin/src/main/java/com/iformall/controller/UploadController.java index 5509f3fbb..82c18f5b4 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/UploadController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/UploadController.java @@ -114,7 +114,7 @@ public class UploadController extends BaseController { @PostMapping(value = "/awsFileUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") @ApiOperation("上传文件") public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) { - logger.debug("[" + getIpAddr() + "] UploadController::awsfileUpload"); + logger.info("[" + getIpAddr() + "] UploadController::awsfileUpload"); ResultData data = new ResultData(); @@ -141,7 +141,12 @@ public class UploadController extends BaseController { .build(); String fileName = UUID.randomUUID().toString(); int dot = multiReq.getOriginalFilename().lastIndexOf('.'); - fileName = getTenantId() + "/" + fileName + multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); + if (dot >= 0) { + fileName = getTenantId() + "/" + fileName + multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); + } else { + fileName = getTenantId() + "/" + fileName; + } + s3.putObject( new PutObjectRequest(awsProperty.getBucketName(), fileName, multiReq.getInputStream(), metadata) From 1cc1ce0eea2a0b43f85810365efbef096de87b56 Mon Sep 17 00:00:00 2001 From: hupeng Date: Fri, 30 Nov 2018 16:36:52 +0800 Subject: [PATCH 6/9] =?UTF-8?q?[A=E7=AB=AF][=E4=BF=AE=E5=A4=8D]:=E5=8D=A1?= =?UTF-8?q?=E5=88=B8=E5=88=9B=E5=BB=BA=E6=9D=A1=E4=BB=B6=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/controller/WxCouponController.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponController.java index 8a4b029d7..d39b2b0c5 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponController.java @@ -9,6 +9,7 @@ import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxCouponChannel; import com.iformall.domain.po.WxMerchant; import com.iformall.enums.EnumCouponStatus; +import com.iformall.enums.EnumCouponValidType; import com.iformall.enums.EnumMerchantStatus; import com.iformall.service.WxCouponChannelService; import com.iformall.service.WxCouponService; @@ -119,6 +120,12 @@ public class WxCouponController extends BaseController { } wxCoupon.setTenantId(getUser().getTenantId()); wxCoupon.setChannels(""); + if (wxCoupon.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING)) { + wxCoupon.setValidStartDate(null); + wxCoupon.setValidEndDate(null); + } else if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME)) { + wxCoupon.setValidDays(null); + } Long id = wxCouponService.saveOrUpdate(wxCoupon); return new ResultData(id); } @@ -134,6 +141,12 @@ public class WxCouponController extends BaseController { String[] arys = wxCoupon.getBusiness().split(","); wxCoupon.setBusiness(JSON.toJSONString(arys)); } + if (wxCoupon.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING)) { + wxCoupon.setValidStartDate(null); + wxCoupon.setValidEndDate(null); + } else if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME)) { + wxCoupon.setValidDays(null); + } return wxCouponService.updateCoupon(wxCoupon); } From 11c58a7a12716d4521baefef8b9d97aace5e408f Mon Sep 17 00:00:00 2001 From: hupeng Date: Fri, 30 Nov 2018 17:18:25 +0800 Subject: [PATCH 7/9] =?UTF-8?q?[A=E7=AB=AF][=E4=BF=AE=E6=94=B9]:=E5=88=B8?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/iformall/domain/po/WxCoupon.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java index 47c18a6ff..9635d150d 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java @@ -1,9 +1,12 @@ package com.iformall.domain.po; +import software.amazon.ion.Decimal; + import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; import java.io.Serializable; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.util.Date; import java.util.List; @@ -298,8 +301,7 @@ public class WxCoupon implements Serializable { public String getUsePriceStr() { if(usePrice!=null) { - DecimalFormat df=new DecimalFormat("0.00"); - usePriceStr = df.format((float)usePrice/100); + usePriceStr = new BigDecimal(usePrice).divide(new BigDecimal(100)).toString(); } return usePriceStr; } @@ -310,8 +312,7 @@ public class WxCoupon implements Serializable { public String getPriceStr() { if(price!=null) { - DecimalFormat df=new DecimalFormat("0.00"); - priceStr = df.format((float)price/100); + priceStr = new BigDecimal(price).divide(new BigDecimal(100)).toString(); } return priceStr; } From 975704e44147341ba3f5245244115512135f830a Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Fri, 30 Nov 2018 17:46:00 +0800 Subject: [PATCH 8/9] =?UTF-8?q?[=E8=BD=A6=E5=9C=BA=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96][=E6=96=B0=E5=A2=9E]:=E8=BD=A6=E5=9C=BA?= =?UTF-8?q?=E7=8A=B6=E6=80=81api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/controller/WxCarController.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxCarController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxCarController.java index 7849ad1f8..2dc2e9756 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxCarController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxCarController.java @@ -1,6 +1,7 @@ package com.iformall.controller; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; @@ -9,6 +10,7 @@ import com.iformall.domain.po.*; import com.iformall.domain.vo.WxCouponCarVo; import com.iformall.enums.EnumCarVendor; import com.iformall.enums.EnumCouponStatus; +import com.iformall.enums.EnumETCPCode; import com.iformall.service.*; import com.iformall.utils.ETCPUtil; import com.iformall.utils.TJDCarUtil; @@ -334,5 +336,58 @@ public class WxCarController extends BaseController { } + @ApiOperation(value = "停车场状态") + @GetMapping("/getParkStatus") + public ResultData getParkStatus() { + MallUserInfo user = getUser(); + /// 1, get mall's park + WxPark park = getCurrentPark(user); + if (park.getVendorType() == EnumCarVendor.CAR_ETCP.getCode()) { + String params = park.getVendorParams(); + JSONObject objParams = JSON.parseObject(params); + String url = objParams.getString("url"); + String merchantNo = objParams.getString("merchantNo"); + String merchantKey = objParams.getString("merchantKey"); + String version = objParams.getString("version"); + if (park.getParkingId() == null) { + String lat = objParams.getString("lat"); + String lon = objParams.getString("lon"); + String radius = objParams.getString("radius"); + String ret = etcp.parkingInfo(url, merchantNo, merchantKey, version, lat, lon, radius); + logger.info(ret); + JSONObject retObj = JSON.parseObject(ret); + if (retObj.getIntValue("code") == EnumETCPCode.SUCCESS.getCode()) { + JSONObject retData = retObj.getJSONObject("data"); + if (retData != null) { + JSONArray retDataList = retData.getJSONArray("list"); + if (retDataList != null) { + JSONObject parkData = retDataList.getJSONObject(0); + if (parkData != null) { + String parkId = parkData.getString("id"); + objParams.put("parkId", parkId); + params = JSON.toJSONString(objParams); + park.setVendorParams(params); + park.setParkingId(parkId); + wxParkService.saveOrUpdate(park); + } + } + } + } + } + + if (park.getParkingId() != null) { + String ret = etcp.parkingStatus(url, merchantNo, merchantKey, version, park.getParkingId()); + + JSONObject retObj = JSON.parseObject(ret); + if (retObj.getIntValue("code") == EnumETCPCode.SUCCESS.getCode()) { + if (retObj.get("data") != null) { + return new ResultData(retObj.getJSONObject("data")); + } + } + } + } + return new ResultData(ErrorCode.CAR_VENDOR_NOT_SUPPORT.getCode(), "车场不支持"); + } + } From 06582095586051936549a6c6b1a20c4dd73ff555 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Fri, 30 Nov 2018 17:51:35 +0800 Subject: [PATCH 9/9] =?UTF-8?q?[=E5=AE=A2=E6=B5=81=E6=95=B0=E6=8D=AE][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E6=95=B0=E6=8D=AE=E8=A1=A8=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E6=95=B0=E6=8D=AE=E6=89=8D=E8=BF=94=E5=9B=9E]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DataTowerServiceImpl.java | 14 ++++++-------- .../service/impl/PushLimitServiceImpl.java | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java index 97d4dbec9..dd8c9f1c5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java @@ -616,18 +616,16 @@ public class DataTowerServiceImpl implements DataTowerService { @Override public Map queryCustomer(String tenantId) { - - WxWiWideInfo wiWideInfo = new WxWiWideInfo(); wiWideInfo.setTenantId(tenantId); List list = wxWiwideInfoMapper.findList(wiWideInfo); - wiWideInfo = list.get(0); - String wiwideUrl = wiWideInfo.getWiwideUrl(); Map datamap = new HashMap<>(2); - - datamap.put("token", getWiwideToken(wiWideInfo)); - datamap.put("url", wiwideUrl); - + if(list.size()>0){ + wiWideInfo = list.get(0); + String wiwideUrl = wiWideInfo.getWiwideUrl(); + datamap.put("token", getWiwideToken(wiWideInfo)); + datamap.put("url", wiwideUrl); + } return datamap; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java index 30c1c8121..0e9cc3b6d 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java @@ -95,7 +95,7 @@ public class PushLimitServiceImpl implements PushLimitService { // 2. check time boolean isInDate = DateUtils.isInDate(curDate, pushLimit.getTimeStart(), pushLimit.getTimeEnd()); if (!isInDate) { - logger.error("短信已达到每天上限"); + logger.error("不在疲劳度允许的时间段"); throw new MallinkException(ErrorCode.PUSH_LIMIT_NOT_INRANG); } return isInDate; @@ -109,7 +109,7 @@ public class PushLimitServiceImpl implements PushLimitService { // 2. check time boolean isInDate = DateUtils.isInDate(curDate, pushLimit.getTimeStart(), pushLimit.getTimeEnd()); if (!isInDate) { - logger.error("短信已达到每天上限"); + logger.error("不在疲劳度允许的时间段"); throw new MallinkException(ErrorCode.PUSH_LIMIT_NOT_INRANG); } // TODO 3. check phone had up to limit