新增对账报表
This commit is contained in:
parent
391695de15
commit
7f02aa43a8
|
@ -28,6 +28,7 @@ import org.springframework.util.CollectionUtils;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -200,25 +201,22 @@ public class SmBusinessRecordServiceImpl implements ISmBusinessRecordService
|
|||
brief.setAgentCount(userService.selectCount(agentQuery));
|
||||
|
||||
// 充值金额总数
|
||||
TransactionBillQuery rechargeDto = new TransactionBillQuery();
|
||||
rechargeDto.setStatus(TransactionBillStatus.SUCCESS.getStatus());
|
||||
List<BillCountVo> billCount = transactionBillService.selectCount(rechargeDto);
|
||||
if (!CollectionUtils.isEmpty(billCount) && billCount.get(0).getRecharge() != null) {
|
||||
brief.setRechargeAmount(billCount.get(0).getRechargeAmount());
|
||||
} else {
|
||||
brief.setRechargeAmount(BigDecimal.ZERO);
|
||||
TransactionBillQuery billQuery = new TransactionBillQuery();
|
||||
billQuery.setStatusList(TransactionBillStatus.payedOrder());
|
||||
billQuery.setType(TransactionBillType.RECHARGE.getType());
|
||||
BigDecimal rechargeAmount = transactionBillService.selectSumOfMoneyWithoutRefund(billQuery);
|
||||
if (rechargeAmount == null) {
|
||||
rechargeAmount = BigDecimal.ZERO;
|
||||
}
|
||||
brief.setRechargeAmount(rechargeAmount);
|
||||
|
||||
// 今日充值金额总数
|
||||
TransactionBillQuery todayRechargeQuery = new TransactionBillQuery();
|
||||
todayRechargeQuery.setStatusList(TransactionBillStatus.payedOrder());
|
||||
todayRechargeQuery.setCreateDate(now);
|
||||
List<BillCountVo> todayBillCount = transactionBillService.selectCount(todayRechargeQuery);
|
||||
if (!CollectionUtils.isEmpty(todayBillCount) && todayBillCount.get(0).getRecharge() != null) {
|
||||
brief.setTodayRechargeAmount(todayBillCount.get(0).getRechargeAmount());
|
||||
} else {
|
||||
brief.setTodayRechargeAmount(BigDecimal.ZERO);
|
||||
billQuery.setCreateDate(now);
|
||||
BigDecimal todayRechargeAmount = transactionBillService.selectSumOfMoneyWithoutRefund(billQuery);
|
||||
if (todayRechargeAmount == null) {
|
||||
todayRechargeAmount = BigDecimal.ZERO;
|
||||
}
|
||||
brief.setTodayRechargeAmount(todayRechargeAmount);
|
||||
|
||||
// 用户总余额
|
||||
brief.setTotalUserBalance(userService.selectSumOfBalance(new SmUserQuery()));
|
||||
|
|
|
@ -23,12 +23,16 @@ public class StoreOperatorVO {
|
|||
@ApiModelProperty("注销店铺")
|
||||
private Boolean del;
|
||||
|
||||
@ApiModelProperty("添加合伙人")
|
||||
private Boolean addStaff;
|
||||
|
||||
public static StoreOperatorVO defaultInstance() {
|
||||
StoreOperatorVO vo = new StoreOperatorVO();
|
||||
vo.setViewDevice(false);
|
||||
vo.setUpdate(false);
|
||||
vo.setConfig(false);
|
||||
vo.setDel(false);
|
||||
vo.setAddStaff(false);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
|
|
@ -258,6 +258,7 @@ public class StoreAssemblerImpl implements StoreAssembler {
|
|||
if (storeValidator.isMch(store, userId)) {
|
||||
vo.setDel(true);
|
||||
vo.setViewDevice(true);
|
||||
vo.setAddStaff(true);
|
||||
}
|
||||
store.setOperator(vo);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.ruoyi.ss.transactionBill.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/12/2
|
||||
*/
|
||||
@Data
|
||||
public class TransactionDailyAmountVO {
|
||||
|
||||
@ApiModelProperty("日期")
|
||||
private LocalDate date;
|
||||
|
||||
@ApiModelProperty("订单总金额")
|
||||
private BigDecimal total;
|
||||
|
||||
@ApiModelProperty("订单退款总金额")
|
||||
private BigDecimal refund;
|
||||
|
||||
@ApiModelProperty("订单总实收金额")
|
||||
private BigDecimal received;
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import com.ruoyi.ss.transactionBill.domain.TransactionBill;
|
|||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.vo.TransactionAmountVO;
|
||||
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
|
||||
import com.ruoyi.ss.transactionBill.domain.vo.TransactionDailyAmountVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -204,4 +205,14 @@ public interface TransactionBillMapper
|
|||
* 查询统计数量
|
||||
*/
|
||||
List<JSONObject> selectCountGroupBy(@Param("query") TransactionBillQuery query, @Param("groupBy") String groupBy);
|
||||
|
||||
/**
|
||||
* 查询订单总金额(不包含退款)
|
||||
*/
|
||||
BigDecimal selectSumOfMoneyWithoutRefund(@Param("query") TransactionBillQuery query);
|
||||
|
||||
/**
|
||||
* 按日查询金额
|
||||
*/
|
||||
List<TransactionDailyAmountVO> selectDailyAmount(@Param("query") TransactionBillQuery query);
|
||||
}
|
||||
|
|
|
@ -360,7 +360,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.groupBy == 'device_id'">
|
||||
stb.device_id as device_id,
|
||||
</if>
|
||||
SUM(IF( stb.type = '1' and stb.status = '2', stb.arrival_amount, 0 )) AS recharge,
|
||||
SUM(IF( stb.type = '1' and stb.status in('2', '3', '7'), stb.arrival_amount, 0 )) AS recharge,
|
||||
SUM(IF( stb.type = '1' and stb.status = '2', stb.money, 0 )) AS recharge_amount,
|
||||
SUM(IF( stb.type = '2' and stb.status = '14', stb.arrival_amount, 0 )) AS withdraw,
|
||||
SUM(stb.service_charge) AS service_charge,
|
||||
|
@ -454,6 +454,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectSumOfMoneyWithoutRefund" resultType="java.math.BigDecimal">
|
||||
select sum(stb.money) - sum(stb.refund_amount)
|
||||
from sm_transaction_bill stb
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<resultMap id="TransactionDailyAmountVO" type="TransactionDailyAmountVO">
|
||||
<result property="date" column="date"/>
|
||||
<result property="total" column="total" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
|
||||
<result property="refund" column="refund" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
|
||||
<result property="received" column="received" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
|
||||
</resultMap>
|
||||
<select id="selectDailyAmount" resultMap="TransactionDailyAmountVO">
|
||||
select
|
||||
date(stb.create_time) as `date`,
|
||||
sum(stb.money) as `total`,
|
||||
sum(stb.refund_amount) as `refund`,
|
||||
sum(stb.money) - sum(stb.refund_amount) as `received`
|
||||
from sm_transaction_bill stb
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
group by `date`
|
||||
</select>
|
||||
|
||||
<insert id="insertSmTransactionBill" parameterType="TransactionBill" useGeneratedKeys="true" keyProperty="billId">
|
||||
<selectKey resultType="Long" order="AFTER" keyProperty="billId">
|
||||
SELECT LAST_INSERT_ID();
|
||||
|
|
|
@ -336,4 +336,14 @@ public interface TransactionBillService
|
|||
* 查询员工可见列表
|
||||
*/
|
||||
List<TransactionBillVO> selectStaffDeviceList(TransactionBillQuery query);
|
||||
|
||||
/**
|
||||
* 查询去除退款金额的订单金额
|
||||
*/
|
||||
BigDecimal selectSumOfMoneyWithoutRefund(TransactionBillQuery query);
|
||||
|
||||
/**
|
||||
* 按日查询订单金额
|
||||
*/
|
||||
List<TransactionDailyAmountVO> selectDailyAmount(TransactionBillQuery query);
|
||||
}
|
||||
|
|
|
@ -432,6 +432,16 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
return this.selectSmTransactionBillList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal selectSumOfMoneyWithoutRefund(TransactionBillQuery query) {
|
||||
return transactionBillMapper.selectSumOfMoneyWithoutRefund(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TransactionDailyAmountVO> selectDailyAmount(TransactionBillQuery query) {
|
||||
return transactionBillMapper.selectDailyAmount(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> selectCountGroupBy(TransactionBillQuery query, String groupBy) {
|
||||
return transactionBillMapper.selectCountGroupBy(query, groupBy);
|
||||
|
|
|
@ -66,7 +66,16 @@ public interface SmUserMapper
|
|||
|
||||
int selectCount(SmUserQuery dto);
|
||||
|
||||
int addBalance(@Param("userId") Long userId, @Param("amount") BigDecimal amount);
|
||||
/**
|
||||
* 增加余额
|
||||
* @param userId 用户id
|
||||
* @param amount 金额
|
||||
* @param beforeBalance 变动前的余额(并发)
|
||||
*/
|
||||
int addBalance(@Param("userId") Long userId,
|
||||
@Param("amount") BigDecimal amount,
|
||||
@Param("beforeBalance") BigDecimal beforeBalance
|
||||
);
|
||||
|
||||
SmUserVO selectSmUserByWxOpenId(String openId);
|
||||
|
||||
|
@ -97,8 +106,13 @@ public interface SmUserMapper
|
|||
* @param userId 用户id
|
||||
* @param amount 金额
|
||||
* @param check 校验余额是否充足
|
||||
* @param beforeBalance 变动前的余额(并发)
|
||||
*/
|
||||
int subtractBalance(@Param("userId") Long userId, @Param("amount") BigDecimal amount, @Param("check") boolean check);
|
||||
int subtractBalance(@Param("userId") Long userId,
|
||||
@Param("amount") BigDecimal amount,
|
||||
@Param("check") boolean check,
|
||||
@Param("beforeBalance") BigDecimal beforeBalance
|
||||
);
|
||||
|
||||
/**
|
||||
* 更新用户服务费
|
||||
|
|
|
@ -261,7 +261,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<update id="addBalance">
|
||||
update sm_user
|
||||
set balance = balance + #{amount}
|
||||
where user_id = #{userId} and del_flag = '0'
|
||||
where user_id = #{userId} and del_flag = '0' and balance = #{beforeBalance}
|
||||
</update>
|
||||
|
||||
<update id="updateSmUser" parameterType="SmUser">
|
||||
|
@ -330,10 +330,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
update sm_user
|
||||
set balance = balance - #{amount}
|
||||
<where>
|
||||
user_id = #{userId} and del_flag = '0'
|
||||
user_id = #{userId} and del_flag = '0' and balance = #{beforeBalance}
|
||||
<if test="check">
|
||||
and balance >= #{amount}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
</update>
|
||||
|
||||
|
|
|
@ -211,8 +211,8 @@ public class SmUserServiceImpl implements ISmUserService
|
|||
SmUserVO user = selectSmUserByUserId(userId);
|
||||
|
||||
// 修改余额
|
||||
int updateCount = smUserMapper.addBalance(userId, amount);
|
||||
ServiceUtil.assertion(updateCount != 1, "增加用户余额失败");
|
||||
int updateCount = smUserMapper.addBalance(userId, amount, user.getBalance());
|
||||
ServiceUtil.assertion(updateCount != 1, "增加用户余额失败,请重试");
|
||||
|
||||
// 余额变动记录
|
||||
int record = recordBalanceService.record(userId, user.getBalance(), amount, reason, bstType, bstId);
|
||||
|
@ -238,8 +238,8 @@ public class SmUserServiceImpl implements ISmUserService
|
|||
SmUserVO user = selectSmUserByUserId(userId);
|
||||
|
||||
// 更新用户余额
|
||||
int updateCount = smUserMapper.subtractBalance(userId, amount, check);
|
||||
ServiceUtil.assertion(updateCount != 1, "减少用户余额失败:用户不存在或余额不足");
|
||||
int updateCount = smUserMapper.subtractBalance(userId, amount, check, user.getBalance());
|
||||
ServiceUtil.assertion(updateCount != 1, "减少用户余额失败,请重试");
|
||||
|
||||
// 余额变动记录
|
||||
int record = recordBalanceService.record(userId, user.getBalance(), amount.negate(), reason, bstType, bstId);
|
||||
|
|
|
@ -178,7 +178,7 @@ public class AppTransactionBillController extends BaseController
|
|||
dto.setEndDate(DateUtils.toLocalDate(DateUtils.getMonthLastDate(dto.getYear(), dto.getMonth())));
|
||||
}
|
||||
|
||||
// FIXME 需要统计退款的订单,并且需要过滤掉退款的金额
|
||||
// FIXME 需要过滤掉退款的金额
|
||||
dto.setMchId(getUserId());
|
||||
dto.setStatusList(TransactionBillStatus.income());
|
||||
AjaxResult ajax = AjaxResult.success(transactionBillService.selectLandlordCount(dto));
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.ruoyi.ss.bonus.service.BonusService;
|
|||
import com.ruoyi.ss.businessRecord.service.ISmBusinessRecordService;
|
||||
import com.ruoyi.dashboard.domain.dto.ServiceIncomeQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.vo.TransactionDailyAmountVO;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillGroupBy;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
|
||||
|
@ -134,4 +135,22 @@ public class SmDashboardController extends BaseController {
|
|||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按天统计订单金额数据
|
||||
*/
|
||||
@GetMapping("/billDailyAmount")
|
||||
public AjaxResult getBillDailyAmount(TransactionBillQuery query) {
|
||||
List<TransactionDailyAmountVO> list = transactionBillService.selectDailyAmount(query);
|
||||
if (query.getStartDate() != null && query.getEndDate() != null) {
|
||||
CollectionUtils.fillVoids(list, TransactionDailyAmountVO::getDate, (date) -> {
|
||||
TransactionDailyAmountVO vo = new TransactionDailyAmountVO();
|
||||
vo.setDate(date);
|
||||
vo.setTotal(BigDecimal.ZERO);
|
||||
vo.setRefund(BigDecimal.ZERO);
|
||||
vo.setReceived(BigDecimal.ZERO);
|
||||
return vo;
|
||||
}, query.getStartDate(), query.getEndDate());
|
||||
}
|
||||
return success(list);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user