|
@@ -1,80 +0,0 @@
|
|
|
-package com.xy.controller;
|
|
|
-
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.date.DatePattern;
|
|
|
-import cn.hutool.core.date.DateTime;
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
-import com.xy.annotate.RestMappingController;
|
|
|
-import com.xy.dto.DeviceDataDto;
|
|
|
-import com.xy.dto.MercMiniDeviceDto;
|
|
|
-import com.xy.dto.OrderRefundDto;
|
|
|
-import com.xy.service.DeviceDataServiceImpl;
|
|
|
-import com.xy.service.OrderRefundService;
|
|
|
-import com.xy.utils.MercAuthUtils;
|
|
|
-import com.xy.utils.R;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-/***
|
|
|
- * 商家端小程序-首页
|
|
|
- * @author 谭斌
|
|
|
- * @date 2023/3/13 14:38
|
|
|
- */
|
|
|
-@Service
|
|
|
-@AllArgsConstructor(onConstructor_ = @Autowired)
|
|
|
-@Api(tags = "商家端小程序-首页")
|
|
|
-@RestMappingController("merc-mini/homepage")
|
|
|
-public class MercMiniDeviceHomePageController {
|
|
|
-
|
|
|
- private DeviceDataServiceImpl deviceDataService;
|
|
|
- private OrderRefundService refundService;
|
|
|
-
|
|
|
-
|
|
|
- @PostMapping("count")
|
|
|
- @ApiOperation("首页统计")
|
|
|
- public R<MercMiniDeviceDto.HomePageVO> homepageCount() {
|
|
|
- MercMiniDeviceDto.HomePageVO vo = new MercMiniDeviceDto.HomePageVO();
|
|
|
- Long mercId = MercAuthUtils.getMercId();
|
|
|
- //当天
|
|
|
- MercMiniDeviceDto.DayCountVO day = new MercMiniDeviceDto.DayCountVO().setOrderNum(0).setSalesPrice(0).setRefundMoney(0);
|
|
|
- List<DeviceDataDto.Vo> mercDataOneDay = deviceDataService.getMercDataOneDay(mercId, DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN));
|
|
|
- if (CollUtil.isNotEmpty(mercDataOneDay)) {
|
|
|
- //今日退款成功订单金额
|
|
|
- OrderRefundDto.CountByDateVO countByDateVO = R.feignCheckData(refundService.countByDate(new OrderRefundDto.CountByDateDTO().setDate(DateTime.now()).setMercId(mercId)));
|
|
|
- Integer hisRefundMoney = countByDateVO.getHisRefundMoney();
|
|
|
- Integer todayRefundMoney = countByDateVO.getTodayRefundMoney();
|
|
|
- //今日销售额 (扣除今日的订单的退款金额)
|
|
|
- day.setDayHisRefundMoney(hisRefundMoney);
|
|
|
- day.setDayRefundMoney(todayRefundMoney);
|
|
|
- //改为和更多数据中的今日收益一样
|
|
|
- day.setSalesPrice(mercDataOneDay.stream().mapToInt(DeviceDataDto.Vo::getSalesMoney).sum() - todayRefundMoney);
|
|
|
- day.setOrderNum(mercDataOneDay.stream().mapToInt(DeviceDataDto.Vo::getSalesCount).sum());
|
|
|
- day.setRefundMoney(hisRefundMoney + todayRefundMoney);
|
|
|
- }
|
|
|
- vo.setDay(day);
|
|
|
- //当月
|
|
|
- MercMiniDeviceDto.MonthCountVO month = new MercMiniDeviceDto.MonthCountVO().setOrderNum(0).setSalesPrice(0).setRefundMoney(0);
|
|
|
- List<DeviceDataDto.Vo> mercDataOneMonth = deviceDataService.getMercDataOneMonth(mercId, DateUtil.format(new Date(), DatePattern.SIMPLE_MONTH_PATTERN));
|
|
|
- if (CollUtil.isNotEmpty(mercDataOneMonth)) {
|
|
|
- OrderRefundDto.CountByMonthVO countByMonthVO = R.feignCheckData(refundService.countByMonth(new OrderRefundDto.CountByMonthDTO().setCurMonthDate(DateTime.now()).setMercId(mercId)));
|
|
|
- Integer hisMonthRefundMoney = countByMonthVO.getHisMonthRefundMoney();
|
|
|
- Integer monthRefundMoney = countByMonthVO.getMonthRefundMoney();
|
|
|
- month.setSalesPrice(mercDataOneMonth.stream().mapToInt(DeviceDataDto.Vo::getSalesMoney).sum() - monthRefundMoney);
|
|
|
- month.setOrderNum(mercDataOneMonth.stream().mapToInt(DeviceDataDto.Vo::getSalesCount).sum());
|
|
|
- month.setRefundMoney(hisMonthRefundMoney + monthRefundMoney);
|
|
|
- month.setMonthRefundMoney(monthRefundMoney);
|
|
|
- month.setMonthHisRefundMoney(hisMonthRefundMoney);
|
|
|
- }
|
|
|
- vo.setMonth(month);
|
|
|
- return R.ok(vo);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|