Commit 5ef89769 by chizw

Merge all from car-service-ordercenter v.17.3

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@36892 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 3b349e13
...@@ -111,8 +111,10 @@ public class OrderController extends BaseController { ...@@ -111,8 +111,10 @@ public class OrderController extends BaseController {
queryOrderReq.setNeedMoreInfo(true); queryOrderReq.setNeedMoreInfo(true);
List<SysOrder> list = orderService.getOrderListByExample(pageIndex, pageSize, queryOrderReq); List<SysOrder> list = orderService.getOrderListByExample(pageIndex, pageSize, queryOrderReq);
Page page = new Page(pageIndex, pageSize); Page page = new Page(pageIndex, pageSize);
com.github.pagehelper.Page<SysOrder> pages = (com.github.pagehelper.Page<SysOrder>) list; if (!CollectionUtil.isEmpty(list)) {
page.setTotalCount((int) pages.getTotal()); com.github.pagehelper.Page<SysOrder> pages = (com.github.pagehelper.Page<SysOrder>) list;
page.setTotalCount((int) pages.getTotal());
}
result.put("page", page); result.put("page", page);
result.put("items", list); result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result); return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
...@@ -951,7 +953,7 @@ public class OrderController extends BaseController { ...@@ -951,7 +953,7 @@ public class OrderController extends BaseController {
//} //}
// orderBy:c按单量排序,d按距离排序,t按时效排序 // orderBy:c按单量排序,d按距离排序,t按时效排序
List<MechanicBusiness> list = orderService.getMechanicList(pageIndex, pageSize, id, keyWord, orderBy, userId); List<MechanicBusiness> list = orderService.getSimpleMechanicList(pageIndex, pageSize, id, keyWord, orderBy, userId);
Page page = new Page(pageIndex, pageSize); Page page = new Page(pageIndex, pageSize);
com.github.pagehelper.Page<MechanicBusiness> pages = (com.github.pagehelper.Page<MechanicBusiness>) list; com.github.pagehelper.Page<MechanicBusiness> pages = (com.github.pagehelper.Page<MechanicBusiness>) list;
page.setTotalCount((int) pages.getTotal()); page.setTotalCount((int) pages.getTotal());
......
...@@ -78,6 +78,8 @@ public class QueryOrderReq implements Serializable { ...@@ -78,6 +78,8 @@ public class QueryOrderReq implements Serializable {
private Integer subsidy; private Integer subsidy;
private List<Integer> ids; private List<Integer> ids;
private List<Integer> idList;
/** /**
* 车品牌 * 车品牌
*/ */
...@@ -416,4 +418,12 @@ public class QueryOrderReq implements Serializable { ...@@ -416,4 +418,12 @@ public class QueryOrderReq implements Serializable {
", orderIds='" + orderIds + '\'' + ", orderIds='" + orderIds + '\'' +
'}'; '}';
} }
public List<Integer> getIdList() {
return idList;
}
public void setIdList(List<Integer> idList) {
this.idList = idList;
}
} }
...@@ -108,4 +108,16 @@ public class CarOrderQueryReq extends PagedReq { ...@@ -108,4 +108,16 @@ public class CarOrderQueryReq extends PagedReq {
private Integer volvoApprovedStatus; private Integer volvoApprovedStatus;
private String orderSource; private String orderSource;
private String contactInfo;
private String beginDate;
private String endDate;
private String carOwnerInfo;
private String volvoApprovedBeginTime;
private String volvoApprovedEndTime;
} }
...@@ -32,6 +32,11 @@ public interface SysMechanicMapper { ...@@ -32,6 +32,11 @@ public interface SysMechanicMapper {
@Param("sortMethod") Byte sortMethod, @Param("sortMethod") Byte sortMethod,
@Param("userId") Integer userId); @Param("userId") Integer userId);
List<MechanicBusiness> selectSimpleMechanicByOrder(@Param("keyWord") String keyWord,
@Param("latitude") String latitude, @Param("longitude") String longitude,
@Param("sortMethod") Byte sortMethod,
@Param("userId") Integer userId);
List<MechanicBusiness> getMechanicListOrderByDistance(@Param("keyWord") String keyWord, List<MechanicBusiness> getMechanicListOrderByDistance(@Param("keyWord") String keyWord,
@Param("latitude") String latitude, @Param("longitude") String longitude, @Param("latitude") String latitude, @Param("longitude") String longitude,
......
...@@ -229,4 +229,22 @@ public interface SysOrderMapper { ...@@ -229,4 +229,22 @@ public interface SysOrderMapper {
* @return * @return
*/ */
List<OrderRepairDto> getAfterSaleNumByOrderIdsOrOrdersnList(@Param("orderIds") Set<Integer> orderIds, @Param("ordersnList") Set<String> ordersnList); List<OrderRepairDto> getAfterSaleNumByOrderIdsOrOrdersnList(@Param("orderIds") Set<Integer> orderIds, @Param("ordersnList") Set<String> ordersnList);
/**
* 获取订单列表(简版)
*
* @param queryOrderReq
* @return
*/
List<SysOrder> getSimpleOrderListByExample(QueryOrderReq queryOrderReq);
List<Integer> getOrderIdListByUserInfo(QueryOrderReq queryOrderReq);
List<SysOrder> getSysUserByShopId(@Param("req") QueryOrderReq queryOrderReq, @Param("list") List<Integer> list);
List<SysOrder> getSysUserByMechanicId(@Param("req") QueryOrderReq queryOrderReq, @Param("list") List<Integer> list);
List<SysOrder> getSysManagerByMerchantId(@Param("req") QueryOrderReq queryOrderReq, @Param("list") List<Integer> list);
List<SysOrder> getSysMerchantByShopId(@Param("req") QueryOrderReq queryOrderReq, @Param("list") List<Integer> list);
List<SysOrder> getSysServiceItemByServiceCode(@Param("req") QueryOrderReq queryOrderReq, @Param("list") List<String> list);
List<SysOrder> getSysDictDataByReserveInstallReason(@Param("req") QueryOrderReq queryOrderReq, @Param("list") List<String> list);
List<SysOrder> getSysOrderSubsidyBySysOrderId(@Param("req") QueryOrderReq queryOrderReq, @Param("list") List<Integer> list);
List<SysOrder> getSysAreaByDistrict(@Param("req") QueryOrderReq queryOrderReq, @Param("list") List<Integer> list);
} }
...@@ -614,4 +614,6 @@ public class SysOrder implements Serializable { ...@@ -614,4 +614,6 @@ public class SysOrder implements Serializable {
*/ */
List<String> vinNoList; List<String> vinNoList;
private String dataKey;
} }
\ No newline at end of file \ No newline at end of file
package com.glsx.ordercenter.pojo; package com.glsx.ordercenter.pojo;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -2932,6 +2934,14 @@ public class SysOrderExample { ...@@ -2932,6 +2934,14 @@ public class SysOrderExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andOrCriteria(String value, List<Integer> ids) {
String join = StringUtils.join(ids, ",");
addCriterion("(order_sn LIKE" + "\"" + "%" + value + "%" + "\"" + " or car_type LIKE" + "\"" + "%" + value
+ "%" + "\"" + " or vin_no LIKE" + "\"" + "%" + value + "%" + "\"" + " or car_owner LIKE" + "\""
+ "%" + value + "%" + "\"" + "or id in (" + join + ")" + ")");
return (Criteria) this;
}
public Criteria andOrCriteria() { public Criteria andOrCriteria() {
addCriterion("(ISNULL(shop_id) or ISNULL(merchant_id))"); addCriterion("(ISNULL(shop_id) or ISNULL(merchant_id))");
return (Criteria) this; return (Criteria) this;
......
...@@ -274,6 +274,9 @@ public interface IOrderService { ...@@ -274,6 +274,9 @@ public interface IOrderService {
List<MechanicBusiness> getMechanicList(Integer page, Integer pageSize, Integer orderId, List<MechanicBusiness> getMechanicList(Integer page, Integer pageSize, Integer orderId,
String keyWord, String orderBy, Integer userId); String keyWord, String orderBy, Integer userId);
List<MechanicBusiness> getSimpleMechanicList(Integer page, Integer pageSize, Integer orderId,
String keyWord, String orderBy, Integer userId);
/** /**
* @param id 订单id * @param id 订单id
* @param flag 是否包含服务详细数据 * @param flag 是否包含服务详细数据
......
...@@ -1334,6 +1334,7 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer ...@@ -1334,6 +1334,7 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer
} }
private SysOrder wrapSubOrderVassal(SysOrder order) { private SysOrder wrapSubOrderVassal(SysOrder order) {
if (CollectionUtils.isEmpty(order.getSubOrderList())) return order;
SysSubOrder subOrder = order.getSubOrderList().get(0); SysSubOrder subOrder = order.getSubOrderList().get(0);
SysSubOrderVassal subOrderVassal = sysSubOrderVassalMapper.selectBySubOrderId(subOrder.getId()); SysSubOrderVassal subOrderVassal = sysSubOrderVassalMapper.selectBySubOrderId(subOrder.getId());
subOrder.setSubOrderVassal(subOrderVassal); subOrder.setSubOrderVassal(subOrderVassal);
......
...@@ -92,8 +92,10 @@ public class OrderUtil { ...@@ -92,8 +92,10 @@ public class OrderUtil {
if (shopInfo != null) { if (shopInfo != null) {
SysOrganization organization = this.organizationMapper.selectByPrimaryKey( SysOrganization organization = this.organizationMapper.selectByPrimaryKey(
shopInfo.getGroupId()); shopInfo.getGroupId());
order.setOrderChannel(organization.getName()); if (organization != null) {
order.setOrderChannelOrgId(organization.getId()); order.setOrderChannel(organization.getName());
order.setOrderChannelOrgId(organization.getId());
}
} }
} else { } else {
// 未知渠道 // 未知渠道
......
...@@ -303,6 +303,46 @@ ...@@ -303,6 +303,46 @@
<if test="orderSource != null and orderSource != ''"> <if test="orderSource != null and orderSource != ''">
and o.order_source = #{orderSource,jdbcType=VARCHAR} and o.order_source = #{orderSource,jdbcType=VARCHAR}
</if> </if>
<if test="vinNo != null and vinNo != ''">
and exists(
select 1 from sys_sub_order sso where sso.order_id = o.id
and sso.vin_no like concat('%',#{vinNo},'%')
)
</if>
<if test="workOrderNo != null and workOrderNo != ''">
and o.work_order_no like concat('%',#{workOrderNo},'%')
</if>
<if test="mechanicInfo != null and mechanicInfo != ''">
and (umec.name like concat('%',#{mechanicInfo},'%')
or umec.phone_number like concat('%',#{mechanicInfo},'%'))
</if>
<if test="city != null and city != ''">
and exists(
SELECT 1 from sys_area d
LEFT JOIN sys_area c ON d.parent_id = c.id
LEFT JOIN sys_area p ON c.parent_id = p.id
where d.id = o.district
and concat_ws('', p.area_name, c.area_name, d.area_name) like concat('%',#{city},'%')
)
</if>
<if test="contactInfo != null and contactInfo != ''">
and (o.contact like concat('%',#{contactInfo},'%')
or o.phone_number like concat('%',#{contactInfo},'%'))
</if>
<if test="carOwnerInfo != null and carOwnerInfo != ''">
and exists(
SELECT 1 from sys_sub_order so
where o.id = so.order_id
and (so.car_owner like concat('%',#{carOwnerInfo},'%')
or so.car_owner_phone like concat('%',#{carOwnerInfo},'%'))
)
</if>
<if test="beginDate != null and beginDate!= ''">
and DATE_FORMAT(o.create_time, '%Y-%m-%d') &gt;= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
and DATE_FORMAT(o.create_time, '%Y-%m-%d') &lt;= #{endDate}
</if>
<!-- 不查找已删除的 --> <!-- 不查找已删除的 -->
and o.active_status != 9 and o.active_status != 9
<!-- 只查找车务单 --> <!-- 只查找车务单 -->
...@@ -932,6 +972,55 @@ ...@@ -932,6 +972,55 @@
<if test="orderSource != null and orderSource != ''"> <if test="orderSource != null and orderSource != ''">
and o.order_source = #{orderSource,jdbcType=VARCHAR} and o.order_source = #{orderSource,jdbcType=VARCHAR}
</if> </if>
<if test="vinNo != null and vinNo != ''">
and exists(
select 1 from sys_sub_order sso where sso.order_id = o.id
and sso.vin_no like concat('%',#{vinNo},'%')
)
</if>
<if test="workOrderNo != null and workOrderNo != ''">
and o.work_order_no like concat('%',#{workOrderNo},'%')
</if>
<if test="mechanicInfo != null and mechanicInfo != ''">
and exists(
select 1 from sys_user umec where o.mechanic_id = umec.id
and (umec.name like concat('%',#{mechanicInfo},'%')
or umec.phone_number like concat('%',#{mechanicInfo},'%'))
)
</if>
<if test="city != null and city != ''">
and exists(
SELECT 1 from sys_area d
LEFT JOIN sys_area c ON d.parent_id = c.id
LEFT JOIN sys_area p ON c.parent_id = p.id
where d.id = o.district
and concat_ws('', p.area_name, c.area_name, d.area_name) like concat('%',#{city},'%')
)
</if>
<if test="contactInfo != null and contactInfo != ''">
and (o.contact like concat('%',#{contactInfo},'%')
or o.phone_number like concat('%',#{contactInfo},'%'))
</if>
<if test="beginDate != null and beginDate!= ''">
and DATE_FORMAT(o.create_time, '%Y-%m-%d') &gt;= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
and DATE_FORMAT(o.create_time, '%Y-%m-%d') &lt;= #{endDate}
</if>
<if test="volvoApprovedBeginTime != null and volvoApprovedBeginTime!= ''">
and DATE_FORMAT(o.volvo_approved_time, '%Y-%m-%d') &gt;= #{volvoApprovedBeginTime}
</if>
<if test="volvoApprovedEndTime != null and volvoApprovedEndTime != ''">
and DATE_FORMAT(o.volvo_approved_time, '%Y-%m-%d') &lt;= #{volvoApprovedEndTime}
</if>
<if test="carOwnerInfo != null and carOwnerInfo != ''">
and exists(
SELECT 1 from sys_sub_order so
where o.id = so.order_id
and (so.car_owner like concat('%',#{carOwnerInfo},'%')
or so.car_owner_phone like concat('%',#{carOwnerInfo},'%'))
)
</if>
<!-- 不查找已删除的 --> <!-- 不查找已删除的 -->
and o.active_status != 9 and o.active_status != 9
<!-- 只查找车务单 --> <!-- 只查找车务单 -->
......
...@@ -368,6 +368,107 @@ ...@@ -368,6 +368,107 @@
</choose> </choose>
</select> </select>
<select id="selectSimpleMechanicByOrder"
resultType="com.glsx.ordercenter.dto.MechanicBusiness">
SELECT
u.id mechanicId,
u.name,
u.phone_number phone,
m.work_status workStatus,
m.mechanic_status mechanicStatus,
<!-- 头像 -->
ui.url portrait,
<!-- 地址 -->
CONCAT_WS('', ap.area_name, ac.area_name, ad.area_name, m.address) address,
<if test="sortMethod != null and (sortMethod == 2 or sortMethod == 3)">
<!-- 安装单量、时效 -->
temp.count count,
temp.timeliness timeliness,
<!-- 距离 -->
</if>
ROUND(
6378.138 * 2 * ASIN(SQRT(
POW(SIN((#{latitude} * PI() / 180 - u.latitude * PI() / 180) / 2), 2)
+ COS(#{latitude} * PI() / 180)
* COS(u.latitude * PI() / 180)
* POW(SIN((#{longitude} * PI() / 180 - u.longitude * PI() / 180) / 2), 2)
)) * 1000
) AS distance
FROM sys_mechanic m
LEFT JOIN sys_user u ON m.user_id = u.id
LEFT JOIN sys_area ad ON m.district = ad.id
LEFT JOIN sys_area ac ON ad.parent_id = ac.id
LEFT JOIN sys_area ap ON ac.parent_id = ap.id
LEFT JOIN sys_user_image ui ON ui.user_id = u.id AND ui.image_key = 'sys_head_portrait'
LEFT JOIN sys_service_mechanic sm ON sm.mechanic_id = u.id
<if test="sortMethod != null and (sortMethod == 2 or sortMethod == 3)">
LEFT JOIN (
<!-- 通过技工ID统计订单量和所有订单的总耗时,并计算每个订单的平均耗时 -->
SELECT mechanicId, COUNT(os.order_id) count,
(TIMESTAMPDIFF(MINUTE, MIN(os.update_time), MAX(os.update_time))
/ COUNT(os.order_id)) timeliness
FROM (
<!-- 查询同一个订单的状态为已派单和已完成的流水记录,用来统计从派单到完成的耗时 -->
SELECT os.order_id, os.update_time, o.mechanic_id mechanicId
FROM sys_order o
LEFT JOIN sys_order_status os ON os.order_id = o.id
<!-- 服务商ID为空,指定发货方式为广联 -->
<if test="userId == null">
LEFT JOIN sys_mechanic m ON o.mechanic_id = m.user_id AND m.send_type = 2
</if>
<!-- 服务商ID不为空,不指定发货方式为广联 -->
<if test="userId != null">
LEFT JOIN sys_mechanic m ON o.mechanic_id = m.user_id
</if>
WHERE o.order_type = 1 AND o.active_status = 8
AND (os.active_status = 8
OR (os.active_status = 4 AND ISNULL(os.remark))
OR (os.active_status = 110 AND ISNULL(os.remark))
)
GROUP BY order_id
) os
WHERE os.mechanicId IS NOT NULL
GROUP BY mechanicId
) temp ON m.user_id = temp.mechanicId
</if>
<where>
u.user_status = 'sys_user_status_normal'
<!-- 服务商ID为空,则不指定服务商,且指定发货方式为广联 -->
<if test="userId == null">
AND m.send_type = 2
</if>
<!-- 服务商ID不为空,指定服务商ID,且不指定发货方式为广联 -->
<if test="userId != null">
AND sm.service_id = #{userId,jdbcType=INTEGER}
</if>
<if test="keyWord != null and keyWord != ''">
<bind name="keyWord" value="'%' + keyWord + '%'"/>
AND (u.name LIKE #{keyWord}
OR u.phone_number LIKE #{keyWord}
OR address LIKE #{keyWord})
</if>
</where>
GROUP BY u.id
<choose>
<!-- 距离排序 -->
<when test="sortMethod == 1">
ORDER BY distance IS NULL, distance ASC
</when>
<!-- 安装量排序 -->
<when test="sortMethod == 2">
ORDER BY `count` IS NULL, `count` DESC
</when>
<!-- 时效排序 -->
<when test="sortMethod == 3">
ORDER BY timeliness IS NULL, timeliness ASC
</when>
<!-- 其他,距离排序 -->
<otherwise>
ORDER BY distance IS NULL, distance ASC
</otherwise>
</choose>
</select>
<select id="getMechanicListOrderByDistance" <select id="getMechanicListOrderByDistance"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!