| @@ -14,16 +14,20 @@ import com.iformall.enums.EnumUserAdmin; | |||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.shiro.PasswordHelper; | import com.iformall.shiro.PasswordHelper; | ||||
| import com.iformall.sms.EnumSMSChannel; | import com.iformall.sms.EnumSMSChannel; | ||||
| import com.iformall.utils.Constant; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.util.Assert; | import org.springframework.util.Assert; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.concurrent.TimeUnit; | |||||
| @RestController | @RestController | ||||
| @Api(description = "初始化相关接口") | @Api(description = "初始化相关接口") | ||||
| @@ -85,6 +89,10 @@ public class WxProjectConfigController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| MallUserInfoService mallUserInfoService; | MallUserInfoService mallUserInfoService; | ||||
| @Autowired | |||||
| @Qualifier("openRedisTemplate") | |||||
| RedisTemplate<String, String> openRedisTemplate; | |||||
| @ApiOperation("添加商场基础数据") | @ApiOperation("添加商场基础数据") | ||||
| @GetMapping(value = "/init/{id}") | @GetMapping(value = "/init/{id}") | ||||
| @@ -577,5 +585,44 @@ public class WxProjectConfigController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| @ApiOperation("刷集团商场历史数据(五分钟内只能掉一次)") | |||||
| @PostMapping("/init/after/group") | |||||
| @SystemControllerLog(description = "商场-数据更新") | |||||
| public ResultData initAfterGroup(@RequestBody WxMall wxMall) { | |||||
| logger.debug("[" + getIpAddr() + "] WxProjectConfigController::initAfterGroup"); | |||||
| try { | |||||
| if(StringUtils.isBlank(wxMall.getTenantId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| if(StringUtils.isBlank(wxMall.getParentTenantId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| TenantEntity TenantEntity = new TenantEntity(){{ | |||||
| setTenantId(wxMall.getParentTenantId()); | |||||
| }}; | |||||
| WxMall parentWxMall = wxMallService.getByTenantInfo(TenantEntity); | |||||
| if(parentWxMall == null || parentWxMall.getSaleType() != 100 | |||||
| || !parentWxMall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode()) | |||||
| || StringUtils.isNotBlank(parentWxMall.getParentTenantId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| sb.append(Constant.INTERFACE_VISIT_LIMIT_KEY).append("initAfterGroup"); | |||||
| String key = sb.toString(); | |||||
| boolean hasKey = openRedisTemplate.hasKey(key); | |||||
| if(hasKey){ | |||||
| return new ResultData(ErrorCode.TOO_MANY_REQUEST); | |||||
| }else{ | |||||
| openRedisTemplate.opsForValue().set(key,"1",3000, TimeUnit.SECONDS); | |||||
| } | |||||
| wxProjectConfigService.initAfterGroup(wxMall.getParentTenantId(),wxMall.getTenantId()); | |||||
| return new ResultData(); | |||||
| }catch (Exception e){ | |||||
| logger.error(e.getMessage(),e); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -3,8 +3,10 @@ package com.iformall.mapper; | |||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import com.iformall.domain.po.WxProjectConfig; | import com.iformall.domain.po.WxProjectConfig; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| public interface WxProjectConfigMapper extends BaseMapper<WxProjectConfig> { | public interface WxProjectConfigMapper extends BaseMapper<WxProjectConfig> { | ||||
| void initAfterGroup(@Param(value = "tenantId")String tenantId, @Param(value = "subTenantIds")String subTenantIds); | |||||
| } | } | ||||
| @@ -40,4 +40,6 @@ public interface WxProjectConfigService { | |||||
| void initSubmall(String parentTenantId, String[] tenantIds); | void initSubmall(String parentTenantId, String[] tenantIds); | ||||
| void initAfterGroup(String tenantId, String tenantIds); | |||||
| } | } | ||||
| @@ -88,12 +88,6 @@ public class MemCouponFromDspServiceImpl implements MemCouponFromDspService { | |||||
| WxCUserBasicInfo user = wxCUserBasicInfoService.findInfoByPhone(record, record.getPhone()); | WxCUserBasicInfo user = wxCUserBasicInfoService.findInfoByPhone(record, record.getPhone()); | ||||
| // // 获取C端用户 | |||||
| // WxCUser user = wxCUserService.getByObject(new WxCUser() {{ | |||||
| // updateTenantInfo(record); | |||||
| // setPhone(record.getPhone()); | |||||
| // }}); | |||||
| if (user == null) { | if (user == null) { | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| @@ -10,6 +10,7 @@ import com.iformall.utils.PasswordHelper; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| @@ -242,10 +243,12 @@ public class WxProjectConfigServiceImpl implements WxProjectConfigService { | |||||
| @Override | @Override | ||||
| public void initSubmall(String parentTenantId, String[] tenantIds) { | public void initSubmall(String parentTenantId, String[] tenantIds) { | ||||
| wxMallService.undateSubmall(parentTenantId,tenantIds); | wxMallService.undateSubmall(parentTenantId,tenantIds); | ||||
| /** | |||||
| * 初始化数据 | |||||
| */ | |||||
| } | |||||
| @Async | |||||
| @Override | |||||
| public void initAfterGroup(String tenantId, String subTenantIds) { | |||||
| wxProjectConfigMapper.initAfterGroup(tenantId,subTenantIds); | |||||
| } | } | ||||
| @@ -49,4 +49,7 @@ public class Constant { | |||||
| // 导入会员 | // 导入会员 | ||||
| public static final String importMemPrev = "importmem:"; | public static final String importMemPrev = "importmem:"; | ||||
| public static final String importInvestCustomerPrev = "importinvestcustomer:"; | public static final String importInvestCustomerPrev = "importinvestcustomer:"; | ||||
| //限制接口访问次数 | |||||
| public static final String INTERFACE_VISIT_LIMIT_KEY = "INTERFACE:LIMIT:"; | |||||
| } | } | ||||
| @@ -2,4 +2,9 @@ | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="com.iformall.mapper.WxProjectConfigMapper"> | <mapper namespace="com.iformall.mapper.WxProjectConfigMapper"> | ||||
| <update id="initAfterGroup" statementType="CALLABLE" > | |||||
| {call init_after_group(#{tenantId},#{subTenantIds})} | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||