diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java index 48b0ab30f..3d7165a17 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java @@ -152,7 +152,7 @@ public class TtPoiPlanController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"定向达人抖音号为空"); } //达人去重 - List collect = record.getDouyinIdList().stream().collect(Collectors.toList()); + List collect = record.getDouyinIdList().stream().distinct().collect(Collectors.toList()); record.setDouyinIdList(collect); if(record.getCouponId() == null){ 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 be1fd820b..68b52475e 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -85,21 +85,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/mallinkAdmin/src/main/resources/db/migration/V2022111600001__add_mall_permission.sql b/mallinkAdmin/src/main/resources/db/migration/V2022111600001__add_mall_permission.sql new file mode 100644 index 000000000..116a0096b --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V2022111600001__add_mall_permission.sql @@ -0,0 +1,4 @@ +INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (648, '抖音平台券', 602, 'Y', NULL, 1, NULL, NULL, 'douyinPlatCoupon', NULL, 0, 648); +INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (649, '抖音品牌券', 602, 'Y', NULL, 1, NULL, NULL, 'douyinBrandCoupon', NULL, 0, 649); + +INSERT INTO `mallink`.`mall_sale_type`(`id`, `name`, `type`, `period`, `menus`) VALUES (101, '抖音集团版', 101, 12, '[1, 2, 4, 5, 6, 50, 105, 110, 201, 205, 202, 211, 212, 221, 222, 223, 224, 251, 409, 410, 411, 416, 500, 502, 504, 505, 506, 507, 511, 512, 521, 522, 523, 591, 592, 595, 601, 602, 605, 610, 615, 622, 648, 649, 676, 711, 901, 902, 904, 907, 61501, 61502]'); 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..050f2f899 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; @@ -363,6 +366,26 @@ public class WxCoupon extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "flowParams") private Map flowParams; + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="spuId",name="spuId")//goodsId + private String spuId; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="状态:0-审核中,1-上架,2-下架,3-审核拒绝 4-审核通过",name="poiStatus") + private Integer poiStatus; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="描述",name="statusDesc") + private String statusDesc; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="状态:0-审核中,1-上架,2-下架,3-审核拒绝 4-审核通过",name="lastStatus") + private Integer lastStatus; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="描述",name="lastStatusDesc") + private String lastStatusDesc; + @io.swagger.annotations.ApiModelProperty(value = "是否删除1是0否", name = "isDel") private Integer isDel; 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 31102a9c5..a714ff03c 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java @@ -28,7 +28,10 @@ public enum EnumCouponType { COUPON_CREDIT(50,"积分券"), COUPON_CREDIT_PARK(51,"积分停车券"), // COUPON_CREDIT_DOUYIN(55,"抖音积分券"), - COUPON_PLAT(53,"平台券"), + + 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/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java index 7a6ab3547..a32c0b20b 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java @@ -24,7 +24,7 @@ public interface WxCouponChannelMapper extends CommonMapper ttChannelList(TtCouponChannelVo ttChannelVo); Long findCouponIdById(@Param("id")Long id,@Param("tenantId")String tenantId); + + int updateStatusByTargetAd(WxCouponChannel updCC); + + int selectCountExclude(WxCouponChannel ccQ); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxMallMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxMallMapper.java index c5f8e8fc2..502d43285 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxMallMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxMallMapper.java @@ -20,6 +20,7 @@ public interface WxMallMapper extends CommonMapper { String queryMenusByTenantInfo(WxMall wxMall); + void updateUnSubMall(@Param(value = "parentTenantId")String parentTenantId); void undateSubmall(@Param(value = "parentTenantId")String parentTenantId, @Param(value = "tenantIds")List tenantIds); List listAsSelectMall(@Param(value = "id")Long id); @@ -27,4 +28,6 @@ public interface WxMallMapper extends CommonMapper { List getTenantEntitys(TenantEntity tenantEntity); List findListAadmin(WxMall record); + + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java b/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java index 4592d2fab..719d6702f 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java @@ -95,6 +95,14 @@ public interface WxMerchantService { */ List findList(WxMerchant record); + /** + * 根据商管商户 + * + * @param tenantEntity + * @return + */ + List findAdminList(TenantEntity tenantEntity); + /** * 查询商户列表 * @param tenantEntity diff --git a/mallinkService/src/main/java/com/iformall/service/cuser/wx/WxCUserServiceAdapter.java b/mallinkService/src/main/java/com/iformall/service/cuser/wx/WxCUserServiceAdapter.java index 2c63c66f5..3d2080092 100644 --- a/mallinkService/src/main/java/com/iformall/service/cuser/wx/WxCUserServiceAdapter.java +++ b/mallinkService/src/main/java/com/iformall/service/cuser/wx/WxCUserServiceAdapter.java @@ -127,7 +127,12 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer updateUser.setId(cuser.getId()); updateUser.updateTenantInfo(cuser); updateUser.setUnionId(userInfo.getUnionId()); - updateUser.setNickName(userInfo.getNickName()); + if(userInfo.getNickName() == null){ + updateUser.setNickName(AppUtils.getAppId());//获取不到微信昵称 + }else{ + updateUser.setNickName(userInfo.getNickName()); + } + updateUser.setGender(Integer.parseInt(userInfo.getGender())); updateUser.setAvatarUrl(userInfo.getAvatarUrl()); updateUser.setProvince(userInfo.getProvince()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java index e89e2db42..263f4c0ce 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java @@ -379,7 +379,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); wxCouponChannelQuery.updateTenantInfo(wxCoupon); wxCouponChannelQuery.setCouponId(wxCoupon.getId()); - wxCouponChannelQuery.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()); +// wxCouponChannelQuery.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()); wxCouponChannelQuery.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); List wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); if(wxCouponChannels.size() > 0){ @@ -653,6 +653,9 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { if(oldTakeRate == null || StringUtils.isBlank(oldTakeRate.getDouyinId())){ throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); } + if(!EnumCpsPlanStatus.ING.getCode().equals(oldTakeRate.getStatus())){ + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该计划已取消或已完成"); + } List addDouyinIdList = new ArrayList<>(); addDouyinIdList.addAll(record.getDouyinIdList()); @@ -672,6 +675,13 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { } if(EnumCpsPlanContentType.VIDEO.getCode().equals(record.getContentType())){ + //当时间改变时, + if(record.getStartTime() != null && record.getStartTime().after(oldTakeRate.getStartTime())){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"开始时间只能向前修改"); + } + if(record.getEndTime() != null && record.getEndTime().before(oldTakeRate.getEndTime())){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"结束时间只能向后延长"); + } //当时间未改变时, if(record.getStartTime() == null || record.getStartTime().equals(oldTakeRate.getStartTime())){ record.setStartTime(null); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index 267d08bf5..6010053f0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -153,6 +153,16 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { if (list != null && list.size() > 0) { return new ResultData(ErrorCode.COUPON_CHANNEL_IS_EXISTED); } + + if(EnumCouponType.getDouYinType().contains(orignal.getType())){ + TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(wxCoupon.getTenantId(),wxCoupon.getId()); + if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该商品未提交审核或审核未通过"); + } + //上架该券的审核渠道 + updateOnlineDouyin(orignal,orignal.getCouponId()); + } + } } Long couponId = null; @@ -169,6 +179,10 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { //浮层下架 wxFloatingLayerMapper.updateStatus(orignal.getCouponId()); + if(EnumCouponType.getDouYinType().contains(orignal.getType())){ + //下架该券的审核渠道(如所有渠道都已下线) + updateTakeOffDouyin(orignal); + } } } record.setUpdateDate(new Date()); @@ -190,6 +204,45 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { return new ResultData(); } + /** + * 前置 该券已审核通过 + * //上架该券的审核渠道 + * @param tenantEntity + * @param couponId + */ + public void updateOnlineDouyin(TenantEntity tenantEntity,Long couponId){ + WxCouponChannel updCC = new WxCouponChannel(); + updCC.updateTenantInfo(tenantEntity); + updCC.setCouponId(couponId); + updCC.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN.getCode()); + updCC.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + updCC.setUpdateDate(new Date()); + wxCouponChannelMapper.updateStatusByTargetAd(updCC); + } + + /** + * //下架该券的审核渠道(如所有其他渠道都已下线) + * @param couponChannel + */ + public void updateTakeOffDouyin(WxCouponChannel couponChannel){ + WxCouponChannel ccQ = new WxCouponChannel(); + ccQ.updateTenantInfo(couponChannel); + ccQ.setCouponId(couponChannel.getCouponId()); + ccQ.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + //Exclude + ccQ.setId(couponChannel.getId()); + ccQ.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN.getCode()); + if(wxCouponChannelMapper.selectCountExclude(ccQ) == 0){ + WxCouponChannel updCC = new WxCouponChannel(); + updCC.updateTenantInfo(couponChannel); + updCC.setCouponId(couponChannel.getCouponId()); + updCC.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN.getCode()); + updCC.setStatus(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()); + updCC.setUpdateDate(new Date()); + wxCouponChannelMapper.updateStatusByTargetAd(updCC); + } + } + @Override public void spuStatusSyncByCoupon(TenantEntity tenantEntity, Long couponId) { FmInsideProductPushMsg productPush = new FmInsideProductPushMsg(); @@ -646,6 +699,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { wxCouponChannel.setBusiness(wxCoupon.getBusiness()); wxCouponChannel.setSubBusiness(wxCoupon.getSubBusiness()); wxCouponChannel.setTitle(wxCoupon.getTitle()); + wxCouponChannel.setTtSpuId(wxCoupon.getGoodsId()); wxCouponChannel.setChannelPrice(channelPrice); wxCouponChannel.setChannelStock(channelStock); ResultData resultData = saveOrUpdate(wxCouponChannel); 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 4ed45446c..3eb900841 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,78 @@ 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()); + } + if(EnumAppPlat.TOUTIAO.getCode().equals(wxCoupon.getPlat())){ + //渠道查询时只查询审核通过的 + wxCoupon.setLastStatus(EnumSpuSyncStatus.sync_audit_pass.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/java/com/iformall/service/impl/WxMallServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMallServiceImpl.java index 5de801946..12b00b4c5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMallServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMallServiceImpl.java @@ -238,6 +238,7 @@ public class WxMallServiceImpl implements WxMallService { @Override public void undateSubmall(String parentTenantId, List tenantIds) { + wxMallMapper.updateUnSubMall(parentTenantId); wxMallMapper.undateSubmall(parentTenantId, tenantIds); TenantEntity tenantEntity = new TenantEntity(); tenantEntity.setTenantId(parentTenantId); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index c8e3533ed..2ea1bc34f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -275,6 +275,16 @@ public class WxMerchantServiceImpl implements WxMerchantService { return wxMerchantMapper.findList(record); } + @Override + public List findAdminList(TenantEntity tenantEntity) { + WxMerchant wxMerchant = new WxMerchant(); + wxMerchant.updateTenantInfo(tenantEntity); + wxMerchant.setStatus(EnumMerchantStatus.VALID.getCode()); + wxMerchant.setIsAdmin(EnumMerchantAdmin.PUBLIC_ADMIN.getCode()); + List list = findList(wxMerchant); + return list; + } + @Override public List findList(TenantEntity tenantEntity) { WxMerchant wxMerchant = new WxMerchant(); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 905af20fd..c52b590a6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1389,6 +1389,18 @@ public class WxRentContractServiceImpl implements WxRentContractService { } + private static Date getCurrentYearRentDate(Date yearEndDate,Date rentDate){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(yearEndDate); + + Calendar rentCalendar = Calendar.getInstance(); + rentCalendar.setTime(rentDate); + + calendar.set(Calendar.DAY_OF_MONTH,rentCalendar.get(Calendar.DAY_OF_MONTH)); + calendar.set(Calendar.MONTH, rentCalendar.get(Calendar.MONTH)); + return calendar.getTime(); + } + public Map buildRent(int receivePeriod, long[] priceArrs, List yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxRentContract); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); @@ -1422,6 +1434,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { long needpay = 0; boolean flag = false; + //此处逻辑处理这一年和下一年交接那一期账单。 if(yearList.size() > 1) { if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { if(yearList.size() > 1) { @@ -1436,18 +1449,26 @@ public class WxRentContractServiceImpl implements WxRentContractService { long needpayAfter = 0; //同一天,算一天 if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ - needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod,false); + needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); }else{ if(billTimeVo.getStartDate().before(endDate)){ if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType()) && EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { //设置跳点率为年周期 price不变 needpayFront = priceArrs[index - 1]; }else { - needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true); - needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true); + needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); + needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); } }else{ - needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod,false); + //如果是按自然月,则这一年和下一年交叉部分需要重新计算 + if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { + Date currentYearRentDate = getCurrentYearRentDate(endDate,wxRentContract.getRentalStartDate()); + needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); + needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); + }else { + //按账单日 + needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod,false,false); + } } } needpay = needpayFront+needpayAfter; @@ -1466,7 +1487,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { //计算金额 if(!flag){ - needpay = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod,false); + needpay = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); } WxBillRent wxBillRent = new WxBillRent(); @@ -1519,13 +1540,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { return resultMap; } - public long getNeedPayMoney(WxRentContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod,boolean part){ + public long getNeedPayMoney(WxRentContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod,boolean part,boolean monthCalDay){ long needpay; //按日 if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ Double priceD = new Double(price); double needpayD = WxRentContractServiceImpl.getNeedPay(0,priceD,startDate,endDate); - needpay = new Double(needpayD).longValue(); + //取整 + //needpay = new Double(needpayD).longValue(); + //四舍五入 + needpay = new BigDecimal(needpayD).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); }else{ Double priceD = new Double(price); if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType())) { @@ -1547,7 +1571,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { //生成金额直接计算 if(!saveDb){ - needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part)).longValue(); + //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part)).longValue(); + needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); return needpay; } @@ -1564,7 +1589,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { int months = getMonths(sdM.format(startDate)+"-01",sdM.format(DateUtils.getDaySet(endDate,Calendar.DATE,1))+"-01"); needpay = new Double(months * priceD).longValue(); }else{ - needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } }else if(i == 0){//第一期 if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ @@ -1573,7 +1599,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { months++; needpay = new Double(months * priceD).longValue(); }else{ - needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } }else{ if(isFirstDay(startDate)){ @@ -1583,7 +1610,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { } needpay = new Double(months * priceD).longValue(); }else{ - needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); } } }else{//中间 @@ -1591,12 +1619,18 @@ public class WxRentContractServiceImpl implements WxRentContractService { if(isFirstDay(startDate)){ months++; } - needpay = new Double(months * priceD).longValue(); + //如果当月费用需要按天计算 + if (monthCalDay) { + //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); + needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); + }else { + needpay = new Double(months * priceD).longValue(); + } } } return needpay; } - + public void setExpiredDay(WxBillRent wxBillRent,int dayType, int receivePeriod){ //截止收租日在当前时间之前 Date date = new Date(); @@ -3288,12 +3322,4 @@ public class WxRentContractServiceImpl implements WxRentContractService { return count; } - - public static void main(String[] args) { - String s = "{\"siteMoney\":\"2\",\"facilityMoney\":\"3\",\"administratorMoney\":\"4\"}"; - JSONObject jsonObject = JSONObject.parseObject(s); - String siteMoney = jsonObject.getString("siteMoney"); - System.out.println(siteMoney); - } - } diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 884f1810d..19e885475 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -535,4 +535,33 @@ and id = #{id} + + update wx_coupon_channel + set status=#{status}, update_date=#{updateDate} + where status != #{status} + and coupon_id = #{couponId} + and target_ad = #{targetAd} + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 8298470e6..9e3af5585 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -60,6 +60,12 @@ + + + + + + @@ -115,7 +121,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`, @@ -476,13 +482,6 @@ - where c.is_del = 0 - - and 0 = (select count(*) from wx_coupon_channel cc - where c.`id` = cc.coupon_id - and cc.status = 0 - and cc.target_ad = #{targetAd}) - and c.`id` = #{id} @@ -495,11 +494,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,14 +641,17 @@ and c.`merchant_type` = #{merchantType} - - and cm.`merchant_id` = #{merchantId} - - and JSON_CONTAINS(c.gift_list,json_array(#{giftList})) + + and 0 = (select count(*) from wx_coupon_channel cc + where c.`id` = cc.coupon_id + and cc.status = 0 + and cc.target_ad = #{targetAd}) + + and c.id in @@ -676,15 +673,34 @@ - order by ${sortColumns} 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 + + left join tt_coupon_channel_poi poi on poi.id = c.id + + where c.is_del = 0 + + + and poi.`spu_id` = #{spuId} + + + + and poi.`status` = #{poiStatus} + + + + and poi.`last_status` = #{lastStatus} + + diff --git a/mallinkService/src/main/resources/mapper/WxMallMapper.xml b/mallinkService/src/main/resources/mapper/WxMallMapper.xml index 30216f082..60eaab8e0 100644 --- a/mallinkService/src/main/resources/mapper/WxMallMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMallMapper.xml @@ -207,9 +207,13 @@ and m.`parent_tenant_id` = #{parentTenantId} + + + + update wx_mall set parent_tenant_id = null where parent_tenant_id = #{parentTenantId} + - update wx_mall set parent_tenant_id = null where parent_tenant_id = #{parentTenantId} ; update wx_mall set parent_tenant_id = #{parentTenantId} where tenant_id in