| @@ -48,19 +48,28 @@ public class WxCouponSendController extends BaseController { | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "merchantName", value = "merchantName", dataType = "String", paramType = "query"), | |||
| }) | |||
| @SystemControllerLog(description = "注券-列表") | |||
| public ResultData list(@ModelAttribute WxCouponSend wxCouponSend, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSendController::list"); | |||
| if (null == wxCouponSend) wxCouponSend = new WxCouponSend(); | |||
| wxCouponSend.setTenantId(getTenantId()); | |||
| wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode()); | |||
| Integer valid = EnumCouponSendStatus.VALID.getCode(); | |||
| if (Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), wxCouponSend.getSendType())) { | |||
| if (Objects.nonNull(wxCouponSend.getStatus())) { | |||
| valid = wxCouponSend.getStatus(); | |||
| } else { | |||
| wxCouponSend.setStatus(null); | |||
| } | |||
| } | |||
| wxCouponSend.setStatus(valid); | |||
| wxCouponSend.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| final PageInfo<WxCouponSendVo> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize); | |||
| PageInfo<WxCouponSendVo> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize); | |||
| for (WxCouponSendVo cs:page.getList()) | |||
| cs.setSendCount(wxCouponActionLogService.getCountByChannelId(getTenantId(), cs.getSendType(), cs.getId())); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -110,7 +119,7 @@ public class WxCouponSendController extends BaseController { | |||
| //商户卡库存校验 | |||
| if(Objects.equals(wxCouponSend.getSendType(),EnumCouponSendSendType.MERCHANT.getCode())) { | |||
| JSONObject jo = JSONObject.parseObject(wxCouponSend.getConditions()) ; | |||
| if(Objects.isNull(jo)||!jo.containsKey(WxCouponSend.KEY_LIMIT)) { | |||
| if(Objects.isNull(jo)||!jo.containsKey(WxCouponSend.KEY_MERCHANT_LNVENTORY)) { | |||
| return new ResultData(ErrorCode.COUPON_SEND_LIMIT_VERIFY); | |||
| } | |||
| WxCoupon queryById = new WxCoupon() ; | |||
| @@ -119,7 +128,7 @@ public class WxCouponSendController extends BaseController { | |||
| if(Objects.isNull(wxCouponOfDb)) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| if(jo.getInteger(WxCouponSend.KEY_LIMIT) >wxCouponOfDb.getRemainInventory()) { | |||
| if(jo.getInteger(WxCouponSend.KEY_MERCHANT_LNVENTORY) >wxCouponOfDb.getRemainInventory()) { | |||
| return new ResultData(ErrorCode.REMAIN_IS_EMPTY); | |||
| } | |||
| } | |||
| @@ -10,6 +10,7 @@ import com.iformall.service.WxCouponActionLogService; | |||
| import com.iformall.service.WxCouponSendService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -31,7 +32,11 @@ public class WxCouponSendController extends BaseController { | |||
| @ApiOperation("查询商户卡券列表") | |||
| @GetMapping("/list") | |||
| @ApiImplicitParam(name = "sendType", value = "sendType", dataType = "Long", paramType = "query", required = true) | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "sendType", value = "2:停车发券 3:核销发券 4: B端刷卡发券 5:商户发卷 6:定时发券 7:商户发券", dataType = "int", paramType = "query",required = true), | |||
| }) | |||
| public ResultData list(Integer sendType, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSendController::list"); | |||
| WxCouponSend wxCouponSend = new WxCouponSend(); | |||
| @@ -39,7 +44,7 @@ public class WxCouponSendController extends BaseController { | |||
| wxCouponSend.setTenantId(getTenantId()); | |||
| wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode()); | |||
| //库存大于0 | |||
| wxCouponSend.setInventory(0); | |||
| wxCouponSend.setMerchantLnventory(0); | |||
| wxCouponSend.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| final PageInfo<WxCouponSendVo> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize); | |||
| @@ -191,7 +191,7 @@ public enum ErrorCode{ | |||
| COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE(4006, "卡券使用期还未开始"), | |||
| COUPON_ORDER_IS_LATER_THAN_VALIDDATE(4007, "卡券使用期已结束"), | |||
| COUPON_ORDER_IS_PRE_VERIFY(4008, "卡券已被预核销"), | |||
| COUPON_SEND_LIMIT_VERIFY(4009, "商户卡库存错误"), | |||
| COUPON_SEND_LIMIT_VERIFY(4009, "商户购券数错误"), | |||
| /** | |||
| * 卡 | |||
| @@ -27,10 +27,10 @@ public class WxCouponSend extends BaseEntity { | |||
| @Transient | |||
| public static final String KEY_BEFOREDAYS = "beforeDays" ; | |||
| /** | |||
| * limit 商户券库存 | |||
| * limit 商户购券数 | |||
| */ | |||
| @Transient | |||
| public static final String KEY_LIMIT = "limit" ; | |||
| public static final String KEY_MERCHANT_LNVENTORY = "merchantLnventory" ; | |||
| @Id | |||
| protected Long id; | |||
| @@ -39,10 +39,13 @@ public class WxCouponSend extends BaseEntity { | |||
| protected List<Long> ids; | |||
| /** | |||
| * 库存条件 | |||
| * 商户购券数 | |||
| */ | |||
| @Transient | |||
| protected Integer inventory; | |||
| protected Integer merchantLnventory; | |||
| /**发卷所属商户名**/ | |||
| private String merchantName; | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| @@ -51,7 +54,7 @@ public class WxCouponSend extends BaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="券名称",name="title") | |||
| private String title; | |||
| @io.swagger.annotations.ApiModelProperty(value="发券方式(1.主动领取,2.停车发券,3.核销发券)",name="sendType") | |||
| @io.swagger.annotations.ApiModelProperty(value="2:停车发券 3:核销发券 4: B端刷卡发券 5:商户发卷 6:定时发券 7:商户发券",name="sendType") | |||
| private Integer sendType; | |||
| @io.swagger.annotations.ApiModelProperty(value="发券条件",name="condition") | |||
| private String conditions; | |||
| @@ -5,7 +5,7 @@ package com.iformall.enums; | |||
| */ | |||
| public enum EnumCouponSendSendType { | |||
| // -1: 未知 0:精准发券 1:主动(保留) 2:停车发券 3:核销发券 4: B端刷卡发券 5:商户发卷 | |||
| // -1: 未知 0:精准发券 1:主动(保留) 2:停车发券 3:核销发券 4: B端刷卡发券 5:商户发卷 6:定时发券 7:商户发券 8:会员生日券 | |||
| UNKNOWN(-1, "未知"), | |||
| INJECT(0, "精准发券"), | |||
| ACTIVE(1, "主动(保留)"), | |||
| @@ -8,6 +8,7 @@ import com.iformall.domain.vo.WxCouponSendVo; | |||
| public interface WxCouponSendMapper extends CommonMapper<WxCouponSend, String> { | |||
| List<WxCouponSendVo> findListVo(WxCouponSend wxCouponSend); | |||
| List<WxCouponSendVo> findListVoFilterName(WxCouponSend wxCouponSend); | |||
| void updateStatusByCouponId(WxCouponSend wxCouponSend); | |||
| @@ -64,7 +64,19 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| @Override | |||
| public PageInfo<WxCouponSendVo> listAsPage(WxCouponSend record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findListVo(record)); | |||
| PageInfo<WxCouponSendVo> pageInfo; | |||
| //设置商户购买券数 | |||
| if (Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), record.getSendType())) { | |||
| pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findListVoFilterName(record)); | |||
| for (WxCouponSendVo cs : pageInfo.getList()) { | |||
| JSONObject jo = JSONObject.parseObject(cs.getConditions()); | |||
| int inventory = jo.getInteger(WxCouponSend.KEY_MERCHANT_LNVENTORY); | |||
| cs.setInventory(inventory); | |||
| } | |||
| } else { | |||
| pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findListVo(record)); | |||
| } | |||
| return pageInfo; | |||
| } | |||
| @Override | |||
| @@ -87,8 +87,8 @@ | |||
| and cs.send_sms = #{sendSms} | |||
| </if> | |||
| <if test=" null != inventory "> | |||
| and c.remain_inventory > #{inventory} | |||
| <if test=" null != merchantLnventory "> | |||
| and c.remain_inventory > #{merchantLnventory} | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| @@ -98,6 +98,16 @@ | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findListVoFilterName" parameterType="com.iformall.domain.vo.WxCouponSendVo" resultMap="BaseResultMap"> | |||
| select tt.* from (select | |||
| <include refid="allColumns"/> | |||
| from wx_coupon_send cs left join wx_coupon c on c.id = cs.coupon_id | |||
| <include refid="dynamicWhereConditions"/>) as tt | |||
| <if test=" null != merchantName "> | |||
| where tt.merchant_name like concat('%', #{merchantName},'%') | |||
| </if> | |||
| </select> | |||
| <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel"> | |||
| update wx_coupon_send set status=#{status} | |||
| where coupon_id=#{couponId} | |||