Browse Source

支付功能,不再支付

mssql
Yen 3 years ago
parent
commit
f86cd4a9ee
  1. 12
      src/main/java/com/qs/serve/modules/pay/common/PaymentType.java
  2. 22
      src/main/java/com/qs/serve/modules/pay/controller/PayPaymentController.java
  3. 8
      src/main/java/com/qs/serve/modules/pay/entity/PayPayment.java
  4. 7
      src/main/java/com/qs/serve/modules/pay/entity/PayPaymentItem.java
  5. 9
      src/main/java/com/qs/serve/modules/pay/entity/bo/PayPaymentBo.java
  6. 51
      src/main/java/com/qs/serve/modules/pay/entity/so/PayPaymentSo.java
  7. 94
      src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java
  8. 1
      src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyController.java
  9. 2
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java

12
src/main/java/com/qs/serve/modules/pay/common/PaymentType.java

@ -0,0 +1,12 @@
package com.qs.serve.modules.pay.common;
/**
* @author YenHex
* @since 2022/12/16
*/
public interface PaymentType {
String PAYMENT = "pay";
String UN_PAYMENT = "unPay";
}

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

@ -9,7 +9,9 @@ import com.qs.serve.common.model.enums.SystemModule;
import com.qs.serve.common.util.PageUtil; import com.qs.serve.common.util.PageUtil;
import com.qs.serve.common.util.CopierUtil; import com.qs.serve.common.util.CopierUtil;
import com.qs.serve.common.util.StringUtils; import com.qs.serve.common.util.StringUtils;
import com.qs.serve.modules.pay.entity.PayPaymentItem;
import com.qs.serve.modules.pay.entity.dto.PayPaymentAmountDto; import com.qs.serve.modules.pay.entity.dto.PayPaymentAmountDto;
import com.qs.serve.modules.pay.service.PayPaymentItemService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -35,6 +37,7 @@ import java.util.List;
public class PayPaymentController { public class PayPaymentController {
private PayPaymentService payPaymentService; private PayPaymentService payPaymentService;
private PayPaymentItemService paymentItemService;
/** /**
@ -47,11 +50,30 @@ public class PayPaymentController {
public R<PageVo<PayPayment>> getPage(PayPaymentSo param){ public R<PageVo<PayPayment>> getPage(PayPaymentSo param){
PayPayment entity = CopierUtil.copy(param,new PayPayment()); PayPayment entity = CopierUtil.copy(param,new PayPayment());
LambdaQueryWrapper<PayPayment> lqw = new LambdaQueryWrapper<>(entity); LambdaQueryWrapper<PayPayment> lqw = new LambdaQueryWrapper<>(entity);
if(param.getQueryStartTime()!=null){
lqw.ge(PayPayment::getPayTime,param.getQueryStartTime());
}
if(param.getQueryEndTime()!=null){
lqw.le(PayPayment::getPayTime,param.getQueryEndTime());
}
PageUtil.startPage(); PageUtil.startPage();
List<PayPayment> list = payPaymentService.list(lqw); List<PayPayment> list = payPaymentService.list(lqw);
return R.byPageHelperList(list); return R.byPageHelperList(list);
} }
/**
* 详情列表
* @param id
* @return
*/
@GetMapping("/listDetails/{id}")
@PreAuthorize("hasRole('pay:payment:query')")
public R<List<PayPaymentItem>> listDetails(@PathVariable("id") Long id){
List<PayPaymentItem> list= paymentItemService.listByPaymentId(id);
return R.ok(list);
}
/** /**
* ID查询 * ID查询
* @param id * @param id

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

@ -31,6 +31,13 @@ public class PayPayment implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Long id; private Long id;
/**
* 支付类型
* pay - 支付
* unPay - 不再支付
**/
private String payType;
/** 供应商id */ /** 供应商id */
@NotNull(message = "供应商id不能为空") @NotNull(message = "供应商id不能为空")
private Long supplierId; private Long supplierId;
@ -43,6 +50,7 @@ public class PayPayment implements Serializable {
/** 供应商 */ /** 供应商 */
@NotBlank(message = "供应商不能为空") @NotBlank(message = "供应商不能为空")
@Length(max = 30,message = "供应商长度不能超过30字") @Length(max = 30,message = "供应商长度不能超过30字")
@TableField(condition = SqlCondition.LIKE)
private String supplierName; private String supplierName;
/** 支付金额 */ /** 支付金额 */

7
src/main/java/com/qs/serve/modules/pay/entity/PayPaymentItem.java

@ -31,6 +31,13 @@ public class PayPaymentItem implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Long id; private Long id;
/**
* 支付类型
* pay - 支付
* unPay - 不再支付
**/
private String payType;
/** 支付id */ /** 支付id */
@NotNull(message = "支付id不能为空") @NotNull(message = "支付id不能为空")
private Long paymentId; private Long paymentId;

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

@ -40,5 +40,14 @@ public class PayPaymentBo implements Serializable {
@Length(max = 255,message = "备注长度不能超过255字") @Length(max = 255,message = "备注长度不能超过255字")
private String remark; private String remark;
/**
* 支付类型
* pay - 支付
* unPay - 不再支付
**/
@NotNull(message = "支付类型不能为空")
private String payType;
} }

51
src/main/java/com/qs/serve/modules/pay/entity/so/PayPaymentSo.java

@ -25,60 +25,17 @@ public class PayPaymentSo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 供应商id */
private Long supplierId;
/** 供应商编码 */
private String supplierCode;
/** 供应商 */ /** 供应商 */
private String supplierName; private String supplierName;
/** 支付金额 */ /** 开始时间 */
private BigDecimal payAmount;
/** 支付人id */
private String userId;
/** 支付人编码 */
private String userCode;
/** 支付人 */
private String userName;
/** 支付时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime payTime; private LocalDateTime queryStartTime;
/** 备注 */ /** 结束时间 */
private String remark;
/** 创建时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
/** 最后更新时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime; private LocalDateTime queryEndTime;
/** 所属租户 */
@JsonIgnore
@JsonProperty
private String tenantId;
/** 创建人 */
private String createBy;
/** 更新人 */
private String updateBy;
/** 逻辑删除标记(0:显示;1:隐藏) */
@JsonIgnore
@JsonProperty
private String delFlag;
} }

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

