| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -29,15 +30,35 @@ public class WxCouponSend extends BaseEntity { | |||||
| /** | /** | ||||
| * limit 商户购券数 | * limit 商户购券数 | ||||
| */ | */ | ||||
| @JsonIgnore | |||||
| @Transient | @Transient | ||||
| public static final String KEY_MERCHANT_LNVENTORY = "merchantLnventory" ; | public static final String KEY_MERCHANT_LNVENTORY = "merchantLnventory" ; | ||||
| /** | /** | ||||
| * limit 商户注券数 | * limit 商户注券数 | ||||
| */ | */ | ||||
| @JsonIgnore | |||||
| @Transient | @Transient | ||||
| public static final String KEY_MERCHANT_SEND = "merchantSend" ; | public static final String KEY_MERCHANT_SEND = "merchantSend" ; | ||||
| /** | |||||
| * 排序-商户购券数 | |||||
| */ | |||||
| @JsonIgnore | |||||
| public static final String SORT_MERCHANT_LNVENTORY = "merchantLnventory" ; | |||||
| /** | |||||
| * 排序-商户已发数 | |||||
| */ | |||||
| @JsonIgnore | |||||
| public static final String SORT_MERCHANT_SEND = "merchantSend" ; | |||||
| /** | |||||
| * 排序-商户剩余数 | |||||
| */ | |||||
| @JsonIgnore | |||||
| public static final String SORT_REMAIN = "merchantRemain" ; | |||||
| @Id | @Id | ||||
| protected Long id; | protected Long id; | ||||
| @@ -50,6 +71,18 @@ public class WxCouponSend extends BaseEntity { | |||||
| @Transient | @Transient | ||||
| protected Integer merchantLnventory; | protected Integer merchantLnventory; | ||||
| /** | |||||
| * 商户已发数 | |||||
| */ | |||||
| @Transient | |||||
| protected Integer merchantSend; | |||||
| /** | |||||
| * 商户剩余数 | |||||
| */ | |||||
| @Transient | |||||
| protected Integer merchantRemain; | |||||
| /**发卷所属商户名**/ | /**发卷所属商户名**/ | ||||
| @Transient | @Transient | ||||
| private String merchantName; | private String merchantName; | ||||
| @@ -89,4 +122,9 @@ public class WxCouponSend extends BaseEntity { | |||||
| @Transient | @Transient | ||||
| private Integer expired; | private Integer expired; | ||||
| @JsonIgnore | |||||
| @io.swagger.annotations.ApiModelProperty(value = "0未过期1已过期,全部时不传", name = "expired" ) | |||||
| @Transient | |||||
| private String sortCol ; | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import java.util.*; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxCouponSend; | import com.iformall.domain.po.WxCouponSend; | ||||
| import com.iformall.domain.vo.WxCouponSendVo; | import com.iformall.domain.vo.WxCouponSendVo; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| public interface WxCouponSendMapper extends CommonMapper<WxCouponSend, String> { | public interface WxCouponSendMapper extends CommonMapper<WxCouponSend, String> { | ||||
| @@ -67,15 +67,24 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| @Override | @Override | ||||
| public PageInfo<WxCouponSendVo> listAsPage(WxCouponSend record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCouponSendVo> listAsPage(WxCouponSend record, Integer pageIndex, Integer pageSize) { | ||||
| PageInfo<WxCouponSendVo> pageInfo; | PageInfo<WxCouponSendVo> pageInfo; | ||||
| //设置商户购买券数 | |||||
| /** | |||||
| * 设置商户购买券数 | |||||
| * 前端排序:时间、商户总库存、商户已发数、商户剩余 | |||||
| */ | |||||
| if (Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), record.getSendType())) { | if (Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), record.getSendType())) { | ||||
| String sortStr = null; | |||||
| if (Objects.equals(record.getSortColumn(), WxCouponSend.SORT_MERCHANT_LNVENTORY) || | |||||
| Objects.equals(record.getSortColumn(), WxCouponSend.SORT_MERCHANT_SEND) || | |||||
| Objects.equals(record.getSortColumn(), WxCouponSend.SORT_REMAIN)) { | |||||
| sortStr = record.getSortColumn() + " " + record.getSortOrder(); | |||||
| record.setSortColumn(null); | |||||
| } | |||||
| record.setSortCol(sortStr); | |||||
| pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findListVoByValidType(record)); | pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findListVoByValidType(record)); | ||||
| for (WxCouponSendVo cs : pageInfo.getList()) { | for (WxCouponSendVo cs : pageInfo.getList()) { | ||||
| JSONObject jo = JSONObject.parseObject(cs.getConditions()); | JSONObject jo = JSONObject.parseObject(cs.getConditions()); | ||||
| int inventory = jo.getIntValue(WxCouponSend.KEY_MERCHANT_LNVENTORY); | int inventory = jo.getIntValue(WxCouponSend.KEY_MERCHANT_LNVENTORY); | ||||
| int sendCound = jo.getIntValue(WxCouponSend.KEY_MERCHANT_SEND); | |||||
| cs.setInventory(inventory); | cs.setInventory(inventory); | ||||
| cs.setSendCount(sendCound); | |||||
| } | } | ||||
| } else { | } else { | ||||
| pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findListVo(record)); | pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findListVo(record)); | ||||
| @@ -25,6 +25,9 @@ | |||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| cs.id,cs.tenant_id,cs.coupon_id,cs.title,cs.send_type,cs.conditions,cs.status,cs.create_date,cs.update_date, | cs.id,cs.tenant_id,cs.coupon_id,cs.title,cs.send_type,cs.conditions,cs.status,cs.create_date,cs.update_date, | ||||
| cs.conditions -> '$.merchantSend' as merchantSend, | |||||
| cs.conditions -> '$.merchantLnventory' as merchantLnventory, | |||||
| cs.conditions -> '$.merchantRemain' as merchantRemain, | |||||
| (case when | (case when | ||||
| (select count(*) from wx_coupon_merchant xcm where xcm.product_id = cs.coupon_id and xcm.status = 0)=1 | (select count(*) from wx_coupon_merchant xcm where xcm.product_id = cs.coupon_id and xcm.status = 0)=1 | ||||
| then | then | ||||
| @@ -96,7 +99,9 @@ | |||||
| and cs.send_sms = #{sendSms} | and cs.send_sms = #{sendSms} | ||||
| </if> | </if> | ||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| <if test=" null != sortColumns"> | |||||
| order by ${sortColumns} | |||||
| </if> | |||||
| </sql> | </sql> | ||||
| <select id="findListVo" parameterType="com.iformall.domain.vo.WxCouponSendVo" resultMap="BaseResultMap"> | <select id="findListVo" parameterType="com.iformall.domain.vo.WxCouponSendVo" resultMap="BaseResultMap"> | ||||
| @@ -133,6 +138,9 @@ | |||||
| </otherwise> | </otherwise> | ||||
| </choose> | </choose> | ||||
| ) | ) | ||||
| <if test=" null != sortCol"> | |||||
| order by ${sortCol} | |||||
| </if> | |||||
| </select> | </select> | ||||
| <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel"> | <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel"> | ||||
| update wx_coupon_send set status=#{status} | update wx_coupon_send set status=#{status} | ||||