From 079de61c9f1096edce0e74d1c3ab81ee58d3cddc Mon Sep 17 00:00:00 2001 From: masterspirit Date: Sun, 19 Aug 2018 16:34:02 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=B2=BE=E5=87=86=E6=8A=95=E6=94=BE][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9]=E7=B2=BE=E5=87=86=E6=8A=95=E6=94=BE?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/simple/domain/po/CouponInject.java | 118 +++++++----------- .../service/impl/CouponInjectServiceImpl.java | 33 +++-- .../resources/mapper/CouponInjectMapper.xml | 5 +- 3 files changed, 67 insertions(+), 89 deletions(-) diff --git a/mallinkService/src/main/java/com/simple/domain/po/CouponInject.java b/mallinkService/src/main/java/com/simple/domain/po/CouponInject.java index 1410c8c7e..8be6a9ad0 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/CouponInject.java +++ b/mallinkService/src/main/java/com/simple/domain/po/CouponInject.java @@ -1,38 +1,24 @@ package com.simple.domain.po; -import com.simple.domain.vo.WxChooseTagVo; - -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; +import java.util.*; +import java.math.*; import javax.persistence.Transient; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; import java.util.List; +import javax.persistence.Id; +import java.io.Serializable; @Table(name = "coupon_inject") public class CouponInject 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 Long modelId; + protected List ids; @Transient - private WxChooseTagVo wxChooseTagVo; - - public WxChooseTagVo getWxChooseTagVo() { - return wxChooseTagVo; - } - - public void setWxChooseTagVo(WxChooseTagVo wxChooseTagVo) { - this.wxChooseTagVo = wxChooseTagVo; - } + protected String sortColumns; public Long getId() { return id; @@ -41,11 +27,11 @@ public class CouponInject implements Serializable { public void setId(Long id) { this.id = id; } - + public String getSortColumns() { return sortColumns; } - + public List getIds() { return ids; } @@ -53,9 +39,9 @@ public class CouponInject implements Serializable { public void setIds(List ids) { this.ids = ids; } - - - + + + /***/ @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") private String tenantId; @@ -77,32 +63,11 @@ public class CouponInject implements Serializable { /*发送时间**/ @io.swagger.annotations.ApiModelProperty(value="发送时间",name="sendTime") private Date sendTime; - @Transient - private Date sendTimeStart; - @Transient - private Date sendTimeEnd; - - public Date getSendTimeStart() { - return sendTimeStart; - } - - public void setSendTimeStart(Date sendTimeStart) { - this.sendTimeStart = sendTimeStart; - } - - public Date getSendTimeEnd() { - return sendTimeEnd; - } - - public void setSendTimeEnd(Date sendTimeEnd) { - this.sendTimeEnd = sendTimeEnd; - } - /*实际发送数量**/ @io.swagger.annotations.ApiModelProperty(value="实际发送数量",name="sendAmount") private Integer sendAmount; - /*0:待发送1:已发送2:发送失败**/ - @io.swagger.annotations.ApiModelProperty(value="0:待发送1:已发送2:发送失败",name="status") + /*0:待发送1:发送中2:已发送3:发送失败4已作废**/ + @io.swagger.annotations.ApiModelProperty(value="0:待发送1:发送中2:已发送3:发送失败4已作废",name="status") private Integer status; /*发送失败原因**/ @io.swagger.annotations.ApiModelProperty(value="发送失败原因",name="errorMsg") @@ -110,6 +75,9 @@ public class CouponInject implements Serializable { /*发送人群标签**/ @io.swagger.annotations.ApiModelProperty(value="发送人群标签",name="tags") private String tags; + /*短信模板id**/ + @io.swagger.annotations.ApiModelProperty(value="短信模板id",name="modelId") + private Long modelId; /*创建时间**/ @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") private Date createTime; @@ -182,6 +150,12 @@ public class CouponInject implements Serializable { public void setTags(String _tags) { tags = _tags; } + public Long getModelId() { + return modelId; + } + public void setModelId(Long _modelId) { + modelId = _modelId; + } public Date getCreateTime() { return createTime; } @@ -194,33 +168,27 @@ public class CouponInject implements Serializable { public void setUpdateTime(Date _updateTime) { updateTime = _updateTime; } - public Long getModelId() { - return modelId; - } - - public void setModelId(Long modelId) { - this.modelId = modelId; - } public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") - ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") - ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") - ,MUserId_ASC("`mUserId` ASC"),MUserId_DESC("`mUserId` DESC") - ,SendType_ASC("`sendType` ASC"),SendType_DESC("`sendType` DESC") - ,CouponId_ASC("`couponId` ASC"),CouponId_DESC("`couponId` DESC") - ,CouponName_ASC("`couponName` ASC"),CouponName_DESC("`couponName` DESC") - ,SendTime_ASC("`sendTime` ASC"),SendTime_DESC("`sendTime` DESC") - ,SendAmount_ASC("`sendAmount` ASC"),SendAmount_DESC("`sendAmount` DESC") - ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") - ,ErrorMsg_ASC("`errorMsg` ASC"),ErrorMsg_DESC("`errorMsg` DESC") - ,Tags_ASC("`tags` ASC"),Tags_DESC("`tags` DESC") - ,CreateTime_ASC("`createTime` ASC"),CreateTime_DESC("`createTime` DESC") - ,UpdateTime_ASC("`updateTime` ASC"),UpdateTime_DESC("`updateTime` DESC") - ; + ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") + ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") + ,MUserId_ASC("`mUserId` ASC"),MUserId_DESC("`mUserId` DESC") + ,SendType_ASC("`sendType` ASC"),SendType_DESC("`sendType` DESC") + ,CouponId_ASC("`couponId` ASC"),CouponId_DESC("`couponId` DESC") + ,CouponName_ASC("`couponName` ASC"),CouponName_DESC("`couponName` DESC") + ,SendTime_ASC("`sendTime` ASC"),SendTime_DESC("`sendTime` DESC") + ,SendAmount_ASC("`sendAmount` ASC"),SendAmount_DESC("`sendAmount` DESC") + ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") + ,ErrorMsg_ASC("`errorMsg` ASC"),ErrorMsg_DESC("`errorMsg` DESC") + ,Tags_ASC("`tags` ASC"),Tags_DESC("`tags` DESC") + ,ModelId_ASC("`modelId` ASC"),ModelId_DESC("`modelId` DESC") + ,CreateTime_ASC("`createTime` ASC"),CreateTime_DESC("`createTime` DESC") + ,UpdateTime_ASC("`updateTime` ASC"),UpdateTime_DESC("`updateTime` DESC") + ; private String value; Field(String value){ this.value = value; @@ -236,7 +204,7 @@ public class CouponInject implements Serializable { return this.getValue(); } } - + public void setSortColumns(CouponInject.Field... fields) { if (fields == null || fields.length == 0) { @@ -262,7 +230,7 @@ public class CouponInject implements Serializable { } if (sortColumns.contains(",")) { String[] cols = sortColumns.split(","); - List fList = new ArrayList(); + java.util.List fList = new java.util.ArrayList(); for (int k = 0; k < cols.length; k++) { fList.add(Field.valueOf(cols[k])); } diff --git a/mallinkService/src/main/java/com/simple/service/impl/CouponInjectServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/CouponInjectServiceImpl.java index d5767a3b4..cf4482771 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/CouponInjectServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/CouponInjectServiceImpl.java @@ -68,25 +68,36 @@ public class CouponInjectServiceImpl implements CouponInjectService { return; } } - final IdWorker idWorker = new IdWorker(0, 0); - record.setId(idWorker.nextId()); - record.setStatus(1); - couponInjectMapper.insertSelective(record); - - String[] arys = record.getTags().split(","); List tagids = new ArrayList<>(); for (int i = 0; i < arys.length; i++) { tagids.add(Long.parseLong(arys[i])); } + record.setTags(JSON.toJSONString(arys)); + + final IdWorker idWorker = new IdWorker(0, 0); + record.setId(idWorker.nextId()); + if(record.getSendType()==0){ + record.setStatus(1); + }else{ + record.setStatus(0); + } + + couponInjectMapper.insertSelective(record); + if(record.getSendType()==0) { + sendNow(tagids, wxCoupon); + } + + + } + + private void sendNow(List tagids,WxCoupon wxCoupon){ //查询标签用户 List cUsers = wxCUserTagsService.findUserByTag(tagids); - record.setTags(JSON.toJSONString(arys)); - for (WxCUser tempCUser : cUsers) { WxCouponOrder wxCouponOrder = new WxCouponOrder(); - wxCouponOrder.setCouponId(record.getCouponId()); + wxCouponOrder.setCouponId(wxCoupon.getId()); wxCouponOrder.setCouponOrderStatus(0); wxCouponOrder.setCUserId(tempCUser.getId()); wxCouponOrder.setCouponPrice(0); @@ -99,12 +110,10 @@ public class CouponInjectServiceImpl implements CouponInjectService { } wxCouponOrder.setTenantId(wxCoupon.getTenantId()); wxCouponOrderService.saveOrUpdate(wxCouponOrder); - //短信通知 - } - } + } } diff --git a/mallinkService/src/main/resources/mapper/CouponInjectMapper.xml b/mallinkService/src/main/resources/mapper/CouponInjectMapper.xml index 9ec0efbd8..fb07c5e56 100644 --- a/mallinkService/src/main/resources/mapper/CouponInjectMapper.xml +++ b/mallinkService/src/main/resources/mapper/CouponInjectMapper.xml @@ -14,12 +14,13 @@ + - + - `id`,`tenant_id`,`name`,`m_user_id`,`send_type`,`coupon_id`,`coupon_name`,`send_time`,`send_amount`,`status`,`error_msg`,`tags`,`create_time`,`update_time` + `id`,`tenant_id`,`name`,`m_user_id`,`send_type`,`coupon_id`,`coupon_name`,`send_time`,`send_amount`,`status`,`error_msg`,`tags`,`model_id`,`create_time`,`update_time`