Commit 954001d7 by HlQ

[add] 发票管理添加流水号字段

[chg]
1.用户列表按照状态排序
2.发货记录列表添加合同相关字段,原项目字段废弃
1 parent b1e4ef50
......@@ -28,7 +28,7 @@ public class ContractDTO extends BaseDTO {
private Integer type;
/**
* 合同进度:1-签订 2-发货 3-货到 4-安装 5-验收 6-质保
* 合同进度:1-签订 2-到货 3-系统验收(初验) 4-项目验收(终验) 5-质保 6-第一笔维保款 7-第二笔维保款 8-第三笔维保款
*/
private Integer status;
......
......@@ -18,10 +18,16 @@ public class DeliveryRecordDTO extends BaseDTO {
*/
private String contractNo;
/**
* 合同id
*/
private Long contractId;
/**
* 项目id
* 合同名称
*/
private Long storeId;
private String contractName;
/**
* 客户名称
......
......@@ -15,6 +15,8 @@ public class FileInfoDTO extends BaseDTO {
private Integer sourceType;
/** 文件来源id */
private Long sourceId;
/** 合同id */
private Long contractId;
/** 文件名称 */
private String name;
/** 文件地址 */
......
......@@ -39,4 +39,9 @@ public class InvoiceDTO extends BaseDTO {
*/
private String remark;
/**
* 流水号
*/
private String serialNo;
}
\ No newline at end of file
......@@ -61,7 +61,7 @@ public class Contract {
private Date maintainEdate;
/**
* 合同进度:1-签订 2-发货 3-货到 4-安装 5-验收 6-质保
* 合同进度:1-签订 2-到货 3-系统验收(初验) 4-项目验收(终验) 5-质保 6-第一笔维保款 7-第二笔维保款 8-第三笔维保款
*/
@TableField(value = "\"status\"")
private Integer status;
......
......@@ -17,10 +17,10 @@ public class ContractLog {
private Long id;
/**
* 合同id
* 合同编号
*/
@TableField(value = "contract_id")
private Long contractId;
@TableField(value = "contract_no")
private String contractNo;
/**
* 操作人
......@@ -40,6 +40,13 @@ public class ContractLog {
@TableField(value = "remark")
private String remark;
/**
* 确认日期
*/
@TableField(value = "rec_time")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date recTime;
@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
......
......@@ -29,10 +29,10 @@ public class DeliveryRecord {
private String contractNo;
/**
* 项目id
* 合同id
*/
@TableField(value = "store_id")
private Long storeId;
@TableField(value = "contract_id")
private Long contractId;
/**
* 客户名称
......
......@@ -20,7 +20,7 @@ import java.util.Date;
public class FileInfo {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/** 门店id */
/** 项目id */
private Long storeId;
/** 文件扩展名 */
private String type;
......@@ -28,6 +28,8 @@ public class FileInfo {
private Integer sourceType;
/** 文件来源id */
private Long sourceId;
/** 合同id */
private Long contractId;
/** 文件名称 */
private String name;
/** 文件地址 */
......
......@@ -54,6 +54,12 @@ public class Invoice {
@TableField(value = "remark")
private String remark;
/**
* 流水号
*/
@TableField(value = "serial_no")
private String serialNo;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
......
......@@ -10,5 +10,5 @@ import vion.model.ContractPayment;
*/
public interface IContractPaymentService extends MPJBaseService<ContractPayment> {
void calMoney(Contract exitContract, Contract dto);
void calMoney(Contract existContract, Contract dto);
}
......@@ -25,24 +25,24 @@ public class ContractPaymentServiceImpl extends MPJBaseServiceImpl<ContractPayme
/**
* 当合同状态变化或者应收款变化时,重新计算款项
*
* @param exitContract
* @param existContract
* @param dto
*/
@Override
public void calMoney(Contract exitContract, Contract dto) {
List<ContractPayment> contractPaymentList = this.lambdaQuery().eq(ContractPayment::getContractId, exitContract.getId()).list();
public void calMoney(Contract existContract, Contract dto) {
List<ContractPayment> contractPaymentList = this.lambdaQuery().eq(ContractPayment::getContractId, existContract.getId()).list();
Map<Integer, BigDecimal> type2RatioMap = contractPaymentList.stream().collect(Collectors.toMap(ContractPayment::getPaymentType, ContractPayment::getPaymentRatio));
Integer status = dto.getStatus() == null ? exitContract.getStatus() : dto.getStatus();
Integer status = dto.getStatus() == null ? existContract.getStatus() : dto.getStatus();
BigDecimal sumRatio = new BigDecimal(0);
for (int i = 1; i <= status; i++) {
BigDecimal ratio = type2RatioMap.get(i);
sumRatio = NumberUtil.add(ratio, sumRatio);
}
BigDecimal totalAmount = exitContract.getTotalAmount();
BigDecimal totalAmount = existContract.getTotalAmount();
BigDecimal curAmount = NumberUtil.mul(totalAmount, sumRatio);
BigDecimal paidAmount = dto.getPaidAmount() == null ? exitContract.getPaidAmount() : dto.getPaidAmount();
BigDecimal paidAmount = dto.getPaidAmount() == null ? existContract.getPaidAmount() : dto.getPaidAmount();
BigDecimal recAmount = NumberUtil.sub(curAmount, paidAmount);
BigDecimal outsideAmount = NumberUtil.sub(totalAmount, NumberUtil.add(paidAmount, recAmount));
BigDecimal outsideAmount = NumberUtil.sub(totalAmount, paidAmount);
dto.setReceivableAmount(recAmount);
dto.setOutstandingAmount(outsideAmount);
}
......
......@@ -115,7 +115,7 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
MPJLambdaWrapper<Contract> wrapper = new MPJLambdaWrapper<Contract>()
.selectAll(Contract.class)
.selectCollection(ContractLog.class, ContractVO::getContractLogs)
.leftJoin(ContractLog.class, ContractLog::getContractId, Contract::getId)
.leftJoin(ContractLog.class, ContractLog::getContractNo, Contract::getContractNo)
.eq(Contract::getId, id);
return this.selectJoinOne(ContractVO.class, wrapper);
}
......@@ -140,22 +140,22 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
@Override
@Transactional(rollbackFor = Exception.class)
public String updateById(Long id, String contractNo, ContractDTO dto) {
Contract exitContract = null;
Contract existContract = null;
if (ObjUtil.isNotNull(id)) {
exitContract = this.getById(id);
existContract = this.getById(id);
} else if (StrUtil.isNotBlank(contractNo)) {
exitContract = this.lambdaQuery().eq(Contract::getContractNo, contractNo).one();
existContract = this.lambdaQuery().eq(Contract::getContractNo, contractNo).one();
}
Assert.notNull(exitContract, "合同不存在");
Assert.notNull(existContract, "合同不存在");
Contract contract = converter.convert(dto, new Contract());
contract.setId(exitContract.getId());
contractPaymentService.calMoney(exitContract, contract);
contract.setId(existContract.getId());
contractPaymentService.calMoney(existContract, contract);
if (this.updateById(contract)) {
UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
ContractLog contractLog = new ContractLog();
contractLog.setContractId(contract.getId());
contractLog.setContractNo(existContract.getContractNo());
if (dto.getStatus() == 1) {
contractLog.setContent("合同:已签订");
} else if (dto.getStatus() == 2) {
......@@ -167,7 +167,11 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
} else if (dto.getStatus() == 5) {
contractLog.setContent("合同:质保");
} else if (dto.getStatus() == 6) {
contractLog.setContent("合同:维保");
contractLog.setContent("合同:第一笔维保款");
} else if (dto.getStatus() == 7) {
contractLog.setContent("合同:第二笔维保款");
} else if (dto.getStatus() == 8) {
contractLog.setContent("合同:第三笔维保款");
}
contractLog.setOperator(userVO.getId());
contractLogService.save(contractLog);
......
......@@ -4,7 +4,7 @@ import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
......@@ -16,9 +16,9 @@ import org.springframework.stereotype.Service;
import vion.dto.ContractDTO;
import vion.dto.DeliveryRecordDTO;
import vion.mapper.DeliveryRecordMapper;
import vion.model.Contract;
import vion.model.DeliveryRecord;
import vion.model.FileInfo;
import vion.model.Store;
import vion.service.IContractService;
import vion.service.IDeliveryRecordService;
import vion.service.IFileService;
......@@ -49,8 +49,10 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
public Page<DeliveryRecordVO> list(DeliveryRecordDTO dto) {
MPJLambdaWrapper<DeliveryRecord> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, new DeliveryRecord()))
.selectAll(DeliveryRecord.class)
.selectAs(Store::getName, DeliveryRecordVO::getStoreName)
.leftJoin(Store.class, Store::getId, DeliveryRecord::getStoreId);
.selectAs(Contract::getName, DeliveryRecordVO::getContractName)
.leftJoin(Contract.class, Contract::getContractNo, DeliveryRecord::getContractNo)
.like(StrUtil.isNotBlank(dto.getContractName()), Contract::getName, dto.getContractName())
.orderByDesc(DeliveryRecord::getShipDate);
return this.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), DeliveryRecordVO.class, wrapper);
}
......@@ -71,8 +73,7 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
String fileName = orgName.substring(0, orgName.lastIndexOf("."));
String fileExt = orgName.substring(orgName.lastIndexOf("."));
String filename = fileName + "_" + DateUtil.format(new Date(), "yyyyMMdd_HHmmss") + fileExt;
Long storeId = ObjUtil.isNull(dto.getStoreId()) ? 0L : dto.getStoreId();
String path = fileUrl + FileUtil.FILE_SEPARATOR + "/delivery" + FileUtil.FILE_SEPARATOR + storeId + FileUtil.FILE_SEPARATOR + record.getId() + FileUtil.FILE_SEPARATOR + filename;
String path = fileUrl + FileUtil.FILE_SEPARATOR + "/delivery" + FileUtil.FILE_SEPARATOR + dto.getContractId() + FileUtil.FILE_SEPARATOR + record.getId() + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
try {
infile.transferTo(file);
......@@ -81,8 +82,9 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
}
FileInfo fileInfo = new FileInfo();
fileInfo.setStoreId(storeId);
fileInfo.setStoreId(0L);
fileInfo.setSourceId(record.getId());
fileInfo.setContractId(dto.getContractId());
fileInfo.setSourceType(6);
fileInfo.setName(filename);
fileInfo.setUrl(path);
......@@ -102,6 +104,7 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
public String updateById(DeliveryRecordDTO dto) {
DeliveryRecord record = converter.convert(dto, new DeliveryRecord());
if (this.updateById(record)) {
DeliveryRecord deliveryRecord = this.getById(dto.getId());
Opt.ofNullable(dto.getFiles())
.ifPresent(fileList -> {
UserVO userVO = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
......@@ -111,7 +114,7 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
String fileName = orgName.substring(0, orgName.lastIndexOf("."));
String fileExt = orgName.substring(orgName.lastIndexOf("."));
String filename = fileName + "_" + DateUtil.format(new Date(), "yyyyMMdd_HHmmss") + fileExt;
String path = fileUrl + FileUtil.FILE_SEPARATOR + "/delivery" + FileUtil.FILE_SEPARATOR + dto.getStoreId() + FileUtil.FILE_SEPARATOR + record.getId() + FileUtil.FILE_SEPARATOR + filename;
String path = fileUrl + FileUtil.FILE_SEPARATOR + "/delivery" + FileUtil.FILE_SEPARATOR + deliveryRecord.getContractId() + FileUtil.FILE_SEPARATOR + record.getId() + FileUtil.FILE_SEPARATOR + filename;
File file = FileUtil.touch(path);
try {
infile.transferTo(file);
......@@ -120,8 +123,9 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
}
FileInfo fileInfo = new FileInfo();
fileInfo.setStoreId(dto.getStoreId());
fileInfo.setStoreId(0L);
fileInfo.setSourceId(record.getId());
fileInfo.setContractId(deliveryRecord.getContractId());
fileInfo.setSourceType(6);
fileInfo.setName(filename);
fileInfo.setUrl(path);
......
......@@ -56,12 +56,12 @@ public class PaymentServiceImpl extends MPJBaseServiceImpl<PaymentMapper, Paymen
no2PaymentMap.forEach((no, list) -> {
BigDecimal sumAmount = list.stream().map(Payment::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
Contract exitContract = contractService.lambdaQuery().eq(Contract::getContractNo, no).one();
Contract existContract = contractService.lambdaQuery().eq(Contract::getContractNo, no).one();
// 最新的应收款去计算
Contract updDto = new Contract();
updDto.setId(exitContract.getId());
updDto.setId(existContract.getId());
updDto.setPaidAmount(sumAmount);
contractPaymentService.calMoney(exitContract, updDto);
contractPaymentService.calMoney(existContract, updDto);
contractService.updateById(updDto);
});
return "成功";
......
......@@ -42,7 +42,8 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
MPJLambdaWrapper<User> wrapper = new MPJLambdaWrapper<>(converter.convert(dto, new User()))
.selectAll(User.class)
.select(Dept::getDeptName)
.leftJoin(Dept.class, Dept::getDeptId, User::getDeptId);
.leftJoin(Dept.class, Dept::getDeptId, User::getDeptId)
.orderByAsc(User::getStatus);
Page<UserVO> userVOS = this.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), UserVO.class, wrapper);
MPJLambdaWrapper<Role> roleWrapper = new MPJLambdaWrapper<Role>()
.selectAll(Role.class)
......
......@@ -17,12 +17,13 @@ public class DeliveryRecordVO {
* 合同编号
*/
private String contractNo;
private String contractName;
/**
* 项目id
* 合同id
*/
private Long storeId;
private String storeName;
private Long contractId;
/**
* 客户名称
......
......@@ -39,6 +39,11 @@ public class InvoiceVO {
*/
private String remark;
/**
* 流水号
*/
private String serialNo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!