报表更新

This commit is contained in:
磷叶 2024-12-02 17:31:14 +08:00
parent 7f02aa43a8
commit 2a8851feda
9 changed files with 131 additions and 18 deletions

View File

@ -0,0 +1,18 @@
package com.ruoyi.common.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
* @author wjh
* 2024/12/2
*/
@Data
public class LocalDateDecimalVO {
private LocalDate key;
private BigDecimal value;
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.ss.bonus.mapper;
import com.ruoyi.common.domain.vo.CommonCountVO;
import com.ruoyi.common.domain.vo.CommonSumVO;
import com.ruoyi.common.domain.vo.LocalDateDecimalVO;
import com.ruoyi.common.domain.vo.LongDecimalVO;
import com.ruoyi.ss.bonus.domain.Bonus;
import com.ruoyi.ss.bonus.domain.BonusProvideQuery;
@ -110,7 +111,7 @@ public interface BonusMapper
/**
* 按月查询
*/
List<BonusMonthAmountVO> selectMonthAmount(@Param("query") BonusQuery query);
List<BonusMonthAmountVO> selectMonthPayedAmount(@Param("query") BonusQuery query);
/**
* 按日查询
@ -136,4 +137,14 @@ public interface BonusMapper
* 查询未分成金额并以到账方分组
*/
List<LongDecimalVO> selectWaitAmountGroupByArrival(@Param("query") BonusQuery query);
/**
* 按日查询已分成金额
*/
List<LocalDateDecimalVO> selectDailyPayedAmount(@Param("query") BonusQuery query);
/**
* 查询已分成金额
*/
BigDecimal selectSumOfPayedAmount(@Param("query") BonusQuery query);
}

View File

