From: Tang Cheng Date: Tue, 9 Apr 2019 09:47:32 +0000 (+0800) Subject: 增加了paydtl 处理逻辑 X-Git-Tag: 1.0.0^2~319 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=707edaaafa2efece037797332f5f5da02b7d52ea;p=epayment%2Ffood_payapi.git 增加了paydtl 处理逻辑 --- diff --git a/src/main/java/com/supwisdom/dlpay/consume/PayDtlBuilder.java b/src/main/java/com/supwisdom/dlpay/consume/PayDtlBuilder.java new file mode 100644 index 00000000..8c0498ac --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/consume/PayDtlBuilder.java @@ -0,0 +1,86 @@ +package com.supwisdom.dlpay.consume; + +import com.supwisdom.dlpay.consume.domain.TAccount; +import com.supwisdom.dlpay.consume.domain.TPerson; +import com.supwisdom.dlpay.framework.service.PersonPayService; +import com.supwisdom.dlpay.framework.util.TradeDict; + +import java.util.ArrayList; +import java.util.List; + +public class PayDtlBuilder { + public static class PayDetail { + private String accNo; + private String accName; + private Double amount; + private String direction; + private String summary; + } + + private TPerson person; + private TAccount account; + private String direction; + + private Double payAmount; + + private String summary; + + private List detail; + + public static PayDtlBuilder newBuilder() { + return new PayDtlBuilder(); + } + + private PayDtlBuilder() { + this.detail = new ArrayList<>(); + } + + public PayDtlBuilder person(TPerson per, TAccount acc, String direction) { + this.person = per; + this.account = acc; + this.direction = direction; + return this; + } + + public PayDtlBuilder setSummary(String s) { + this.summary = s; + return this; + } + + public PayDtlBuilder setTransDatetime(String transDate ,String transTime) { + + return this; + } + + public Boolean done(PersonPayService service) { + if (this.detail.size() == 0) { + return false; + } + this.payAmount = 0.0; + + for (PayDetail d : detail) { + this.payAmount += d.amount; + } + if (this.payAmount > this.account.getBalance()) { + return false; + } + service.process(this); + return true; + } + + + public PayDtlBuilder addSubDtl(String accNo, Double amount, String summary) { + PayDetail dtl = new PayDetail(); + dtl.accNo = accNo; + dtl.accName = ""; + dtl.amount = amount; + if (this.direction.equals(TradeDict.TRANS_DIRECTION_CREDIT)) { + dtl.direction = TradeDict.TRANS_DIRECTION_DEBIT; + } else { + dtl.direction = TradeDict.TRANS_DIRECTION_CREDIT; + } + dtl.summary = summary; + this.detail.add(dtl); + return this; + } +} diff --git a/src/main/java/com/supwisdom/dlpay/consume/domain/TPayCreditDtl.java b/src/main/java/com/supwisdom/dlpay/consume/domain/TPayCreditDtl.java new file mode 100644 index 00000000..9a2e3fa8 --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/consume/domain/TPayCreditDtl.java @@ -0,0 +1,33 @@ +package com.supwisdom.dlpay.consume.domain; + +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "t_paycreditdtl") +public class TPayCreditDtl { + private String refno; + private Integer rowno; + /** + * 贷方账号 + */ + private String accNo; + private String accSubjNo; + + private String otherAccNo; + + /** + * 发生金额 + */ + private Double amount; + + /** + * 交易方向 credit, debit + */ + private String direction; + + /** + * 交易摘要 + */ + private String summary; +} diff --git a/src/main/java/com/supwisdom/dlpay/consume/domain/TPaydtl.java b/src/main/java/com/supwisdom/dlpay/consume/domain/TPaydtl.java new file mode 100644 index 00000000..e2e79e7b --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/consume/domain/TPaydtl.java @@ -0,0 +1,83 @@ +package com.supwisdom.dlpay.consume.domain; + +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "t_paydtl") +public class TPaydtl { + private String refno; + /** + * 交易关联个人信息 + */ + private String userid; + private String name; + /** + * 记账日期 + */ + private String accDate; + /** + * 交易发生日期 + */ + private String transDate; + private String transTime; + + /** + * 交易代码 + */ + private Integer transCode; + private String transName; + /** + * 可选值 init, wip, success, failed + */ + private String status; + /** + * 交易总金额 + */ + private Double amount; + /** + * 交易前个人账户余额 + */ + private Double befBalance; + /** + * 借方账号 + */ + private String accNo; + private String accName; + /** + * 借方科目号 + */ + private String accSubjNo; + + /** + * 交易方向 credit, debit + */ + private String direction; + /** + * 结算标志 none, ok + */ + private String settleStatus; + /** + * 结算日期 + */ + private String settleDate; + /** + * 可选值 none, cancel, reversed + */ + private String reverseFlag; + /** + * 当有撤销交易时,撤销金额填写 + */ + private Double reverseAmount; + + /** + * 交易说明 + */ + private String describe; + + /** + * 交易字表 + */ + private String detailType; + +} diff --git a/src/main/java/com/supwisdom/dlpay/framework/service/PersonPayService.java b/src/main/java/com/supwisdom/dlpay/framework/service/PersonPayService.java new file mode 100644 index 00000000..5e7ace62 --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/framework/service/PersonPayService.java @@ -0,0 +1,10 @@ +package com.supwisdom.dlpay.framework.service; + +import com.supwisdom.dlpay.consume.PayDtlBuilder; +import com.supwisdom.dlpay.consume.domain.TPaydtl; +import org.springframework.stereotype.Service; + +@Service +public interface PersonPayService { + TPaydtl process(PayDtlBuilder builder); +} diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java b/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java index 685ad9f2..b570823e 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java +++ b/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java @@ -25,6 +25,12 @@ public class TradeDict { public static final String DTL_STATUS_FAIL = "fail"; public static final String DTL_STATUS_CANCEL = "cancel"; + /** + * 交易借方 + */ + public static final String TRANS_DIRECTION_CREDIT = "credit"; + public static final String TRANS_DIRECTION_DEBIT = "debit"; + /** * 科目定义 subjno * 2004 - 商户科目