Commit 5e2eca10 authored by zhangzc's avatar zhangzc

添加司机抢单接口

parent 0d8e7e6d
package com.esv.freight.app.feign;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.feign.DriverInterface
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/05 13:00
* @version:1.0
*/
@FeignClient(value = "freight-customer-service")
public interface OwnerContractInterface {
/**
* 货主合同详情
* @param bodyJson
* @return
*/
@PostMapping(value = "/customer/contract/online/getContractByNumber")
JSONObject detail(JSONObject bodyJson);
}
......@@ -30,4 +30,12 @@ public interface TmsGrabInterface {
*/
@PostMapping(value = "tms/order/grabbing/grab")
JSONObject grabOrder(JSONObject bodyJson);
/**
* 司机抢单
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/order/grabbing/grab/prepare")
JSONObject grabOrderPrepare(JSONObject bodyJson);
}
package com.esv.freight.app.module.contract.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.exception.EException;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.FeignUtils;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.feign.OwnerComplaintInterface;
import com.esv.freight.app.feign.OwnerContractInterface;
import com.esv.freight.app.module.complaint.form.OwnerComplaintForm;
import com.esv.freight.app.module.contract.form.ContractQueryForm;
import com.esv.freight.app.module.contract.pojo.OwnerContractPojo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* @description: 货主合同Controller
* @project: freight-app-service
* @name: com.esv.freight.app.module.contract.controller.OwnerContractController
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/05 13:30
* @version:1.0
*/
@RestController
@RequestMapping("/ownerBackend/contract")
@Slf4j
@Validated
public class OwnerContractController {
private OwnerContractInterface ownerContractInterface;
@Autowired
public OwnerContractController(OwnerContractInterface ownerContractInterface) {
this.ownerContractInterface = ownerContractInterface;
}
/**
* description 获取线下文本合同(货主)详情
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/06/05 13:30
**/
@PostMapping("/detail")
public EResponse detail(@RequestBody @Validated(ValidatorDetail.class) ContractQueryForm form) throws EException {
// 调用投诉列表分页查询接口
JSONObject reqJson = new JSONObject();
reqJson.put("contractNumber", form.getContractNumber());
log.info(reqJson.toJSONString());
JSONObject result = ownerContractInterface.detail(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
OwnerContractPojo driverAccountInfoPojo = JSONObject.toJavaObject(FeignUtils.getFeignDataJson(result), OwnerContractPojo.class);
return EResponse.ok(driverAccountInfoPojo);
}
}
package com.esv.freight.app.module.contract.form;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.contract.form.ContractQueryForm
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/05 13:25
* @version:1.0
*/
@Data
public class ContractQueryForm {
/**
* 合同编号
*/
@Length(max = 64, message = "参数contractNumber长度不合法", groups = {ValidatorDetail.class})
@NotBlank(message = "参数contractNumber不能为空", groups = {ValidatorDetail.class})
private String contractNumber;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.app.module.contract.pojo;
import lombok.Data;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.contract.pojo.OwnerContractPojo
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/05 14:00
* @version:1.0
*/
@Data
public class OwnerContractPojo {
/**
*
*/
private Long id;
/**
* 合同类型:1-货主与平台合同、2-司机与平台合同
*/
private Integer contractType;
/**
* 合同文件ID
*/
private String contractFileId;
/**
* 合同文件URL
*/
private String contractFileUrl;
/**
* 合同编号
*/
private String contractNumber;
/**
* 业务编号(订单号或运单号)
*/
private String businessNumber;
/**
* 客户ID
*/
private Long customerId;
/**
* 客户名称
*/
private String customerName;
/**
* 客户(货主或司机)签订时间
*/
private Long customerSignTime;
/**
* 平台签订时间
*/
private Long platformSignTime;
/**
* 合同签订完成:1-是,2-否
*/
private Integer signComplete;
/**
* 合同生效时间
*/
private Long effectiveTime;
}
package com.esv.freight.app.module.contract.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.contract.vo.OwnerContractDetailVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/05 13:25
* @version:1.0
*/
@Data
public class OwnerContractDetailVO {
/**
*
*/
private Long id;
/**
* 合同类型:1-货主与平台合同、2-司机与平台合同
*/
private Integer contractType;
/**
* 合同文件ID
*/
private String contractFileId;
/**
* 合同文件URL
*/
private String contractFileUrl;
/**
* 合同编号
*/
private String contractNumber;
/**
* 业务编号(订单号或运单号)
*/
private String businessNumber;
/**
* 客户ID
*/
private Long customerId;
/**
* 客户名称
*/
private String customerName;
/**
* 客户(货主或司机)签订时间
*/
private Long customerSignTime;
/**
* 平台签订时间
*/
private Long platformSignTime;
/**
* 合同签订完成:1-是,2-否
*/
private Integer signComplete;
/**
* 合同生效时间
*/
private Long effectiveTime;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.FeignUtils;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
......@@ -154,6 +155,7 @@ public class GrabController {
reqJson.put("orderGrabbingId", orderGrabbingForm.getOrderGrabbingId());
reqJson.put("driverId", orderGrabbingForm.getDriverId());
reqJson.put("vehicleId", orderGrabbingForm.getVehicleId());
reqJson.put("signData", orderGrabbingForm.getSignData());
log.info(reqJson.toJSONString());
JSONObject result = tmsGrabInterface.grabOrder(reqJson);
log.info(result.toJSONString());
......@@ -162,8 +164,38 @@ public class GrabController {
return EResponse.error(1009, "已经抢过该订单了");
}
if(result.getInteger("code") != 200) {
return EResponse.error(result.getInteger("code"), result.getString("message"));
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
return EResponse.ok();
}
/**
* description 判断司机是否符合抢单条件
* param orderGrabbingForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/06/05 09:20
**/
@PostMapping("/find/grab/prepare")
public EResponse prepare(@RequestBody(required=false) @Validated(ValidatorInsert.class) OrderGrabbingForm orderGrabbingForm) {
// 调用抢单接口
JSONObject reqJson = new JSONObject();
reqJson.put("orderGrabbingId", orderGrabbingForm.getOrderGrabbingId());
reqJson.put("driverId", orderGrabbingForm.getDriverId());
reqJson.put("vehicleId", orderGrabbingForm.getVehicleId());
log.info(reqJson.toJSONString());
JSONObject result = tmsGrabInterface.grabOrderPrepare(reqJson);
log.info(result.toJSONString());
if(result.getInteger("code") == 1009) {
return EResponse.error(1009, "已经抢过该订单了");
}
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
return EResponse.ok();
......
......@@ -7,6 +7,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
......@@ -47,6 +48,11 @@ public class OrderGrabbingForm {
@DecimalMin(value = "0.000000", message = "运费司机议价单价不合法", groups = {ValidatorInsert.class})
private BigDecimal freightUnitPriceOutput;
/**
* 司机签名数据
*/
private String signData;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
......
......@@ -131,6 +131,7 @@ public class OrderController {
vo.setRequiredReceiveTime(object.getLong("requiredReceiveTime"));
vo.setCreateTime(object.getLong("createTime"));
vo.setOrderSource(object.getString("orderSource"));
vo.setContractNumber(object.getString("contractNumber"));
vo.setPlaceOrderTime(object.getLong("placeOrderTime"));
records.add(vo);
}
......
......@@ -121,4 +121,9 @@ public class OrderListItemVO {
* 客户下单时间
*/
private Long placeOrderTime;
/**
* 合同编号
*/
private String contractNumber;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment