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

b端商户发卷接口

release_toaliyun_real
xhxu 5 лет назад
Родитель
Сommit
07111ed884
5 измененных файлов: 50 добавлений и 23 удалений
  1. +1
    -0
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java
  2. +18
    -4
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java
  3. +2
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java
  4. +6
    -3
      mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml
  5. +23
    -16
      mallinkService/src/main/resources/mapper/WxCouponMapper.xml

+ 1
- 0
mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java Просмотреть файл

@@ -57,6 +57,7 @@ public class WxCouponChannelController extends BaseController {
if (wxCouponChannel.getStatus() != null && wxCouponChannel.getStatus() == -1) {
wxCouponChannel.setStatus(null);
}
wxCouponChannel.setMerchantId(getUser().getMerchantId());
wxCouponChannel.updateTenantInfo(getTenantInfo());
wxCouponChannel.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize);


+ 18
- 4
mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.iformall.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
@@ -7,6 +8,7 @@ import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;
import com.iformall.domain.po.WxCouponPassword;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCouponStatisVo;
import com.iformall.enums.*;
@@ -14,6 +16,7 @@ import com.iformall.mapper.WxCouponChannelMapper;
import com.iformall.service.WxCouponPasswordService;
import com.iformall.service.WxCouponService;
import com.iformall.service.WxFlowService;
import com.iformall.service.WxMerchantService;
import com.iformall.utils.DateUtils;
import com.iformall.utils.RedisLock;
import io.swagger.annotations.Api;
@@ -29,10 +32,7 @@ import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;

@RestController
@RequestMapping("/api/coupon")
@@ -49,6 +49,8 @@ public class WxCouponController extends BaseController {
@Autowired
private WxFlowService wxFlowService;
@Autowired
private WxMerchantService wxMerchantService;
@Autowired
RedisLock redisLock;

@ApiOperation("分页列表接口")
@@ -63,6 +65,7 @@ public class WxCouponController extends BaseController {
if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Bapi.getCode());
}
wxCoupon.setMerchantId(getUser().getMerchantId());
return wxCouponService.list(wxCoupon, pageNum, pageSize); //全列表
}

@@ -98,6 +101,11 @@ public class WxCouponController extends BaseController {
if(null == wxCoupon.getSourceType()){
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Bapi.getCode());
}
List<WxMerchant> merchantList = new ArrayList<>();
WxMerchant wxMerchant = wxMerchantService.getById(getUser().getMerchantId());
merchantList.add(wxMerchant);

wxCoupon.setMerchantParams(JSONObject.toJSONString(merchantList));

ResultData resultData = wxCouponService.saveOrUpdate(wxCoupon);
if (resultData.code != 200) {
@@ -132,6 +140,12 @@ public class WxCouponController extends BaseController {
}
}

List<WxMerchant> merchantList = new ArrayList<>();
WxMerchant wxMerchant = wxMerchantService.getById(getUser().getMerchantId());
merchantList.add(wxMerchant);

wxCoupon.setMerchantParams(JSONObject.toJSONString(merchantList));

WxCoupon coupon = wxCouponService.getById(wxCoupon.getId());
if (null == coupon) {
return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId());


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

@@ -145,6 +145,8 @@ public class WxCoupon extends TenantEntity {

@TableField(exist = false)
private String merchantParams;
@TableField(exist = false)
private Long merchantId;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="投放频道参数,用来过滤",name="targetAd")


+ 6
- 3
mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml Просмотреть файл

@@ -21,7 +21,7 @@
</resultMap>

<sql id="allColumns">
cc.`id`,cc.`tenant_id`,cc.`parent_tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code
distinct cc.`id`,cc.`tenant_id`,cc.`parent_tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code
</sql>

<sql id="dynamicWhereConditions">
@@ -100,9 +100,11 @@
</if>

<if test=" null != sourceType ">
and `source_type` = #{sourceType}
and c.`source_type` = #{sourceType}
</if>
<if test=" null != merchantId ">
and cm.`merchant_id` = #{merchantId}
</if>
<if test=" null != ids ">
and cc.id in
@@ -206,6 +208,7 @@
select <include refid="CouponChannelVoColumns" />
from wx_coupon_channel cc
left join wx_coupon c on cc.coupon_id = c.id
left join wx_coupon_merchant cm on c.id = cm.product_id and cm.status = 0
<include refid="dynamicWhereConditions" />
</select>



+ 23
- 16
mallinkService/src/main/resources/mapper/WxCouponMapper.xml Просмотреть файл

