资金明细优化

This commit is contained in:
张乐
2020-08-26 18:02:40 +08:00
parent bff836d52e
commit 17100b75f8
12 changed files with 70 additions and 30 deletions

View File

@@ -122,7 +122,7 @@ export function userActivity(){
}
/*
* 资金明细types|0=全部,1=消费,2=充值,3=返佣,4=提现
* 余额明细types|2=全部,1=支出,2=收入
* */
export function getCommissionInfo(q, types) {
return request.get("spread/commission/" + types, q);

View File

@@ -26,4 +26,4 @@ module.exports = {
TOKENNAME: 'Authori-zation',
// 缓存时间 0 永久
EXPIRE:0,
};
};

View File

@@ -55,4 +55,4 @@ const app = new Vue({
store,
Cache
})
app.$mount();
app.$mount();

View File

@@ -3,8 +3,8 @@
<view class='bill-details'>
<view class='nav acea-row'>
<view class='item' :class='type==0 ? "on":""' @click='changeType(0)'>全部</view>
<view class='item' :class='type==1 ? "on":""' @click='changeType(1)'>消费</view>
<view class='item' :class='type==2 ? "on":""' @click='changeType(2)'>充值</view>
<view class='item' :class='type==1 ? "on":""' @click='changeType(1)'>支出</view>
<view class='item' :class='type==2 ? "on":""' @click='changeType(2)'>收入</view>
</view>
<view class='sign-record'>
<view class='list' v-for="(item,index) in userBillList" :key="index">

View File

@@ -18,11 +18,11 @@
</view>
<view class='cumulative acea-row row-top'>
<view class='item'>
<view>累计充值()</view>
<view>累计收入()</view>
<view class='money'>{{statistics.recharge || 0}}</view>
</view>
<view class='item'>
<view>累计消费()</view>
<view>累计支出()</view>
<view class='money'>{{statistics.orderStatusSum || 0}}</view>
</view>
</view>
@@ -39,7 +39,7 @@
<view class='pictrue'>
<image src='../../../static/images/record2.png'></image>
</view>
<view>消费记录</view>
<view>支出记录</view>
</navigator>
<navigator class='item' hover-class='none' url='/pages/users/user_bill/index?type=2' v-if="recharge_switch">
<view class='pictrue'>

View File

@@ -27,4 +27,6 @@ public interface UserRechargeService extends IService<UserRecharge> {
UserRecharge create(UserRechargeRequest request);
Boolean complete(UserRecharge userRecharge);
BigDecimal getSumBigDecimal(Integer uid);
}

View File

@@ -1,6 +1,7 @@
package com.zbkj.crmeb.finance.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.common.PageParamRequest;
import com.constants.Constants;
@@ -146,5 +147,26 @@ public class UserRechargeServiceImpl extends ServiceImpl<UserRechargeDao, UserRe
}
}
/**
* 充值总金额
* @param userId Integer 用户uid
* @author Mr.Zhang
* @since 2020-05-29
* @return UserBill
*/
@Override
public BigDecimal getSumBigDecimal(Integer userId) {
QueryWrapper<UserRecharge> queryWrapper = new QueryWrapper<>();
queryWrapper.select("sum(price) as price").
eq("uid", userId).
eq("paid", 1);
UserRecharge userRecharge = dao.selectOne(queryWrapper);
if(null == userRecharge || null == userRecharge.getPrice()){
return BigDecimal.ZERO;
}
return userRecharge.getPrice();
}
}

View File

