Commit 1aedcf17 by zhengxj

finish 统计门店某段时间的订单量 on 20190213 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17330 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 77268389
......@@ -24,10 +24,13 @@
*/
package com.glsx.ordercenter.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -38,7 +41,9 @@ import com.glsx.common.annotation.AuthCheck;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.Page;
import com.glsx.common.utils.StringUtils;
import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.BizAmountResp;
import com.glsx.ordercenter.dto.OrderStastic;
import com.glsx.ordercenter.dto.QueryOrderReq;
import com.glsx.ordercenter.pojo.SysOrder;
......@@ -135,7 +140,7 @@ public class OrderController {
}
@RequestMapping(value = "/update", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject update(SysOrder sysOrder) {
public ResultObject update(HttpServletRequest request,SysOrder sysOrder) {
orderService.updateByPrimaryKeySelective(sysOrder);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), null);
}
......@@ -143,12 +148,22 @@ public class OrderController {
@RequestMapping(value = "/getStatistic", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getStatistic() {
public ResultObject getStatistic(HttpServletRequest request) {
// TODO 获取当前用户
Integer userId=12;
String userName=UserUtils.getUserName(request);
OrderStastic orderStastic = orderService.getStatistic(userId);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), orderStastic);
}
@RequestMapping(value = "/getBizAmount", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getBizAmount(HttpServletRequest request,String selectType,Date startDate,Date endDate) {
// TODO 获取当前用户
Integer userId=UserUtils.getUserId(request);
BizAmountResp bizAmountResp = orderService.getBizAmount(userId,selectType,startDate,endDate);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), bizAmountResp);
}
}
/*
* Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved.
* GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.glsx.ordercenter.dto;
import java.io.Serializable;
import java.util.List;
/**
* @ClassName: BizAmountResp
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年2月13日
*
*/
public class BizAmountResp implements Serializable{
/**
*
*/
private static final long serialVersionUID = -2087619381362662039L;
private String type;
private List<Long> bizAmount;
private List<ShopBizAmount> shopBizAmount;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<Long> getBizAmount() {
return bizAmount;
}
public void setBizAmount(List<Long> bizAmount) {
this.bizAmount = bizAmount;
}
public List<ShopBizAmount> getShopBizAmount() {
return shopBizAmount;
}
public void setShopBizAmount(List<ShopBizAmount> shopBizAmount) {
this.shopBizAmount = shopBizAmount;
}
}
/*
* Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved.
* GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.glsx.ordercenter.dto;
import java.io.Serializable;
/**
* @ClassName: ShopRank
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年2月13日
*
*/
public class ShopBizAmount implements Serializable{
/**
*
*/
private static final long serialVersionUID = -4459816057299745181L;
private String shopName;
private Long bizAmount;
public String getShopName() {
return shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public Long getBizAmount() {
return bizAmount;
}
public void setBizAmount(Long bizAmount) {
this.bizAmount = bizAmount;
}
}
......@@ -24,9 +24,11 @@
*/
package com.glsx.ordercenter.service;
import java.util.Date;
import java.util.List;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.dto.BizAmountResp;
import com.glsx.ordercenter.dto.OrderStastic;
import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysOrderExample;
......@@ -51,5 +53,7 @@ public interface IOrderService {
int updateByPrimaryKeySelective(SysOrder record);
OrderStastic getStatistic(Integer userId);
BizAmountResp getBizAmount(Integer userId,String selectType,Date startDate,Date endDate);
}
......@@ -36,6 +36,7 @@ import com.alibaba.druid.util.StringUtils;
import com.github.pagehelper.PageHelper;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.dto.BizAmountResp;
import com.glsx.ordercenter.dto.FinishedOrders;
import com.glsx.ordercenter.dto.MachanicInfo;
import com.glsx.ordercenter.dto.OrderStastic;
......@@ -485,4 +486,68 @@ public class OrderServiceImpl implements IOrderService {
return subOrders;
}
/* (non-Javadoc)
* @see com.glsx.ordercenter.service.IOrderService#getBizAmount(java.lang.Integer)
*/
@Override
public BizAmountResp getBizAmount(Integer userId, String selectType, Date startDate, Date endDate) {
BizAmountResp bizAmountResp = new BizAmountResp();
SysOrderExample orderExample = new SysOrderExample();
List<Long> bizAmount= new ArrayList<>();
SysUser sysUser = sysUserDao.selectByPrimaryKey(userId);
Criteria criteria = orderExample.createCriteria();
criteria.andActiveStatusEqualTo((byte) 8);
int userType = sysUser.getUserType();
// 当前用户:服务商或者门店
if (userType == 1) {
SysMerchantExample merExample = new SysMerchantExample();
merExample.createCriteria().andUserIdEqualTo(userId);
SysMerchant merchant = sysMerchantDao.selectByExample(merExample).get(0);
criteria.andMerchantIdEqualTo(merchant.getId());
// 按照小时计算
if(startDate==null||endDate==null){
switch (selectType) {
case "d":
bizAmountResp.setType("d");
Date currentTime = DateUtil.getCurrentTime();
int currentHour = currentTime.getHours();
for (int i = 0; i < currentHour; i++) {
Date beginTime = new Date();
beginTime.setHours(i);
beginTime.setMinutes(0);
beginTime.setSeconds(0);
Date endTime = new Date();
endTime.setHours(i);
endTime.setMinutes(59);
endTime.setSeconds(59);
criteria.andCreateTimeBetween(beginTime, endTime);
long businessAmount =orderDao.countByExample(orderExample);
bizAmount.add(businessAmount);
}
break;
// 按照周计算
case "w":
break;
// 按照月计算
case "m":
break;
// 按照年计算
case "y":
break;
default:
break;
}
}
}
return bizAmountResp;
}
}
......@@ -441,6 +441,10 @@
<result column="active_status" jdbcType="TINYINT" property="activeStatus" />
</resultMap>
<resultMap id="OrderCountResultMap" type="com.glsx.ordercenter.dto.ShopBizAmount">
<result column="shop_name" jdbcType="VARCHAR" property="shopName" />
<result column="biz_amount" jdbcType="BIGINT" property="bizAmount" />
</resultMap>
<!-- <select id="selectByParams" parameterType="com.glsx.ordercenter.pojo.SysOrderExample"
resultMap="OrderDetailResultMap">
SELECT
......@@ -475,4 +479,26 @@
</if>
</where>
</select>
<select id="countByParams" parameterType="java.util.Map" resultMap="OrderCountResultMap">
SELECT
sm.shop_name,
count(1) AS biz_amount
FROM
sys_order so
LEFT JOIN
sys_merchant sm ON so.shop_id = sm.id
<where>
so.active_status = 8
and so.merchant_id = #{merchantId,jdbcType=INTEGER}
<if test="beginTime != null">
and so.create_time &gt;= #{beginTime}
</if>
<if test="endTime != null">
and so.create_time &lt;= #{endTime}
</if>
</where>
GROUP BY shop_id
ORDER BY biz_amount DESC
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!