| @@ -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 = { | |||
| @@ -42,6 +42,9 @@ public class WxCoupon extends TenantEntity { | |||
| @TableField(exist = false) | |||
| protected List<Long> notinTypes; | |||
| @TableField(exist = false) | |||
| protected Integer plat; | |||
| @TableField(exist = false) | |||
| protected String channels; | |||
| @@ -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<Integer> getWeiXinType(){ | |||
| List<Integer> 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<Integer> getDouYinType(){ | |||
| List<Integer> 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<Integer> getCouponTypeBy(Integer code){ | |||
| List<Integer> 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; | |||
| } | |||
| } | |||
| @@ -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<Integer> getAllCodes(){ | |||
| List<Integer> 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<Integer> 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<Integer> getPlatType(){ | |||
| List<Integer> typeList = new ArrayList<>(); | |||
| @@ -119,4 +132,13 @@ public enum EnumCouponType { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "券类型错误,未找到对应平台"); | |||
| } | |||
| public static List<Integer> 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(), "券平台错误,未找到对应类型"); | |||
| } | |||
| } | |||
| @@ -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<WxCoupon> 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<WxCoupon> page = listAsPage(wxCoupon, pageNum, pageSize); | |||
| List<WxCoupon> 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<Long> merchantIds = new ArrayList<Long>(); | |||
| merchantIds.add(wxCoupon.getMerchantId()); | |||
| List<Long> 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<Integer> types = wxCoupon.getTypes(); | |||
| if(wxCoupon.getTargetAd() != null){ | |||
| if(wxCoupon.getPlat() == null){ | |||
| wxCoupon.setPlat(EnumCouponChannelType.getAppPlat(wxCoupon.getTargetAd()).getCode()); | |||
| } | |||
| List<Integer> 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<Integer> 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<WxCoupon> list(WxCoupon wxCoupon){ | |||
| @@ -115,7 +115,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| 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} | |||
| </if> | |||
| <if test=" null == type and null == types"> | |||
| <!-- and ( c.`type` < 7 or c.`type` = 10 ) --> | |||
| and c.`type` in (1,2,3,4,5,6,10,11,12,66) | |||
| </if> | |||
| <if test=" null != type "> | |||
| and c.`type` = #{type} | |||
| </if> | |||
| @@ -647,10 +642,6 @@ | |||
| and c.`merchant_type` = #{merchantType} | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and cm.`merchant_id` = #{merchantId} | |||
| </if> | |||
| <if test=" null != giftList"> | |||
| and JSON_CONTAINS(c.gift_list,json_array(#{giftList})) | |||
| </if> | |||
| @@ -683,7 +674,6 @@ | |||
| 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"> | |||
| @@ -693,9 +683,8 @@ | |||
| <select id="findCouponListCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Integer"> | |||
| select | |||
| count(distinct c.id) | |||
| count(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> | |||