[add]统计订单状态

master
NH-LHG 2 years ago
parent fa1da2274c
commit 1fc874a8ed

@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt;
import org.jeecg.modules.demo.erp.entity.ext.OrderExt;
import org.jeecg.modules.demo.erp.vo.OrderStateVo;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@ -102,6 +103,13 @@ public class OrderController {
return Result.OK(pageExt);
}
@ApiOperation(value="订单状态统计", notes="订单状态统计")
@GetMapping(value = "/queryState")
public Result<OrderStateVo> queryState(@RequestParam(name="userId",required=true) String userId){
OrderStateVo orderStateVo = new OrderStateVo();
orderStateVo = orderService.queryState(userId);
return Result.OK(orderStateVo);
}
/**
*
*

@ -1,10 +1,9 @@
package org.jeecg.modules.demo.erp.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.demo.erp.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.demo.erp.vo.OrderStateVo;
/**
* @Description:
@ -13,5 +12,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @Version: V1.0
*/
public interface OrderMapper extends BaseMapper<Order> {
/**
*
* @param userId
* @return
*/
OrderStateVo queryState(@Param("userId") String userId);
}

@ -2,4 +2,20 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.demo.erp.mapper.OrderMapper">
</mapper>
<!-- 订单状态统计 -->
<select id="queryState" resultType="org.jeecg.modules.demo.erp.vo.OrderStateVo">
SELECT
count(1) as totalNum,
sum(CASE state WHEN 0 THEN 1 ELSE 0 END ) AS unpaid,
sum(CASE state WHEN 1 THEN 1 ELSE 0 END ) AS notSend,
sum(CASE state WHEN 2 THEN 1 ELSE 0 END) as send,
sum(CASE state WHEN 3 THEN 1 ELSE 0 END) as complete,
sum(CASE state WHEN 4 THEN 1 ELSE 0 END) as other,
sum(CASE state WHEN 5 THEN 1 ELSE 0 END) as cancel
FROM orders
where 1=1 and user_id = #{userId};
</select>
</mapper>

@ -3,6 +3,8 @@ package org.jeecg.modules.demo.erp.service;
import org.jeecg.modules.demo.erp.entity.OrderDetail;
import org.jeecg.modules.demo.erp.entity.Order;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.demo.erp.vo.OrderStateVo;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
@ -22,7 +24,7 @@ public interface IOrderService extends IService<Order> {
* @param orderDetailList
*/
public void saveMain(Order order,List<OrderDetail> orderDetailList) ;
/**
*
*
@ -30,19 +32,26 @@ public interface IOrderService extends IService<Order> {
* @param orderDetailList
*/
public void updateMain(Order order,List<OrderDetail> orderDetailList);
/**
*
*
* @param id
*/
public void delMain (String id);
/**
*
* @param id
* @return
*/
public OrderStateVo queryState(String id);
/**
*
*
* @param idList
*/
public void delBatchMain (Collection<? extends Serializable> idList);
}

@ -5,6 +5,7 @@ import org.jeecg.modules.demo.erp.entity.OrderDetail;
import org.jeecg.modules.demo.erp.mapper.OrderDetailMapper;
import org.jeecg.modules.demo.erp.mapper.OrderMapper;
import org.jeecg.modules.demo.erp.service.IOrderService;
import org.jeecg.modules.demo.erp.vo.OrderStateVo;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@ -65,6 +66,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
orderMapper.deleteById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public OrderStateVo queryState(String id) {
return orderMapper.queryState(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delBatchMain(Collection<? extends Serializable> idList) {

@ -0,0 +1,43 @@
package org.jeecg.modules.demo.erp.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* @author NH-LHG
*/
@Data
@ApiModel(value="订单状态统计", description="订单状态统计")
public class OrderStateVo {
/**总数*/
@Excel(name = "总数", width = 15)
@ApiModelProperty(value = "总数")
private java.lang.String totalNum;
/**未付款*/
@Excel(name = "未付款", width = 15)
@ApiModelProperty(value = "未付款")
private java.lang.String unpaid;
/**未发货*/
@Excel(name = "未发货", width = 15)
@ApiModelProperty(value = "未发货")
private java.lang.String notSend;
/**已发货*/
@Excel(name = "已发货", width = 15)
@ApiModelProperty(value = "已发货")
private java.lang.String send;
/**完结*/
@Excel(name = "完结", width = 15)
@ApiModelProperty(value = "完结")
private java.lang.String complete;
/**其他*/
@Excel(name = "其他", width = 15)
@ApiModelProperty(value = "其他")
private java.lang.String other;
/**取消*/
@Excel(name = "取消", width = 15)
@ApiModelProperty(value = "取消")
private java.lang.String cancel;
}
Loading…
Cancel
Save