Commit 308b120b by wangnb

包活干用户类型各种订单状态数据统计优化--think.wang

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@30863 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent f9a964b9
...@@ -134,6 +134,13 @@ public interface SysOrderMapper { ...@@ -134,6 +134,13 @@ public interface SysOrderMapper {
List<SysOrder> getOrderListByExample(QueryOrderReq queryOrderReq); List<SysOrder> getOrderListByExample(QueryOrderReq queryOrderReq);
/** /**
* 订单状态数据统计
* @param req
* @return
*/
int orderStatusStatistics(QueryOrderReq req);
/**
* 根据用户id和订单id获取用户关注订单 * 根据用户id和订单id获取用户关注订单
* *
* @param userId * @param userId
......
...@@ -3473,75 +3473,64 @@ public class OrderServiceImpl implements IOrderService { ...@@ -3473,75 +3473,64 @@ public class OrderServiceImpl implements IOrderService {
if (userType == 0) { // 运营角色 if (userType == 0) { // 运营角色
// 待指派 // 待指派
queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MERCHANT_HAS_SENT.getActiveStatus()); queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MERCHANT_HAS_SENT.getActiveStatus());
List<SysOrder> list = getOrderListByExample(1, 1, queryOrderReq); int value = orderMapper.orderStatusStatistics(queryOrderReq);
com.github.pagehelper.Page<SysOrder> pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("waitAssign", value);
map.put("waitAssign", (int) pages.getTotal()); int all = value;
int all = (int) pages.getTotal();
// 服务商已接单 // 服务商已接单
queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_NOT_ASSIGN_MECHANIC.getActiveStatus()); queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_NOT_ASSIGN_MECHANIC.getActiveStatus());
list = getOrderListByExample(1, 1, queryOrderReq); value = orderMapper.orderStatusStatistics(queryOrderReq);
pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("notAssignMechanic", value);
map.put("notAssignMechanic", (int) pages.getTotal()); all = all + value;
all = all + (int) pages.getTotal();
// 服务商已指派 // 服务商已指派
queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_NOT_ACCEPT.getActiveStatus()); queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_NOT_ACCEPT.getActiveStatus());
list = getOrderListByExample(1, 1, queryOrderReq); value = orderMapper.orderStatusStatistics(queryOrderReq);
pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("mechanicNotAccept", value);
map.put("mechanicNotAccept", (int) pages.getTotal()); all = all + value;
all = all + (int) pages.getTotal();
// 技工已接未约 // 技工已接未约
queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_WITHOUT_APPOINTMENT.getActiveStatus()); queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_WITHOUT_APPOINTMENT.getActiveStatus());
list = getOrderListByExample(1, 1, queryOrderReq); value = orderMapper.orderStatusStatistics(queryOrderReq);
pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("mechanicWithoutAppointment", value);
map.put("mechanicWithoutAppointment", (int) pages.getTotal()); all = all + value;
all = all + (int) pages.getTotal();
// 技工已约未装 // 技工已约未装
queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_NOT_FINISH.getActiveStatus()); queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_NOT_FINISH.getActiveStatus());
list = getOrderListByExample(1, 1, queryOrderReq); value = orderMapper.orderStatusStatistics(queryOrderReq);
pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("notFinish", value);
map.put("notFinish", (int) pages.getTotal()); all = all + value;
all = all + (int) pages.getTotal();
// 已取消 // 已取消
queryOrderReq.setOrderStatus((byte) 20); queryOrderReq.setOrderStatus((byte) 20);
list = getOrderListByExample(1, 1, queryOrderReq); value = orderMapper.orderStatusStatistics(queryOrderReq);
pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("canceled", value);
map.put("canceled", (int) pages.getTotal()); all = all + value;
all = all + (int) pages.getTotal();
// 完成 // 完成
queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus()); queryOrderReq.setOrderStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus());
list = getOrderListByExample(1, 1, queryOrderReq); value = orderMapper.orderStatusStatistics(queryOrderReq);
pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("finished", value);
map.put("finished", (int) pages.getTotal()); all = all + value;
all = all + (int) pages.getTotal();
map.put("all", all); map.put("all", all);
} else { } else {
// 服务商角色&商户角色 // 服务商角色&商户角色
// 服务商: 待指派 商户:待接单 // 服务商: 待指派 商户:待接单
queryOrderReq.setOrderStatus((byte) 0); queryOrderReq.setOrderStatus((byte) 0);
List<SysOrder> list = getOrderListByExample(1, 1, queryOrderReq); int value = orderMapper.orderStatusStatistics(queryOrderReq);
com.github.pagehelper.Page<SysOrder> pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("waitAssign", value);
map.put("waitAssign", (int) pages.getTotal()); int all = value;
int all = (int) pages.getTotal();
// 待完成 // 待完成
queryOrderReq.setOrderStatus((byte) 2); queryOrderReq.setOrderStatus((byte) 2);
list = getOrderListByExample(1, 1, queryOrderReq); value = orderMapper.orderStatusStatistics(queryOrderReq);
pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("finishing", value);
map.put("finishing", (int) pages.getTotal()); all = all + value;
all = all + (int) pages.getTotal();
// 已取消 // 已取消
queryOrderReq.setOrderStatus((byte) 20); queryOrderReq.setOrderStatus((byte) 20);
list = getOrderListByExample(1, 1, queryOrderReq); value = orderMapper.orderStatusStatistics(queryOrderReq);
pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("canceled", value);
map.put("canceled", (int) pages.getTotal()); all = all + value;
all = all + (int) pages.getTotal();
// 完成 // 完成
queryOrderReq.setOrderStatus((byte) 1); queryOrderReq.setOrderStatus((byte) 1);
list = getOrderListByExample(1, 1, queryOrderReq); value = orderMapper.orderStatusStatistics(queryOrderReq);
pages = (com.github.pagehelper.Page<SysOrder>) list; map.put("finished", value);
map.put("finished", (int) pages.getTotal()); all = all + value;
all = all + (int) pages.getTotal();
// 全部 // 全部
map.put("all", all); map.put("all", all);
} }
......
...@@ -1516,6 +1516,88 @@ ...@@ -1516,6 +1516,88 @@
ORDER BY so.create_time DESC ORDER BY so.create_time DESC
</select> </select>
<select id="orderStatusStatistics" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT so.id) FROM
<choose>
<!--超级管理员 -->
<when test="userId == 0">
sys_order so WHERE so.active_status &lt;&gt; 9
<if test="orderStatus != null ">
<choose>
<when test="orderStatus == 20">
and so.canceled = 0
</when>
<otherwise>
and so.active_status = #{orderStatus}
and so.canceled = 1
</otherwise>
</choose>
</if>
</when>
<!--服务商 -->
<when test="userType == 1">
sys_order so where so.merchant_id = #{userId} and so.active_status &lt;&gt;9
<choose>
<when test="orderStatus == 0">
and so.active_status in (1,2,5)
and so.canceled = 1
</when>
<when test="orderStatus == 1">
and so.active_status = 8
</when>
<when test="orderStatus == 2">
and so.active_status in (4,6,7)
and so.canceled = 1
</when>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
</choose>
</when>
<!--运营角色 -->
<when test="userType == 0">
sys_user_org suo LEFT JOIN sys_user u ON suo.org_id = u.org_id
LEFT JOIN sys_order so ON so.shop_id = u.id AND u.user_type = 2
WHERE suo.user_id = #{userId} AND so.active_status &lt;&gt; 9
<choose>
<when test="orderStatus == 20">
and so.canceled = 0
</when>
<when test="orderStatus != null">
and so.active_status = #{orderStatus}
and so.canceled = 1
</when>
</choose>
</when>
<!--商户角色 -->
<when test="userType == 2">
sys_user_org suo
LEFT JOIN sys_user u ON suo.org_id = u.org_id
LEFT JOIN sys_order so ON so.shop_id = u.id AND u.user_type = 2
WHERE suo.user_id = #{userId} AND so.active_status &lt;&gt; 9 AND so.shop_id = #{userId}
<choose>
<when test="orderStatus == 0">
and active_status in (1,2,3,4,5)
and so.canceled = 1
</when>
<when test="orderStatus == 1">
and so.active_status = 8
</when>
<when test="orderStatus == 2">
and (active_status in (6,7) )
and so.canceled = 1
</when>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
</choose>
</when>
</choose>
AND so.order_type IN (1,2,3)
</select>
<insert id="insertUserOrder"> <insert id="insertUserOrder">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!