优化并修改bug
authorTang Cheng <cheng.tang@supwisdom.com>
Fri, 18 Oct 2019 02:31:01 +0000 (10:31 +0800)
committerTang Cheng <cheng.tang@supwisdom.com>
Wed, 4 Dec 2019 01:30:58 +0000 (09:30 +0800)
payapi-sdk/src/test/java/com/supwisdom/dlpay/paysdktest/CitizenCardPayProxyTest.java
payapi/src/main/kotlin/com/supwisdom/dlpay/api/controller/user_api_controller.kt
payapi/src/main/kotlin/com/supwisdom/dlpay/api/transaction_builder.kt

index 29919c5..8a0ad65 100644 (file)
@@ -253,6 +253,9 @@ public class CitizenCardPayProxyTest {
     assertThat("user card biz init " + response.getRetcode() + response.getRetmsg() + response.getException(),
         response.getRetcode(), equalTo(0));
 
+    System.out.println("biz init accdate " + response.getAccdate() + " , refno " + response.getRefno()
+        + ", description " + response.getDescription() + "  summary " + response.getRetmsg());
+
     param.setAccdate(response.getAccdate());
     param.setRefno(response.getRefno());
     response = userProxy.bizConfirm(param);
@@ -260,6 +263,9 @@ public class CitizenCardPayProxyTest {
     assertThat("user card biz confirm " + response.getRetcode() + response.getRetmsg() + response.getException(),
         response.getRetcode(), equalTo(0));
 
+    System.out.println("biz confirm accdate " + response.getAccdate() + " , refno " + response.getRefno()
+        + ", description " + response.getDescription() + "  summary " + response.getRetmsg());
+
   }
 
   @Test
index 271af87..ef0018a 100644 (file)
@@ -174,8 +174,9 @@ class UserAPIController {
             setTransInfo(request.transdate, request.transtime, TradeCode.TRANSCODE_CARD_BIZ, "balance")
             setOutTransInfo(request.operid, request.operSeqno)
             dtltype = "cardservice"
-            description = request.summary
         }
+        val transDesc = arrayListOf<String>()
+        transDesc.add(request.summary)
         val result = PublishCardResponse()
 
         val user = useService.findAccountByUserid(request.userid, null)
@@ -203,12 +204,11 @@ class UserAPIController {
                     TradeErrorCode.INPUT_DATA_ERROR,
                     "交易金额错误")
         }
-        if (depositAmount != 0 && request.totalAmount != 0) {
+        if (request.totalAmount != 0) {
             if (depositAmount > 0) {
-                builder.addDebitCreditRecord(capitalSubj.subjno, capitalSubj.subjname,
+                builder.addDebitCreditRecord(capitalSubj.subjno, capitalSubj.subjno,
                         user.accno, Subject.SUBJNO_PERSONAL_DEPOSIT, request.totalAmount / 100.0, request.summary)
             }
-            val transDesc = arrayListOf<String>()
             if (request.cost > 0) {
                 val subject = accountUtilServcie.readSubject(Subject.SUBJNO_CARD_COST)
                 builder.addDebitCreditRecord(user.accno, Subject.SUBJNO_PERSONAL_DEPOSIT,
@@ -231,8 +231,8 @@ class UserAPIController {
                         request.summary)
                 transDesc.add("手续费" + "%.2f".format(request.charge / 100.0) + " 元")
             }
-            builder.description += transDesc.joinToString(";")
         }
+        builder.description = transDesc.joinToString(";")
         val transaction = transactionService.init(builder)
 
         result.apply {
@@ -249,6 +249,7 @@ class UserAPIController {
         val response = PublishCardResponse().apply {
             accdate = transaction.accdate
             refno = transaction.refno
+            description = transaction.personDtl.transdesc
         }
         return ResponseBodyBuilder.successEntity(response, "${request.summary}确认成功")
     }
index 64f9033..1b81661 100644 (file)
@@ -8,6 +8,7 @@ import com.supwisdom.dlpay.framework.domain.TShopacc
 import com.supwisdom.dlpay.framework.domain.TSubject
 import com.supwisdom.dlpay.framework.util.TradeDict
 import com.supwisdom.dlpay.framework.util.TradeErrorCode
+import org.apache.commons.lang3.StringUtils
 import kotlin.math.abs
 
 open class SubTransactionBuilder<T : SubTransactionBuilder<T>>(val parent: TransactionBuilder) {
@@ -217,6 +218,13 @@ class TransactionBuilder {
     var remark: String = ""
     var dtltype: String = ""
 
+
+    private fun checkSubjectNo(subjno: String) {
+        if (!StringUtils.isNumeric(subjno)) {
+            throw TransactionCheckException(TradeErrorCode.INPUT_DATA_ERROR, "科目号<$subjno>不合法")
+        }
+    }
+
     fun person(): PersonTranactionBuilder {
         return this.personBuilder
     }
@@ -290,6 +298,8 @@ class TransactionBuilder {
     fun addDebitCreditRecord(debitAccNo: String, debitSubjNo: String,
                              creditAccNo: String, creditSubjNo: String,
                              amount: Double, summary: String): TransactionBuilder {
+        checkSubjectNo(debitSubjNo)
+        checkSubjectNo(creditSubjNo)
         debitCreditLines.add(DebitCreditLine(debitAccNo, debitSubjNo,
                 creditAccNo, creditSubjNo,
                 amount, summary, debitCreditLines.size + 1))