@ -6,6 +6,7 @@ import com.qs.serve.common.util.Assert;
import com.qs.serve.common.util.AuthContextUtils; import com.qs.serve.common.util.AuthContextUtils;
import com.qs.serve.modules.bms.entity.BmsSupplier; import com.qs.serve.modules.bms.entity.BmsSupplier;
import com.qs.serve.modules.bms.service.BmsSupplierService; import com.qs.serve.modules.bms.service.BmsSupplierService;
import com.qs.serve.modules.pay.common.PaymentType;
import com.qs.serve.modules.pay.entity.PayPaymentItem; import com.qs.serve.modules.pay.entity.PayPaymentItem;
import com.qs.serve.modules.pay.entity.bo.PayPaymentBo; import com.qs.serve.modules.pay.entity.bo.PayPaymentBo;
import com.qs.serve.modules.pay.entity.dto.PayPaymentAmountDto; import com.qs.serve.modules.pay.entity.dto.PayPaymentAmountDto;
@ -18,6 +19,7 @@ import com.qs.serve.modules.vtb.entity.VtbVerificationSubject;
import com.qs.serve.modules.vtb.service.VtbVerificationSubjectService; import com.qs.serve.modules.vtb.service.VtbVerificationSubjectService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.qs.serve.modules.pay.entity.PayPayment; import com.qs.serve.modules.pay.entity.PayPayment;
import com.qs.serve.modules.pay.service.PayPaymentService; import com.qs.serve.modules.pay.service.PayPaymentService;
@ -49,6 +51,10 @@ public class PayPaymentServiceImpl extends ServiceImpl<PayPaymentMapper,PayPayme
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public PayPayment payment(PayPaymentBo paymentBo) { public PayPayment payment(PayPaymentBo paymentBo) {
String payType = paymentBo.getPayType();
if(!payType.equals(PaymentType.PAYMENT)&&!payType.equals(PaymentType.UN_PAYMENT)){
Assert.throwEx("param err P1 ");
}
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId());
PayPaymentAmountDto amountDto = this.getSupplierBalance(paymentBo.getSupplierId()); PayPaymentAmountDto amountDto = this.getSupplierBalance(paymentBo.getSupplierId());
BigDecimal allowAmount = amountDto.getTotalAmount().subtract(amountDto.getHasPayment()); BigDecimal allowAmount = amountDto.getTotalAmount().subtract(amountDto.getHasPayment());
@ -64,6 +70,52 @@ public class PayPaymentServiceImpl extends ServiceImpl<PayPaymentMapper,PayPayme
List<PayPaymentItem> paymentItemList = new ArrayList<>(); List<PayPaymentItem> paymentItemList = new ArrayList<>();
List<VtbVerificationSubject> verificationSubjectUpdateList = new ArrayList<>(); List<VtbVerificationSubject> verificationSubjectUpdateList = new ArrayList<>();
for (VtbVerificationSubject verificationSubject : verificationSubjectList) { for (VtbVerificationSubject verificationSubject : verificationSubjectList) {
currentBalance = this.buildPaymentItems(paymentBo, currentBalance, paymentItemList, verificationSubjectUpdateList, verificationSubject);
if(currentBalance.compareTo(BigDecimal.ZERO)==0){
break;
}
}
PayPayment payPayment = new PayPayment();
payPayment.setPayType(payType);
payPayment.setSupplierId(paymentBo.getSupplierId());
payPayment.setSupplierCode(supplier.getCode());
payPayment.setSupplierName(supplier.getName());
payPayment.setPayAmount(paymentBo.getPayAmount());
payPayment.setUserId(sysUser.getId());
payPayment.setUserCode(sysUser.getCode());
payPayment.setUserName(sysUser.getName());
payPayment.setRemark(paymentBo.getRemark());
payPayment.setPayTime(LocalDateTime.now());
payPayment.setErpCode(paymentBo.getErpCode());
this.save(payPayment);
List<Long> actIds = paymentItemList.stream().map(PayPaymentItem::getActivityId).distinct().collect(Collectors.toList());
//关联活动编码
List<TbsActivity> activityList = activityService.listByIds(actIds);
for (PayPaymentItem paymentItem : paymentItemList) {
for (TbsActivity activity : activityList) {
if(activity.getId().equals(paymentItem.getActivityId())){
paymentItem.setActivityCode(activity.getActivityCode());
break;
}
}
paymentItem.setPaymentId(payPayment.getId());
}
verificationSubjectService.updateBatchById(verificationSubjectUpdateList);
paymentItemService.saveBatch(paymentItemList);
return payPayment;
}
/**
* 构建支付明细
* @param paymentBo
* @param currentBalance
* @param paymentItemList
* @param verificationSubjectUpdateList
* @param verificationSubject
* @return currentBalance 本次支付余额
*/
@NotNull
private BigDecimal buildPaymentItems(PayPaymentBo paymentBo, BigDecimal currentBalance, List<PayPaymentItem> paymentItemList, List<VtbVerificationSubject> verificationSubjectUpdateList, VtbVerificationSubject verificationSubject) {
//统计历史支付金额 //统计历史支付金额
BigDecimal hisPayAmount = BigDecimal.ZERO; BigDecimal hisPayAmount = BigDecimal.ZERO;
List<PayPaymentItem> payPaymentItems = paymentItemService.listByVerSubjectId(verificationSubject.getId()); List<PayPaymentItem> payPaymentItems = paymentItemService.listByVerSubjectId(verificationSubject.getId());
@ -82,6 +134,7 @@ public class PayPaymentServiceImpl extends ServiceImpl<PayPaymentMapper,PayPayme
currentBalance = BigDecimal.ZERO; currentBalance = BigDecimal.ZERO;
} }
PayPaymentItem paymentItem = new PayPaymentItem(); PayPaymentItem paymentItem = new PayPaymentItem();
paymentItem.setPayType(paymentBo.getPayType());
paymentItem.setSupplierId(paymentBo.getSupplierId()); paymentItem.setSupplierId(paymentBo.getSupplierId());
paymentItem.setItemPayAmount(currentItemPay); paymentItem.setItemPayAmount(currentItemPay);
paymentItem.setVerificationId(verificationSubject.getVerificationId()); paymentItem.setVerificationId(verificationSubject.getVerificationId());
@ -101,41 +154,16 @@ public class PayPaymentServiceImpl extends ServiceImpl<PayPaymentMapper,PayPayme
subjectParam.setPayFinishedFlag(1); subjectParam.setPayFinishedFlag(1);
} }
verificationSubjectUpdateList.add(subjectParam); verificationSubjectUpdateList.add(subjectParam);
if(currentBalance.compareTo(BigDecimal.ZERO)==0){ return currentBalance;
break;
}
}
PayPayment payPayment = new PayPayment();
payPayment.setSupplierId(paymentBo.getSupplierId());
payPayment.setSupplierCode(supplier.getCode());
payPayment.setSupplierName(supplier.getName());
payPayment.setPayAmount(paymentBo.getPayAmount());
payPayment.setUserId(sysUser.getId());
payPayment.setUserCode(sysUser.getCode());
payPayment.setUserName(sysUser.getName());
payPayment.setRemark(paymentBo.getRemark());
payPayment.setPayTime(LocalDateTime.now());
this.save(payPayment);
List<Long> actIds = paymentItemList.stream().map(PayPaymentItem::getActivityId).distinct().collect(Collectors.toList());
//关联活动编码
List<TbsActivity> activityList = activityService.listByIds(actIds);
for (PayPaymentItem paymentItem : paymentItemList) {
for (TbsActivity activity : activityList) {
if(activity.getId().equals(paymentItem.getActivityId())){
paymentItem.setActivityCode(activity.getActivityCode());
break;
}
}
paymentItem.setPaymentId(payPayment.getId());
}
verificationSubjectService.updateBatchById(verificationSubjectUpdateList);
paymentItemService.saveBatch(paymentItemList);
return payPayment;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void cancel(Long id) { public void cancel(Long id) {
PayPayment dbPay = this.getById(id);
if(dbPay.getCancelFlag().equals(1)){
Assert.throwEx("已取消,请勿重复提交");
}
List<PayPaymentItem> paymentItemList = paymentItemService.listByPaymentId(id); List<PayPaymentItem> paymentItemList = paymentItemService.listByPaymentId(id);
List<Long> paymentItemIds = paymentItemList.stream().map(PayPaymentItem::getId) List<Long> paymentItemIds = paymentItemList.stream().map(PayPaymentItem::getId)
.distinct().collect(Collectors.toList()); .distinct().collect(Collectors.toList());
@ -174,12 +202,12 @@ public class PayPaymentServiceImpl extends ServiceImpl<PayPaymentMapper,PayPayme
lqw.eq(VtbVerificationSubject::getEffectiveFlag,1); lqw.eq(VtbVerificationSubject::getEffectiveFlag,1);
List<VtbVerificationSubject> vtbVerificationSubjectList = verificationSubjectService.list(lqw); List<VtbVerificationSubject> vtbVerificationSubjectList = verificationSubjectService.list(lqw);
BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal payAmount = BigDecimal.ZERO; BigDecimal hasAmount = BigDecimal.ZERO;
for (VtbVerificationSubject verificationSubject : vtbVerificationSubjectList) { for (VtbVerificationSubject verificationSubject : vtbVerificationSubjectList) {
totalAmount = totalAmount.add(verificationSubject.getUsedAmount()); totalAmount = totalAmount.add(verificationSubject.getUsedAmount());
payAmount = payAmount.add(verificationSubject.getPayAmount()); hasAmount = hasAmount.add(verificationSubject.getPayAmount());
} }
PayPaymentAmountDto amountDto = new PayPaymentAmountDto(totalAmount,payAmount,vtbVerificationSubjectList); PayPaymentAmountDto amountDto = new PayPaymentAmountDto(totalAmount,hasAmount,vtbVerificationSubjectList);
return amountDto; return amountDto;
} }

1
src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyController.java

@ -349,6 +349,7 @@ public class TbsCostApplyController {
apply.setId(costApply.getId()); apply.setId(costApply.getId());
apply.setChargeState(TbsCostApplyState.State_2_actioning.getCode()); apply.setChargeState(TbsCostApplyState.State_2_actioning.getCode());
tbsCostApplyService.updateById(apply); tbsCostApplyService.updateById(apply);
return R.ok();
}else if ("stop".equals(flag)){ }else if ("stop".equals(flag)){
TbsCostApply apply = new TbsCostApply(); TbsCostApply apply = new TbsCostApply();
apply.setId(costApply.getId()); apply.setId(costApply.getId());

2
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java

@ -252,7 +252,7 @@ public class TbsActivityServiceImpl extends ServiceImpl<TbsActivityMapper,TbsAct
TbsActivityCenterGoods centerGoods = new TbsActivityCenterGoods(); TbsActivityCenterGoods centerGoods = new TbsActivityCenterGoods();
centerGoods.setSupplierId(Long.parseLong(supplier.getId())); centerGoods.setSupplierId(Long.parseLong(supplier.getId()));
centerGoods.setSupplierCode(supplier.getCode()); centerGoods.setSupplierCode(supplier.getCode());
centerGoods.setSubjectName(supplier.getName()); centerGoods.setSupplierName(supplier.getName());
centerGoods.setCenterGoodsCode(activity.getActivityCode()+"_"+(i+1)); centerGoods.setCenterGoodsCode(activity.getActivityCode()+"_"+(i+1));
centerGoods.setTmpUk(centerGoodsBo.getTmpUk()); centerGoods.setTmpUk(centerGoodsBo.getTmpUk());
//设置成本中心 //设置成本中心

Loading…
Cancel
Save