16 changed files with 806 additions and 7 deletions
@ -0,0 +1,106 @@ |
|||||
|
package com.qs.serve.modules.pay.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import com.qs.serve.common.util.CopierUtil; |
||||
|
import com.qs.serve.common.util.StringUtils; |
||||
|
import com.qs.serve.modules.pay.entity.dto.PayPaymentAmountDto; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import com.qs.serve.modules.pay.entity.so.PayPaymentSo; |
||||
|
import com.qs.serve.modules.pay.entity.bo.PayPaymentBo; |
||||
|
import com.qs.serve.modules.pay.entity.PayPayment; |
||||
|
import com.qs.serve.modules.pay.service.PayPaymentService; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 【支付】 |
||||
|
* @author YenHex |
||||
|
* @since 2022-12-15 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("pay/payment") |
||||
|
public class PayPaymentController { |
||||
|
|
||||
|
private PayPaymentService payPaymentService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 翻页 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page") |
||||
|
@PreAuthorize("hasRole('pay:payment:query')") |
||||
|
public R<PageVo<PayPayment>> getPage(PayPaymentSo param){ |
||||
|
PayPayment entity = CopierUtil.copy(param,new PayPayment()); |
||||
|
LambdaQueryWrapper<PayPayment> lqw = new LambdaQueryWrapper<>(entity); |
||||
|
PageUtil.startPage(); |
||||
|
List<PayPayment> list = payPaymentService.list(lqw); |
||||
|
return R.byPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* ID查询 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getById/{id}") |
||||
|
@SysLog(module = SystemModule.Payment, title = "支付", biz = BizType.QUERY) |
||||
|
@PreAuthorize("hasRole('pay:payment:query')") |
||||
|
public R<PayPayment> getById(@PathVariable("id") String id){ |
||||
|
PayPayment payPayment = payPaymentService.getById(id); |
||||
|
return R.ok(payPayment); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取客户支付金额 |
||||
|
* @param supplierId |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getSupplierAmount/{supplierId}") |
||||
|
public R<PayPaymentAmountDto> getSupplierAmount(@PathVariable("supplierId") Long supplierId){ |
||||
|
PayPaymentAmountDto amountDto = payPaymentService.getSupplierBalance(supplierId); |
||||
|
return R.ok(amountDto); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增支付 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/payment") |
||||
|
@SysLog(module = SystemModule.Payment, title = "支付", biz = BizType.INSERT) |
||||
|
@PreAuthorize("hasRole('pay:payment:insert')") |
||||
|
public R<PayPayment> save(@RequestBody @Valid PayPaymentBo param){ |
||||
|
PayPayment payPayment = payPaymentService.payment(param); |
||||
|
return R.ok(payPayment); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取消支付 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@DeleteMapping("/cancel/{id}") |
||||
|
@SysLog(module = SystemModule.Payment, title = "支付", biz = BizType.DELETE) |
||||
|
@PreAuthorize("hasRole('pay:payment:delete')") |
||||
|
public R<?> cancelById(@PathVariable("id") Long id){ |
||||
|
payPaymentService.cancel(id); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,112 @@ |
|||||
|
package com.qs.serve.modules.pay.entity; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 支付 实体类 |
||||
|
* @author YenHex |
||||
|
* @since 2022-12-15 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("pay_payment") |
||||
|
public class PayPayment implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 供应商id */ |
||||
|
@NotNull(message = "供应商id不能为空") |
||||
|
private Long supplierId; |
||||
|
|
||||
|
/** 供应商编码 */ |
||||
|
@NotBlank(message = "供应商编码不能为空") |
||||
|
@Length(max = 30,message = "供应商编码长度不能超过30字") |
||||
|
private String supplierCode; |
||||
|
|
||||
|
/** 供应商 */ |
||||
|
@NotBlank(message = "供应商不能为空") |
||||
|
@Length(max = 30,message = "供应商长度不能超过30字") |
||||
|
private String supplierName; |
||||
|
|
||||
|
/** 支付金额 */ |
||||
|
@NotNull(message = "支付金额不能为空") |
||||
|
private BigDecimal payAmount; |
||||
|
|
||||
|
/** 支付人id */ |
||||
|
@NotBlank(message = "支付人id不能为空") |
||||
|
@Length(max = 32,message = "支付人id长度不能超过32字") |
||||
|
private String userId; |
||||
|
|
||||
|
/** 支付人编码 */ |
||||
|
@NotBlank(message = "支付人编码不能为空") |
||||
|
@Length(max = 32,message = "支付人编码长度不能超过32字") |
||||
|
private String userCode; |
||||
|
|
||||
|
/** 支付人 */ |
||||
|
@NotBlank(message = "支付人不能为空") |
||||
|
@Length(max = 255,message = "支付人长度不能超过255字") |
||||
|
private String userName; |
||||
|
|
||||
|
/** 支付时间 */ |
||||
|
@NotNull(message = "支付时间不能为空") |
||||
|
@Length(max = 0,message = "支付时间长度不能超过0字") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private LocalDateTime payTime; |
||||
|
|
||||
|
/** 取消标识 */ |
||||
|
private Integer cancelFlag; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@Length(max = 255,message = "备注长度不能超过255字") |
||||
|
private String remark; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 最后更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 所属租户 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private String updateBy; |
||||
|
|
||||
|
/** 逻辑删除标记(0:显示;1:隐藏) */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String delFlag; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,116 @@ |
|||||
|
package com.qs.serve.modules.pay.entity; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 支付明细项 实体类 |
||||
|
* @author YenHex |
||||
|
* @since 2022-12-15 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("pay_payment_item") |
||||
|
public class PayPaymentItem implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 支付id */ |
||||
|
@NotNull(message = "支付id不能为空") |
||||
|
private Long paymentId; |
||||
|
|
||||
|
/** 供应商id */ |
||||
|
@NotNull(message = "供应商id不能为空") |
||||
|
private Long supplierId; |
||||
|
|
||||
|
/** 支付金额 */ |
||||
|
@NotNull(message = "支付金额不能为空") |
||||
|
private BigDecimal itemPayAmount; |
||||
|
|
||||
|
/** 核销id */ |
||||
|
@NotNull(message = "核销id不能为空") |
||||
|
private Long verificationId; |
||||
|
|
||||
|
/** 核销科目项id */ |
||||
|
@NotNull(message = "核销科目项id不能为空") |
||||
|
private Long verificationSubjectId; |
||||
|
|
||||
|
/** 费用申请id */ |
||||
|
@NotNull(message = "费用申请id不能为空") |
||||
|
private Long costApplyId; |
||||
|
|
||||
|
/** 活动id */ |
||||
|
@NotNull(message = "活动id不能为空") |
||||
|
private Long activityId; |
||||
|
|
||||
|
/** 活动编码 */ |
||||
|
@NotBlank(message = "活动编码不能为空") |
||||
|
@Length(max = 30,message = "活动编码长度不能超过30字") |
||||
|
private String activityCode; |
||||
|
|
||||
|
/** 科目id */ |
||||
|
@NotNull(message = "科目id不能为空") |
||||
|
private Long subjectId; |
||||
|
|
||||
|
/** 科目编码 */ |
||||
|
@NotBlank(message = "科目编码不能为空") |
||||
|
@Length(max = 50,message = "科目编码长度不能超过50字") |
||||
|
private String subjectCode; |
||||
|
|
||||
|
/** 科目名称 */ |
||||
|
@NotBlank(message = "科目名称不能为空") |
||||
|
@Length(max = 50,message = "科目名称长度不能超过50字") |
||||
|
private String subjectName; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@Length(max = 255,message = "备注长度不能超过255字") |
||||
|
private String remark; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 最后更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 所属租户 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private String updateBy; |
||||
|
|
||||
|
/** 逻辑删除标记(0:显示;1:隐藏) */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String delFlag; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,41 @@ |
|||||
|
package com.qs.serve.modules.pay.entity.bo; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.DecimalMin; |
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 支付 Bo |
||||
|
* @author YenHex |
||||
|
* @since 2022-12-15 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PayPaymentBo implements Serializable { |
||||
|
|
||||
|
/** 供应商id */ |
||||
|
@NotNull(message = "供应商id不能为空") |
||||
|
private Long supplierId; |
||||
|
|
||||
|
/** 支付金额 */ |
||||
|
@DecimalMin(value = "0.01",message = "支付金额必须大于0元") |
||||
|
@NotNull(message = "支付金额不能为空") |
||||
|
private BigDecimal payAmount; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@Length(max = 255,message = "备注长度不能超过255字") |
||||
|
private String remark; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,33 @@ |
|||||
|
package com.qs.serve.modules.pay.entity.dto; |
||||
|
|
||||
|
import com.qs.serve.modules.vtb.entity.VtbVerificationSubject; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2022/12/15 |
||||
|
*/ |
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
public class PayPaymentAmountDto { |
||||
|
|
||||
|
/** |
||||
|
* 统计支付金额 |
||||
|
*/ |
||||
|
private BigDecimal totalAmount; |
||||
|
|
||||
|
/** |
||||
|
* 已支付金额 |
||||
|
*/ |
||||
|
private BigDecimal hasPayment; |
||||
|
|
||||
|
/** |
||||
|
* 可支付核销明细 |
||||
|
*/ |
||||
|
private List<VtbVerificationSubject> verificationSubjectList; |
||||
|
|
||||
|
} |
@ -0,0 +1,84 @@ |
|||||
|
package com.qs.serve.modules.pay.entity.so; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 支付 查询参数 |
||||
|
* @author YenHex |
||||
|
* @since 2022-12-15 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PayPaymentSo implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
private Long id; |
||||
|
|
||||
|
/** 供应商id */ |
||||
|
private Long supplierId; |
||||
|
|
||||
|
/** 供应商编码 */ |
||||
|
private String supplierCode; |
||||
|
|
||||
|
/** 供应商 */ |
||||
|
private String supplierName; |
||||
|
|
||||
|
/** 支付金额 */ |
||||
|
private BigDecimal payAmount; |
||||
|
|
||||
|
/** 支付人id */ |
||||
|
private String userId; |
||||
|
|
||||
|
/** 支付人编码 */ |
||||
|
private String userCode; |
||||
|
|
||||
|
/** 支付人 */ |
||||
|
private String userName; |
||||
|
|
||||
|
/** 支付时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
private LocalDateTime payTime; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
private String remark; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 最后更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 所属租户 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
private String updateBy; |
||||
|
|
||||
|
/** 逻辑删除标记(0:显示;1:隐藏) */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String delFlag; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.pay.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.pay.entity.PayPaymentItem; |
||||
|
|
||||
|
/** |
||||
|
* 支付明细项 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2022-12-15 |
||||
|
*/ |
||||
|
public interface PayPaymentItemMapper extends BaseMapper<PayPaymentItem> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.pay.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.pay.entity.PayPayment; |
||||
|
|
||||
|
/** |
||||
|
* 支付 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2022-12-15 |
||||
|
*/ |
||||
|
public interface PayPaymentMapper extends BaseMapper<PayPayment> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,21 @@ |
|||||
|
package com.qs.serve.modules.pay.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.pay.entity.PayPaymentItem; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 支付明细项 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2022-12-15 |
||||
|
*/ |
||||
|
public interface PayPaymentItemService extends IService<PayPaymentItem> { |
||||
|
|
||||
|
List<PayPaymentItem> listByVerSubjectId(Long versubId); |
||||
|
|
||||
|
|
||||
|
List<PayPaymentItem> listByPaymentId(Long paymentId); |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,36 @@ |
|||||
|
package com.qs.serve.modules.pay.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.pay.entity.PayPayment; |
||||
|
import com.qs.serve.modules.pay.entity.bo.PayPaymentBo; |
||||
|
import com.qs.serve.modules.pay.entity.dto.PayPaymentAmountDto; |
||||
|
|
||||
|
/** |
||||
|
* 支付 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2022-12-15 |
||||
|
*/ |
||||
|
public interface PayPaymentService extends IService<PayPayment> { |
||||
|
|
||||
|
/** |
||||
|
* 支付 |
||||
|
* @param paymentBo |
||||
|
* @return |
||||
|
*/ |
||||
|
PayPayment payment(PayPaymentBo paymentBo); |
||||
|
|
||||
|
/** |
||||
|
* 取消支付 |
||||
|
* @param id |
||||
|
*/ |
||||
|
void cancel(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 获取供应商需支付明细 |
||||
|
* @param supplierId |
||||
|
* @return |
||||
|
*/ |
||||
|
PayPaymentAmountDto getSupplierBalance(Long supplierId); |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,39 @@ |
|||||
|
package com.qs.serve.modules.pay.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.qs.serve.modules.pay.entity.PayPaymentItem; |
||||
|
import com.qs.serve.modules.pay.service.PayPaymentItemService; |
||||
|
import com.qs.serve.modules.pay.mapper.PayPaymentItemMapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 支付明细项 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2022-12-15 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class PayPaymentItemServiceImpl extends ServiceImpl<PayPaymentItemMapper,PayPaymentItem> implements PayPaymentItemService { |
||||
|
|
||||
|
@Override |
||||
|
public List<PayPaymentItem> listByVerSubjectId(Long versubId) { |
||||
|
LambdaQueryWrapper<PayPaymentItem> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.eq(PayPaymentItem::getVerificationSubjectId,versubId); |
||||
|
return this.list(lqw); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<PayPaymentItem> listByPaymentId(Long paymentId) { |
||||
|
LambdaQueryWrapper<PayPaymentItem> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.eq(PayPaymentItem::getPaymentId,paymentId); |
||||
|
return this.list(lqw); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,183 @@ |
|||||
|
package com.qs.serve.modules.pay.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.qs.serve.common.util.Assert; |
||||
|
import com.qs.serve.common.util.AuthContextUtils; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
||||
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
||||
|
import com.qs.serve.modules.pay.entity.PayPaymentItem; |
||||
|
import com.qs.serve.modules.pay.entity.bo.PayPaymentBo; |
||||
|
import com.qs.serve.modules.pay.entity.dto.PayPaymentAmountDto; |
||||
|
import com.qs.serve.modules.pay.service.PayPaymentItemService; |
||||
|
import com.qs.serve.modules.sys.entity.SysUser; |
||||
|
import com.qs.serve.modules.sys.service.SysUserService; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsActivity; |
||||
|
import com.qs.serve.modules.tbs.service.TbsActivityService; |
||||
|
import com.qs.serve.modules.vtb.entity.VtbVerificationSubject; |
||||
|
import com.qs.serve.modules.vtb.service.VtbVerificationSubjectService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.qs.serve.modules.pay.entity.PayPayment; |
||||
|
import com.qs.serve.modules.pay.service.PayPaymentService; |
||||
|
import com.qs.serve.modules.pay.mapper.PayPaymentMapper; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 支付 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2022-12-15 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class PayPaymentServiceImpl extends ServiceImpl<PayPaymentMapper,PayPayment> implements PayPaymentService { |
||||
|
|
||||
|
private SysUserService sysUserService; |
||||
|
private BmsSupplierService supplierService; |
||||
|
private PayPaymentItemService paymentItemService; |
||||
|
private VtbVerificationSubjectService verificationSubjectService; |
||||
|
private TbsActivityService activityService; |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public PayPayment payment(PayPaymentBo paymentBo) { |
||||
|
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); |
||||
|
PayPaymentAmountDto amountDto = this.getSupplierBalance(paymentBo.getSupplierId()); |
||||
|
BigDecimal allowAmount = amountDto.getTotalAmount().subtract(amountDto.getHasPayment()); |
||||
|
BmsSupplier supplier = supplierService.getById(paymentBo.getSupplierId()); |
||||
|
//本次支付金额
|
||||
|
BigDecimal currentAmount = paymentBo.getPayAmount(); |
||||
|
//本次支付余额
|
||||
|
BigDecimal currentBalance = paymentBo.getPayAmount(); |
||||
|
if(currentAmount.compareTo(allowAmount)>0){ |
||||
|
Assert.throwEx("支付不能超过待支付金额!"); |
||||
|
} |
||||
|
List<VtbVerificationSubject> verificationSubjectList = amountDto.getVerificationSubjectList(); |
||||
|
List<PayPaymentItem> paymentItemList = new ArrayList<>(); |
||||
|
List<VtbVerificationSubject> verificationSubjectUpdateList = new ArrayList<>(); |
||||
|
for (VtbVerificationSubject verificationSubject : verificationSubjectList) { |
||||
|
//统计历史支付金额
|
||||
|
BigDecimal hisPayAmount = BigDecimal.ZERO; |
||||
|
List<PayPaymentItem> payPaymentItems = paymentItemService.listByVerSubjectId(verificationSubject.getId()); |
||||
|
for (PayPaymentItem paymentItem : payPaymentItems) { |
||||
|
hisPayAmount = hisPayAmount.add(paymentItem.getItemPayAmount()); |
||||
|
} |
||||
|
//需支付
|
||||
|
BigDecimal shouldPay = verificationSubject.getUsedAmount().subtract(hisPayAmount); |
||||
|
if(currentBalance.compareTo(shouldPay)>0){ |
||||
|
currentBalance = currentBalance.subtract(shouldPay); |
||||
|
}else { |
||||
|
currentBalance = BigDecimal.ZERO; |
||||
|
} |
||||
|
PayPaymentItem paymentItem = new PayPaymentItem(); |
||||
|
paymentItem.setSupplierId(paymentBo.getSupplierId()); |
||||
|
paymentItem.setItemPayAmount(shouldPay); |
||||
|
paymentItem.setVerificationId(verificationSubject.getVerificationId()); |
||||
|
paymentItem.setVerificationSubjectId(verificationSubject.getId()); |
||||
|
paymentItem.setCostApplyId(verificationSubject.getCostApplyId()); |
||||
|
paymentItem.setActivityId(verificationSubject.getActivityId()); |
||||
|
paymentItem.setSubjectId(verificationSubject.getSubjectId()); |
||||
|
paymentItem.setSubjectCode(verificationSubject.getSubjectCode()); |
||||
|
paymentItem.setSubjectName(verificationSubject.getSubjectName()); |
||||
|
paymentItemList.add(paymentItem); |
||||
|
//更新核销科目余额
|
||||
|
BigDecimal payAmountOfVer = verificationSubject.getPayAmount().add(shouldPay); |
||||
|
VtbVerificationSubject subjectParam = new VtbVerificationSubject(); |
||||
|
subjectParam.setId(verificationSubject.getId()); |
||||
|
subjectParam.setPayAmount(payAmountOfVer); |
||||
|
if(verificationSubject.getUsedAmount().compareTo(payAmountOfVer)==0){ |
||||
|
subjectParam.setPayFinishedFlag(1); |
||||
|
} |
||||
|
verificationSubjectUpdateList.add(subjectParam); |
||||
|
if(currentBalance.compareTo(BigDecimal.ZERO)==0){ |
||||
|
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 |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void cancel(Long id) { |
||||
|
List<PayPaymentItem> paymentItemList = paymentItemService.listByPaymentId(id); |
||||
|
List<Long> paymentItemIds = paymentItemList.stream().map(PayPaymentItem::getId) |
||||
|
.distinct().collect(Collectors.toList()); |
||||
|
List<Long> verSubjectIds = paymentItemList.stream().map(PayPaymentItem::getVerificationSubjectId) |
||||
|
.distinct().collect(Collectors.toList()); |
||||
|
List<VtbVerificationSubject> verificationSubjectList = verificationSubjectService.listByIds(verSubjectIds); |
||||
|
for (VtbVerificationSubject verificationSubject : verificationSubjectList) { |
||||
|
for (PayPaymentItem paymentItem : paymentItemList) { |
||||
|
if(verificationSubject.getId().equals(paymentItem.getVerificationSubjectId())){ |
||||
|
BigDecimal payAmount = verificationSubject.getPayAmount().subtract(paymentItem.getItemPayAmount()); |
||||
|
verificationSubject.setPayAmount(payAmount); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
List<VtbVerificationSubject> verificationSubjectUpdateList = verificationSubjectList.stream().map(obj->{ |
||||
|
VtbVerificationSubject param = new VtbVerificationSubject(); |
||||
|
param.setId(obj.getId()); |
||||
|
param.setPayAmount(obj.getPayAmount()); |
||||
|
param.setEffectiveFlag(0); |
||||
|
return param; |
||||
|
}).collect(Collectors.toList()); |
||||
|
//更新数据
|
||||
|
PayPayment payPayment = new PayPayment(); |
||||
|
payPayment.setId(id); |
||||
|
payPayment.setCancelFlag(1); |
||||
|
this.updateById(payPayment); |
||||
|
paymentItemService.removeBatchByIds(paymentItemIds); |
||||
|
verificationSubjectService.updateBatchById(verificationSubjectUpdateList); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public PayPaymentAmountDto getSupplierBalance(Long supplierId) { |
||||
|
LambdaQueryWrapper<VtbVerificationSubject> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.eq(VtbVerificationSubject::getSupplierId,supplierId); |
||||
|
lqw.eq(VtbVerificationSubject::getPayFinishedFlag,0); |
||||
|
lqw.orderByAsc(VtbVerificationSubject::getId); |
||||
|
List<VtbVerificationSubject> vtbVerificationSubjectList = verificationSubjectService.list(lqw); |
||||
|
BigDecimal totalAmount = BigDecimal.ZERO; |
||||
|
BigDecimal payAmount = BigDecimal.ZERO; |
||||
|
for (VtbVerificationSubject verificationSubject : vtbVerificationSubjectList) { |
||||
|
totalAmount = totalAmount.add(verificationSubject.getUsedAmount()); |
||||
|
payAmount = payAmount.add(verificationSubject.getPayAmount()); |
||||
|
} |
||||
|
PayPaymentAmountDto amountDto = new PayPaymentAmountDto(totalAmount,payAmount,vtbVerificationSubjectList); |
||||
|
return amountDto; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
Loading…
Reference in new issue