Просмотр исходного кода

[需求][新增]:账单导出使用统一接口

release_toaliyun_real
hupeng 7 лет назад
Родитель
Сommit
36d933e6a7
6 измененных файлов: 354 добавлений и 25 удалений
  1. +265
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxBillAllVo.java
  2. +2
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxBillAllMapper.java
  3. +41
    -13
      mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java
  4. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java
  5. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxMerchantSubsidyServiceImpl.java
  6. +42
    -7
      mallinkService/src/main/resources/mapper/WxBillAllMapper.xml

+ 265
- 0
mallinkService/src/main/java/com/iformall/domain/vo/WxBillAllVo.java Просмотреть файл

@@ -0,0 +1,265 @@
package com.iformall.domain.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;

import java.math.BigDecimal;
import java.util.Date;

/**
* @author gongbiao
*/
public class WxBillAllVo {
Long id;

String tenantId;

Long merchantId;

Long shopId;

//@Excel(name="商铺号",width = 20,orderNum = "1")
String shopNumber;

//@Excel(name="商户名称",width = 20,orderNum = "2")
String merchantName;

//@Excel(name="商铺类型",width = 20,orderNum = "3", replace = {"店铺_1","多经点位_2"})
Integer rentShopType;

@Excel(name="费用类型",width = 20,orderNum = "4")
String billType;

@Excel(name="实际应收金额(元)",width = 20,orderNum = "5")
String receivePayStr;

@Excel(name="实收金额(元)",width = 20,orderNum = "6")
String payStr;

@Excel(name="欠缴金额(元)",width = 20,orderNum = "7")
String oweStr;

@Excel(name="缴款截止日期",width = 20,orderNum = "8", format="yyyy-MM-dd")
Date receiveDate;

@Excel(name="逾期天数",width = 20,orderNum = "9")
Integer expiredDay;

@Excel(name="账单状态",width = 20,orderNum = "10", replace = {"欠缴_1","待缴_2","已结清_3","未到期_4","已退还_5","失效_6"})
Integer status;

Integer billTypeValue;
Integer needPay;
Integer receivePay;
Integer pay;
Integer owe;
Date payDate;
Date starttime;
Date endtime;

String manager;
String managerPhone;


public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Long getMerchantId() {
return merchantId;
}

public void setMerchantId(Long merchantId) {
this.merchantId = merchantId;
}

public Long getShopId() {
return shopId;
}

public void setShopId(Long shopId) {
this.shopId = shopId;
}

public Integer getBillTypeValue() {
return billTypeValue;
}

public void setBillTypeValue(Integer billTypeValue) {
this.billTypeValue = billTypeValue;
}

public String getBillType() {
return billType;
}

public void setBillType(String billType) {
this.billType = billType;
}

public Integer getNeedPay() {
return needPay;
}

public void setNeedPay(Integer needPay) {
this.needPay = needPay;
}

public Integer getReceivePay() {
return receivePay;
}

public void setReceivePay(Integer receivePay) {
this.receivePay = receivePay;
}

public Integer getPay() {
return pay;
}

public void setPay(Integer pay) {
this.pay = pay;
}

public Integer getOwe() {
return owe;
}

public void setOwe(Integer owe) {
this.owe = owe;
}

public Date getReceiveDate() {
return receiveDate;
}

public void setReceiveDate(Date receiveDate) {
this.receiveDate = receiveDate;
}

public Date getPayDate() {
return payDate;
}

public void setPayDate(Date payDate) {
this.payDate = payDate;
}

public Integer getExpiredDay() {
return expiredDay;
}

public void setExpiredDay(Integer expiredDay) {
this.expiredDay = expiredDay;
}

public Integer getStatus() {
return status;
}

public void setStatus(Integer status) {
this.status = status;
}

public String getTenantId() {
return tenantId;
}

public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}

public Date getStarttime() {
return starttime;
}

public void setStarttime(Date starttime) {
this.starttime = starttime;
}

public Date getEndtime() {
return endtime;
}

public void setEndtime(Date endtime) {
this.endtime = endtime;
}


public Integer getRentShopType() {
return rentShopType;
}

public void setRentShopType(Integer rentShopType) {
this.rentShopType = rentShopType;
}

public String getMerchantName() {
return merchantName;
}

public void setMerchantName(String merchantName) {
this.merchantName = merchantName;
}

public String getShopNumber() {
return shopNumber;
}

