| @@ -17,8 +17,7 @@ import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxCouponChannel") | @RequestMapping("wxCouponChannel") | ||||
| @@ -81,7 +80,6 @@ public class WxCouponChannelController extends BaseController | |||||
| public ResultData findById(@RequestBody WxCouponChannelDto wxCouponChannelDto) { | public ResultData findById(@RequestBody WxCouponChannelDto wxCouponChannelDto) { | ||||
| String[] ids = wxCouponChannelDto.getCouponIds().split(","); | String[] ids = wxCouponChannelDto.getCouponIds().split(","); | ||||
| String[] channelId = wxCouponChannelDto.getChannelId().split(","); | String[] channelId = wxCouponChannelDto.getChannelId().split(","); | ||||
| List<WxCouponChannel> list = new ArrayList<>(); | |||||
| MallUserInfo user = getUser(); | MallUserInfo user = getUser(); | ||||
| wxCouponChannelService.addBatch(ids,channelId,user.getTenantId()); | wxCouponChannelService.addBatch(ids,channelId,user.getTenantId()); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| @@ -1,5 +1,7 @@ | |||||
| package com.simple.controller; | package com.simple.controller; | ||||
| import com.simple.domain.po.WxCoupon; | |||||
| import com.simple.service.WxCouponService; | |||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.util.Assert; | import org.springframework.util.Assert; | ||||
| @@ -15,12 +17,17 @@ import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxCouponSend") | @RequestMapping("wxCouponSend") | ||||
| public class WxCouponSendController extends BaseController | public class WxCouponSendController extends BaseController | ||||
| { | { | ||||
| @Autowired | @Autowired | ||||
| private WxCouponSendService wxCouponSendService; | private WxCouponSendService wxCouponSendService; | ||||
| @Autowired | |||||
| private WxCouponService wxCouponService; | |||||
| private Logger logger = Logger.getLogger(WxCouponSendController.class); | private Logger logger = Logger.getLogger(WxCouponSendController.class); | ||||
| @@ -38,6 +45,20 @@ public class WxCouponSendController extends BaseController | |||||
| @ApiOperation("新增接口") | @ApiOperation("新增接口") | ||||
| @PostMapping("add") | @PostMapping("add") | ||||
| public ResultData add(@RequestBody WxCouponSend wxCouponSend) { | public ResultData add(@RequestBody WxCouponSend wxCouponSend) { | ||||
| List<WxCouponSend> wxCouponSendList = wxCouponSendService.listAsPage(wxCouponSend,1,1).getList(); | |||||
| if(wxCouponSendList!=null&&!wxCouponSendList.isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"已经添加过该券"); | |||||
| } | |||||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId()); | |||||
| if(wxCoupon.getSendEndDate().after(new Date())){ | |||||
| return new ResultData(Result.ERROR,"发放日期异常"); | |||||
| } | |||||
| wxCouponSend.setMerchantId(wxCoupon.getMerchantId()); | |||||
| wxCouponSend.setTenantId(wxCoupon.getTenantId()); | |||||
| wxCouponSend.setTitle(wxCoupon.getTitle()); | |||||
| wxCouponSend.setSendStartTime(wxCoupon.getSendStartDate()); | |||||
| wxCouponSend.setSendEndTime(wxCoupon.getSendEndDate()); | |||||
| //Assert.notNull(wxCouponSend.getName(), "角色名不能为空"); | //Assert.notNull(wxCouponSend.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxCouponSendService.saveOrUpdate(wxCouponSend); | wxCouponSendService.saveOrUpdate(wxCouponSend); | ||||
| @@ -11,15 +11,15 @@ import java.io.Serializable; | |||||
| @Table(name = "wx_coupon_send") | @Table(name = "wx_coupon_send") | ||||
| public class WxCouponSend implements Serializable { | public class WxCouponSend implements Serializable { | ||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| @Id | @Id | ||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<String> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| public Long getId() { | public Long getId() { | ||||
| return id; | return id; | ||||
| } | } | ||||
| @@ -27,20 +27,21 @@ public class WxCouponSend implements Serializable { | |||||
| public void setId(Long id) { | public void setId(Long id) { | ||||
| this.id = id; | this.id = id; | ||||
| } | } | ||||
| public String getSortColumns() { | public String getSortColumns() { | ||||
| return sortColumns; | return sortColumns; | ||||
| } | } | ||||
| public List<String> getIds() { | |||||
| public List<Long> getIds() { | |||||
| return ids; | return ids; | ||||
| } | } | ||||
| public void setIds(List<String> ids) { | |||||
| public void setIds(List<Long> ids) { | |||||
| this.ids = ids; | this.ids = ids; | ||||
| } | } | ||||
| /*租户ID**/ | /*租户ID**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | ||||
| private String tenantId; | private String tenantId; | ||||
| @@ -59,6 +60,15 @@ public class WxCouponSend implements Serializable { | |||||
| /*发券方式(1.主动领取,2.停车发券,3.核销发券)**/ | /*发券方式(1.主动领取,2.停车发券,3.核销发券)**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="发券方式(1.主动领取,2.停车发券,3.核销发券)",name="sendType") | @io.swagger.annotations.ApiModelProperty(value="发券方式(1.主动领取,2.停车发券,3.核销发券)",name="sendType") | ||||
| private Integer sendType; | private Integer sendType; | ||||
| /*0:有效 1:无效**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="0:有效 1:无效",name="status") | |||||
| private Integer status; | |||||
| /***/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="sendStartTime") | |||||
| private Date sendStartTime; | |||||
| /***/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="sendEndTime") | |||||
| private Date sendEndTime; | |||||
| /*创建时间**/ | /*创建时间**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | ||||
| private Date createDate; | private Date createDate; | ||||
| @@ -101,6 +111,24 @@ public class WxCouponSend implements Serializable { | |||||
| public void setSendType(Integer _sendType) { | public void setSendType(Integer _sendType) { | ||||
| sendType = _sendType; | sendType = _sendType; | ||||
| } | } | ||||
| public Integer getStatus() { | |||||
| return status; | |||||
| } | |||||
| public void setStatus(Integer _status) { | |||||
| status = _status; | |||||
| } | |||||
| public Date getSendStartTime() { | |||||
| return sendStartTime; | |||||
| } | |||||
| public void setSendStartTime(Date _sendStartTime) { | |||||
| sendStartTime = _sendStartTime; | |||||
| } | |||||
| public Date getSendEndTime() { | |||||
| return sendEndTime; | |||||
| } | |||||
| public void setSendEndTime(Date _sendEndTime) { | |||||
| sendEndTime = _sendEndTime; | |||||
| } | |||||
| public Date getCreateDate() { | public Date getCreateDate() { | ||||
| return createDate; | return createDate; | ||||
| } | } | ||||
| @@ -119,15 +147,18 @@ public class WxCouponSend implements Serializable { | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||||
| ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") | |||||
| ,CouponId_ASC("`couponId` ASC"),CouponId_DESC("`couponId` DESC") | |||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||||
| ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") | |||||
| ,SendType_ASC("`sendType` ASC"),SendType_DESC("`sendType` DESC") | |||||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | |||||
| ; | |||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||||
| ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") | |||||
| ,CouponId_ASC("`couponId` ASC"),CouponId_DESC("`couponId` DESC") | |||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||||
| ,Title_ASC("`title` ASC"),Title_DESC("`title` DESC") | |||||
| ,SendType_ASC("`sendType` ASC"),SendType_DESC("`sendType` DESC") | |||||
| ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | |||||
| ,SendStartTime_ASC("`sendStartTime` ASC"),SendStartTime_DESC("`sendStartTime` DESC") | |||||
| ,SendEndTime_ASC("`sendEndTime` ASC"),SendEndTime_DESC("`sendEndTime` DESC") | |||||
| ,CreateDate_ASC("`createDate` ASC"),CreateDate_DESC("`createDate` DESC") | |||||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | |||||
| ; | |||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| this.value = value; | this.value = value; | ||||
| @@ -143,7 +174,7 @@ public class WxCouponSend implements Serializable { | |||||
| return this.getValue(); | return this.getValue(); | ||||
| } | } | ||||
| } | } | ||||
| public void setSortColumns(WxCouponSend.Field... fields) | public void setSortColumns(WxCouponSend.Field... fields) | ||||
| { | { | ||||
| if (fields == null || fields.length == 0) { | if (fields == null || fields.length == 0) { | ||||
| @@ -159,9 +190,9 @@ public class WxCouponSend implements Serializable { | |||||
| sb.append(","); | sb.append(","); | ||||
| sb.append(fields[k].toString()); | sb.append(fields[k].toString()); | ||||
| } | } | ||||
| } | } | ||||
| public void setSortColumns(String sortColumns) | public void setSortColumns(String sortColumns) | ||||
| { | { | ||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | if (sortColumns == null || "".equals(sortColumns.trim())) { | ||||
| @@ -9,78 +9,100 @@ | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | <result column="type" jdbcType="INTEGER" property="type" /> | ||||
| <result column="title" jdbcType="VARCHAR" property="title" /> | <result column="title" jdbcType="VARCHAR" property="title" /> | ||||
| <result column="send_type" jdbcType="INTEGER" property="sendType" /> | <result column="send_type" jdbcType="INTEGER" property="sendType" /> | ||||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||||
| <result column="send_start_time" jdbcType="TIMESTAMP" property="sendStartTime" /> | |||||
| <result column="send_end_time" jdbcType="TIMESTAMP" property="sendEndTime" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | ||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | ||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`merchant_id`,`coupon_id`,`type`,`title`,`send_type`,`create_date`,`update_date` | |||||
| `id`,`tenant_id`,`merchant_id`,`coupon_id`,`type`,`title`,`send_type`,`status`,`send_start_time`,`send_end_time`,`create_date`,`update_date` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||||
| </if> | |||||
| <if test=" null != merchantId "> | |||||
| and `merchant_id` = #{merchantId} | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != title "> | |||||
| and `title` like concat('%', #{title},'%') | |||||
| </if> | |||||
| <if test=" null != sendType "> | |||||
| and `send_type` = #{sendType} | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </if> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||||
| </if> | |||||
| <if test=" null != merchantId "> | |||||
| and `merchant_id` = #{merchantId} | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != title "> | |||||
| and `title` like concat('%', #{title},'%') | |||||
| </if> | |||||
| <if test=" null != sendType "> | |||||
| and `send_type` = #{sendType} | |||||
| </if> | |||||
| <if test=" null != status "> | |||||
| and `status` = #{status} | |||||
| </if> | |||||
| <if test=" null != sendStartTime "> | |||||
| and `send_start_time` = #{sendStartTime} | |||||
| </if> | |||||
| <if test=" null != sendEndTime "> | |||||
| and `send_end_time` = #{sendEndTime} | |||||
| </if> | |||||
| <if test=" null != status and status==1"> | |||||
| and `send_end_time` >= NOW() | |||||
| and `send_start_time` <= NOW() | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </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=")"> | ||||
| #{idItem} | |||||
| #{idItem} | |||||
| </foreach> | </foreach> | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| </sql> | </sql> | ||||
| <select id="findList" parameterType="com.simple.domain.po.WxCouponSend" resultMap="BaseResultMap"> | <select id="findList" parameterType="com.simple.domain.po.WxCouponSend" resultMap="BaseResultMap"> | ||||
| select <include refid="allColumns" /> from wx_coupon_send | select <include refid="allColumns" /> from wx_coupon_send | ||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| </mapper> | </mapper> | ||||