Преглед изворни кода

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

release_toaliyun_real
hupeng пре 7 година
родитељ
комит
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") @io.swagger.annotations.ApiModelProperty(value="修改时间",name="updateDate")
private Date updateDate; private Date updateDate;


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



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


public Integer getStatus() {
return status;
}

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

public static enum Field public static enum Field
{ {
Id_ASC("`id` ASC"),Id_DESC("`id` DESC") 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.WxCouponChannel;
import com.iformall.domain.po.WxCouponMerchant; import com.iformall.domain.po.WxCouponMerchant;
import com.iformall.domain.vo.WxCouponCVo; 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.WxCouponMapper;
import com.iformall.mapper.WxCouponMerchantMapper; import com.iformall.mapper.WxCouponMerchantMapper;
import com.iformall.service.WxCouponChannelService; import com.iformall.service.WxCouponChannelService;
@@ -82,6 +79,7 @@ public class WxCouponServiceImpl implements WxCouponService {
cm.setCouponId(record.getId()); cm.setCouponId(record.getId());
cm.setCreateDate(new Date()); cm.setCreateDate(new Date());
cm.setUpdateDate(new Date()); cm.setUpdateDate(new Date());
cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode());
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
//param.put("",record.get); //param.put("",record.get);
cm.setParameter(param.toString()); cm.setParameter(param.toString());
@@ -97,6 +95,11 @@ public class WxCouponServiceImpl implements WxCouponService {
&& !record.getMerchantIds().isEmpty()) && !record.getMerchantIds().isEmpty())
{ {
String[] ids = StringUtils.split(record.getMerchantIds(),","); 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 -> { Arrays.stream(ids).forEach(id -> {
WxCouponMerchant cm = new WxCouponMerchant(); WxCouponMerchant cm = new WxCouponMerchant();
cm.setMerchantId(Long.valueOf(id)); cm.setMerchantId(Long.valueOf(id));
@@ -105,11 +108,13 @@ public class WxCouponServiceImpl implements WxCouponService {
if (rcm != null) { if (rcm != null) {
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
//param.put("",record.get); //param.put("",record.get);
rcm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode());
rcm.setParameter(param.toString()); rcm.setParameter(param.toString());
rcm.setUpdateDate(new Date()); rcm.setUpdateDate(new Date());
wxCouponMerchantMapper.updateByPrimaryKeySelective(rcm); wxCouponMerchantMapper.updateByPrimaryKeySelective(rcm);
}else { }else {
cm.setId(idWorker.nextId()); cm.setId(idWorker.nextId());
cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode());
cm.setCreateDate(new Date()); cm.setCreateDate(new Date());
cm.setUpdateDate(new Date()); cm.setUpdateDate(new Date());
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
@@ -117,6 +122,15 @@ public class WxCouponServiceImpl implements WxCouponService {
cm.setParameter(param.toString()); cm.setParameter(param.toString());
wxCouponMerchantMapper.insertSelective(cm); 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="parameter" jdbcType="VARCHAR" property="parameter" />
<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" />
<result column="status" jdbcType="INTEGER" property="status" />
</resultMap> </resultMap>
<sql id="allColumns"> <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>


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


</if> </if>


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

</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=")">


Loading…
Откажи
Сачувај