public void setShopNumber(String shopNumber) {
this.shopNumber = shopNumber;
}

public String getManager() {
return manager;
}

public void setManager(String manager) {
this.manager = manager;
}

public String getManagerPhone() {
return managerPhone;
}

public void setManagerPhone(String managerPhone) {
this.managerPhone = managerPhone;
}


public String getReceivePayStr() {
if(getReceivePay()!=null) {
receivePayStr = new BigDecimal(getReceivePay()).divide(new BigDecimal(100)).toString();
}
return receivePayStr;
}

public void setReceivePayStr(String receivePayStr) {
this.receivePayStr = receivePayStr;
}

public String getPayStr() {
if(getPay()!=null) {
payStr = new BigDecimal(getPay()).divide(new BigDecimal(100)).toString();
}
return payStr;
}

public void setPayStr(String payStr) {
this.payStr = payStr;
}

public String getOweStr() {
if(getOwe()!=null) {
oweStr = new BigDecimal(getOwe()).divide(new BigDecimal(100)).toString();
}
return oweStr;
}

public void setOweStr(String oweStr) {
this.oweStr = oweStr;
}
}

+ 2
- 1
mallinkService/src/main/java/com/iformall/mapper/WxBillAllMapper.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.iformall.mapper;

import com.iformall.domain.vo.WxBillAll;
import com.iformall.domain.vo.WxBillAllVo;

import java.util.List;
import java.util.Map;
@@ -11,7 +12,7 @@ import java.util.Map;
public interface WxBillAllMapper {


List<Map<String,Object>> list(WxBillAll record);
List<WxBillAllVo> list(WxBillAll record);

Map<String,Object> queryOweInfo(WxBillAll record);



+ 41
- 13
mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java Просмотреть файл

@@ -1,22 +1,18 @@
package com.iformall.service.impl;

import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.github.pagehelper.PageHelper;
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.WxBillAll;
import com.iformall.domain.vo.WxBillAllVo;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.*;
import com.iformall.service.*;
import com.iformall.utils.Constant;
import com.iformall.utils.DateUtils;
import org.apache.commons.io.FileUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -24,8 +20,7 @@ import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;

import java.util.*;
import java.util.stream.Collectors;

@@ -81,13 +76,15 @@ public class WxBillAllServiceImpl implements WxBillAllService {
@Autowired
WxBillOtherDepositMapper wxBillOtherDepositMapper;

@Autowired
ExcelService excelService;

@Override
public Map<String, Object> listAsPage(WxBillAll record, Integer pageIndex, Integer pageSize) {
//更新各账单状态
updateBillStatus(record);
PageHelper.startPage(pageIndex, pageSize);
List<Map<String, Object>> billList = wxBillAllMapper.list(record);
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(billList);
PageInfo<WxBillAllVo> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBillAllMapper.list(record));

Map<String, Object> result = new HashMap<>();
result.put("pageInfo", pageInfo);
return result;
@@ -193,6 +190,37 @@ public class WxBillAllServiceImpl implements WxBillAllService {
}
}

@Override
public void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillAll wxBillAll) {

Map<Long, List<WxBillAllVo>> billMapList = wxBillAllMapper.list(wxBillAll)
.parallelStream()
.collect(Collectors.groupingBy(WxBillAllVo::getMerchantId));

List<Map<String, Object>> list = new ArrayList<>();

Iterator<Map.Entry<Long, List<WxBillAllVo>>> entries = billMapList.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<Long, List<WxBillAllVo>> entry = entries.next();
Map<String,Object> map = new HashMap<>();
ExportParams deptExportParams = new ExportParams();
WxBillAllVo first = ((List<WxBillAllVo>)(entry.getValue())).get(0);
deptExportParams.setSheetName(first.getMerchantName());
deptExportParams.setTitle(first.getMerchantName()
+ "("
+ EnumRentShopType.getEnum((Integer)first.getRentShopType()).getMessage()
+ "-"+first.getShopNumber()
+ ")");
//deptExportParams.setSecondTitle();
map.put("title", deptExportParams);
map.put("entity", WxBillAllVo.class);
map.put("data", entry.getValue());
list.add(map);
}

