| @@ -0,0 +1,2 @@ | |||||
| ALTER TABLE `wx_screen_ad` | |||||
| ADD COLUMN `ext_info` JSON NULL DEFAULT NULL AFTER `target_id`; | |||||
| @@ -44,6 +44,9 @@ public class WxDeviceScreenAdController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxCampaignService wxCampaignService; | private WxCampaignService wxCampaignService; | ||||
| @Autowired | |||||
| private WxMerchantService wxMerchantService; | |||||
| @Autowired | @Autowired | ||||
| private WxCouponChannelService wxCouponChannelService; | private WxCouponChannelService wxCouponChannelService; | ||||
| @@ -82,6 +85,8 @@ public class WxDeviceScreenAdController extends BaseController { | |||||
| target = wxCouponChannelService.findDetailVo(s.getTargetId()); | target = wxCouponChannelService.findDetailVo(s.getTargetId()); | ||||
| else if (s.getType().equals(EnumScreenAdType.CAMPAIGN.getCode())) | else if (s.getType().equals(EnumScreenAdType.CAMPAIGN.getCode())) | ||||
| target = wxCampaignService.getById(s.getTargetId()); | target = wxCampaignService.getById(s.getTargetId()); | ||||
| else if (s.getType().equals(EnumScreenAdType.MERCHANT.getCode())) | |||||
| target = wxMerchantService.getById(s.getTargetId()); | |||||
| s.setTarget(target); | s.setTarget(target); | ||||
| }); | }); | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| @@ -43,6 +43,9 @@ public class WxScreenAd extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="广告目标ID: couponChannelId or campaignId",name="targetId") | @io.swagger.annotations.ApiModelProperty(value="广告目标ID: couponChannelId or campaignId",name="targetId") | ||||
| private Long targetId; | private Long targetId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="扩展信息",name="ExtInfo") | |||||
| private String ExtInfo; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| protected Object target; | protected Object target; | ||||
| @@ -7,7 +7,9 @@ public enum EnumScreenAdType { | |||||
| COUPON(0, "券"), | COUPON(0, "券"), | ||||
| CAMPAIGN(1, "宣传页"), | CAMPAIGN(1, "宣传页"), | ||||
| PICTURE(2, "图片"),; | |||||
| PICTURE(2, "图片"), | |||||
| MERCHANT(3, "商户"); | |||||
| public static EnumScreenAdType getEnum(Integer code) { | public static EnumScreenAdType getEnum(Integer code) { | ||||
| for (EnumScreenAdType value : values()) { | for (EnumScreenAdType value : values()) { | ||||
| if (value.getCode().equals(code)) { | if (value.getCode().equals(code)) { | ||||
| @@ -1,16 +1,14 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxCampaign; | |||||
| import com.iformall.domain.po.WxCouponChannel; | |||||
| import com.iformall.domain.po.WxScreenAd; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.enums.EnumCouponChannelType; | import com.iformall.enums.EnumCouponChannelType; | ||||
| import com.iformall.enums.EnumScreenAdType; | import com.iformall.enums.EnumScreenAdType; | ||||
| @@ -18,6 +16,7 @@ import com.iformall.mapper.WxCampaignMapper; | |||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.mapper.WxScreenAdMapper; | import com.iformall.mapper.WxScreenAdMapper; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxMerchantService; | |||||
| import com.iformall.service.WxScreenAdService; | import com.iformall.service.WxScreenAdService; | ||||
| import com.iformall.service.wechat.FmOpenService; | import com.iformall.service.wechat.FmOpenService; | ||||
| import com.iformall.utils.MaUtil; | import com.iformall.utils.MaUtil; | ||||
| @@ -43,6 +42,9 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { | |||||
| @Autowired | @Autowired | ||||
| WxCouponChannelMapper wxCouponChannelMapper; | WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @Autowired | |||||
| WxMerchantService wxMerchantService; | |||||
| @Autowired | @Autowired | ||||
| WxCampaignMapper wxCampaignMapper; | WxCampaignMapper wxCampaignMapper; | ||||
| @@ -83,6 +85,19 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { | |||||
| } else if (record.getType().equals(EnumScreenAdType.PICTURE.getCode())) { | } else if (record.getType().equals(EnumScreenAdType.PICTURE.getCode())) { | ||||
| if (record.getCoverImg() == null) | if (record.getCoverImg() == null) | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | ||||
| } else if (record.getType().equals(EnumScreenAdType.MERCHANT.getCode())) { | |||||
| if (record.getExtInfo() == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| JSONObject jo = JSONObject.parseObject(record.getExtInfo()); | |||||
| if (jo == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| if (jo.getInteger("executionIndex") == null || jo.getInteger("populationIndex") == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| WxMerchant wxMerchant = wxMerchantService.getById(record.getTargetId()); | |||||
| if (wxMerchant == null) | |||||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||||
| record.setCoverImg(wxMerchant.getImgUrl()); | |||||
| record.setTitle(wxMerchant.getName()); | |||||
| } | } | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| @@ -12,10 +12,11 @@ | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | ||||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | ||||
| <result column="target_id" jdbcType="BIGINT" property="targetId"/> | <result column="target_id" jdbcType="BIGINT" property="targetId"/> | ||||
| <result column="ext_info" jdbcType="VARCHAR" property="extInfo"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`, `tenant_id`, `title`, `type`, `sub_type`, `status`, `create_date`, `update_date`, `cover_img`, `target_id` | |||||
| `id`, `tenant_id`, `title`, `type`, `sub_type`, `status`, `create_date`, `update_date`, `cover_img`, `target_id`, `ext_info` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -62,7 +63,6 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||