@@ -144,7 +144,7 @@ public class UserController {
*/
@ApiOperation(value = "推广佣金明细")
@RequestMapping(value = "/spread/commission/{type}", method = RequestMethod.GET)
@ApiImplicitParam(name = "type", value = "类型 佣金类型|0=全部,1=消费,2=充值,3=返佣,4=提现", allowableValues = "range[0,1,2,3,4]", dataType = "int")
@ApiImplicitParam(name = "type", value = "类型 佣金类型|0=全部,1=支出,2=收入,3=佣金明细", allowableValues = "range[0,1,2,3]", dataType = "int")
public CommonResult<CommonPage<UserSpreadCommissionResponse>> getSpreadCommissionByType(@PathVariable int type, @Validated PageParamRequest pageParamRequest){
return CommonResult.success(CommonPage.restPage(userCenterService.getSpreadCommissionByType(type, pageParamRequest)));
}

View File

@@ -33,7 +33,6 @@ import com.zbkj.crmeb.user.model.UserBill;
import com.zbkj.crmeb.user.model.UserToken;
import com.zbkj.crmeb.user.request.RegisterThirdUserRequest;
import com.zbkj.crmeb.user.request.UserOperateFundsRequest;
import com.zbkj.crmeb.user.service.UserAddressService;
import com.zbkj.crmeb.user.service.UserBillService;
import com.zbkj.crmeb.user.service.UserService;
import com.zbkj.crmeb.user.service.UserTokenService;
@@ -99,8 +98,6 @@ public class UserCenterServiceImpl extends ServiceImpl<UserDao, User> implements
@Autowired
private WeChatService weChatService;
@Autowired
private UserAddressService userAddressService;
/**
@@ -112,8 +109,10 @@ public class UserCenterServiceImpl extends ServiceImpl<UserDao, User> implements
public UserCommissionResponse getCommission() {
UserCommissionResponse userCommissionResponse = new UserCommissionResponse();
//昨天的佣金
userCommissionResponse.setLastDayCount(userBillService.getSumBigDecimal(0, userService.getUserIdException(), Constants.USER_BILL_CATEGORY_MONEY, Constants.SEARCH_DATE_YESTERDAY, null));
userCommissionResponse.setExtractCount(userBillService.getSumBigDecimal(0, userService.getUserIdException(), Constants.USER_BILL_CATEGORY_MONEY, null, Constants.USER_BILL_TYPE_EXTRACT));
userCommissionResponse.setLastDayCount(userBillService.getSumBigDecimal(0, userService.getUserIdException(), Constants.USER_BILL_CATEGORY_BROKERAGE_PRICE, Constants.SEARCH_DATE_YESTERDAY, null));
userCommissionResponse.setExtractCount(userBillService.getSumBigDecimal(0, userService.getUserIdException(), Constants.USER_BILL_CATEGORY_BROKERAGE_PRICE, null, Constants.USER_BILL_TYPE_EXTRACT));
userCommissionResponse.setCommissionCount(userService.getInfo().getBrokeragePrice());
return userCommissionResponse;
}
@@ -126,7 +125,25 @@ public class UserCenterServiceImpl extends ServiceImpl<UserDao, User> implements
*/
@Override
public PageInfo<UserSpreadCommissionResponse> getSpreadCommissionByType(int type, PageParamRequest pageParamRequest) {
return userBillService.getListGroupByMonth(userService.getUserIdException(), type, pageParamRequest);
Integer pm = null;
String category = Constants.USER_BILL_CATEGORY_MONEY;
switch (type){
case 1:
pm = 0;
break;
case 2:
pm = 1;
break;
case 3:
category = Constants.USER_BILL_CATEGORY_BROKERAGE_PRICE;
break;
case 4:
return null;
default:
break;
}
return userBillService.getListGroupByMonth(userService.getUserIdException(), pm, pageParamRequest, category);
}
/**
@@ -275,7 +292,7 @@ public class UserCenterServiceImpl extends ServiceImpl<UserDao, User> implements
@Override
public UserBalanceResponse getUserBalance() {
User info = userService.getInfo();
BigDecimal recharge = userBillService.getSumBigDecimal(1, info.getUid(), Constants.USER_BILL_CATEGORY_MONEY, null, Constants.USER_BILL_TYPE_RECHARGE);
BigDecimal recharge = userBillService.getSumBigDecimal(1, info.getUid(), Constants.USER_BILL_CATEGORY_MONEY, null, null);
BigDecimal orderStatusSum = storeOrderService.getSumBigDecimal(info.getUid(), null);
return new UserBalanceResponse(info.getBrokeragePrice(), recharge, orderStatusSum);
}

View File

@@ -154,7 +154,7 @@ public class RechargePayServiceImpl extends PayService implements RechargePaySer
//余额变动
UserOperateFundsRequest userOperateFundsRequest = new UserOperateFundsRequest();
userOperateFundsRequest.setValue(getUserRecharge().getPrice().add(getUserRecharge().getGivePrice()));
userOperateFundsRequest.setFoundsType(Constants.ORDER_LOG_PAY_SUCCESS);
userOperateFundsRequest.setFoundsType(Constants.USER_BILL_TYPE_PAY_RECHARGE);
userOperateFundsRequest.setUid(getUserRecharge().getUid());
userOperateFundsRequest.setTitle("充值支付");
userOperateFundsRequest.setFoundsCategory(Constants.USER_BILL_CATEGORY_MONEY);

View File

@@ -28,7 +28,7 @@ public interface UserBillService extends IService<UserBill> {
BigDecimal getSumBigDecimal(Integer pm, Integer userId, String category, String date, String type);
PageInfo<UserSpreadCommissionResponse> getListGroupByMonth(Integer userId, int type, PageParamRequest pageParamRequest);
PageInfo<UserSpreadCommissionResponse> getListGroupByMonth(Integer userId, Integer type, PageParamRequest pageParamRequest, String category);
boolean saveRefundBill(StoreOrderRefundRequest request, User user);

View File

@@ -299,21 +299,20 @@ public class UserBillServiceImpl extends ServiceImpl<UserBillDao, UserBill> impl
}
/**
* 按照月份分组
* 按照月份分组, 余额
* @author Mr.Zhang
* @since 2020-06-08
* @return CommonPage<UserBill>
*/
@Override
public PageInfo<UserSpreadCommissionResponse> getListGroupByMonth(Integer userId, int type, PageParamRequest pageParamRequest) {
public PageInfo<UserSpreadCommissionResponse> getListGroupByMonth(Integer userId, Integer pm, PageParamRequest pageParamRequest, String category) {
Page<UserBill> userBillPage = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
ArrayList<UserSpreadCommissionResponse> userSpreadCommissionResponseList = new ArrayList<>();
QueryWrapper<UserBill> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("uid", userId).eq("status", 1);
ArrayList<String> typeList = getTypeList(type);
if(typeList.size() > 0){
queryWrapper.in("type", typeList);
queryWrapper.eq("uid", userId).eq("status", 1).eq("category", category);
if(null != pm){
queryWrapper.eq("pm", pm);
}
queryWrapper.groupBy("left(create_time, 7)");
@@ -325,7 +324,7 @@ public class UserBillServiceImpl extends ServiceImpl<UserBillDao, UserBill> impl
for (UserBill userBill : list) {
String date = DateUtil.dateToStr(userBill.getCreateTime(), Constants.DATE_FORMAT_MONTH);
userSpreadCommissionResponseList.add(new UserSpreadCommissionResponse(date, getListByMonth(userId, type, date)));
userSpreadCommissionResponseList.add(new UserSpreadCommissionResponse(date, getListByMonth(userId, pm, date, category)));
}
return CommonPage.copyPageInfo(userBillPage, userSpreadCommissionResponseList);
@@ -409,13 +408,13 @@ public class UserBillServiceImpl extends ServiceImpl<UserBillDao, UserBill> impl
* @since 2020-06-08
* @return List<UserBill>
*/
private List<UserBill> getListByMonth(Integer userId, int type, String month) {
private List<UserBill> getListByMonth(Integer userId, Integer pm, String month, String category) {
QueryWrapper<UserBill> queryWrapper = new QueryWrapper<>();
queryWrapper.select("pm,title,number,create_time").eq("uid", userId). eq("status", 1).eq("left(create_time, 7)", month);
ArrayList<String> typeList = getTypeList(type);
if(typeList.size() > 0){
queryWrapper.in("type", typeList);
queryWrapper.select("pm,title,number,create_time").eq("uid", userId). eq("status", 1).eq("left(create_time, 7)", month).eq("category", category);
if(null != pm){
queryWrapper.eq("pm", pm);
}
queryWrapper.orderByDesc("create_time");
return dao.selectList(queryWrapper);
}