diff --git a/smart-switch-service/src/main/java/com/ruoyi/common/domain/vo/LocalDateDecimalVO.java b/smart-switch-service/src/main/java/com/ruoyi/common/domain/vo/LocalDateDecimalVO.java new file mode 100644 index 00000000..d0259891 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/common/domain/vo/LocalDateDecimalVO.java @@ -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; +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.java index b8a751ce..0c38bf41 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.java @@ -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 selectMonthAmount(@Param("query") BonusQuery query); + List selectMonthPayedAmount(@Param("query") BonusQuery query); /** * 按日查询 @@ -136,4 +137,14 @@ public interface BonusMapper * 查询未分成金额,并以到账方分组 */ List selectWaitAmountGroupByArrival(@Param("query") BonusQuery query); + + /** + * 按日查询已分成金额 + */ + List selectDailyPayedAmount(@Param("query") BonusQuery query); + + /** + * 查询已分成金额 + */ + BigDecimal selectSumOfPayedAmount(@Param("query") BonusQuery query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml index 750bb5f5..f27821bc 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml @@ -145,11 +145,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select year(sb.pay_time) as `year`, month(sb.pay_time) as `month`, - sum(amount) as amount + sum(payed_amount) as amount @@ -193,6 +193,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" group by `key` + + + + + + + insert into ss_bonus diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusService.java index 1927ff4a..3a26ea4a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusService.java @@ -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 selectMonthAmount(BonusQuery query); + List selectMonthPayedAmount(BonusQuery query); /** * 按日查询分成 @@ -158,4 +159,14 @@ public interface BonusService * 根据ID支付分成 */ int payBonusById(Long id); + + /** + * 按日查询已分成金额 + */ + List selectDailyPayedAmount(BonusQuery query); + + /** + * 查询已分成金额总和 + */ + BigDecimal selectSumOfPayedAmount(BonusQuery query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java index 97b15c0a..6b55e3cb 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java @@ -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 selectMonthAmount(BonusQuery query) { - return bonusMapper.selectMonthAmount(query); + public List selectMonthPayedAmount(BonusQuery query) { + return bonusMapper.selectMonthPayedAmount(query); } @Override @@ -422,6 +423,16 @@ public class BonusServiceImpl implements BonusService return this.payBonus(bonus); } + @Override + public List selectDailyPayedAmount(BonusQuery query) { + return bonusMapper.selectDailyPayedAmount(query); + } + + @Override + public BigDecimal selectSumOfPayedAmount(BonusQuery query) { + return bonusMapper.selectSumOfPayedAmount(query); + } + private int batchUpdateAmount(List list) { if (CollectionUtils.isEmptyElement(list)) { return 0; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillVO.java index 60e08953..393dbb7a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillVO.java @@ -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; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml index c33e5f9e..03837c5d 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml @@ -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 diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDashboardController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDashboardController.java index 946d417e..5a0c47bf 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDashboardController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDashboardController.java @@ -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 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; + } } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java index 02b10b1e..e0f075fa 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java @@ -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 list = bonusService.selectDailyAmount(query); + List 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()); }