developrelease_toaliyun_real
| @@ -101,6 +101,7 @@ public class ShiroConfig { | |||||
| filterChainDefinitionMap.put("/bHidLogin/**", "anon"); | filterChainDefinitionMap.put("/bHidLogin/**", "anon"); | ||||
| filterChainDefinitionMap.put("/sendLoginPhoneCode/**", "anon"); | filterChainDefinitionMap.put("/sendLoginPhoneCode/**", "anon"); | ||||
| filterChainDefinitionMap.put("/doLoginByPhone/**", "anon"); | filterChainDefinitionMap.put("/doLoginByPhone/**", "anon"); | ||||
| filterChainDefinitionMap.put("/wechat/login", "anon"); // 微信第三方登录callback | |||||
| filterChainDefinitionMap.put("/wechat/callback", "anon"); // 微信第三方登录callback | filterChainDefinitionMap.put("/wechat/callback", "anon"); // 微信第三方登录callback | ||||
| filterChainDefinitionMap.put("/wechat/weChatUserLogin", "anon"); // 微信第三方登录绑定 | filterChainDefinitionMap.put("/wechat/weChatUserLogin", "anon"); // 微信第三方登录绑定 | ||||
| // callback | // callback | ||||
| @@ -55,9 +55,13 @@ public class WebConfig implements WebMvcConfigurer { | |||||
| public CorsFilter corsFilter() { | public CorsFilter corsFilter() { | ||||
| final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); | final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); | ||||
| final CorsConfiguration corsConfiguration = new CorsConfiguration(); | final CorsConfiguration corsConfiguration = new CorsConfiguration(); | ||||
| // 允许cookies跨域 | |||||
| corsConfiguration.setAllowCredentials(true); | corsConfiguration.setAllowCredentials(true); | ||||
| // 允许向该服务器提交请求的URI, *表示全部允许 | |||||
| corsConfiguration.addAllowedOrigin("*"); | corsConfiguration.addAllowedOrigin("*"); | ||||
| // 允许访问的头信息,*表示全部 | |||||
| corsConfiguration.addAllowedHeader("*"); | corsConfiguration.addAllowedHeader("*"); | ||||
| // 允许提交请求的方法, *表示全部允许 | |||||
| corsConfiguration.addAllowedMethod("*"); | corsConfiguration.addAllowedMethod("*"); | ||||
| urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); | urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); | ||||
| return new CorsFilter(urlBasedCorsConfigurationSource); | return new CorsFilter(urlBasedCorsConfigurationSource); | ||||
| @@ -167,6 +167,7 @@ public class HomeController extends BaseController { | |||||
| try { | try { | ||||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | ||||
| Cookie unameCookie = new Cookie("uname", cookieName); | Cookie unameCookie = new Cookie("uname", cookieName); | ||||
| unameCookie.setPath("/"); | |||||
| unameCookie.setMaxAge(3600); | unameCookie.setMaxAge(3600); | ||||
| response.addCookie(unameCookie); | response.addCookie(unameCookie); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -237,6 +238,7 @@ public class HomeController extends BaseController { | |||||
| } | } | ||||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | ||||
| Cookie unameCookie = new Cookie("uname", cookieName); | Cookie unameCookie = new Cookie("uname", cookieName); | ||||
| unameCookie.setPath("/"); | |||||
| unameCookie.setMaxAge(3600); | unameCookie.setMaxAge(3600); | ||||
| response.addCookie(unameCookie); | response.addCookie(unameCookie); | ||||
| @@ -329,6 +331,7 @@ public class HomeController extends BaseController { | |||||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | ||||
| Cookie unameCookie = new Cookie("uname", cookieName); | Cookie unameCookie = new Cookie("uname", cookieName); | ||||
| unameCookie.setPath("/"); | |||||
| unameCookie.setMaxAge(3600); | unameCookie.setMaxAge(3600); | ||||
| response.addCookie(unameCookie); | response.addCookie(unameCookie); | ||||
| @@ -29,14 +29,21 @@ import org.apache.shiro.authc.UnknownAccountException; | |||||
| import org.apache.shiro.subject.Subject; | import org.apache.shiro.subject.Subject; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Qualifier; | import org.springframework.beans.factory.annotation.Qualifier; | ||||
| import org.springframework.dao.DataAccessException; | |||||
| import org.springframework.data.redis.connection.RedisConnection; | |||||
| import org.springframework.data.redis.core.RedisCallback; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | import org.springframework.data.redis.core.RedisTemplate; | ||||
| import org.springframework.data.redis.serializer.RedisSerializer; | |||||
| import org.springframework.stereotype.Controller; | import org.springframework.stereotype.Controller; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import redis.clients.jedis.Protocol; | |||||
| import redis.clients.util.SafeEncoder; | |||||
| import javax.servlet.http.Cookie; | import javax.servlet.http.Cookie; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.UnsupportedEncodingException; | |||||
| import java.net.URLEncoder; | import java.net.URLEncoder; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| @@ -71,22 +78,56 @@ public class WechatLoginController extends BaseController { | |||||
| String userRole; | String userRole; | ||||
| } | } | ||||
| @ApiOperation(value = "微信登录") | |||||
| @GetMapping("login") | |||||
| public void login(HttpServletRequest request, HttpServletResponse response) { | |||||
| log.debug("[" + getIpAddr() + "] MallUserInfoController::login"); | |||||
| String host = request.getHeader("host"); | |||||
| log.debug("Host: " + host); | |||||
| host = getHost(host); | |||||
| String wechatUrl = wxMpService.buildQrConnectUrl("https://"+host+"/api/wechat/callback", "snsapi_login", "111"); | |||||
| try { | |||||
| response.sendRedirect(wechatUrl); | |||||
| } catch (IOException e) { | |||||
| log.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| private String getHost(String host) { | |||||
| if(host.contains("iformall.com")) { | |||||
| if(host.contains("admintest")) { | |||||
| host = "admin.malls.iformall.com"; | |||||
| } else { | |||||
| host = "admintest.malls.iformall.com"; | |||||
| } | |||||
| } else if(host.contains("youlane.cn")) { | |||||
| host = "mall.youlane.cn"; | |||||
| } else { | |||||
| host = "admin.malls.iformall.com"; | |||||
| } | |||||
| return host; | |||||
| } | |||||
| @ApiOperation(value = "微信网页登录回调", notes = "请配置此callback到网页redirect_uri") | @ApiOperation(value = "微信网页登录回调", notes = "请配置此callback到网页redirect_uri") | ||||
| @GetMapping("callback") | @GetMapping("callback") | ||||
| @ResponseBody | |||||
| public void getAccessToken(String code, String state, HttpServletRequest request, HttpServletResponse response) { | public void getAccessToken(String code, String state, HttpServletRequest request, HttpServletResponse response) { | ||||
| log.debug("[" + getIpAddr() + "] WechatLoginController::getAccessToken"); | log.debug("[" + getIpAddr() + "] WechatLoginController::getAccessToken"); | ||||
| String host = request.getHeader("host"); | String host = request.getHeader("host"); | ||||
| log.debug("host: " + host); | log.debug("host: " + host); | ||||
| log.debug("code: " + code); | log.debug("code: " + code); | ||||
| host = getHost(host); | |||||
| try { | try { | ||||
| WxMpOAuth2AccessToken accessToken = wxMpService.oauth2getAccessToken(code); | WxMpOAuth2AccessToken accessToken = wxMpService.oauth2getAccessToken(code); | ||||
| log.debug("accessToken: " + accessToken.getAccessToken() + ", openId: " + accessToken.getOpenId() + ", unionId: " + accessToken.getUnionId()); | |||||
| log.info("accessToken: " + accessToken.getAccessToken() + ", openId: " + accessToken.getOpenId() + ", unionId: " + accessToken.getUnionId()); | |||||
| accessToken = wxMpService.oauth2refreshAccessToken(accessToken.getRefreshToken()); | |||||
| log.info("accessToken: " + accessToken.getAccessToken() + ", openId: " + accessToken.getOpenId() + ", unionId: " + accessToken.getUnionId()); | |||||
| // 获取 用户信息 | // 获取 用户信息 | ||||
| WxMpUser mpUser = wxMpService.oauth2getUserInfo(accessToken, null); | WxMpUser mpUser = wxMpService.oauth2getUserInfo(accessToken, null); | ||||
| if(mpUser != null) { | if(mpUser != null) { | ||||
| log.debug(mpUser.toString()); | |||||
| log.info(mpUser.toString()); | |||||
| } | } | ||||
| // check user openid 是否是已授权用户 | // check user openid 是否是已授权用户 | ||||
| @@ -130,6 +171,7 @@ public class WechatLoginController extends BaseController { | |||||
| try { | try { | ||||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | ||||
| Cookie unameCookie = new Cookie("uname", cookieName); | Cookie unameCookie = new Cookie("uname", cookieName); | ||||
| unameCookie.setPath("/"); | |||||
| unameCookie.setMaxAge(3600); | unameCookie.setMaxAge(3600); | ||||
| response.addCookie(unameCookie); | response.addCookie(unameCookie); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -139,12 +181,14 @@ public class WechatLoginController extends BaseController { | |||||
| } | } | ||||
| Object codeObj = ret.get("code"); | Object codeObj = ret.get("code"); | ||||
| if(codeObj == null) { | if(codeObj == null) { | ||||
| log.info("用户登录成功,切换主页"); | |||||
| try { | try { | ||||
| response.sendRedirect("https://" + host + "/#/layout"); | |||||
| response.sendRedirect("https://"+host+"/#/layout"); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| log.error(e.getMessage()); | log.error(e.getMessage()); | ||||
| } | } | ||||
| } else { | } else { | ||||
| log.info("用户登录失败-3,返回登录"); | |||||
| try { | try { | ||||
| String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); | String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); | ||||
| response.sendRedirect("https://" + host + "/#/login?errcode=" + errCode); | response.sendRedirect("https://" + host + "/#/login?errcode=" + errCode); | ||||
| @@ -153,6 +197,7 @@ public class WechatLoginController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| log.info("用户登录失败-2,返回登录"); | |||||
| try { | try { | ||||
| String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); | String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); | ||||
| response.sendRedirect("https://" + host + "/#/login?errcode="+errCode); | response.sendRedirect("https://" + host + "/#/login?errcode="+errCode); | ||||
| @@ -162,10 +207,20 @@ public class WechatLoginController extends BaseController { | |||||
| } | } | ||||
| } else { | } else { | ||||
| // 跳转登录选择页面 | // 跳转登录选择页面 | ||||
| String key = TOTP.generateWechatOpen(accessToken.getOpenId()); | |||||
| if (openRedisTemplate.opsForValue().setIfAbsent(WECHAT_PREV + key, accessToken.getOpenId())){ | |||||
| openRedisTemplate.expire(key, 30, TimeUnit.SECONDS); | |||||
| } | |||||
| String key = WECHAT_PREV + TOTP.generateWechatOpen(accessToken.getOpenId()); | |||||
| Boolean isAbsent = openRedisTemplate.<Boolean>execute(new RedisCallback<Boolean>() { | |||||
| @Override | |||||
| public Boolean doInRedis(RedisConnection connection) throws DataAccessException { | |||||
| RedisSerializer valueSerializer = openRedisTemplate.getValueSerializer(); | |||||
| RedisSerializer keySerializer = openRedisTemplate.getKeySerializer(); | |||||
| Object obj = connection.execute("set", keySerializer.serialize(key), | |||||
| valueSerializer.serialize(key), | |||||
| SafeEncoder.encode("NX"), | |||||
| SafeEncoder.encode("EX"), | |||||
| Protocol.toByteArray(60)); // 60s 过期时间 | |||||
| return obj != null; | |||||
| } | |||||
| }); | |||||
| List<DisplayUserInfo> users = new ArrayList<DisplayUserInfo>(); | List<DisplayUserInfo> users = new ArrayList<DisplayUserInfo>(); | ||||
| for(MallUserInfoVo user: userList) { | for(MallUserInfoVo user: userList) { | ||||
| DisplayUserInfo disUser = new DisplayUserInfo(); | DisplayUserInfo disUser = new DisplayUserInfo(); | ||||
| @@ -184,6 +239,7 @@ public class WechatLoginController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| log.info("用户登录失败-1,返回登录"); | |||||
| // 跳转登录页面 | // 跳转登录页面 | ||||
| Map<String, Object> ret = new HashMap<>(); | Map<String, Object> ret = new HashMap<>(); | ||||
| ret.put("code", ErrorCode.WECHAT_LOGIN_NOT_BIND.getCode()); | ret.put("code", ErrorCode.WECHAT_LOGIN_NOT_BIND.getCode()); | ||||
| @@ -242,6 +298,7 @@ public class WechatLoginController extends BaseController { | |||||
| // 登录cookie | // 登录cookie | ||||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | ||||
| Cookie unameCookie = new Cookie("uname", cookieName); | Cookie unameCookie = new Cookie("uname", cookieName); | ||||
| unameCookie.setPath("/"); | |||||
| unameCookie.setMaxAge(3600); | unameCookie.setMaxAge(3600); | ||||
| response.addCookie(unameCookie); | response.addCookie(unameCookie); | ||||
| @@ -7,10 +7,16 @@ import com.iformall.utils.IPUtil; | |||||
| import com.iformall.utils.UrlCheck; | import com.iformall.utils.UrlCheck; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.dao.DataAccessException; | |||||
| import org.springframework.data.redis.connection.RedisConnection; | |||||
| import org.springframework.data.redis.core.RedisCallback; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | import org.springframework.data.redis.core.RedisTemplate; | ||||
| import org.springframework.data.redis.serializer.RedisSerializer; | |||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| import org.springframework.web.servlet.ModelAndView; | import org.springframework.web.servlet.ModelAndView; | ||||
| import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | ||||
| import redis.clients.jedis.Protocol; | |||||
| import redis.clients.util.SafeEncoder; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| @@ -78,8 +84,20 @@ public class RequestInterceptor extends HandlerInterceptorAdapter { | |||||
| sb.append(resultBody); | sb.append(resultBody); | ||||
| String key = "request-" + HashUtil.md5(sb.toString()); | String key = "request-" + HashUtil.md5(sb.toString()); | ||||
| if (redisTemplate.opsForValue().setIfAbsent(key, key)) { | |||||
| redisTemplate.expire(key, 3, TimeUnit.SECONDS); | |||||
| Boolean isAbsent = redisTemplate.<Boolean>execute(new RedisCallback<Boolean>() { | |||||
| @Override | |||||
| public Boolean doInRedis(RedisConnection connection) throws DataAccessException { | |||||
| RedisSerializer valueSerializer = redisTemplate.getValueSerializer(); | |||||
| RedisSerializer keySerializer = redisTemplate.getKeySerializer(); | |||||
| Object obj = connection.execute("set", keySerializer.serialize(key), | |||||
| valueSerializer.serialize(key), | |||||
| SafeEncoder.encode("NX"), | |||||
| SafeEncoder.encode("EX"), | |||||
| Protocol.toByteArray(3)); // 3s | |||||
| return obj != null; | |||||
| } | |||||
| }); | |||||
| if (isAbsent) { | |||||
| logger.info(key + ": 第一次提交"); | logger.info(key + ": 第一次提交"); | ||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -4,10 +4,16 @@ import com.iformall.utils.HashUtil; | |||||
| import com.iformall.utils.IPUtil; | import com.iformall.utils.IPUtil; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.dao.DataAccessException; | |||||
| import org.springframework.data.redis.connection.RedisConnection; | |||||
| import org.springframework.data.redis.core.RedisCallback; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | import org.springframework.data.redis.core.RedisTemplate; | ||||
| import org.springframework.data.redis.serializer.RedisSerializer; | |||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| import org.springframework.web.servlet.ModelAndView; | import org.springframework.web.servlet.ModelAndView; | ||||
| import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | ||||
| import redis.clients.jedis.Protocol; | |||||
| import redis.clients.util.SafeEncoder; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| @@ -70,8 +76,20 @@ public class RequestInterceptor extends HandlerInterceptorAdapter { | |||||
| sb.append(resultBody); | sb.append(resultBody); | ||||
| String key = "request-" + HashUtil.md5(sb.toString()); | String key = "request-" + HashUtil.md5(sb.toString()); | ||||
| if (redisTemplate.opsForValue().setIfAbsent(key, key)) { | |||||
| redisTemplate.expire(key, 3, TimeUnit.SECONDS); | |||||
| Boolean isAbsent = redisTemplate.<Boolean>execute(new RedisCallback<Boolean>() { | |||||
| @Override | |||||
| public Boolean doInRedis(RedisConnection connection) throws DataAccessException { | |||||
| RedisSerializer valueSerializer = redisTemplate.getValueSerializer(); | |||||
| RedisSerializer keySerializer = redisTemplate.getKeySerializer(); | |||||
| Object obj = connection.execute("set", keySerializer.serialize(key), | |||||
| valueSerializer.serialize(key), | |||||
| SafeEncoder.encode("NX"), | |||||
| SafeEncoder.encode("EX"), | |||||
| Protocol.toByteArray(3)); // 3s | |||||
| return obj != null; | |||||
| } | |||||
| }); | |||||
| if (isAbsent) { | |||||
| logger.info(key + ": 第一次提交"); | logger.info(key + ": 第一次提交"); | ||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -4,10 +4,16 @@ import com.iformall.utils.HashUtil; | |||||
| import com.iformall.utils.IPUtil; | import com.iformall.utils.IPUtil; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.dao.DataAccessException; | |||||
| import org.springframework.data.redis.connection.RedisConnection; | |||||
| import org.springframework.data.redis.core.RedisCallback; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | import org.springframework.data.redis.core.RedisTemplate; | ||||
| import org.springframework.data.redis.serializer.RedisSerializer; | |||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| import org.springframework.web.servlet.ModelAndView; | import org.springframework.web.servlet.ModelAndView; | ||||
| import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | ||||
| import redis.clients.jedis.Protocol; | |||||
| import redis.clients.util.SafeEncoder; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| @@ -72,8 +78,20 @@ public class RequestInterceptor extends HandlerInterceptorAdapter { | |||||
| sb.append(resultBody); | sb.append(resultBody); | ||||
| String key = "request-" + HashUtil.md5(sb.toString()); | String key = "request-" + HashUtil.md5(sb.toString()); | ||||
| if (redisTemplate.opsForValue().setIfAbsent(key, key)) { | |||||
| redisTemplate.expire(key, 3, TimeUnit.SECONDS); | |||||
| Boolean isAbsent = redisTemplate.<Boolean>execute(new RedisCallback<Boolean>() { | |||||
| @Override | |||||
| public Boolean doInRedis(RedisConnection connection) throws DataAccessException { | |||||
| RedisSerializer valueSerializer = redisTemplate.getValueSerializer(); | |||||
| RedisSerializer keySerializer = redisTemplate.getKeySerializer(); | |||||
| Object obj = connection.execute("set", keySerializer.serialize(key), | |||||
| valueSerializer.serialize(key), | |||||
| SafeEncoder.encode("NX"), | |||||
| SafeEncoder.encode("EX"), | |||||
| Protocol.toByteArray(3)); // 3s | |||||
| return obj != null; | |||||
| } | |||||
| }); | |||||
| if (isAbsent) { | |||||
| logger.info(key + ": 第一次提交"); | logger.info(key + ": 第一次提交"); | ||||
| logger.debug("preHandle start 2"); | logger.debug("preHandle start 2"); | ||||
| return true; | return true; | ||||
| @@ -56,17 +56,20 @@ public class MqBaseConsumer { | |||||
| baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode()); | baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode()); | ||||
| wxMsgRecordMapper.update(baseMsg); | wxMsgRecordMapper.update(baseMsg); | ||||
| }catch (Exception e){ | }catch (Exception e){ | ||||
| //todo:测试下 | |||||
| if(null != baseMsg){ | |||||
| if(baseMsg.getDelayTimeLevel() < 3){ | |||||
| baseMsg.setDelayTimeLevel(3); //10s后重试 | |||||
| mqBaseProducer.sendMessage(baseMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| }else{ | |||||
| baseMsg.setStatusMessage(e.getMessage()); | |||||
| baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode()); | |||||
| wxMsgRecordMapper.update(baseMsg); | |||||
| } | |||||
| } | |||||
| log.error("consum received error: {}", e); | |||||
| baseMsg.setStatusMessage(e.getMessage()); | |||||
| baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode()); | |||||
| wxMsgRecordMapper.update(baseMsg); | |||||
| // if(null != baseMsg){ | |||||
| // if(baseMsg.getDelayTimeLevel() < 3){ | |||||
| // baseMsg.setDelayTimeLevel(3); //10s后重试 | |||||
| // mqBaseProducer.sendMessage(baseMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| // }else{ | |||||
| // baseMsg.setStatusMessage(e.getMessage()); | |||||
| // baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode()); | |||||
| // wxMsgRecordMapper.update(baseMsg); | |||||
| // } | |||||
| // } | |||||
| } | } | ||||
| } | } | ||||
| @@ -86,4 +86,4 @@ logging: | |||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| com.iformall.mapper: debug | com.iformall.mapper: debug | ||||
| path: ./logs/s | |||||
| path: ./logs/m | |||||
| @@ -72,4 +72,4 @@ logging: | |||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| com.iformall: debug | com.iformall: debug | ||||
| path: ./logs/s | |||||
| path: ./logs/m | |||||
| @@ -1,7 +1,6 @@ | |||||
| spring: | spring: | ||||
| profiles: | profiles: | ||||
| include: rabbitMQ | include: rabbitMQ | ||||
| spring: | |||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallinkTest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true | url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallinkTest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true | ||||
| @@ -71,4 +70,4 @@ logging: | |||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| com.iformall: debug | com.iformall: debug | ||||
| path: ./logs/s | |||||
| path: ./logs/m | |||||
| @@ -2,7 +2,6 @@ package com.iformall.schedule; | |||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.WxOrder; | import com.iformall.domain.po.WxOrder; | ||||
| import com.iformall.domain.po.WxOrderGroup; | |||||
| import com.iformall.enums.EnumAppType; | import com.iformall.enums.EnumAppType; | ||||
| import com.iformall.enums.EnumOrderStatus; | import com.iformall.enums.EnumOrderStatus; | ||||
| import com.iformall.enums.EnumOrderType; | import com.iformall.enums.EnumOrderType; | ||||
| @@ -82,24 +81,36 @@ public class OrderExpiringSchedule { | |||||
| } | } | ||||
| }); | }); | ||||
| //拼团 过期与失败 | |||||
| List<WxOrderGroup> orderGroups = wxOrderGroupService.findList(null); | |||||
| orderGroups.stream().forEach(g -> { | |||||
| //拼团过期 | |||||
| WxOrder order = new WxOrder(); | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_OVERTIME.getCode()); | |||||
| wxOrderMapper.select(order).parallelStream().forEach(o -> { | |||||
| try { | try { | ||||
| wxOrderGroupService.updateGroupStatus(g); | |||||
| returnMoney(o); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error("拼团过期退款失败" + e.getMessage()); | |||||
| } | |||||
| }); | |||||
| //拼团券下架 | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode()); | |||||
| wxOrderMapper.select(order).parallelStream().forEach(o -> { | |||||
| try { | |||||
| returnMoney(o); | |||||
| } catch (Exception e) { | |||||
| logger.error("拼团券下架退款失败" + e.getMessage()); | |||||
| } | } | ||||
| }); | }); | ||||
| //参团失败 | //参团失败 | ||||
| WxOrder order = new WxOrder(); | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_FAILD.getCode()); | order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_FAILD.getCode()); | ||||
| wxOrderMapper.select(order).parallelStream().forEach(o -> { | wxOrderMapper.select(order).parallelStream().forEach(o -> { | ||||
| try { | try { | ||||
| returnMoney(o); | returnMoney(o); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("拼团订单退款失败" + e.getMessage()); | |||||
| logger.error("参团失败退款失败" + e.getMessage()); | |||||
| } | } | ||||
| }); | }); | ||||
| @@ -117,6 +117,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||||
| ArrayList typeList = new ArrayList(); | ArrayList typeList = new ArrayList(); | ||||
| typeList.add(EnumBillTypeParam.RENT_DEPOSIT.getCode()); | typeList.add(EnumBillTypeParam.RENT_DEPOSIT.getCode()); | ||||
| typeList.add(EnumBillTypeParam.PROPERTY_DEPOSIT.getCode()); | typeList.add(EnumBillTypeParam.PROPERTY_DEPOSIT.getCode()); | ||||
| typeList.add(EnumBillTypeParam.ATHER_DEPOSIT.getCode()); | |||||
| wxBillAll.setTypeList(typeList); | wxBillAll.setTypeList(typeList); | ||||
| } else if (wxBillAll.getBillTypeValue().equals(EnumBillType.PROPERTY.getCode())) { | } else if (wxBillAll.getBillTypeValue().equals(EnumBillType.PROPERTY.getCode())) { | ||||
| wxBillAll.setBillTypeValue(EnumBillTypeParam.PROPERTY.getCode()); | wxBillAll.setBillTypeValue(EnumBillTypeParam.PROPERTY.getCode()); | ||||
| @@ -41,7 +41,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { | |||||
| @Override | @Override | ||||
| public PageInfo<Map<String, Object>> listAsPage(WxBillProperty record, Integer pageIndex, Integer pageSize) { | public PageInfo<Map<String, Object>> listAsPage(WxBillProperty record, Integer pageIndex, Integer pageSize) { | ||||
| //更新账单状态 | //更新账单状态 | ||||
| updateBillStatus(record); | |||||
| //updateBillStatus(record); | |||||
| PageHelper.startPage(pageIndex, pageSize); | PageHelper.startPage(pageIndex, pageSize); | ||||
| List<Map<String, Object>> billRentList = wxBillPropertyMapper.queryBillPropertyList(record); | List<Map<String, Object>> billRentList = wxBillPropertyMapper.queryBillPropertyList(record); | ||||
| PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(billRentList); | PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(billRentList); | ||||
| @@ -157,19 +157,22 @@ | |||||
| rentShopType from ( | rentShopType from ( | ||||
| select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金' | select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金' | ||||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type | bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type | ||||
| from wx_bill_rent where is_preview = 0 | |||||
| from wx_bill_rent where is_preview = 0 and rent_contract_id in (select id from wx_rent_contract where status in | |||||
| (2,3,4)) | |||||
| union | union | ||||
| select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金' | select id,merchant_id,shop_id,tenant_id,'租赁押金' name,2 bill_type_value,'租赁押金' | ||||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type | bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type | ||||
| from wx_bill_rent_deposit | |||||
| from wx_bill_rent_deposit where rent_contract_id in (select id from wx_rent_contract where status in (2,3,4)) | |||||
| union | union | ||||
| select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费' | select id,merchant_id,shop_id,tenant_id,'物业费' name,3 bill_type_value,'物业费' | ||||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type | bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type | ||||
| from wx_bill_property where is_preview = 0 | |||||
| from wx_bill_property where is_preview = 0 and property_contract_id in (select id from wx_property_contract | |||||
| where status in(2,3,4)) | |||||
| union | union | ||||
| select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金' | select id,merchant_id,shop_id,tenant_id,'物业押金' name,4 bill_type_value,'物业押金' | ||||
| bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type | bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,starttime,endtime,rent_shop_type | ||||
| from wx_bill_property_deposit | |||||
| from wx_bill_property_deposit where property_contract_id in (select id from wx_property_contract where status in | |||||
| (2,3,4)) | |||||
| union | union | ||||
| select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type, 0 as | select id,merchant_id,shop_id,tenant_id,'水费' name,5 bill_type_value,'水费' bill_type, 0 as | ||||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type | need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type | ||||
| @@ -179,7 +182,7 @@ | |||||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type | need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type | ||||
| from wx_bill_daily where type=2 | from wx_bill_daily where type=2 | ||||
| union | union | ||||
| select id,merchant_id,shop_id,tenant_id,name,7 bill_type_value,'其他' bill_type,0 as | |||||
| select id,merchant_id,shop_id,tenant_id,name,7 bill_type_vaue,'其他' bill_type,0 as | |||||
| need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type | need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,'' endtime,rent_shop_type | ||||
| from wx_bill_other | from wx_bill_other | ||||
| union | union | ||||