| @@ -0,0 +1,60 @@ | |||||
| package com.iformall.controller; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.entity.PayAdapterResult; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.*; | |||||
| import com.iformall.service.wx.WxPayService; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.SysConfigConstant; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @RestController | |||||
| @RequestMapping("/api/product") | |||||
| public class WxProductController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| SysConfigService sysConfigService; | |||||
| @GetMapping("/detail") | |||||
| public ResultData payOrderDetail() { | |||||
| Map retMap = new HashMap(); | |||||
| TenantEntity tenantEntity = getCUser(); | |||||
| SysConfig salePrice = sysConfigService.getByKey(SysConfigConstant.sale_price, tenantEntity); | |||||
| SysConfig price = sysConfigService.getByKey(SysConfigConstant.price, tenantEntity); | |||||
| SysConfig days = sysConfigService.getByKey(SysConfigConstant.expired_days, tenantEntity); | |||||
| SysConfig img = sysConfigService.getByKey(SysConfigConstant.productImg, tenantEntity); | |||||
| retMap.put("price", price.getConfigItemValue()); | |||||
| retMap.put("salePrice", salePrice.getConfigItemValue()); | |||||
| retMap.put("days", days.getConfigItemValue()); | |||||
| retMap.put("productImg", img.getConfigItemValue()); | |||||
| return new ResultData(retMap); | |||||
| } | |||||
| } | |||||
| @@ -130,6 +130,7 @@ public class WxUserGrantController extends BaseController { | |||||
| logger.info("session_key: " + session_key + ", openId: " + openId + ", unionId: " + unionId); | logger.info("session_key: " + session_key + ", openId: " + openId + ", unionId: " + unionId); | ||||
| resultMap.put("openId", openId); | resultMap.put("openId", openId); | ||||
| resultMap.put("sessionKey", session_key); | resultMap.put("sessionKey", session_key); | ||||
| resultMap.put("tenantId", wxAppinfo.getTenantId()); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage(), e); | logger.error(e.getMessage(), e); | ||||
| return new ResultData(ErrorCode.PARAM_EMPITY, resultMap); | return new ResultData(ErrorCode.PARAM_EMPITY, resultMap); | ||||
| @@ -9,6 +9,7 @@ import com.iformall.common.TenantThreadLocal; | |||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxCUserService; | |||||
| import com.iformall.service.cache.WxCUserCache; | import com.iformall.service.cache.WxCUserCache; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -34,6 +35,9 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| @Autowired | @Autowired | ||||
| @Qualifier("objectCommonRedisTemplate") | @Qualifier("objectCommonRedisTemplate") | ||||
| RedisTemplate<String, Object> redisTemplate; | RedisTemplate<String, Object> redisTemplate; | ||||
| @Autowired | |||||
| WxCUserService wxCUserService; | |||||
| @Override | @Override | ||||
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | ||||
| @@ -58,15 +62,26 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| if(StringUtils.isBlank(token)){ | if(StringUtils.isBlank(token)){ | ||||
| token = request.getParameter("token"); | token = request.getParameter("token"); | ||||
| } | } | ||||
| String tenantId = request.getHeader("tenantId"); | |||||
| if(StringUtils.isBlank(tenantId)){ | |||||
| tenantId = request.getParameter("tenantId"); | |||||
| } | |||||
| //token为空 | //token为空 | ||||
| if(StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token)){ | |||||
| if(StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token) | |||||
| || StringUtils.isBlank(tenantId) || "null".equals(tenantId) || "undefined".equals(tenantId)){ | |||||
| throw new MallinkException(ErrorCode.UNLOGIN); | throw new MallinkException(ErrorCode.UNLOGIN); | ||||
| } | } | ||||
| WxCUser wxCUser = WxCUserCache.getCacheAppInfo(redisTemplate, Long.parseLong(token)); | WxCUser wxCUser = WxCUserCache.getCacheAppInfo(redisTemplate, Long.parseLong(token)); | ||||
| if (null == wxCUser) { | if (null == wxCUser) { | ||||
| throw new MallinkException(ErrorCode.UNLOGIN); | |||||
| wxCUser = wxCUserService.getById(Long.parseLong(token), tenantId); | |||||
| if (null == wxCUser) { | |||||
| throw new MallinkException(ErrorCode.UNLOGIN); | |||||
| } | |||||
| WxCUserCache.cacheApp(redisTemplate, wxCUser); | |||||
| } | } | ||||
| request.setAttribute(Constant.TENANT_ID, wxCUser.getTenantId()); | request.setAttribute(Constant.TENANT_ID, wxCUser.getTenantId()); | ||||
| @@ -21,7 +21,7 @@ import com.iformall.common.IdWorker; | |||||
| @Service | @Service | ||||
| public class SysConfigServiceImpl implements SysConfigService { | public class SysConfigServiceImpl implements SysConfigService { | ||||
| private static final String cache_prex = "sysconfig:%s:%s"; | |||||
| private static final String cache_prex = "gpt:sysconfig:%s:%s"; | |||||
| @Autowired | @Autowired | ||||
| SysConfigMapper sysConfigMapper; | SysConfigMapper sysConfigMapper; | ||||
| @@ -3,7 +3,8 @@ package com.iformall.utils; | |||||
| public class SysConfigConstant { | public class SysConfigConstant { | ||||
| public static final String sale_price="salePrice"; | public static final String sale_price="salePrice"; | ||||
| public static final String pay_call_back = "payCallBack"; | |||||
| public static final String price="price"; | |||||
| public static final String productImg="productImg"; | |||||
| public static final String expired_days = "expiredDays"; | public static final String expired_days = "expiredDays"; | ||||
| } | } | ||||