Browse Source

提现回调

cy 3 years ago
parent
commit
8d021aabf8

+ 27 - 29
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/UserWithdrawalCallback.java

@@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.yonge.cooleshow.common.entity.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import org.apache.commons.lang3.builder.ToStringBuilder;
 
-import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -36,39 +34,39 @@ public class UserWithdrawalCallback extends BaseEntity {
 
     @TableField("additional_charge_")
     @ApiModelProperty(value = "个人附加费(单位为:分)")
-    private BigDecimal additionalCharge;
+    private Integer additionalCharge;
 
     @TableField("actual_amount_")
     @ApiModelProperty(value = "实发金额(单位为:分,范围:1~10000000000)")
-    private BigDecimal actualAmount;
+    private Integer actualAmount;
 
     @TableField("company_charge_")
     @ApiModelProperty(value = "企业附加费(单位为:分)")
-    private BigDecimal companyCharge;
+    private Integer companyCharge;
 
     @TableField("company_service_fee_")
     @ApiModelProperty(value = "公司服务费汇总=企业个税+企业附加费+企业服务费(单位为:分)")
-    private BigDecimal companyServiceFee;
+    private Integer companyServiceFee;
 
     @TableField("company_tax_")
     @ApiModelProperty(value = "企业承担个税(单位为:分)")
-    private BigDecimal companyTax;
+    private Integer companyTax;
 
     @TableField("service_charge_")
     @ApiModelProperty(value = "企业服务费(单位为:分)")
-    private BigDecimal serviceCharge;
+    private Integer serviceCharge;
 
     @TableField("tax_fee_")
     @ApiModelProperty(value = "个人承担个税(单位为:分)")
-    private BigDecimal taxFee;
+    private Integer taxFee;
 
     @TableField("person_service_fee_")
     @ApiModelProperty(value = "个人服务费汇总=个人个税+个人附加费(单位为:分)")
-    private BigDecimal personServiceFee;
+    private Integer personServiceFee;
 
     @TableField("predict_amount_")
     @ApiModelProperty(value = "应发金额(单位为:分,范围:1~10000000000)")
-    private BigDecimal predictAmount;
+    private Integer predictAmount;
 
     @TableField("salary_type_")
     @ApiModelProperty(value = "发放类型(0:个人经营所得)")
@@ -174,75 +172,75 @@ public class UserWithdrawalCallback extends BaseEntity {
         this.outerOrderNo = outerOrderNo;
     }
 
-    public BigDecimal getAdditionalCharge() {
+    public Integer getAdditionalCharge() {
         return additionalCharge;
     }
 
-    public void setAdditionalCharge(BigDecimal additionalCharge) {
+    public void setAdditionalCharge(Integer additionalCharge) {
         this.additionalCharge = additionalCharge;
     }
 
-    public BigDecimal getActualAmount() {
+    public Integer getActualAmount() {
         return actualAmount;
     }
 
-    public void setActualAmount(BigDecimal actualAmount) {
+    public void setActualAmount(Integer actualAmount) {
         this.actualAmount = actualAmount;
     }
 
-    public BigDecimal getCompanyCharge() {
+    public Integer getCompanyCharge() {
         return companyCharge;
     }
 
-    public void setCompanyCharge(BigDecimal companyCharge) {
+    public void setCompanyCharge(Integer companyCharge) {
         this.companyCharge = companyCharge;
     }
 
-    public BigDecimal getCompanyServiceFee() {
+    public Integer getCompanyServiceFee() {
         return companyServiceFee;
     }
 
-    public void setCompanyServiceFee(BigDecimal companyServiceFee) {
+    public void setCompanyServiceFee(Integer companyServiceFee) {
         this.companyServiceFee = companyServiceFee;
     }
 
-    public BigDecimal getCompanyTax() {
+    public Integer getCompanyTax() {
         return companyTax;
     }
 
-    public void setCompanyTax(BigDecimal companyTax) {
+    public void setCompanyTax(Integer companyTax) {
         this.companyTax = companyTax;
     }
 
-    public BigDecimal getServiceCharge() {
+    public Integer getServiceCharge() {
         return serviceCharge;
     }
 
-    public void setServiceCharge(BigDecimal serviceCharge) {
+    public void setServiceCharge(Integer serviceCharge) {
         this.serviceCharge = serviceCharge;
     }
 
-    public BigDecimal getTaxFee() {
+    public Integer getTaxFee() {
         return taxFee;
     }
 
-    public void setTaxFee(BigDecimal taxFee) {
+    public void setTaxFee(Integer taxFee) {
         this.taxFee = taxFee;
     }
 
-    public BigDecimal getPersonServiceFee() {
+    public Integer getPersonServiceFee() {
         return personServiceFee;
     }
 
-    public void setPersonServiceFee(BigDecimal personServiceFee) {
+    public void setPersonServiceFee(Integer personServiceFee) {
         this.personServiceFee = personServiceFee;
     }
 
-    public BigDecimal getPredictAmount() {
+    public Integer getPredictAmount() {
         return predictAmount;
     }
 
-    public void setPredictAmount(BigDecimal predictAmount) {
+    public void setPredictAmount(Integer predictAmount) {
         this.predictAmount = predictAmount;
     }
 

+ 6 - 5
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/WithdrawController.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.yonge.cooleshow.biz.dal.entity.UserWithdrawalCallback;
 import com.yonge.cooleshow.biz.dal.service.UserWithdrawalCallbackService;
 import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.thirdparty.lingxinpay.RSA;
 import com.yonge.toolset.thirdparty.lingxinpay.Withdraw;
 import com.yonge.toolset.utils.json.JsonUtil;
@@ -43,7 +44,7 @@ public class WithdrawController extends BaseController {
      * @return
      */
     @PostMapping("/callback")
-    public String test(@RequestBody String content, HttpServletRequest request) {
+    public HttpResponseResult<Object> callback(@RequestBody String content, HttpServletRequest request) {
         log.info("交易回调请求地址:{} 请求参数:{}", request.getRemoteAddr(), content);
         try {
             if (StringUtils.isBlank(content)) {
@@ -56,15 +57,15 @@ public class WithdrawController extends BaseController {
             Map<String, Object> withdrawRecord = JSONObject.parseObject(jsonStr);
             UserWithdrawalCallback callback = JsonUtil.toJavaObject(withdrawRecord, UserWithdrawalCallback.class);
             callbackService.insertCallback(callback);
-            return jsonStr;
+            return succeed();
         } catch (Exception e) {
             log.error("解密失败e:{}", e);
-            return "failed";
+            return failed();
         }
     }
 
     @GetMapping("/test")
-    public String a() {
+    public String a(String remark) {
         Withdraw withdraw = new Withdraw();
 
         //输入商户订单号
@@ -92,7 +93,7 @@ public class WithdrawController extends BaseController {
         String cardAttribute = "C";
 
         String requestParam = withdraw.withdraw(outerOrderNo, name, mobile, certificateNo, predictAmount, payAccount, cardType,
-                salaryType, projectName, payType, cardAttribute);
+                salaryType, projectName, payType, cardAttribute, remark);
         log.info("单笔请求返回参数:{}", requestParam);
         return requestParam;
     }

+ 7 - 2
toolset/thirdparty-component/src/main/java/com/yonge/toolset/thirdparty/lingxinpay/Withdraw.java

@@ -2,6 +2,7 @@ package com.yonge.toolset.thirdparty.lingxinpay;
 
 import com.alibaba.fastjson.JSONObject;
 import com.yonge.toolset.utils.http.HttpUtil;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -39,10 +40,11 @@ public class Withdraw {
      * @param projectName   项目名称
      * @param payType       支付类型(1:银行卡,2:支付宝,4:微信) 以实际业务为准
      * @param cardAttribute 卡属性:(C:对私)
+     * @param remark        备注(扩展字段) 只针对测试环境:只要参数合规都会返回交易成功,如果想要模拟交易失败,该字段值中含有“失败”二字即会失败。
      * @return
      */
     public String withdraw(String outerOrderNo, String name, String mobile, String certificateNo, String predictAmount,
-                           String payAccount, String cardType, String salaryType, String projectName, String payType, String cardAttribute) {
+                           String payAccount, String cardType, String salaryType, String projectName, String payType, String cardAttribute, String remark) {
         Map<String, Object> map = new HashMap<>();
         map.put("outMemberNo", memberNo);
         map.put("outerOrderNo", outerOrderNo);
@@ -63,6 +65,9 @@ public class Withdraw {
         map.put("payType", payType);
         map.put("cardAttribute", cardAttribute);
         map.put("payAccount", payAccount);
+        if (StringUtils.isNotBlank(remark)) {
+            map.put("remark", remark);
+        }
         String jsonStr = JSONObject.toJSONString(map);
 
         //签名
@@ -141,7 +146,7 @@ public class Withdraw {
         String cardAttribute = "C";
 
         String requestParam = withdraw.withdraw(outerOrderNo, name, mobile, certificateNo, predictAmount, payAccount, cardType,
-                salaryType, projectName, payType, cardAttribute);
+                salaryType, projectName, payType, cardAttribute,null);
         logger.info("单笔请求返回参数:{}", requestParam);
     }
 }