Commit c808cdcf by zhengxj

finish 订单状态统计 on 20191010 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@24173 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 5fab9801
...@@ -778,10 +778,10 @@ public class OrderController extends BaseController { ...@@ -778,10 +778,10 @@ public class OrderController extends BaseController {
*/ */
@AuthCheck @AuthCheck
@RequestMapping(value = "/getCountByStatus", method = { RequestMethod.GET, RequestMethod.POST }) @RequestMapping(value = "/getCountByStatus", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getCountByStatus(HttpServletRequest request) { public ResultObject getCountByStatus(HttpServletRequest request, QueryOrderReq oueryOrderReq) {
// TODO
ResultObject result = new ResultObject();
return result; oueryOrderReq.setUserId(UserUtils.getUserId(request));
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),
orderService.countByOrderStatusAndUserType(oueryOrderReq));
} }
} }
...@@ -65,7 +65,17 @@ public class QueryOrderReq implements Serializable { ...@@ -65,7 +65,17 @@ public class QueryOrderReq implements Serializable {
*/ */
private String conditions; private String conditions;
public Integer getOrderType() { private String keyWord;
public String getKeyWord() {
return keyWord;
}
public void setKeyWord(String keyWord) {
this.keyWord = keyWord;
}
public Integer getOrderType() {
return orderType; return orderType;
} }
...@@ -197,8 +207,8 @@ public class QueryOrderReq implements Serializable { ...@@ -197,8 +207,8 @@ public class QueryOrderReq implements Serializable {
return orderStatus; return orderStatus;
} }
public void setOrderStatus(Byte orderStatus) { public void setOrderStatus(Byte orderStatus) {
this.orderStatus = orderStatus; this.orderStatus = orderStatus;
} }
public String getDateStart() { public String getDateStart() {
......
...@@ -207,4 +207,6 @@ public interface SysOrderMapper { ...@@ -207,4 +207,6 @@ public interface SysOrderMapper {
* *
*/ */
int assignMechanic(SysOrder order); int assignMechanic(SysOrder order);
int countByOrderStatusAndUserType(QueryOrderReq oueryOrderReq);
} }
\ No newline at end of file \ No newline at end of file
...@@ -26,6 +26,7 @@ package com.glsx.ordercenter.service; ...@@ -26,6 +26,7 @@ package com.glsx.ordercenter.service;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -298,4 +299,6 @@ public interface IOrderService { ...@@ -298,4 +299,6 @@ public interface IOrderService {
*/ */
public void indertSysOrderWechatMsg(SysOrder sysOrder, Integer userId, Byte msgType, String remark, public void indertSysOrderWechatMsg(SysOrder sysOrder, Integer userId, Byte msgType, String remark,
Integer recever); Integer recever);
Map<String, Integer> countByOrderStatusAndUserType(QueryOrderReq oueryOrderReq);
} }
...@@ -3490,5 +3490,78 @@ public class OrderServiceImpl implements IOrderService { ...@@ -3490,5 +3490,78 @@ public class OrderServiceImpl implements IOrderService {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg()); return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} }
/**
*
*/
@Override
public Map<String, Integer> countByOrderStatusAndUserType(QueryOrderReq oueryOrderReq) {
Map<String, Integer> map = new HashMap<>(8);
JSONObject user = getUserInfo(oueryOrderReq.getUserId());
int userType = user.getIntValue("userType");
oueryOrderReq.setUserType(userType);
if (userType == 0) {
// 运营角色
// 待指派
oueryOrderReq.setOrderStatus(
(byte) OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MERCHANT_HAS_SENT.getActiveStatus());
int waitAssign = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("waitAssign", waitAssign);
// 服务商已接单
oueryOrderReq.setOrderStatus(
(byte) OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_NOT_ASSIGN_MECHANIC.getActiveStatus());
int notAssignMechanic = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("notAssignMechanic", notAssignMechanic);
// 服务商已指派
oueryOrderReq.setOrderStatus(
(byte) OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_NOT_ACCEPT.getActiveStatus());
int mechanicNotAccept = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("mechanicNotAccept", mechanicNotAccept);
// 技工已接未约
oueryOrderReq.setOrderStatus(
(byte) OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_WITHOUT_APPOINTMENT.getActiveStatus());
int mechanicWithoutAppointment = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("mechanicWithoutAppointment", mechanicWithoutAppointment);
// 技工已约未装
oueryOrderReq.setOrderStatus(
(byte) OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_NOT_FINISH.getActiveStatus());
int notFinish = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("notFinish", notFinish);
// 已取消
oueryOrderReq.setOrderStatus((byte) 20);
int canceled = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("canceled", canceled);
// 完成
oueryOrderReq.setOrderStatus((byte) OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus());
int finished = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("finished", finished);
} else {
// 服务商角色&商户角色
// 待指派
oueryOrderReq.setOrderStatus((byte) 0);
int waitAssign = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("waitAssign", waitAssign);
// 待完成
oueryOrderReq.setOrderStatus((byte) 2);
int finishing = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("finishing", finishing);
// 已取消
oueryOrderReq.setOrderStatus((byte) 20);
int canceled = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("canceled", canceled);
// 完成
oueryOrderReq.setOrderStatus((byte) OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus());
int finished = orderDao.countByOrderStatusAndUserType(oueryOrderReq);
map.put("finished", finished);
}
return map;
}
} }
...@@ -1306,24 +1306,30 @@ ...@@ -1306,24 +1306,30 @@
and(( sm.name like "%"#{keyWord}"%" and(( sm.name like "%"#{keyWord}"%"
and sm.user_type = 3) or ssm.shop_name like "%"#{keyWord}"%" or so.car_owner like "%"#{keyWord}"%" or so.vin_no like "%"#{keyWord}"%" or so.work_order_no like "%"#{keyWord}"%") and sm.user_type = 3) or ssm.shop_name like "%"#{keyWord}"%" or so.car_owner like "%"#{keyWord}"%" or so.vin_no like "%"#{keyWord}"%" or so.work_order_no like "%"#{keyWord}"%")
</if> </if>
<!-- 商户 -->
<choose> <choose>
<when test="userType == 2"> <when test="userType == 2">
and so.shop_id = #{userId} and so.shop_id = #{userId}
<if test="orderStatus != null and orderStatus!=''"> <if test="orderStatus != null and orderStatus!=''">
<choose> <choose>
<when test="orderStatus == 0"> <when test="orderStatus == 0">
and so.active_status in (1,2,3,4,5) and active_status in (1,2,3,4,5)
and so.canceled = 1
</when> </when>
<when test="orderStatus == 1"> <when test="orderStatus == 1">
and so.active_status in (8) and so.active_status in (8)
</when> </when>
<when test="orderStatus == 2"> <!-- <when test="orderStatus == 2">
and so.active_status in (1,2,3,4,5,6,7) and so.active_status in (1,2,3,4,5,6,7)
</when> </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>
<otherwise> <otherwise>
and so.active_status in #{orderStatus} and so.active_status in #{orderStatus}
</otherwise> </otherwise>
...@@ -1331,7 +1337,7 @@ ...@@ -1331,7 +1337,7 @@
</if> </if>
</when> </when>
<when test="userType == 3"> <!--<when test="userType == 3">
and so.mechanic_id = #{userId} and so.mechanic_id = #{userId}
<if test="orderStatus != null and orderStatus!=''"> <if test="orderStatus != null and orderStatus!=''">
<choose> <choose>
...@@ -1346,15 +1352,19 @@ ...@@ -1346,15 +1352,19 @@
<when test="orderStatus == 2"> <when test="orderStatus == 2">
and so.active_status in (6,7) and so.active_status in (6,7)
</when> </when>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
</choose> </choose>
</if> </if>
</when> </when> -->
<!-- 服务商 -->
<when test="userType == 1"> <when test="userType == 1">
<if test="orderStatus != null and orderStatus!=''"> <if test="orderStatus != null and orderStatus!=''">
<choose> <choose>
<when test="orderStatus == 0"> <when test="orderStatus == 0">
and so.active_status in (1,2,5) and so.active_status in (1,2,5)
and so.canceled = 1
</when> </when>
<when test="orderStatus == 1"> <when test="orderStatus == 1">
...@@ -1363,18 +1373,22 @@ ...@@ -1363,18 +1373,22 @@
<when test="orderStatus == 2"> <when test="orderStatus == 2">
and so.active_status in (4,6,7) and so.active_status in (4,6,7)
and so.canceled = 1
</when> </when>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
</choose> </choose>
</if> </if>
</when> </when>
<!-- 运营 -->
<otherwise> <otherwise>
<choose> <choose>
<when test="orderStatus != null and orderStatus==0"> <when test="orderStatus != null and orderStatus==20">
and so.canceled = #{orderStatus} and so.canceled = 0
</when> </when>
<when test="orderStatus != null and orderStatus>0"> <when test="orderStatus != null and orderStatus<20">
and so.active_status = #{orderStatus} and so.active_status = #{orderStatus}
and so.canceled = 1 and so.canceled = 1
</when> </when>
...@@ -1519,4 +1533,104 @@ ...@@ -1519,4 +1533,104 @@
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<select id="countByOrderStatusAndUserType" resultType="java.lang.Integer" >
select COUNT(1) FROM
<choose>
<when test="userId == 0">
sys_order so
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
LEFT JOIN sys_user sc ON so.merchant_id = sc.id
LEFT JOIN sys_merchant ssm ON so.shop_id = ssm.user_id
WHERE so.active_status &lt;&gt; 9
</when>
<otherwise>
<choose>
<when test="userType == 1">
sys_order so
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
LEFT JOIN sys_user sc ON so.merchant_id = sc.id
LEFT JOIN sys_merchant ssm ON so.shop_id = ssm.user_id
WHERE so.merchant_id = #{userId}
and so.active_status &lt;&gt; 9
</when>
<otherwise>
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
LEFT JOIN sys_user sp ON so.shop_id = sp.id
LEFT JOIN sys_user sm ON so.mechanic_id = sm.id
LEFT JOIN sys_user sc ON so.merchant_id = sc.id
WHERE suo.user_id = #{userId}
and so.active_status &lt;&gt; 9
</otherwise>
</choose>
</otherwise>
</choose>
<!-- 商户 -->
<choose>
<when test="userType == 2">
and so.shop_id = #{userId}
<if test="orderStatus != null and orderStatus!=''">
<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 in (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>
</if>
</when>
<!-- 服务商 -->
<when test="userType == 1">
<if test="orderStatus != null and orderStatus!=''">
<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 in (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>
</if>
</when>
<!-- 运营 -->
<otherwise>
<choose>
<when test="orderStatus != null and orderStatus==20">
and so.canceled = 0
</when>
<when test="orderStatus != null and orderStatus<20">
and so.active_status = #{orderStatus}
and so.canceled = 1
</when>
</choose>
</otherwise>
</choose>
and so.order_type != 4
order by so.create_time desc
</select>
</mapper> </mapper>
\ No newline at end of file \ 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!