Commit e0663e01 by zhanghj

V1.1.0--提交标准修改订单接口相关代码--by zhanghj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@20010 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent f70b9259
...@@ -42,6 +42,8 @@ public enum ResultCodeEnum { ...@@ -42,6 +42,8 @@ public enum ResultCodeEnum {
*/ */
ORDER_CHANNEL_NOT_EXIST(4001, "该派单渠道不存在"), ORDER_CHANNEL_NOT_EXIST(4001, "该派单渠道不存在"),
USER_ORG_MERCHANT_NAME_REPEAT(4002, "渠道派单,该组织下相同商户名称存在多个"), USER_ORG_MERCHANT_NAME_REPEAT(4002, "渠道派单,该组织下相同商户名称存在多个"),
ORDER_ORDERNO_NOT_EXIST(4003, "该渠道的订单号不存在"),
ORDER_FINISH_CAN_NOT_UPDATE(4004, "订单已完成,不允许修改"),
; ;
/** /**
......
package com.glsx.ordercenter.controller.api; package com.glsx.ordercenter.controller.api;
import java.util.Date;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.groups.Default;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
...@@ -14,13 +12,12 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -14,13 +12,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.constants.OrderTypeEnum;
import com.glsx.ordercenter.constants.ResultCodeEnum; import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.controller.BaseController; import com.glsx.ordercenter.controller.BaseController;
import com.glsx.ordercenter.dto.DeviceActiveModel; import com.glsx.ordercenter.dto.DeviceActiveModel;
import com.glsx.ordercenter.dto.WorkOrderNode; import com.glsx.ordercenter.dto.WorkOrderNode;
import com.glsx.ordercenter.pojo.GroupA; import com.glsx.ordercenter.pojo.GroupA;
import com.glsx.ordercenter.pojo.GroupB;
import com.glsx.ordercenter.pojo.SysOrder; import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.service.StandardOrderService; import com.glsx.ordercenter.service.StandardOrderService;
...@@ -95,4 +92,15 @@ public class StandardOrderController extends BaseController { ...@@ -95,4 +92,15 @@ public class StandardOrderController extends BaseController {
ResultObject result = orderService.save(sysOrder); ResultObject result = orderService.save(sysOrder);
return result; return result;
} }
@RequestMapping(value = "/update", method = {RequestMethod.POST})
public ResultObject update(HttpServletRequest request, @Validated(value = {GroupB.class}) SysOrder sysOrder, BindingResult bindingResult) {
logger.info("标准接口修改单接口参数=====" + sysOrder.toString());
if (bindingResult.hasErrors()) {
Map<String, String> errorMap = getErrors(bindingResult);
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg(), errorMap);
}
ResultObject result = orderService.update(sysOrder);
return result;
}
} }
...@@ -70,4 +70,28 @@ public interface SysOrderMapper { ...@@ -70,4 +70,28 @@ public interface SysOrderMapper {
List<SysOrder> getOrderOnHand(); List<SysOrder> getOrderOnHand();
/**
*
* @author zhanghj
* @Title: getOrderList
* @Description: TODO 获取订单列表
* @param order
* @return
* List<SysOrder>
*
*/
List<SysOrder> getOrderList(SysOrder order);
/**
*
* @author zhanghj
* @Title: updateChannelOrder
* @Description: TODO 标准接口,更新渠道订单
* @param order
* @return
* int
*
*/
int updateChannelOrder(SysOrder order);
} }
\ No newline at end of file \ No newline at end of file
package com.glsx.ordercenter.pojo;
/**
*
* @Title GroupB.java
* @Package com.glsx.ordercenter.pojo
* @Description TODO Hibernate-validator的分组
* @author zhanghj
* @date 2019年4月20日 下午10:29:33
* @version 1.0.0
*/
public interface GroupB {
}
...@@ -37,17 +37,17 @@ public class SysOrder { ...@@ -37,17 +37,17 @@ public class SysOrder {
/** /**
* 详细地址 * 详细地址
*/ */
@NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class}) @NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class, GroupB.class})
private String address; private String address;
/** /**
* 商户联系人姓名 * 商户联系人姓名
*/ */
@NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class}) @NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class, GroupB.class})
private String contact; private String contact;
/** /**
* 商户联系人电话 * 商户联系人电话
*/ */
@NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class}) @NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class, GroupB.class})
private String phoneNumber; private String phoneNumber;
/** /**
...@@ -62,13 +62,13 @@ public class SysOrder { ...@@ -62,13 +62,13 @@ public class SysOrder {
/** /**
* 车辆车型 * 车辆车型
*/ */
@NotBlank(message="{param.not.null}", groups={GroupA.class}) @NotBlank(message="{param.not.null}", groups={GroupA.class, GroupB.class})
private String carType; private String carType;
/** /**
* 车架号 * 车架号
*/ */
@NotBlank(message="{param.not.null}", groups={GroupA.class}) @NotBlank(message="{param.not.null}", groups={GroupA.class, GroupB.class})
private String vinNo; private String vinNo;
/** /**
* 车辆颜色 * 车辆颜色
...@@ -78,7 +78,7 @@ public class SysOrder { ...@@ -78,7 +78,7 @@ public class SysOrder {
/** /**
* 安装日期 * 安装日期
*/ */
@NotNull(message="{param.not.null}", groups={Default.class, GroupA.class}) @NotNull(message="{param.not.null}", groups={Default.class, GroupA.class, GroupB.class})
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date expectInstallTime; private Date expectInstallTime;
/** /**
...@@ -89,7 +89,7 @@ public class SysOrder { ...@@ -89,7 +89,7 @@ public class SysOrder {
/** /**
* 车主姓名 * 车主姓名
*/ */
@NotBlank(message="{param.not.null}", groups={GroupA.class}) @NotBlank(message="{param.not.null}", groups={GroupA.class, GroupB.class})
private String carOwner; private String carOwner;
private String carOwnerPhone; private String carOwnerPhone;
...@@ -175,18 +175,18 @@ public class SysOrder { ...@@ -175,18 +175,18 @@ public class SysOrder {
/** /**
* 渠道传入的工单号 * 渠道传入的工单号
*/ */
@NotBlank(message="{param.not.null}", groups={GroupA.class}) @NotBlank(message="{param.not.null}", groups={GroupA.class, GroupB.class})
private String workOrderNo; private String workOrderNo;
/** /**
* 渠道编码 * 渠道编码
*/ */
@NotBlank(message="{param.not.null}", groups={GroupA.class}) @NotBlank(message="{param.not.null}", groups={GroupA.class, GroupB.class})
private String channel; private String channel;
/** /**
* 商户名称 * 商户名称
*/ */
@NotBlank(message="{param.not.null}", groups={GroupA.class}) @NotBlank(message="{param.not.null}", groups={GroupA.class, GroupB.class})
private String merchantName; private String merchantName;
/** /**
......
...@@ -30,4 +30,16 @@ public interface StandardOrderService { ...@@ -30,4 +30,16 @@ public interface StandardOrderService {
* *
*/ */
ResultObject save(SysOrder sysOrder); ResultObject save(SysOrder sysOrder);
/**
*
* @author zhanghj
* @Title: update
* @Description: TODO 修改订单
* @param sysOrder
* @return
* ResultObject
*
*/
ResultObject update(SysOrder sysOrder);
} }
...@@ -15,14 +15,12 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -15,14 +15,12 @@ import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ctc.wstx.util.StringUtil;
import com.glsx.common.constants.Constants; import com.glsx.common.constants.Constants;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.common.feign.client.UserClient; import com.glsx.common.feign.client.UserClient;
import com.glsx.common.utils.DateUtil; import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.HttpUtils; import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil; import com.glsx.common.utils.PropertiesUtil;
import com.glsx.common.utils.StringUtils;
import com.glsx.ordercenter.constants.OrderActiveStatusEnum; import com.glsx.ordercenter.constants.OrderActiveStatusEnum;
import com.glsx.ordercenter.constants.OrderTypeEnum; import com.glsx.ordercenter.constants.OrderTypeEnum;
import com.glsx.ordercenter.constants.ResultCodeEnum; import com.glsx.ordercenter.constants.ResultCodeEnum;
...@@ -39,7 +37,6 @@ import com.glsx.ordercenter.service.IOrderChannelService; ...@@ -39,7 +37,6 @@ import com.glsx.ordercenter.service.IOrderChannelService;
import com.glsx.ordercenter.service.IOrderService; import com.glsx.ordercenter.service.IOrderService;
import com.glsx.ordercenter.service.IResourceMatchingService; import com.glsx.ordercenter.service.IResourceMatchingService;
import com.glsx.ordercenter.service.StandardOrderService; import com.glsx.ordercenter.service.StandardOrderService;
import com.google.gson.JsonArray;
/** /**
* @author duanht * @author duanht
...@@ -337,4 +334,189 @@ public class StandardOrderServiceImpl implements StandardOrderService { ...@@ -337,4 +334,189 @@ public class StandardOrderServiceImpl implements StandardOrderService {
} }
@Override
public ResultObject update(SysOrder sysOrder) {
ResultObject result = null;
Integer groupId = null;
String serviceType = null;
Integer merchantId = null;
int orderType = OrderTypeEnum.INSTALL.getOrderType();
sysOrder.setOrderType((byte) orderType);
Date now = new Date();
// TODO Auto-generated method stub
String merchantName = sysOrder.getMerchantName();
String channel = sysOrder.getChannel();
String address = sysOrder.getAddress();
Integer district = sysOrder.getDistrict();
/*
* 检查该渠道订单号是否存在,并且校验订单是否有完成的,有则不允许修改订单
*/
SysOrder or = new SysOrder();
or.setWorkOrderNo(sysOrder.getWorkOrderNo());
List<SysOrder> orderList = orderDao.getOrderList(or);
if (orderList == null || orderList.size() == 0) {
result = new ResultObject(ResultCodeEnum.ORDER_ORDERNO_NOT_EXIST.getCode(),
ResultCodeEnum.ORDER_ORDERNO_NOT_EXIST.getMsg());
return result;
} else {
for (SysOrder sOrder : orderList) {
int activeStatus = sOrder.getActiveStatus();
if (OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_FINISH.getActiveStatus() == activeStatus) {
result = new ResultObject(ResultCodeEnum.ORDER_FINISH_CAN_NOT_UPDATE.getCode(),
ResultCodeEnum.ORDER_FINISH_CAN_NOT_UPDATE.getMsg());
return result;
}
}
}
/*
* 调用高德地图接口,解析拿到所在地方的区行政编码
*/
if (org.springframework.util.StringUtils.isEmpty(district)) {
try {
} catch (Exception e) {
}
}
/*
* 获取对应渠道的根组织id
*/
SysChannelOrg channelOrg = new SysChannelOrg();
channelOrg.setChannel(channel);
SysChannelOrg sysChannelOrg = orderChannelService.getChannelOrg(channelOrg);
if (sysChannelOrg != null) {
groupId = sysChannelOrg.getOrgid();
} else {
return new ResultObject(ResultCodeEnum.ORDER_CHANNEL_NOT_EXIST.getCode(),
ResultCodeEnum.ORDER_CHANNEL_NOT_EXIST.getMsg());
}
/*
* 校验对应的商户
*/
JSONObject obj = userClient.getMerchantList(groupId, merchantName);
if (obj != null && obj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
JSONArray array = obj.getJSONArray("data");
int size = array.size();
if (size == 1) {
String userStatus = array.getJSONObject(0).getString("userStatus");
if (!Constants.SYS_USER_STATUS_NORMAL.equals(userStatus)) {
result = new ResultObject(ResultCodeEnum.USER_IS_DISABLE_OR_LOGOUT.getCode(),
ResultCodeEnum.USER_IS_DISABLE_OR_LOGOUT.getMsg());
return result;
}
JSONObject data = array.getJSONObject(0);
serviceType = data.getString("serviceType");
merchantId = data.getInteger("id");
} else if (size > 1) {
result = new ResultObject(ResultCodeEnum.USER_ORG_MERCHANT_NAME_REPEAT.getCode(),
ResultCodeEnum.USER_ORG_MERCHANT_NAME_REPEAT.getMsg());
return result;
}
}
sysOrder.setServiceType(serviceType);
/*
* 修改渠道订单,判断商户的为空和不为空两种情况
* 1.商户id为null,2.商户id不为null
* 1:商户id为null,技工服务商恢复null,订单状态初始状态
* 2:判断技工,和服务商有木有变动,若没有变动,订单状态保持原样,若变动,则恢复订单状态为开始状态
*/
Byte activeStatus = null;
//技工id
Integer mechanicId = null;
//服务商id
Integer serviceId = null;
if (merchantId == null) {
activeStatus = (byte) OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MERCHANT_HAS_SENT.getActiveStatus();
SysOrder order = new SysOrder();
order.setActiveStatus(activeStatus);
order.setOrderType((byte) orderType);
//商户用户id
order.setShopId(merchantId);
order.setDistrict(district);
order.setAddress(address);
order.setContact(sysOrder.getContact());
order.setPhoneNumber(sysOrder.getPhoneNumber());
order.setCarType(sysOrder.getCarType());
order.setVinNo(sysOrder.getVinNo());
order.setCarColor(sysOrder.getCarColor());
order.setExpectInstallTime(sysOrder.getExpectInstallTime());
order.setServiceType(serviceType);
order.setCarOwner(sysOrder.getCarOwner());
order.setCarOwnerPhone(sysOrder.getCarOwnerPhone());
//这是服务商id
order.setMerchantId(serviceId);
order.setMechanicId(mechanicId);
order.setRemark(sysOrder.getRemark());
order.setUpdateTime(now);
order.setUpdateBy(merchantId);
order.setWorkOrderNo(sysOrder.getWorkOrderNo());
order.setMerchantName(merchantName);
orderDao.updateChannelOrder(order);
} else {
for (SysOrder sOrder : orderList) {
String installDeviceType = sOrder.getInstallDeviceType();
Integer id = sOrder.getId();
//服务商id
Integer oldServiceId = sOrder.getMerchantId();
Integer oldMechanicId = sOrder.getMechanicId();
activeStatus = sOrder.getActiveStatus();
List<SysResourceMatching> resourMatchings = resourceMatchingService.getResourceMatchingList(merchantId,
installDeviceType);
/*
* 获取订单的服务商和技工
*/
for (SysResourceMatching resourMatching : resourMatchings) {
String serviceKey = resourMatching.getServiceKey();
Integer userType = resourMatching.getUserType();
if (userType != null && com.glsx.common.constants.Constants.USER_TYPE_SP == userType
&& installDeviceType.equals(serviceKey)) {
serviceId = resourMatching.getUserId();
if (!serviceId.equals(oldServiceId)) {
activeStatus = (byte) OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_NOT_ASSIGN_MECHANIC.getActiveStatus();
}
} else if (userType != null && userType != com.glsx.common.constants.Constants.USER_TYPE_SP
&& installDeviceType.equals(serviceKey)) {
mechanicId = resourMatching.getUserId();
if (!mechanicId.equals(oldMechanicId)) {
activeStatus = (byte) OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_NOT_ACCEPT.getActiveStatus();
}
}
}
SysOrder order = new SysOrder();
order.setId(id);
order.setActiveStatus(activeStatus);
order.setOrderType((byte) orderType);
//商户用户id
order.setShopId(merchantId);
order.setDistrict(district);
order.setAddress(address);
order.setContact(sysOrder.getContact());
order.setPhoneNumber(sysOrder.getPhoneNumber());
order.setCarType(sysOrder.getCarType());
order.setVinNo(sysOrder.getVinNo());
order.setCarColor(sysOrder.getCarColor());
order.setExpectInstallTime(sysOrder.getExpectInstallTime());
order.setServiceType(serviceType);
order.setCarOwner(sysOrder.getCarOwner());
order.setCarOwnerPhone(sysOrder.getCarOwnerPhone());
//这是服务商id
order.setMerchantId(serviceId);
order.setMechanicId(mechanicId);
order.setRemark(sysOrder.getRemark());
order.setUpdateTime(now);
order.setUpdateBy(merchantId);
order.setMerchantName(merchantName);
orderDao.updateChannelOrder(order);
}
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
} }
...@@ -793,5 +793,46 @@ ...@@ -793,5 +793,46 @@
AND so.active_status IN (2,4) AND TIMESTAMPDIFF(MINUTE,so.update_time,NOW())>=30 AND so.active_status IN (2,4) AND TIMESTAMPDIFF(MINUTE,so.update_time,NOW())>=30
</select> </select>
<select id="getOrderList" parameterType="com.glsx.ordercenter.pojo.SysOrder" resultMap="BaseResultMap">
select so.*
from sys_order so
<where>
<if test="workOrderNo != null or workOrderNo != ''">
and so.work_order_no = #{workOrderNo}
</if>
</where>
</select>
<update id="updateChannelOrder" parameterType="com.glsx.ordercenter.pojo.SysOrder">
update sys_order
set
active_status = #{activeStatus,jdbcType=TINYINT},
shop_id = #{shopId,jdbcType=INTEGER},
district = #{district,jdbcType=INTEGER},
address = #{address,jdbcType=VARCHAR},
contact = #{contact,jdbcType=VARCHAR},
phone_number = #{phoneNumber,jdbcType=VARCHAR},
car_type = #{carType,jdbcType=VARCHAR},
vin_no = #{vinNo,jdbcType=VARCHAR},
car_color = #{carColor,jdbcType=VARCHAR},
expect_install_time = #{expectInstallTime,jdbcType=TIMESTAMP},
<if test="serviceType != null and serviceType != ''">
service_type = #{serviceType,jdbcType=VARCHAR},
</if>
car_owner = #{carOwner,jdbcType=VARCHAR},
car_owner_phone = #{carOwnerPhone,jdbcType=VARCHAR},
merchant_id = #{merchantId,jdbcType=INTEGER},
mechanic_id = #{mechanicId,jdbcType=INTEGER},
remark = #{remark,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=INTEGER},
merchant_name = #{merchantName,jdbcType=VARCHAR}
<where>
<if test="id != null">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="workOrderNo != null and workOrderNo != ''">
and work_order_no = #{workOrderNo}
</if>
</where>
</update>
</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!