Browse Source

支付功能

mssql
Yen 3 years ago
parent
commit
c23b780525
  1. 7
      src/main/java/com/qs/serve/modules/pay/controller/PayPaymentController.java
  2. 2
      src/main/java/com/qs/serve/modules/pay/entity/PayPayment.java
  3. 3
      src/main/java/com/qs/serve/modules/pay/entity/bo/PayPaymentBo.java
  4. 14
      src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java

7
src/main/java/com/qs/serve/modules/pay/controller/PayPaymentController.java

@ -70,7 +70,8 @@ public class PayPaymentController {
* @param supplierId
* @return
*/
@GetMapping("/getSupplierAmount/{supplierId}")
@GetMapping("/amount/{supplierId}")
@PreAuthorize("hasRole('pay:payment:query')")
public R<PayPaymentAmountDto> getSupplierAmount(@PathVariable("supplierId") Long supplierId){
PayPaymentAmountDto amountDto = payPaymentService.getSupplierBalance(supplierId);
return R.ok(amountDto);
@ -83,7 +84,7 @@ public class PayPaymentController {
*/
@PostMapping("/payment")
@SysLog(module = SystemModule.Payment, title = "支付", biz = BizType.INSERT)
@PreAuthorize("hasRole('pay:payment:insert')")
@PreAuthorize("hasRole('pay:payment:pay')")
public R<PayPayment> save(@RequestBody @Valid PayPaymentBo param){
PayPayment payPayment = payPaymentService.payment(param);
return R.ok(payPayment);
@ -96,7 +97,7 @@ public class PayPaymentController {
*/
@DeleteMapping("/cancel/{id}")
@SysLog(module = SystemModule.Payment, title = "支付", biz = BizType.DELETE)
@PreAuthorize("hasRole('pay:payment:delete')")
@PreAuthorize("hasRole('pay:payment:cancel')")
public R<?> cancelById(@PathVariable("id") Long id){
payPaymentService.cancel(id);
return R.ok();

2
src/main/java/com/qs/serve/modules/pay/entity/PayPayment.java

@ -49,6 +49,8 @@ public class PayPayment implements Serializable {
@NotNull(message = "支付金额不能为空")
private BigDecimal payAmount;
private String erpCode;
/** 支付人id */
@NotBlank(message = "支付人id不能为空")
@Length(max = 32,message = "支付人id长度不能超过32字")

3
src/main/java/com/qs/serve/modules/pay/entity/bo/PayPaymentBo.java

@ -33,6 +33,9 @@ public class PayPaymentBo implements Serializable {
@NotNull(message = "支付金额不能为空")
private BigDecimal payAmount;
/** ERP编码 */
private String erpCode;
/** 备注 */
@Length(max = 255,message = "备注长度不能超过255字")
private String remark;

14
src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java

@ -70,16 +70,20 @@ public class PayPaymentServiceImpl extends ServiceImpl<PayPaymentMapper,PayPayme
for (PayPaymentItem paymentItem : payPaymentItems) {
hisPayAmount = hisPayAmount.add(paymentItem.getItemPayAmount());
}
//支付
//当前项未支付
BigDecimal shouldPay = verificationSubject.getUsedAmount().subtract(hisPayAmount);
//当前项支付金额
BigDecimal currentItemPay;
if(currentBalance.compareTo(shouldPay)>0){
currentItemPay = shouldPay;
currentBalance = currentBalance.subtract(shouldPay);
}else {
currentItemPay = currentBalance;
currentBalance = BigDecimal.ZERO;
}
PayPaymentItem paymentItem = new PayPaymentItem();
paymentItem.setSupplierId(paymentBo.getSupplierId());
paymentItem.setItemPayAmount(shouldPay);
paymentItem.setItemPayAmount(currentItemPay);
paymentItem.setVerificationId(verificationSubject.getVerificationId());
paymentItem.setVerificationSubjectId(verificationSubject.getId());
paymentItem.setCostApplyId(verificationSubject.getCostApplyId());
@ -89,7 +93,7 @@ public class PayPaymentServiceImpl extends ServiceImpl<PayPaymentMapper,PayPayme
paymentItem.setSubjectName(verificationSubject.getSubjectName());
paymentItemList.add(paymentItem);
//更新核销科目余额
BigDecimal payAmountOfVer = verificationSubject.getPayAmount().add(shouldPay);
BigDecimal payAmountOfVer = verificationSubject.getPayAmount().add(currentItemPay);
VtbVerificationSubject subjectParam = new VtbVerificationSubject();
subjectParam.setId(verificationSubject.getId());
subjectParam.setPayAmount(payAmountOfVer);
@ -150,7 +154,7 @@ public class PayPaymentServiceImpl extends ServiceImpl<PayPaymentMapper,PayPayme
VtbVerificationSubject param = new VtbVerificationSubject();
param.setId(obj.getId());
param.setPayAmount(obj.getPayAmount());
param.setEffectiveFlag(0);
param.setPayFinishedFlag(0);
return param;
}).collect(Collectors.toList());
//更新数据
@ -167,7 +171,7 @@ public class PayPaymentServiceImpl extends ServiceImpl<PayPaymentMapper,PayPayme
LambdaQueryWrapper<VtbVerificationSubject> lqw = new LambdaQueryWrapper<>();
lqw.eq(VtbVerificationSubject::getSupplierId,supplierId);
lqw.eq(VtbVerificationSubject::getPayFinishedFlag,0);
lqw.orderByAsc(VtbVerificationSubject::getId);
lqw.eq(VtbVerificationSubject::getEffectiveFlag,1);
List<VtbVerificationSubject> vtbVerificationSubjectList = verificationSubjectService.list(lqw);
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal payAmount = BigDecimal.ZERO;

Loading…
Cancel
Save