From d553dfc2d401ef0f3b2e734642283beda7bdedf5 Mon Sep 17 00:00:00 2001 From: Burce Date: Fri, 23 Aug 2019 19:35:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E6=88=B7=E6=B3=A8=E5=88=B8->=E6=B3=A8?= =?UTF-8?q?=E5=88=B8=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../market/WxCouponSendController.java | 3 +- .../controller/WxCouponSendController.java | 31 ++++++- .../iformall/domain/vo/WxCouponSendVo.java | 2 + .../mapper/WxCouponActionLogMapper.java | 8 ++ .../service/WxCouponActionLogService.java | 14 ++- .../iformall/service/WxCouponSendService.java | 1 + .../impl/WxCouponActionLogServiceImpl.java | 23 ++++- .../mapper/WxCouponActionLogMapper.xml | 93 ++++++++++++------- 8 files changed, 133 insertions(+), 42 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java index eda708e9c..14bb6c622 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java @@ -49,7 +49,8 @@ public class WxCouponSendController extends BaseController { @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", 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 = "注券-列表") public ResultData list(@ModelAttribute WxCouponSend wxCouponSend, Integer pageNum, Integer pageSize) { diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java index 3c1e92c76..ae36bdf0f 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; import com.iformall.domain.po.*; +import com.iformall.domain.vo.WxCouponActionLogVo; import com.iformall.domain.vo.WxCouponSendVo; import com.iformall.enums.EnumCouponSendSendType; import com.iformall.enums.EnumCouponSendStatus; @@ -11,6 +12,7 @@ import com.iformall.exception.MallinkException; import com.iformall.mapper.WxCUserMapper; import com.iformall.service.WxCouponActionLogService; import com.iformall.service.WxCouponSendService; +import com.iformall.utils.DateUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -24,8 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -import java.util.Arrays; -import java.util.Objects; +import java.util.*; @RestController @RequestMapping("/api/couponSend") @@ -72,6 +73,7 @@ public class WxCouponSendController extends BaseController { @ApiImplicitParam(name = "cUserId", value = "用户ID", dataType = "long", paramType = "query", required = true), }) public ResultData handSel(Long[] wxCouponSendIds, Long cUserId) { + logger.debug("[" + getIpAddr() + "] WxCouponSendController::handSel"); WxCUser cu = wxCUserMapper.selectByPrimaryKey(cUserId); if (Objects.isNull(cu)) { throw new MallinkException(ErrorCode.USER_IS_EMPTY); @@ -90,5 +92,30 @@ public class WxCouponSendController extends BaseController { 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 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 data = wxCouponActionLogService.getActionLog(params,pageNum,pageSize) ; + return new ResultData(data); + } + } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponSendVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponSendVo.java index dc1bf0020..53b5e491a 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponSendVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponSendVo.java @@ -33,4 +33,6 @@ public class WxCouponSendVo extends WxCouponSend implements Serializable{ /**发卷所属商户名**/ private String merchantName; + + private Date sendDate ; } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java index dd19a6a04..b04f7a851 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponActionLogMapper.java @@ -6,6 +6,7 @@ import com.iformall.domain.dto.MarkingCouponDataReportDto; import com.iformall.domain.vo.MarkingSceneDataReportTVo; import com.iformall.domain.vo.MarkingSceneDataReportVo; import com.iformall.domain.vo.MarkingSceneDataVo; +import com.iformall.domain.vo.WxCouponActionLogVo; import org.apache.ibatis.annotations.Param; import com.iformall.domain.po.WxCouponActionLog; @@ -53,4 +54,11 @@ public interface WxCouponActionLogMapper extends CommonMapper params); + + /** + * 查找注券记录 + * @param params + * @return + */ + List getActionLog(Map params) ; } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponActionLogService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponActionLogService.java index 6ef78390c..028aafae9 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponActionLogService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponActionLogService.java @@ -2,6 +2,10 @@ package com.iformall.service; import com.github.pagehelper.PageInfo; import com.iformall.domain.po.WxCouponActionLog; +import com.iformall.domain.vo.WxCouponActionLogVo; + +import java.util.List; +import java.util.Map; public interface WxCouponActionLogService { @@ -42,6 +46,14 @@ public interface WxCouponActionLogService { int getCountByChannelId(String tenantId, int channelType, Long channelId); - + + /** + * 查找注券记录 + * @param params + * @param pageNum + * @param pageSize + * @return + */ + PageInfo getActionLog(Map params, Integer pageNum, Integer pageSize) ; } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java index e16d20bf8..fec6f59ac 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java @@ -93,4 +93,5 @@ public interface WxCouponSendService { void handSel(WxCouponSend wxCouponSend, WxCUser user) ; + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java index 278118583..0ad214d14 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java @@ -2,9 +2,13 @@ package com.iformall.service.impl; import java.text.SimpleDateFormat; import java.util.*; + import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.iformall.common.ErrorCode; 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.service.WxCouponActionLogService; import org.slf4j.Logger; @@ -12,12 +16,13 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.iformall.common.IdWorker; +import org.springframework.util.CollectionUtils; @Service public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - @Autowired + + @Autowired WxCouponActionLogMapper wxCouponActionLogMapper; @@ -36,7 +41,7 @@ public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { if (record.getId() == null) { //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); + record.setId(idWorker.nextId()); wxCouponActionLogMapper.insertSelective(record); } else { wxCouponActionLogMapper.updateByPrimaryKeySelective(record); @@ -58,7 +63,8 @@ public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { actionLog.setCouponOrderId(coupon_order_id); actionLog.setChannelType(channelType); actionLog.setCreateTime(curDate); - actionLog.setCreateTimeMd(new SimpleDateFormat("MM/dd").format(curDate));; + actionLog.setCreateTimeMd(new SimpleDateFormat("MM/dd").format(curDate)); + ; saveOrUpdate(actionLog); } @@ -67,4 +73,13 @@ public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { return wxCouponActionLogMapper.getCountByChannelId(tenantId, channelType, channelId); } + @Override + public PageInfo getActionLog(Map 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)); + } + } diff --git a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml index ad31c0b2e..51eff3e3a 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml @@ -10,44 +10,44 @@ - + `id`,`tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time` where 1 = 1 - - - and `id` = #{id} - - - - + + + and `id` = #{id} + + + + and `tenant_id` = #{tenantId} - - - - - and `coupon_id` = #{couponId} - - - - - and `coupon_order_id` = #{couponOrderId} - - - - - and `channel_type` = #{channelType} - - - - - and `channel_id` = #{channelId} - - - + + + + + and `coupon_id` = #{couponId} + + + + + and `coupon_order_id` = #{couponOrderId} + + + + + and `channel_type` = #{channelType} + + + + + and `channel_id` = #{channelId} + + + and `create_time` = #{createTime} @@ -59,14 +59,14 @@ - and id in + and id in #{idItem} - + order by ${sortColumns} - + +