| @@ -49,7 +49,8 @@ public class WxCouponSendController extends BaseController { | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "merchantName", value = "merchantName", dataType = "String", paramType = "query"), | |||||
| @ApiImplicitParam(name = "merchantName", value = "商户名,模糊查询", dataType = "String", paramType = "query"), | |||||
| @ApiImplicitParam(name = "merchantId", value = "商户Id", dataType = "String", paramType = "query"), | |||||
| }) | }) | ||||
| @SystemControllerLog(description = "注券-列表") | @SystemControllerLog(description = "注券-列表") | ||||
| public ResultData list(@ModelAttribute WxCouponSend wxCouponSend, Integer pageNum, Integer pageSize) { | public ResultData list(@ModelAttribute WxCouponSend wxCouponSend, Integer pageNum, Integer pageSize) { | ||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponActionLogVo; | |||||
| import com.iformall.domain.vo.WxCouponSendVo; | import com.iformall.domain.vo.WxCouponSendVo; | ||||
| import com.iformall.enums.EnumCouponSendSendType; | import com.iformall.enums.EnumCouponSendSendType; | ||||
| import com.iformall.enums.EnumCouponSendStatus; | import com.iformall.enums.EnumCouponSendStatus; | ||||
| @@ -11,6 +12,7 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxCUserMapper; | import com.iformall.mapper.WxCUserMapper; | ||||
| import com.iformall.service.WxCouponActionLogService; | import com.iformall.service.WxCouponActionLogService; | ||||
| import com.iformall.service.WxCouponSendService; | import com.iformall.service.WxCouponSendService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -24,8 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.Arrays; | |||||
| import java.util.Objects; | |||||
| import java.util.*; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("/api/couponSend") | @RequestMapping("/api/couponSend") | ||||
| @@ -72,6 +73,7 @@ public class WxCouponSendController extends BaseController { | |||||
| @ApiImplicitParam(name = "cUserId", value = "用户ID", dataType = "long", paramType = "query", required = true), | @ApiImplicitParam(name = "cUserId", value = "用户ID", dataType = "long", paramType = "query", required = true), | ||||
| }) | }) | ||||
| public ResultData handSel(Long[] wxCouponSendIds, Long cUserId) { | public ResultData handSel(Long[] wxCouponSendIds, Long cUserId) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponSendController::handSel"); | |||||
| WxCUser cu = wxCUserMapper.selectByPrimaryKey(cUserId); | WxCUser cu = wxCUserMapper.selectByPrimaryKey(cUserId); | ||||
| if (Objects.isNull(cu)) { | if (Objects.isNull(cu)) { | ||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | throw new MallinkException(ErrorCode.USER_IS_EMPTY); | ||||
| @@ -90,5 +92,30 @@ public class WxCouponSendController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiOperation("注券记录") | |||||
| @GetMapping("/actionLog") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "beginDate", value = "开始日期 yyyy-MM-dd", dataType = "string", paramType = "query"), | |||||
| @ApiImplicitParam(name = "endDate", value = "结束日期 yyyy-MM-dd", dataType = "string", paramType = "query"), | |||||
| }) | |||||
| public ResultData sendLog(String beginDate, String endDate, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponSendController::actionLog"); | |||||
| Date begin = DateUtils.stringToDate(beginDate) ; | |||||
| Date end = DateUtils.stringToDate(endDate) ; | |||||
| Calendar cal = Calendar.getInstance(); | |||||
| cal.setTime(end); | |||||
| cal.add(Calendar.DATE, 1); | |||||
| Map<String,Object> params = new HashMap<>() ; | |||||
| params.put("tenantId",getTenantId()) ; | |||||
| params.put("channelType",EnumCouponSendSendType.MERCHANT.getCode()) ; | |||||
| params.put("merchantId",getUser().getMerchantId()) ; | |||||
| params.put("beginDate",begin) ; | |||||
| params.put("endDate",cal.getTime()) ; | |||||
| PageInfo<WxCouponActionLogVo> data = wxCouponActionLogService.getActionLog(params,pageNum,pageSize) ; | |||||
| return new ResultData(data); | |||||
| } | |||||
| } | } | ||||
| @@ -33,4 +33,6 @@ public class WxCouponSendVo extends WxCouponSend implements Serializable{ | |||||
| /**发卷所属商户名**/ | /**发卷所属商户名**/ | ||||
| private String merchantName; | private String merchantName; | ||||
| private Date sendDate ; | |||||
| } | } | ||||
| @@ -6,6 +6,7 @@ import com.iformall.domain.dto.MarkingCouponDataReportDto; | |||||
| import com.iformall.domain.vo.MarkingSceneDataReportTVo; | import com.iformall.domain.vo.MarkingSceneDataReportTVo; | ||||
| import com.iformall.domain.vo.MarkingSceneDataReportVo; | import com.iformall.domain.vo.MarkingSceneDataReportVo; | ||||
| import com.iformall.domain.vo.MarkingSceneDataVo; | import com.iformall.domain.vo.MarkingSceneDataVo; | ||||
| import com.iformall.domain.vo.WxCouponActionLogVo; | |||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||
| import com.iformall.domain.po.WxCouponActionLog; | import com.iformall.domain.po.WxCouponActionLog; | ||||
| @@ -53,4 +54,11 @@ public interface WxCouponActionLogMapper extends CommonMapper<WxCouponActionLog, | |||||
| int getCountByUserAndCouponAndDate(Map<String,Object> params); | int getCountByUserAndCouponAndDate(Map<String,Object> params); | ||||
| /** | |||||
| * 查找注券记录 | |||||
| * @param params | |||||
| * @return | |||||
| */ | |||||
| List<WxCouponActionLogVo> getActionLog(Map<String,Object> params) ; | |||||
| } | } | ||||
| @@ -2,6 +2,10 @@ package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.WxCouponActionLog; | import com.iformall.domain.po.WxCouponActionLog; | ||||
| import com.iformall.domain.vo.WxCouponActionLogVo; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| public interface WxCouponActionLogService { | public interface WxCouponActionLogService { | ||||
| @@ -42,6 +46,14 @@ public interface WxCouponActionLogService { | |||||
| int getCountByChannelId(String tenantId, int channelType, Long channelId); | int getCountByChannelId(String tenantId, int channelType, Long channelId); | ||||
| /** | |||||
| * 查找注券记录 | |||||
| * @param params | |||||
| * @param pageNum | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxCouponActionLogVo> getActionLog(Map<String,Object> params, Integer pageNum, Integer pageSize) ; | |||||
| } | } | ||||
| @@ -93,4 +93,5 @@ public interface WxCouponSendService { | |||||
| void handSel(WxCouponSend wxCouponSend, WxCUser user) ; | void handSel(WxCouponSend wxCouponSend, WxCUser user) ; | ||||
| } | } | ||||
| @@ -2,9 +2,13 @@ package com.iformall.service.impl; | |||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.*; | import java.util.*; | ||||
| 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.domain.po.WxCouponActionLog; | import com.iformall.domain.po.WxCouponActionLog; | ||||
| import com.iformall.domain.vo.WxCouponActionLogVo; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxCouponActionLogMapper; | import com.iformall.mapper.WxCouponActionLogMapper; | ||||
| import com.iformall.service.WxCouponActionLogService; | import com.iformall.service.WxCouponActionLogService; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -12,12 +16,13 @@ import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import org.springframework.util.CollectionUtils; | |||||
| @Service | @Service | ||||
| public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { | public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| @Autowired | |||||
| WxCouponActionLogMapper wxCouponActionLogMapper; | WxCouponActionLogMapper wxCouponActionLogMapper; | ||||
| @@ -36,7 +41,7 @@ public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| record.setId(idWorker.nextId()); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxCouponActionLogMapper.insertSelective(record); | wxCouponActionLogMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| wxCouponActionLogMapper.updateByPrimaryKeySelective(record); | wxCouponActionLogMapper.updateByPrimaryKeySelective(record); | ||||
| @@ -58,7 +63,8 @@ public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { | |||||
| actionLog.setCouponOrderId(coupon_order_id); | actionLog.setCouponOrderId(coupon_order_id); | ||||
| actionLog.setChannelType(channelType); | actionLog.setChannelType(channelType); | ||||
| actionLog.setCreateTime(curDate); | actionLog.setCreateTime(curDate); | ||||
| actionLog.setCreateTimeMd(new SimpleDateFormat("MM/dd").format(curDate));; | |||||
| actionLog.setCreateTimeMd(new SimpleDateFormat("MM/dd").format(curDate)); | |||||
| ; | |||||
| saveOrUpdate(actionLog); | saveOrUpdate(actionLog); | ||||
| } | } | ||||
| @@ -67,4 +73,13 @@ public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { | |||||
| return wxCouponActionLogMapper.getCountByChannelId(tenantId, channelType, channelId); | return wxCouponActionLogMapper.getCountByChannelId(tenantId, channelType, channelId); | ||||
| } | } | ||||
| @Override | |||||
| public PageInfo<WxCouponActionLogVo> getActionLog(Map<String, Object> params, Integer pageNum, Integer pageSize) { | |||||
| Object channelType = params.get("channelType"); | |||||
| if (CollectionUtils.isEmpty(params) || Objects.isNull(channelType)) { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCouponActionLogMapper.getActionLog(params)); | |||||
| } | |||||
| } | } | ||||
| @@ -10,44 +10,44 @@ | |||||
| <result column="channel_id" jdbcType="BIGINT" property="channelId" /> | <result column="channel_id" jdbcType="BIGINT" property="channelId" /> | ||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | ||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time` | `id`,`tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time` | ||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| where 1 = 1 | where 1 = 1 | ||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | and `tenant_id` = #{tenantId} | ||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != couponOrderId "> | |||||
| and `coupon_order_id` = #{couponOrderId} | |||||
| </if> | |||||
| <if test=" null != channelType "> | |||||
| and `channel_type` = #{channelType} | |||||
| </if> | |||||
| <if test=" null != channelId "> | |||||
| and `channel_id` = #{channelId} | |||||
| </if> | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != couponOrderId "> | |||||
| and `coupon_order_id` = #{couponOrderId} | |||||
| </if> | |||||
| <if test=" null != channelType "> | |||||
| and `channel_type` = #{channelType} | |||||
| </if> | |||||
| <if test=" null != channelId "> | |||||
| and `channel_id` = #{channelId} | |||||
| </if> | |||||
| <if test=" null != createTime "> | <if test=" null != createTime "> | ||||
| and `create_time` = #{createTime} | and `create_time` = #{createTime} | ||||
| </if> | </if> | ||||
| @@ -59,14 +59,14 @@ | |||||
| </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=")"> | ||||
| #{idItem} | #{idItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| </sql> | </sql> | ||||
| <select id="findList" parameterType="com.iformall.domain.po.WxCouponActionLog" resultMap="BaseResultMap"> | <select id="findList" parameterType="com.iformall.domain.po.WxCouponActionLog" resultMap="BaseResultMap"> | ||||
| select <include refid="allColumns" /> from wx_coupon_action_log | select <include refid="allColumns" /> from wx_coupon_action_log | ||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| @@ -212,5 +212,30 @@ | |||||
| and a.create_time >= #{startTime} | and a.create_time >= #{startTime} | ||||
| and a.create_time <= #{endTime} | and a.create_time <= #{endTime} | ||||
| </select> | </select> | ||||
| <select id="getActionLog" resultType="com.iformall.domain.vo.WxCouponActionLogVo"> | |||||
| SELECT cal.id AS actionId, | |||||
| cal.coupon_id AS couponId, | |||||
| cal.create_time AS createDate, | |||||
| cs.id AS couponSendId, | |||||
| c.title, | |||||
| cu.nick_name AS userName, | |||||
| cu.phone, | |||||
| mbu.NAME AS operator | |||||
| FROM wx_coupon_action_log cal | |||||
| LEFT JOIN wx_coupon_send cs ON cal.channel_id = cs.id | |||||
| LEFT JOIN wx_coupon_order co ON cal.coupon_order_id = co.id | |||||
| LEFT JOIN wx_coupon c ON cal.coupon_id = c.id | |||||
| LEFT JOIN wx_c_user cu ON cu.id = co.c_user_id | |||||
| LEFT JOIN wx_merchant_b_user mbu ON co.b_user_id = mbu.id | |||||
| WHERE cal.channel_type = #{channelType} | |||||
| AND cal.tenant_id = #{tenantId} | |||||
| AND mbu.merchant_id = #{merchantId} | |||||
| <if test=" null != beginDate "> | |||||
| and cal.create_time >= #{beginDate} | |||||
| </if> | |||||
| <if test=" null != endDate "> | |||||
| and cal.create_time <= #{endDate} | |||||
| </if> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||