v1.1 后台-用户充值记录查询

This commit is contained in:
2022-10-18 18:39:18 +08:00
parent 6183b31e96
commit fca1604865
9 changed files with 153 additions and 44 deletions

View File

@@ -12,4 +12,7 @@ import java.util.List;
public interface ChargeRecordAdminMapper extends BaseMapper<ChargeRecord> {
Page<ChargeRecordAdminVo> page(Page<ChargeRecordAdminVo> p, @Param("erbanNo") Long erbanNo, @Param("channel") String channel, @Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("status") Integer status, @Param("newUser") Boolean newUser, @Param("appChannel") String appChannel);
List<ChargeRecord> listFisrChargeRecordByUids(@Param("uids") List<Long> uids);
}

View File

@@ -102,8 +102,8 @@ public class BillRecordAdminService extends BaseService {
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<String> chargeRecordIds = list.stream().filter(b->b.getObjType() == BillObjTypeEnum.CHARGE.getValue() || b.getObjType() == BillObjTypeEnum.OPEN_VIP.getValue())
.map(BillRecord::getObjId).collect(Collectors.toList());
List<ChargeRecord> chargeRecordList = chargeRecordService.listChargeRecordByIds(chargeRecordIds);
Map<String, ChargeRecord> chargeRecordMap = chargeRecordList.stream().collect(Collectors.toMap(ChargeRecord::getChargeRecordId, c->c));

View File

@@ -3,10 +3,13 @@ package com.accompany.admin.service.user;
import com.accompany.admin.mapper.ChargeRecordAdminMapper;
import com.accompany.admin.service.base.BaseService;
import com.accompany.admin.vo.ChargeRecordAdminVo;
import com.accompany.admin.vo.ChargeRecordPersonAdminVo;
import com.accompany.business.constant.ChargeChannelEnum;
import com.accompany.common.constant.Constant;
import com.accompany.common.utils.BlankUtil;
import com.accompany.common.utils.DateTimeUtil;
import com.accompany.core.model.Users;
import com.accompany.core.service.user.UsersBaseService;
import com.accompany.payment.mapper.ChargeRecordMapper;
import com.accompany.payment.mapper.ChargeRecordMapperMgr;
import com.accompany.payment.model.ChargeRecord;
@@ -14,19 +17,21 @@ import com.accompany.payment.model.ChargeRecordExample;
import com.accompany.payment.vo.ChargeRecordDetailVo;
import com.accompany.payment.vo.ChargeRecordStatisVo;
import com.alibaba.excel.EasyExcel;
import com.alipay.api.internal.util.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Maps;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* 2 * @Author: zhuct
@@ -42,6 +47,8 @@ public class ChargeRecordAdminService extends BaseService {
@Autowired
private ChargeRecordAdminMapper chargeRecordAdminMapper;
@Autowired
private UsersBaseService usersBaseService;
public List<ChargeRecordStatisVo> getRecordDailyList(boolean statisticCount) {
@@ -211,6 +218,43 @@ public class ChargeRecordAdminService extends BaseService {
return new PageInfo<>(list);
}
public List<ChargeRecordPersonAdminVo> convertPersonVo(List<ChargeRecord> list) {
List<ChargeRecordPersonAdminVo> voList = new ArrayList<>();
List<Long> uidList = list.stream().map(ChargeRecord::getUid).collect(Collectors.toList());
List<Users> users = usersBaseService.getUsersListByUids(uidList);
Map<Long, Users> usersMap = users.stream().collect(Collectors.toMap(Users::getUid, u->u));
List<ChargeRecord> firstChargeRecords = chargeRecordAdminMapper.listFisrChargeRecordByUids(uidList);
Map<Long, ChargeRecord> firstChargeMap = firstChargeRecords.stream().collect(Collectors.toMap(ChargeRecord::getUid, cr->cr));
for (ChargeRecord chargeRecord: list){
ChargeRecordPersonAdminVo vo = new ChargeRecordPersonAdminVo();
BeanUtils.copyProperties(chargeRecord, vo);
vo.setCreateTime(DateTimeUtil.convertDate(chargeRecord.getCreateTime()));
vo.setNewUser(false);
vo.setFirstCharge(false);
Users u = usersMap.get(chargeRecord.getUid());
if (null != u){
vo.setErbanNo(u.getErbanNo());
vo.setNick(u.getNick());
ChargeRecord firstCr = firstChargeMap.get(chargeRecord.getUid());
if (null != firstCr){
if (firstCr.equals(chargeRecord.getChargeRecordId())){
vo.setFirstCharge(true);
}
vo.setNewUser(DateUtils.isSameDay(u.getCreateTime(), firstCr.getCreateTime()));
}
}
voList.add(vo);
}
return voList;
}
public Page<ChargeRecordAdminVo> chargeRecordList(Integer pageNumber, Integer pageSize, Long erbanNo, String channel, Date startTime,
Date endTime, Integer status, Boolean newUser, String appChannel) {
Page<ChargeRecordAdminVo> p = new Page<>(pageNumber, pageSize);
@@ -223,4 +267,5 @@ public class ChargeRecordAdminService extends BaseService {
Page<ChargeRecordAdminVo> page = chargeRecordList(-1, -1, erbanNo, channel, startTime, endTime, status, newUser, appChannel);
EasyExcel.write(outputStream, ChargeRecordAdminVo.class).sheet("充值明细").doWrite(page.getRecords());
}
}

View File

@@ -9,7 +9,7 @@ import lombok.Data;
import java.util.Date;
@Data
public class ChargeRecordAdminVo extends BaseVo {
public class ChargeRecordAdminVo {
@ExcelProperty("充值记录ID")
@FieldComment("主键id")

View File

@@ -0,0 +1,56 @@
package com.accompany.admin.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class ChargeRecordPersonAdminVo {
@ExcelProperty("充值订单号")
public String chargeRecordId;
@ExcelProperty("第三方订单号")
public String pingxxChargeId;
@ExcelProperty("uid")
public Long uid;
@ExcelProperty("平台号")
public Long erbanNo;
@ExcelProperty("昵称")
public String nick;
@ExcelProperty("渠道")
public String channel;
@ExcelProperty("当地货币代码")
public String country;
@ExcelProperty("当地货币代码")
public String localCurrencyCode;
@ExcelProperty("当地金额")
public Long localAmount;
@ExcelProperty("钻石")
public Long totalGold;
@ExcelProperty("状态")
public Byte chargeStatus;
@ExcelProperty("IP")
public String clientIp;
@ExcelProperty("是否新用户")
public Boolean newUser;
@ExcelProperty("是否首充")
public Boolean firstCharge;
@ExcelProperty("创建时间")
public String createTime;
}

View File

@@ -35,4 +35,12 @@
and new_user = #{newUser}
</if>
</select>
<select id="listFisrChargeRecordByUids" resultType="com.accompany.payment.model.ChargeRecord">
select charge_record_id, cr.uid, cr.create_time from charge_record cr
inner join (select uid, min(create_time) create_time from charge_record
where uid in <foreach collection="uids" item="uid" separator="," open="(" close=")">#{uid}</foreach> and charge_status = 1 group by uid) crg
on cr.uid = crg.uid and cr.create_time = crg.create_time
</select>
</mapper>

View File

@@ -3,6 +3,7 @@ package com.accompany.admin.controller.user;
import com.accompany.admin.controller.BaseController;
import com.accompany.admin.service.user.ChargeRecordAdminService;
import com.accompany.admin.vo.ChargeRecordAdminVo;
import com.accompany.admin.vo.ChargeRecordPersonAdminVo;
import com.accompany.business.service.user.UsersService;
import com.accompany.business.util.ReplaceDomainUtil;
import com.accompany.common.constant.Constant;
@@ -20,6 +21,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -27,10 +29,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 2 * @Author: zhuct
@@ -182,14 +181,17 @@ public class ChargeRecordAdminController extends BaseController {
uid = users.getUid();
}
try {
ReplaceDomainUtil.handlerForObject(users);
PageInfo<ChargeRecord> pageInfo = this.chargeRecordAdminService.queryUserChargeRecord(uid, channel,
PageInfo<ChargeRecord> pageInfo = chargeRecordAdminService.queryUserChargeRecord(uid, channel,
searchType, chargeRecordId, getPageNumber(), getPageSize(), startDate, endDate);
JSONObject jsonObject = new JSONObject();
jsonObject.put("total", pageInfo.getTotal());
jsonObject.put("rows", pageInfo.getList());
if (!CollectionUtils.isEmpty(pageInfo.getList())){
jsonObject.put("rows", chargeRecordAdminService.convertPersonVo(pageInfo.getList()));
}
if (Constant.ChargeRecordSearchType.PERSONAL.equals(searchType)) {
jsonObject.put("users", users);
} else {

View File

@@ -29,9 +29,7 @@
<section class="content-header">
<h1 id="itemTitle"></h1>
</section>
<section class="content">
<div id="table"></div>
<section class="content-body">
<div id="toolbar">
<div id="userMessage">
<div class="avatar"><img src="" alt=""></div>
@@ -49,16 +47,9 @@
</select>
<label for="channel" class="channel-text">充值渠道</label>
<select name="channel" id="channel">
<option value="all">--请选择--</option>
<option value="exchange">兑换</option>
<option value="alipay">APP支付宝</option>
<option value="wx">APP微信</option>
<option value="alipay_wap">H5支付宝</option>
<option value="ios_pay">苹果内购</option>
<option value="wx_pay">H5微信</option>
<option value="fastpay">汇聚快捷支付</option>
<option value="wx_mp">微信小程序支付</option>
<option value="wx_pub">微信公众号</option>
<option value="">全部</option>
<option value="google_play_billing">谷歌内购</option>
<option value="payermax">payermax</option>
</select>
<label for="chargeRecordId" class="chargeRecord-text">订单号:</label>
<input type="text" id="chargeRecordId" name="chargeRecordId">
@@ -68,6 +59,7 @@
<button id="btnSearch" class="btn btn-sm btn-primary">查询</button>
</div>
<div id="table"></div>
</section>
</div>
</div>
@@ -78,16 +70,8 @@
columns: [
{field: 'chargeRecordId', title: '充值订单号', align: 'center', valign: 'middle', width: '20%'},
{field: 'pingxxChargeId', title: '第三方订单号', align: 'center', valign: 'middle', width: '20%'},
{
field: 'createTime', title: '账单创建时间', align: 'center', valign: 'middle', width: '20%', formatter: function (val, row, index) {
if (val) {
var date = new Date(val);
return date.format("yyyy-MM-dd hh:mm:ss");
} else {
return '-';
}
}
},
{field: 'erbanNo', title: '平台id', align: 'center', valign: 'middle'},
{field: 'nick', title: '昵称', align: 'center', valign: 'middle'},
{
field: 'channel', title: '充值渠道', align: 'center', valign: 'middle', width: '10%', formatter: function (val, row, index) {
if (val) {
@@ -110,20 +94,19 @@
return "微信小程序支付";
case "wx_pub":
return "微信公众号";
default:
return val
}
} else {
return '-';
}
}
},
{field: 'subject', title: '充值内容', align: 'center', valign: 'middle', width: '20%'},
{
field: 'amount', title: '花费金额(元)', align: 'center', valign: 'middle', width: '20%', formatter: function (val, row, inde) {
return val / 100 + "元";
}
},
{
field: 'chargeStatus', title: '充值状态', align: 'center', valign: 'middle', width: '10%', formatter: function (val, row, inde) {
{field: 'country', title: '地区', align: 'center', valign: 'middle'},
{field: 'localCurrencyCode', title: '本地货币代码', align: 'center', valign: 'middle'},
{field: 'localAmount', title: '本地金额', align: 'center', valign: 'middle'},
{field: 'totalGold', title: '钻石', align: 'center', valign: 'middle'},
{field: 'chargeStatus', title: '充值状态', align: 'center', valign: 'middle', width: '10%', formatter: function (val, row, inde) {
switch (val) {
case 1:
return "未完成";
@@ -131,7 +114,19 @@
return "已支付";
}
}
}
},
{field: 'clientIp', title: 'ip', align: 'center', valign: 'middle'},
{field: 'newUser', title: '是否新用户', align: 'center', valign: 'middle'},
{field: 'firstCharge', title: '是否首充', align: 'center', valign: 'middle'},
{field: 'createTime', title: '账单创建时间', align: 'center', valign: 'middle', width: '20%', formatter: function (val, row, index) {
if (val) {
var date = new Date(val);
return date.format("yyyy-MM-dd hh:mm:ss");
} else {
return '-';
}
}
},
],
cache: false,
striped: true,

View File

@@ -99,7 +99,7 @@
</sql>
<sql id="Base_Column_List">
charge_record_id, uid, room_uid, pingxx_charge_id, charge_prod_id, channel, buss_type,
charge_status, charge_status_desc, amount, total_gold, client_ip, wx_pub_openid,
charge_status, charge_status_desc, amount, country, local_currency_code, local_amount, total_gold, client_ip, wx_pub_openid,
subject, body, extra, metadata, charge_desc, agent_conf_id, agent_id, charge_app, create_time, update_time
</sql>
<select id="selectByExample" resultMap="BaseResultMap"