v1.1 后台-用户账单查询
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.shardingsphere</groupId>
|
||||
<artifactId>sharding-jdbc-core</artifactId>
|
||||
<version>4.0.0-RC2</version>
|
||||
<version>4.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.accompany</groupId>
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.accompany.admin.service.user;
|
||||
|
||||
import com.accompany.admin.common.BusinessException;
|
||||
import com.accompany.admin.service.base.BaseService;
|
||||
import com.accompany.admin.vo.BillRecordVo;
|
||||
import com.accompany.business.model.Gift;
|
||||
@@ -13,10 +12,14 @@ import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.enumeration.BillObjTypeEnum;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.accompany.payment.model.ChargeRecord;
|
||||
import com.accompany.payment.service.ChargeRecordService;
|
||||
import com.accompany.sharding.mapper.BillRecordMapper;
|
||||
import com.accompany.sharding.model.BillRecord;
|
||||
import com.accompany.sharding.vo.BillRecordGroupVo;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -25,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -43,8 +48,18 @@ public class BillRecordAdminService extends BaseService {
|
||||
private BillRecordService billRecordService;
|
||||
@Autowired
|
||||
private GiftService giftService;
|
||||
@Autowired
|
||||
private ChargeRecordService chargeRecordService;
|
||||
|
||||
public PageInfo<BillRecord> getBillRecordList(Integer pageNum, Integer pageSize, Byte billType, Long uid, String startDate, String endDate){
|
||||
public void pageBillRecordList(Page<BillRecord> page, Long erbanNo, Byte billType, String startDate, String endDate){
|
||||
Long uid = null;
|
||||
if (erbanNo != null) {
|
||||
Users users = usersBaseService.getUsersByErBanNo(erbanNo);
|
||||
if (users == null) {
|
||||
return;
|
||||
}
|
||||
uid = users.getUid();
|
||||
}
|
||||
|
||||
List<Byte> bList = new ArrayList<>();
|
||||
QueryWrapper<BillRecord> wrapper = new QueryWrapper<>();
|
||||
@@ -57,15 +72,15 @@ public class BillRecordAdminService extends BaseService {
|
||||
bList.add(billType);
|
||||
}
|
||||
}
|
||||
wrapper.lambda().eq(uid != null, BillRecord::getUid,uid)
|
||||
|
||||
wrapper.lambda().eq(uid != null, BillRecord::getUid, uid)
|
||||
.ge(!BlankUtil.isBlank(startDate), BillRecord::getCreateTime, DateTimeUtil.convertStrToDate(startDate))
|
||||
.le(!BlankUtil.isBlank(endDate),BillRecord::getCreateTime, DateTimeUtil.convertStrToDate(endDate));
|
||||
if (!CollectionUtils.isEmpty(bList)) {
|
||||
wrapper.lambda().in(BillRecord::getObjType, bList);
|
||||
}
|
||||
wrapper.lambda().orderByDesc(BillRecord::getCreateTime);
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
return new PageInfo<>(billRecordService.list(wrapper));
|
||||
billRecordService.page(page, wrapper);
|
||||
}
|
||||
|
||||
public List<BillRecordVo> convertVoList(List<BillRecord> list) {
|
||||
@@ -77,13 +92,21 @@ public class BillRecordAdminService extends BaseService {
|
||||
List<Users> usersList = usersBaseService.getUsersListByUids(uids);
|
||||
Map<Long, Long> erbanNoMap = usersList.stream().collect(Collectors.toMap(Users::getUid, Users::getErbanNo));
|
||||
Map<Long, String> nickMap = usersList.stream().collect(Collectors.toMap(Users::getUid, Users::getNick));
|
||||
|
||||
List<Long> roomUids = list.stream().map(BillRecord::getRoomUid).collect(Collectors.toList());
|
||||
List<Users> roomUsersList = usersBaseService.getUsersListByUids(roomUids);
|
||||
Map<Long, Long> roomErbanNoMap = roomUsersList.stream().collect(Collectors.toMap(Users::getUid, Users::getErbanNo));
|
||||
Map<Long, String> roomNickMap = roomUsersList.stream().collect(Collectors.toMap(Users::getUid, Users::getNick));
|
||||
|
||||
List<Integer> giftIds = list.stream().map(BillRecord::getGiftId).collect(Collectors.toList());
|
||||
List<Gift> giftList = giftService.getGiftByIdsFromDb(giftIds);
|
||||
Map<Integer, String> giftNameMap = giftList.stream().collect(Collectors.toMap(Gift::getGiftId, Gift::getGiftName));
|
||||
|
||||
List<String> chargeRecordIds = list.stream().filter(b->b.getBillType() == BillObjTypeEnum.CHARGE.getValue() || b.getBillType() == BillObjTypeEnum.OPEN_VIP.getValue())
|
||||
.map(BillRecord::getBillId).collect(Collectors.toList());
|
||||
List<ChargeRecord> chargeRecordList = chargeRecordService.listChargeRecordByIds(chargeRecordIds);
|
||||
Map<String, ChargeRecord> chargeRecordMap = chargeRecordList.stream().collect(Collectors.toMap(ChargeRecord::getChargeRecordId, c->c));
|
||||
|
||||
List<BillRecordVo> voList = new ArrayList<>(list.size());
|
||||
|
||||
Map<Long, Users> userMap = new HashMap<>();
|
||||
@@ -109,6 +132,14 @@ public class BillRecordAdminService extends BaseService {
|
||||
if (billRecordAdminVo.getGiftId() != null) {
|
||||
billRecordAdminVo.setGiftName(giftNameMap.getOrDefault(billRecordAdminVo.getGiftId(), null));
|
||||
}
|
||||
if (billRecordAdminVo.getObjType() == BillObjTypeEnum.CHARGE.getValue()
|
||||
|| billRecordAdminVo.getObjType() == BillObjTypeEnum.OPEN_VIP.getValue()){
|
||||
ChargeRecord chargeRecord = chargeRecordMap.get(billRecordAdminVo.getObjId());
|
||||
if (null != chargeRecord){
|
||||
billRecordAdminVo.setLocalCurrencyCode(chargeRecord.getLocalCurrencyCode());
|
||||
billRecordAdminVo.setLocalAmount(new BigDecimal(chargeRecord.getLocalAmount()).divide(Constant.HUNDRED, 2, RoundingMode.HALF_UP));
|
||||
}
|
||||
}
|
||||
voList.add(billRecordAdminVo);
|
||||
}
|
||||
return voList;
|
||||
|
@@ -33,9 +33,13 @@ public class BillRecordVo extends BaseVo {
|
||||
public String roomNick;
|
||||
@FieldComment("钻石/水晶/金币")
|
||||
public BigDecimal amount;
|
||||
@FieldComment("人民币数")
|
||||
@FieldComment("货币数")
|
||||
public BigDecimal localAmount;
|
||||
@FieldComment("本地货币代码")
|
||||
public String localCurrencyCode;
|
||||
@FieldComment("货币数")
|
||||
public BigDecimal actualAmount;
|
||||
@FieldComment("货币")
|
||||
@FieldComment("游戏货币")
|
||||
public String currencyDesc;
|
||||
@FieldComment("收入支出")
|
||||
public String billTypeDesc;
|
||||
@@ -43,6 +47,7 @@ public class BillRecordVo extends BaseVo {
|
||||
public String objTypeDesc;
|
||||
@FieldComment("账单类型code")
|
||||
private Byte objType;
|
||||
private String objId;
|
||||
@FieldComment("账单创建时间")
|
||||
public Date createTime;
|
||||
@FieldComment("备注")
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package com.accompany.admin.controller.user;
|
||||
|
||||
import com.accompany.admin.base.Pagination;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.service.user.BillRecordAdminService;
|
||||
import com.accompany.admin.vo.BillRecordVo;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.accompany.core.util.ExcelUtils;
|
||||
@@ -16,6 +18,7 @@ import com.google.common.collect.Lists;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@@ -32,49 +35,32 @@ import java.util.*;
|
||||
@ResponseBody
|
||||
public class BillRecordAdminController extends BaseController {
|
||||
@Autowired
|
||||
BillRecordAdminService billRecordAdminService;
|
||||
@Autowired
|
||||
UsersService usersService;
|
||||
|
||||
@Autowired
|
||||
private UsersBaseService usersBaseService;
|
||||
private BillRecordAdminService billRecordAdminService;
|
||||
|
||||
|
||||
@RequestMapping("/getList")
|
||||
@ResponseBody
|
||||
public void getBillRecordList(Byte billType,Long erbanNo,String startDate,String endDate){
|
||||
Long uid = null;
|
||||
if (erbanNo != null) {
|
||||
Users users = usersBaseService.getUsersByErBanNo(erbanNo);
|
||||
if (users == null) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("total",0);
|
||||
jsonObject.put("rows", Collections.emptyList());
|
||||
|
||||
writeJson(jsonObject.toJSONString());
|
||||
return;
|
||||
}
|
||||
uid = users.getUid();
|
||||
public Pagination getBillRecordList(Long erbanNo, Byte billType, String startDate, String endDate){
|
||||
Page<BillRecord> page = new Page<>(getPageNumber(), getPageSize());
|
||||
billRecordAdminService.pageBillRecordList(page, erbanNo, billType, startDate, endDate);
|
||||
Pagination p = new Pagination(page);
|
||||
if (!CollectionUtils.isEmpty(page.getRecords())){
|
||||
p.setRows(billRecordAdminService.convertVoList(page.getRecords()));
|
||||
}
|
||||
PageInfo<BillRecord> pageInfo = billRecordAdminService.getBillRecordList(getPageNumber(), getPageSize(), billType, uid, startDate, endDate);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("total", pageInfo.getTotal());
|
||||
jsonObject.put("rows", billRecordAdminService.convertVoList(pageInfo.getList()));
|
||||
|
||||
writeJson(jsonObject.toJSONString());
|
||||
return p;
|
||||
}
|
||||
|
||||
@RequestMapping("/exportList")
|
||||
@ResponseBody
|
||||
public void exportBillRecordList(Byte billType, Long erbanNo, String startDate, String endDate, HttpServletResponse response) throws Exception {
|
||||
Users users = usersBaseService.getUsersByErBanNo(erbanNo);
|
||||
public void exportBillRecordList(Long erbanNo, Byte billType, String startDate, String endDate, HttpServletResponse response) throws Exception {
|
||||
/*Users users = usersBaseService.getUsersByErBanNo(erbanNo);
|
||||
Long uid = users.getUid();
|
||||
PageInfo<BillRecord> pageInfo = billRecordAdminService.getBillRecordList(1,1000000, billType, uid, startDate, endDate);
|
||||
List<BillRecordVo> voList = billRecordAdminService.convertVoList(pageInfo.getList());
|
||||
String filename = erbanNo.toString() + "_bill_record";
|
||||
List<String> fields = Arrays.asList("nick", "erbanNo", "targetNick", "targetErbanNo", "roomNick", "roomErbanNo",
|
||||
"giftName", "giftNum", "actualAmount", "amount", "billTypeDesc", "objTypeDesc", "createTime");
|
||||
ExcelUtils.exportExcel("用户账单", filename, fields, voList, response);
|
||||
ExcelUtils.exportExcel("用户账单", filename, fields, voList, response);*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,15 +1,10 @@
|
||||
<style>
|
||||
#erbanNo,#billType,#startDate,#endDate{
|
||||
margin-right: 4px;
|
||||
}
|
||||
</style>
|
||||
<section class="content">
|
||||
<div class="box box-primary">
|
||||
<div class="box-body">
|
||||
<section class="content-header">
|
||||
<h1 id="itemTitle"></h1>
|
||||
</section>
|
||||
<div id="table"></div>
|
||||
<section class="content-body">
|
||||
<form id="form" action="" method="post" target="_blank">
|
||||
<input type="hidden" id="exportErbanNo" name = "erbanNo">
|
||||
<input type="hidden" id="exportBillType" name = "billType">
|
||||
@@ -17,14 +12,29 @@
|
||||
<input type="hidden" id="exportEndTime" name = "endDate">
|
||||
</form>
|
||||
<div id="toolbar">
|
||||
平台号:<input type="text" name="erbanNo" id="erbanNo" class="input-sm"/>
|
||||
账单类型:<select name="billType" id="billType">
|
||||
</select>
|
||||
开始时间:<input type="text" name="startDate" id="startDate" class="input-sm" >
|
||||
结束时间:<input type="text" name="endDate" id="endDate" class="input-sm" >
|
||||
<button id="btnSearch" class="btn btn-sm btn-primary">查询</button>
|
||||
<button id="btnExport" class="btn btn-sm btn-primary">导出</button>
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="erbanNo">平台号:</label>
|
||||
<input type="text" class="form-control" name="erbanNo" id="erbanNo">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="billType">账单类型:</label>
|
||||
<select class="form-control" name="billType" id="billType"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="startDate">开始时间:</label>
|
||||
<input type="text" class="form-control" name="startDate" id="startDate">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="endDate">结束时间:</label>
|
||||
<input type="text" class="form-control" name="endDate" id="endDate">
|
||||
</div>
|
||||
<button id="btnSearch" class="btn btn-default">查询</button>
|
||||
<button id="btnExport" class="btn btn-default">导出</button>
|
||||
</form>
|
||||
</div>
|
||||
<div id="table"></div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -46,8 +56,9 @@
|
||||
{field:'roomErbanNo',title:'房主平台号',align:'center',valign:'middle',width:'10%'},
|
||||
{field:'giftName',title:'礼物名称',align:'center',valign:'middle',width:'5%'},
|
||||
{field:'giftNum',title:'礼物数量',align:'center',valign:'middle',width:'5%'},
|
||||
{field:'actualAmount',title:'人民币数',align:'center',valign:'middle',width:'5%'},
|
||||
{field:'amount',title:'钻石/水晶/金币',align:'center',valign:'middle',width:'5%'},
|
||||
{field:'localCurrencyCode',title:'本地货币数',align:'center',valign:'middle',width:'5%'},
|
||||
{field:'localAmount',title:'货币数',align:'center',valign:'middle',width:'5%'},
|
||||
{field:'billTypeDesc',title:'收入支出',align:'center',valign:'middle',width:'10%'},
|
||||
{field:'objTypeDesc',title:'账单类型',align:'center',valign:'middle',width:'10%'},
|
||||
{field:'createTime',title:'账单创建时间',align:'center',valign:'middle',width:'10%',formatter:function (val,row,index) {
|
||||
@@ -99,7 +110,6 @@
|
||||
// $("#tipModal").modal('show');
|
||||
// return;
|
||||
// }
|
||||
console.debug('ASDFASDF')
|
||||
if ($('#startDate').val() && $('#endDate').val()) {
|
||||
var dateStart = new Date($('#startDate').val().replace(/\-/g, "/"));
|
||||
var dateEnd = new Date($('#endDate').val().replace(/\-/g, "/"));
|
||||
|
@@ -44,6 +44,12 @@ public class ChargeRecordService extends BaseService {
|
||||
return chargeRecord;
|
||||
}
|
||||
|
||||
public List<ChargeRecord> listChargeRecordByIds(List<String> ids) {
|
||||
ChargeRecordExample example = new ChargeRecordExample();
|
||||
example.createCriteria().andChargeRecordIdIn(ids);
|
||||
return chargeRecordMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public void insertChargeRecord(ChargeRecord chargeRecord) {
|
||||
chargeRecord.setCreateTime(new Date());
|
||||
chargeRecordMapper.insertSelective(chargeRecord);
|
||||
|
@@ -5,17 +5,12 @@
|
||||
<id column="bill_id" property="billId" jdbcType="VARCHAR"/>
|
||||
<result column="uid" property="uid" jdbcType="BIGINT"/>
|
||||
<result column="target_uid" property="targetUid" jdbcType="BIGINT"/>
|
||||
<result column="bill_status" property="billStatus" jdbcType="TINYINT"/>
|
||||
<result column="obj_id" property="objId" jdbcType="VARCHAR"/>
|
||||
<result column="obj_type" property="objType" jdbcType="TINYINT"/>
|
||||
<result column="gift_id" property="giftId" jdbcType="INTEGER"/>
|
||||
<result column="gift_num" property="giftNum" jdbcType="INTEGER"/>
|
||||
<result column="gift_total_gold_num" property="giftTotalGoldNum" jdbcType="BIGINT"/>
|
||||
<result column="diamond_num" property="diamondNum" jdbcType="DOUBLE"/>
|
||||
<result column="gold_num" property="goldNum" jdbcType="BIGINT"/>
|
||||
<result column="money" property="money" jdbcType="BIGINT"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getGiftSumByGift" resultType="long">
|
||||
|
Reference in New Issue
Block a user