Commit aa464a26 by wubh

鍖呮椿骞睼2.0.0-淇敼锛氬揩閫掑崟鍒楄〃鐢ㄦ埛鏉冮檺闂銆佺粍缁囨煡鎵炬敮鎸佸晢鎴枫€佷慨鏀瑰懡鍚?

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@28321 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent c5c39797
Showing 18 changed files with 262 additions and 58 deletions
...@@ -44,6 +44,7 @@ public class DeliveryController extends BaseController { ...@@ -44,6 +44,7 @@ public class DeliveryController extends BaseController {
super.logInfo("==== /delivery/countByStatus param", req); super.logInfo("==== /delivery/countByStatus param", req);
req.setUserId(UserUtils.getCurrentUserId()); req.setUserId(UserUtils.getCurrentUserId());
req.setUserType(UserUtils.getCurrentUserType());
Map<String, Integer> statusCountMap = this.deliveryService.countByStatus(req); Map<String, Integer> statusCountMap = this.deliveryService.countByStatus(req);
R result = R.ok().data(statusCountMap); R result = R.ok().data(statusCountMap);
...@@ -62,6 +63,7 @@ public class DeliveryController extends BaseController { ...@@ -62,6 +63,7 @@ public class DeliveryController extends BaseController {
super.logInfo("==== /delivery/getList param", req); super.logInfo("==== /delivery/getList param", req);
req.setUserId(UserUtils.getCurrentUserId()); req.setUserId(UserUtils.getCurrentUserId());
req.setUserType(UserUtils.getCurrentUserType());
req.setNeedDetail(true); req.setNeedDetail(true);
PagedResp<SysDelivery> pagedResp = this.deliveryService.getList(req); PagedResp<SysDelivery> pagedResp = this.deliveryService.getList(req);
R result = R.ok().data(pagedResp); R result = R.ok().data(pagedResp);
...@@ -80,6 +82,7 @@ public class DeliveryController extends BaseController { ...@@ -80,6 +82,7 @@ public class DeliveryController extends BaseController {
super.logInfo("==== /delivery/getDetail param", req); super.logInfo("==== /delivery/getDetail param", req);
req.setUserId(UserUtils.getCurrentUserId()); req.setUserId(UserUtils.getCurrentUserId());
req.setUserType(UserUtils.getCurrentUserType());
SysDelivery delivery = this.deliveryService.getDetail(req); SysDelivery delivery = this.deliveryService.getDetail(req);
R result = R.ok().data(delivery); R result = R.ok().data(delivery);
...@@ -104,6 +107,7 @@ public class DeliveryController extends BaseController { ...@@ -104,6 +107,7 @@ public class DeliveryController extends BaseController {
ResultCodeEnum.USER_TYPE_NOT_HAS_AUTHORITY.getMsg()); ResultCodeEnum.USER_TYPE_NOT_HAS_AUTHORITY.getMsg());
} }
delivery.setUserId(UserUtils.getCurrentUserId()); delivery.setUserId(UserUtils.getCurrentUserId());
delivery.setUserType(userType);
R result = this.deliveryService.save(delivery); R result = this.deliveryService.save(delivery);
super.logInfo("==== /delivery/save result", result); super.logInfo("==== /delivery/save result", result);
...@@ -121,6 +125,7 @@ public class DeliveryController extends BaseController { ...@@ -121,6 +125,7 @@ public class DeliveryController extends BaseController {
super.logInfo("==== /delivery/send param", delivery); super.logInfo("==== /delivery/send param", delivery);
delivery.setUserId(UserUtils.getCurrentUserId()); delivery.setUserId(UserUtils.getCurrentUserId());
delivery.setUserType(UserUtils.getCurrentUserType());
R result = this.deliveryService.send(delivery); R result = this.deliveryService.send(delivery);
super.logInfo("==== /delivery/send result", result); super.logInfo("==== /delivery/send result", result);
...@@ -138,6 +143,7 @@ public class DeliveryController extends BaseController { ...@@ -138,6 +143,7 @@ public class DeliveryController extends BaseController {
super.logInfo("==== /delivery/receive param", delivery); super.logInfo("==== /delivery/receive param", delivery);
delivery.setUserId(UserUtils.getCurrentUserId()); delivery.setUserId(UserUtils.getCurrentUserId());
delivery.setUserType(UserUtils.getCurrentUserType());
R result = this.deliveryService.receive(delivery); R result = this.deliveryService.receive(delivery);
super.logInfo("==== /delivery/receive result", result); super.logInfo("==== /delivery/receive result", result);
...@@ -155,6 +161,7 @@ public class DeliveryController extends BaseController { ...@@ -155,6 +161,7 @@ public class DeliveryController extends BaseController {
super.logInfo("==== /delivery/cancel param", delivery); super.logInfo("==== /delivery/cancel param", delivery);
delivery.setUserId(UserUtils.getCurrentUserId()); delivery.setUserId(UserUtils.getCurrentUserId());
delivery.setUserType(UserUtils.getCurrentUserType());
R result = this.deliveryService.cancel(delivery); R result = this.deliveryService.cancel(delivery);
super.logInfo("==== /delivery/cancel result", result); super.logInfo("==== /delivery/cancel result", result);
......
...@@ -708,6 +708,14 @@ public class ReportController extends BaseReportController { ...@@ -708,6 +708,14 @@ public class ReportController extends BaseReportController {
* @return 快递单导出实体 * @return 快递单导出实体
*/ */
private DeliveryVo convertDeliveryVo(DeliveryVo deliveryVo, SysDelivery delivery) { private DeliveryVo convertDeliveryVo(DeliveryVo deliveryVo, SysDelivery delivery) {
// 寄件方角色
String senderTypeText = UserUtils.convertUserTypeName(delivery.getSenderType());
deliveryVo.setSenderTypeText(senderTypeText);
// 收件方角色
String receiverTypeText = UserUtils.convertUserTypeName(delivery.getReceiverType());
deliveryVo.setReceiverTypeText(receiverTypeText);
// 寄件人地区 // 寄件人地区
SysArea senderArea = delivery.getSenderDistrictInfo(); SysArea senderArea = delivery.getSenderDistrictInfo();
StringBuffer senderAreaTextSb = new StringBuffer(); StringBuffer senderAreaTextSb = new StringBuffer();
......
...@@ -49,7 +49,7 @@ public class DeliveryVo implements Serializable { ...@@ -49,7 +49,7 @@ public class DeliveryVo implements Serializable {
* 寄件人角色 * 寄件人角色
*/ */
@ExcelColumn(index = 5, value = "寄件人角色") @ExcelColumn(index = 5, value = "寄件人角色")
private String senderType; private String senderTypeText;
/** /**
* 寄件人详细地址 * 寄件人详细地址
...@@ -72,7 +72,7 @@ public class DeliveryVo implements Serializable { ...@@ -72,7 +72,7 @@ public class DeliveryVo implements Serializable {
* 收件人角色 * 收件人角色
*/ */
@ExcelColumn(index = 8, value = "收件人角色") @ExcelColumn(index = 8, value = "收件人角色")
private String receiverType; private String receiverTypeText;
/** /**
* 收件人详细地址 * 收件人详细地址
...@@ -139,12 +139,12 @@ public class DeliveryVo implements Serializable { ...@@ -139,12 +139,12 @@ public class DeliveryVo implements Serializable {
this.senderPhone = senderPhone; this.senderPhone = senderPhone;
} }
public String getSenderType() { public String getSenderTypeText() {
return senderType; return senderTypeText;
} }
public void setSenderType(String senderType) { public void setSenderTypeText(String senderTypeText) {
this.senderType = senderType; this.senderTypeText = senderTypeText;
} }
public String getSenderAddress() { public String getSenderAddress() {
...@@ -171,12 +171,12 @@ public class DeliveryVo implements Serializable { ...@@ -171,12 +171,12 @@ public class DeliveryVo implements Serializable {
this.receiverPhone = receiverPhone; this.receiverPhone = receiverPhone;
} }
public String getReceiverType() { public String getReceiverTypeText() {
return receiverType; return receiverTypeText;
} }
public void setReceiverType(String receiverType) { public void setReceiverTypeText(String receiverTypeText) {
this.receiverType = receiverType; this.receiverTypeText = receiverTypeText;
} }
public String getReceiverAddress() { public String getReceiverAddress() {
...@@ -219,11 +219,11 @@ public class DeliveryVo implements Serializable { ...@@ -219,11 +219,11 @@ public class DeliveryVo implements Serializable {
", orderSn='" + orderSn + '\'' + ", orderSn='" + orderSn + '\'' +
", sender='" + sender + '\'' + ", sender='" + sender + '\'' +
", senderPhone='" + senderPhone + '\'' + ", senderPhone='" + senderPhone + '\'' +
", senderType='" + senderType + '\'' + ", senderTypeText='" + senderTypeText + '\'' +
", senderAddress='" + senderAddress + '\'' + ", senderAddress='" + senderAddress + '\'' +
", receiver='" + receiver + '\'' + ", receiver='" + receiver + '\'' +
", receiverPhone='" + receiverPhone + '\'' + ", receiverPhone='" + receiverPhone + '\'' +
", receiverType='" + receiverType + '\'' + ", receiverTypeText='" + receiverTypeText + '\'' +
", receiverAddress='" + receiverAddress + '\'' + ", receiverAddress='" + receiverAddress + '\'' +
", statusText='" + statusText + '\'' + ", statusText='" + statusText + '\'' +
", createTime=" + createTime + ", createTime=" + createTime +
......
...@@ -24,6 +24,14 @@ public class CarOrderQueryReq extends PagedReq { ...@@ -24,6 +24,14 @@ public class CarOrderQueryReq extends PagedReq {
*/ */
private Byte userType; private Byte userType;
/** /**
* 服务商ID,根据用户角色生成
*/
private Integer providerId;
/**
* 商户ID,根据用户角色生成
*/
private Integer shopId;
/**
* 状态列表,用于不同角色 * 状态列表,用于不同角色
*/ */
private List<Byte> statusList; private List<Byte> statusList;
...@@ -50,6 +58,9 @@ public class CarOrderQueryReq extends PagedReq { ...@@ -50,6 +58,9 @@ public class CarOrderQueryReq extends PagedReq {
* 是否取消:0已取消,1未取消 * 是否取消:0已取消,1未取消
*/ */
private Byte canceled; private Byte canceled;
private Integer orderChannel; private Integer orderChannel;
private String serviceType; private String serviceType;
private String serviceCode; private String serviceCode;
...@@ -111,6 +122,22 @@ public class CarOrderQueryReq extends PagedReq { ...@@ -111,6 +122,22 @@ public class CarOrderQueryReq extends PagedReq {
this.userType = userType; this.userType = userType;
} }
public Integer getProviderId() {
return providerId;
}
public void setProviderId(Integer providerId) {
this.providerId = providerId;
}
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public List<Byte> getStatusList() { public List<Byte> getStatusList() {
return statusList; return statusList;
} }
...@@ -309,6 +336,8 @@ public class CarOrderQueryReq extends PagedReq { ...@@ -309,6 +336,8 @@ public class CarOrderQueryReq extends PagedReq {
"keyword='" + keyword + '\'' + "keyword='" + keyword + '\'' +
", userId=" + userId + ", userId=" + userId +
", userType=" + userType + ", userType=" + userType +
", providerId=" + providerId +
", shopId=" + shopId +
", statusList=" + statusList + ", statusList=" + statusList +
", needDetail=" + needDetail + ", needDetail=" + needDetail +
", id=" + id + ", id=" + id +
......
...@@ -24,7 +24,11 @@ public class DeliveryQueryReq extends PagedReq { ...@@ -24,7 +24,11 @@ public class DeliveryQueryReq extends PagedReq {
*/ */
private Byte userType; private Byte userType;
/** /**
* 根据权限生成的状态列表 * 根据用户权限生成的组织列表
*/
private List<Integer> userOrgList;
/**
* 根据用户权限生成的状态列表
*/ */
private List<Byte> statusList; private List<Byte> statusList;
/** /**
...@@ -148,6 +152,14 @@ public class DeliveryQueryReq extends PagedReq { ...@@ -148,6 +152,14 @@ public class DeliveryQueryReq extends PagedReq {
this.userType = userType; this.userType = userType;
} }
public List<Integer> getUserOrgList() {
return userOrgList;
}
public void setUserOrgList(List<Integer> userOrgList) {
this.userOrgList = userOrgList;
}
public List<Byte> getStatusList() { public List<Byte> getStatusList() {
return statusList; return statusList;
} }
...@@ -314,6 +326,7 @@ public class DeliveryQueryReq extends PagedReq { ...@@ -314,6 +326,7 @@ public class DeliveryQueryReq extends PagedReq {
"keyword='" + keyword + '\'' + "keyword='" + keyword + '\'' +
", userId=" + userId + ", userId=" + userId +
", userType=" + userType + ", userType=" + userType +
", userOrgList=" + userOrgList +
", statusList=" + statusList + ", statusList=" + statusList +
", needDetail=" + needDetail + ", needDetail=" + needDetail +
", id=" + id + ", id=" + id +
......
...@@ -25,7 +25,7 @@ public class SysDelivery implements Serializable { ...@@ -25,7 +25,7 @@ public class SysDelivery implements Serializable {
/** /**
* 寄件人角色 * 寄件人角色
*/ */
private String senderType; private Byte senderType;
/** /**
* 寄件人地区信息 * 寄件人地区信息
*/ */
...@@ -33,7 +33,7 @@ public class SysDelivery implements Serializable { ...@@ -33,7 +33,7 @@ public class SysDelivery implements Serializable {
/** /**
* 收件人角色 * 收件人角色
*/ */
private String receiverType; private Byte receiverType;
/** /**
* 收件人地区信息 * 收件人地区信息
*/ */
...@@ -181,11 +181,11 @@ public class SysDelivery implements Serializable { ...@@ -181,11 +181,11 @@ public class SysDelivery implements Serializable {
this.sendOrReceive = sendOrReceive; this.sendOrReceive = sendOrReceive;
} }
public String getSenderType() { public Byte getSenderType() {
return senderType; return senderType;
} }
public void setSenderType(String senderType) { public void setSenderType(Byte senderType) {
this.senderType = senderType; this.senderType = senderType;
} }
...@@ -197,11 +197,11 @@ public class SysDelivery implements Serializable { ...@@ -197,11 +197,11 @@ public class SysDelivery implements Serializable {
this.senderDistrictInfo = senderDistrictInfo; this.senderDistrictInfo = senderDistrictInfo;
} }
public String getReceiverType() { public Byte getReceiverType() {
return receiverType; return receiverType;
} }
public void setReceiverType(String receiverType) { public void setReceiverType(Byte receiverType) {
this.receiverType = receiverType; this.receiverType = receiverType;
} }
...@@ -404,9 +404,9 @@ public class SysDelivery implements Serializable { ...@@ -404,9 +404,9 @@ public class SysDelivery implements Serializable {
"userId=" + userId + "userId=" + userId +
", userType=" + userType + ", userType=" + userType +
", sendOrReceive=" + sendOrReceive + ", sendOrReceive=" + sendOrReceive +
", senderType='" + senderType + '\'' + ", senderType=" + senderType +
", senderDistrictInfo=" + senderDistrictInfo + ", senderDistrictInfo=" + senderDistrictInfo +
", receiverType='" + receiverType + '\'' + ", receiverType=" + receiverType +
", receiverDistrictInfo=" + receiverDistrictInfo + ", receiverDistrictInfo=" + receiverDistrictInfo +
", deliveryFileList=" + deliveryFileList + ", deliveryFileList=" + deliveryFileList +
", id=" + id + ", id=" + id +
......
...@@ -243,7 +243,8 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer ...@@ -243,7 +243,8 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer
if (pageIndex != null && pageSize != null) { if (pageIndex != null && pageSize != null) {
PageHelper.startPage(pageIndex, pageSize, true); PageHelper.startPage(pageIndex, pageSize, true);
} }
this.wrapStatusList(req); this.wrapReqUserType(req);
this.wrapReqStatusList(req);
List<SysOrder> orderList = this.carOrderMapper.selectList(req); List<SysOrder> orderList = this.carOrderMapper.selectList(req);
if (Boolean.TRUE.equals(req.getNeedDetail())) { if (Boolean.TRUE.equals(req.getNeedDetail())) {
for (SysOrder order : orderList) { for (SysOrder order : orderList) {
...@@ -266,6 +267,7 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer ...@@ -266,6 +267,7 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer
*/ */
@Override @Override
public SysOrder getDetail(CarOrderQueryReq req) { public SysOrder getDetail(CarOrderQueryReq req) {
this.wrapReqUserType(req);
SysOrder order = this.carOrderMapper.selectOne(req); SysOrder order = this.carOrderMapper.selectOne(req);
if (order == null) { if (order == null) {
throw BusinessException.create(ResultCodeEnum.ORDER_NOT_EXIST.getCode(), throw BusinessException.create(ResultCodeEnum.ORDER_NOT_EXIST.getCode(),
...@@ -688,6 +690,7 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer ...@@ -688,6 +690,7 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer
} }
Integer receiverDistrict = Integer.parseInt(receiverDistrictStr); Integer receiverDistrict = Integer.parseInt(receiverDistrictStr);
// 暂时设置收件方ID为超级管理员
delivery.setReceiverId(0); delivery.setReceiverId(0);
delivery.setReceiver(receiver); delivery.setReceiver(receiver);
delivery.setReceiverPhone(receiverPhone); delivery.setReceiverPhone(receiverPhone);
...@@ -736,6 +739,7 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer ...@@ -736,6 +739,7 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer
} }
Integer senderDistrict = Integer.parseInt(senderDistrictStr); Integer senderDistrict = Integer.parseInt(senderDistrictStr);
// 暂时设置寄件方ID为超级管理员
delivery.setSenderId(0); delivery.setSenderId(0);
delivery.setSender(sender); delivery.setSender(sender);
delivery.setSenderPhone(senderPhone); delivery.setSenderPhone(senderPhone);
...@@ -890,12 +894,38 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer ...@@ -890,12 +894,38 @@ public class CarOrderServiceImpl extends BaseOrderService implements CarOrderSer
} }
/** /**
* 根据用户角色生成需要查询的用户ID
*
* @param req 请求体
* @return 结果
*/
private CarOrderQueryReq wrapReqUserType(CarOrderQueryReq req) {
Integer userId = req.getUserId();
Byte userType = req.getUserType();
if (BizConstants.USER_TYPE_ADMIN == userType) {
// 运营,不指定服务商或商户ID
req.setProviderId(null);
req.setShopId(null);
} else if (BizConstants.USER_TYPE_MERCHANT == userType) {
// 服务商,指定服务商ID为当前用户ID
req.setProviderId(userId);
req.setShopId(null);
} else if (BizConstants.USER_TYPE_SHOP == userType) {
// 商户,指定商户ID为当前用户ID
req.setProviderId(null);
req.setShopId(userId);
}
return req;
}
/**
* 根据用户权限来生成需要查询的状态 * 根据用户权限来生成需要查询的状态
* *
* @param req 请求体 * @param req 请求体
* @return 结果 * @return 结果
*/ */
private CarOrderQueryReq wrapStatusList(CarOrderQueryReq req) { private CarOrderQueryReq wrapReqStatusList(CarOrderQueryReq req) {
Byte userType = req.getUserType(); Byte userType = req.getUserType();
Byte status = req.getStatus(); Byte status = req.getStatus();
List<Byte> statusList = new ArrayList<>(); List<Byte> statusList = new ArrayList<>();
......
...@@ -463,11 +463,11 @@ public class DeliveryServiceImpl extends BaseOrderService implements DeliverySer ...@@ -463,11 +463,11 @@ public class DeliveryServiceImpl extends BaseOrderService implements DeliverySer
private SysDelivery wrapUserType(SysDelivery delivery) { private SysDelivery wrapUserType(SysDelivery delivery) {
Integer senderId = delivery.getSenderId(); Integer senderId = delivery.getSenderId();
JSONObject senderInfo = UserUtils.getUserInfo(senderId); JSONObject senderInfo = UserUtils.getUserInfo(senderId);
String senderType = UserUtils.convertUserTypeName(senderInfo.getByte("userType")); Byte senderType = senderInfo.getByte("userType");
delivery.setSenderType(senderType); delivery.setSenderType(senderType);
Integer receiverId = delivery.getReceiverId(); Integer receiverId = delivery.getReceiverId();
JSONObject receiverInfo = UserUtils.getUserInfo(receiverId); JSONObject receiverInfo = UserUtils.getUserInfo(receiverId);
String receiverType = UserUtils.convertUserTypeName(receiverInfo.getByte("userType")); Byte receiverType = receiverInfo.getByte("userType");
delivery.setReceiverType(receiverType); delivery.setReceiverType(receiverType);
return delivery; return delivery;
......
...@@ -100,50 +100,72 @@ ...@@ -100,50 +100,72 @@
<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 distinct d.id, d.order_id, d.order_sn, d.logistics_id, d.express_sn, d.sender_id,
sender_district, sender_address, receiver_id, receiver, receiver_phone, d.sender, d.sender_phone, d.sender_district, d.sender_address, d.receiver_id,
receiver_district, receiver_address, `status`, canceled, remark, create_time, d.receiver, d.receiver_phone, d.receiver_district, d.receiver_address, d.`status`,
update_time, create_by, update_by d.canceled, d.remark, d.create_time, d.update_time, d.create_by, d.update_by
from sys_delivery from sys_delivery d
left join sys_user us on us.id = d.sender_id
left join sys_user ur on ur.id = d.receiver_id
<!-- 查询权限下所有组织 -->
left join sys_user_org suo on suo.user_id = #{userId,jdbcType=INTEGER}
<where> <where>
<if test="keyword != null and keyword != ''"> <if test="keyword != null and keyword != ''">
<!-- 按照关键词查询 --> <!-- 按照关键词查询 -->
and (express_sn like "%"#{keyword,jdbcType=VARCHAR}"%" and (d.express_sn like "%"#{keyword,jdbcType=VARCHAR}"%"
or sender like "%"#{keyword,jdbcType=VARCHAR}"%" or d.sender like "%"#{keyword,jdbcType=VARCHAR}"%"
or sender_phone like "%"#{keyword,jdbcType=VARCHAR}"%" or d.sender_phone like "%"#{keyword,jdbcType=VARCHAR}"%"
or receiver like "%"#{keyword,jdbcType=VARCHAR}"%" or d.receiver like "%"#{keyword,jdbcType=VARCHAR}"%"
or receiver_phone like "%"#{keyword,jdbcType=VARCHAR}"%") or d.receiver_phone like "%"#{keyword,jdbcType=VARCHAR}"%")
</if> </if>
<if test="status == 9"> <if test="status == 9">
<!-- 状态为已取消 --> <!-- 状态为已取消 -->
and canceled = 0 and d.canceled = 0
</if> </if>
<if test="status != null and status != 9"> <if test="status != null and status != 9">
<!-- 其他未取消状态 --> <!-- 其他未取消状态 -->
and status = #{status,jdbcType=TINYINT} and d.status = #{status,jdbcType=TINYINT}
and canceled = 1 and d.canceled = 1
</if> </if>
<!--and (-->
<!-- &lt;!&ndash; 用户为收件人,查询全部 &ndash;&gt;-->
<!-- d.sender_id = #{userId,jdbcType=INTEGER}-->
<!-- &lt;!&ndash; 用户为寄件人,查询状态不为待寄件的记录 &ndash;&gt;-->
<!-- or (d.receiver_id = #{userId,jdbcType=INTEGER} and d.status != 1)-->
<!--)-->
and ( and (
<!-- 用户为收件人,查询全部 --> <!-- 用户权限下有收件人组织,查询全部 -->
sender_id = #{userId,jdbcType=INTEGER} us.org_id = suo.org_id
<!-- 用户为寄件人,查询状态不为待寄件的记录 --> <!-- 用户权限下有寄件人组织,查询状态不为待寄件的记录 -->
or (receiver_id = #{userId,jdbcType=INTEGER} and status != 1) or (ur.org_id = suo.org_id and d.status != 1)
) )
</where> </where>
order by create_time desc order by d.create_time desc
</select> </select>
<select id="selectOne" parameterType="com.glsx.ordercenter.dto.req.DeliveryQueryReq" <select id="selectOne" parameterType="com.glsx.ordercenter.dto.req.DeliveryQueryReq"
resultMap="BaseResultMap"> resultMap="BaseResultMap">
select select distinct d.id, d.order_id, d.order_sn, d.logistics_id, d.express_sn, d.sender_id,
<include refid="Base_Column_List"/> d.sender, d.sender_phone, d.sender_district, d.sender_address, d.receiver_id,
from sys_delivery d.receiver, d.receiver_phone, d.receiver_district, d.receiver_address, d.`status`,
where id = #{id,jdbcType=INTEGER} d.canceled, d.remark, d.create_time, d.update_time, d.create_by, d.update_by
from sys_delivery d
left join sys_user us on us.id = d.sender_id
left join sys_user ur on ur.id = d.receiver_id
<!-- 查询权限下所有组织 -->
left join sys_user_org suo on suo.user_id = #{userId,jdbcType=INTEGER}
where d.id = #{id,jdbcType=INTEGER}
<!--and (-->
<!-- &lt;!&ndash; 用户为收件人,查询全部 &ndash;&gt;-->
<!-- d.sender_id = #{userId,jdbcType=INTEGER}-->
<!-- &lt;!&ndash; 用户为寄件人,查询状态不为待寄件的记录 &ndash;&gt;-->
<!-- or (d.receiver_id = #{userId,jdbcType=INTEGER} and d.status != 1)-->
<!--)-->
and ( and (
<!-- 用户为收件人,查询全部 --> <!-- 用户权限下有收件人组织,查询全部 -->
sender_id = #{userId,jdbcType=INTEGER} us.org_id = suo.org_id
<!-- 用户为寄件人,查询状态不为待寄件的记录 --> <!-- 用户权限下有寄件人组织,查询状态不为待寄件的记录 -->
or (receiver_id = #{userId,jdbcType=INTEGER} and status != 1) or (ur.org_id = suo.org_id and d.status != 1)
) )
</select> </select>
......
...@@ -12,6 +12,7 @@ public class AppTest { ...@@ -12,6 +12,7 @@ public class AppTest {
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true); mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
mapper.configure(SerializationConfig.Feature.USE_ANNOTATIONS, true);
System.out.println(mapper.writeValueAsString(o)); System.out.println(mapper.writeValueAsString(o));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -53,9 +53,7 @@ public class CarOrderServiceTest extends AppTest { ...@@ -53,9 +53,7 @@ public class CarOrderServiceTest extends AppTest {
public void test_getList() { public void test_getList() {
CarOrderQueryReq req = new CarOrderQueryReq(); CarOrderQueryReq req = new CarOrderQueryReq();
req.setUserId(4001); req.setUserId(4001);
req.setUserType(BizConstants.USER_TYPE_ADMIN); req.setUserType(BizConstants.USER_TYPE_SHOP);
req.setPageIndex(2);
req.setPageSize(4);
super.printJson(this.carOrderService.getList(req)); super.printJson(this.carOrderService.getList(req));
} }
......
...@@ -4,6 +4,7 @@ import java.util.Arrays; ...@@ -4,6 +4,7 @@ import java.util.Arrays;
import cn.hutool.core.lang.UUID; import cn.hutool.core.lang.UUID;
import com.glsx.ordercenter.AppTest; import com.glsx.ordercenter.AppTest;
import com.glsx.ordercenter.Application; import com.glsx.ordercenter.Application;
import com.glsx.ordercenter.constants.BizConstants;
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.ordercenter.pojo.SysDeliveryFile; import com.glsx.ordercenter.pojo.SysDeliveryFile;
...@@ -38,6 +39,7 @@ public class DeliveryServiceTest extends AppTest { ...@@ -38,6 +39,7 @@ public class DeliveryServiceTest extends AppTest {
public void test_getList() { public void test_getList() {
DeliveryQueryReq req = new DeliveryQueryReq(); DeliveryQueryReq req = new DeliveryQueryReq();
req.setUserId(4000); req.setUserId(4000);
req.setUserType(BizConstants.USER_TYPE_ADMIN);
super.printJson(deliveryService.getList(req)); super.printJson(deliveryService.getList(req));
} }
...@@ -45,7 +47,8 @@ public class DeliveryServiceTest extends AppTest { ...@@ -45,7 +47,8 @@ public class DeliveryServiceTest extends AppTest {
public void test_getDetail() { public void test_getDetail() {
DeliveryQueryReq req = new DeliveryQueryReq(); DeliveryQueryReq req = new DeliveryQueryReq();
req.setUserId(4000); req.setUserId(4000);
req.setId(6); req.setUserType(BizConstants.USER_TYPE_ADMIN);
req.setId(12);
super.printJson(deliveryService.getDetail(req)); super.printJson(deliveryService.getDetail(req));
} }
......
...@@ -35,6 +35,8 @@ public enum ResultCodeEnum { ...@@ -35,6 +35,8 @@ public enum ResultCodeEnum {
USER_BIND_WECHAT_MINI_REPEAT(2020, "该微信已被绑定,不可继续绑定"), USER_BIND_WECHAT_MINI_REPEAT(2020, "该微信已被绑定,不可继续绑定"),
SHOPNAME_REPETITION(2021, "该根组织下存在同名商户,请勿重复创建"), SHOPNAME_REPETITION(2021, "该根组织下存在同名商户,请勿重复创建"),
USER_GET_MINI_OPENID_FAIL(2022, "微信小程序获取openid失败"), USER_GET_MINI_OPENID_FAIL(2022, "微信小程序获取openid失败"),
MERCHANT_USERNAME_EXIST(2023, "该商户用户名已存在"),
MECHANIC_USERNAME_EXIST(2024, "该技工用户名已存在"),
/** /**
* 参数相关提示 * 参数相关提示
......
...@@ -1372,7 +1372,7 @@ ...@@ -1372,7 +1372,7 @@
WHERE id = #{userId,jdbcType=INTEGER} WHERE id = #{userId,jdbcType=INTEGER}
</update> </update>
<select id="getProviderByGroupAndName" resultType="com.glsx.usercenter.pojo.user.SysUser"> <sql id="selectSpGroupSql">
SELECT SELECT
u.id id, u.id id,
sm.provider_name name, sm.provider_name name,
...@@ -1383,7 +1383,31 @@ ...@@ -1383,7 +1383,31 @@
LEFT JOIN sys_user_org uo ON uo.org_id = u.org_id LEFT JOIN sys_user_org uo ON uo.org_id = u.org_id
LEFT JOIN sys_organization so ON uo.org_id = so.id LEFT JOIN sys_organization so ON uo.org_id = so.id
LEFT JOIN sys_manager sm ON sm.user_id = u.id LEFT JOIN sys_manager sm ON sm.user_id = u.id
WHERE u.user_type = 1 </sql>
<sql id="selectMerchantGroupSql">
SELECT
u.id id,
sm.shop_name name,
sm.shop_name serviceName,
u.org_id orgId
FROM
sys_user u
LEFT JOIN sys_user_org uo ON uo.org_id = u.org_id
LEFT JOIN sys_organization so ON uo.org_id = so.id
LEFT JOIN sys_merchant sm ON sm.user_id = u.id
</sql>
<select id="getProviderByGroupAndName" resultType="com.glsx.usercenter.pojo.user.SysUser">
<choose>
<when test="userType == 1">
<include refid="selectSpGroupSql"/>
</when>
<otherwise>
<include refid="selectMerchantGroupSql"/>
</otherwise>
</choose>
<where>
and u.user_status='sys_user_status_normal' and u.user_status='sys_user_status_normal'
<if test="orgId != null"> <if test="orgId != null">
and u.group_id = #{orgId,jdbcType=INTEGER} and u.group_id = #{orgId,jdbcType=INTEGER}
...@@ -1392,8 +1416,19 @@ ...@@ -1392,8 +1416,19 @@
AND uo.user_id = #{id,jdbcType=INTEGER} AND uo.user_id = #{id,jdbcType=INTEGER}
</if> </if>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
<choose>
<when test="userType == 1">
AND sm.provider_name LIKE concat('%',#{name,jdbcType=VARCHAR},'%') AND sm.provider_name LIKE concat('%',#{name,jdbcType=VARCHAR},'%')
</when>
<otherwise>
AND sm.shop_name LIKE concat('%',#{name,jdbcType=VARCHAR},'%')
</otherwise>
</choose>
</if> </if>
<if test="userType != null">
and u.user_type = #{userType,jdbcType=INTEGER}
</if>
</where>
group by id group by id
Limit 50 Limit 50
</select> </select>
......
package com.glsx.usercenter;
import java.io.IOException;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
public class AppTest {
protected void printJson(Object o) {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
mapper.configure(SerializationConfig.Feature.USE_ANNOTATIONS, true);
System.out.println(mapper.writeValueAsString(o));
} catch (IOException e) {
e.printStackTrace();
}
}
}
package com.glsx.usercenter.service;
import com.glsx.common.constants.Constants;
import com.glsx.usercenter.AppTest;
import com.glsx.usercenter.Application;
import com.glsx.usercenter.pojo.vo.UserQueryVo;
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-09-03
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {Application.class},
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class UserServiceTest extends AppTest {
@Autowired
private SysUserService userService;
@Test
public void test_getServiceOrg() {
UserQueryVo req = new UserQueryVo();
req.setId(0);
req.setOrgId(5);
req.setUserType(Constants.USER_TYPE_MERCHANT);
super.printJson(this.userService.getServiceOrg(req));
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!