diff --git a/share-space-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java b/share-space-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java index 50c4dad..3a5d3b2 100644 --- a/share-space-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java +++ b/share-space-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java @@ -48,6 +48,8 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +import static com.ruoyi.common.constant.ServiceConstants.TIME_LIMIT_7_DAYS; + /** * app接口(需要登录校验的) @@ -97,13 +99,10 @@ public class AppVerifyController extends BaseController * 首页统计 */ @GetMapping(value = { "/index" }) - public AjaxResult index(String startTime,String endTime) + public AjaxResult index(String timeLimit) { - logger.info("【首页统计/index】参数:startTime={},endTime={}", startTime,endTime); - AjaxResult ajax = AjaxResult.success(); - IndexAdminVo incomeVos = orderService.indexStatistics(startTime, endTime,getUserId()); - ajax.put(AjaxResult.DATA_TAG, incomeVos); - return ajax; + logger.info("【首页统计/index】参数:timeLimit={}", timeLimit); + return success(orderService.indexStatistics(timeLimit)); } /** diff --git a/share-space-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java b/share-space-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java index 3ce5030..cf127b7 100644 --- a/share-space-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java +++ b/share-space-common/src/main/java/com/ruoyi/common/constant/ServiceConstants.java @@ -1106,5 +1106,39 @@ public class ServiceConstants { /**----------------------------是否已退款end----------------------------*/ + /**----------------------------首页时间范围start----------------------------*/ + + /** + * 是否已退款: 1-7天 + */ + public static final String TIME_LIMIT_7_DAYS = "1"; + + /** + * 是否已退款: 1-30天 + */ + public static final String TIME_LIMIT_30_DAYS = "2"; + + /**----------------------------首页时间范围end----------------------------*/ + + /**----------------------------首页时间范围start----------------------------*/ + + /** + * 时间范围: 今天 + */ + public static final String TIME_LIMIT_TODAY = "today"; + + /** + * 时间范围: 本周 + */ + public static final String TIME_LIMIT_WEEK = "week"; + + /** + * 时间范围: 本月 + */ + public static final String TIME_LIMIT_MONTH = "month"; + + /**----------------------------首页时间范围end----------------------------*/ + + } diff --git a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetail.java b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetail.java index b6e6b7e..d4d044f 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetail.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetail.java @@ -48,6 +48,10 @@ public class DividendDetail extends BaseEntity @Excel(name = "分账金额") private BigDecimal dividendAmount; + /** 结算金额 */ + @Excel(name = "结算金额") + private BigDecimal settlementAmount; + /** 分红比例 */ @Excel(name = "分红比例") private BigDecimal dividendProportion; diff --git a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetailQuery.java b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetailQuery.java index d8b07b7..3711452 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetailQuery.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetailQuery.java @@ -2,9 +2,17 @@ package com.ruoyi.ss.dividendDetail.domain; import lombok.Data; +import java.time.LocalDateTime; + @Data public class DividendDetailQuery extends DividendDetail{ /** 代理商名称 */ private String agentName; + + /** 开始时间 */ + private LocalDateTime startTime; + + /** 结束时间 */ + private LocalDateTime endTime; } diff --git a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetailVO.java b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetailVO.java index 2872bdb..58f18bc 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetailVO.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/domain/DividendDetailVO.java @@ -5,7 +5,4 @@ import lombok.Data; @Data public class DividendDetailVO extends DividendDetail{ - /** 代理名称 */ - private String agentName; - } diff --git a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/mapper/DividendDetailMapper.java b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/mapper/DividendDetailMapper.java index 930dd31..f82a0ab 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/mapper/DividendDetailMapper.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/mapper/DividendDetailMapper.java @@ -1,9 +1,15 @@ package com.ruoyi.ss.dividendDetail.mapper; +import com.ruoyi.ss.device.domain.DeviceQuery; import com.ruoyi.ss.dividendDetail.domain.DividendDetail; import com.ruoyi.ss.dividendDetail.domain.DividendDetailQuery; import com.ruoyi.ss.dividendDetail.domain.DividendDetailVO; +import com.ruoyi.system.domain.vo.InCome; +import com.ruoyi.system.domain.vo.IndexAdminVo; +import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.List; @@ -69,4 +75,19 @@ public interface DividendDetailMapper * @return */ List selectRlDividendDetailListByOrderNo(String orderNo); + + /** + * 根据商户id查询近7天收入 + */ + List select7DaysIncome(Long merchantId); + + /** + * 根据商户id查询近30天收入 + */ + List select30DaysIncome(Long merchantId); + + /** + * 查询收入 + */ + BigDecimal getIncome(DividendDetailQuery query ); } diff --git a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/mapper/DividendDetailMapper.xml b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/mapper/DividendDetailMapper.xml index 13944e4..fc9a1a6 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/mapper/DividendDetailMapper.xml +++ b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/mapper/DividendDetailMapper.xml @@ -7,16 +7,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select dd.id, dd.partner_id, dd.partner_name, dd.partner_phone, dd.partner_type, dd.order_no,dd.status,dd.refund_amount, - dd.total_amount, dd.dividend_amount, dd.dividend_proportion, dd.create_time from ss_dividend_detail dd + select dd.id, + dd.partner_id, + dd.partner_name, + dd.partner_phone, + dd.partner_type, + dd.order_no, + dd.status, + dd.refund_amount, + dd.total_amount, + dd.dividend_amount, + dd.settlement_amount, + dd.dividend_proportion, + dd.create_time + from ss_dividend_detail dd left join ss_user u on u.user_id = dd.partner_id - + + where 1=1 + ${params.dataScope} order by dd.create_time desc @@ -39,6 +58,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where dd.order_no = #{orderNo} + + + + + + + insert into ss_dividend_detail @@ -49,6 +125,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order_no, total_amount, dividend_amount, + settlement_amount, dividend_proportion, create_time, status, @@ -61,6 +138,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{orderNo}, #{totalAmount}, #{dividendAmount}, + #{settlementAmount}, #{dividendProportion}, #{createTime}, #{status}, @@ -77,6 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order_no = #{orderNo}, total_amount = #{totalAmount}, dividend_amount = #{dividendAmount}, + settlement_amount = #{settlementAmount}, dividend_proportion = #{dividendProportion}, refund_amount = #{refundAmount}, create_time = #{createTime}, diff --git a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/service/IDividendDetailService.java b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/service/IDividendDetailService.java index 0ed101f..a70ba4f 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/service/IDividendDetailService.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/service/IDividendDetailService.java @@ -3,8 +3,11 @@ package com.ruoyi.ss.dividendDetail.service; import com.ruoyi.ss.dividendDetail.domain.DividendDetail; import com.ruoyi.ss.dividendDetail.domain.DividendDetailQuery; import com.ruoyi.ss.dividendDetail.domain.DividendDetailVO; +import com.ruoyi.system.domain.vo.InCome; +import com.ruoyi.system.domain.vo.IndexAdminVo; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.List; /** @@ -96,4 +99,24 @@ public interface IDividendDetailService * @return 结果 */ public int updateRefundAmount(Long id, BigDecimal userRefundAmount); + + /** + * 查询近7天收入 + * @param merchantId 商户id + * @return 结果 + */ + List select7DaysIncome(Long merchantId); + + /** + * 查询近30天收入 + * @param merchantId 商户id + * @return 结果 + */ + List select30DaysIncome(Long merchantId); + + /** + * 获取指定时间范围的收入 + * @return 收入金额 + */ + BigDecimal getIncome(DividendDetailQuery query); } diff --git a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/service/impl/DividendDetailServiceImpl.java b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/service/impl/DividendDetailServiceImpl.java index e4c5c09..5934786 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/service/impl/DividendDetailServiceImpl.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/dividendDetail/service/impl/DividendDetailServiceImpl.java @@ -1,6 +1,5 @@ package com.ruoyi.ss.dividendDetail.service.impl; -//import com.ruoyi.common.core.domain.entity.RlUser; import com.ruoyi.common.utils.DateUtils; //import com.ruoyi.system.domain.agent.RlAgentVO; import com.ruoyi.ss.dividendDetail.domain.DividendDetail; @@ -10,12 +9,16 @@ import com.ruoyi.ss.dividendDetail.domain.DividendDetailVO; //import com.ruoyi.system.domain.userExt.RlUserExt; import com.ruoyi.ss.dividendDetail.mapper.DividendDetailMapper; import com.ruoyi.ss.dividendDetail.service.IDividendDetailService; +import com.ruoyi.system.domain.vo.InCome; +import com.ruoyi.system.domain.vo.IndexAdminVo; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; - import java.util.List; +import java.time.LocalDateTime; +import java.util.Collections; +import java.util.List; /** * 分账明细Service业务层处理 @@ -28,19 +31,7 @@ import java.math.BigDecimal; public class DividendDetailServiceImpl implements IDividendDetailService { @Resource - private DividendDetailMapper rlDividendDetailMapper; - -// @Resource -// private IRlUserExtService userExtService; -// -// @Autowired -// private IRlUserService userService; -// -// @Autowired -// private IRlAgentService agentService; -// -// @Autowired -// private IRlChangeBalanceService changeBalanceService; + private DividendDetailMapper dividendDetailMapper; /** * 查询分账明细 @@ -51,7 +42,7 @@ public class DividendDetailServiceImpl implements IDividendDetailService @Override public DividendDetail selectRlDividendDetailById(Long id) { - return rlDividendDetailMapper.selectRlDividendDetailById(id); + return dividendDetailMapper.selectRlDividendDetailById(id); } /** @@ -64,7 +55,7 @@ public class DividendDetailServiceImpl implements IDividendDetailService // @DataScope(agentAlias = "a",userAlias = "u") public List selectRlDividendDetailList(DividendDetailQuery rlDividendDetail) { - return rlDividendDetailMapper.selectRlDividendDetailList(rlDividendDetail); + return dividendDetailMapper.selectRlDividendDetailList(rlDividendDetail); } /** @@ -74,7 +65,7 @@ public class DividendDetailServiceImpl implements IDividendDetailService */ @Override public List selectRlDividendDetailListByOrderNo(String orderNo) { - return rlDividendDetailMapper.selectRlDividendDetailListByOrderNo(orderNo); + return dividendDetailMapper.selectRlDividendDetailListByOrderNo(orderNo); } /** @@ -87,7 +78,7 @@ public class DividendDetailServiceImpl implements IDividendDetailService public int insertRlDividendDetail(DividendDetail rlDividendDetail) { rlDividendDetail.setCreateTime(DateUtils.getNowDate()); - return rlDividendDetailMapper.insertRlDividendDetail(rlDividendDetail); + return dividendDetailMapper.insertRlDividendDetail(rlDividendDetail); } /** @@ -99,7 +90,7 @@ public class DividendDetailServiceImpl implements IDividendDetailService @Override public int updateRlDividendDetail(DividendDetail rlDividendDetail) { - return rlDividendDetailMapper.updateRlDividendDetail(rlDividendDetail); + return dividendDetailMapper.updateRlDividendDetail(rlDividendDetail); } /** @@ -111,7 +102,7 @@ public class DividendDetailServiceImpl implements IDividendDetailService @Override public int deleteRlDividendDetailByIds(Long[] ids) { - return rlDividendDetailMapper.deleteRlDividendDetailByIds(ids); + return dividendDetailMapper.deleteRlDividendDetailByIds(ids); } /** @@ -123,72 +114,10 @@ public class DividendDetailServiceImpl implements IDividendDetailService @Override public int deleteRlDividendDetailById(Long id) { - return rlDividendDetailMapper.deleteRlDividendDetailById(id); + return dividendDetailMapper.deleteRlDividendDetailById(id); } -// /** -// * 计算分账金额 -// * @param originalOrder -// * @return -// */ -// @Override -// public int calculationDividend(RlOrder originalOrder,String userType) { -// RlUserExt rlUserExt; -// RlUser rlUser ; -// RlDividendDetail rlDividendDetail = new RlDividendDetail(); -// if(userType.equals(ServiceConstants.USER_TYPE_MERCHANT)){ -// rlUserExt = userExtService.selectRlUserExtByUserId(originalOrder.getMerchantId()); -// rlUser = userService.selectUserById(rlUserExt.getUserId()); -// }else if(userType.equals(ServiceConstants.USER_TYPE_AGENT)){ -// RlAgentVO rlAgentVO = agentService.selectRlAgentByAgentId(originalOrder.getAgentId()); -// rlUserExt = userExtService.selectRlUserExtByUserId(rlAgentVO.getUserid()); -// rlUser = userService.selectUserById(rlUserExt.getUserId()); -// rlDividendDetail.setDividendProportion(rlAgentVO.getDividendProportion()); -// }else{ -// throw new ServiceException("用户类型有误"); -// } -// rlDividendDetail.setAgentId(originalOrder.getAgentId()); -// rlDividendDetail.setPartnerId(rlUserExt.getUserId()); -// rlDividendDetail.setOrderNo(originalOrder.getOrderNo()); -// rlDividendDetail.setTotalAmount(originalOrder.getPayFee()); -// rlDividendDetail.setCreateTime(DateUtils.getNowDate()); -// rlDividendDetail.setPartnerName(rlUser.getUserName()); -// rlDividendDetail.setPartnerPhone(rlUser.getPhonenumber()); -// rlDividendDetail.setPartnerType(rlUser.getUserType()); -// rlDividendDetail.setStatus(ServiceConstants.DIVIDEND_STATUS_NOT_SETTLED); -// int i = insertRlDividendDetail(rlDividendDetail); -// if(i>0){ -// log.info("=================【微信支付回调】计算合作人分成成功=================="); -// } -// return i; -// } - /** - * 计算分账金额 - * @param rlDividendDetails 分账明细 - * @return - */ -// @Override -// public int calculationAmount(List rlDividendDetails,BigDecimal totalDividendAmount) { -// log.info("【计算分账金额】计算分账金额开始============"); -// for(DividendDetailVO dividendDetail:rlDividendDetails){ -// log.info("【计算分账金额】租赁费和逾期费进行分成============"+totalDividendAmount); -// RlUserExt rlUserExt = userExtService.selectRlUserExtByUserId(dividendDetail.getPartnerId()); -// if(ObjectUtil.isNull(rlUserExt)){ -// throw new ServiceException("用户【"+dividendDetail.getPartnerName()+"】不存在"); -// } -// if(rlUserExt.getDividendProportion().compareTo(BigDecimal.ZERO)==0 || ObjectUtil.isNull(rlUserExt.getDividendProportion())){ -// throw new ServiceException("用户【"+dividendDetail.getPartnerName()+"】分账比例不能为空"); -// } -// // 保留两位小数点 -// BigDecimal dividendAmount = rlUserExt.getDividendProportion().multiply(totalDividendAmount) -// .setScale(2, RoundingMode.HALF_UP); -// dividendDetail.setDividendAmount(dividendAmount); -// dividendDetail.setStatus(ServiceConstants.DIVIDEND_STATUS_SETTLED); -// updateRlDividendDetail(dividendDetail); -// } -// return 1; -// } /** * 更新退款金额 @@ -202,7 +131,36 @@ public class DividendDetailServiceImpl implements IDividendDetailService DividendDetail rlDividendDetail = new DividendDetail(); rlDividendDetail.setRefundAmount(userRefundAmount); rlDividendDetail.setId(id); - return rlDividendDetailMapper.updateRlDividendDetail(rlDividendDetail); + return dividendDetailMapper.updateRlDividendDetail(rlDividendDetail); + } + + /** + * 查询近7天收入 + * @param merchantId 商户id + * @return 结果 + */ + @Override + public List select7DaysIncome(Long merchantId) { + return dividendDetailMapper.select7DaysIncome(merchantId); + } + + /** + * 查询近30天收入 + * @param merchantId 商户id + * @return 结果 + */ + @Override + public List select30DaysIncome(Long merchantId) { + return dividendDetailMapper.select30DaysIncome(merchantId); + } + + /** + * 查询收入 + * @return 结果 + */ + @Override + public BigDecimal getIncome(DividendDetailQuery query) { + return dividendDetailMapper.getIncome(query); } diff --git a/share-space-system/src/main/java/com/ruoyi/ss/order/mapper/OrderMapper.java b/share-space-system/src/main/java/com/ruoyi/ss/order/mapper/OrderMapper.java index d008412..a9e44f8 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/order/mapper/OrderMapper.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/order/mapper/OrderMapper.java @@ -7,6 +7,7 @@ import com.ruoyi.ss.order.domain.vo.ReservedTimePeriod; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.Date; import java.util.List; @@ -128,7 +129,7 @@ public interface OrderMapper /** * 订单数量 */ - Integer getOrderNum(@Param("startDateStr") String startDateStr , @Param("endDateStr") String endDateStr ,@Param("merchantId") Long merchantId); + Integer getOrderNum(@Param("merchantId") Long merchantId, @Param("startTime") LocalDateTime startDateStr , @Param("endTime") LocalDateTime endDateStr); /** * 已售数量 diff --git a/share-space-system/src/main/java/com/ruoyi/ss/order/mapper/OrderMapper.xml b/share-space-system/src/main/java/com/ruoyi/ss/order/mapper/OrderMapper.xml index f654693..ea0d5b1 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/order/mapper/OrderMapper.xml +++ b/share-space-system/src/main/java/com/ruoyi/ss/order/mapper/OrderMapper.xml @@ -254,12 +254,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/share-space-system/src/main/java/com/ruoyi/ss/order/service/IOrderService.java b/share-space-system/src/main/java/com/ruoyi/ss/order/service/IOrderService.java index d340442..c4cb52b 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/order/service/IOrderService.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/order/service/IOrderService.java @@ -210,7 +210,7 @@ public interface IOrderService /** * app首页统计 */ - IndexAdminVo indexStatistics(String startTime, String endTime, Long userId); + IndexAdminVo indexStatistics(String timeLimit); /** * 已售数量 diff --git a/share-space-system/src/main/java/com/ruoyi/ss/order/service/impl/OrderServiceImpl.java b/share-space-system/src/main/java/com/ruoyi/ss/order/service/impl/OrderServiceImpl.java index 20a34bc..b003ce1 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/order/service/impl/OrderServiceImpl.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/order/service/impl/OrderServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.ss.order.service.impl; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.ruoyi.common.annotation.DataScope; @@ -13,7 +14,11 @@ import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.common.utils.wx.vo.PrepayResponseVO; +import com.ruoyi.ss.device.domain.DeviceQuery; +import com.ruoyi.ss.device.domain.enums.DeviceStatus; +import com.ruoyi.ss.device.service.DeviceService; import com.ruoyi.ss.dividendDetail.domain.DividendDetail; +import com.ruoyi.ss.dividendDetail.domain.DividendDetailQuery; import com.ruoyi.ss.dividendDetail.service.IDividendDetailService; import com.ruoyi.ss.feeRule.domain.FeeRuleVO; import com.ruoyi.ss.feeRule.service.IFeeRuleService; @@ -35,10 +40,13 @@ import com.ruoyi.ss.orderOper.service.IOrderOperService; import com.ruoyi.ss.product.service.IProductService; import com.ruoyi.ss.refund.domain.Refund; import com.ruoyi.ss.refund.service.IRefundService; +import com.ruoyi.ss.room.domain.RoomQuery; +import com.ruoyi.ss.room.service.IRoomService; import com.ruoyi.ss.store.domain.StoreVO; import com.ruoyi.ss.store.service.IStoreService; import com.ruoyi.ss.user.domain.UserVO; import com.ruoyi.ss.user.service.IUserService; +import com.ruoyi.system.domain.vo.InCome; import com.ruoyi.system.domain.vo.IndexAdminVo; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.ss.pay.service.IWxPayService; @@ -55,9 +63,13 @@ import org.springframework.transaction.support.TransactionTemplate; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.DayOfWeek; import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjusters; import java.util.*; import static com.ruoyi.common.constant.ServiceConstants.*; @@ -105,6 +117,9 @@ public class OrderServiceImpl implements IOrderService @Autowired private IOrderOperService rlOrderOperService; + @Autowired + private DeviceService deviceService; + @Autowired private IOrderOperService orderOperService; @@ -115,7 +130,7 @@ public class OrderServiceImpl implements IOrderService private IDividendDetailService dividendDetailService; @Autowired - private IMsgLogService msgLogService; + private IRoomService roomService; @Autowired private IProductService productService; @@ -1131,15 +1146,8 @@ public class OrderServiceImpl implements IOrderService * 首页统计 */ @Override - public IndexAdminVo indexStatistics(String startTime,String endTime,Long userId) { - // 定义统一的日期格式 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - // 根据用户id查询代理商,根据代理商做数据权限隔离 - User rlUser = userService.selectUserById(userId); - if(!USER_TYPE_MERCHANT.equals(rlUser.getUserType())){ - throw new ServiceException("您没有权限访问"); - } - return getIndexAdminVoByAgentId(startTime, endTime, formatter,rlUser.getUserId()); + public IndexAdminVo indexStatistics(String timeLimit) { + return getIndexAdminVoByAgentId(timeLimit); } /** @@ -1168,78 +1176,132 @@ public class OrderServiceImpl implements IOrderService @NotNull - private IndexAdminVo getIndexAdminVoByAgentId(String startTime, String endTime, DateTimeFormatter formatter,Long merchantId) { - // 校验输入时间格式并判断时间区间是否超过15天 - if (StrUtil.isBlank(startTime) && StrUtil.isBlank(endTime)) { - // 获取今日订单数量和收入 - startTime = DateUtils.getYYYY_MM_DD(DateUtils.getNowDate()); - endTime = DateUtils.getYYYY_MM_DD(DateUtils.getNowDate()); - } - // 使用LocalDate统一日期处理 - LocalDate startDate = LocalDate.parse(startTime, formatter); - LocalDate endDate = LocalDate.parse(endTime, formatter); - - // 计算两者之间的天数差异 - long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); - if (daysBetween > 15) { - throw new ServiceException("时间范围不能超过15天"); - } - - // 创建结果对象 + private IndexAdminVo getIndexAdminVoByAgentId(String timeLimit) { + Long merchantId = getUserId(); IndexAdminVo indexAdminVo = new IndexAdminVo(); - ArrayList incomeVos = new ArrayList<>(); - // 遍历从 startDate 到 endDate 的每一天,生成订单数据 - for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) { - IndexAdminVo.IncomeVo orderFee = new IndexAdminVo.IncomeVo(); - String day = date.format(formatter); - String startDateStr = day + " "+ Constants.DATE_FORMAT_START_PEREND; - String endDateStr = day + " " +Constants.DATE_FORMAT_END_PEREND; - orderFee.setDay(day); // 设置每一天的日期 - BigDecimal orderFee1 = orderMapper.getOrderFee(startDateStr, endDateStr, merchantId);//订单金额 - orderFee.setOrderFee(orderFee1); - orderFee.setOrderNum(orderMapper.getOrderNum(startDateStr, endDateStr, merchantId));//订单数量 + /** 收入统计 */ + setIncome(merchantId,indexAdminVo); - incomeVos.add(orderFee); - } - // 设置收入数据 - indexAdminVo.setIncomeVoList(incomeVos); - // 获取今日订单数量和收入 - String todayStart = DateUtils.getYYYY_MM_DD(DateUtils.getNowDate()) + " " + Constants.DATE_FORMAT_START_PEREND; - String todayEnd = DateUtils.getYYYY_MM_DD(DateUtils.getNowDate()) + " " + Constants.DATE_FORMAT_END_PEREND; + /** 运营概况 */ + setOperateOverview(timeLimit, merchantId, indexAdminVo); - // 查询今日的订单数和营收 - Integer todayOrderNum = orderMapper.getOrderNum(todayStart, todayEnd, merchantId); - BigDecimal todayIncome = orderMapper.getOrderFee(todayStart, todayEnd, merchantId); - - // 设置今日的订单数和营收 - indexAdminVo.setTodayOrderNum(todayOrderNum); - indexAdminVo.setTodayIncome(todayIncome); - - String yesterdayStart = DateUtils.getYYYY_MM_DD(DateUtils.addDays(DateUtils.getNowDate(), -1)) + " " + Constants.DATE_FORMAT_START_PEREND; - String yesterdayEnd = DateUtils.getYYYY_MM_DD(DateUtils.addDays(DateUtils.getNowDate(), -1)) + " " + Constants.DATE_FORMAT_END_PEREND; - // 查询昨日的订单数和营收 - Integer yesterdayOrderNum = orderMapper.getOrderNum(yesterdayStart, yesterdayEnd, merchantId); - BigDecimal yesterdayIncome = orderMapper.getOrderFee(yesterdayStart, yesterdayEnd, merchantId); - - // 计算较昨日的营收和订单数 - BigDecimal comparedYesterdayIncome = todayIncome.subtract(yesterdayIncome); - BigDecimal comparedYesterdayOrderNum = new BigDecimal(todayOrderNum - yesterdayOrderNum); - - // 设置较昨日的营收和订单数 - indexAdminVo.setComparedYesterdayIncome(comparedYesterdayIncome); - indexAdminVo.setComparedYesterdayOrderNum(comparedYesterdayOrderNum); + /** 当前营运情况 */ + setDeviceOverview(merchantId,indexAdminVo); // 设置车辆统计数据 - IndexAdminVo.DeviceVO deviceVO = new IndexAdminVo.DeviceVO(); -// deviceVO.setTotal(deviceService.getTatalDeviceCount(merchantId,null,null)); -// deviceVO.setIdle(deviceService.getTatalDeviceCount(merchantId,ServiceConstants.VEHICLE_STATUS_NORMAL,null)); - String[] statusList = new String[] { VEHICLE_STATUS_IN_USING, VEHICLE_STATUS_TEMPORARILY_LOCK }; -// deviceVO.setRent(deviceService.getTatalDeviceCount(merchantId,null,statusList)); - indexAdminVo.setDeviceVO(deviceVO); return indexAdminVo; } + + private void setDeviceOverview(Long merchantId, IndexAdminVo indexAdminVo) { + RoomQuery query = new RoomQuery(); + query.setMerchantId(merchantId); + query.setType2(ROOM_TYPE2_PRIVATE_ROOM); + query.setStatus(ROOM_STATUS_INUSE); + indexAdminVo.setInUseRoomNum(roomService.getCount(query)); + query.setStatus(null); + indexAdminVo.setTotalRoomNum(roomService.getCount(query)); + + query.setType2(ROOM_TYPE2_LOBBY_DEVICE); + indexAdminVo.setTotalEquNum(roomService.getCount(query)); + query.setStatus(ROOM_STATUS_INUSE); + indexAdminVo.setInUseEquNum(roomService.getCount(query)); + + DeviceQuery deviceQuery = new DeviceQuery(); + deviceQuery.setUserId(merchantId); + indexAdminVo.setTotalDeviceNum(deviceService.selectCount(deviceQuery)); + + deviceQuery.setStatus(DeviceStatus.USING.getStatus()); + indexAdminVo.setInUseDeviceNum(deviceService.selectCount(deviceQuery)); + + } + + private void setOperateOverview(String timeLimit, Long merchantId, IndexAdminVo indexAdminVo) { + List incomeVos; + if(TIME_LIMIT_30_DAYS.equals(timeLimit)){ + incomeVos = dividendDetailService.select30DaysIncome(merchantId); + }else{ + // 查询7天的数据 + incomeVos = dividendDetailService.select7DaysIncome(merchantId); + } + indexAdminVo.setIncomeVoList(incomeVos); + // 根据查询出来的incomeVos,合计订单金额和订单数,保存到 indexAdminVo中 + indexAdminVo.setTotalIncome(incomeVos.stream().map(InCome::getOrderIncome).reduce(BigDecimal.ZERO, BigDecimal::add)); + indexAdminVo.setTotalOrderNum(incomeVos.stream().map(InCome::getOrderNum).reduce(0, Integer::sum)); + } + + private void setIncome(Long merchantId, IndexAdminVo indexAdminVo) { + // 获取今日收入和订单数 + indexAdminVo.setTodayIncome(getIncomeByTimeType(merchantId, TIME_LIMIT_TODAY)); + indexAdminVo.setTodayOrderNum(getOrderCountByTimeType(merchantId, TIME_LIMIT_TODAY)); + + // 获取本周收入和订单数 + indexAdminVo.setWeekIncome(getIncomeByTimeType(merchantId, TIME_LIMIT_WEEK)); + indexAdminVo.setWeekOrderNum(getOrderCountByTimeType(merchantId, TIME_LIMIT_WEEK)); + + // 获取本月收入和订单数 + indexAdminVo.setMonthIncome(getIncomeByTimeType(merchantId, TIME_LIMIT_MONTH)); + indexAdminVo.setMonthOrderNum(getOrderCountByTimeType(merchantId, TIME_LIMIT_MONTH)); + + } + + // 根据时间差收入 + public BigDecimal getIncomeByTimeType(Long merchantId, String timeType) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime; + + switch (timeType) { + case TIME_LIMIT_TODAY: + // 今日收入 + startTime = now.with(LocalTime.MIN); + break; + case TIME_LIMIT_WEEK: + // 本周收入(周一到现在) + startTime = now.with(LocalTime.MIN).with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); + break; + case TIME_LIMIT_MONTH: + // 本月收入 + startTime = now.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN); + break; + default: + throw new IllegalArgumentException("时间类型无效"); + } + + DividendDetailQuery dividendDetailQuery = new DividendDetailQuery(); + dividendDetailQuery.setStatus(DIVIDEND_STATUS_PAID); + dividendDetailQuery.setPartnerId(merchantId); + dividendDetailQuery.setStartTime(startTime); + dividendDetailQuery.setEndTime(now); + return dividendDetailService.getIncome(dividendDetailQuery); + } + + public Integer getOrderCountByTimeType(Long merchantId, String timeType) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime; + + switch (timeType) { + case TIME_LIMIT_TODAY: + // 今日订单数 + startTime = now.with(LocalTime.MIN); + break; + case TIME_LIMIT_WEEK: + // 本周订单数 + startTime = now.with(LocalTime.MIN) + .with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); + break; + case TIME_LIMIT_MONTH: + // 本月订单数 + startTime = now.with(TemporalAdjusters.firstDayOfMonth()) + .with(LocalTime.MIN); + break; + default: + throw new IllegalArgumentException("时间类型无效"); + } + + return orderMapper.getOrderNum(merchantId, startTime, now); + } + /** * 进行中的订单 */ diff --git a/share-space-system/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml b/share-space-system/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml index e16b783..f414318 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml +++ b/share-space-system/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml @@ -20,11 +20,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" r.refund_result, r.merchant_id, r.oper_time, - o.pay_type, - o.store_name, p.amount from ss_refund r - left join ss_pay_bill p on p.pay_id = o.pay_id + left join ss_pay_bill p on p.pay_id = r.pay_id left join ss_user m on m.user_id = r.merchant_id diff --git a/share-space-system/src/main/java/com/ruoyi/ss/room/mapper/RoomMapper.java b/share-space-system/src/main/java/com/ruoyi/ss/room/mapper/RoomMapper.java index 5cc4d82..23f1705 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/room/mapper/RoomMapper.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/room/mapper/RoomMapper.java @@ -117,4 +117,9 @@ public interface RoomMapper * @return boolean */ List selectIsExistRule(Long ruleId); + + /** + * 获取房间数 + */ + int getCount(@Param("query") RoomQuery query); } diff --git a/share-space-system/src/main/java/com/ruoyi/ss/room/mapper/RoomMapper.xml b/share-space-system/src/main/java/com/ruoyi/ss/room/mapper/RoomMapper.xml index 8565a48..9bc5acf 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/room/mapper/RoomMapper.xml +++ b/share-space-system/src/main/java/com/ruoyi/ss/room/mapper/RoomMapper.xml @@ -107,6 +107,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select room_name from ss_room where FIND_IN_SET( #{ruleId}, rule_ids ) + + insert into ss_room diff --git a/share-space-system/src/main/java/com/ruoyi/ss/room/service/IRoomService.java b/share-space-system/src/main/java/com/ruoyi/ss/room/service/IRoomService.java index 3d9fa91..6e65b61 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/room/service/IRoomService.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/room/service/IRoomService.java @@ -171,4 +171,8 @@ public interface IRoomService List selectWifiObjList(); + /** + * 获取房间数 + */ + int getCount(RoomQuery query); } diff --git a/share-space-system/src/main/java/com/ruoyi/ss/room/service/impl/RoomServiceImpl.java b/share-space-system/src/main/java/com/ruoyi/ss/room/service/impl/RoomServiceImpl.java index 3de03dc..aee0428 100644 --- a/share-space-system/src/main/java/com/ruoyi/ss/room/service/impl/RoomServiceImpl.java +++ b/share-space-system/src/main/java/com/ruoyi/ss/room/service/impl/RoomServiceImpl.java @@ -400,4 +400,12 @@ public class RoomServiceImpl implements IRoomService return wifiObjVOS; } + /** + * 获取房间数 + */ + @Override + public int getCount(RoomQuery query) { + return roomMapper.getCount(query); + } + } diff --git a/share-space-system/src/main/java/com/ruoyi/system/domain/vo/InCome.java b/share-space-system/src/main/java/com/ruoyi/system/domain/vo/InCome.java new file mode 100644 index 0000000..ffa4591 --- /dev/null +++ b/share-space-system/src/main/java/com/ruoyi/system/domain/vo/InCome.java @@ -0,0 +1,19 @@ +package com.ruoyi.system.domain.vo; + +import lombok.Data; +import java.math.BigDecimal; + +/** + * 经营概况,7天,30天 + */ +@Data +public class InCome { + + /** 日期 */ + private String day; + /** 订单营收 */ + private BigDecimal orderIncome; + /** 订单数 */ + private Integer orderNum; + +} diff --git a/share-space-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java b/share-space-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java index 228ebf3..5335077 100644 --- a/share-space-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java +++ b/share-space-system/src/main/java/com/ruoyi/system/domain/vo/IndexAdminVo.java @@ -14,45 +14,54 @@ import java.util.List; @Data public class IndexAdminVo { - /** 收入统计list */ - private List incomeVoList; - - /** 车辆统计 */ - private DeviceVO deviceVO; - - /** - * 7日营收 - */ - @Data - public static class IncomeVo { - /** 日期 */ - private String day; - /** 订单金额 */ - private BigDecimal orderFee; - /** 订单数 */ - private Integer orderNum; - } - - @Data - public static class DeviceVO { - /** 车辆总数 */ - private Integer total; - /** 空闲中 */ - private Integer idle; - /** 出租中 */ - private Integer rent; - } - - /** 今日营收 */ + /** 今日收入 */ private BigDecimal todayIncome; /** 今日订单数 */ private Integer todayOrderNum; - /** 较昨日营收 */ - private BigDecimal comparedYesterdayIncome; + /** 本周收入 */ + private BigDecimal weekIncome; + + /** 本周订单 */ + private Integer weekOrderNum; + + /** 本月收入 */ + private BigDecimal monthIncome; + + /** 本月订单 */ + private Integer monthOrderNum; + + /** 收入统计list */ + private List incomeVoList; + + /** 营收合计*/ + private BigDecimal totalIncome; + + /** 营收合计*/ + private Integer totalOrderNum; + + + /** + * 当前营运情况 + */ + /** 使用中房间 */ + private Integer inUseRoomNum; + + /** 总房间 */ + private Integer totalRoomNum; + + /** 使用中大厅设施 */ + private Integer inUseEquNum; + + /** 总大厅设施 */ + private Integer totalEquNum; + + /** 使用中大厅设施 */ + private Integer inUseDeviceNum; + + /** 总大厅设施 */ + private Integer totalDeviceNum; - /** 较昨日订单数 */ - private BigDecimal comparedYesterdayOrderNum; }