excelService.exportExcel(list, "账单数据.xls", response);
}
/*
@Override
public void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillAll wxBillAll) {
//得到当前月
@@ -332,7 +360,7 @@ public class WxBillAllServiceImpl implements WxBillAllService {
e.printStackTrace();
}
}
*/
private int updateBillOther(Map<String, Object> bill) {
logger.info("updateBillOther params:"+bill.toString());
Object id = bill.get("id");


+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java Просмотреть файл

@@ -594,7 +594,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
e.printStackTrace();
}
}
*/
public void downFile(String filePath, String filename, String exportFileName,
HttpServletResponse response, HttpServletRequest req) throws IOException {
try {
@@ -624,5 +624,5 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
e.printStackTrace();
}
}
*/
}

+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxMerchantSubsidyServiceImpl.java Просмотреть файл

@@ -167,7 +167,7 @@ public class WxMerchantSubsidyServiceImpl implements WxMerchantSubsidyService {
e.printStackTrace();
}
}
*/

public void downFile(String filePath, String filename, String exportFileName,
HttpServletResponse response, HttpServletRequest req) throws IOException {
@@ -198,6 +198,6 @@ public class WxMerchantSubsidyServiceImpl implements WxMerchantSubsidyService {
e.printStackTrace();
}
}
*/
}

+ 42
- 7
mallinkService/src/main/resources/mapper/WxBillAllMapper.xml Просмотреть файл

@@ -1,13 +1,48 @@
<?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.WxBillAllMapper">
<select id="list" parameterType="com.iformall.domain.vo.WxBillAll" resultType="hashmap">
select bill.id,bill.merchant_id merchantId,bill.shop_id shopId,bill.bill_type_value billTypeValue,bill.bill_type billType,bill.need_pay needPay,
bill.receive_pay receivePay,bill.pay,bill.owe,bill.receive_date receiveDate,bill.pay_date payDate,bill.expired_day expiredDay,bill.status,
bill.tenant_id tenantId,m.name merchantName,s.shop_number
shopNumber,bill.starttime,bill.endtime,bill.name,s.manager,s.manager_phone managerPhone,
bill.rent_shop_type rentShopType from (


<resultMap id="allVoResultMap" type="com.iformall.domain.vo.WxBillAllVo">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="tenantId" jdbcType="VARCHAR" property="tenantId" />
<result column="merchantId" jdbcType="INTEGER" property="merchantId" />
<result column="shopId" jdbcType="INTEGER" property="shopId" />

<result column="billTypeValue" jdbcType="INTEGER" property="billTypeValue"/>
<result column="billType" jdbcType="VARCHAR" property="billType"/>
<result column="needPay" jdbcType="INTEGER" property="needPay" />

<result column="merchantName" jdbcType="VARCHAR" property="merchantName" />
<result column="rentShopType" jdbcType="INTEGER" property="rentShopType"/>
<result column="receiveDate" jdbcType="TIMESTAMP" property="receiveDate" />
<result column="expiredDay" jdbcType="INTEGER" property="expiredDay" />
<result column="status" jdbcType="INTEGER" property="status" />


<result column="receivePay" jdbcType="INTEGER" property="receivePay" />
<result column="owe" jdbcType="INTEGER" property="owe" />
<result column="pay" jdbcType="INTEGER" property="pay" />
<result column="payDate" jdbcType="TIMESTAMP" property="payDate" />
<result column="starttime" jdbcType="TIMESTAMP" property="starttime" />
<result column="endtime" jdbcType="TIMESTAMP" property="endtime" />

<result column="shopNumber" jdbcType="VARCHAR" property="shopNumber"/>
<result column="manager" jdbcType="VARCHAR" property="manager"/>
<result column="managerPhone" jdbcType="VARCHAR" property="managerPhone"/>
</resultMap>


<select id="list" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
select
bill.id,bill.tenant_id tenantId,bill.merchant_id merchantId,bill.shop_id shopId,
bill.bill_type_value billTypeValue,bill.bill_type billType,bill.need_pay needPay,
bill.receive_pay receivePay,bill.pay,bill.owe,bill.receive_date receiveDate,bill.pay_date payDate,
bill.expired_day expiredDay,bill.status,
bill.starttime,bill.endtime,bill.name,bill.rent_shop_type rentShopType,
m.name merchantName,
s.shop_number shopNumber, s.manager, s.manager_phone managerPhone
from (
select id,merchant_id,shop_id,tenant_id,'租金' name,1 bill_type_value,'租金'
bill_type,need_pay,receive_pay,pay,owe,receive_date,pay_date,expired_day,status,'' starttime,''
endtime,rent_shop_type from wx_bill_rent where is_preview = 0


Загрузка…
Отмена
Сохранить