@ -145,11 +145,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="amount" column="amount" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
</resultMap>
<select id="selectMonthAmount" resultMap="BonusMonthAmountVO">
<select id="selectMonthPayedAmount" resultMap="BonusMonthAmountVO">
select
year(sb.pay_time) as `year`,
month(sb.pay_time) as `month`,
sum(amount) as amount
sum(payed_amount) as amount
<include refid="searchTables"/>
<where>
<include refid="searchCondition"/>
@ -193,6 +193,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by `key`
</select>
<resultMap id="LocalDateDecimalVO" type="LocalDateDecimalVO" autoMapping="true">
<result column="value" property="value" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
</resultMap>
<select id="selectDailyPayedAmount" resultMap="LocalDateDecimalVO">
select
date(sb.pay_time) as `key`,
sum(sb.payed_amount) as `value`
<include refid="searchTables"/>
<where>
<include refid="searchCondition"/>
</where>
group by `key`
</select>
<select id="selectSumOfPayedAmount" resultType="java.math.BigDecimal">
select
sum(sb.payed_amount)
<include refid="searchTables"/>
<where>
<include refid="searchCondition"/>
</where>
</select>
<insert id="insertBonus" parameterType="Bonus" useGeneratedKeys="true" keyProperty="id">
insert into ss_bonus
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -2,6 +2,7 @@ package com.ruoyi.ss.bonus.service;
import com.ruoyi.common.domain.vo.CommonCountVO;
import com.ruoyi.common.domain.vo.CommonSumVO;
import com.ruoyi.common.domain.vo.LocalDateDecimalVO;
import com.ruoyi.common.domain.vo.LongDecimalVO;
import com.ruoyi.ss.bonus.domain.Bonus;
import com.ruoyi.ss.bonus.domain.BonusProvideQuery;
@ -130,7 +131,7 @@ public interface BonusService
/**
* 按月查询分成金额
*/
List<BonusMonthAmountVO> selectMonthAmount(BonusQuery query);
List<BonusMonthAmountVO> selectMonthPayedAmount(BonusQuery query);
/**
* 按日查询分成
@ -158,4 +159,14 @@ public interface BonusService
* 根据ID支付分成
*/
int payBonusById(Long id);
/**
* 按日查询已分成金额
*/
List<LocalDateDecimalVO> selectDailyPayedAmount(BonusQuery query);
/**
* 查询已分成金额总和
*/
BigDecimal selectSumOfPayedAmount(BonusQuery query);
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.ss.bonus.service.impl;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.domain.vo.CommonCountVO;
import com.ruoyi.common.domain.vo.CommonSumVO;
import com.ruoyi.common.domain.vo.LocalDateDecimalVO;
import com.ruoyi.common.domain.vo.LongDecimalVO;
import com.ruoyi.common.enums.LoginType;
import com.ruoyi.common.utils.DateUtils;
@ -372,8 +373,8 @@ public class BonusServiceImpl implements BonusService
}
@Override
public List<BonusMonthAmountVO> selectMonthAmount(BonusQuery query) {
return bonusMapper.selectMonthAmount(query);
public List<BonusMonthAmountVO> selectMonthPayedAmount(BonusQuery query) {
return bonusMapper.selectMonthPayedAmount(query);
}
@Override
@ -422,6 +423,16 @@ public class BonusServiceImpl implements BonusService
return this.payBonus(bonus);
}
@Override
public List<LocalDateDecimalVO> selectDailyPayedAmount(BonusQuery query) {
return bonusMapper.selectDailyPayedAmount(query);
}
@Override
public BigDecimal selectSumOfPayedAmount(BonusQuery query) {
return bonusMapper.selectSumOfPayedAmount(query);
}
private int batchUpdateAmount(List<BonusVO> list) {
if (CollectionUtils.isEmptyElement(list)) {
return 0;

View File

@ -17,6 +17,7 @@ import lombok.Data;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.List;
/**
@ -48,6 +49,10 @@ public class TransactionBillVO extends TransactionBill implements IotDevice {
@JsonView(JsonViewProfile.App.class)
private BigDecimal deviceTotalEle;
@ApiModelProperty("设备结束时间")
@JsonView(JsonViewProfile.App.class)
private LocalDateTime deviceExpireTime;
@ApiModelProperty("是否使用中")
@JsonView(JsonViewProfile.App.class)
private Boolean isUsing;

View File

@ -94,6 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
su1.phonenumber as mch_mobile,
sd.device_no as device_no,
sd.total_electri_quantity as device_total_ele,
sd.expire_time as device_expire_time,
su.phonenumber as user_mobile
from <include refid="rechargeTables"/>
</sql>

View File

@ -1,11 +1,25 @@
package com.ruoyi.web.controller.app;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.domain.vo.LocalDateDecimalVO;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.dashboard.service.DashboardService;
import com.ruoyi.ss.bonus.domain.BonusQuery;
import com.ruoyi.ss.bonus.domain.enums.BonusArrivalType;
import com.ruoyi.ss.bonus.domain.vo.BonusDailyAmountVO;
import com.ruoyi.ss.bonus.service.BonusService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author wjh
* 2024/11/28
@ -15,12 +29,31 @@ import org.springframework.web.bind.annotation.RestController;
public class AppDashboardController extends BaseController {
@Autowired
private DashboardService dashboardService;
private BonusService bonusService;
// @ApiOperation("按日查询分成列表")
// @GetMapping("/bonusSumOfDaily")
// public AjaxResult bonusDaily() {
// return success(dashboardService.selectBonusDaily());
// }
@ApiOperation("按日查询本人分成列表")
@GetMapping("/bonusDailyAmount")
public AjaxResult bonusDailyAmount(BonusQuery query) {
query.setArrivalId(getUserId());
query.setArrivalTypes(BonusArrivalType.userList());
List<LocalDateDecimalVO> list = bonusService.selectDailyPayedAmount(query);
list = list.stream().filter(item -> Objects.nonNull(item.getKey())).collect(Collectors.toList());
if (query.getPayDateStart() != null && query.getPayDateEnd() != null) {
list = CollectionUtils.fillVoids(list, LocalDateDecimalVO::getKey, (date) -> {
LocalDateDecimalVO vo = new LocalDateDecimalVO();
vo.setKey(date);
vo.setValue(BigDecimal.ZERO);
return vo;
}, query.getPayDateStart(), query.getPayDateEnd());
}
AjaxResult ajax = AjaxResult.success(list);
BonusQuery totalQuery = new BonusQuery();
totalQuery.setArrivalId(getUserId());
totalQuery.setArrivalTypes(BonusArrivalType.userList());
ajax.put("total", bonusService.selectSumOfPayedAmount(totalQuery));
return ajax;
}
}

View File

@ -3,13 +3,13 @@ package com.ruoyi.web.controller.ss;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.domain.vo.LocalDateDecimalVO;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.dashboard.service.DashboardService;
import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriodQuery;
import com.ruoyi.ss.balancePeriod.service.ISmBalancePeriodService;
import com.ruoyi.ss.bonus.domain.BonusQuery;
import com.ruoyi.ss.bonus.domain.vo.BonusDailyAmountVO;
import com.ruoyi.ss.bonus.service.BonusService;
import com.ruoyi.ss.businessRecord.service.ISmBusinessRecordService;
import com.ruoyi.dashboard.domain.dto.ServiceIncomeQuery;
@ -114,7 +114,7 @@ public class SmDashboardController extends BaseController {
*/
@GetMapping("/bonusMonthAmount")
public AjaxResult getBonusMonthAmount(BonusQuery query) {
return success(bonusService.selectMonthAmount(query));
return success(bonusService.selectMonthPayedAmount(query));
}
/**
@ -122,13 +122,13 @@ public class SmDashboardController extends BaseController {
*/
@GetMapping("/bonusDailyAmount")
public AjaxResult getBonusDailyAmount(BonusQuery query) {
List<BonusDailyAmountVO> list = bonusService.selectDailyAmount(query);
List<LocalDateDecimalVO> list = bonusService.selectDailyPayedAmount(query);
// 若开始和结束日期不为空则补全缺失的日期
if (query.getPayDateStart() != null && query.getPayDateEnd() != null) {
list = CollectionUtils.fillVoids(list, BonusDailyAmountVO::getKey, (date) -> {
BonusDailyAmountVO vo = new BonusDailyAmountVO();
list = CollectionUtils.fillVoids(list, LocalDateDecimalVO::getKey, (date) -> {
LocalDateDecimalVO vo = new LocalDateDecimalVO();
vo.setKey(date);
vo.setSum(BigDecimal.ZERO);
vo.setValue(BigDecimal.ZERO);
return vo;
}, query.getPayDateStart(), query.getPayDateEnd());
}