Commit 0b1cf3f7 authored by huangcb's avatar huangcb

新增接口:根据合同编号获取合同信息

parent 7aef434a
...@@ -121,6 +121,12 @@ ...@@ -121,6 +121,12 @@
<groupId>org.docx4j</groupId> <groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId> <artifactId>docx4j</artifactId>
<version>6.1.2</version> <version>6.1.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.docx4j</groupId> <groupId>org.docx4j</groupId>
......
...@@ -300,4 +300,7 @@ public class ErrorMessageComponent { ...@@ -300,4 +300,7 @@ public class ErrorMessageComponent {
@Value("${error-message.contract.online.goods-owner.sign.1001}") @Value("${error-message.contract.online.goods-owner.sign.1001}")
private String contractOnlineGoodsOwnerAdd1001; private String contractOnlineGoodsOwnerAdd1001;
@Value("${error-message.contract.online.get-by-number.1001}")
private String contractOnlineGetByNumber1001;
} }
...@@ -2,6 +2,8 @@ package com.esv.freight.customer.module.contract.controller; ...@@ -2,6 +2,8 @@ package com.esv.freight.customer.module.contract.controller;
import com.esv.freight.customer.common.exception.EException; 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.module.contract.form.ContractOnlineRecordForm;
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;
...@@ -45,4 +47,16 @@ public class ContractOnlineRecordController { ...@@ -45,4 +47,16 @@ public class ContractOnlineRecordController {
public EResponse goodsOwnerSign(@RequestBody @Validated ContractOnlineRecordSignGoodsOwnerForm form) throws EException { public EResponse goodsOwnerSign(@RequestBody @Validated ContractOnlineRecordSignGoodsOwnerForm form) throws EException {
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/22 17:20
**/
@PostMapping("/getContractByNumber")
public EResponse getContractByNumber(@RequestBody @Validated(ValidatorDetail.class) ContractOnlineRecordForm form) throws EException {
return EResponse.ok(contractOnlineRecordService.getContractInfoByNumber(form.getContractNumber()));
}
} }
...@@ -56,6 +56,10 @@ public class ContractOnlineRecordEntity implements Serializable { ...@@ -56,6 +56,10 @@ public class ContractOnlineRecordEntity implements Serializable {
* 业务编号(订单号或运单号) * 业务编号(订单号或运单号)
*/ */
private String businessNumber; private String businessNumber;
/**
* 客户ID
*/
private Long customerId;
/** /**
* 客户(货主或司机)签订时间 * 客户(货主或司机)签订时间
*/ */
......
package com.esv.freight.customer.module.contract.form;
import com.esv.freight.customer.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;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 16:52
* @version:1.0
*/
@Data
public class ContractOnlineRecordForm {
/**
*
*/
private Long id;
/**
* 合同类型:1-货主与平台合同、2-司机与平台合同
*/
private Integer contractType;
/**
* 合同文件ID
*/
private String contractFileId;
/**
* 合同文件URL
*/
private String contractFileUrl;
/**
* 合同编号
*/
@Length(max = 64, message = "参数contractNumber长度不合法", groups = {ValidatorDetail.class})
@NotBlank(message = "参数contractNumber不能为空", groups = {ValidatorDetail.class})
private String contractNumber;
/**
* 业务编号(订单号或运单号)
*/
private String businessNumber;
/**
* 客户ID
*/
private Long customerId;
/**
* 客户(货主或司机)签订时间
*/
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);
}
}
...@@ -2,8 +2,10 @@ package com.esv.freight.customer.module.contract.service; ...@@ -2,8 +2,10 @@ package com.esv.freight.customer.module.contract.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
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.ContractOnlineRecordSignGoodsOwnerForm; import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
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;
/** /**
* 线上电子合同记录表 * 线上电子合同记录表
...@@ -23,5 +25,14 @@ public interface ContractOnlineRecordService extends IService<ContractOnlineReco ...@@ -23,5 +25,14 @@ public interface ContractOnlineRecordService extends IService<ContractOnlineReco
**/ **/
ContractOnlineRecordSignGoodsOwnerVO goodsOwnerSign(ContractOnlineRecordSignGoodsOwnerForm form); ContractOnlineRecordSignGoodsOwnerVO goodsOwnerSign(ContractOnlineRecordSignGoodsOwnerForm form);
/**
* description 根据合同编号获取合同信息
* param [contractNumber]
* return com.esv.freight.customer.module.contract.vo.ContractOnlineRecordVO
* author Administrator
* createTime 2020/05/22 16:54
**/
ContractOnlineRecordVO getContractInfoByNumber(String contractNumber);
} }
package com.esv.freight.customer.module.contract.service.impl; package com.esv.freight.customer.module.contract.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate; import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.PictureRenderData; import com.deepoove.poi.data.PictureRenderData;
...@@ -21,6 +22,7 @@ import com.esv.freight.customer.module.contract.pojo.ContractOnlineGoodsOwnerPoj ...@@ -21,6 +22,7 @@ import com.esv.freight.customer.module.contract.pojo.ContractOnlineGoodsOwnerPoj
import com.esv.freight.customer.module.contract.service.ContractOnlineRecordService; import com.esv.freight.customer.module.contract.service.ContractOnlineRecordService;
import com.esv.freight.customer.module.contract.service.ContractOnlineTemplateService; import com.esv.freight.customer.module.contract.service.ContractOnlineTemplateService;
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.goodsowner.GoodsOwnerConstants; import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants;
import com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto; import com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto;
import com.esv.freight.customer.module.goodsowner.form.AccountForm; import com.esv.freight.customer.module.goodsowner.form.AccountForm;
...@@ -136,6 +138,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR ...@@ -136,6 +138,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
onlineRecordEntity.setContractFileUrl(fileUrl); onlineRecordEntity.setContractFileUrl(fileUrl);
onlineRecordEntity.setContractNumber(contractNumber); onlineRecordEntity.setContractNumber(contractNumber);
onlineRecordEntity.setBusinessNumber(form.getBusinessNumber()); onlineRecordEntity.setBusinessNumber(form.getBusinessNumber());
onlineRecordEntity.setCustomerId(form.getGoodsOwnerId());
onlineRecordEntity.setCustomerSignTime(new Date()); onlineRecordEntity.setCustomerSignTime(new Date());
onlineRecordEntity.setSignComplete(ContractConstants.CONTRACT_SIGN_COMPLETE_NO); onlineRecordEntity.setSignComplete(ContractConstants.CONTRACT_SIGN_COMPLETE_NO);
this.baseMapper.insert(onlineRecordEntity); this.baseMapper.insert(onlineRecordEntity);
...@@ -146,6 +149,40 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR ...@@ -146,6 +149,40 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
return vo; return vo;
} }
@Override
public ContractOnlineRecordVO getContractInfoByNumber(String contractNumber) {
ContractOnlineRecordEntity recordEntity = this.baseMapper.selectOne(new LambdaQueryWrapper<ContractOnlineRecordEntity>()
.eq(ContractOnlineRecordEntity::getContractNumber, contractNumber));
if (null == recordEntity) {
throw new EException(1001, errorMessageComponent.getContractOnlineGetByNumber1001());
}
ContractOnlineRecordVO vo = new ContractOnlineRecordVO();
BeanUtils.copyProperties(recordEntity, vo);
// 判断是货主还是司机签订的合同,并获取客户的名称
String customerName = null;
if (ContractConstants.CONTRACT_TYPE_GOODS_OWNER.equals(recordEntity.getContractType())) {
AccountForm accountForm = new AccountForm();
accountForm.setId(recordEntity.getCustomerId());
AccountInfoDto accountInfo = goodsOwnerAccountService.getAccountInfo(accountForm);
if (null != accountInfo) {
if (GoodsOwnerConstants.OWNER_TYPE_COMPANY.equals(accountInfo.getOwnerType())) {
customerName = accountInfo.getOwnerFullName();
} else {
customerName = accountInfo.getContactor();
}
}
} else {
}
vo.setCustomerName(customerName);
vo.setCustomerSignTime(recordEntity.getCustomerSignTime().getTime());
vo.setPlatformSignTime(null == recordEntity.getPlatformSignTime() ? null : recordEntity.getPlatformSignTime().getTime());
vo.setEffectiveTime(null == recordEntity.getEffectiveTime() ? null : recordEntity.getEffectiveTime().getTime());
return vo;
}
/** /**
* description 获取货主签订合同时的数据 * description 获取货主签订合同时的数据
* param [form, accountInfo] * param [form, accountInfo]
......
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.ContractOnlineRecordVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 16:37
* @version:1.0
*/
@Data
public class ContractOnlineRecordVO {
/**
*
*/
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);
}
}
...@@ -248,4 +248,6 @@ error-message: ...@@ -248,4 +248,6 @@ error-message:
online: online:
goods-owner: goods-owner:
sign: sign:
1001: 无效的货主ID 1001: 无效的货主ID
\ No newline at end of file get-by-number:
1001: 无效的合同编号
\ No newline at end of file
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
<result property="contractFileUrl" column="contract_file_url"/> <result property="contractFileUrl" column="contract_file_url"/>
<result property="contractNumber" column="contract_number"/> <result property="contractNumber" column="contract_number"/>
<result property="businessNumber" column="business_number"/> <result property="businessNumber" column="business_number"/>
<result property="customerId" column="customer_id"/>
<result property="customerSignTime" column="customer_sign_time"/> <result property="customerSignTime" column="customer_sign_time"/>
<result property="platformSignTime" column="platform_sign_time"/> <result property="platformSignTime" column="platform_sign_time"/>
<result property="signComplete" column="sign_complete"/> <result property="signComplete" column="sign_complete"/>
<result property="effectiveTime" column="effective_time"/> <result property="effectiveTime" column="effective_time"/>
</resultMap> </resultMap>
</mapper> </mapper>
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.contract.controller; ...@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.contract.controller;
import com.alibaba.fastjson.JSONObject; 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.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;
...@@ -128,4 +129,56 @@ public class ContractOnlineRecordControllerTest extends BaseTestController { ...@@ -128,4 +129,56 @@ 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 b1_getContractByNumber_success_test() throws Exception {
String url = "/contract/online/getContractByNumber";
// 构造数据
ContractOnlineRecordForm form = new ContractOnlineRecordForm();
form.setContractNumber("HZHT20200522000006");
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"));
}
/**
* 根据合同编号获取合同信息:无效的合同编号
**/
@Test
public void b2_getContractByNumber_wrong_contractNumber_failure_test() throws Exception {
String url = "/contract/online/getContractByNumber";
// 构造数据
ContractOnlineRecordForm form = new ContractOnlineRecordForm();
form.setContractNumber("99999");
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