Commit 9d58d337 authored by huangcb's avatar huangcb

新增接口:司机与平台的电子合同-司机签订

parent 99665a71
...@@ -299,11 +299,15 @@ public class ErrorMessageComponent { ...@@ -299,11 +299,15 @@ public class ErrorMessageComponent {
private String contractOfflineCarrierDelete1001; private String contractOfflineCarrierDelete1001;
@Value("${error-message.contract.online.goods-owner.sign.1001}") @Value("${error-message.contract.online.goods-owner.sign.1001}")
private String contractOnlineGoodsOwnerAdd1001; private String contractOnlineGoodsOwnerSign1001;
@Value("${error-message.contract.online.driver.sign.1001}")
private String contractOnlineDriverSign1001;
@Value("${error-message.contract.online.platform.sign.1001}")
private String contractOnlinePlatformSign1001;
@Value("${error-message.contract.online.get-by-number.1001}") @Value("${error-message.contract.online.get-by-number.1001}")
private String contractOnlineGetByNumber1001; private String contractOnlineGetByNumber1001;
@Value("${error-message.contract.online.goods-owner.platform-sign.1001}")
private String contractOnlineGoodsOwnerPlatformSign1001;
} }
...@@ -4,6 +4,7 @@ import com.esv.freight.customer.common.exception.EException; ...@@ -4,6 +4,7 @@ import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.EResponse; import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail; import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm; import com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm; import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
import com.esv.freight.customer.module.contract.service.ContractOnlineRecordService; import com.esv.freight.customer.module.contract.service.ContractOnlineRecordService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -48,6 +49,18 @@ public class ContractOnlineRecordController { ...@@ -48,6 +49,18 @@ public class ContractOnlineRecordController {
return EResponse.ok(contractOnlineRecordService.goodsOwnerSign(form)); return EResponse.ok(contractOnlineRecordService.goodsOwnerSign(form));
} }
/**
* description 司机与平台的电子合同-司机签订
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/26 15:19
**/
@PostMapping("/driver/sign")
public EResponse driverSign(@RequestBody @Validated ContractOnlineRecordSignDriverForm form) throws EException {
return EResponse.ok(contractOnlineRecordService.driverSign(form));
}
/** /**
* description 电子合同-平台签订 * description 电子合同-平台签订
* param [form] * param [form]
......
package com.esv.freight.customer.module.contract.form;
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-customer-service
* @name: com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 17:44
* @version:1.0
*/
@Data
public class ContractOnlineRecordSignDriverForm {
/**
* 司机ID
*/
@NotNull(message = "参数driverId不能为空")
private Long driverId;
/**
* 业务编号(订单号或运单号)
*/
@Length(max = 50, message = "参数businessNumber长度不合法")
@NotBlank(message = "参数businessNumber不能为空")
private String businessNumber;
/**
* 货物名称
*/
@Length(max = 50, message = "参数goodsName长度不合法")
@NotBlank(message = "参数goodsName不能为空")
private String goodsName;
/**
* 货物总量
*/
@Length(max = 50, message = "参数goodsTotal长度不合法")
@NotBlank(message = "参数goodsTotal不能为空")
private String goodsTotal;
/**
* 货物单位
*/
@Length(max = 50, message = "参数goodsUnit长度不合法")
@NotBlank(message = "参数goodsUnit不能为空")
private String goodsUnit;
/**
* 货物单价
*/
@Length(max = 50, message = "参数goodsUnitPrice长度不合法")
@NotBlank(message = "参数goodsUnitPrice不能为空")
private String goodsUnitPrice;
/**
* 货物总价
*/
@Length(max = 50, message = "参数goodsTotalPrice长度不合法")
@NotBlank(message = "参数goodsTotalPrice不能为空")
private String goodsTotalPrice;
/**
* 发货地址
*/
@Length(max = 200, message = "参数deliverAddress长度不合法")
@NotBlank(message = "参数deliverAddress不能为空")
private String deliverAddress;
/**
* 收货地址
*/
@Length(max = 200, message = "参数receiveAddress长度不合法")
@NotBlank(message = "参数receiveAddress不能为空")
private String receiveAddress;
/**
* 发货时间
*/
@Length(max = 50, message = "参数deliverTime长度不合法")
@NotBlank(message = "参数deliverTime不能为空")
private String deliverTime;
/**
* 交货时间
*/
@Length(max = 50, message = "参数receiveTime长度不合法")
@NotBlank(message = "参数receiveTime不能为空")
private String receiveTime;
/**
* 运费
*/
@Length(max = 50, message = "参数freightCharge长度不合法")
@NotBlank(message = "参数freightCharge不能为空")
private String freightCharge;
/**
* 货主签名数据,base64编码
*/
@NotBlank(message = "参数signData不能为空")
private String signData;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.customer.module.contract.pojo;
import lombok.Data;
/**
* @description: 货主与平台签订合同的模板内容项
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.pojo.ContractOnlineDriverPojo
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 10:05
* @version:1.0
*/
@Data
public class ContractOnlineDriverPojo {
/**
* 合同编号
*/
private String contactNumber;
/**
* 承运方
*/
private String driverName;
/**
* 承运方身份证号码
*/
private String driverId;
/**
* 承运方
*/
private String platformName;
/**
* 承运方组织机构代码
*/
private String platformId;
/**
* 货物名称
*/
private String goodsName;
/**
* 货物总量
*/
private String goodsTotal;
/**
* 货物单位
*/
private String goodsUnit;
/**
* 货物单价
*/
private String goodsUnitPrice;
/**
* 货物总价
*/
private String goodsTotalPrice;
/**
* 发货地址
*/
private String deliverAddress;
/**
* 收货地址
*/
private String receiveAddress;
/**
* 发货时间
*/
private String deliverTime;
/**
* 交货时间
*/
private String receiveTime;
/**
* 本次运输运费
*/
private String freightCharge;
/**
* 承运方签字
*/
private Object driverSignImg;
/**
* 委托方签字
*/
private Object platformFreightSealImg;
/**
* 生效时间
*/
private String effectiveTime;
}
...@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.common.exception.EException; import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity; import com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm; import com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm; import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignDriverVO;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO; import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordVO; import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordVO;
...@@ -26,6 +28,15 @@ public interface ContractOnlineRecordService extends IService<ContractOnlineReco ...@@ -26,6 +28,15 @@ public interface ContractOnlineRecordService extends IService<ContractOnlineReco
**/ **/
ContractOnlineRecordSignGoodsOwnerVO goodsOwnerSign(ContractOnlineRecordSignGoodsOwnerForm form); ContractOnlineRecordSignGoodsOwnerVO goodsOwnerSign(ContractOnlineRecordSignGoodsOwnerForm form);
/**
* description 司机与平台的电子合同-司机签订
* param [form]
* return com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignDriverVO
* author Administrator
* createTime 2020/05/26 15:03
**/
ContractOnlineRecordSignDriverVO driverSign(ContractOnlineRecordSignDriverForm form);
/** /**
* description 根据合同编号获取合同信息 * description 根据合同编号获取合同信息
* param [contractNumber] * param [contractNumber]
......
package com.esv.freight.customer.module.contract.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignDriverVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 17:54
* @version:1.0
*/
@Data
public class ContractOnlineRecordSignDriverVO {
/**
* 合同编号
*/
private String contractNumber;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
...@@ -249,7 +249,11 @@ error-message: ...@@ -249,7 +249,11 @@ error-message:
goods-owner: goods-owner:
sign: sign:
1001: 无效的货主ID 1001: 无效的货主ID
platform-sign: driver:
sign:
1001: 无效的司机ID
platform:
sign:
1001: 无效的合同编号 1001: 无效的合同编号
get-by-number: get-by-number:
1001: 无效的合同编号 1001: 无效的合同编号
\ No newline at end of file
...@@ -249,7 +249,11 @@ error-message: ...@@ -249,7 +249,11 @@ error-message:
goods-owner: goods-owner:
sign: sign:
1001: 无效的货主ID 1001: 无效的货主ID
platform-sign: driver:
sign:
1001: 无效的司机ID
platform:
sign:
1001: 无效的合同编号 1001: 无效的合同编号
get-by-number: get-by-number:
1001: 无效的合同编号 1001: 无效的合同编号
\ No newline at end of file
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<!-- mybatis sql日志 日志的级别需要是DEBUG --> <!-- mybatis sql日志 日志的级别需要是DEBUG -->
<!-- 日志打印的包的范围,及分类日志文件存储 --> <!-- 日志打印的包的范围,及分类日志文件存储 -->
<logger name="com.esv" level="INFO" additivity="false"> <logger name="com.esv" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE_APPENDER" /> <appender-ref ref="CONSOLE_APPENDER" />
<appender-ref ref="FILE_APPENDER" /> <appender-ref ref="FILE_APPENDER" />
</logger> </logger>
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.BaseTestController; import com.esv.freight.customer.BaseTestController;
import com.esv.freight.customer.common.response.ECode; import com.esv.freight.customer.common.response.ECode;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm; import com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm; import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
...@@ -139,7 +140,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController { ...@@ -139,7 +140,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
// 构造数据 // 构造数据
ContractOnlineRecordForm form = new ContractOnlineRecordForm(); ContractOnlineRecordForm form = new ContractOnlineRecordForm();
form.setContractNumber("HZHT20200526000002"); form.setContractNumber("SJHT20200526000001");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url) MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
...@@ -191,7 +192,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController { ...@@ -191,7 +192,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
// 构造数据 // 构造数据
ContractOnlineRecordForm form = new ContractOnlineRecordForm(); ContractOnlineRecordForm form = new ContractOnlineRecordForm();
form.setContractNumber("HZHT20200526000002"); form.setContractNumber("SJHT20200526000001");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url) MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
...@@ -234,4 +235,88 @@ public class ContractOnlineRecordControllerTest extends BaseTestController { ...@@ -234,4 +235,88 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
JSONObject result = JSONObject.parseObject(responseStr); JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1001, result.getIntValue("code")); Assert.assertEquals(1001, result.getIntValue("code"));
} }
/**
* 司机与平台的电子合同-司机签订
**/
@Test
public void a1_driverSign_success_test() throws Exception {
String url = "/contract/online/driver/sign";
// 构造数据
ContractOnlineRecordSignDriverForm form = new ContractOnlineRecordSignDriverForm();
form.setDriverId(1L);
form.setBusinessNumber("DD" + System.currentTimeMillis());
form.setGoodsName("煤炭");
form.setGoodsTotal("5");
form.setGoodsUnit("吨");
form.setGoodsUnitPrice("230");
form.setGoodsTotalPrice("1150");
form.setDeliverAddress("辽宁沈阳市沈河区惠工街10号卓越大厦2710");
form.setDeliverTime("2020-05-28 11:00:00");
form.setReceiveAddress("辽宁沈阳市沈河区泉园二路85号");
form.setReceiveTime("2020-05-28 18:00:00");
form.setFreightCharge("500");
String filepath = "D:\\test\\何锋.jpg";
File signFile = new File(filepath);
InputStream input = new FileInputStream(signFile);
form.setSignData(Base64.getEncoder().encodeToString(IOUtils.toByteArray(input)));
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
Assert.assertTrue(result.getJSONObject("data").containsKey("contractNumber"));
}
/**
* 司机与平台的电子合同-司机签订:无效的司机ID
**/
@Test
@Rollback
public void a2_driverSign_failure_test() throws Exception {
String url = "/contract/online/driver/sign";
// 构造数据
ContractOnlineRecordSignDriverForm form = new ContractOnlineRecordSignDriverForm();
form.setDriverId(99999L);
form.setBusinessNumber("DD" + System.currentTimeMillis());
form.setGoodsName("煤炭");
form.setGoodsTotal("5");
form.setGoodsUnit("吨");
form.setGoodsUnitPrice("230");
form.setGoodsTotalPrice("1150");
form.setDeliverAddress("辽宁沈阳市沈河区惠工街10号卓越大厦2710");
form.setDeliverTime("2020-05-28 11:00:00");
form.setReceiveAddress("辽宁沈阳市沈河区泉园二路85号");
form.setReceiveTime("2020-05-28 18:00:00");
form.setFreightCharge("500");
String filepath = "D:\\test\\何锋.jpg";
File signFile = new File(filepath);
InputStream input = new FileInputStream(signFile);
form.setSignData(Base64.getEncoder().encodeToString(IOUtils.toByteArray(input)));
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1001, result.getIntValue("code"));
}
} }
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