收益相关代码更新
This commit is contained in:
parent
402a84dc44
commit
561deee01a
|
|
@ -1,15 +1,15 @@
|
|||
package com.playlet.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.playlet.common.core.domain.Result;
|
||||
import com.playlet.system.pojo.vo.RevenueRecordStatisticsVO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.playlet.common.annotation.Log;
|
||||
import com.playlet.common.enums.BusinessType;
|
||||
import com.playlet.system.domain.PlayletRevenueRecord;
|
||||
|
|
@ -36,8 +36,7 @@ public class PlayletRevenueRecordController extends BaseController{
|
|||
|
||||
@RequiresPermissions("system:record:view")
|
||||
@GetMapping()
|
||||
public String record()
|
||||
{
|
||||
public String record() {
|
||||
return prefix + "/record";
|
||||
}
|
||||
|
||||
|
|
@ -47,8 +46,7 @@ public class PlayletRevenueRecordController extends BaseController{
|
|||
@RequiresPermissions("system:record:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(PlayletRevenueRecord playletRevenueRecord)
|
||||
{
|
||||
public TableDataInfo list(PlayletRevenueRecord playletRevenueRecord) {
|
||||
startPage();
|
||||
List<PlayletRevenueRecord> list = playletRevenueRecordService.selectPlayletRevenueRecordList(playletRevenueRecord);
|
||||
return getDataTable(list);
|
||||
|
|
@ -61,8 +59,7 @@ public class PlayletRevenueRecordController extends BaseController{
|
|||
@Log(title = "短剧任务收益", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(PlayletRevenueRecord playletRevenueRecord)
|
||||
{
|
||||
public AjaxResult export(PlayletRevenueRecord playletRevenueRecord) {
|
||||
List<PlayletRevenueRecord> list = playletRevenueRecordService.selectPlayletRevenueRecordList(playletRevenueRecord);
|
||||
ExcelUtil<PlayletRevenueRecord> util = new ExcelUtil<PlayletRevenueRecord>(PlayletRevenueRecord.class);
|
||||
return util.exportExcel(list, "短剧任务收益数据");
|
||||
|
|
@ -72,8 +69,7 @@ public class PlayletRevenueRecordController extends BaseController{
|
|||
* 新增短剧任务收益
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String add()
|
||||
{
|
||||
public String add() {
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
|
|
@ -84,8 +80,7 @@ public class PlayletRevenueRecordController extends BaseController{
|
|||
@Log(title = "短剧任务收益", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(PlayletRevenueRecord playletRevenueRecord)
|
||||
{
|
||||
public AjaxResult addSave(PlayletRevenueRecord playletRevenueRecord) {
|
||||
return toAjax(playletRevenueRecordService.insertPlayletRevenueRecord(playletRevenueRecord));
|
||||
}
|
||||
|
||||
|
|
@ -94,8 +89,7 @@ public class PlayletRevenueRecordController extends BaseController{
|
|||
*/
|
||||
@RequiresPermissions("system:record:edit")
|
||||
@GetMapping("/edit/{id}")
|
||||
public String edit(@PathVariable("id") Long id, ModelMap mmap)
|
||||
{
|
||||
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
|
||||
PlayletRevenueRecord playletRevenueRecord = playletRevenueRecordService.selectPlayletRevenueRecordById(id);
|
||||
mmap.put("playletRevenueRecord", playletRevenueRecord);
|
||||
return prefix + "/edit";
|
||||
|
|
@ -108,8 +102,7 @@ public class PlayletRevenueRecordController extends BaseController{
|
|||
@Log(title = "短剧任务收益", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(PlayletRevenueRecord playletRevenueRecord)
|
||||
{
|
||||
public AjaxResult editSave(PlayletRevenueRecord playletRevenueRecord) {
|
||||
return toAjax(playletRevenueRecordService.updatePlayletRevenueRecord(playletRevenueRecord));
|
||||
}
|
||||
|
||||
|
|
@ -120,8 +113,28 @@ public class PlayletRevenueRecordController extends BaseController{
|
|||
@Log(title = "短剧任务收益", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
public AjaxResult remove(String ids) {
|
||||
return toAjax(playletRevenueRecordService.deletePlayletRevenueRecordByIds(ids));
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/statistics/time")
|
||||
@ApiOperation(value = "短剧收益时间统计")
|
||||
public Result<PlayletRevenueRecord> statisticsTime(@RequestBody PlayletRevenueRecord playletRevenueRecord) {
|
||||
return Result.success(playletRevenueRecordService.statisticsTime(playletRevenueRecord));
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/statistics")
|
||||
@ApiOperation(value = "短剧收益统计")
|
||||
public Result<RevenueRecordStatisticsVO> statistics(@RequestBody PlayletRevenueRecord playletRevenueRecord) {
|
||||
return Result.success(playletRevenueRecordService.statistics(playletRevenueRecord));
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/statistics/time/type")
|
||||
@ApiOperation(value = "短剧收益时间统计分类")
|
||||
public Result<List<PlayletRevenueRecord>> statisticsTimeType(@RequestBody PlayletRevenueRecord playletRevenueRecord) {
|
||||
return Result.success(playletRevenueRecordService.statisticsTimeType(playletRevenueRecord));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.playlet.system.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.playlet.system.domain.PlayletRevenueRecord;
|
||||
import com.playlet.system.pojo.vo.RevenueRecordStatisticsVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -60,4 +61,10 @@ public interface IPlayletRevenueRecordService extends IService<PlayletRevenueRec
|
|||
* @return 结果
|
||||
*/
|
||||
public int deletePlayletRevenueRecordById(Long id);
|
||||
|
||||
PlayletRevenueRecord statisticsTime(PlayletRevenueRecord record);
|
||||
|
||||
RevenueRecordStatisticsVO statistics(PlayletRevenueRecord record);
|
||||
|
||||
List<PlayletRevenueRecord> statisticsTimeType(PlayletRevenueRecord record);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,17 @@
|
|||
package com.playlet.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.playlet.common.utils.DateUtils;
|
||||
import com.playlet.system.pojo.vo.RevenueRecordStatisticsVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.playlet.system.mapper.PlayletRevenueRecordMapper;
|
||||
|
|
@ -90,4 +99,118 @@ public class PlayletRevenueRecordServiceImpl extends ServiceImpl<PlayletRevenueR
|
|||
public int deletePlayletRevenueRecordById(Long id) {
|
||||
return playletRevenueRecordMapper.deletePlayletRevenueRecordById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayletRevenueRecord statisticsTime(PlayletRevenueRecord record) {
|
||||
PlayletRevenueRecord revenueRecord = new PlayletRevenueRecord();
|
||||
List<PlayletRevenueRecord> revenueRecordList = selectPlayletRevenueRecordList(record);
|
||||
if (CollectionUtils.isNotEmpty(revenueRecordList)) {
|
||||
long rechargeMoney = 0L;
|
||||
long refundMoney = 0L;
|
||||
long estimateEarnings = 0L;
|
||||
for (PlayletRevenueRecord revenue : revenueRecordList) {
|
||||
rechargeMoney = rechargeMoney + revenue.getRechargeMoney();
|
||||
refundMoney = refundMoney + revenue.getRefundMoney();
|
||||
estimateEarnings = estimateEarnings + revenue.getEstimateEarnings();
|
||||
}
|
||||
revenueRecord.setRechargeMoney(rechargeMoney);
|
||||
revenueRecord.setRefundMoney(refundMoney);
|
||||
revenueRecord.setEstimateEarnings(estimateEarnings);
|
||||
} else {
|
||||
revenueRecord.setRechargeMoney(0L);
|
||||
revenueRecord.setRefundMoney(0L);
|
||||
revenueRecord.setEstimateEarnings(0L);
|
||||
}
|
||||
return revenueRecord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevenueRecordStatisticsVO statistics(PlayletRevenueRecord record) {
|
||||
RevenueRecordStatisticsVO vo = new RevenueRecordStatisticsVO();
|
||||
// 总金额。
|
||||
List<PlayletRevenueRecord> revenueRecordListByTotal = selectPlayletRevenueRecordList(record);
|
||||
if (CollectionUtils.isNotEmpty(revenueRecordListByTotal)) {
|
||||
vo.setTotalMoney(revenueRecordListByTotal.stream().mapToLong(PlayletRevenueRecord::getPracticalEarnings).sum());
|
||||
}
|
||||
// 开始时间结束时间缺省值
|
||||
Long startTime = System.currentTimeMillis();
|
||||
Long endTime = System.currentTimeMillis();
|
||||
// 今日
|
||||
startTime = timeGain(null);
|
||||
timeSupplement(record, startTime, endTime);
|
||||
List<PlayletRevenueRecord> revenueRecordListByDay = selectPlayletRevenueRecordList(record);
|
||||
if (CollectionUtils.isNotEmpty(revenueRecordListByDay)) {
|
||||
vo.setTodayEstimate(revenueRecordListByDay.stream().mapToLong(PlayletRevenueRecord::getEstimateEarnings).sum());
|
||||
}
|
||||
// 七日
|
||||
startTime = timeGain(-7);
|
||||
timeSupplement(record, startTime, endTime);
|
||||
List<PlayletRevenueRecord> revenueRecordListBySevenDay = selectPlayletRevenueRecordList(record);
|
||||
if (CollectionUtils.isNotEmpty(revenueRecordListBySevenDay)) {
|
||||
vo.setSevenDaysEstimate(revenueRecordListBySevenDay.stream().mapToLong(PlayletRevenueRecord::getEstimateEarnings).sum());
|
||||
}
|
||||
// 昨日
|
||||
startTime = timeGain(-1);
|
||||
endTime = timeGain(null);
|
||||
timeSupplement(record, startTime, endTime);
|
||||
List<PlayletRevenueRecord> revenueRecordListByYesterday = selectPlayletRevenueRecordList(record);
|
||||
if (CollectionUtils.isNotEmpty(revenueRecordListByYesterday)) {
|
||||
vo.setSevenDaysEstimate(revenueRecordListByYesterday.stream().mapToLong(PlayletRevenueRecord::getEstimateEarnings).sum());
|
||||
}
|
||||
// 本月
|
||||
startTime = timeGain(1);
|
||||
timeSupplement(record, startTime, endTime);
|
||||
List<PlayletRevenueRecord> revenueRecordListByMoney = selectPlayletRevenueRecordList(record);
|
||||
if (CollectionUtils.isNotEmpty(revenueRecordListByMoney)) {
|
||||
vo.setSevenDaysEstimate(revenueRecordListByMoney.stream().mapToLong(PlayletRevenueRecord::getEstimateEarnings).sum());
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayletRevenueRecord> statisticsTimeType(PlayletRevenueRecord record) {
|
||||
List<PlayletRevenueRecord> listByReturn = new ArrayList<>();
|
||||
|
||||
List<PlayletRevenueRecord> revenueRecordList = selectPlayletRevenueRecordList(record);
|
||||
if (CollectionUtils.isNotEmpty(revenueRecordList)) {
|
||||
Map<Long, List<PlayletRevenueRecord>> listMap = revenueRecordList.stream().collect(Collectors.groupingBy(PlayletRevenueRecord::getEarningsType));
|
||||
for (Long key : listMap.keySet()) {
|
||||
List<PlayletRevenueRecord> list = listMap.get(key);
|
||||
long rechargeMoney = 0L;
|
||||
long refundMoney = 0L;
|
||||
long estimateEarnings = 0L;
|
||||
for (PlayletRevenueRecord revenue : list) {
|
||||
rechargeMoney = rechargeMoney + revenue.getRechargeMoney();
|
||||
refundMoney = refundMoney + revenue.getRefundMoney();
|
||||
estimateEarnings = estimateEarnings + revenue.getEstimateEarnings();
|
||||
}
|
||||
PlayletRevenueRecord revenueRecord = new PlayletRevenueRecord();
|
||||
revenueRecord.setEarningsType(key);
|
||||
revenueRecord.setRechargeMoney(rechargeMoney);
|
||||
revenueRecord.setRefundMoney(refundMoney);
|
||||
revenueRecord.setEstimateEarnings(estimateEarnings);
|
||||
listByReturn.add(revenueRecord);
|
||||
}
|
||||
}
|
||||
return listByReturn;
|
||||
}
|
||||
|
||||
// 时间更新
|
||||
private void timeSupplement(PlayletRevenueRecord record, Long startTime, Long endTime) {
|
||||
record.setStartTime(startTime);
|
||||
record.setEndTime(endTime);
|
||||
}
|
||||
|
||||
// 获取时间
|
||||
private Long timeGain(Integer day) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
if (ObjectUtils.isNotNull(day)) {
|
||||
calendar.set(Calendar.DATE, day);
|
||||
}
|
||||
return calendar.getTimeInMillis();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue