Commit edd20862 by wubh

包活干V2.0.0-修改:快递单相关业务

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@28219 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 54720442
...@@ -2,6 +2,8 @@ package com.glsx.common.utils; ...@@ -2,6 +2,8 @@ package com.glsx.common.utils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.Constants; import com.glsx.common.constants.Constants;
import com.glsx.common.constants.ResultCodeEnum; import com.glsx.common.constants.ResultCodeEnum;
...@@ -40,6 +42,24 @@ public class UserUtils { ...@@ -40,6 +42,24 @@ public class UserUtils {
return userId; return userId;
} }
public static JSONObject getUserInfo(Integer id) {
JSONObject respObj = userClient.getUserById(id);
JSONObject userObj;
if (respObj != null
&& respObj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
userObj = respObj.getJSONObject("data");
} else {
userObj = new JSONObject();
}
return userObj;
}
/**
* 获取当前登录用户对象
*
* @return 用户对象
*/
public static JSONObject getCurrentUser() { public static JSONObject getCurrentUser() {
JSONObject userObj; JSONObject userObj;
ServletRequestAttributes attributes = ServletRequestAttributes attributes =
...@@ -47,13 +67,7 @@ public class UserUtils { ...@@ -47,13 +67,7 @@ public class UserUtils {
if (attributes != null) { if (attributes != null) {
HttpServletRequest request = attributes.getRequest(); HttpServletRequest request = attributes.getRequest();
JSONObject respObj = userClient.getUserById(getUserId(request)); userObj = getUserInfo(getUserId(request));
if (respObj != null && respObj.getIntValue("code")
== ResultCodeEnum.SUCCESS.getCode()) {
userObj = respObj.getJSONObject("data");
} else {
userObj = new JSONObject();
}
} else { } else {
userObj = new JSONObject(); userObj = new JSONObject();
} }
...@@ -61,14 +75,42 @@ public class UserUtils { ...@@ -61,14 +75,42 @@ public class UserUtils {
return userObj; return userObj;
} }
/**
* 获取当前登录用户ID
*
* @return 用户ID
*/
public static Integer getCurrentUserId() { public static Integer getCurrentUserId() {
return getCurrentUser().getInteger("id"); ServletRequestAttributes attributes =
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
return (attributes != null) ? getUserId(attributes.getRequest()) : null;
} }
/**
* 获取当前登录用户角色
*
* @return 用户角色
*/
public static Byte getCurrentUserType() { public static Byte getCurrentUserType() {
return getCurrentUser().getByte("userType"); return getCurrentUser().getByte("userType");
} }
/**
* 根据用户角色代码转换成文本
*
* @param userType 用户角色
* @return 角色名
*/
public static String convertUserTypeName(Byte userType) {
Map<Byte, String> userTypeMap = new HashMap<>(4);
userTypeMap.put((byte) 0, "平台运营");
userTypeMap.put((byte) 1, "服务商");
userTypeMap.put((byte) 2, "商户");
userTypeMap.put((byte) 3, "技工");
return userTypeMap.get(userType);
}
@Autowired @Autowired
public void setUserClient(UserClient userClient) { public void setUserClient(UserClient userClient) {
UserUtils.userClient = userClient; UserUtils.userClient = userClient;
......
...@@ -76,7 +76,9 @@ public enum ResultCodeEnum { ...@@ -76,7 +76,9 @@ public enum ResultCodeEnum {
DELIVERY_ALREADY_SENT(30042, "快递单已经寄出,不可重复操作"), DELIVERY_ALREADY_SENT(30042, "快递单已经寄出,不可重复操作"),
DELIVERY_ALREADY_RECEIVED(30043, "快递单已经签收,不可重复操作"), DELIVERY_ALREADY_RECEIVED(30043, "快递单已经签收,不可重复操作"),
DELIVERY_ALREADY_CANCELED(30044, "快递单已取消,不可重复操作"), DELIVERY_ALREADY_CANCELED(30044, "快递单已取消,不可重复操作"),
DELIVERY_STATUS_ERROR(30045, "快递单状态不为待寄件,无法操作"), DELIVERY_STATUS_ERROR(30045, "快递单状态错误,无法操作"),
DELIVERY_NOT_SENDER(30046, "当前用户不是寄件人,无法寄件"),
DELIVERY_NOT_RECEIVER(30046, "当前用户不是收件人,无法签收"),
/** /**
* 渠道订单相关状态码 * 渠道订单相关状态码
......
package com.glsx.ordercenter.controller; package com.glsx.ordercenter.controller;
import java.util.Map;
import java.util.Objects;
import com.glsx.common.annotation.AuthCheck; import com.glsx.common.annotation.AuthCheck;
import com.glsx.common.pojo.PagedResp;
import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.req.DeliveryQueryReq; import com.glsx.ordercenter.dto.req.DeliveryQueryReq;
import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.pojo.SysDelivery; import com.glsx.ordercenter.pojo.SysDelivery;
import com.glsx.ordercenter.service.DeliveryService; import com.glsx.ordercenter.service.DeliveryService;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
...@@ -21,7 +28,7 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -21,7 +28,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
@AuthCheck @AuthCheck
@Controller @Controller
@RequestMapping("/delivery") @RequestMapping("/delivery")
public class DeliveryController { public class DeliveryController extends BaseController {
@Autowired @Autowired
private DeliveryService deliveryService; private DeliveryService deliveryService;
...@@ -33,7 +40,14 @@ public class DeliveryController { ...@@ -33,7 +40,14 @@ public class DeliveryController {
*/ */
@RequestMapping(value = "/countByStatus", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/countByStatus", method = {RequestMethod.POST, RequestMethod.GET})
R countByStatus(DeliveryQueryReq req) { R countByStatus(DeliveryQueryReq req) {
return this.deliveryService.countByStatus(req); super.logInfo("==== /delivery/countByStatus param", req);
req.setUserId(UserUtils.getCurrentUserId());
Map<String, Integer> statusCountMap = this.deliveryService.countByStatus(req);
R result = R.ok().data(statusCountMap);
super.logInfo("==== /delivery/countByStatus result", result);
return result;
} }
/** /**
...@@ -44,7 +58,13 @@ public class DeliveryController { ...@@ -44,7 +58,13 @@ public class DeliveryController {
*/ */
@RequestMapping(value = "/getList", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/getList", method = {RequestMethod.POST, RequestMethod.GET})
R getList(DeliveryQueryReq req) { R getList(DeliveryQueryReq req) {
return this.deliveryService.getList(req); super.logInfo("==== /delivery/getList param", req);
req.setUserId(UserUtils.getCurrentUserId());
PagedResp<SysDelivery> pagedResp = this.deliveryService.getList(req);
R result = R.ok().data(pagedResp);
return result;
} }
/** /**
...@@ -55,7 +75,14 @@ public class DeliveryController { ...@@ -55,7 +75,14 @@ public class DeliveryController {
*/ */
@RequestMapping(value = "/getDetail", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/getDetail", method = {RequestMethod.POST, RequestMethod.GET})
R getDetail(DeliveryQueryReq req) { R getDetail(DeliveryQueryReq req) {
return this.deliveryService.getDetail(req); super.logInfo("==== /delivery/getDetail param", req);
req.setUserId(UserUtils.getCurrentUserId());
SysDelivery delivery = this.deliveryService.getDetail(req);
R result = R.ok().data(delivery);
super.logInfo("==== /delivery/getDetail result", result);
return result;
} }
/** /**
...@@ -66,7 +93,20 @@ public class DeliveryController { ...@@ -66,7 +93,20 @@ public class DeliveryController {
*/ */
@RequestMapping(value = "/save", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/save", method = {RequestMethod.POST, RequestMethod.GET})
R save(SysDelivery delivery) { R save(SysDelivery delivery) {
return this.deliveryService.save(delivery); super.logInfo("==== /delivery/save param", delivery);
Byte currentUserType = UserUtils.getCurrentUserType();
if (!Objects.equals(BizConstants.USER_TYPE_AMIN, currentUserType)) {
super.logInfo("==== /delivery verifyUserType ERROR: userType not admin: ",
currentUserType);
throw BusinessException.create(ResultCodeEnum.USER_TYPE_NOT_HAS_AUTHORITY.getCode(),
ResultCodeEnum.USER_TYPE_NOT_HAS_AUTHORITY.getMsg());
}
delivery.setUserId(UserUtils.getCurrentUserId());
R result = this.deliveryService.save(delivery);
super.logInfo("==== /delivery/save result", result);
return result;
} }
/** /**
...@@ -77,7 +117,13 @@ public class DeliveryController { ...@@ -77,7 +117,13 @@ public class DeliveryController {
*/ */
@RequestMapping(value = "/send", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/send", method = {RequestMethod.POST, RequestMethod.GET})
R send(SysDelivery delivery) { R send(SysDelivery delivery) {
return this.deliveryService.send(delivery); super.logInfo("==== /delivery/send param", delivery);
delivery.setUserId(UserUtils.getCurrentUserId());
R result = this.deliveryService.send(delivery);
super.logInfo("==== /delivery/send result", result);
return result;
} }
/** /**
...@@ -88,7 +134,13 @@ public class DeliveryController { ...@@ -88,7 +134,13 @@ public class DeliveryController {
*/ */
@RequestMapping(value = "/receive", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/receive", method = {RequestMethod.POST, RequestMethod.GET})
R receive(SysDelivery delivery) { R receive(SysDelivery delivery) {
return this.deliveryService.receive(delivery); super.logInfo("==== /delivery/receive param", delivery);
delivery.setUserId(UserUtils.getCurrentUserId());
R result = this.deliveryService.receive(delivery);
super.logInfo("==== /delivery/receive result", result);
return result;
} }
/** /**
...@@ -99,6 +151,12 @@ public class DeliveryController { ...@@ -99,6 +151,12 @@ public class DeliveryController {
*/ */
@RequestMapping(value = "/cancel", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/cancel", method = {RequestMethod.POST, RequestMethod.GET})
R cancel(SysDelivery delivery) { R cancel(SysDelivery delivery) {
return this.deliveryService.cancel(delivery); super.logInfo("==== /delivery/cancel param", delivery);
delivery.setUserId(UserUtils.getCurrentUserId());
R result = this.deliveryService.cancel(delivery);
super.logInfo("==== /delivery/cancel result", result);
return result;
} }
} }
...@@ -188,14 +188,21 @@ public class ReportController extends BaseReportController { ...@@ -188,14 +188,21 @@ public class ReportController extends BaseReportController {
JSONObject user = this.userClient.getUserById(oueryOrderReq.getUserId()); JSONObject user = this.userClient.getUserById(oueryOrderReq.getUserId());
int userType = user.getIntValue("userType"); int userType = user.getIntValue("userType");
oueryOrderReq.setUserType(userType); oueryOrderReq.setUserType(userType);
oueryOrderReq.setNeedMoreInfo(true);
List<SysOrder> list = this.orderService.getOrderListByExample(null, null, oueryOrderReq);
if (list.size() > 10000) { // 先不获取详细数据,只查出所有总数
oueryOrderReq.setNeedMoreInfo(false);
int totalSize = this.orderService.getOrderListByExample(null, null, oueryOrderReq).size();
if (totalSize > 10000) {
throw SysException.create(ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getCode(), throw SysException.create(ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getCode(),
ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getMsg()); ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getMsg());
} }
if (list.size() > 0) {
// 开始获取详细数据
oueryOrderReq.setNeedMoreInfo(true);
List<SysOrder> list = this.orderService.getOrderListByExample(null, null, oueryOrderReq);
if (!list.isEmpty()) {
for (SysOrder sysOrder : list) { for (SysOrder sysOrder : list) {
ExportOrderVo exportOrderVo = new ExportOrderVo(); ExportOrderVo exportOrderVo = new ExportOrderVo();
BeanUtils.copyProperties(sysOrder, exportOrderVo); BeanUtils.copyProperties(sysOrder, exportOrderVo);
......
...@@ -22,6 +22,16 @@ public class DeliveryQueryReq extends PagedReq { ...@@ -22,6 +22,16 @@ public class DeliveryQueryReq extends PagedReq {
private Integer userId; private Integer userId;
/** /**
* 当前用户类型
*/
private Byte userType;
/**
* 是否需要详细信息
*/
private Boolean needDetailInfo = true;
/**
* 快递单ID * 快递单ID
*/ */
private Integer id; private Integer id;
...@@ -132,6 +142,22 @@ public class DeliveryQueryReq extends PagedReq { ...@@ -132,6 +142,22 @@ public class DeliveryQueryReq extends PagedReq {
this.userId = userId; this.userId = userId;
} }
public Byte getUserType() {
return userType;
}
public void setUserType(Byte userType) {
this.userType = userType;
}
public Boolean getNeedDetailInfo() {
return needDetailInfo;
}
public void setNeedDetailInfo(Boolean needDetailInfo) {
this.needDetailInfo = needDetailInfo;
}
public Integer getId() { public Integer getId() {
return id; return id;
} }
...@@ -289,6 +315,8 @@ public class DeliveryQueryReq extends PagedReq { ...@@ -289,6 +315,8 @@ public class DeliveryQueryReq extends PagedReq {
return "DeliveryQueryReq{" + return "DeliveryQueryReq{" +
"keyword='" + keyword + '\'' + "keyword='" + keyword + '\'' +
", userId=" + userId + ", userId=" + userId +
", userType=" + userType +
", needDetailInfo=" + needDetailInfo +
", id=" + id + ", id=" + id +
", orderId=" + orderId + ", orderId=" + orderId +
", orderSn='" + orderSn + '\'' + ", orderSn='" + orderSn + '\'' +
......
package com.glsx.ordercenter.mapper; package com.glsx.ordercenter.mapper;
import java.util.List; import java.util.List;
import com.glsx.ordercenter.dto.req.DeliveryQueryReq;
import com.glsx.ordercenter.pojo.SysDelivery; import com.glsx.ordercenter.pojo.SysDelivery;
import com.glsx.ordercenter.pojo.SysDeliveryExample; import com.glsx.ordercenter.pojo.SysDeliveryExample;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -8,6 +9,10 @@ import org.springframework.stereotype.Repository; ...@@ -8,6 +9,10 @@ import org.springframework.stereotype.Repository;
@Repository @Repository
public interface SysDeliveryMapper { public interface SysDeliveryMapper {
List<SysDelivery> selectList(DeliveryQueryReq req);
SysDelivery selectOneByUserId(DeliveryQueryReq req);
long countByExample(SysDeliveryExample example); long countByExample(SysDeliveryExample example);
int deleteByExample(SysDeliveryExample example); int deleteByExample(SysDeliveryExample example);
...@@ -22,9 +27,11 @@ public interface SysDeliveryMapper { ...@@ -22,9 +27,11 @@ public interface SysDeliveryMapper {
SysDelivery selectByPrimaryKey(Integer id); SysDelivery selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") SysDelivery record, @Param("example") SysDeliveryExample example); int updateByExampleSelective(@Param("record") SysDelivery record,
@Param("example") SysDeliveryExample example);
int updateByExample(@Param("record") SysDelivery record, @Param("example") SysDeliveryExample example); int updateByExample(@Param("record") SysDelivery record,
@Param("example") SysDeliveryExample example);
int updateByPrimaryKeySelective(SysDelivery record); int updateByPrimaryKeySelective(SysDelivery record);
......
...@@ -11,6 +11,29 @@ import org.springframework.format.annotation.DateTimeFormat; ...@@ -11,6 +11,29 @@ import org.springframework.format.annotation.DateTimeFormat;
*/ */
public class SysDelivery implements Serializable { public class SysDelivery implements Serializable {
/** /**
* 当前用户ID
*/
private Integer userId;
/**
* 当前用户类型
*/
private Byte userType;
/**
* 寄件人角色
*/
private String senderType;
/**
* 收件人角色
*/
private String receiverType;
/**
* 快递文件列表
*/
private List<SysDeliveryFile> deliveryFileList;
/**
* 快递单ID * 快递单ID
*/ */
private Integer id; private Integer id;
...@@ -132,7 +155,46 @@ public class SysDelivery implements Serializable { ...@@ -132,7 +155,46 @@ public class SysDelivery implements Serializable {
*/ */
private Integer updateBy; private Integer updateBy;
private List<SysDeliveryFile> deliveryFileList; public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Byte getUserType() {
return userType;
}
public void setUserType(Byte userType) {
this.userType = userType;
}
public String getSenderType() {
return senderType;
}
public void setSenderType(String senderType) {
this.senderType = senderType;
}
public String getReceiverType() {
return receiverType;
}
public void setReceiverType(String receiverType) {
this.receiverType = receiverType;
}
public List<SysDeliveryFile> getDeliveryFileList() {
return deliveryFileList;
}
public void setDeliveryFileList(
List<SysDeliveryFile> deliveryFileList) {
this.deliveryFileList = deliveryFileList;
}
public Integer getId() { public Integer getId() {
return id; return id;
...@@ -326,19 +388,15 @@ public class SysDelivery implements Serializable { ...@@ -326,19 +388,15 @@ public class SysDelivery implements Serializable {
this.updateBy = updateBy; this.updateBy = updateBy;
} }
public List<SysDeliveryFile> getDeliveryFileList() {
return deliveryFileList;
}
public void setDeliveryFileList(
List<SysDeliveryFile> deliveryFileList) {
this.deliveryFileList = deliveryFileList;
}
@Override @Override
public String toString() { public String toString() {
return "SysDelivery{" + return "SysDelivery{" +
"id=" + id + "userId=" + userId +
", userType=" + userType +
", senderType='" + senderType + '\'' +
", receiverType='" + receiverType + '\'' +
", deliveryFileList=" + deliveryFileList +
", id=" + id +
", orderId=" + orderId + ", orderId=" + orderId +
", orderSn='" + orderSn + '\'' + ", orderSn='" + orderSn + '\'' +
", logisticsId=" + logisticsId + ", logisticsId=" + logisticsId +
...@@ -362,7 +420,6 @@ public class SysDelivery implements Serializable { ...@@ -362,7 +420,6 @@ public class SysDelivery implements Serializable {
", updateTime=" + updateTime + ", updateTime=" + updateTime +
", createBy=" + createBy + ", createBy=" + createBy +
", updateBy=" + updateBy + ", updateBy=" + updateBy +
", deliveryFileList=" + deliveryFileList +
'}'; '}';
} }
} }
package com.glsx.ordercenter.service; package com.glsx.ordercenter.service;
import java.util.Map;
import com.glsx.common.pojo.PagedResp;
import com.glsx.ordercenter.dto.req.DeliveryQueryReq; import com.glsx.ordercenter.dto.req.DeliveryQueryReq;
import com.glsx.ordercenter.pojo.SysDelivery; import com.glsx.ordercenter.pojo.SysDelivery;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
...@@ -13,11 +15,11 @@ import com.glsx.plat.core.web.R; ...@@ -13,11 +15,11 @@ import com.glsx.plat.core.web.R;
* @date 2020-08-26 * @date 2020-08-26
*/ */
public interface DeliveryService { public interface DeliveryService {
R countByStatus(DeliveryQueryReq req); Map<String, Integer> countByStatus(DeliveryQueryReq req);
R getList(DeliveryQueryReq req); PagedResp<SysDelivery> getList(DeliveryQueryReq req);
R getDetail(DeliveryQueryReq req); SysDelivery getDetail(DeliveryQueryReq req);
R save(SysDelivery delivery); R save(SysDelivery delivery);
......
...@@ -3173,7 +3173,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -3173,7 +3173,7 @@ public class OrderServiceImpl implements IOrderService {
@Override @Override
public List<SysOrder> getOrderListByExample(Integer page, Integer pageSize, QueryOrderReq queryOrderReq) { public List<SysOrder> getOrderListByExample(Integer page, Integer pageSize, QueryOrderReq queryOrderReq) {
List<SysOrder> orderList = new ArrayList<>(); List<SysOrder> orderList;
JSONObject user = getUserInfo(queryOrderReq.getUserId()); JSONObject user = getUserInfo(queryOrderReq.getUserId());
if (0 != queryOrderReq.getUserId()) { if (0 != queryOrderReq.getUserId()) {
int userType = user.getIntValue("userType"); int userType = user.getIntValue("userType");
...@@ -3211,6 +3211,19 @@ public class OrderServiceImpl implements IOrderService { ...@@ -3211,6 +3211,19 @@ public class OrderServiceImpl implements IOrderService {
} }
orderList = orderMapper.getOrderListByExample(queryOrderReq); orderList = orderMapper.getOrderListByExample(queryOrderReq);
if (Boolean.TRUE.equals(queryOrderReq.getNeedMoreInfo())) { if (Boolean.TRUE.equals(queryOrderReq.getNeedMoreInfo())) {
this.getOrderMoreInfo(orderList);
}
return orderList;
}
/**
* 获取订单的更多信息
*
* @param orderList 订单基本信息
* @return 填充后的订单信息
*/
private List<SysOrder> getOrderMoreInfo(List<SysOrder> orderList) {
for (SysOrder order : orderList) { for (SysOrder order : orderList) {
// 渠道名称 // 渠道名称
if (order.getShopId() != null) { if (order.getShopId() != null) {
...@@ -3272,7 +3285,6 @@ public class OrderServiceImpl implements IOrderService { ...@@ -3272,7 +3285,6 @@ public class OrderServiceImpl implements IOrderService {
// 设置车辆信息 // 设置车辆信息
orderUtil.setCarInfo(orderList); orderUtil.setCarInfo(orderList);
} }
}
return orderList; return orderList;
} }
......
...@@ -98,22 +98,6 @@ ...@@ -98,22 +98,6 @@
update_by update_by
</sql> </sql>
<select id="selectByExample" parameterType="com.glsx.ordercenter.pojo.SysDeliveryExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from sys_delivery
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectList" parameterType="com.glsx.ordercenter.dto.req.DeliveryQueryReq" <select id="selectList" parameterType="com.glsx.ordercenter.dto.req.DeliveryQueryReq"
resultMap="BaseResultMap"> resultMap="BaseResultMap">
select id, order_id, order_sn, logistics_id, express_sn, sender_id, sender, sender_phone, select id, order_id, order_sn, logistics_id, express_sn, sender_id, sender, sender_phone,
...@@ -123,23 +107,61 @@ ...@@ -123,23 +107,61 @@
from sys_delivery from sys_delivery
<where> <where>
<if test="keyword != null"> <if test="keyword != null">
`express_sn` like "%"#{keyword}"%" <!-- 按照关键词查询 -->
or `sender` like "%"#{keyword}"%" and (express_sn like "%"#{keyword,jdbcType=VARCHAR}"%"
or `sender_phone` like "%"#{keyword}"%" or sender like "%"#{keyword,jdbcType=VARCHAR}"%"
or `receiver` like "%"#{keyword}"%" or sender_phone like "%"#{keyword,jdbcType=VARCHAR}"%"
or `receiver_phone` like "%"#{keyword}"%" or receiver like "%"#{keyword,jdbcType=VARCHAR}"%"
or receiver_phone like "%"#{keyword,jdbcType=VARCHAR}"%")
</if> </if>
<if test="status == 9"> <if test="status == 9">
<!-- 已取消 --> <!-- 状态为已取消 -->
and `canceled` = 0 and canceled = 0
</if> </if>
<if test="status != null"> <if test="status != null and status != 9">
<!-- 其他未取消状态 --> <!-- 其他未取消状态 -->
and `status` = #{status} and status = #{status,jdbcType=TINYINT}
</if> and canceled = 1
</if>
and (
<!-- 用户为收件人,查询全部 -->
sender_id = #{userId,jdbcType=INTEGER}
<!-- 用户为寄件人,查询状态不为待寄件的记录 -->
or (receiver_id = #{userId,jdbcType=INTEGER} and status != 1)
)
</where> </where>
</select> </select>
<select id="selectOneByUserId" parameterType="com.glsx.ordercenter.dto.req.DeliveryQueryReq"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from sys_delivery
where id = #{id,jdbcType=INTEGER}
and (
<!-- 用户为收件人,查询全部 -->
sender_id = #{userId,jdbcType=INTEGER}
<!-- 用户为寄件人,查询状态不为待寄件的记录 -->
or (receiver_id = #{userId,jdbcType=INTEGER} and status != 1)
)
</select>
<select id="selectByExample" parameterType="com.glsx.ordercenter.pojo.SysDeliveryExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from sys_delivery
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
......
package com.glsx.ordercenter.service;
import com.glsx.ordercenter.Application;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* <p>Description: 车务单业务测试
* <p>Project: car-service
*
* @author wbh
* @date 2020-08-31
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {Application.class},
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class CarOrderServiceTest {
}
package com.glsx.ordercenter.service;
import com.alibaba.fastjson.JSON;
import com.glsx.ordercenter.Application;
import com.glsx.ordercenter.dto.req.DeliveryQueryReq;
import com.glsx.ordercenter.pojo.SysDelivery;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* <p>Description: 快递单业务测试
* <p>Project: car-service
*
* @author wbh
* @date 2020-08-31
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {Application.class},
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class DeliveryServiceTest {
@Autowired
private DeliveryService deliveryService;
@Test
public void test_countByStatus() {
DeliveryQueryReq req = new DeliveryQueryReq();
req.setUserId(1);
this.prettyPrint(deliveryService.countByStatus(req));
}
@Test
public void test_getList() {
DeliveryQueryReq req = new DeliveryQueryReq();
req.setUserId(1);
this.prettyPrint(deliveryService.getList(req));
}
@Test
public void test_getDetail() {
DeliveryQueryReq req = new DeliveryQueryReq();
req.setUserId(1);
req.setId(3);
this.prettyPrint(deliveryService.getDetail(req));
}
@Test
public void test_save() {
SysDelivery delivery = new SysDelivery();
this.prettyPrint(deliveryService.save(delivery));
}
@Test
public void test_send() {
SysDelivery delivery = new SysDelivery();
this.prettyPrint(deliveryService.send(delivery));
}
@Test
public void test_receive() {
SysDelivery delivery = new SysDelivery();
this.prettyPrint(deliveryService.receive(delivery));
}
@Test
public void test_cancel() {
SysDelivery delivery = new SysDelivery();
this.prettyPrint(deliveryService.cancel(delivery));
}
private void prettyPrint(Object o) {
System.out.println(JSON.toJSONString(o, true));
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!