From 26dd8365f69fde75f5b94f8733b4770d86892247 Mon Sep 17 00:00:00 2001 From: xhxu Date: Tue, 15 Nov 2022 17:43:40 +0800 Subject: [PATCH] //coupon --- .../controller/market/WxCouponController.java | 15 --- .../java/com/iformall/domain/po/WxCoupon.java | 3 + .../iformall/enums/EnumCouponChannelType.java | 97 +++++++++++++++++++ .../com/iformall/enums/EnumCouponType.java | 24 ++++- .../service/impl/WxCouponServiceImpl.java | 79 +++++++++++++-- .../main/resources/mapper/WxCouponMapper.xml | 15 +-- 6 files changed, 196 insertions(+), 37 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java index 8d2d6e84f..4e267c5bd 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -83,21 +83,6 @@ public class WxCouponController extends BaseController { wxCoupon.setSortColumn(null); } - if(wxCoupon.getTargetAd() != null ){ - if(wxCoupon.getTargetAd() == EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode() - || wxCoupon.getTargetAd() == EnumCouponChannelType.COUPON_CHANNEL_ID_GAME.getCode()){ - Integer[] typeArray = { - EnumCouponType.COUPON_MANJIAN.getCode(), - EnumCouponType.COUPON_DAIJIN.getCode(), - EnumCouponType.COUPON_LIPIN.getCode(), - EnumCouponType.COUPON_TINGCHE.getCode(), - EnumCouponType.COUPON_MULTIMCH.getCode(), - EnumCouponType.COUPON_DOUYIN.getCode()}; - - wxCoupon.setTypes(Arrays.asList(typeArray)); - } - } - //isList true 查全部 / 否则 只查询主动领取和定向投放的。 if(!(isList == null?false:isList)){ Integer[] sendTypeArray = { 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 0e380a147..773cdb50c 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java @@ -42,6 +42,9 @@ public class WxCoupon extends TenantEntity { @TableField(exist = false) protected List notinTypes; + @TableField(exist = false) + protected Integer plat; + @TableField(exist = false) protected String channels; diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelType.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelType.java index 34bd5e737..b319b82b2 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelType.java @@ -1,5 +1,11 @@ package com.iformall.enums; +import com.iformall.common.ErrorCode; +import com.iformall.exception.MallinkException; + +import java.util.ArrayList; +import java.util.List; + /** * Created by Stormeye on 2018/08/09. */ @@ -10,9 +16,12 @@ public enum EnumCouponChannelType { * //初次投放,只为展示审核,不让购买。 * //当券投放到其他渠道时,此渠道自动上架,才可购买。 * //其他所有渠道下架后,该渠道自动下架。 + * + * //该渠道不做任何查询 */ COUPON_CHANNEL_ID_DOUYIN(0,"抖音"), + COUPON_CHANNEL_ID_LIST(1, "列表"), COUPON_CHANNEL_ID_TIMED(2, "限时抢购"), COUPON_CHANNEL_ID_CAMPAIN(3, "幻灯片"), // banner图, 宣传页,轮播图,走马灯 @@ -46,6 +55,41 @@ public enum EnumCouponChannelType { this.message = message; } + /** + * 微信平台的渠道 + */ + public static List getWeiXinType(){ + List typeList = new ArrayList<>(); + typeList.add(COUPON_CHANNEL_ID_LIST.getCode()); + typeList.add(COUPON_CHANNEL_ID_TIMED.getCode()); + typeList.add(COUPON_CHANNEL_ID_GAME.getCode()); + typeList.add(COUPON_CHANNEL_ID_CARD.getCode()); + typeList.add(COUPON_CHANNEL_ID_PRESS.getCode()); + typeList.add(COUPON_CHANNEL_ID_ORDER_GROUP.getCode()); + typeList.add(COUPON_CHANNEL_ID_CREDIT.getCode()); + typeList.add(COUPON_CHANNEL_ID_H5.getCode()); + typeList.add(COUPON_CHANNEL_ID_WXLIVE_LIST.getCode()); + return typeList; + } + + /** + * 抖音平台的渠道 + */ + public static List getDouYinType(){ + List typeList = new ArrayList<>(); + typeList.add(COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()); + return typeList; + } + + public static EnumAppPlat getAppPlat(Integer code) { + if(getWeiXinType().contains(code)){ + return EnumAppPlat.WX; + }else if(getDouYinType().contains(code)){ + return EnumAppPlat.TOUTIAO; + } + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "券类型错误,未找到对应平台"); + } + public Integer getCode() { return code; } @@ -53,4 +97,57 @@ public enum EnumCouponChannelType { public String getMessage() { return message; } + + //根据渠道筛选券类型 + public static List getCouponTypeBy(Integer code){ + List codes = new ArrayList<>(); + if(COUPON_CHANNEL_ID_LIST.getCode().equals(code)){ + //微信 列表 渠道 + //满减,代金,礼品,停车,通用,预购商品,可配送商品,券礼包 + codes.add(EnumCouponType.COUPON_MANJIAN.getCode()); + codes.add(EnumCouponType.COUPON_DAIJIN.getCode()); + codes.add(EnumCouponType.COUPON_LIPIN.getCode()); + codes.add(EnumCouponType.COUPON_TINGCHE.getCode()); + codes.add(EnumCouponType.COUPON_MULTIMCH.getCode()); + codes.add(EnumCouponType.COUPON_PREORDER.getCode()); + codes.add(EnumCouponType.COUPON_DISTRIBUTION.getCode()); + codes.add(EnumCouponType.COUPON_GIFT.getCode()); + }else if(COUPON_CHANNEL_ID_TIMED.getCode().equals(code) + || COUPON_CHANNEL_ID_GAME.getCode().equals(code)){ + //微信 限时抢购,游戏 渠道 + //可用 满减,代金,礼品,停车,通用 + codes.add(EnumCouponType.COUPON_MANJIAN.getCode()); + codes.add(EnumCouponType.COUPON_DAIJIN.getCode()); + codes.add(EnumCouponType.COUPON_LIPIN.getCode()); + codes.add(EnumCouponType.COUPON_TINGCHE.getCode()); + codes.add(EnumCouponType.COUPON_MULTIMCH.getCode()); + }else if(COUPON_CHANNEL_ID_CARD.getCode().equals(code)){ + //微信 卡频道 + //可用 消费卡 + codes.add(EnumCouponType.CARD_MULTIMCH.getCode()); + }else if(COUPON_CHANNEL_ID_PRESS.getCode().equals(code)){ + //微信 砍价频道 + //可用 砍价券 + codes.add(EnumCouponType.COUPON_PRESS.getCode()); + }else if(COUPON_CHANNEL_ID_ORDER_GROUP.getCode().equals(code)){ + //微信 拼团频道 + //可用 拼团券 + codes.add(EnumCouponType.COUPON_GROUP.getCode()); + }else if(COUPON_CHANNEL_ID_CAMPAIN.getCode().equals(code) + || COUPON_CHANNEL_ID_TOPIC.getCode().equals(code)){ + //宣传页 专题 (不分平台)查所有券 + //平台从其他地方区分 + codes.addAll(EnumCouponType.getAllCodes()); + }else if(COUPON_CHANNEL_ID_CREDIT.getCode().equals(code)){ + //微信 积分商城 + codes.add(EnumCouponType.COUPON_CREDIT.getCode()); + codes.add(EnumCouponType.COUPON_CREDIT_PARK.getCode()); + }else if(COUPON_CHANNEL_ID_DOUYIN_LIST.getCode().equals(code)){ + //抖音 列表 + codes.add(EnumCouponType.COUPON_DOUYIN.getCode()); + codes.add(EnumCouponType.COUPON_DOUYIN_PLAT.getCode()); + codes.add(EnumCouponType.COUPON_DOUYIN_BRAND.getCode()); + } + return codes; + } } diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java index 7f6d64b8b..a714ff03c 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java @@ -29,6 +29,9 @@ public enum EnumCouponType { COUPON_CREDIT_PARK(51,"积分停车券"), // COUPON_CREDIT_DOUYIN(55,"抖音积分券"), + COUPON_DOUYIN_PLAT(67, "抖音集团平台券"), + COUPON_DOUYIN_BRAND(68, "抖音集团品牌券"), + CARD_MULTIMCH(100, "消费卡"), ; @@ -40,6 +43,14 @@ public enum EnumCouponType { } return null; } + + public static List getAllCodes(){ + List codes = new ArrayList<>(); + for (EnumCouponType value : values()) { + codes.add(value.getCode()); + } + return codes; + } public static boolean mustHasMerchant(Integer code) { if (null == code) { @@ -75,6 +86,8 @@ public enum EnumCouponType { List typeList = new ArrayList<>(); typeList.add(COUPON_DOUYIN.getCode()); // typeList.add(COUPON_CREDIT_DOUYIN.getCode()); + typeList.add(COUPON_DOUYIN_PLAT.getCode()); + typeList.add(COUPON_DOUYIN_BRAND.getCode()); return typeList; } @@ -101,7 +114,7 @@ public enum EnumCouponType { } /** - * 有价 并且永不分账的券类型 + * 微信 有价 并且永不分账的券类型 */ public static List getPlatType(){ List typeList = new ArrayList<>(); @@ -119,4 +132,13 @@ public enum EnumCouponType { throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "券类型错误,未找到对应平台"); } + public static List getTypeCode(Integer plat){ + if(EnumAppPlat.WX.getCode().equals(plat)){ + return getWeiXinType(); + }else if(EnumAppPlat.TOUTIAO.getCode().equals(plat)){ + return getDouYinType(); + } + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "券平台错误,未找到对应类型"); + } + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index 1bd98f61c..a2c36b592 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -152,12 +152,7 @@ public class WxCouponServiceImpl implements WxCouponService { public ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { if (null == wxCoupon) wxCoupon = new WxCoupon(); wxCoupon.updateTenantInfo(tenantEntity); - if(StringUtils.isBlank(wxCoupon.getSortColumns())){ - wxCoupon.setSortColumns(BaseEntity.SortField.CCreateDate_DESC, BaseEntity.SortField.CId_DESC); - } - PageInfo page = null; - if (wxCoupon.getStatus() != null && wxCoupon.getStatus() == -1) - wxCoupon.setStatus(null); + handCouponList(wxCoupon); //除了a端列表 其他默认需要过滤 if(!EnumFilterPut.NO.equals(wxCoupon.getFilterCanPut())) { @@ -169,8 +164,8 @@ public class WxCouponServiceImpl implements WxCouponService { wxCoupon.setPressModelId(couponModel.getPressModelId()); } } - - page = listAsPage(wxCoupon, pageNum, pageSize); + + PageInfo page = listAsPage(wxCoupon, pageNum, pageSize); List wxCouponList = page.getList(); @@ -212,6 +207,74 @@ public class WxCouponServiceImpl implements WxCouponService { return new ResultData(page); } + + private void handCouponList(WxCoupon wxCoupon){ + //默认排序 + if(StringUtils.isBlank(wxCoupon.getSortColumns())){ + wxCoupon.setSortColumns(BaseEntity.SortField.CCreateDate_DESC, BaseEntity.SortField.CId_DESC); + } + if (wxCoupon.getStatus() != null && wxCoupon.getStatus() == -1){ + wxCoupon.setStatus(null); + } + //门店处理 + if(wxCoupon.getMerchantId() != null){ + List merchantIds = new ArrayList(); + merchantIds.add(wxCoupon.getMerchantId()); + List mcids = wxCouponMerchantMapper.findMerchantProductIds(wxCoupon.getTenantId(), merchantIds,0); + if(mcids == null || mcids.isEmpty()){ + wxCoupon.setId(-999L); + return; + }else{ + wxCoupon.setIds(mcids); + } + } + + //券类型处理 + if(wxCoupon.getType() != null){ + if(wxCoupon.getPlat() == null){ + wxCoupon.setPlat(EnumCouponType.getAppPlat(wxCoupon.getType()).getCode()); + } + }else{ + List types = wxCoupon.getTypes(); + if(wxCoupon.getTargetAd() != null){ + if(wxCoupon.getPlat() == null){ + wxCoupon.setPlat(EnumCouponChannelType.getAppPlat(wxCoupon.getTargetAd()).getCode()); + } + List couponTypes = EnumCouponChannelType.getCouponTypeBy(wxCoupon.getTargetAd()); + if(couponTypes.isEmpty()){ + wxCoupon.setId(-999L); + return; + }else{ + if(types == null || types.isEmpty()){ + types = couponTypes; + }else{ + types.retainAll(couponTypes); + if(types.isEmpty()){ + wxCoupon.setId(-999L); + return; + } + } + } + } + if(wxCoupon.getPlat() == null){ + //默认查微信平台 + wxCoupon.setPlat(EnumAppPlat.WX.getCode()); + } + List typeCode = EnumCouponType.getTypeCode(wxCoupon.getPlat()); + if(types == null || types.isEmpty()){ + types = typeCode; + }else{ + types.retainAll(typeCode); + if(types.isEmpty()){ + wxCoupon.setId(-999L); + return; + } + } + wxCoupon.setTypes(types); + } + + } + @Override public List list(WxCoupon wxCoupon){ diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 8298470e6..1ce966648 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -115,7 +115,7 @@ - distinct c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`make_merchant_id`,c.`type`,c.`cover_img`,c.`cover_picture`,c.`detail_picture`, + c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`make_merchant_id`,c.`type`,c.`cover_img`,c.`cover_picture`,c.`detail_picture`, c.`title`,c.`sub_title`,c.`item_group`,c.`sale_price`,c.`freight_price`,c.`use_price`,c.`use_limit_rule`,c.`use_limit_quantity`,c.`send_type`, c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,c.`valid_days`,c.`detail`,c.`price`,c.tail_price,c.orig_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`, @@ -495,11 +495,6 @@ and c.`parent_tenant_id` = #{parentTenantId} - - - and c.`type` in (1,2,3,4,5,6,10,11,12,66) - - and c.`type` = #{type} @@ -647,10 +642,6 @@ and c.`merchant_type` = #{merchantType} - - and cm.`merchant_id` = #{merchantId} - - and JSON_CONTAINS(c.gift_list,json_array(#{giftList})) @@ -683,7 +674,6 @@ select from wx_coupon c - left join wx_coupon_merchant cm on c.id = cm.product_id and cm.status = 0 @@ -693,9 +683,8 @@