| @@ -9,6 +9,7 @@ import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.enums.EnumCouponStatus; | import com.iformall.enums.EnumCouponStatus; | ||||
| import com.iformall.enums.EnumMerchantStatus; | |||||
| import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
| import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
| import com.iformall.service.WxMerchantService; | import com.iformall.service.WxMerchantService; | ||||
| @@ -146,9 +147,11 @@ public class WxCouponController extends BaseController { | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | ||||
| public ResultData findById(Long id) { | public ResultData findById(Long id) { | ||||
| WxCoupon c = wxCouponService.getById(id); | WxCoupon c = wxCouponService.getById(id); | ||||
| WxMerchant merchant = wxMerchantService.getById(c.getMerchantId()); | |||||
| if(merchant.getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) | |||||
| return new ResultData(Result.ERROR, "此券的商户已禁用"); | |||||
| WxCounponDto dto = new WxCounponDto(); | WxCounponDto dto = new WxCounponDto(); | ||||
| org.springframework.beans.BeanUtils.copyProperties(c, dto); | org.springframework.beans.BeanUtils.copyProperties(c, dto); | ||||
| WxMerchant merchant = wxMerchantService.getById(c.getMerchantId()); | |||||
| dto.setWxMerchant(merchant); | dto.setWxMerchant(merchant); | ||||
| return new ResultData(Result.SUCCESS, "查询成功", dto); | return new ResultData(Result.SUCCESS, "查询成功", dto); | ||||
| } | } | ||||
| @@ -52,14 +52,18 @@ public class WxLevelConfigController extends BaseController { | |||||
| String[] points = dto.getPoints().split("&"); | String[] points = dto.getPoints().split("&"); | ||||
| String[] level = dto.getLevel().split("&"); | String[] level = dto.getLevel().split("&"); | ||||
| String[] descs =dto.getDescription().split("&"); | String[] descs =dto.getDescription().split("&"); | ||||
| if (points.length != level.length) { | |||||
| return new ResultData(Result.ERROR, "请同时设置成长值和等级"); | |||||
| } | |||||
| String tenantId = getTenantId(); | String tenantId = getTenantId(); | ||||
| wxLevelConfigService.deleteAll(); | |||||
| wxLevelConfigService.deleteAll(tenantId); | |||||
| for(int i=0;i<points.length;i++) { | for(int i=0;i<points.length;i++) { | ||||
| WxLevelConfig wxLevelConfig = new WxLevelConfig(); | WxLevelConfig wxLevelConfig = new WxLevelConfig(); | ||||
| wxLevelConfig.setTenantId(tenantId); | wxLevelConfig.setTenantId(tenantId); | ||||
| wxLevelConfig.setPoints(Integer.parseInt(points[i])); | wxLevelConfig.setPoints(Integer.parseInt(points[i])); | ||||
| wxLevelConfig.setLevel(level[i]); | wxLevelConfig.setLevel(level[i]); | ||||
| wxLevelConfig.setDescription(descs[i]); | |||||
| if (descs.length > 0 && i < descs.length) | |||||
| wxLevelConfig.setDescription(descs[i]); | |||||
| wxLevelConfigService.saveOrUpdate(wxLevelConfig); | wxLevelConfigService.saveOrUpdate(wxLevelConfig); | ||||
| } | } | ||||
| return new ResultData(); | return new ResultData(); | ||||
| @@ -109,6 +109,10 @@ public class WxCUserBasicInfo implements Serializable { | |||||
| private String tagNames; | private String tagNames; | ||||
| @Transient | @Transient | ||||
| private long count; | private long count; | ||||
| @Transient | |||||
| private Date startTime; | |||||
| @Transient | |||||
| private Date endTime; | |||||
| public String getLevel() { | public String getLevel() { | ||||
| return level; | return level; | ||||
| @@ -225,7 +229,21 @@ public class WxCUserBasicInfo implements Serializable { | |||||
| name = _name; | name = _name; | ||||
| } | } | ||||
| public Date getStartTime() { | |||||
| return startTime; | |||||
| } | |||||
| public void setStartTime(Date startTime) { | |||||
| this.startTime = startTime; | |||||
| } | |||||
| public Date getEndTime() { | |||||
| return endTime; | |||||
| } | |||||
| public void setEndTime(Date endTime) { | |||||
| this.endTime = endTime; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| @@ -10,7 +10,7 @@ public interface WxLevelConfigMapper extends CommonMapper<WxLevelConfig, Long> { | |||||
| List<WxLevelConfig> findList(WxLevelConfig wxLevelConfig); | List<WxLevelConfig> findList(WxLevelConfig wxLevelConfig); | ||||
| void deleteAll(); | |||||
| void deleteAll(@Param("tenantId")String tenantId); | |||||
| String getLevel(@Param("tenantId")String tenantId,@Param("poins")Integer poins); | String getLevel(@Param("tenantId")String tenantId,@Param("poins")Integer poins); | ||||
| @@ -47,7 +47,7 @@ public interface WxLevelConfigService { | |||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| void deleteAll(); | |||||
| void deleteAll(String tenantId); | |||||
| /** | /** | ||||
| * 根据积分获取会员等级 | * 根据积分获取会员等级 | ||||
| * @param tenantId | * @param tenantId | ||||
| @@ -57,8 +57,8 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void deleteAll() { | |||||
| wxLevelConfigMapper.deleteAll(); | |||||
| public void deleteAll(String tenantId) { | |||||
| wxLevelConfigMapper.deleteAll(tenantId); | |||||
| } | } | ||||
| @@ -78,6 +78,9 @@ | |||||
| <if test=" null != name "> | <if test=" null != name "> | ||||
| and `name` like concat('%', #{name},'%') | and `name` like concat('%', #{name},'%') | ||||
| </if> | </if> | ||||
| <if test=" null != startTime and null!=endTime"> | |||||
| and `create_date` between #{startTime} and #{endTime} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| @@ -1,72 +1,68 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!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.WxLevelConfigMapper"> | <mapper namespace="com.iformall.mapper.WxLevelConfigMapper"> | ||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxLevelConfig"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="points" jdbcType="INTEGER" property="points" /> | |||||
| <result column="level" jdbcType="VARCHAR" property="level" /> | |||||
| <result column="description" jdbcType="VARCHAR" property="description" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxLevelConfig"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="points" jdbcType="INTEGER" property="points"/> | |||||
| <result column="level" jdbcType="VARCHAR" property="level"/> | |||||
| <result column="description" jdbcType="VARCHAR" property="description"/> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`points`,`level`,`description`,`create_date`,`tenant_id` | `id`,`points`,`level`,`description`,`create_date`,`tenant_id` | ||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != points "> | |||||
| and `points` = #{points} | |||||
| </if> | |||||
| <if test=" null != level "> | |||||
| and `level` like concat('%', #{level},'%') | |||||
| </if> | |||||
| <if test=" null != description "> | |||||
| and `description` like concat('%', #{description},'%') | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxLevelConfig" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_level_config | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <delete id="deleteAll"> | |||||
| delete from wx_level_config; | |||||
| </delete> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != points "> | |||||
| and `points` = #{points} | |||||
| </if> | |||||
| <if test=" null != level "> | |||||
| and `level` like concat('%', #{level},'%') | |||||
| </if> | |||||
| <if test=" null != description "> | |||||
| and `description` like concat('%', #{description},'%') | |||||
| </if> | |||||
| <select id="getLevel" parameterType="com.iformall.domain.po.WxLevelConfig" resultType="String"> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxLevelConfig" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_level_config | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <delete id="deleteAll" parameterType="com.iformall.domain.po.WxLevelConfig"> | |||||
| delete from wx_level_config where `tenant_id` = #{tenantId}; | |||||
| </delete> | |||||
| <select id="getLevel" parameterType="com.iformall.domain.po.WxLevelConfig" resultType="String"> | |||||
| SELECT `level` FROM `wx_level_config` where tenant_id=#{tenantId} and points <= #{points} ORDER BY points desc LIMIT 1 | SELECT `level` FROM `wx_level_config` where tenant_id=#{tenantId} and points <= #{points} ORDER BY points desc LIMIT 1 | ||||
| </select> | </select> | ||||
| </mapper> | </mapper> | ||||