Commit be3599ce by huluobin

update

parent 010151a1
package com.blt.other.module.cost.controller; package com.blt.other.module.cost.controller;
import com.blt.other.common.util.AxiosUtil;
import com.blt.other.common.util.PathUtil;
import com.blt.other.module.cost.dao.CostDao;
import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.service.CostService;
import com.blt.other.module.cost.service.UserCostFinansysService;
import com.blt.other.module.cost.utils.CostFileUtil;
import com.blt.other.module.cost.utils.CostUtils;
import com.blt.other.module.database.model.UserCostFinansysDomain;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
@Deprecated @Deprecated
@RestController @RestController
...@@ -30,129 +12,4 @@ public class CostListAddController { ...@@ -30,129 +12,4 @@ public class CostListAddController {
private static Logger logger = LoggerFactory.getLogger(CostListAddController.class); private static Logger logger = LoggerFactory.getLogger(CostListAddController.class);
@Autowired
private CostService costService;
@Autowired
CostDao costDao;
@Autowired
private UserCostFinansysService userCostFinansysService;
/**
* 保存费用单(带附件)
*
* @param response
* @param request
* @param file
* @return
*/
@Deprecated
@PostMapping("affirmFile")
public Map<String, Object> affirmFile(HttpServletResponse response,
HttpServletRequest request,
@RequestParam("fileSelect") MultipartFile file) {
AxiosUtil.setCors(response, request);
Map<String, Object> result = new HashMap<>();
String costNo = CostUtils.getIdNum();
CostDomain costDomainByNo = costDao.selectByCostNo(costNo);
while (null != costDomainByNo && null != costDomainByNo.getId()) {
costNo = CostUtils.getIdNum();
}
CostDomain costDomain = CostUtils.createCostDomain(request, costNo);
// 文件上传的路径
String filePath = PathUtil.getBasePath() + PathUtil.getPath("cost/" + costDomain.getCostNo() + "/");
// 调用工具类执行保存,并返回 path
String path = CostFileUtil.upload(file, filePath);
costDomain.setFilePath(path);
// 保存表单中的银行卡信息
if (hasRecord(costDomain)) {
Integer finansyRecord = doSaveFinansyRecord(costDomain);
}
Integer integer = costService.saveNewCost(costDomain);
if (null != integer && integer >= 1) {
result.put("msg", "费用单已创建");
result.put("costNo", costDomain.getCostNo());
result.put("costDomain", costDomain);
return result;
}
result.put("msg", "费用单创建失败");
result.put("costNo", null);
return result;
}
/**
* 保存费用单(不带附件)
*
* @param response
* @param request
* @return
*/
@PostMapping("affirmNoFile")
public Map<String, Object> affirmNoFile(HttpServletResponse response, HttpServletRequest request) {
AxiosUtil.setCors(response, request);
Map<String, Object> result = new HashMap<>();
String costNo = CostUtils.getIdNum();
CostDomain costDomainByNo = costDao.selectByCostNo(costNo);
while (null != costDomainByNo && null != costDomainByNo.getId()) {
costNo = CostUtils.getIdNum();
}
CostDomain costDomain = CostUtils.createCostDomain(request, costNo);
// 保存表单中的银行卡信息
if (hasRecord(costDomain)) {
Integer finansyRecord = doSaveFinansyRecord(costDomain);
}
Integer integer = costService.saveNewCost(costDomain);
if (null != integer && integer >= 1) {
result.put("msg", "费用单已创建");
result.put("costNo", costDomain.getCostNo());
return result;
}
result.put("msg", "费用单已创建");
result.put("costNo", costDomain.getCostNo());
result.put("costDomain", costDomain);
return result;
}
/**
* 保存填写的财务信息
*
* @return
*/
private Integer doSaveFinansyRecord(CostDomain costDomain) {
UserCostFinansysDomain finansyRecordByCostDomain = userCostFinansysService.createFinansyRecordByCostDomain(costDomain);
Integer integer = userCostFinansysService.saveFinansysRecord(finansyRecordByCostDomain);
return integer;
}
/**
* 判断是否需要记录财务信息
*
* @param costDomain
* @return
*/
private boolean hasRecord(CostDomain costDomain) {
UserCostFinansysDomain finansyRecordByCostDomain = userCostFinansysService.createFinansyRecordByCostDomain(costDomain);
UserCostFinansysDomain byUserCostFinansysDetail = userCostFinansysService.getByUserCostFinansysDetail(finansyRecordByCostDomain);
if (null != byUserCostFinansysDetail && null != byUserCostFinansysDetail.getId()) {
return false;
} else {
// 判断是否是付款费用或借支单
if (1 == costDomain.getCostForm()) {
return true;
} else if (2 == costDomain.getCostForm()) {
return false;
} else {
if (1 == costDomain.getIsLend()) {
return true;
} else {
return false;
}
}
}
}
} }
...@@ -8,7 +8,6 @@ import com.blt.other.module.database.model.CostPlanDomain; ...@@ -8,7 +8,6 @@ import com.blt.other.module.database.model.CostPlanDomain;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -46,17 +45,12 @@ public class CostPlanNewController { ...@@ -46,17 +45,12 @@ public class CostPlanNewController {
@PostMapping("/affirm") @PostMapping("/affirm")
public Map<String, Object> affirm(@RequestParam String costPlanNo) { public Map<String, Object> affirm(@RequestParam String costPlanNo) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
try { CostPlanService costPlanService = CostPlanServiceFactory.getCostPlanService(costPlanNo);
CostPlanService costPlanService = CostPlanServiceFactory.getCostPlanService(costPlanNo);
Integer affirm = costPlanService.affirm(costPlanNo);
result.put("success", true);
result.put("msg", "已生成 " + affirm + " 张付款费用单");
Integer affirm = costPlanService.affirm(costPlanNo);
result.put("success", true);
result.put("msg", "已生成 " + affirm + " 张付款费用单");
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
result.put("success", false);
result.put("msg", "付款计划不存在或发生其他错误");
}
return result; return result;
} }
......
...@@ -52,54 +52,41 @@ public class CostDomain implements Serializable { ...@@ -52,54 +52,41 @@ public class CostDomain implements Serializable {
// 费用单编号 // 费用单编号
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Integer id; private Integer id;
// 费用单编号
@ApiModelProperty("费用单编号") @ApiModelProperty("费用单编号")
private String costNo; private String costNo;
// 费用计划编号
@ApiModelProperty("费用计划编号") @ApiModelProperty("费用计划编号")
private String costPlanNo; private String costPlanNo;
// 主体编号
@ApiModelProperty("主体编号") @ApiModelProperty("主体编号")
private String companyNo; private String companyNo;
// 主体名称
@ApiModelProperty("主体名称") @ApiModelProperty("主体名称")
private String companyName; private String companyName;
// 类型编号
@ApiModelProperty("类型编号") @ApiModelProperty("类型编号")
private String typeNo; private String typeNo;
// 类型标题
@ApiModelProperty("类型标题") @ApiModelProperty("类型标题")
private String typeName; private String typeName;
// 科目编号
@ApiModelProperty("科目编号") @ApiModelProperty("科目编号")
private String subjectCode; private String subjectCode;
// 小类编号
@ApiModelProperty("小类编号") @ApiModelProperty("小类编号")
private String kindNo; private String kindNo;
// 小类标题
@ApiModelProperty("小类标题") @ApiModelProperty("小类标题")
private String kindName; private String kindName;
// 创建人 id
@ApiModelProperty("创建人id") @ApiModelProperty("创建人id")
private Integer createUserid; private Integer createUserid;
// 创建人编号
@ApiModelProperty("创建人编号") @ApiModelProperty("创建人编号")
private String createUsercode; private String createUsercode;
// 创建人名称
@ApiModelProperty("创建人名称") @ApiModelProperty("创建人名称")
private String createUsername; private String createUsername;
// 费用单备注
@ApiModelProperty("费用单备注") @ApiModelProperty("费用单备注")
private String costRemark; private String costRemark;
@ApiModelProperty("创建时间") @ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime; private Date createTime;
// 关联子单
@ApiModelProperty("关联子单") @ApiModelProperty("关联子单")
@Deprecated @Deprecated
private String sonCostNo; private String sonCostNo;
@ApiModelProperty("关联父单") @ApiModelProperty("关联父单")
private String supCostNo; private String supCostNo;
...@@ -108,114 +95,96 @@ public class CostDomain implements Serializable { ...@@ -108,114 +95,96 @@ public class CostDomain implements Serializable {
@ApiModelProperty("文件地址") @ApiModelProperty("文件地址")
private String filePath; private String filePath;
@ApiModelProperty("补充材料地址") @ApiModelProperty("补充材料地址")
private String morFilePath; private String morFilePath;
// 费用总金额 @ApiModelProperty("补充信息")
private String morRemark;
@ApiModelProperty("费用总金额") @ApiModelProperty("费用总金额")
private BigDecimal amount; private BigDecimal amount;
// 二级物流供应商ID
@ApiModelProperty("二级物流供应商ID") @ApiModelProperty("二级物流供应商ID")
private Integer subLogisticsSupplierId; private Integer subLogisticsSupplierId;
// 一级物流供应商ID
@ApiModelProperty("一级物流供应商ID") @ApiModelProperty("一级物流供应商ID")
private Integer logisticsSupplierId; private Integer logisticsSupplierId;
// 收款银行(平台)
@ApiModelProperty("收款银行(平台)") @ApiModelProperty("收款银行(平台)")
private String bankName; private String bankName;
// 收款账户
@ApiModelProperty("收款账户") @ApiModelProperty("收款账户")
private String bankCard; private String bankCard;
// 收款用户名
@ApiModelProperty("收款用户名") @ApiModelProperty("收款用户名")
private String bankCardUser; private String bankCardUser;
// 收款/付款单位
@ApiModelProperty("收款/付款单位") @ApiModelProperty("收款/付款单位")
private String bankCompany; private String bankCompany;
// 补充信息
@ApiModelProperty("补充信息")
private String morRemark;
// 1 付款费用 2 收款费用 3 借支/借还
@ApiModelProperty("1 付款费用 2 收款费用 3 借支/借还") @ApiModelProperty("1 付款费用 2 收款费用 3 借支/借还")
private Integer costForm; private Integer costForm;
// 付款理由
@ApiModelProperty("付款理由")
private String costReason;
// 1 借支 2 借还
@ApiModelProperty("1 借支 2 借还") @ApiModelProperty("1 借支 2 借还")
private Integer isLend; private Integer isLend;
// 借支单已还金额 @ApiModelProperty("1 未还 2 部分还款 3 待补差额 4 结清")
private Integer lendStatus;
@ApiModelProperty("付款理由")
private String costReason;
@ApiModelProperty("驳回原因")
private String rejectReason;
@ApiModelProperty("借支单已还金额") @ApiModelProperty("借支单已还金额")
private BigDecimal hadPay; private BigDecimal hadPay;
// 借支单状态 1 未还 2 部分还款 3 结清
@ApiModelProperty("借支单状态 1 未还 2 部分还款 3 结清")
private Integer lendStatus;
// 借支单补偿金额
@ApiModelProperty("借支单补偿金额") @ApiModelProperty("借支单补偿金额")
private BigDecimal compensate; private BigDecimal compensate;
// 冲销金额 @ApiModelProperty("冲销金额 (借支单币种)")
@ApiModelProperty("冲销金额")
private BigDecimal counteract; private BigDecimal counteract;
// 借还单余额 @ApiModelProperty("借还单余额 (借支单币种)")
@ApiModelProperty("借还单余额")
private BigDecimal lendBalance; private BigDecimal lendBalance;
// 驳回原因 @ApiModelProperty("对应借支单币种)")
@ApiModelProperty("驳回原因")
private String rejectReason;
// 币种
@ApiModelProperty("币种")
private String dic; private String dic;
// 借还单冲销金额 ( 支付币种 )
@ApiModelProperty("借还单冲销金额 ( 支付币种 )") @ApiModelProperty("借还单冲销金额 ( 支付币种 )")
private BigDecimal payCounteract; private BigDecimal payCounteract;
// 借还单余额 ( 支付币种 )
@ApiModelProperty("借还单余额 ( 支付币种 )") @ApiModelProperty("借还单余额 ( 支付币种 )")
private BigDecimal payLendBalance; private BigDecimal payLendBalance;
// 计划金额 ( 支付币种 )
@ApiModelProperty("计划金额 ( 支付币种 )") @ApiModelProperty("计划金额 ( 支付币种 )")
private BigDecimal payPlanAmount; private BigDecimal payPlanAmount;
// 支付币种
@ApiModelProperty("支付币种") @ApiModelProperty("支付币种")
private String payDic; private String payDic;
// 汇率 @ApiModelProperty("借还单 借还支付币种 -> 借支币种汇率")
@ApiModelProperty("汇率")
private BigDecimal payCur; private BigDecimal payCur;
// 0 不抵扣个税 1 抵扣个税
@ApiModelProperty("0 不抵扣个税 1 抵扣个税") @ApiModelProperty("0 不抵扣个税 1 抵扣个税")
private Integer isTax; private Integer isTax;
// 出纳系统 detailKey
@ApiModelProperty("出纳系统 detailKey") @ApiModelProperty("出纳系统 detailKey")
private String detailKey; private String detailKey;
// 支付者用户ID
@ApiModelProperty("支付者用户ID") @ApiModelProperty("支付者用户ID")
private Integer payUserId; private Integer payUserId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
// 支付时间
@ApiModelProperty("支付时间") @ApiModelProperty("支付时间")
private Date payTime; private Date payTime;
// 转人民币汇率
@ApiModelProperty("转人民币汇率") @ApiModelProperty("转人民币汇率")
private BigDecimal toRmbRate; private BigDecimal toRmbRate;
// 费用单人民币总金额
@ApiModelProperty("费用单人民币总金额") @ApiModelProperty("费用单人民币总金额")
private BigDecimal amountRmb; private BigDecimal amountRmb;
// 公司主体value
@ApiModelProperty("公司主体value") @ApiModelProperty("公司主体value")
private Integer companyValue; private Integer companyValue;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty("财务审核时间") @ApiModelProperty("财务审核时间")
private Date auditTime; private Date auditTime;
//发票状态
@ApiModelProperty("费用单发票状态编号") @ApiModelProperty("费用单发票状态编号")
private Integer hasInvoice; private Integer hasInvoice;
//驳回类型
@ApiModelProperty("驳回类型") @ApiModelProperty("驳回类型")
private Integer rejectType; private Integer rejectType;
//财务驳回时间
@ApiModelProperty("财务驳回时间") @ApiModelProperty("财务驳回时间")
private Date rejectTime; private Date rejectTime;
...@@ -225,13 +194,12 @@ public class CostDomain implements Serializable { ...@@ -225,13 +194,12 @@ public class CostDomain implements Serializable {
@ApiModelProperty("") @ApiModelProperty("")
private String cashierDownloadPath; private String cashierDownloadPath;
//
@ApiModelProperty("费用来源 1-默认 2-WMS 3-调拨系统") @ApiModelProperty("费用来源 1-默认 2-WMS 3-调拨系统")
private String sourceFrom; private String sourceFrom;
//项目
@ApiModelProperty("项目") @ApiModelProperty("项目")
private String projectType; private String projectType;
//客户编号
@ApiModelProperty("客户编号") @ApiModelProperty("客户编号")
private String customerNum; private String customerNum;
...@@ -251,8 +219,8 @@ public class CostDomain implements Serializable { ...@@ -251,8 +219,8 @@ public class CostDomain implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private Boolean canAudit; private Boolean canAudit;
@TableField(exist = false) @ApiModelProperty("借支单,还款申请金额,包括已还的和申请中 ,借支单币种。")
private String checkUrl; private BigDecimal repaymentAppliedAmount;
public CostDto castToDto() { public CostDto castToDto() {
......
...@@ -134,4 +134,11 @@ public interface CostService { ...@@ -134,4 +134,11 @@ public interface CostService {
* @param cashierCallbackUrlVo req * @param cashierCallbackUrlVo req
*/ */
void cashierCallback(CashierCallbackUrlVo cashierCallbackUrlVo); void cashierCallback(CashierCallbackUrlVo cashierCallbackUrlVo);
/**
* 审批拒绝handle
*
* @param costNo costNo
*/
void reject(String costNo);
} }
...@@ -291,6 +291,13 @@ public abstract class AbstractCostService implements CostService { ...@@ -291,6 +291,13 @@ public abstract class AbstractCostService implements CostService {
} }
} }
@Override
public void reject(String costNo) {
CostDomain costDomain = costDao.selectByCostNo(costNo);
costDomain.setCostStatus(CostDomain.STATUS_REJECT);
costDao.updateById(costDomain);
}
@Resource @Resource
CostCashiercallbackService costCashiercallbackService; CostCashiercallbackService costCashiercallbackService;
...@@ -340,7 +347,6 @@ public abstract class AbstractCostService implements CostService { ...@@ -340,7 +347,6 @@ public abstract class AbstractCostService implements CostService {
costDomain.setLendStatus(1); costDomain.setLendStatus(1);
} }
} }
costDomain.setPayUserId(costCashiercallbackDomain.getPayuserid()); costDomain.setPayUserId(costCashiercallbackDomain.getPayuserid());
costDomain.setPayTime(new Date()); costDomain.setPayTime(new Date());
costDomain.setAmountRmb(costCashiercallbackDomain.getCashierpaymoneyrmb()); costDomain.setAmountRmb(costCashiercallbackDomain.getCashierpaymoneyrmb());
......
...@@ -78,75 +78,57 @@ public class Lend2PayCostServiceImpl extends AbstractCostService implements Cost ...@@ -78,75 +78,57 @@ public class Lend2PayCostServiceImpl extends AbstractCostService implements Cost
} }
@Override @Override
public void reject(String costNo) {
super.reject(costNo);
//释放已申请的金额
CostDomain costDomain = costDao.selectByCostNo(costNo);
CostDomain supCost = costDao.selectByCostNo(costDomain.getSupCostNo());
supCost.setRepaymentAppliedAmount(supCost.getRepaymentAppliedAmount().subtract(costDomain.getAmount()));
costDao.updateById(supCost);
}
@Override
void cashierCallbackPass(CostCashiercallbackDomain costCashiercallbackDomain) { void cashierCallbackPass(CostCashiercallbackDomain costCashiercallbackDomain) {
// 付款成功,更改借还单信息,否则返回失败 // 付款成功,更改借还单信息,否则返回失败
CostDomain costDomainByNo = this.getCostByCostNo(costCashiercallbackDomain.getCostNo()); CostDomain costDomain = this.getCostByCostNo(costCashiercallbackDomain.getCostNo());
String sonNo = costDomainByNo.getCostNo().toUpperCase(); String sonNo = costDomain.getCostNo().toUpperCase();
changeStatus(costCashiercallbackDomain.getCostNo(), 4, costDomainByNo.getLendStatus(), costCashiercallbackDomain.getPayuserid());
if (sonNo.contains("S")) {
CostDomain supCostDomain = this.getCostByCostNo(costDomainByNo.getSupCostNo());
if (null == supCostDomain.getHadPay()) supCostDomain.setHadPay(new BigDecimal(0));
if (null == supCostDomain.getCompensate()) supCostDomain.setCompensate(new BigDecimal(0));
// supCostDomain.setCompensate(supCostDomain.getCompensate().add(costCashiercallbackDomain.getPayamount()));
supCostDomain.setCompensate(supCostDomain.getCompensate().subtract(costCashiercallbackDomain.getPayamount()));
// supCostDomain.setHadPay(supCostDomain.getHadPay().add(costCashiercallbackDomain.getPayamount()));
// 借还单在出纳完成收付款后,不用直接获取返回的金额(使用费用系统中记录的提交金额,出纳系统结算的实时汇率和费用系统不一定一致)
supCostDomain.setHadPay(supCostDomain.getHadPay().add(costDomainByNo.getAmount()));
// int i = supCostDomain.getAmount().compareTo(supCostDomain.getHadPay().subtract(supCostDomain.getCompensate()));
BigDecimal zero = new BigDecimal(0);
if (supCostDomain.getCompensate().compareTo(zero) == 0) {
supCostDomain.setLendStatus(4);
// 已补差额,但是仍有金额未到账
BigDecimal allPayAmount = supCostDomain.getAmount().add(costCashiercallbackDomain.getPayamount());
int i = allPayAmount.compareTo(supCostDomain.getHadPay());
if (0 < i) {
supCostDomain.setLendStatus(2);
}
}
if (supCostDomain.getCompensate().compareTo(zero) == 1) {
supCostDomain.setLendStatus(3); costDomain.setCostStatus(CostDomain.STATUS_PAYED);
} costDomain.setPayUserId(costCashiercallbackDomain.getPayuserid());
this.updateCost(supCostDomain); costDomain.setPayTime(new Date());
} BigDecimal toRmbRate = CurUtils.getCur(costDomain.getDic(), "CNY");
if (!sonNo.contains("S") && null != costDomainByNo.getSupCostNo()) {
CostDomain supCostDomain = this.getCostByCostNo(costDomainByNo.getSupCostNo()); costDomain.setToRmbRate(toRmbRate);
if (null == supCostDomain.getHadPay()) { costDomain.setAmountRmb(costDomain.getAmount().multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP));
supCostDomain.setHadPay(new BigDecimal(0)); costDomain.setAuditTime(new Date());
} costDao.updateById(costDomain);
// supCostDomain.setHadPay(supCostDomain.getHadPay().add(costCashiercallbackDomain.getCashierpaymoney()));
//借还单
if (!sonNo.contains("S")) {
//关联借支单
CostDomain supCostDomain = this.getCostByCostNo(costDomain.getSupCostNo());
// 借还单在出纳完成收付款后,不用直接获取返回的金额(使用费用系统中记录的提交金额,出纳系统结算的实时汇率和费用系统不一定一致) // 借还单在出纳完成收付款后,不用直接获取返回的金额(使用费用系统中记录的提交金额,出纳系统结算的实时汇率和费用系统不一定一致)
supCostDomain.setHadPay(supCostDomain.getHadPay().add(costDomainByNo.getAmount())); supCostDomain.setHadPay(supCostDomain.getHadPay().add(costDomain.getAmount()));
if (supCostDomain.getHadPay().compareTo(supCostDomain.getAmount()) == 0) { if (supCostDomain.getHadPay().compareTo(supCostDomain.getAmount()) == 0) {
//结清
supCostDomain.setLendStatus(4); supCostDomain.setLendStatus(4);
} } else if (supCostDomain.getHadPay().compareTo(supCostDomain.getAmount()) < 0) {
if (supCostDomain.getHadPay().compareTo(supCostDomain.getAmount()) == -1) { //部分结清
supCostDomain.setLendStatus(2); supCostDomain.setLendStatus(2);
} else if (supCostDomain.getHadPay().compareTo(supCostDomain.getAmount()) > 0) {
//todo 邮件通知
log.error("金额异常 联系管理员,costNo:{}", supCostDomain.getCostNo());
} }
if (supCostDomain.getHadPay().compareTo(supCostDomain.getAmount()) == 1) { costDao.updateById(supCostDomain);
supCostDomain.setLendStatus(3);
supCostDomain.setCompensate(supCostDomain.getHadPay().subtract(supCostDomain.getAmount()));
}
this.updateCost(supCostDomain);
} }
costLogService.save(costCashiercallbackDomain.getCostNo(), costCashiercallbackDomain.getPayuserid(), "出纳收/付款成功:" + costCashiercallbackDomain.getPaynote());
} costLogService.save(costDomain.getCostNo(), costDomain.getPayUserId(), "出纳收/付款成功:" + costCashiercallbackDomain.getPaynote());
private void changeStatus(String costNo, Integer costStatus, Integer lendStatus, Integer updateUserId) {
Date now = new Date();
CostDomain costDomain = this.getCostByCostNo(costNo);
costDomain.setCostStatus(costStatus);
costDomain.setCostNo(costNo);
costDomain.setLendStatus(lendStatus);
costDomain.setPayUserId(updateUserId);
costDomain.setPayTime(now);
BigDecimal toRmbRate = CurUtils.getCur(costDomain.getDic(), "CNY");
costDomain.setToRmbRate(toRmbRate);
costDomain.setAmountRmb(costDomain.getAmount().multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP));
costDomain.setAuditTime(now);
this.updateCost(costDomain);
} }
} }
...@@ -51,7 +51,7 @@ public class DepartmentCheckState extends CostState { ...@@ -51,7 +51,7 @@ public class DepartmentCheckState extends CostState {
//流转状态 //流转状态
nextState(financialCheckState); nextState(financialCheckState);
costSubscribe.subscribe(costContext); costSubscribe.subscribe(costContext);
costLogService.saveByManage(costDomain.getCostNo(),"部门审核自动通过", CostLogDomain.DEPARTMENT_AUTO_PASS); costLogService.saveByManage(costDomain.getCostNo(), "部门审核自动通过", CostLogDomain.DEPARTMENT_AUTO_PASS);
return; return;
} }
...@@ -110,10 +110,11 @@ public class DepartmentCheckState extends CostState { ...@@ -110,10 +110,11 @@ public class DepartmentCheckState extends CostState {
throw new BizRuntimeException("current user no authority"); throw new BizRuntimeException("current user no authority");
} }
costDomain.setCostStatus(CostDomain.STATUS_REJECT);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "部门审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE); costLogService.save(costDomain.getCostNo(), currentUserId, "部门审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE);
//sd
costContext.costService.reject(costDomain.getCostNo());
} }
} }
...@@ -122,8 +122,7 @@ public class FinalCheckState extends CostState { ...@@ -122,8 +122,7 @@ public class FinalCheckState extends CostState {
throw new BizRuntimeException("current user no authority"); throw new BizRuntimeException("current user no authority");
} }
costDomain.setCostStatus(CostDomain.STATUS_REJECT); costContext.costService.resetCost(costDomain.getCostNo());
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "最终审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE); costLogService.save(costDomain.getCostNo(), currentUserId, "最终审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE);
......
...@@ -99,8 +99,7 @@ public class FinancialCheckState extends CostState { ...@@ -99,8 +99,7 @@ public class FinancialCheckState extends CostState {
throw new BizRuntimeException("current user no authority"); throw new BizRuntimeException("current user no authority");
} }
costDomain.setCostStatus(CostDomain.STATUS_REJECT); costContext.costService.resetCost(costDomain.getCostNo());
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "财务审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE); costLogService.save(costDomain.getCostNo(), currentUserId, "财务审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE);
......
...@@ -96,6 +96,7 @@ public abstract class AbstractCostPlanService implements CostPlanService { ...@@ -96,6 +96,7 @@ public abstract class AbstractCostPlanService implements CostPlanService {
costPlanDomain.setCreateUserid(user.getUserid()); costPlanDomain.setCreateUserid(user.getUserid());
costPlanDomain.setCreateUsername(user.getUsername()); costPlanDomain.setCreateUsername(user.getUsername());
costPlanDomain.setCreateTime(new Date()); costPlanDomain.setCreateTime(new Date());
//借还单 借还币种 -> 借支币种汇率
costPlanDomain.setPayCur(costPlanDomain.getCur()); costPlanDomain.setPayCur(costPlanDomain.getCur());
} }
......
...@@ -73,18 +73,18 @@ public class CostPlanNewLend1ServiceImpl extends AbstractCostPlanService impleme ...@@ -73,18 +73,18 @@ public class CostPlanNewLend1ServiceImpl extends AbstractCostPlanService impleme
CostDomain costDomain = planToCost(costPlanDomain.getCostPlanNo()); CostDomain costDomain = planToCost(costPlanDomain.getCostPlanNo());
String costNo = getCostNo(); String costNo = getCostNo();
costDomain.setCompensate(BigDecimal.ZERO);
costDomain.setRepaymentAppliedAmount(BigDecimal.ZERO);
costDomain.setCostNo(costNo); costDomain.setCostNo(costNo);
costDomain.setCostStatus(0); costDomain.setCostStatus(0);
costDomain.setAmount(costPlanDomain.getPlanAmount()); costDomain.setAmount(costPlanDomain.getPlanAmount());
BigDecimal toRmbRate = CurUtils.getCur(costDomain.getDic(), "CNY"); BigDecimal toRmbRate = CurUtils.getCur(costDomain.getDic(), "CNY");
costDomain.setToRmbRate(toRmbRate); costDomain.setToRmbRate(toRmbRate);
costDomain.setAmountRmb(costDomain.getAmount().multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP)); costDomain.setAmountRmb(costDomain.getAmount().multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP));
Integer insert = costDao.insert(costDomain); int insert = costDao.insert(costDomain);
if (null == insert || insert <= 0) {
return 0; costLogService.save(costDomain.getCostNo(), costDomain.getCreateUserid(), "由费用计划:" + costDomain.getCostPlanNo() + " 生成借支单");
}
costLogService.save(costDomain.getCostNo(), costDomain.getCreateUserid(),
"由费用计划:" + costDomain.getCostPlanNo() + " 生成借支单");
return insert; return insert;
} }
} }
...@@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; ...@@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.blt.other.module.cost.dao.CostDao; import com.blt.other.module.cost.dao.CostDao;
import com.blt.other.module.cost.model.CostDomain; import com.blt.other.module.cost.model.CostDomain;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.NumberFormat; import java.text.NumberFormat;
/** /**
...@@ -49,148 +47,4 @@ public class CostUtils { ...@@ -49,148 +47,4 @@ public class CostUtils {
} }
return "F" + result; return "F" + result;
} }
/**
* 生成 CostDomain 实例
*
* @param request
* @return
*/
@Deprecated
public static CostDomain createCostDomain(HttpServletRequest request, String costNo) {
String companyNo = request.getParameter("companyNo");
String kindNo = request.getParameter("kindNo");
String amountRequest = request.getParameter("amount");
BigDecimal amount = null;
if (null != amountRequest) {
amount = new BigDecimal(amountRequest);
}
String costRemark = request.getParameter("costRemark");
String createUsercode = request.getParameter("createUsercode");
Integer subLogisticsSupplierId = null;//二级物流供应商ID,非物流费用单为NULL
String subLogisticsStr = request.getParameter("subLogisticsSupplierId");
if (subLogisticsStr != null && !"".equals(subLogisticsStr) && !"null".equals(subLogisticsStr)) {
subLogisticsSupplierId = Integer.valueOf(subLogisticsStr);
}
Integer logisticsSupplierId = null;//一级物流供应商ID,非物流费用单为NULL
String logisticsStr = request.getParameter("logisticsSupplierId");
if (logisticsStr != null && !"".equals(logisticsStr) && !"null".equals(logisticsStr)) {
logisticsSupplierId = Integer.valueOf(logisticsStr);
}
String bankName = request.getParameter("bankName");
String bankCard = request.getParameter("bankCard");
String bankCardUser = request.getParameter("bankCardUser");
String bankCompany = request.getParameter("bankCompany");
String morRemark = request.getParameter("morRemark");
String costReason = request.getParameter("costReason");
String isLendStr = request.getParameter("isLend");
String dic = request.getParameter("dic");
String detailKey = request.getParameter("detailKey");
Integer isLend = null;
if (null != isLendStr && !"null".equals(isLendStr)) {
isLend = Integer.parseInt(isLendStr);
}
String costFormStr = request.getParameter("costForm");
Integer costForm = null;
int isTax = 0;
if (null != costFormStr && !"null".equals(costFormStr)) {
costForm = Integer.parseInt(costFormStr);
if (1 == costForm) {
String isTaxStr = request.getParameter("isTax");
if (null != isTaxStr) {
isTax = Integer.parseInt(isTaxStr);
}
}
}
String projectType = request.getParameter("projectType");
String customerNum = request.getParameter("customerNum");
// 封装 CostDomain
CostDomain costDomain = new CostDomain();
costDomain.setCostNo(costNo);
costDomain.setDetailKey(detailKey);
costDomain.setCompanyNo(companyNo);
costDomain.setKindNo(kindNo);
costDomain.setAmount(amount);
costDomain.setCostRemark(costRemark);
costDomain.setCreateUsercode(createUsercode);
costDomain.setSubLogisticsSupplierId(subLogisticsSupplierId);
costDomain.setLogisticsSupplierId(logisticsSupplierId);
costDomain.setBankName(bankName);
costDomain.setBankCard(bankCard);
costDomain.setBankCardUser(bankCardUser);
costDomain.setBankCompany(bankCompany);
costDomain.setMorRemark(morRemark);
costDomain.setCostForm(costForm);
costDomain.setCostReason(costReason);
costDomain.setIsLend(isLend);
costDomain.setDic(dic);
costDomain.setIsTax(isTax);
costDomain.setProjectType(projectType);
costDomain.setCustomerNum(customerNum);
if (null != costForm && 3 == costForm) {
if (1 == isLend) {
// 借支
costDomain.setTypeNo(null);
costDomain.setKindNo(kindNo);
String hadPay = request.getParameter("hadPay");
if (null != hadPay && !"null".equals(hadPay)) {
costDomain.setHadPay(new BigDecimal(hadPay));
}
String lendStatus = request.getParameter("lendStatus");
if (null != lendStatus && !"null".equals(lendStatus)) {
costDomain.setLendStatus(Integer.parseInt(lendStatus));
}
String compensate = request.getParameter("compensate");
if (null != compensate && !"null".equals(compensate)) {
costDomain.setCompensate(new BigDecimal(compensate));
}
String counteract = request.getParameter("counteract");
if (null != counteract && !"null".equals(counteract)) {
costDomain.setCounteract(new BigDecimal(counteract));
}
String lendBalance = request.getParameter("lendBalance");
if (null != lendBalance && !"null".equals(lendBalance)) {
costDomain.setLendBalance(new BigDecimal(lendBalance));
}
} else if (2 == isLend) {
// 借还
String supCostNo = request.getParameter("supCostNo");
costDomain.setSupCostNo(supCostNo);
costDomain.setTypeNo(null);
costDomain.setKindNo(kindNo);
String counteract = request.getParameter("counteract");
if (null != counteract && !"null".equals(counteract)) {
costDomain.setCounteract(new BigDecimal(counteract));
}
String lendBalance = request.getParameter("lendBalance");
if (null != lendBalance && !"null".equals(lendBalance)) {
costDomain.setLendBalance(new BigDecimal(lendBalance));
}
String payDic = request.getParameter("payDic");
if (null != lendBalance && !"null".equals(lendBalance)) {
costDomain.setPayDic(payDic);
}
String payCounteract = request.getParameter("payCounteract");
if (null != payCounteract && !"null".equals(payCounteract)) {
costDomain.setPayCounteract(new BigDecimal(payCounteract));
}
String payLendBalance = request.getParameter("payLendBalance");
if (null != payLendBalance && !"null".equals(payLendBalance)) {
costDomain.setPayLendBalance(new BigDecimal(payLendBalance));
}
String payPlanAmount = request.getParameter("payPlanAmount");
if (null != payPlanAmount && !"null".equals(payPlanAmount)) {
costDomain.setPayPlanAmount(new BigDecimal(payPlanAmount));
}
String cur = request.getParameter("cur");
if (null != cur && !"null".equals(cur)) {
costDomain.setPayCur(new BigDecimal(cur));
}
}
}
return costDomain;
}
} }
...@@ -28,10 +28,14 @@ public class CostPlanDomain implements Serializable { ...@@ -28,10 +28,14 @@ public class CostPlanDomain implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Integer id; // 费用单表 id private Integer id; // 费用单表 id
@ApiModelProperty("费用计划编号") @ApiModelProperty("费用计划编号")
private String costPlanNo; // 费用计划编号 private String costPlanNo; // 费用计划编号
@ApiModelProperty("0 不抵扣个税 1 抵扣个税")
private Integer isTax;
@ApiModelProperty("公司主体value")
private Integer companyValue;
@ApiModelProperty("主体编号") @ApiModelProperty("主体编号")
private String companyNo; // 主体编号 private String companyNo; // 主体编号
@ApiModelProperty("主体名称") @ApiModelProperty("主体名称")
...@@ -47,106 +51,105 @@ public class CostPlanDomain implements Serializable { ...@@ -47,106 +51,105 @@ public class CostPlanDomain implements Serializable {
private String kindName; // 种类标题 private String kindName; // 种类标题
@ApiModelProperty("创建人id") @ApiModelProperty("创建人id")
private Integer createUserid; // 创建人 id private Integer createUserid;
@ApiModelProperty("创建人编号") @ApiModelProperty("创建人编号")
private String createUsercode; // 创建人编号 private String createUsercode;
@ApiModelProperty("创建人名称") @ApiModelProperty("创建人名称")
private String createUsername; // 创建人名称 private String createUsername;
@ApiModelProperty("付款理由") @ApiModelProperty("付款理由")
private String costReason; // 付款理由 private String costReason;
@ApiModelProperty("费用单备注") @ApiModelProperty("费用单备注")
private String costRemark; // 费用单备注 private String costRemark;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty("创建时间") @ApiModelProperty("创建时间")
private Date createTime; // 创建时间 private Date createTime;
@ApiModelProperty("关联子单") @ApiModelProperty("关联子单")
@Deprecated @Deprecated
private String sonCostNo; // 关联子单 private String sonCostNo;
@ApiModelProperty("关联父单") @ApiModelProperty("关联父单")
private String supCostNo; // 关联父单 private String supCostNo;
@ApiModelProperty("费用计划状态 0 待确认 1 已确认") @ApiModelProperty("费用计划状态 0 待确认 1 已确认")
private Integer costPlanStatus; // 费用计划状态 0 待确认 1 已确认 private Integer costPlanStatus;
@ApiModelProperty("文件地址") @ApiModelProperty("文件地址")
private String filePath; // 文件地址 private String filePath;
@ApiModelProperty("补充材料地址") @ApiModelProperty("补充材料地址")
private String morFilePath; // 补充材料地址 private String morFilePath;
@ApiModelProperty("费用总金额") @ApiModelProperty("费用总金额")
private BigDecimal planAmount; // 费用总金额 private BigDecimal planAmount;
@ApiModelProperty("二级物流供应商ID") @ApiModelProperty("二级物流供应商ID")
private Integer subLogisticsSupplierId; // 二级物流供应商ID private Integer subLogisticsSupplierId;
@ApiModelProperty("一级物流供应商ID") @ApiModelProperty("一级物流供应商ID")
private Integer logisticsSupplierId; // 一级物流供应商ID private Integer logisticsSupplierId;
@ApiModelProperty("收款银行(平台)") @ApiModelProperty("收款银行(平台)")
private String bankName; // 收款银行(平台) private String bankName;
@ApiModelProperty("收款账户") @ApiModelProperty("收款账户")
private String bankCard; // 收款账户 private String bankCard;
@ApiModelProperty("收款用户名") @ApiModelProperty("收款用户名")
private String bankCardUser; // 收款用户名 private String bankCardUser;
@ApiModelProperty("收款/付款单位") @ApiModelProperty("收款/付款单位")
private String bankCompany; // 收款/付款单位 private String bankCompany;
@ApiModelProperty("补充信息") @ApiModelProperty("补充信息")
private String morRemark; // 补充信息 private String morRemark;
@ApiModelProperty("1 付款费用 2 收款费用 3 借支/借还") @ApiModelProperty("1 付款费用 2 收款费用 3 借支/借还")
private Integer costForm; // 1 付款费用 2 收款费用 3 借支/借还 private Integer costForm;
@ApiModelProperty("1 借支 2 借还") @ApiModelProperty("1 借支 2 借还")
private Integer isLend; // 1 借支 2 借还 private Integer isLend;
@ApiModelProperty("借支单已还金额") @ApiModelProperty("借支单已还金额")
private BigDecimal hadPay; // 借支单已还金额 private BigDecimal hadPay;
@ApiModelProperty("借支单状态 1 未还 2 部分还款 3 结清") @ApiModelProperty("借支单状态 1 未还 2 部分还款 3 结清")
private Integer lendStatus; // 借支单状态 1 未还 2 部分还款 3 结清 private Integer lendStatus;
@ApiModelProperty("借支单补偿金额")
private BigDecimal compensate; // 借支单补偿金额
@ApiModelProperty("冲销金额")
private BigDecimal counteract; // 冲销金额
@ApiModelProperty("借还单余额")
private BigDecimal lendBalance; // 借还单余额
@ApiModelProperty("驳回原因") @ApiModelProperty("驳回原因")
private String rejectReason; // 驳回原因 private String rejectReason;
@ApiModelProperty("币种")
private String dic; // 币种 /*借还单参数 start*/
@ApiModelProperty("借支单补偿金额")
private BigDecimal compensate;
@ApiModelProperty("借还单冲销金额 (对应借支单币种)")
private BigDecimal counteract;
@ApiModelProperty("借还单归还金额 (对应借支单币种)")
private BigDecimal lendBalance;
@ApiModelProperty("对应借支单币种")
private String dic;
@ApiModelProperty("借还单冲销金额 ( 支付币种 )") @ApiModelProperty("借还单冲销金额 ( 支付币种 )")
private BigDecimal payCounteract; // 借还单冲销金额 ( 支付币种 ) private BigDecimal payCounteract;
@ApiModelProperty("借还单额 ( 支付币种 )") @ApiModelProperty("借还单归还金额 ( 支付币种 )")
private BigDecimal payLendBalance; // 借还单余额 ( 支付币种 ) private BigDecimal payLendBalance;
@ApiModelProperty("计划金额 ( 支付币种 )") @ApiModelProperty("计划金额 ( 支付币种 )")
private BigDecimal payPlanAmount; // 计划金额 ( 支付币种 ) private BigDecimal payPlanAmount;
@ApiModelProperty("支付币种") @ApiModelProperty("支付币种")
private String payDic; // 支付币种 private String payDic;
@ApiModelProperty("汇率") @ApiModelProperty("借还单 借还支付币种 -> 借支币种汇率")
private BigDecimal payCur; // 汇率 private BigDecimal payCur;
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty("费用计划编汇率号") @ApiModelProperty("借还单 借还支付币种 -> 借支币种汇率")
private BigDecimal cur; // 汇率 private BigDecimal cur;
/*借还单参数 end*/
@ApiModelProperty("0 不抵扣个税 1 抵扣个税")
private Integer isTax; // 0 不抵扣个税 1 抵扣个税
@ApiModelProperty("公司主体value")
private Integer companyValue; // 公司主体value
@TableField(value = "`attach`", typeHandler = JacksonTypeHandler.class) @TableField(value = "`attach`", typeHandler = JacksonTypeHandler.class)
@ApiModelProperty("附加字段") @ApiModelProperty("附加字段")
private List<CostAttach> attach; private List<CostAttach> attach;
@ApiModelProperty("费用模版id") @ApiModelProperty("费用模版id")
private Integer costTemplateId; private Integer costTemplateId;
@TableField(exist = false) @TableField(exist = false)
private CostTemplate costTemplate; private CostTemplate costTemplate;
public CostPlanDto castToDto() { public CostPlanDto castToDto() {
StatusMapper statusMapper = SpringContextUtil.getBean(StatusMapper.class); StatusMapper statusMapper = SpringContextUtil.getBean(StatusMapper.class);
......
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