|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
package cn.iocoder.yudao.module.accounting.service.voucherdetails;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.VoucherExportReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO;
|
|
|
|
|
import cn.iocoder.yudao.module.accounting.dal.mysql.voucher.VoucherMapper;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
@ -31,10 +34,24 @@ public class VoucherDetailsServiceImpl implements VoucherDetailsService {
|
|
|
|
|
@Resource
|
|
|
|
|
private VoucherDetailsMapper voucherDetailsMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private VoucherMapper voucherMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Long createVoucherDetails(VoucherDetailsCreateReqVO createReqVO) {
|
|
|
|
|
// 插入
|
|
|
|
|
VoucherDetailsDO voucherDetails = VoucherDetailsConvert.INSTANCE.convert(createReqVO);
|
|
|
|
|
//寻找凭证id通过voucherNum
|
|
|
|
|
if (createReqVO.getVoucherNum() != null) {
|
|
|
|
|
String voucherNum = createReqVO.getVoucherNum();
|
|
|
|
|
VoucherExportReqVO voucherExportReqVO = new VoucherExportReqVO();
|
|
|
|
|
voucherExportReqVO.setVoucherNum(voucherNum);
|
|
|
|
|
List<VoucherDO> voucherDOS = voucherMapper.selectList(voucherExportReqVO);
|
|
|
|
|
if (voucherDOS.size()>0){
|
|
|
|
|
voucherDetails.setVoucherId(voucherDOS.get(0).getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
voucherDetailsMapper.insert(voucherDetails);
|
|
|
|
|
// 返回
|
|
|
|
|
return voucherDetails.getId();
|
|
|
|
@ -46,6 +63,16 @@ public class VoucherDetailsServiceImpl implements VoucherDetailsService {
|
|
|
|
|
validateVoucherDetailsExists(updateReqVO.getId());
|
|
|
|
|
// 更新
|
|
|
|
|
VoucherDetailsDO updateObj = VoucherDetailsConvert.INSTANCE.convert(updateReqVO);
|
|
|
|
|
//寻找凭证id通过voucherNum
|
|
|
|
|
if (updateReqVO.getVoucherNum() != null) {
|
|
|
|
|
String voucherNum = updateReqVO.getVoucherNum();
|
|
|
|
|
VoucherExportReqVO voucherExportReqVO = new VoucherExportReqVO();
|
|
|
|
|
voucherExportReqVO.setVoucherNum(voucherNum);
|
|
|
|
|
List<VoucherDO> voucherDOS = voucherMapper.selectList(voucherExportReqVO);
|
|
|
|
|
if (voucherDOS.size()>0){
|
|
|
|
|
updateReqVO.setVoucherId(voucherDOS.get(0).getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
voucherDetailsMapper.updateById(updateObj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|