parent
7de4b04ccf
commit
73520984c4
@ -0,0 +1,51 @@
|
|||||||
|
package com.ruoyi.web.controller.mall;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ruoyi.mall.domain.query.GoodsStatisticsQuery;
|
||||||
|
import com.ruoyi.mall.domain.query.OrderStatisticsQuery;
|
||||||
|
import com.ruoyi.mall.domain.vo.OrderAndAftersaleStatisticsVO;
|
||||||
|
import com.ruoyi.mall.domain.vo.OrderStatisticsVO;
|
||||||
|
import com.ruoyi.mall.domain.vo.ProductTopVO;
|
||||||
|
import com.ruoyi.mall.service.IndexStatisticsService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "管理端,首页统计数据接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dev/statistics/index")
|
||||||
|
public class IndexStatisticsManagerController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页统计
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private IndexStatisticsService indexStatisticsService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取首页查询热卖商品TOP10")
|
||||||
|
@GetMapping("/goodsStatistics")
|
||||||
|
public ResponseEntity<List<ProductTopVO>> goodsStatistics(@Validated GoodsStatisticsQuery goodsStatisticsQuery) {
|
||||||
|
|
||||||
|
return ResponseEntity.ok(indexStatisticsService.goodsStatistics(goodsStatisticsQuery));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "订单与售后单统计")
|
||||||
|
@GetMapping("/order/aftersale/statistics")
|
||||||
|
public ResponseEntity<OrderAndAftersaleStatisticsVO> orderAndAftersaleStatistics(){
|
||||||
|
return ResponseEntity.ok(indexStatisticsService.orderAndAftersaleStatistics());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "订单信息")
|
||||||
|
@PostMapping("/orderStatistics")
|
||||||
|
public ResponseEntity<List<OrderStatisticsVO>> orderStatistics(@RequestBody OrderStatisticsQuery param) {
|
||||||
|
return ResponseEntity.ok(indexStatisticsService.orderStatistics(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,92 @@
|
|||||||
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.RestResponse;
|
||||||
|
import com.ruoyi.system.domain.SysTenant;
|
||||||
|
import com.ruoyi.system.domain.vo.ReqBusinessAddTenant;
|
||||||
|
import com.ruoyi.system.domain.vo.ReqSearchSysTenant;
|
||||||
|
import com.ruoyi.system.service.SysTenantService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 租户信息 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangby
|
||||||
|
* @since 2019-11-06
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/tenant")
|
||||||
|
public class SysTenantController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysTenantService sysTenantService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*
|
||||||
|
* @param reqSearchSysTenant
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/list/searchList")
|
||||||
|
public RestResponse searchList(ReqSearchSysTenant reqSearchSysTenant) {
|
||||||
|
return sysTenantService.searchList(reqSearchSysTenant);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前端select
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/list/treeSelect")
|
||||||
|
public RestResponse treeSelect() {
|
||||||
|
return sysTenantService.treeSelect();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*
|
||||||
|
* @param tenantId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/info/detailById/{tenantId}")
|
||||||
|
public RestResponse detailById(@PathVariable("tenantId") Long tenantId) {
|
||||||
|
return sysTenantService.detailById(tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param reqBusinessAddTenant
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/add/addTenant")
|
||||||
|
public RestResponse addSysTenant(@RequestBody ReqBusinessAddTenant reqBusinessAddTenant) {
|
||||||
|
return sysTenantService.addTenant(reqBusinessAddTenant);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*
|
||||||
|
* @param sysTenant
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PutMapping("/update/updateTenant")
|
||||||
|
public RestResponse updateTenant(@RequestBody SysTenant sysTenant) {
|
||||||
|
return sysTenantService.updateTenant(sysTenant);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @param tenantIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/delete/deleteById/{tenantIds}")
|
||||||
|
public RestResponse deleteById(@PathVariable("tenantIds") String[] tenantIds) {
|
||||||
|
return sysTenantService.deleteById(tenantIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.ruoyi.mall.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderAndAftersaleStatisticsVO {
|
||||||
|
/** 待处理售后 */
|
||||||
|
private Integer pendingAftersaleCount;
|
||||||
|
/** 处理中售后 */
|
||||||
|
private Integer processingAftersaleCount;
|
||||||
|
/** 待发货 */
|
||||||
|
private Integer waitDeliveredCount;
|
||||||
|
/** 已发货 */
|
||||||
|
private Integer todayHasDeliveredCount;
|
||||||
|
/** 订单数 */
|
||||||
|
private Integer todayOrderCount;
|
||||||
|
/** 成交额 */
|
||||||
|
private BigDecimal todayTransactionAmount;
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.mall.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderStatisticsVO {
|
||||||
|
|
||||||
|
private String date;
|
||||||
|
//订单笔数
|
||||||
|
private Double orderCount;
|
||||||
|
//订单金额
|
||||||
|
private Double orderAmount;
|
||||||
|
private Double numPaidOrders;
|
||||||
|
private Double numPendingOrders;
|
||||||
|
private Double numRefundOrders;
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.ruoyi.mall.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ProductTopVO {
|
||||||
|
|
||||||
|
private String productName;
|
||||||
|
private int totalSales;
|
||||||
|
private String pic;
|
||||||
|
private String spData;
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.ruoyi.mall.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ruoyi.mall.domain.Aftersale;
|
||||||
|
import com.ruoyi.mall.domain.vo.OrderAndAftersaleStatisticsVO;
|
||||||
|
|
||||||
|
public interface AftersaleMapper extends BaseMapper<Aftersale> {
|
||||||
|
|
||||||
|
|
||||||
|
OrderAndAftersaleStatisticsVO statPendingAndProcessing();
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.mall.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ruoyi.mall.domain.query.GoodsStatisticsQuery;
|
||||||
|
import com.ruoyi.mall.domain.query.OrderStatisticsQuery;
|
||||||
|
import com.ruoyi.mall.domain.vo.OrderStatisticsVO;
|
||||||
|
import com.ruoyi.mall.domain.vo.ProductTopVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IndexStatisticsMapper {
|
||||||
|
|
||||||
|
List<ProductTopVO> goodsSkuStatistics(GoodsStatisticsQuery goodsStatisticsQuery);
|
||||||
|
|
||||||
|
List<ProductTopVO> goodsStatistics(GoodsStatisticsQuery goodsStatisticsQuery);
|
||||||
|
List<OrderStatisticsVO> orderStatistics(OrderStatisticsQuery param);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.mall.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ruoyi.mall.domain.Order;
|
||||||
|
import com.ruoyi.mall.domain.vo.OrderAndAftersaleStatisticsVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
public interface OrderMapper extends BaseMapper<Order> {
|
||||||
|
|
||||||
|
|
||||||
|
Integer statWaitDelivered();
|
||||||
|
OrderAndAftersaleStatisticsVO statTodayData(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package com.ruoyi.mall.service;
|
||||||
|
|
||||||
|
import com.ruoyi.mall.domain.query.GoodsStatisticsQuery;
|
||||||
|
import com.ruoyi.mall.domain.query.OrderStatisticsQuery;
|
||||||
|
import com.ruoyi.mall.domain.vo.OrderAndAftersaleStatisticsVO;
|
||||||
|
import com.ruoyi.mall.domain.vo.OrderStatisticsVO;
|
||||||
|
import com.ruoyi.mall.domain.vo.ProductTopVO;
|
||||||
|
import com.ruoyi.mall.mapper.AftersaleMapper;
|
||||||
|
import com.ruoyi.mall.mapper.IndexStatisticsMapper;
|
||||||
|
import com.ruoyi.mall.mapper.OrderMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端,首页统计数据Service业务层处理
|
||||||
|
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class IndexStatisticsService {
|
||||||
|
@Autowired
|
||||||
|
private AftersaleMapper aftersaleMapper;
|
||||||
|
@Autowired
|
||||||
|
private OrderMapper orderMapper;
|
||||||
|
@Autowired
|
||||||
|
private IndexStatisticsMapper indexStatisticsMapper;
|
||||||
|
|
||||||
|
public List<ProductTopVO> goodsStatistics(GoodsStatisticsQuery goodsStatisticsQuery) {
|
||||||
|
if (goodsStatisticsQuery.getStatType() == 1){
|
||||||
|
return indexStatisticsMapper.goodsSkuStatistics(goodsStatisticsQuery);
|
||||||
|
}else {
|
||||||
|
return indexStatisticsMapper.goodsStatistics(goodsStatisticsQuery);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrderAndAftersaleStatisticsVO orderAndAftersaleStatistics() {
|
||||||
|
//统计售后
|
||||||
|
OrderAndAftersaleStatisticsVO vo = aftersaleMapper.statPendingAndProcessing();
|
||||||
|
//统计未发货数
|
||||||
|
vo.setWaitDeliveredCount(orderMapper.statWaitDelivered());
|
||||||
|
//统计今日订单数,成交金额,发货数
|
||||||
|
LocalDateTime startTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
|
||||||
|
LocalDateTime endTime = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
|
||||||
|
OrderAndAftersaleStatisticsVO todayData = orderMapper.statTodayData(startTime, endTime);
|
||||||
|
vo.setTodayOrderCount(todayData.getTodayOrderCount());
|
||||||
|
vo.setTodayHasDeliveredCount(todayData.getTodayHasDeliveredCount());
|
||||||
|
vo.setTodayTransactionAmount(todayData.getTodayTransactionAmount());
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderStatisticsVO> orderStatistics(OrderStatisticsQuery param) {
|
||||||
|
return indexStatisticsMapper.orderStatistics(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.system.domain.vo;
|
||||||
|
|
||||||
|
import com.ruoyi.common.page.ReqPageBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ReqSearchSysTenant extends ReqPageBase implements Serializable {
|
||||||
|
|
||||||
|
private String tenantName;
|
||||||
|
private String contactName;
|
||||||
|
private String inUse;
|
||||||
|
//过期开始时间
|
||||||
|
private String beginTime;
|
||||||
|
//过期结束
|
||||||
|
private String endTime;
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ruoyi.system.domain.SysTenant;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 租户信息 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public interface SysTenantMapper extends BaseMapper<SysTenant> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户租户列表
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SysTenant> selectUserTenantList(@Param("userId")String userId, @Param("limitTenantUserId")String limitTenantUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在用用户所属的租户
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param tenantId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SysTenant selectInUseUserTenant(@Param("userId")String userId, @Param("tenantId")String tenantId);
|
||||||
|
|
||||||
|
int tenantHaveContent(String tenantId);
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ruoyi.common.core.domain.RestResponse;
|
||||||
|
import com.ruoyi.system.domain.SysTenant;
|
||||||
|
import com.ruoyi.system.domain.vo.ReqBusinessAddTenant;
|
||||||
|
import com.ruoyi.system.domain.vo.ReqSearchSysTenant;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SysTenantService extends IService<SysTenant> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户租户列表
|
||||||
|
* @param userId
|
||||||
|
* @param limitTenantUserId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SysTenant> selectUserTenantList(String userId, String limitTenantUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验用户所属租户是否在用生效
|
||||||
|
* @param userId
|
||||||
|
* @param tenantId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean checkUserTenantInUse(String userId,String tenantId);
|
||||||
|
|
||||||
|
RestResponse searchList(ReqSearchSysTenant reqSearchSysTenant);
|
||||||
|
RestResponse treeSelect();
|
||||||
|
RestResponse detailById(Long tenantId);
|
||||||
|
RestResponse addTenant(ReqBusinessAddTenant reqBusinessAddTenant);
|
||||||
|
RestResponse updateTenant(SysTenant sysTenant);
|
||||||
|
RestResponse deleteById(String[] tenantIds);
|
||||||
|
}
|
||||||
@ -0,0 +1,221 @@
|
|||||||
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
|
import com.ruoyi.common.core.domain.RestResponse;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
import com.ruoyi.common.page.RespPage;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.system.domain.SysTenant;
|
||||||
|
import com.ruoyi.system.domain.vo.ReqBusinessAddTenant;
|
||||||
|
import com.ruoyi.system.domain.vo.ReqSearchSysTenant;
|
||||||
|
import com.ruoyi.system.mapper.SysTenantMapper;
|
||||||
|
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
||||||
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
import com.ruoyi.system.service.SysTenantService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant> implements SysTenantService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService userService;
|
||||||
|
@Autowired
|
||||||
|
private SysUserRoleMapper userRoleMapper;
|
||||||
|
@Override
|
||||||
|
public List<SysTenant> selectUserTenantList(String userId, String limitTenantUserId) {
|
||||||
|
return baseMapper.selectUserTenantList(userId, limitTenantUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkUserTenantInUse(String userId, String tenantId) {
|
||||||
|
if (StringUtils.isAnyEmpty(userId, tenantId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SysTenant sysTenant = baseMapper.selectInUseUserTenant(userId, tenantId);
|
||||||
|
return sysTenant != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询树
|
||||||
|
*
|
||||||
|
* @param reqSearchSysTenant
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public RestResponse searchList(ReqSearchSysTenant reqSearchSysTenant) {
|
||||||
|
QueryWrapper qw = new QueryWrapper();
|
||||||
|
if (StringUtils.isNotEmpty(reqSearchSysTenant.getTenantName())) {
|
||||||
|
qw.like("tenant_name", reqSearchSysTenant.getTenantName());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(reqSearchSysTenant.getContactName())) {
|
||||||
|
qw.like("contact_name", reqSearchSysTenant.getContactName());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(reqSearchSysTenant.getInUse())) {
|
||||||
|
qw.eq("in_use", reqSearchSysTenant.getInUse());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNoneEmpty(reqSearchSysTenant.getBeginTime(), reqSearchSysTenant.getEndTime())) {
|
||||||
|
qw.between("end_time", reqSearchSysTenant.getBeginTime() + " 00:00:00", reqSearchSysTenant.getEndTime() + " 23:59:59");
|
||||||
|
}
|
||||||
|
// 不展示超级管理租户
|
||||||
|
qw.ne("super_tenant", "1");
|
||||||
|
|
||||||
|
qw.orderByDesc("in_use", "create_time");
|
||||||
|
RespPage<SysTenant> page = new RespPage(reqSearchSysTenant.getPageNum(), reqSearchSysTenant.getPageSize());
|
||||||
|
RespPage<SysTenant> listPage = page(page, qw);
|
||||||
|
return new RestResponse().setData(listPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前端select
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public RestResponse treeSelect() {
|
||||||
|
QueryWrapper qw = new QueryWrapper();
|
||||||
|
qw.select("tenant_id", "tenant_name");
|
||||||
|
qw.ne("super_tenant", 1);
|
||||||
|
qw.orderByDesc("create_time");
|
||||||
|
List<SysTenant> list = list(qw);
|
||||||
|
return new RestResponse().setData(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*
|
||||||
|
* @param tenantId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public RestResponse detailById(Long tenantId) {
|
||||||
|
if (null == tenantId) {
|
||||||
|
return new RestResponse();
|
||||||
|
}
|
||||||
|
SysTenant detailInfo = getById(tenantId);
|
||||||
|
List<String> useDateList = Arrays.asList(DateUtil.format(detailInfo.getBeginTime(), "yyyy-MM-dd"), DateUtil.format(detailInfo.getEndTime(), "yyyy-MM-dd"));
|
||||||
|
String[] useDateRange = useDateList.toArray(new String[useDateList.size()]);
|
||||||
|
detailInfo.setUseDateRange(useDateRange);
|
||||||
|
return new RestResponse().setData(detailInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param reqBusinessAddTenant
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
public RestResponse addTenant(ReqBusinessAddTenant reqBusinessAddTenant) {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
|
||||||
|
SysTenant sysTenant = new SysTenant();
|
||||||
|
BeanUtils.copyProperties(reqBusinessAddTenant, sysTenant);
|
||||||
|
|
||||||
|
sysTenant.setCreateUser(loginUser.getUserId());
|
||||||
|
sysTenant.setBeginTime(DateUtil.parse(sysTenant.getBeginTime().toString()));//,"yyyy-MM-dd 00:00:00"
|
||||||
|
sysTenant.setEndTime(DateUtil.parse(DateUtil.format(sysTenant.getEndTime(),"yyyy-MM-dd 23:59:59")));//,"yyyy-MM-dd 23:59:59"
|
||||||
|
this.save(sysTenant);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// TenantContextHolder.setTenant(sysTenant.getTenantId());
|
||||||
|
// 保存用户
|
||||||
|
if (StringUtils.isAnyEmpty(reqBusinessAddTenant.getUsername(), reqBusinessAddTenant.getPassword())) {
|
||||||
|
return RestResponse.failure("请求参数错误,请完善后重试");
|
||||||
|
} else if (!reqBusinessAddTenant.getPassword().equals(reqBusinessAddTenant.getCheckPass())) {
|
||||||
|
return RestResponse.failure(("新旧密码输入不一致,请稍后重试"));
|
||||||
|
}
|
||||||
|
// 校验账号是否已被注册
|
||||||
|
boolean usernameUnique = UserConstants.UNIQUE.equals(userService.checkUserNameUnique(reqBusinessAddTenant.getUsername()));
|
||||||
|
if (!usernameUnique) {
|
||||||
|
return RestResponse.failure(("用户名已被注册,请修改后重新提交"));
|
||||||
|
}
|
||||||
|
SysUser sysUser = reqBusinessAddTenant.transferToSysUser();
|
||||||
|
sysUser.setTenantId(sysTenant.getTenantId());
|
||||||
|
sysUser.setCreateBy(loginUser.getUserId());
|
||||||
|
sysUser.setPassword(SecurityUtils.encryptPassword(sysUser.getPassword()));
|
||||||
|
userService.insertUser(sysUser);
|
||||||
|
|
||||||
|
|
||||||
|
// 用户角色
|
||||||
|
userRoleMapper.countRoleAndUserId(100l,loginUser.getUserId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return RestResponse.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
*
|
||||||
|
* @param sysTenant
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public RestResponse updateTenant(SysTenant sysTenant) {
|
||||||
|
if (StringUtils.isEmpty(sysTenant.getTenantId())) {
|
||||||
|
return RestResponse.failure("操作失败,请稍后重试");
|
||||||
|
}
|
||||||
|
SysTenant dbTenant = this.getById(sysTenant.getTenantId());
|
||||||
|
if(null != dbTenant && dbTenant.getSuperTenant()) {
|
||||||
|
return RestResponse.failure("此租户信息不允许变更");
|
||||||
|
}
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
sysTenant.setBeginTime(DateUtil.parse(sysTenant.getBeginTime().toString()));
|
||||||
|
sysTenant.setEndTime(DateUtil.parse(DateUtil.format(sysTenant.getEndTime(),"yyyy-MM-dd 23:59:59")));
|
||||||
|
sysTenant.setLastUpdateUser(loginUser.getUserId());
|
||||||
|
sysTenant.setLastUpdateTime(new Date());
|
||||||
|
boolean updateTenant = this.updateById(sysTenant);
|
||||||
|
if (updateTenant) {
|
||||||
|
return RestResponse.success();
|
||||||
|
} else {
|
||||||
|
return RestResponse.failure("操作失败,请稍后重试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @param tenantIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public RestResponse deleteById(String[] tenantIds) {
|
||||||
|
if (null == tenantIds || tenantIds.length == 0) {
|
||||||
|
return RestResponse.failure("操作失败,请稍后重试");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String tenantId : tenantIds) {
|
||||||
|
|
||||||
|
SysTenant dbTenant = this.getById(tenantId);
|
||||||
|
if(null != dbTenant && dbTenant.getSuperTenant()) {
|
||||||
|
return RestResponse.failure(dbTenant.getTenantName() + ",此租户信息不允许删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否有学生/课程/班级
|
||||||
|
int contentCount = baseMapper.tenantHaveContent(tenantId);
|
||||||
|
if (contentCount > 0) {
|
||||||
|
return RestResponse.failure("租户下有学员,无法删除");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean deleteTenant = this.removeByIds(Arrays.asList(tenantIds));
|
||||||
|
if (deleteTenant) {
|
||||||
|
return RestResponse.success();
|
||||||
|
} else {
|
||||||
|
return RestResponse.failure("操作失败,请稍后重试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.mall.mapper.AftersaleMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<sql id="selectAftersaleVo">
|
||||||
|
select id, member_id, order_id, return_amount, type, status, handle_time, quantity, reason, description, proof_pics, handle_note, handle_man, create_by, create_time, update_by, update_time from oms_aftersale
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="statPendingAndProcessing" resultType="OrderAndAftersaleStatisticsVO">
|
||||||
|
select
|
||||||
|
IFNULL(sum(case when status=0 then 1 else 0 end), 0) pendingAftersaleCount,
|
||||||
|
IFNULL(sum(case when status=1 then 1 else 0 end), 0) processingAftersaleCount
|
||||||
|
from oms_aftersale
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,104 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.mall.mapper.IndexStatisticsMapper">
|
||||||
|
<sql id="dateRange">
|
||||||
|
SELECT
|
||||||
|
curdate( ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 1 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 2 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 3 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 4 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 5 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 6 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 7 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 8 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 9 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 10 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 11 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 12 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 13 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 14 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 15 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 16 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 17 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 18 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 19 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 20 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 21 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 22 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 23 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 24 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 25 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 26 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 27 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 28 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 29 DAY ) AS date
|
||||||
|
</sql>
|
||||||
|
<sql id="dateRange2">
|
||||||
|
SELECT
|
||||||
|
curdate( ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 1 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 2 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 3 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 4 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 5 DAY ) AS date UNION ALL
|
||||||
|
SELECT date_sub( curdate( ), INTERVAL 6 DAY ) AS date
|
||||||
|
</sql>
|
||||||
|
<resultMap id="topSalesResultMap" type="ProductTopVO">
|
||||||
|
<result property="productName" column="product_name"/>
|
||||||
|
<result property="totalSales" column="total_sales"/>
|
||||||
|
<result property="pic" column="pic"/>
|
||||||
|
<result property="spData" column="sp_data"/>
|
||||||
|
</resultMap>
|
||||||
|
<select id="goodsStatistics" parameterType="GoodsStatisticsQuery" resultMap="topSalesResultMap">
|
||||||
|
SELECT product_id ,
|
||||||
|
product_name,
|
||||||
|
pic,
|
||||||
|
IFNULL(SUM(quantity), 0) as total_sales
|
||||||
|
FROM oms_order_item item right join oms_order o on o.id=item.order_id
|
||||||
|
WHERE DATE(item.create_time) between DATE(#{startDate}) AND DATE(#{endDate}) AND o.status in(1,2,3)
|
||||||
|
GROUP BY product_id, product_name
|
||||||
|
ORDER BY total_sales DESC
|
||||||
|
LIMIT #{size}
|
||||||
|
</select>
|
||||||
|
<select id="orderStatistics" resultType="OrderStatisticsVO">
|
||||||
|
select a.date,
|
||||||
|
IFNULL(b.order_count,0) orderCount,
|
||||||
|
IFNULL(b.order_amount,0) orderAmount
|
||||||
|
from
|
||||||
|
(
|
||||||
|
<choose>
|
||||||
|
<when test="type == 1">
|
||||||
|
<include refid="dateRange2"></include>
|
||||||
|
</when>
|
||||||
|
<when test="type == 2">
|
||||||
|
<include refid="dateRange"></include>
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
) a
|
||||||
|
left join (
|
||||||
|
SELECT DATE_FORMAT(create_time, '%Y-%m-%d') as date,
|
||||||
|
COUNT(*) as order_count,
|
||||||
|
SUM(total_amount) as order_amount
|
||||||
|
FROM oms_order
|
||||||
|
WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) AND status in(1,2,3)
|
||||||
|
GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')
|
||||||
|
) b
|
||||||
|
on a.date=b.date
|
||||||
|
order by a.date asc
|
||||||
|
</select>
|
||||||
|
<select id="goodsSkuStatistics" resultMap="topSalesResultMap">
|
||||||
|
SELECT product_id ,
|
||||||
|
product_name,
|
||||||
|
pic,
|
||||||
|
sp_data,
|
||||||
|
IFNULL(SUM(quantity), 0) as total_sales
|
||||||
|
FROM oms_order_item item right join oms_order o on o.id=item.order_id
|
||||||
|
WHERE DATE(item.create_time) between DATE(#{startDate}) AND DATE(#{endDate}) AND o.status in(1,2,3)
|
||||||
|
GROUP BY sku_id
|
||||||
|
ORDER BY total_sales DESC
|
||||||
|
LIMIT #{size}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.mall.mapper.OrderMapper">
|
||||||
|
|
||||||
|
<select id="statWaitDelivered" resultType="java.lang.Integer">
|
||||||
|
select IFNULL(count(id), 0) from oms_order where status=1 and aftersale_status=1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="statTodayData" resultType="OrderAndAftersaleStatisticsVO">
|
||||||
|
select
|
||||||
|
IFNULL(sum(case when status in (2,3) then 1 else 0 end), 0) todayHasDeliveredCount,
|
||||||
|
IFNULL(count(id), 0) todayOrderCount,
|
||||||
|
IFNULL(sum(case when status in (1,2,3) then pay_amount else 0 end), 0) todayTransactionAmount
|
||||||
|
from oms_order
|
||||||
|
where create_time between #{startTime} and #{endTime}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.system.mapper.SysTenantMapper">
|
||||||
|
|
||||||
|
<select id="selectUserTenantList" resultType="SysTenant">
|
||||||
|
select t.tenant_id,t.tenant_name
|
||||||
|
from sys_tenant t,sys_user_tenant ut
|
||||||
|
where t.delete_flag='0'
|
||||||
|
and t.tenant_id=ut.tenant_id and ut.user_id=#{userId}
|
||||||
|
<if test="limitTenantUserId != null and limitTenantUserId != ''">
|
||||||
|
and exists(select 1 from sys_user_tenant utl where utl.user_id=#{limitTenantUserId} and utl.tenant_id=t.tenant_id)
|
||||||
|
</if>
|
||||||
|
order by t.create_time desc
|
||||||
|
</select>
|
||||||
|
<select id="selectInUseUserTenant" resultType="SysTenant">
|
||||||
|
select * from sys_tenant t,sys_user_tenant ut
|
||||||
|
where t.tenant_id=ut.tenant_id
|
||||||
|
and ut.user_id=#{userId} and ut.tenant_id=#{tenantId}
|
||||||
|
and now() between t.begin_time and t.end_time
|
||||||
|
and t.in_use='1'
|
||||||
|
and t.delete_flag='0'
|
||||||
|
</select>
|
||||||
|
<select id="tenantHaveContent" resultType="integer">
|
||||||
|
select
|
||||||
|
sum(CASE
|
||||||
|
WHEN s.student_name is not null THEN 1
|
||||||
|
WHEN c.course_name is not null THEN 1
|
||||||
|
WHEN a.cla_name is not null THEN 1
|
||||||
|
ELSE 0 END)
|
||||||
|
from sys_tenant t
|
||||||
|
LEFT JOIN sc_student s on t.tenant_id=s.tenant_id
|
||||||
|
LEFT JOIN sc_course c on t.tenant_id=c.tenant_id
|
||||||
|
LEFT JOIN sc_course_cla a on t.tenant_id=a.tenant_id
|
||||||
|
WHERE t.tenant_id=#{tenantId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in new issue