| @@ -0,0 +1,62 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.BaseEntity; | |||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||||
| import com.iformall.service.WxCouponPasswordService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("couponPassword") | |||||
| @Api(description = "免费卡接口") | |||||
| public class WxCouponPasswordController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCouponPasswordService wxCouponPasswordService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("/list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "列表") | |||||
| public ResultData list(@ModelAttribute WxCouponPassword wxCouponPassword, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::list"); | |||||
| wxCouponPassword.setTenantId(getTenantId()); | |||||
| wxCouponPassword.setSortColumns(BaseEntity.SortField.CreateDate_DESC, BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<WxCouponPassword> page = wxCouponPasswordService.listAsPage(wxCouponPassword, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("可发送卡数据") | |||||
| @GetMapping("/findCouponList") | |||||
| @SystemControllerLog(description = "可发送卡数据") | |||||
| public ResultData findCouponList() { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::findCouponList"); | |||||
| List<WxCouponPasswordCountInfoVO> voList = wxCouponPasswordService.findCouponList(getTenantId()); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", voList); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,54 @@ | |||||
| package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.BaseEntity; | |||||
| import com.iformall.domain.po.WxCouponPresent; | |||||
| import com.iformall.service.WxCouponPresentService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("couponPrsent") | |||||
| @Api(description = "卡投放接口") | |||||
| public class WxCouponPresentController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxCouponPresentService wxCouponPresentService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("/list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| @SystemControllerLog(description = "列表") | |||||
| public ResultData list(@ModelAttribute WxCouponPresent wxCouponPresent, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPresentController::list"); | |||||
| wxCouponPresent.setTenantId(getTenantId()); | |||||
| wxCouponPresent.setSortColumns(BaseEntity.SortField.CreateTime_DESC, BaseEntity.SortField.Id_DESC); | |||||
| final PageInfo<WxCouponPresent> page = wxCouponPresentService.listAsPage(wxCouponPresent, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "查询") | |||||
| public ResultData findById(@RequestParam Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponPresentController::findById"); | |||||
| return new ResultData(wxCouponPresentService.findById(id)); | |||||
| } | |||||
| } | |||||
| @@ -3,11 +3,11 @@ package com.iformall.domain.po; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import javax.persistence.Id; | |||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | import javax.persistence.Transient; | ||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| import javax.persistence.Id; | |||||
| @Table(name = "wx_coupon_password") | @Table(name = "wx_coupon_password") | ||||
| @Data | @Data | ||||
| @@ -41,5 +41,7 @@ public class WxCouponPassword extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="过期时间",name="expireDate") | @io.swagger.annotations.ApiModelProperty(value="过期时间",name="expireDate") | ||||
| private Date expireDate; | private Date expireDate; | ||||
| @Transient | |||||
| private String statusStr; | |||||
| } | } | ||||
| @@ -0,0 +1,46 @@ | |||||
| package com.iformall.domain.po; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import javax.persistence.Id; | |||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Table(name = "wx_coupon_present") | |||||
| @Data | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxCouponPresent extends BaseEntity { | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | |||||
| private String tenantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "userId") | |||||
| private Long userId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "卡券ID", name = "couponId") | |||||
| private Long couponId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "卡券名称", name = "couponName") | |||||
| private String couponName; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "手机", name = "phones") | |||||
| private String phones; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | |||||
| private Date createTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | |||||
| private Date updateTime; | |||||
| @Transient | |||||
| protected Date sendTimeStart; | |||||
| @Transient | |||||
| protected Date sendTimeEnd; | |||||
| } | |||||
| @@ -0,0 +1,14 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import lombok.Data; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Data | |||||
| public class WxCouponPasswordCountInfoVO { | |||||
| private Long couponId; | |||||
| private String couponName; | |||||
| private Long couponCount; | |||||
| } | |||||
| @@ -1,8 +1,10 @@ | |||||
| package com.iformall.mapper; | package com.iformall.mapper; | ||||
| import java.util.*; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxCouponPassword; | import com.iformall.domain.po.WxCouponPassword; | ||||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||||
| import java.util.List; | |||||
| public interface WxCouponPasswordMapper extends CommonMapper<WxCouponPassword, Long> { | public interface WxCouponPasswordMapper extends CommonMapper<WxCouponPassword, Long> { | ||||
| @@ -11,7 +13,7 @@ public interface WxCouponPasswordMapper extends CommonMapper<WxCouponPassword, L | |||||
| void insertCouponPasswds(List<WxCouponPassword> pwdlist); | void insertCouponPasswds(List<WxCouponPassword> pwdlist); | ||||
| int updateStatusByCouponId(Long couponId); | int updateStatusByCouponId(Long couponId); | ||||
| List<WxCouponPassword> findCouponGroupList(WxCouponPassword wxCouponPassword); | List<WxCouponPassword> findCouponGroupList(WxCouponPassword wxCouponPassword); | ||||
| List<WxCouponPasswordCountInfoVO> findCouponCountInfo(WxCouponPassword wxCouponPassword); | |||||
| } | } | ||||
| @@ -0,0 +1,13 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxCouponPassword; | |||||
| import com.iformall.domain.po.WxCouponPresent; | |||||
| import java.util.List; | |||||
| public interface WxCouponPresentMapper extends CommonMapper<WxCouponPresent, Long> { | |||||
| List<WxCouponPresent> findList(WxCouponPresent wxCouponPresent); | |||||
| } | |||||
| @@ -2,6 +2,9 @@ package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.WxCouponPassword; | import com.iformall.domain.po.WxCouponPassword; | ||||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||||
| import java.util.List; | |||||
| public interface WxCouponPasswordService { | public interface WxCouponPasswordService { | ||||
| @@ -44,12 +47,8 @@ public interface WxCouponPasswordService { | |||||
| * @param inventory | * @param inventory | ||||
| */ | */ | ||||
| void mkPasswords(String tenantId, Long couponId, Integer inventory); | void mkPasswords(String tenantId, Long couponId, Integer inventory); | ||||
| List<WxCouponPasswordCountInfoVO> findCouponList(String tenantId); | |||||
| } | } | ||||
| @@ -0,0 +1,15 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxCouponPresent; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| public interface WxCouponPresentService { | |||||
| PageInfo<WxCouponPresent> listAsPage(WxCouponPresent wxCouponPresent, Integer pageNum, Integer pageSize); | |||||
| WxCouponPresent findById(Long id); | |||||
| } | |||||
| @@ -2,13 +2,14 @@ package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxCouponPassword; | import com.iformall.domain.po.WxCouponPassword; | ||||
| import com.iformall.enums.EnumCouponPasswordStatus; | import com.iformall.enums.EnumCouponPasswordStatus; | ||||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | |||||
| import com.iformall.mapper.WxCouponPasswordMapper; | import com.iformall.mapper.WxCouponPasswordMapper; | ||||
| import com.iformall.service.WxCouponPasswordService; | import com.iformall.service.WxCouponPasswordService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.iformall.common.IdWorker; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| @@ -49,6 +50,13 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService { | |||||
| wxCouponPasswordMapper.deleteByPrimaryKey(id); | wxCouponPasswordMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| @Override | |||||
| public List<WxCouponPasswordCountInfoVO> findCouponList(String tenantId) { | |||||
| WxCouponPassword wxCouponPassword = new WxCouponPassword(); | |||||
| wxCouponPassword.setTenantId(tenantId); | |||||
| return wxCouponPasswordMapper.findCouponCountInfo(wxCouponPassword); | |||||
| } | |||||
| @Override | @Override | ||||
| public void mkPasswords(String tenantId, Long couponId, Integer inventory) { | public void mkPasswords(String tenantId, Long couponId, Integer inventory) { | ||||
| String strAll = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | String strAll = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||||
| @@ -0,0 +1,31 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxCouponPresent; | |||||
| import com.iformall.mapper.WxCouponPresentMapper; | |||||
| import com.iformall.service.WxCouponPresentService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Service | |||||
| public class WxCouponPresentServiceImpl implements WxCouponPresentService { | |||||
| @Autowired | |||||
| WxCouponPresentMapper wxCouponPresentMapper; | |||||
| @Override | |||||
| public PageInfo<WxCouponPresent> listAsPage(WxCouponPresent record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponPresentMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxCouponPresent findById(Long id) { | |||||
| return wxCouponPresentMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -59,7 +59,12 @@ | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| #{idItem} | #{idItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != statusStr and ''!=statusStr"> | |||||
| and status in (${statusStr}) | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| </sql> | </sql> | ||||
| @@ -93,4 +98,23 @@ | |||||
| </select> | </select> | ||||
| <resultMap id="CouponCountInfoMap" type="com.iformall.domain.vo.WxCouponPasswordCountInfoVO"> | |||||
| <result column="coupon_count" jdbcType="BIGINT" property="couponCount"/> | |||||
| <result column="title" jdbcType="VARCHAR" property="couponName"/> | |||||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId"/> | |||||
| </resultMap> | |||||
| <select id="findCouponCountInfo" parameterType="com.iformall.domain.po.WxCouponPassword" | |||||
| resultMap="CouponCountInfoMap"> | |||||
| select cp.coupon_id,c.title,cp.coupon_count from | |||||
| (select count(*) as coupon_count,coupon_id from wx_coupon_password | |||||
| where tenant_id#{tenantId} and status=0) cp | |||||
| inner join wx_coupon c on cp.coupon_id = c.id | |||||
| where c.tenant_id=#{tenantId} and c.status=1 | |||||
| <if test=" null != couponId "> | |||||
| and cp.`coupon_id` = #{couponId} | |||||
| </if> | |||||
| group by cp.coupon_id | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -0,0 +1,57 @@ | |||||
| <?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"> | |||||
| <mapper namespace="com.iformall.mapper.WxCouponPresentMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponPresent"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId"/> | |||||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId"/> | |||||
| <result column="coupon_name" jdbcType="VARCHAR" property="couponName"/> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`coupon_id`,`coupon_name`,`user_id`,`create_time`,`update_time` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != couponName "> | |||||
| and `coupon_name` like concat('%', #{couponName},'%') | |||||
| </if> | |||||
| <if test=" null != phones "> | |||||
| and `phones` like concat('%', #{phones},'%') | |||||
| </if> | |||||
| <if test=" null != sendTimeStart and null!=sendTimeEnd "> | |||||
| and `create_date` between #{sendTimeStart} and #{sendTimeEnd} | |||||
| </if> | |||||
| <if test=" null != updateTime "> | |||||
| and `update_date` = #{updateTime} | |||||
| </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.WxCouponPresent" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_coupon_present | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| </mapper> | |||||