From e536b455174b789aa19e7b228e257a7736882a68 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Thu, 18 Jul 2019 14:01:08 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=A7=AF=E5=88=86=E5=8F=98=E6=9B=B4=E8=AE=B0?= =?UTF-8?q?=E5=BD=95][=E4=BF=AE=E6=94=B9][=E6=9F=A5=E8=AF=A2=E5=8F=8A?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=95=B0=E6=8D=AE]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mem/WxCreditHistoryController.java | 10 +++ .../iformall/domain/po/WxCreditHistory.java | 4 +- .../iformall/domain/vo/WxCreditHistoryVo.java | 61 +++++++++++-------- .../service/WxCreditHistoryService.java | 5 ++ .../impl/WxCreditHistoryServiceImpl.java | 22 ++++++- .../mapper/WxCreditHistoryMapper.xml | 3 + 6 files changed, 79 insertions(+), 26 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java index 7e254744f..4d64a734c 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java @@ -18,6 +18,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + @RestController @RequestMapping("wxCreditHistory") public class WxCreditHistoryController extends BaseController { @@ -87,4 +90,11 @@ public class WxCreditHistoryController extends BaseController { return new ResultData(Result.SUCCESS); } + @GetMapping("exportData") + @SystemControllerLog(description = "积分历史-导出数据") + public void exportData(@ModelAttribute WxCreditHistory wxCreditHistory, HttpServletRequest request, HttpServletResponse response) { + wxCreditHistory.setTenantId(getTenantId()); + wxCreditHistoryService.exportData(request, response, wxCreditHistory); + } + } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCreditHistory.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCreditHistory.java index c90fb3c72..4b73d3cf9 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCreditHistory.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCreditHistory.java @@ -72,7 +72,9 @@ public class WxCreditHistory implements Serializable { @io.swagger.annotations.ApiModelProperty(value="兑换用途",name="changePurpose") private String changePurpose; - + @Transient + @io.swagger.annotations.ApiModelProperty(value = "商户名称", name = "merchantName") + private String merchantName; public static enum Field { diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxCreditHistoryVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxCreditHistoryVo.java index 1282cef75..e5e5506eb 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxCreditHistoryVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxCreditHistoryVo.java @@ -1,5 +1,6 @@ package com.iformall.domain.vo; +import cn.afterturn.easypoi.excel.annotation.Excel; import lombok.Data; import java.util.Date; @@ -7,51 +8,63 @@ import java.util.Date; @Data public class WxCreditHistoryVo { - @io.swagger.annotations.ApiModelProperty(value="手机号",name="phone") - private String phone; + @Excel(name = "微信昵称", width = 20, orderNum = "1") @io.swagger.annotations.ApiModelProperty(value="姓名",name="name") private String name; + @Excel(name = "手机号", width = 20, orderNum = "2") + @io.swagger.annotations.ApiModelProperty(value = "手机号", name = "phone") + private String phone; + + @Excel(name = "性别", width = 20, orderNum = "3") @io.swagger.annotations.ApiModelProperty(value="性别",name="sex") private String sex; - @io.swagger.annotations.ApiModelProperty(value="积分ID",name="creditId") - private String creditId; + @Excel(name = "总积分", width = 20, orderNum = "4") + @io.swagger.annotations.ApiModelProperty(value = "总积分", name = "creditAmount") + private Integer creditAmount; - @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") - private String tenantId; + @Excel(name = "积分操作", width = 20, orderNum = "5") + @io.swagger.annotations.ApiModelProperty(value = "每笔积分明细", name = "creditNum") + private Integer creditNum; - @io.swagger.annotations.ApiModelProperty(value="用户ID",name="cUserId") - private Long cUserId; + @Excel(name = "时间", width = 20, orderNum = "6", format = "yyyy-MM-dd HH:mm:ss") + @io.swagger.annotations.ApiModelProperty(value = "创建日期", name = "createDate") + private Date createDate; - @io.swagger.annotations.ApiModelProperty(value="总积分",name="creditAmount") - private Integer creditAmount; + @Excel(name = "消费商户", width = 20, orderNum = "7") + @io.swagger.annotations.ApiModelProperty(value = "商户", name = "merchantName") + private String merchantName; - @io.swagger.annotations.ApiModelProperty(value="每笔积分明细",name="creditNum") - private Integer creditNum; + @Excel(name = "积分来源", width = 20, orderNum = "8") + @io.swagger.annotations.ApiModelProperty(value = "操作人类型", name = "operator") + private Integer operatorType; - @io.swagger.annotations.ApiModelProperty(value="积分类型",name="creditType") + @Excel(name = "操作说明", width = 20, orderNum = "9", replace = {"每日登录_1", "消费_2", "绑车牌_3", "连接WIFI_4", "微信用户昵称授权_5", "微信用户手机授权_6", "完善个人信息_7", "会员导入_8", "会员成长值扣减_9", "新增积分_10", "积分兑换_11", "消费积分_12", "活动报名_13"}) + @io.swagger.annotations.ApiModelProperty(value = "积分类型", name = "creditType") private Integer creditType; - @io.swagger.annotations.ApiModelProperty(value="创建日期",name="createDate") - private Date createDate; - - @io.swagger.annotations.ApiModelProperty(value="小票URL",name="receiptUrl") + @Excel(name = "购物小票", width = 20, orderNum = "10") + @io.swagger.annotations.ApiModelProperty(value = "小票URL", name = "receiptUrl") private String receiptUrl; - @io.swagger.annotations.ApiModelProperty(value="商户",name="merchantName") - private String merchantName; + @Excel(name = "操作人", width = 20, orderNum = "11") + @io.swagger.annotations.ApiModelProperty(value = "操作人", name = "operator") + private String operator; - @io.swagger.annotations.ApiModelProperty(value="操作人类型",name="operator") - private Integer operatorType; + @io.swagger.annotations.ApiModelProperty(value="积分ID",name="creditId") + private String creditId; + + @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") + private String tenantId; + + @io.swagger.annotations.ApiModelProperty(value="用户ID",name="cUserId") + private Long cUserId; @io.swagger.annotations.ApiModelProperty(value="操作人ID",name="operatorId") private Long operatorId; - @io.swagger.annotations.ApiModelProperty(value="操作人",name="operator") - private String operator; - @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") private Long merchantId; diff --git a/mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java b/mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java index 1716adfe8..95195bb91 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java @@ -4,6 +4,8 @@ import com.github.pagehelper.PageInfo; import com.iformall.domain.po.WxCreditHistory; import com.iformall.domain.vo.WxCreditHistoryVo; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.Map; public interface WxCreditHistoryService { @@ -53,4 +55,7 @@ public interface WxCreditHistoryService { Map findByMerchantIdAndSpend(Long merchantId, String spendStr, String tenantId); void clearCreditByYear(); + + void exportData(HttpServletRequest request, HttpServletResponse response, WxCreditHistory wxCreditHistory); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java index a436124c7..2320f4ed3 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java @@ -13,6 +13,7 @@ import com.iformall.domain.vo.WxCreditHistoryVo; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; +import com.iformall.service.ExcelService; import com.iformall.service.WxCreditHistoryService; import com.iformall.service.WxScoreRulesService; import com.iformall.utils.RedisLock; @@ -23,6 +24,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -60,6 +63,9 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { @Autowired RedisLock redisLock; + @Autowired + ExcelService excelService; + @Override public void clearCreditByYear() { WxScoreRules wxScoreRules = new WxScoreRules(); @@ -69,6 +75,16 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { } + @Override + public void exportData(HttpServletRequest request, HttpServletResponse response, WxCreditHistory wxCreditHistory) { + List wxCreditHistoryVoList = wxCreditHistoryMapper.findListMore(wxCreditHistory); + if (!wxCreditHistoryVoList.isEmpty()) { + supplyCreditInfo(wxCreditHistoryVoList); + } + excelService.exportExcel(wxCreditHistoryVoList, null, "积分变更记录", WxCreditHistoryVo.class, "积分变更记录.xlsx", response, false); + + } + @Override public PageInfo listAsPage(WxCreditHistory record, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCreditHistoryMapper.findList(record)); @@ -81,6 +97,11 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { if (wxCreditHistoryVoList == null || wxCreditHistoryVoList.size() == 0) { return new PageInfo<>(wxCreditHistoryVoList); } + supplyCreditInfo(wxCreditHistoryVoList); + return new PageInfo<>(wxCreditHistoryVoList); + } + + public void supplyCreditInfo(List wxCreditHistoryVoList) { List cUserIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.CUSER.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); List cUserBasicIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.CUSERBASIC.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); List bUserIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.BUSER.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); @@ -142,7 +163,6 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { credit.setMerchantName(EnumMerchantType.MERCHANT_MORE.getMessage()); } } - return new PageInfo<>(wxCreditHistoryVoList); } @Override diff --git a/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml b/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml index 0468a353e..a02648645 100644 --- a/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml @@ -105,6 +105,9 @@ and credit.merchant_id = #{merchantId} + + and merchant.name like concat('%', #{merchantName},'%') +