| @@ -4,11 +4,8 @@ import com.alibaba.fastjson.JSON; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.CouponInject; | |||
| import com.iformall.domain.po.WxMsg; | |||
| import com.iformall.domain.po.WxMsgModel; | |||
| import com.iformall.enums.EnumCouponInjectSendType; | |||
| import com.iformall.service.CouponInjectService; | |||
| import com.iformall.domain.po.WxCouponInject; | |||
| import com.iformall.service.WxCouponInjectService; | |||
| import com.iformall.service.WxCUserTagsService; | |||
| import com.iformall.service.WxMsgModelService; | |||
| import io.swagger.annotations.Api; | |||
| @@ -21,17 +18,16 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Api(description = "精准投放接口") | |||
| @RestController | |||
| @RequestMapping("couponInject") | |||
| public class CouponInjectController extends BaseController { | |||
| public class WxCouponInjectController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private CouponInjectService couponInjectService; | |||
| private WxCouponInjectService wxCouponInjectService; | |||
| @Autowired | |||
| private WxCUserTagsService wxCUserTagsService; | |||
| @Autowired | |||
| @@ -42,37 +38,37 @@ public class CouponInjectController extends BaseController { | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute CouponInject couponInject, Integer pageNum, Integer pageSize) { | |||
| if (null == couponInject) couponInject = new CouponInject(); | |||
| public ResultData list(@ModelAttribute WxCouponInject couponInject, Integer pageNum, Integer pageSize) { | |||
| if (null == couponInject) couponInject = new WxCouponInject(); | |||
| if (couponInject.getStatus() != null && couponInject.getStatus() == -1) { | |||
| couponInject.setStatus(null); | |||
| } | |||
| couponInject.setTenantId(getTenantId()); | |||
| couponInject.setSortColumns(CouponInject.Field.Id_DESC); | |||
| final PageInfo<CouponInject> page = couponInjectService.listAsPage(couponInject, pageNum, pageSize); | |||
| couponInject.setSortColumns(WxCouponInject.Field.Id_DESC); | |||
| final PageInfo<WxCouponInject> page = wxCouponInjectService.listAsPage(couponInject, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody CouponInject couponInject) { | |||
| public ResultData add(@RequestBody WxCouponInject couponInject) { | |||
| couponInject.setTenantId(getUser().getTenantId()); | |||
| couponInject.setMUserId(getUser().getId()); | |||
| return couponInjectService.add(couponInject); | |||
| return wxCouponInjectService.add(couponInject); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody CouponInject couponInject) { | |||
| public ResultData update(@RequestBody WxCouponInject couponInject) { | |||
| String[] arys = couponInject.getTags().split(","); | |||
| List<Long> tagids = new ArrayList<>(); | |||
| for (int i = 0; i < arys.length; i++) { | |||
| tagids.add(Long.parseLong(arys[i])); | |||
| } | |||
| couponInject.setTags(JSON.toJSONString(arys)); | |||
| couponInjectService.saveOrUpdate(couponInject); | |||
| wxCouponInjectService.saveOrUpdate(couponInject); | |||
| return new ResultData(); | |||
| } | |||
| @@ -80,7 +76,7 @@ public class CouponInjectController extends BaseController { | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData delete(Long id) { | |||
| couponInjectService.deleteById(id); | |||
| wxCouponInjectService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @@ -89,7 +85,7 @@ public class CouponInjectController extends BaseController { | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData findById(Long id) { | |||
| CouponInject couponInject = couponInjectService.getById(id); | |||
| WxCouponInject couponInject = wxCouponInjectService.getById(id); | |||
| if (couponInject != null) { | |||
| List<Long> tagids = JSON.parseArray(couponInject.getTags(), Long.class); | |||
| if (!tagids.isEmpty()) { | |||
| @@ -7,8 +7,8 @@ import java.io.Serializable; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Table(name = "coupon_inject") | |||
| public class CouponInject implements Serializable { | |||
| @Table(name = "wx_coupon_inject") | |||
| public class WxCouponInject implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| @@ -265,7 +265,7 @@ public class CouponInject implements Serializable { | |||
| } | |||
| } | |||
| public void setSortColumns(CouponInject.Field... fields) | |||
| public void setSortColumns(WxCouponInject.Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| @@ -1,17 +0,0 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.CouponInject; | |||
| import java.util.List; | |||
| public interface CouponInjectMapper extends CommonMapper<CouponInject, Long> { | |||
| List<CouponInject> findList(CouponInject couponInject); | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxCouponInject; | |||
| import java.util.List; | |||
| public interface WxCouponInjectMapper extends CommonMapper<WxCouponInject, Long> { | |||
| List<WxCouponInject> findList(WxCouponInject couponInject); | |||
| } | |||
| @@ -2,9 +2,9 @@ package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.CouponInject; | |||
| import com.iformall.domain.po.WxCouponInject; | |||
| public interface CouponInjectService { | |||
| public interface WxCouponInjectService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| @@ -14,7 +14,7 @@ public interface CouponInjectService { | |||
| * @param limit | |||
| * @return | |||
| */ | |||
| PageInfo<CouponInject> listAsPage(CouponInject record, Integer pageIndex, Integer pageSize); | |||
| PageInfo<WxCouponInject> listAsPage(WxCouponInject record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| @@ -22,14 +22,14 @@ public interface CouponInjectService { | |||
| * @param id | |||
| * @return | |||
| */ | |||
| CouponInject getById(Long id); | |||
| WxCouponInject getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(CouponInject record); | |||
| void saveOrUpdate(WxCouponInject record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| @@ -42,7 +42,7 @@ public interface CouponInjectService { | |||
| * | |||
| * @param id | |||
| */ | |||
| ResultData add(CouponInject record); | |||
| ResultData add(WxCouponInject record); | |||
| @@ -10,9 +10,8 @@ import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.CouponInjectMapper; | |||
| import com.iformall.mapper.WxCouponInjectMapper; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -23,11 +22,11 @@ import java.util.Date; | |||
| import java.util.List; | |||
| @Service | |||
| public class CouponInjectServiceImpl implements CouponInjectService { | |||
| public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| CouponInjectMapper couponInjectMapper; | |||
| WxCouponInjectMapper couponInjectMapper; | |||
| @Autowired | |||
| WxCouponOrderService wxCouponOrderService; | |||
| @Autowired | |||
| @@ -52,17 +51,17 @@ public class CouponInjectServiceImpl implements CouponInjectService { | |||
| @Override | |||
| public PageInfo<CouponInject> listAsPage(CouponInject record, Integer pageIndex, Integer pageSize) { | |||
| public PageInfo<WxCouponInject> listAsPage(WxCouponInject record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> couponInjectMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public CouponInject getById(Long id) { | |||
| public WxCouponInject getById(Long id) { | |||
| return couponInjectMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(CouponInject record) { | |||
| public void saveOrUpdate(WxCouponInject record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| @@ -79,7 +78,7 @@ public class CouponInjectServiceImpl implements CouponInjectService { | |||
| } | |||
| @Override | |||
| public ResultData add(CouponInject record) { | |||
| public ResultData add(WxCouponInject record) { | |||
| try { | |||
| pushLimitService.checkSendTime(record.getTenantId()); | |||
| @@ -151,7 +150,7 @@ public class CouponInjectServiceImpl implements CouponInjectService { | |||
| return new ResultData(); | |||
| } | |||
| private ResultData sendMsg(CouponInject record, List<WxCUser> cUsers) { | |||
| private ResultData sendMsg(WxCouponInject record, List<WxCUser> cUsers) { | |||
| //根据模板ID查询短信信息 | |||
| WxMsgModel model = wxMsgModelService.getById(record.getModelId()); | |||
| @@ -207,7 +206,7 @@ public class CouponInjectServiceImpl implements CouponInjectService { | |||
| return wxMsgService.saveOrUpdate(wxmsg); | |||
| } | |||
| private List<WxCUser> sendCoupon(WxCoupon wxCoupon,List<WxCUser> cUsers,CouponInject record){ | |||
| private List<WxCUser> sendCoupon(WxCoupon wxCoupon,List<WxCUser> cUsers,WxCouponInject record){ | |||
| //查询标签用户 | |||
| List<WxCUser> sentUsers = new ArrayList<WxCUser>(); | |||
| @@ -1,7 +1,7 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.CouponInjectMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.CouponInject"> | |||
| <mapper namespace="com.iformall.mapper.WxCouponInjectMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponInject"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||
| @@ -113,8 +113,8 @@ | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.CouponInject" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from coupon_inject | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCouponInject" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_inject | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||