Просмотр исходного кода

[A端][需求]:1000072,多商户通用券

release_toaliyun_real
hupeng 7 лет назад
Родитель
Сommit
7b36d518e2
4 измененных файлов: 76 добавлений и 5 удалений
  1. +14
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxCouponMerchant.java
  2. +37
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumCouponMerchantStatus.java
  3. +18
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java
  4. +7
    -1
      mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml

+ 14
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxCouponMerchant.java Просмотреть файл

@@ -57,6 +57,12 @@ public class WxCouponMerchant implements Serializable {
@io.swagger.annotations.ApiModelProperty(value="修改时间",name="updateDate")
private Date updateDate;

/*状态,0 有效 1 无效**/
@io.swagger.annotations.ApiModelProperty(value="修改时间",name="updateDate")
private Integer status;



public Long getCouponId() {
return couponId;
}
@@ -97,6 +103,14 @@ public class WxCouponMerchant implements Serializable {
this.updateDate = updateDate;
}

public Integer getStatus() {
return status;
}

public void setStatus(Integer status) {
this.status = status;
}

public static enum Field
{
Id_ASC("`id` ASC"),Id_DESC("`id` DESC")


+ 37
- 0
mallinkService/src/main/java/com/iformall/enums/EnumCouponMerchantStatus.java Просмотреть файл

@@ -0,0 +1,37 @@
package com.iformall.enums;

/**
* Created by Stormeye on 2018/08/09.
*/
public enum EnumCouponMerchantStatus {

// 0-有效;1-无效;
COUPON_MERCHANT_STATUS_VALID(0, "有效"),
COUPON_MERCHANT_STATUS_INVALID(1, "无效"),
;

public static EnumCouponMerchantStatus getEnum(Integer code) {
for (EnumCouponMerchantStatus value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumCouponMerchantStatus(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

+ 18
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java Просмотреть файл

@@ -12,10 +12,7 @@ import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.WxCouponMerchant;
import com.iformall.domain.vo.WxCouponCVo;
import com.iformall.enums.EnumCouponChannelStatus;
import com.iformall.enums.EnumCouponSendStatus;
import com.iformall.enums.EnumCouponStatus;
import com.iformall.enums.EnumCouponType;
import com.iformall.enums.*;
import com.iformall.mapper.WxCouponMapper;
import com.iformall.mapper.WxCouponMerchantMapper;
import com.iformall.service.WxCouponChannelService;
@@ -82,6 +79,7 @@ public class WxCouponServiceImpl implements WxCouponService {
cm.setCouponId(record.getId());
cm.setCreateDate(new Date());
cm.setUpdateDate(new Date());
cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode());
JSONObject param = new JSONObject();
//param.put("",record.get);
cm.setParameter(param.toString());
@@ -97,6 +95,11 @@ public class WxCouponServiceImpl implements WxCouponService {
&& !record.getMerchantIds().isEmpty())
{
String[] ids = StringUtils.split(record.getMerchantIds(),",");

WxCouponMerchant cmParam = new WxCouponMerchant();
cmParam.setCouponId(record.getId());
List<WxCouponMerchant> oldList = wxCouponMerchantMapper.findList(cmParam);

Arrays.stream(ids).forEach(id -> {
WxCouponMerchant cm = new WxCouponMerchant();
cm.setMerchantId(Long.valueOf(id));
@@ -105,11 +108,13 @@ public class WxCouponServiceImpl implements WxCouponService {
if (rcm != null) {
JSONObject param = new JSONObject();
//param.put("",record.get);
rcm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode());
rcm.setParameter(param.toString());
rcm.setUpdateDate(new Date());
wxCouponMerchantMapper.updateByPrimaryKeySelective(rcm);
}else {
cm.setId(idWorker.nextId());
cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode());
cm.setCreateDate(new Date());
cm.setUpdateDate(new Date());
JSONObject param = new JSONObject();
@@ -117,6 +122,15 @@ public class WxCouponServiceImpl implements WxCouponService {
cm.setParameter(param.toString());
wxCouponMerchantMapper.insertSelective(cm);
}
oldList.removeIf(
old->old.getCouponId().equals(record.getId()) &&
old.getMerchantId().equals(Long.valueOf(id)));
});

oldList.stream().forEach(old->{
old.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_INVALID.getCode());
old.setUpdateDate(new Date());
wxCouponMerchantMapper.updateByPrimaryKeySelective(old);
});
}
}


+ 7
- 1
mallinkService/src/main/resources/mapper/WxCouponMerchantMapper.xml Просмотреть файл

@@ -8,10 +8,11 @@
<result column="parameter" jdbcType="VARCHAR" property="parameter" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
<result column="status" jdbcType="INTEGER" property="status" />
</resultMap>
<sql id="allColumns">
`id`,`coupon_id`,`merchant_id`,`parameter`,`create_date`,`update_date`
`id`,`coupon_id`,`merchant_id`,`parameter`,`create_date`,`update_date`,`status`
</sql>

<sql id="dynamicWhereConditions">
@@ -42,6 +43,11 @@

</if>

<if test=" null != status ">
and `status` = #{status}

</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">


Загрузка…
Отмена
Сохранить