1231123
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
package com.ruoyi.web.controller.cai.admin;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.AccountCash;
|
||||
import com.ruoyi.cai.dto.admin.common.IdsReq;
|
||||
import com.ruoyi.cai.dto.admin.vo.AccountCashAdminVo;
|
||||
import com.ruoyi.cai.dto.admin.vo.account.ExportBatchAuditVo;
|
||||
import com.ruoyi.cai.dto.admin.vo.accountCash.AccountCashExportVo;
|
||||
import com.ruoyi.cai.enums.AccountCashStatusEnum;
|
||||
import com.ruoyi.cai.mapper.AccountCashMapper;
|
||||
import com.ruoyi.cai.service.AccountCashService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.convert.ExcelBigNumberConvert;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
@@ -25,8 +31,11 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -45,6 +54,8 @@ import java.util.stream.Collectors;
|
||||
public class AccountCashController extends BaseController {
|
||||
|
||||
private final AccountCashService accountCashService;
|
||||
@Resource
|
||||
private AccountCashMapper accountCashMapper;
|
||||
|
||||
/**
|
||||
* 查询用户提现记录列表
|
||||
@@ -67,14 +78,31 @@ public class AccountCashController extends BaseController {
|
||||
query.setPageSize(Integer.MAX_VALUE);
|
||||
query.setPageNum(1);
|
||||
List<AccountCashAdminVo> list = accountCashService.pageAdmin(query,bo).getRecords();
|
||||
ExcelUtil.exportExcel(list, "用户提现记录", AccountCashAdminVo.class, response);
|
||||
List<AccountCashExportVo> mergeList = accountCashMapper.exportMerge(bo);
|
||||
try {
|
||||
ExcelUtil.resetResponse("用户提现", response);
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
ExcelWriter excelWriter = EasyExcel.write(os).autoCloseStream(false)
|
||||
// 自动适配
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
// 添加下拉框操作
|
||||
// builder.registerWriteHandler(new ExcelDownHandler(null));
|
||||
// 大数值自动转换 防止失真
|
||||
.registerConverter(new ExcelBigNumberConvert()).build();
|
||||
excelWriter.write(mergeList, EasyExcel.writerSheet(0, "用户提现汇总").head(AccountCashExportVo.class).build());
|
||||
excelWriter.write(list, EasyExcel.writerSheet(1, "用户提现明细").head(AccountCashAdminVo.class).build());
|
||||
excelWriter.finish();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("导出Excel异常");
|
||||
}
|
||||
// ExcelUtil.exportExcel(list, "用户提现记录", AccountCashAdminVo.class, response);
|
||||
}
|
||||
|
||||
@Log(title = "用户导入提现通过", businessType = BusinessType.IMPORT)
|
||||
@SaCheckPermission("cai:accountCash:edit")
|
||||
@PostMapping(value = "/importAudit", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<ExportBatchAuditVo> importData(@RequestPart("file") MultipartFile file) throws Exception {
|
||||
List<AccountCashAdminVo> result = ExcelUtil.importExcel(file.getInputStream(), AccountCashAdminVo.class);
|
||||
List<AccountCashAdminVo> result = ExcelUtil.importExcel(file.getInputStream(), AccountCashAdminVo.class,"用户提现明细");
|
||||
List<Long> ids = result.stream().map(AccountCash::getId).collect(Collectors.toList());
|
||||
ExportBatchAuditVo audit = accountCashService.batchAudit(ids);
|
||||
return R.ok(audit);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.ruoyi.cai.dto.admin.vo.accountCash;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.ruoyi.cai.enums.AccountCashStatusEnum;
|
||||
import com.ruoyi.cai.enums.IsAnchorEnum;
|
||||
import com.ruoyi.common.annotation.ExcelEnumFormat;
|
||||
import com.ruoyi.common.convert.ExcelEnumConvert;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.NumberFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class AccountCashExportVo {
|
||||
@ExcelProperty(value = "提现次数")
|
||||
private Integer cashNum;
|
||||
|
||||
@ExcelProperty(value = "昵称")
|
||||
private String nickname;
|
||||
|
||||
@ExcelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ExcelProperty(value = "主播",converter = ExcelEnumConvert.class)
|
||||
@ExcelEnumFormat(enumClass = IsAnchorEnum.class,codeField = "code",textField = "message")
|
||||
private Integer isAnchor;
|
||||
|
||||
@ExcelProperty(value = "提现紫贝")
|
||||
private Long withdrawCoin;
|
||||
|
||||
@ExcelProperty(value = "提现金额")
|
||||
@NumberFormat(pattern = "0.##")
|
||||
// @ContentFontStyle(color = Font.COLOR_RED)
|
||||
private BigDecimal cashMoney;
|
||||
|
||||
/**
|
||||
* 银行名称
|
||||
*/
|
||||
@ExcelProperty(value = "银行名称")
|
||||
private String bank;
|
||||
/**
|
||||
* 账户名称
|
||||
*/
|
||||
@ExcelProperty(value = "账户名称")
|
||||
private String cardName;
|
||||
|
||||
@ExcelProperty(value = "账户")
|
||||
private String cardAccount;
|
||||
|
||||
@ExcelProperty(value = "状态",converter = ExcelEnumConvert.class)
|
||||
@ExcelEnumFormat(enumClass = AccountCashStatusEnum.class,codeField = "code",textField = "text")
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty(value = "ids")
|
||||
@ColumnWidth(value = 20)
|
||||
private String ids;
|
||||
}
|
||||
@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.dto.admin.incomeStatis.AccountCashCountDTO;
|
||||
import com.ruoyi.cai.domain.AccountCash;
|
||||
import com.ruoyi.cai.dto.admin.vo.AccountCashAdminVo;
|
||||
import com.ruoyi.cai.dto.admin.vo.accountCash.AccountCashExportVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户提现记录Mapper接口
|
||||
@@ -20,4 +22,6 @@ public interface AccountCashMapper extends BaseMapper<AccountCash> {
|
||||
Page<AccountCashAdminVo> pageAdmin(@Param("build") Page<Object> build, @Param("bo") AccountCashAdminVo bo);
|
||||
|
||||
AccountCashCountDTO incomeStatistics(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
|
||||
|
||||
List<AccountCashExportVo> exportMerge(@Param("bo") AccountCashAdminVo bo);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</where>
|
||||
order by t1.create_time desc
|
||||
</select>
|
||||
<select id="exportMerge" resultType="com.ruoyi.cai.dto.admin.vo.accountCash.AccountCashExportVo">
|
||||
select
|
||||
group_concat(t1.id) as ids,
|
||||
count(1) as cash_num,
|
||||
t2.nickname, t2.mobile, t2.is_anchor,
|
||||
sum(t1.withdraw_coin) as withdraw_coin, sum(t1.cash_money) as cash_money,
|
||||
t1.bank, t1.card_name, t1.card_account, t1.status
|
||||
from cai_account_cash t1
|
||||
left join cai_user t2 on t1.user_id = t2.id
|
||||
where t1.status = 1
|
||||
<if test="bo.cardName != null and bo.cardName != ''">
|
||||
and t1.card_name like concat('%',#{bo.cardName},'%')
|
||||
</if>
|
||||
<if test="bo.cardAccount != null and bo.cardAccount != ''">
|
||||
and t1.card_account like concat('%',#{bo.cardAccount},'%')
|
||||
</if>
|
||||
<if test="bo.mobile != null and bo.mobile != ''">
|
||||
and t2.mobile = #{bo.mobile}
|
||||
</if>
|
||||
<if test="bo.usercode != null and bo.usercode != ''">
|
||||
and t2.usercode = #{bo.usercode}
|
||||
</if>
|
||||
<if test="bo.status != null">
|
||||
|
||||
</if>
|
||||
<if test="bo.id != null">
|
||||
and t1.id = #{bo.id}
|
||||
</if>
|
||||
group by t1.user_id, t1.card_name, t1.card_account
|
||||
order by t1.create_time desc
|
||||
</select>
|
||||
<select id="incomeStatistics" resultType="com.ruoyi.cai.dto.admin.incomeStatis.AccountCashCountDTO">
|
||||
select
|
||||
sum(cash_money) as cash_money,
|
||||
@@ -57,5 +88,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where status = 2 and create_time between #{startTime} and #{endTime}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -45,6 +45,10 @@ public class ExcelUtil {
|
||||
return EasyExcel.read(is).head(clazz).autoCloseStream(false).sheet().doReadSync();
|
||||
}
|
||||
|
||||
public static <T> List<T> importExcel(InputStream is, Class<T> clazz,String sheetName) {
|
||||
return EasyExcel.read(is).head(clazz).autoCloseStream(false).sheet(sheetName).doReadSync();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 使用校验监听器 异步导入 同步返回
|
||||
@@ -306,7 +310,7 @@ public class ExcelUtil {
|
||||
/**
|
||||
* 重置响应体
|
||||
*/
|
||||
private static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException {
|
||||
public static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException {
|
||||
String filename = encodingFilename(sheetName);
|
||||
FileUtils.setAttachmentResponseHeader(response, filename);
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
|
||||
|
||||
Reference in New Issue
Block a user