| @@ -1,5 +1,6 @@ | |||||
| package com.simple.controller; | package com.simple.controller; | ||||
| import com.simple.domain.vo.WxCouponChannelVo; | |||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.util.Assert; | import org.springframework.util.Assert; | ||||
| @@ -31,33 +32,11 @@ public class WxCouponChannelController extends BaseController | |||||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | ||||
| public ResultData list(@ModelAttribute WxCouponChannel wxCouponChannel,Integer pageNum, Integer pageSize) { | public ResultData list(@ModelAttribute WxCouponChannel wxCouponChannel,Integer pageNum, Integer pageSize) { | ||||
| if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel(); | if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel(); | ||||
| final PageInfo<WxCouponChannel> page = wxCouponChannelService.listAsPage(wxCouponChannel, pageNum, pageSize); | |||||
| wxCouponChannel.setTenantId(getTenantId()); | |||||
| final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize); | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| public ResultData add(@RequestBody WxCouponChannel wxCouponChannel) { | |||||
| //Assert.notNull(wxCouponChannel.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxCouponChannelService.saveOrUpdate(wxCouponChannel); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) { | |||||
| wxCouponChannelService.saveOrUpdate(wxCouponChannel); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||||
| public ResultData delete(Long id) { | |||||
| wxCouponChannelService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | @ApiOperation("根据id查询接口") | ||||
| @GetMapping("/findById") | @GetMapping("/findById") | ||||
| @@ -30,6 +30,7 @@ public class WxCouponController extends BaseController { | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
| public ResultData list(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | public ResultData list(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | ||||
| if (null == wxCoupon) wxCoupon = new WxCoupon(); | if (null == wxCoupon) wxCoupon = new WxCoupon(); | ||||
| wxCoupon.setTenantId(getTenantId()); | |||||
| final PageInfo<WxCoupon> page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize); | final PageInfo<WxCoupon> page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize); | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -31,33 +31,11 @@ public class WxCouponSendController extends BaseController | |||||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | ||||
| public ResultData list(@ModelAttribute WxCouponSend wxCouponSend,Integer pageNum, Integer pageSize) { | public ResultData list(@ModelAttribute WxCouponSend wxCouponSend,Integer pageNum, Integer pageSize) { | ||||
| if (null == wxCouponSend) wxCouponSend = new WxCouponSend(); | if (null == wxCouponSend) wxCouponSend = new WxCouponSend(); | ||||
| wxCouponSend.setTenantId(getTenantId()); | |||||
| final PageInfo<WxCouponSend> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize); | final PageInfo<WxCouponSend> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize); | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| public ResultData add(@RequestBody WxCouponSend wxCouponSend) { | |||||
| //Assert.notNull(wxCouponSend.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxCouponSendService.saveOrUpdate(wxCouponSend); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| public ResultData update(@RequestBody WxCouponSend wxCouponSend) { | |||||
| wxCouponSendService.saveOrUpdate(wxCouponSend); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||||
| public ResultData delete(Long id) { | |||||
| wxCouponSendService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | @ApiOperation("根据id查询接口") | ||||
| @GetMapping("/findById") | @GetMapping("/findById") | ||||
| @@ -2,12 +2,15 @@ package com.simple.mapper; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.simple.common.CommonMapper; | import com.simple.common.CommonMapper; | ||||
| import com.simple.domain.vo.WxCouponChannelVo; | |||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||
| import com.simple.domain.po.WxCouponChannel; | import com.simple.domain.po.WxCouponChannel; | ||||
| public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, String> { | public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, String> { | ||||
| List<WxCouponChannel> findList(WxCouponChannel wxCouponChannel); | List<WxCouponChannel> findList(WxCouponChannel wxCouponChannel); | ||||
| List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | |||||
| @@ -1,8 +1,8 @@ | |||||
| package com.simple.service; | package com.simple.service; | ||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.domain.po.WxCouponChannel; | import com.simple.domain.po.WxCouponChannel; | ||||
| import com.simple.domain.vo.WxCouponChannelVo; | |||||
| public interface WxCouponChannelService { | public interface WxCouponChannelService { | ||||
| @@ -15,6 +15,8 @@ public interface WxCouponChannelService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<WxCouponChannel> listAsPage(WxCouponChannel record, Integer pageIndex, Integer pageSize); | PageInfo<WxCouponChannel> listAsPage(WxCouponChannel record, Integer pageIndex, Integer pageSize); | ||||
| PageInfo<WxCouponChannelVo> listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize); | |||||
| /** | /** | ||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| @@ -1,10 +1,13 @@ | |||||
| package com.simple.service.impl; | package com.simple.service.impl; | ||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.stream.Collectors; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.domain.po.WxCoupon; | import com.simple.domain.po.WxCoupon; | ||||
| import com.simple.domain.po.WxCouponChannel; | import com.simple.domain.po.WxCouponChannel; | ||||
| import com.simple.domain.vo.WxCouponChannelVo; | |||||
| import com.simple.mapper.WxCouponChannelMapper; | import com.simple.mapper.WxCouponChannelMapper; | ||||
| import com.simple.service.WxCouponChannelService; | import com.simple.service.WxCouponChannelService; | ||||
| import com.simple.service.WxCouponService; | import com.simple.service.WxCouponService; | ||||
| @@ -22,6 +25,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| WxCouponService wxCouponService; | WxCouponService wxCouponService; | ||||
| /** | |||||
| * B端业务端 | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| @Override | @Override | ||||
| public PageInfo<WxCouponChannel> listAsPage(WxCouponChannel record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCouponChannel> listAsPage(WxCouponChannel record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findList(record)); | ||||
| @@ -64,11 +74,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| } | } | ||||
| @Transactional | |||||
| public void addCuponChannel(Long couponid,Integer channelId,String tanantId){ | public void addCuponChannel(Long couponid,Integer channelId,String tanantId){ | ||||
| WxCoupon wxCouponUP = new WxCoupon(); | |||||
| wxCouponUP.setId(couponid); | |||||
| wxCouponUP.setStatus(1); | |||||
| wxCouponService.saveOrUpdate(wxCouponUP); | |||||
| WxCoupon wxCoupon = wxCouponService.getById(couponid); | |||||
| if(wxCoupon.getStatus()!=1) { | |||||
| wxCoupon.setStatus(1); | |||||
| wxCouponService.saveOrUpdate(wxCoupon); | |||||
| } | |||||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | WxCouponChannel wxCouponChannel = new WxCouponChannel(); | ||||
| wxCouponChannel.setCouponId(couponid); | wxCouponChannel.setCouponId(couponid); | ||||
| wxCouponChannel.setCouponStatus(1); | wxCouponChannel.setCouponStatus(1); | ||||
| @@ -77,5 +89,33 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| saveOrUpdate(wxCouponChannel); | saveOrUpdate(wxCouponChannel); | ||||
| } | } | ||||
| /** | |||||
| * C端api使用,关联查找的券时已生效 | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| @Override | |||||
| public PageInfo<WxCouponChannelVo> listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize) { | |||||
| List<WxCouponChannelVo> wxCouponChannelVoList = new ArrayList<>(); | |||||
| PageHelper.startPage(pageIndex, pageSize); | |||||
| wxCouponChannelVoList = wxCouponChannelMapper.findVoList(record); | |||||
| if(wxCouponChannelVoList.isEmpty()){ | |||||
| return new PageInfo<>(wxCouponChannelVoList); | |||||
| } | |||||
| List<Long> couponIds = wxCouponChannelVoList.stream().map(p->p.getCouponId()).distinct().collect(Collectors.toList()); | |||||
| WxCoupon wxCoupon = new WxCoupon(); | |||||
| wxCoupon.setIds(couponIds); | |||||
| List<WxCoupon> wxCoupons = wxCouponService.findList(wxCoupon); | |||||
| Map<Long,WxCoupon> couponNamesMap = wxCoupons.stream().collect(Collectors.toMap(WxCoupon::getId,p->p)); | |||||
| for (WxCouponChannelVo wxcouponVo:wxCouponChannelVoList) { | |||||
| if(couponNamesMap.get(wxcouponVo.getCouponId())!=null){ | |||||
| wxcouponVo.setWxCoupon(couponNamesMap.get(wxcouponVo.getCouponId())); | |||||
| } | |||||
| } | |||||
| return new PageInfo<>(wxCouponChannelVoList); | |||||
| } | |||||
| } | } | ||||
| @@ -10,12 +10,13 @@ | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | <result column="type" jdbcType="INTEGER" property="type" /> | ||||
| <result column="title" jdbcType="VARCHAR" property="title" /> | <result column="title" jdbcType="VARCHAR" property="title" /> | ||||
| <result column="target_ad" jdbcType="INTEGER" property="targetAd" /> | <result column="target_ad" jdbcType="INTEGER" property="targetAd" /> | ||||
| <result column="business" jdbcType="VARCHAR" property="business" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | ||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | ||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`merchant_id`,`coupon_id`,`coupon_status`,`type`,`title`,`target_ad`,`create_date`,`update_date` | |||||
| `id`,`tenant_id`,`merchant_id`,`coupon_id`,`coupon_status`,`type`,`title`,`target_ad`,`business`,`create_date`,`update_date` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -83,6 +84,25 @@ | |||||
| select <include refid="allColumns" /> from wx_coupon_channel | select <include refid="allColumns" /> from wx_coupon_channel | ||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <select id="findVoList" parameterType="com.simple.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap"> | |||||
| select <include refid="allColumns" /> from wx_coupon_channel | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <resultMap id="CouponChannelVoMap" type="com.simple.domain.vo.WxCouponChannelVo"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||||
| <result column="coupon_status" jdbcType="INTEGER" property="couponStatus" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||||
| <result column="target_ad" jdbcType="INTEGER" property="targetAd" /> | |||||
| <result column="business" jdbcType="VARCHAR" property="business" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| </resultMap> | |||||