资金明细优化
This commit is contained in:
@@ -27,4 +27,6 @@ public interface UserRechargeService extends IService<UserRecharge> {
|
||||
UserRecharge create(UserRechargeRequest request);
|
||||
|
||||
Boolean complete(UserRecharge userRecharge);
|
||||
|
||||
BigDecimal getSumBigDecimal(Integer uid);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user