From a955c867f6989bce3b1d235d809511126696210c Mon Sep 17 00:00:00 2001 From: masterspirit Date: Thu, 16 Aug 2018 16:09:09 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8D=A1=E5=88=B8=E5=9C=BA=E6=99=AF=E6=8A=95?= =?UTF-8?q?=E6=94=BE][=E4=BF=AE=E6=94=B9]:=E7=94=9F=E6=95=88=20=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCouponChannelController.java | 4 +- .../controller/WxCouponSendController.java | 21 +++ .../com/simple/domain/po/WxCouponSend.java | 85 +++++++---- .../resources/mapper/WxCouponSendMapper.xml | 138 ++++++++++-------- 4 files changed, 160 insertions(+), 88 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java index c02ab3fe0..aca90be61 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java @@ -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 list = new ArrayList<>(); MallUserInfo user = getUser(); wxCouponChannelService.addBatch(ids,channelId,user.getTenantId()); return new ResultData(); diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponSendController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponSendController.java index b43a78ab1..ad4da0932 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponSendController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponSendController.java @@ -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 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); diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCouponSend.java b/mallinkService/src/main/java/com/simple/domain/po/WxCouponSend.java index 730acce5d..21148cf16 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCouponSend.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCouponSend.java @@ -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 ids; - @Transient - protected String sortColumns; - + protected Long id; + + @Transient + protected List 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 getIds() { + + public List getIds() { return ids; } - public void setIds(List ids) { + + public void setIds(List 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())) { diff --git a/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml index 092b603c4..67e4be2a7 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml @@ -9,78 +9,100 @@ + + + - + - `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` - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id` like concat('%', #{tenantId},'%') - - - - - and `merchant_id` = #{merchantId} - - - - - and `coupon_id` = #{couponId} - - - - - and `type` = #{type} - - - - - and `title` like concat('%', #{title},'%') - - - - - and `send_type` = #{sendType} - - - - - and `create_date` = #{createDate} - - - - - and `update_date` = #{updateDate} - - + where 1 = 1 + + + and `id` = #{id} + + + + + and `tenant_id` like concat('%', #{tenantId},'%') + + + + + and `merchant_id` = #{merchantId} + + + + + and `coupon_id` = #{couponId} + + + + + and `type` = #{type} + + + + + and `title` like concat('%', #{title},'%') + + + + + and `send_type` = #{sendType} + + + + + and `status` = #{status} + + + + + and `send_start_time` = #{sendStartTime} + + + + + and `send_end_time` = #{sendEndTime} + + + + and `send_end_time` >= NOW() + and `send_start_time` <= NOW() + + + + and `create_date` = #{createDate} + + + + + and `update_date` = #{updateDate} + + - and id in + and id in - #{idItem} + #{idItem} - + order by ${sortColumns} - + - - - - - - + + + + + +