main
parent
922304c9d2
commit
0acb1d6b52
@ -0,0 +1,105 @@
|
||||
package zking
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"insure/e"
|
||||
"insure/service"
|
||||
"insure/third_party/zking"
|
||||
"io"
|
||||
)
|
||||
|
||||
func checkParam(c *gin.Context) (*zking.CommonParam, error) {
|
||||
body, _ := io.ReadAll(c.Request.Body)
|
||||
if body != nil {
|
||||
fmt.Printf("push body:%s\n", body)
|
||||
}
|
||||
|
||||
param := zking.CommonParam{}
|
||||
err := json.Unmarshal(body, ¶m)
|
||||
if err != nil {
|
||||
return nil, e.NewError("参数异常:" + err.Error())
|
||||
}
|
||||
if !zking.InsureApi.Verify(param) {
|
||||
return nil, e.NewError("验签错误")
|
||||
}
|
||||
|
||||
return ¶m, nil
|
||||
}
|
||||
|
||||
func Push(c *gin.Context) {
|
||||
data := map[string]interface{}{}
|
||||
result := map[string]interface{}{
|
||||
"code": 200,
|
||||
"msg": "成功",
|
||||
"data": data,
|
||||
}
|
||||
|
||||
param, err := checkParam(c)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
result["code"] = 201
|
||||
result["msg"] = err.Error()
|
||||
c.JSON(200, result)
|
||||
return
|
||||
}
|
||||
|
||||
pushData := zking.PushCallbackData{}
|
||||
err = json.Unmarshal([]byte(param.Data), &pushData)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
result["code"] = 201
|
||||
result["msg"] = "data异常"
|
||||
c.JSON(200, result)
|
||||
return
|
||||
}
|
||||
orderResult, err := service.OrderService.SaveOrderResult(pushData)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
result["code"] = 201
|
||||
result["msg"] = "内部错误"
|
||||
c.JSON(200, result)
|
||||
return
|
||||
}
|
||||
fmt.Println("orderResult:", orderResult)
|
||||
}
|
||||
|
||||
func Revoke(c *gin.Context) {
|
||||
data := map[string]interface{}{}
|
||||
result := map[string]interface{}{
|
||||
"code": 200,
|
||||
"msg": "成功",
|
||||
"data": data,
|
||||
}
|
||||
|
||||
param, err := checkParam(c)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
result["code"] = 201
|
||||
result["msg"] = err.Error()
|
||||
c.JSON(200, result)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(param)
|
||||
}
|
||||
|
||||
func Claim(c *gin.Context) {
|
||||
data := map[string]interface{}{}
|
||||
result := map[string]interface{}{
|
||||
"code": 200,
|
||||
"msg": "成功",
|
||||
"data": data,
|
||||
}
|
||||
|
||||
param, err := checkParam(c)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
result["code"] = 201
|
||||
result["msg"] = err.Error()
|
||||
c.JSON(200, result)
|
||||
return
|
||||
}
|
||||
fmt.Println(param)
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package config
|
||||
|
||||
type Server struct {
|
||||
Port string
|
||||
Domain string
|
||||
Port string
|
||||
Domain string
|
||||
RootPath string `yaml:"root-path"`
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package request
|
||||
|
||||
type UpdateApplicantRequest struct {
|
||||
Token string `form:"token"`
|
||||
ApplicantName string `form:"applicantName"`
|
||||
CreditCode string `form:"creditCode"`
|
||||
ContactName string `form:"contactName"`
|
||||
ContactMobile string `form:"contactMobile"`
|
||||
BankName string `form:"bankName"`
|
||||
BankCardNum string `form:"bankCardNum"`
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"insure/api/zking"
|
||||
)
|
||||
|
||||
func zkingRouteInit(r *gin.Engine) {
|
||||
zkGroup := r.Group("/zking")
|
||||
zkGroup.Match([]string{"POST", "GET", "OPTIONS"}, "/push", zking.Push)
|
||||
zkGroup.Match([]string{"POST", "GET", "OPTIONS"}, "/revoke", zking.Revoke)
|
||||
zkGroup.Match([]string{"POST", "GET", "OPTIONS"}, "/claim", zking.Claim)
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,20 @@
|
||||
package zking
|
||||
|
||||
type PushCallbackData struct {
|
||||
DataType string `json:"data_type" form:"data_type"`
|
||||
OrderSn string `json:"ordersn" form:"ordersn"`
|
||||
PolicyNo string `json:"policyNo" form:"policyNo"`
|
||||
MinPremium string `json:"min_premium" form:"min_premium"`
|
||||
Rate string `json:"rate" form:"rate"`
|
||||
Status string `json:"status" form:"status"` // 3 已出单,其他状态待定
|
||||
ServiceAmount string `json:"service_amount" form:"service_amount"`
|
||||
GuranteeLink string `json:"gurantee_link" form:"gurantee_link"`
|
||||
GuranteeLinkMd5 string `json:"gurantee_link_md5" form:"gurantee_link_md5"`
|
||||
GuranteeOfdLink string `json:"gurantee_ofd_link" form:"gurantee_ofd_link"`
|
||||
GuranteeOfdLinkMd5 string `json:"gurantee_ofd_link_md5" form:"gurantee_ofd_link_md5"`
|
||||
InvoiceLink string `json:"invoice_link" form:"invoice_link"`
|
||||
InvoiceLinkMd5 string `json:"invoice_link_md5" form:"invoice_link_md5"`
|
||||
ConfirmReceiptLink string `json:"confirm_receipt_link" form:"confirm_receipt_link"`
|
||||
ConfirmReceiptLinkMd5 string `json:"confirm_receipt_link_md5" form:"confirm_receipt_link_md5"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
}
|
Loading…
Reference in New Issue