1
This commit is contained in:
139
platformapi/lakala/lakala_bill.go
Normal file
139
platformapi/lakala/lakala_bill.go
Normal file
@@ -0,0 +1,139 @@
|
||||
package lakala
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// QueryBillBalance 查询账户余额
|
||||
func (a *API) QueryBillBalance(param *QueryBillBalanceReq) (*QueryBillBalanceResp, error) {
|
||||
reqParameter := map[string]interface{}{
|
||||
"reqData": utils.Struct2Map(param, "", false),
|
||||
"reqId": utils.GetUUID(),
|
||||
"ver": "1.0.0",
|
||||
"timestamp": time.Now().Unix(),
|
||||
}
|
||||
result, err := a.AccessAPISign(BillTestUrl, BillQuery, http.MethodPost, "", reqParameter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result["retCode"].(string) != Success {
|
||||
return nil, fmt.Errorf(result["retMsg"].(string))
|
||||
}
|
||||
|
||||
bodyResult, err := json.Marshal(result["respData"])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := &QueryBillBalanceResp{}
|
||||
if err = json.Unmarshal(bodyResult, resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// EwalletWithdrawD1 账户D1提现
|
||||
func (a *API) EwalletWithdrawD1(param *EwalletWithdrawD1Req) (string, string, error) {
|
||||
reqParameter := map[string]interface{}{
|
||||
"reqData": utils.Struct2Map(param, "", false),
|
||||
"reqId": utils.GetUUID(),
|
||||
"ver": "1.0.0",
|
||||
"timestamp": time.Now().Unix(),
|
||||
}
|
||||
result, err := a.AccessAPISign(BillTestUrl, BillDrawD1, http.MethodPost, "", reqParameter)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
if result["retCode"].(string) != Success {
|
||||
return "", "", fmt.Errorf(result["retMsg"].(string))
|
||||
}
|
||||
|
||||
return result["respData"].(map[string]string)["drawJnl"], result["respData"].(map[string]string)["merOrderNo"], nil
|
||||
}
|
||||
|
||||
// EwalletWithdrawQuery 提现结果查询
|
||||
func (a *API) EwalletWithdrawQuery(param *EwalletWithdrawQueryReq) (*EwalletWithdrawQueryResp, error) {
|
||||
reqParameter := map[string]interface{}{
|
||||
"reqData": utils.Struct2Map(param, "", false),
|
||||
"reqId": utils.GetUUID(),
|
||||
"ver": "1.0.0",
|
||||
"timestamp": time.Now().Unix(),
|
||||
}
|
||||
result, err := a.AccessAPISign(BillTestUrl, BillDrawD1Query, http.MethodPost, "", reqParameter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result["retCode"].(string) != Success {
|
||||
return nil, fmt.Errorf(result["retMsg"].(string))
|
||||
}
|
||||
|
||||
bodyResult, err := json.Marshal(result["respData"])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := &EwalletWithdrawQueryResp{}
|
||||
if err = json.Unmarshal(bodyResult, resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
||||
}
|
||||
|
||||
// SettleDrawPattern 设置提款模式
|
||||
func (a *API) SettleDrawPattern(param *SettleDrawPatternReq) error {
|
||||
reqParameter := map[string]interface{}{
|
||||
"reqData": utils.Struct2Map(param, "", false),
|
||||
"reqId": utils.GetUUID(),
|
||||
"ver": "1.0.0",
|
||||
"timestamp": time.Now().Unix(),
|
||||
}
|
||||
result, err := a.AccessAPISign(BillTestUrl, BillSettleProfile, http.MethodPost, "", reqParameter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if result["retCode"].(string) != Success {
|
||||
return fmt.Errorf(result["retMsg"].(string))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// EwalletSettleQuery 提款模式查询
|
||||
func (a *API) EwalletSettleQuery(bmcpNo, mercId string) (*EwalletSettleQueryResp, error) {
|
||||
reqParameter := map[string]interface{}{
|
||||
"reqData": map[string]string{"bmcpNo": bmcpNo, "mercId": mercId},
|
||||
"reqId": utils.GetUUID(),
|
||||
"ver": "1.0.0",
|
||||
"timestamp": time.Now().Unix(),
|
||||
}
|
||||
result, err := a.AccessAPISign(BillTestUrl, BillSettleQuery, http.MethodPost, "", reqParameter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result["retCode"].(string) != Success {
|
||||
return nil, fmt.Errorf(result["retMsg"].(string))
|
||||
}
|
||||
|
||||
bodyResult, err := json.Marshal(result["respData"])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := &EwalletSettleQueryResp{}
|
||||
if err = json.Unmarshal(bodyResult, resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
Reference in New Issue
Block a user