| @@ -64,6 +64,13 @@ public class WxLegionActivityMerchantConfig extends TenantEntity { | |||
| @TableField(value = "union_id") | |||
| private Long unionId; | |||
| /** | |||
| * 号段 | |||
| */ | |||
| @io.swagger.annotations.ApiModelProperty(value="号段",name="numberRange") | |||
| @TableField(value = "number_range") | |||
| private String numberRange; | |||
| /** | |||
| * 创建时间 | |||
| */ | |||
| @@ -2,14 +2,17 @@ package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.domain.po.WxLegionActivity; | |||
| import com.iformall.domain.po.WxLegionActivityConfig; | |||
| import com.iformall.domain.po.WxLegionActivityMerchantConfig; | |||
| import com.iformall.domain.vo.LegionActivityCount; | |||
| import com.iformall.domain.vo.LegionActivityUserStatistics; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxLegionActivityMerchantConfigMapper; | |||
| import com.iformall.service.WxLegionActivityConfigService; | |||
| import com.iformall.mapper.WxLegionActivityConfigMapper; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @@ -77,6 +80,9 @@ public class WxLegionActivityConfigServiceImpl implements WxLegionActivityConfig | |||
| if(merchantConfig.getUnionId() == null){ | |||
| merchantConfig.setUnionId(0L); | |||
| } | |||
| if(!verifyNumber(merchantConfig.getNumberRange())){ | |||
| throw new MallinkException(Result.ERROR,"vip号段格式错误"); | |||
| } | |||
| merchantConfig.setUpdateDate(now); | |||
| merchantConfigList.add(merchantConfig); | |||
| } | |||
| @@ -91,6 +97,33 @@ public class WxLegionActivityConfigServiceImpl implements WxLegionActivityConfig | |||
| } | |||
| } | |||
| private boolean verifyNumber(String numberRange){ | |||
| if(StringUtils.isBlank(numberRange)){ | |||
| // return false; | |||
| }else{ | |||
| List<Integer> numberList = new ArrayList<>(); | |||
| try { | |||
| for (String s : numberRange.split(",")) { | |||
| if(s.contains("-") && s.split("-").length == 2){ | |||
| for (String string : s.split("-")) { | |||
| numberList.add(Integer.parseInt(string)); | |||
| } | |||
| }else{ | |||
| if(StringUtils.isNotBlank(s)){ | |||
| numberList.add(Integer.parseInt(s)); | |||
| } | |||
| } | |||
| } | |||
| }catch (Exception e){ | |||
| return false; | |||
| } | |||
| if(numberList.isEmpty()){ | |||
| return false; | |||
| } | |||
| } | |||
| return true; | |||
| } | |||
| @Override | |||
| public List<WxLegionActivityConfig> findLegionList(Long activityId, String tenantId) { | |||
| WxLegionActivityConfig configQ = new WxLegionActivityConfig(); | |||
| @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.domain.po.WxLegionActivityMerchantConfig; | |||
| @@ -16,6 +17,7 @@ import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxLegionActivityMerchantConfigMapper; | |||
| import com.iformall.service.WxLegionActivityUserService; | |||
| import com.iformall.mapper.WxLegionActivityUserMapper; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @@ -80,9 +82,13 @@ public class WxLegionActivityUserServiceImpl implements WxLegionActivityUserServ | |||
| if(merchantConfig != null){ | |||
| wxLegionActivityUser.setLegionId(merchantConfig.getLegionId()); | |||
| wxLegionActivityUser.setUnionId(merchantConfig.getUnionId()); | |||
| if(!verifyNumber(wxLegionActivityUser.getVipNum(),merchantConfig.getNumberRange())){ | |||
| throw new MallinkException(Result.ERROR,"vip号段不符合"); | |||
| } | |||
| }else{ | |||
| wxLegionActivityUser.setLegionId(0L); | |||
| wxLegionActivityUser.setUnionId(0L); | |||
| throw new MallinkException(Result.ERROR,"该店铺未参加活动"); | |||
| // wxLegionActivityUser.setLegionId(0L); | |||
| // wxLegionActivityUser.setUnionId(0L); | |||
| } | |||
| Date now = new Date(); | |||
| @@ -100,6 +106,31 @@ public class WxLegionActivityUserServiceImpl implements WxLegionActivityUserServ | |||
| } | |||
| } | |||
| private boolean verifyNumber(String cradNumber, String numberRange) { | |||
| if(StringUtils.isBlank(numberRange)){ | |||
| return true; | |||
| } | |||
| for (String s : numberRange.split(",")) { | |||
| if(s.contains("-") && s.split("-").length == 2){ | |||
| String minNum = s.split("-")[0]; | |||
| String maxNum = s.split("-")[1]; | |||
| try{ | |||
| if(Integer.parseInt(cradNumber) >= Integer.parseInt(minNum) | |||
| && Integer.parseInt(cradNumber) <= Integer.parseInt(maxNum)){ | |||
| return true; | |||
| } | |||
| }catch(Exception e){ | |||
| return false; | |||
| } | |||
| }else{ | |||
| if(cradNumber.equals(s)){ | |||
| return true; | |||
| } | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
| @Override | |||
| public WxLegionActivityUser getById(Long id, String tenantId) { | |||
| return wxLegionActivityUserMapper.selectById(id,tenantId); | |||
| @@ -12,6 +12,7 @@ | |||
| <result property="legionId" column="legion_id" jdbcType="BIGINT"/> | |||
| <result property="merchantId" column="merchant_id" jdbcType="BIGINT"/> | |||
| <result property="unionId" column="union_id" jdbcType="BIGINT"/> | |||
| <result property="numberRange" column="number_range" jdbcType="VARCHAR"/> | |||
| <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/> | |||
| <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/> | |||
| </resultMap> | |||
| @@ -19,7 +20,7 @@ | |||
| <sql id="allColumns"> | |||
| id,tenant_id,parent_tenant_id, | |||
| activity_id,legion_id,merchant_id, | |||
| union_id,create_date,update_date | |||
| union_id,number_range,create_date,update_date | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -74,12 +75,12 @@ | |||
| insert into wx_legion_activity_merchant_config | |||
| (id, | |||
| activity_id,legion_id,merchant_id, | |||
| union_id,create_date,update_date) | |||
| union_id,number_range,create_date,update_date) | |||
| values | |||
| <foreach collection="configList" item="item" index="index" separator=","> | |||
| (#{item.id,jdbcType=BIGINT}, | |||
| #{item.activityId,jdbcType=BIGINT},#{item.legionId,jdbcType=BIGINT},#{item.merchantId,jdbcType=BIGINT}, | |||
| #{item.unionId,jdbcType=BIGINT},#{item.createDate,jdbcType=TIMESTAMP},#{item.updateDate,jdbcType=TIMESTAMP}) | |||
| #{item.unionId,jdbcType=BIGINT},#{item.numberRange,jdbcType=VARCHAR},#{item.createDate,jdbcType=TIMESTAMP},#{item.updateDate,jdbcType=TIMESTAMP}) | |||
| </foreach> | |||
| </insert> | |||