@@ -98,11 +98,12 @@
</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`type`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`,
`valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`,
`remark`,`status`,`create_date`,`update_date`,`business`,`sub_business`,`support_transfer`,`subsidy_num`,`subsidy_type`,
`press_limit_num`, `press_limit_hours`, `auto_refund`,`credit_price`,`credit_refund`,`put_apply_status`,`stock_apply_status`,`cancle_apply_status`,
`conditions`,approval_type,content_type,source_type
distinct c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`type`,c.`cover_img`,c.`cover_picture`,c.`detail_picture`,
c.`title`,c.`sub_title`,c.`sale_price`,c.`use_price`,c.`use_limit_quantity`,c.`send_type`,
c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.`valid_days`,c.`detail`,c.`price`,c.`unit`,c.`remain_inventory`,c.`inventory`,
c.`remark`,c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,c.`support_transfer`,c.`subsidy_num`,c.`subsidy_type`,
c.`press_limit_num`, c.`press_limit_hours`, c.`auto_refund`,c.`credit_price`,c.`credit_refund`,c.`put_apply_status`,c.`stock_apply_status`,c.`cancle_apply_status`,
c.`conditions`,c.approval_type,c.content_type,c.source_type
</sql>

<sql id="statusColumns">
@@ -294,7 +295,7 @@
<select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_coupon
from wx_coupon c
<include refid="dynamicWhereConditions"/>
</select>

@@ -315,7 +316,7 @@


<sql id="dynamicWhereConditionsForCoupon">
where is_del = 0
where c.is_del = 0
<if test=" null != targetAd ">
and 0 = (select count(*) from wx_coupon_channel cc
where c.`id` = cc.coupon_id
@@ -427,7 +428,7 @@
</if>

<if test=" null != subBusiness ">
and `sub_business` = #{subBusiness}
and c.`sub_business` = #{subBusiness}
</if>

<if test=" null != supportTransfer ">
@@ -459,10 +460,10 @@
</if>

<if test=" null != putApplyStatus and putApplyStatus == 2">
and `put_apply_status` = #{putApplyStatus}
and c.`put_apply_status` = #{putApplyStatus}
</if>
<if test=" null != putApplyStatus and putApplyStatus == -1">
and `put_apply_status` != 2
and c.`put_apply_status` != 2
</if>

<if test=" null != stockApplyStatus ">
@@ -477,10 +478,14 @@
and c.`source_type` = #{sourceType}
</if>

<if test=" null != merchantId ">
and cm.`merchant_id` = #{merchantId}
</if>

<!--如果配置了审批模板,需要过滤投放审批状态-->
<if test="0 != filterCanPut or null ==filterCanPut ">
<if test=" null != pressModelId and 0l != pressModelId">
and if(type=8,put_apply_status =2 or c.id in (
and if(c.type=8,c.put_apply_status =2 or c.id in (
select coupon_id from wx_coupon_channel
where status=0
<if test=" null != tenantId and '' != tenantId">
@@ -492,7 +497,7 @@
) ,1=1)
</if>
<if test=" null != groupModelId and 0l != groupModelId">
and if(type=9,put_apply_status =2 or c.id in (
and if(c.type=9,c.put_apply_status =2 or c.id in (
select coupon_id from wx_coupon_channel
where status=0
<if test=" null != tenantId and '' != tenantId">
@@ -504,7 +509,7 @@
),1=1)
</if>
<if test=" null != cardModelId and 0l != cardModelId">
and if(type=100,put_apply_status =2 or c.id in (
and if(c.type=100,c.put_apply_status =2 or c.id in (
select coupon_id from wx_coupon_channel
where status=0
<if test=" null != tenantId and '' != tenantId">
@@ -516,7 +521,7 @@
),1=1)
</if>
<if test=" null != couponModelId and 0l != couponModelId">
and if(type !=8 and type !=9 and type!=100,put_apply_status =2 or c.id in (
and if(c.type !=8 and c.type !=9 and c.type!=100,c.put_apply_status =2 or c.id in (
select coupon_id from wx_coupon_channel
where status=0
<if test=" null != tenantId and '' != tenantId">
@@ -550,6 +555,7 @@
select
<include refid="allColumns"/>
from wx_coupon c
left join wx_coupon_merchant cm on c.id = cm.product_id and cm.status = 0
<include refid="dynamicWhereConditionsForCoupon"/>

<if test="null != limitStart and null != limitEnd">
@@ -559,8 +565,9 @@

<select id="findCouponListCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Integer">
select
count(*)
count(distinct c.id)
from wx_coupon c
left join wx_coupon_merchant cm on c.id = cm.product_id and cm.status = 0
<include refid="dynamicWhereConditionsForCoupon"/>
</select>

@@ -650,7 +657,7 @@
<select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">
select
<include refid="allColumns"/>
from wx_coupon
from wx_coupon c
where id = #{id}
</select>



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