From 07111ed884b775467752529e2ec62acf4e342a1d Mon Sep 17 00:00:00 2001 From: xhxu Date: Tue, 8 Sep 2020 11:11:23 +0800 Subject: [PATCH] =?UTF-8?q?b=E7=AB=AF=E5=95=86=E6=88=B7=E5=8F=91=E5=8D=B7?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCouponChannelController.java | 1 + .../controller/WxCouponController.java | 22 +++++++++-- .../java/com/iformall/domain/po/WxCoupon.java | 2 + .../mapper/WxCouponChannelMapper.xml | 9 +++-- .../main/resources/mapper/WxCouponMapper.xml | 39 +++++++++++-------- 5 files changed, 50 insertions(+), 23 deletions(-) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java index 16b5b73f4..20419f2c2 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java +++ b/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 page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize); diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java index 9fb169707..e47b9246e 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/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 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 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()); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java index 28b2a9e49..0de8dcb4a 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java +++ b/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") diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index f914a55a7..76bc45b5a 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -21,7 +21,7 @@ - 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 @@ -100,9 +100,11 @@ - and `source_type` = #{sourceType} + and c.`source_type` = #{sourceType} + + + and cm.`merchant_id` = #{merchantId} - and cc.id in @@ -206,6 +208,7 @@ select 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 diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index c0e19ca55..fa5414c59 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -98,11 +98,12 @@ - `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 @@ -294,7 +295,7 @@ @@ -315,7 +316,7 @@ - where is_del = 0 + where c.is_del = 0 and 0 = (select count(*) from wx_coupon_channel cc where c.`id` = cc.coupon_id @@ -427,7 +428,7 @@ - and `sub_business` = #{subBusiness} + and c.`sub_business` = #{subBusiness} @@ -459,10 +460,10 @@ - and `put_apply_status` = #{putApplyStatus} + and c.`put_apply_status` = #{putApplyStatus} - and `put_apply_status` != 2 + and c.`put_apply_status` != 2 @@ -477,10 +478,14 @@ and c.`source_type` = #{sourceType} + + and cm.`merchant_id` = #{merchantId} + + - 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 @@ -492,7 +497,7 @@ ) ,1=1) - 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 @@ -504,7 +509,7 @@ ),1=1) - 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 @@ -516,7 +521,7 @@ ),1=1) - 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 @@ -550,6 +555,7 @@ select from wx_coupon c + left join wx_coupon_merchant cm on c.id = cm.product_id and cm.status = 0 @@ -559,8 +565,9 @@ @@ -650,7 +657,7 @@