Skip to content

Commit

Permalink
Merge pull request #389 from ArtisanCloud/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Matrix-X authored Sep 10, 2023
2 parents ee8185c + b371d4c commit c2d2a38
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 22 deletions.
44 changes: 30 additions & 14 deletions src/kernel/models/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@ const WX_TRADE_STATE_PAYERROR = "PAYERROR" // 支付失败(其他原因,

// Transaction
type Transaction struct {
Amount *TransactionAmount `json:"amount,omitempty"`
AppID string `json:"appid,omitempty"`
Attach string `json:"attach,omitempty"`
BankType string `json:"bank_type,omitempty"`
MchID string `json:"mchid,omitempty"`
OutTradeNo string `json:"out_trade_no,omitempty"`
Payer *TransactionPayer `json:"payer,omitempty"`
PromotionDetail []PromotionDetail `json:"promotion_detail,omitempty"`
SuccessTime string `json:"success_time,omitempty"`
TradeState string `json:"trade_state,omitempty"`
TradeStateDesc string `json:"trade_state_desc,omitempty"`
TradeType string `json:"trade_type,omitempty"`
TransactionID string `json:"transaction_id,omitempty"`
Amount *TransactionAmount `json:"amount,omitempty"`
AppID string `json:"appid,omitempty"`
SpAppid string `json:"sp_appid,omitempty"`
SpMchid string `json:"sp_mchid,omitempty"`
SubAppid string `json:"sub_appid,omitempty"`
SubMchid string `json:"sub_mchid,omitempty"`
Attach string `json:"attach,omitempty"`
BankType string `json:"bank_type,omitempty"`
MchID string `json:"mchid,omitempty"`
OutTradeNo string `json:"out_trade_no,omitempty"`
Payer *TransactionPayer `json:"payer,omitempty"`
PromotionDetail []PromotionDetail `json:"promotion_detail,omitempty"`
SuccessTime string `json:"success_time,omitempty"`
TradeState string `json:"trade_state,omitempty"`
TradeStateDesc string `json:"trade_state_desc,omitempty"`
TradeType string `json:"trade_type,omitempty"`
TransactionID string `json:"transaction_id,omitempty"`
SceneInfo *TransactionSceneInfo `json:"scene_info,omitempty"`
}

// TransactionSceneInfo
type TransactionSceneInfo struct {
DeviceId string `json:"device_id,omitempty"`
}

// TransactionAmount
Expand All @@ -46,7 +56,9 @@ type TransactionAmount struct {

// TransactionPayer
type TransactionPayer struct {
OpenID string `json:"openid,omitempty"`
OpenID string `json:"openid,omitempty"`
SubOpenid string `json:"sub_openid,omitempty"`
SpOpenid string `json:"sp_openid,omitempty"`
}

// PromotionDetail
Expand Down Expand Up @@ -91,6 +103,10 @@ type PromotionGoodsDetail struct {
// --- Refund models ----
// Refund
type Refund struct {
//服务商户号
SpMchid string `json:"sp_mchid,omitempty"`
//子商户号
SubMchid string `json:"sub_mchid,omitempty"`
// 原支付交易对应的商户订单号
MchID string `json:"mchid"`
// 微信支付交易订单号
Expand Down
8 changes: 4 additions & 4 deletions src/payment/notify/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

type Handler struct {
App *kernel.ApplicationPaymentInterface
App kernel.ApplicationPaymentInterface
Message *request.RequestNotify
fail string
Attributes *object.StringMap
Expand All @@ -30,7 +30,7 @@ type Handler struct {
const SUCCESS = "SUCCESS"
const FAIL = "FAIL"

func NewHandler(app *kernel.ApplicationPaymentInterface, r *http.Request) *Handler {
func NewHandler(app kernel.ApplicationPaymentInterface, r *http.Request) *Handler {

//-------------- external request --------------
request := &http.Request{}
Expand Down Expand Up @@ -72,7 +72,7 @@ func (handler *Handler) ToResponse() (response *http.Response, err error) {
}

attributes := object.MergeStringMap(base, handler.Attributes)
baseClient := (*handler.App).GetComponent("Base").(*base2.Client)
baseClient := (handler.App).GetComponent("Base").(*base2.Client)
if handler.Sign {
(*attributes)["sign"], err = baseClient.BaseClient.Signer.GenerateSign("")
if err != nil {
Expand Down Expand Up @@ -120,7 +120,7 @@ func (handler *Handler) DecryptMessage() (string, error) {
return "", errors.New("uniformMessage doesn't have the key value")
}

config := (*handler.App).GetConfig()
config := (handler.App).GetConfig()
wxKey := config.GetString("mch_api_v3_key", "")
nonce := message.Resource.Nonce
associatedData := message.Resource.AssociatedData
Expand Down
2 changes: 1 addition & 1 deletion src/payment/notify/paid.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Paid struct {
func NewPaidNotify(app kernel.ApplicationPaymentInterface, request *http.Request) *Paid {

paid := &Paid{
NewHandler(&app, request),
NewHandler(app, request),
}

return paid
Expand Down
2 changes: 1 addition & 1 deletion src/payment/notify/refund.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Refund struct {
func NewRefundNotify(app kernel.ApplicationPaymentInterface, request *http.Request) *Refund {

paid := &Refund{
NewHandler(&app, request),
NewHandler(app, request),
}

return paid
Expand Down
4 changes: 2 additions & 2 deletions src/payment/notify/scanned.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Scanned struct {
func NewScannedNotify(app kernel.ApplicationPaymentInterface, request *http.Request) *Scanned {

scanned := &Scanned{
NewHandler(&app, request),
NewHandler(app, request),
"",
}

Expand Down Expand Up @@ -46,7 +46,7 @@ func (comp *Scanned) Handle(closure func(message *request.RequestNotify, fail fu
}

if comp.alert == "" && reflect.TypeOf(result).Name() == "string" {
config := (*comp.App).GetConfig()
config := (comp.App).GetConfig()
(*attributes)["appid"] = config.GetString("app_id", "")
(*attributes)["mch_id"] = config.GetString("mch_id", "")
(*attributes)["nonce_str"] = object.UniqueID("")
Expand Down
5 changes: 5 additions & 0 deletions src/payment/partner/response/responseOrder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ type Payer struct {
SubOpenid string `json:"sub_openid"`
}

type SceneInfo struct {
DeviceId string `json:"device_id,omitempty"`
}

type ResponseOrder struct {
response.ResponsePayment

Expand All @@ -38,4 +42,5 @@ type ResponseOrder struct {
TradeStateDesc string `json:"trade_state_desc"`
TradeType string `json:"trade_type"`
TransactionId string `json:"transaction_id"`
SceneInfo *SceneInfo `json:"scene_info,omitempty"`
}

0 comments on commit c2d2a38

Please sign in to comment.