| @@ -17,8 +17,7 @@ import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxCouponChannel") | |||
| @@ -81,7 +80,6 @@ public class WxCouponChannelController extends BaseController | |||
| public ResultData findById(@RequestBody WxCouponChannelDto wxCouponChannelDto) { | |||
| String[] ids = wxCouponChannelDto.getCouponIds().split(","); | |||
| String[] channelId = wxCouponChannelDto.getChannelId().split(","); | |||
| List<WxCouponChannel> list = new ArrayList<>(); | |||
| MallUserInfo user = getUser(); | |||
| wxCouponChannelService.addBatch(ids,channelId,user.getTenantId()); | |||
| return new ResultData(); | |||
| @@ -1,5 +1,7 @@ | |||
| package com.simple.controller; | |||
| import com.simple.domain.po.WxCoupon; | |||
| import com.simple.service.WxCouponService; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.util.Assert; | |||
| @@ -15,12 +17,17 @@ import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxCouponSend") | |||
| public class WxCouponSendController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxCouponSendService wxCouponSendService; | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| private Logger logger = Logger.getLogger(WxCouponSendController.class); | |||
| @@ -38,6 +45,20 @@ public class WxCouponSendController extends BaseController | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| 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.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCouponSendService.saveOrUpdate(wxCouponSend); | |||
| @@ -11,15 +11,15 @@ import java.io.Serializable; | |||
| @Table(name = "wx_coupon_send") | |||
| public class WxCouponSend implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @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() { | |||
| return id; | |||
| } | |||
| @@ -27,20 +27,21 @@ public class WxCouponSend implements Serializable { | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getSortColumns() { | |||
| return sortColumns; | |||
| } | |||
| public List<String> getIds() { | |||
| public List<Long> getIds() { | |||
| return ids; | |||
| } | |||
| public void setIds(List<String> ids) { | |||
| public void setIds(List<Long> ids) { | |||
| this.ids = ids; | |||
| } | |||
| /*租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| @@ -59,6 +60,15 @@ public class WxCouponSend implements Serializable { | |||
| /*发券方式(1.主动领取,2.停车发券,3.核销发券)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="发券方式(1.主动领取,2.停车发券,3.核销发券)",name="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") | |||
| private Date createDate; | |||
| @@ -101,6 +111,24 @@ public class WxCouponSend implements Serializable { | |||
| public void setSendType(Integer _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() { | |||
| return createDate; | |||
| } | |||
| @@ -119,15 +147,18 @@ public class WxCouponSend implements Serializable { | |||
| public static enum Field | |||
| { | |||
| 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; | |||
| Field(String value){ | |||
| this.value = value; | |||
| @@ -143,7 +174,7 @@ public class WxCouponSend implements Serializable { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(WxCouponSend.Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| @@ -159,9 +190,9 @@ public class WxCouponSend implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| @@ -9,78 +9,100 @@ | |||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <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="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| </resultMap> | |||
| <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 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 "> | |||
| and id in | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.simple.domain.po.WxCouponSend" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_send | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||