From dc2edbdbd84ec7aac7276024062431fe27475108 Mon Sep 17 00:00:00 2001 From: Jerry <85411418@qq.com> Date: Sun, 8 Sep 2024 00:16:02 +0800 Subject: [PATCH] v1.5.105 (#420) --- alipay/client.go | 73 ++++---- alipay/client_request.go | 5 +- alipay/merchant_qipan.go | 376 +++++++++++++++++++++++++++++++++++++++ alipay/model_merchant.go | 338 +++++++++++++++++++++++++++++++++++ constant.go | 2 +- doc/alipay.md | 41 +++-- error.go | 1 + go.mod | 2 +- go.sum | 4 +- release_note.txt | 31 ++++ 10 files changed, 814 insertions(+), 59 deletions(-) create mode 100644 alipay/merchant_qipan.go diff --git a/alipay/client.go b/alipay/client.go index 0c9bafe5..16e8046e 100644 --- a/alipay/client.go +++ b/alipay/client.go @@ -122,6 +122,9 @@ func (a *Client) RequestParam(bm gopay.BodyMap, method string) (string, error) { err error sign string ) + if bm == nil { + return "", gopay.BodyMapNilErr + } // check if there is biz_content bz := bm.GetInterface("biz_content") if bzBody, ok := bz.(gopay.BodyMap); ok { @@ -161,40 +164,42 @@ func (a *Client) pubParamsHandle(bm gopay.BodyMap, method, bizContent string, au Set("version", "1.0"). Set("timestamp", time.Now().Format(xtime.TimeLayout)) - // version - if version := bm.GetString("version"); version != gopay.NULL { - pubBody.Set("version", version) - } - if a.AppCertSN != gopay.NULL { - pubBody.Set("app_cert_sn", a.AppCertSN) - } - if a.AliPayRootCertSN != gopay.NULL { - pubBody.Set("alipay_root_cert_sn", a.AliPayRootCertSN) - } - // return_url - if a.ReturnUrl != gopay.NULL { - pubBody.Set("return_url", a.ReturnUrl) - } - if returnUrl := bm.GetString("return_url"); returnUrl != gopay.NULL { - pubBody.Set("return_url", returnUrl) - } - if a.location != nil { - pubBody.Set("timestamp", time.Now().In(a.location).Format(xtime.TimeLayout)) - } - // notify_url - if a.NotifyUrl != gopay.NULL { - pubBody.Set("notify_url", a.NotifyUrl) - } - if notifyUrl := bm.GetString("notify_url"); notifyUrl != gopay.NULL { - pubBody.Set("notify_url", notifyUrl) - } - // default use app_auth_token - if a.AppAuthToken != gopay.NULL { - pubBody.Set("app_auth_token", a.AppAuthToken) - } - // if user set app_auth_token in body_map, use this - if aat := bm.GetString("app_auth_token"); aat != gopay.NULL { - pubBody.Set("app_auth_token", aat) + if bm != nil { + // version + if version := bm.GetString("version"); version != gopay.NULL { + pubBody.Set("version", version) + } + if a.AppCertSN != gopay.NULL { + pubBody.Set("app_cert_sn", a.AppCertSN) + } + if a.AliPayRootCertSN != gopay.NULL { + pubBody.Set("alipay_root_cert_sn", a.AliPayRootCertSN) + } + // return_url + if a.ReturnUrl != gopay.NULL { + pubBody.Set("return_url", a.ReturnUrl) + } + if returnUrl := bm.GetString("return_url"); returnUrl != gopay.NULL { + pubBody.Set("return_url", returnUrl) + } + if a.location != nil { + pubBody.Set("timestamp", time.Now().In(a.location).Format(xtime.TimeLayout)) + } + // notify_url + if a.NotifyUrl != gopay.NULL { + pubBody.Set("notify_url", a.NotifyUrl) + } + if notifyUrl := bm.GetString("notify_url"); notifyUrl != gopay.NULL { + pubBody.Set("notify_url", notifyUrl) + } + // default use app_auth_token + if a.AppAuthToken != gopay.NULL { + pubBody.Set("app_auth_token", a.AppAuthToken) + } + // if user set app_auth_token in body_map, use this + if aat := bm.GetString("app_auth_token"); aat != gopay.NULL { + pubBody.Set("app_auth_token", aat) + } } if len(authToken) > 0 { pubBody.Set("auth_token", authToken[0]) diff --git a/alipay/client_request.go b/alipay/client_request.go index d0748119..8cf1fd91 100644 --- a/alipay/client_request.go +++ b/alipay/client_request.go @@ -26,7 +26,6 @@ func (a *Client) PostAliPayAPISelfV2(ctx context.Context, bodyMap gopay.BodyMap, } bodyMap.Set("biz_content", string(bodyBs)) } - if bs, err = a.doAliPaySelf(ctx, bodyMap, method); err != nil { return err } @@ -146,7 +145,9 @@ func (a *Client) doAliPay(ctx context.Context, bm gopay.BodyMap, method string, return nil, fmt.Errorf("json.Marshal:%w", err) } bizContent = string(bodyBs) - bm.Set("app_auth_token", aat) + if aat != "" { + bm.Set("app_auth_token", aat) + } } else { if bodyBs, err = json.Marshal(bm); err != nil { return nil, fmt.Errorf("json.Marshal:%w", err) diff --git a/alipay/merchant_qipan.go b/alipay/merchant_qipan.go new file mode 100644 index 00000000..c390a03a --- /dev/null +++ b/alipay/merchant_qipan.go @@ -0,0 +1,376 @@ +package alipay + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/go-pay/gopay" +) + +// alipay.merchant.qipan.crowd.create(上传创建人群) +// 文档地址:https://opendocs.alipay.com/open/e93d9a54_alipay.merchant.qipan.crowd.create +func (a *Client) MerchantQipanCrowdCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MerchantQipanCrowdCreateRsp, err error) { + err = bm.CheckEmptyError("crowd_name", "external_crowd_code", "user_list") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowd.create"); err != nil { + return nil, err + } + aliRsp = new(MerchantQipanCrowdCreateRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.merchant.qipan.crowduser.add(人群中追加用户) +// 文档地址:https://opendocs.alipay.com/open/04330914_alipay.merchant.qipan.crowduser.add +func (a *Client) MerchantQipanCrowdUserAdd(ctx context.Context, bm gopay.BodyMap) (aliRsp *MerchantQipanCrowdUserAddRsp, err error) { + err = bm.CheckEmptyError("crowd_code", "user_list") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowduser.add"); err != nil { + return nil, err + } + aliRsp = new(MerchantQipanCrowdUserAddRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.merchant.qipan.crowduser.delete(人群中删除用户) +// 文档地址:https://opendocs.alipay.com/open/80646633_alipay.merchant.qipan.crowduser.delete +func (a *Client) MerchantQipanCrowdUserDelete(ctx context.Context, bm gopay.BodyMap) (aliRsp *MerchantQipanCrowdUserDeleteRsp, err error) { + err = bm.CheckEmptyError("crowd_code", "user_list") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowduser.delete"); err != nil { + return nil, err + } + aliRsp = new(MerchantQipanCrowdUserDeleteRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.marketing.qipan.tagbase.batchquery(棋盘人群圈选标签基本信息查询) +// 文档地址:https://opendocs.alipay.com/open/ce6aee00_alipay.marketing.qipan.tagbase.batchquery +func (a *Client) MarketingQipanTagBaseBatchQuery(ctx context.Context) (aliRsp *MarketingQipanTagBaseBatchQueryRsp, err error) { + var bs []byte + if bs, err = a.doAliPay(ctx, nil, "alipay.marketing.qipan.tagbase.batchquery"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanTagBaseBatchQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.marketing.qipan.tag.query(棋盘标签圈选值查询) +// 文档地址:https://opendocs.alipay.com/open/e322cb35_alipay.marketing.qipan.tag.query +func (a *Client) MarketingQipanTagQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanTagQueryRsp, err error) { + err = bm.CheckEmptyError("tag_code") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.qipan.tag.query"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanTagQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.marketing.qipan.crowdoperation.create(棋盘人群创建) +// 文档地址:https://opendocs.alipay.com/open/09c10677_alipay.marketing.qipan.crowdoperation.create +func (a *Client) MarketingQipanCrowdOperationCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdOperationCreateRsp, err error) { + err = bm.CheckEmptyError("crowd_name", "operation_pool_list") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.qipan.crowdoperation.create"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanCrowdOperationCreateRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.marketing.qipan.crowdtag.query(查询圈选标签列表) +// 文档地址:https://opendocs.alipay.com/open/8e411cec_alipay.marketing.qipan.crowdtag.query +func (a *Client) MarketingQipanCrowdTagQuery(ctx context.Context) (aliRsp *MarketingQipanCrowdTagQueryRsp, err error) { + var bs []byte + if bs, err = a.doAliPay(ctx, nil, "alipay.marketing.qipan.crowdtag.query"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanCrowdTagQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.marketing.qipan.crowdwithtag.create(标签圈选创建人群) +// 文档地址:https://opendocs.alipay.com/open/cbf0efa4_alipay.marketing.qipan.crowdwithtag.create +func (a *Client) MarketingQipanCrowdWithTagCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdWithTagCreateRsp, err error) { + err = bm.CheckEmptyError("crowd_name", "apply_channel_list", "select_tag_list") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.qipan.crowdwithtag.create"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanCrowdWithTagCreateRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.marketing.qipan.crowdwithtag.query(标签圈选预估人群规模) +// 文档地址:https://opendocs.alipay.com/open/adb5dd04_alipay.marketing.qipan.crowdwithtag.query +func (a *Client) MarketingQipanCrowdWithTagQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdWithTagQueryRsp, err error) { + err = bm.CheckEmptyError("crowd_id") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.marketing.qipan.crowdwithtag.query"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanCrowdWithTagQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.merchant.qipan.crowd.batchquery(查询人群列表) +// 文档地址:https://opendocs.alipay.com/open/b7f3caec_alipay.merchant.qipan.crowd.batchquery +func (a *Client) MarketingQipanCrowdBatchQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdBatchQueryRsp, err error) { + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowd.batchquery"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanCrowdBatchQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.merchant.qipan.crowd.query(查询人群详情) +// 文档地址:https://opendocs.alipay.com/open/be384367_alipay.merchant.qipan.crowd.query +func (a *Client) MarketingQipanCrowdQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdQueryRsp, err error) { + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowd.query"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanCrowdQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.merchant.qipan.crowd.modify(修改人群) +// 文档地址:https://opendocs.alipay.com/open/6c8ebb31_alipay.merchant.qipan.crowd.modify +func (a *Client) MarketingQipanCrowdModify(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanCrowdModifyRsp, err error) { + err = bm.CheckEmptyError("crowd_code") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.crowd.modify"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanCrowdModifyRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.merchant.qipan.board.query(看板分析) +// 文档地址:https://opendocs.alipay.com/open/aa5066aa_alipay.merchant.qipan.board.query +func (a *Client) MarketingQipanBoardQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanBoardQueryRsp, err error) { + err = bm.CheckEmptyError("scene_code") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.board.query"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanBoardQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.merchant.qipan.insight.query(画像分析) +// 文档地址:https://opendocs.alipay.com/open/46a75f4e_alipay.merchant.qipan.insight.query +func (a *Client) MarketingQipanInsightQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanInsightQueryRsp, err error) { + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.insight.query"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanInsightQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.merchant.qipan.behavior.query(行为分析) +// 文档地址:https://opendocs.alipay.com/open/56735ac5_alipay.merchant.qipan.behavior.query +func (a *Client) MarketingQipanBehaviorQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanBehaviorQueryRsp, err error) { + err = bm.CheckEmptyError("scene_code", "request_params") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.behavior.query"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanBehaviorQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.merchant.qipan.trend.query(趋势分析) +// 文档地址:https://opendocs.alipay.com/open/8ee7795a_alipay.merchant.qipan.trend.query +func (a *Client) MarketingQipanTrendQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanTrendQueryRsp, err error) { + err = bm.CheckEmptyError("index_key", "request_params") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.trend.query"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanTrendQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} + +// alipay.merchant.qipan.insightcity.query(常住省市查询) +// 文档地址:https://opendocs.alipay.com/open/f7d99821_alipay.merchant.qipan.insightcity.query +func (a *Client) MarketingQipanInsightCityQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *MarketingQipanInsightCityQueryRsp, err error) { + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "alipay.merchant.qipan.insightcity.query"); err != nil { + return nil, err + } + aliRsp = new(MarketingQipanInsightCityQueryRsp) + if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil { + return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) + } + if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil { + return aliRsp, err + } + signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn) + aliRsp.SignData = signData + return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr) +} diff --git a/alipay/model_merchant.go b/alipay/model_merchant.go index 7c4ebb91..b73cd63f 100644 --- a/alipay/model_merchant.go +++ b/alipay/model_merchant.go @@ -70,6 +70,125 @@ type PayAppMarketingConsultRsp struct { Sign string `json:"sign"` } +type MerchantQipanCrowdCreateRsp struct { + Response *MerchantQipanCrowdCreate `json:"alipay_merchant_qipan_crowd_create_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MerchantQipanCrowdUserAddRsp struct { + Response *MerchantQipanCrowdUserAdd `json:"alipay_merchant_qipan_crowduser_add_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MerchantQipanCrowdUserDeleteRsp struct { + Response *MerchantQipanCrowdUserDelete `json:"alipay_merchant_qipan_crowduser_delete_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanTagBaseBatchQueryRsp struct { + Response *MarketingQipanTagBaseBatchQuery `json:"alipay_marketing_qipan_tagbase_batchquery_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanTagQueryRsp struct { + Response *MarketingQipanTagQuery `json:"alipay_marketing_qipan_tag_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanCrowdOperationCreateRsp struct { + Response *MarketingQipanCrowdOperationCreate `json:"alipay_marketing_qipan_crowdoperation_create_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanCrowdTagQueryRsp struct { + Response *MarketingQipanCrowdTagQuery `json:"alipay_marketing_qipan_crowdtag_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanCrowdWithTagCreateRsp struct { + Response *MarketingQipanCrowdWithTagCreate `json:"alipay_marketing_qipan_crowdwithtag_create_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanCrowdWithTagQueryRsp struct { + Response *MarketingQipanCrowdWithTagQuery `json:"alipay_marketing_qipan_crowdwithtag_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanCrowdBatchQueryRsp struct { + Response *MarketingQipanCrowdBatchQuery `json:"alipay_merchant_qipan_crowd_batchquery_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanCrowdQueryRsp struct { + Response *MarketingQipanCrowdQuery `json:"alipay_merchant_qipan_crowd_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanCrowdModifyRsp struct { + Response *MarketingQipanCrowdModify `json:"alipay_merchant_qipan_crowd_modify_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanBoardQueryRsp struct { + Response *MarketingQipanBoardQuery `json:"alipay_merchant_qipan_board_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanInsightQueryRsp struct { + Response *MarketingQipanInsightQuery `json:"alipay_merchant_qipan_insight_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanBehaviorQueryRsp struct { + Response *MarketingQipanBehaviorQuery `json:"alipay_merchant_qipan_behavior_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanTrendQueryRsp struct { + Response *MarketingQipanTrendQuery `json:"alipay_merchant_qipan_trend_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type MarketingQipanInsightCityQueryRsp struct { + Response *MarketingQipanInsightCityQuery `json:"alipay_merchant_qipan_insightcity_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + // =========================================================分割========================================================= type TradeRelationBind struct { @@ -171,3 +290,222 @@ type ViewData struct { ThresholdAmount string `json:"threshold_amount"` PayOperationInfo string `json:"pay_operation_info"` } + +type MerchantQipanCrowdCreate struct { + ErrorResponse + CrowdCode string `json:"crowd_code"` +} + +type MerchantQipanCrowdUserAdd struct { + ErrorResponse +} + +type MerchantQipanCrowdUserDelete struct { + ErrorResponse +} + +type MarketingQipanTagBaseBatchQuery struct { + ErrorResponse + OperationTagList []*OperationTagItem `json:"operation_tag_list"` +} + +type OperationTagItem struct { + TagCode string `json:"tag_code"` + TagName string `json:"tag_name"` + TagDesc string `json:"tag_desc"` +} + +type MarketingQipanTagQuery struct { + ErrorResponse + OperationTag *OperationTag `json:"operation_tag"` +} + +type OperationTag struct { + TagCode string `json:"tag_code"` + TagName string `json:"tag_name"` + TagDesc string `json:"tag_desc"` + OperationOptionList []*OperationOptionItem `json:"operation_option_list"` +} + +type OperationOptionItem struct { + OptionCode string `json:"option_code"` + OptionName string `json:"option_name"` + OptionDataType string `json:"option_data_type"` + OptionList []*Option `json:"option_list"` +} + +type Option struct { + Id int `json:"id"` + Value string `json:"value"` + Text string `json:"text"` + Desc string `json:"desc"` + ParentId string `json:"parent_id"` + ParentValue string `json:"parent_value"` +} + +type MarketingQipanCrowdOperationCreate struct { + ErrorResponse + CrowdCode string `json:"crowd_code"` +} + +type MarketingQipanCrowdTagQuery struct { + ErrorResponse + SelectTagList []*SelectTag `json:"select_tag_list"` +} + +type SelectTag struct { + TagId int `json:"tag_id"` + TagName string `json:"tag_name"` + CategoryTagOptionList []*CategoryTagOption `json:"category_tag_option_list"` +} + +type CategoryTagOption struct { + TagOptionCategoryId int `json:"tag_option_category_id"` + TagOptionCategoryName string `json:"tag_option_category_name"` + TagOptionList []*TagOption `json:"tag_option_list"` +} + +type TagOption struct { + Text string `json:"text"` + Value string `json:"value"` + Children []*Children `json:"children"` +} + +type Children struct { + Text string `json:"text"` + Value string `json:"value"` +} + +type MarketingQipanCrowdWithTagCreate struct { + ErrorResponse + CrowdId string `json:"crowd_id"` +} + +type MarketingQipanCrowdWithTagQuery struct { + ErrorResponse + CountRange string `json:"count_range"` +} + +type MarketingQipanCrowdBatchQuery struct { + ErrorResponse + TotalNumber string `json:"total_number"` + CrowdList []*Crowd `json:"crowd_list"` +} + +type Crowd struct { + CrowdCode string `json:"crowd_code"` + CrowdName string `json:"crowd_name"` + CrowdDesc string `json:"crowd_desc"` + ExternalCrowdCode string `json:"external_crowd_code"` + Status string `json:"status"` + Processable bool `json:"processable"` + ApplyChannelList []string `json:"apply_channel_list"` + CrowdSize string `json:"crowd_size"` + Hidden bool `json:"hidden"` +} + +type MarketingQipanCrowdQuery struct { + ErrorResponse + CrowdInfo *CrowdInfo `json:"crowd_info"` +} + +type CrowdInfo struct { + CrowdCode string `json:"crowd_code"` + CrowdName string `json:"crowd_name"` + CrowdDesc string `json:"crowd_desc"` + ExternalCrowdCode string `json:"external_crowd_code"` + Status string `json:"status"` + Processable bool `json:"processable"` + ApplyChannelList []string `json:"apply_channel_list"` + CrowdSize string `json:"crowd_size"` + Hidden bool `json:"hidden"` +} + +type MarketingQipanCrowdModify struct { + ErrorResponse +} + +type MarketingQipanBoardQuery struct { + ErrorResponse + IndexList []*Index `json:"index_list"` +} + +type Index struct { + IndexKey string `json:"index_key"` + IndexName string `json:"index_name"` + IndexDesc string `json:"index_desc"` + IndexValue string `json:"index_value"` + ReportDate string `json:"report_date"` +} + +type MarketingQipanInsightQuery struct { + ErrorResponse + PortraitDataList []*PortraitData `json:"portrait_data_list"` +} + +type PortraitData struct { + PortraitKey string `json:"portrait_key"` + PortraitName string `json:"portrait_name"` + PortraitDesc string `json:"portrait_desc"` + Coverage string `json:"coverage"` + ReportDate string `json:"report_date"` + DataList []*DataItem `json:"data_list"` +} + +type DataItem struct { + Value string `json:"value"` + Num string `json:"num"` +} + +type MarketingQipanBehaviorQuery struct { + ErrorResponse + MultiDataList []*MultiData `json:"multi_data_list"` +} + +type MultiData struct { + ObjectType string `json:"object_type"` + ObjectId string `json:"object_id"` + ObjectName string `json:"object_name"` + FeatureKey string `json:"feature_key"` + UserCnt string `json:"user_cnt"` + UserRatio string `json:"user_ratio"` + AvgNum string `json:"avg_num"` +} + +type MarketingQipanTrendQuery struct { + ErrorResponse + IndexTrendResults []*IndexTrendResult `json:"index_trend_results"` +} + +type IndexTrendResult struct { + IndexKey string `json:"index_key"` + IndexName string `json:"index_name"` + IndexDesc string `json:"index_desc"` + IndexValue string `json:"index_value"` + ReportDate string `json:"report_date"` + StartDate string `json:"start_date"` + EndDate string `json:"end_date"` +} + +type MarketingQipanInsightCityQuery struct { + ErrorResponse + PortraitKey string `json:"portrait_key"` + PortraitName string `json:"portrait_name"` + PortraitDesc string `json:"portrait_desc"` + Coverage string `json:"coverage"` + ReportDate string `json:"report_date"` + DataList []*Data `json:"data_list"` +} + +type Data struct { + PortraitValue string `json:"portrait_value"` + Num int `json:"num"` + AreaCode string `json:"area_code"` + CityList []*City `json:"city_list"` +} + +type City struct { + PortraitValue string `json:"portrait_value"` + AreaCode string `json:"area_code"` + Num int `json:"num"` +} diff --git a/constant.go b/constant.go index 8b5ac8db..6e8dfef1 100644 --- a/constant.go +++ b/constant.go @@ -7,7 +7,7 @@ const ( OK = "OK" DebugOff = 0 DebugOn = 1 - Version = "v1.5.104" + Version = "v1.5.105" ) type DebugSwitch int8 diff --git a/doc/alipay.md b/doc/alipay.md index 7a680ea7..0f21d9b9 100644 --- a/doc/alipay.md +++ b/doc/alipay.md @@ -355,11 +355,11 @@ xlog.Infof("%+v", phone) * 会员卡开卡表单模板配置接口:`client.MarketingCardFormTemplateSet()` * 上传门店照片和视频接口:`client.OfflineMaterialImageUpload()` * 营销活动送红包 - * 创建现金活动接口:TODO:https://opendocs.alipay.com/open/029yy9 - * 触发现金红包活动接口:TODO:https://opendocs.alipay.com/open/029yya - * 更改现金活动状态接口:TODO:https://opendocs.alipay.com/open/029yyb - * 现金活动列表查询接口:TODO:https://opendocs.alipay.com/open/02a1f9 - * 现金活动详情查询接口:TODO:https://opendocs.alipay.com/open/02a1fa + * 创建现金活动接口:`client.MarketingCampaignCashCreate()` + * 触发现金红包活动接口:`client.MarketingCampaignCashTrigger()` + * 更改现金活动状态接口:`client.MarketingCampaignCashStatusModify()` + * 现金活动列表查询接口:`client.MarketingCampaignCashListQuery()` + * 现金活动详情查询接口:`client.MarketingCampaignCashDetailQuery()` * 红包 * 资金转账页面支付接口: `client.FundTransPagePay()` * 现金红包无线支付接口: `client.FundTransAppPay()` @@ -368,23 +368,26 @@ xlog.Infof("%+v", phone) * 资金退回接口: `client.FundTransRefund()` * 棋盘密云 * 接口上传人群 - * 上传创建人群接口:TODO:https://opendocs.alipay.com/open/e93d9a54_alipay.merchant.qipan.crowd.create - * 人群中追加用户接口:TODO:https://opendocs.alipay.com/open/04330914_alipay.merchant.qipan.crowduser.add - * 人群中删除用户接口:TODO:https://opendocs.alipay.com/open/80646633_alipay.merchant.qipan.crowduser.delete + * 上传创建人群接口:`client.MerchantQipanCrowdCreate()` + * 人群中追加用户接口:`client.MerchantQipanCrowdUserAdd()` + * 人群中删除用户接口:`client.MerchantQipanCrowdUserDelete()` * 标签圈选创建人群 - * 查询圈选标签列表接口:TODO:https://opendocs.alipay.com/open/8e411cec_alipay.marketing.qipan.crowdtag.query - * 标签圈选创建人群接口:TODO:https://opendocs.alipay.com/open/cbf0efa4_alipay.marketing.qipan.crowdwithtag.create - * 标签圈选预估人群规模接口:TODO:https://opendocs.alipay.com/open/adb5dd04_alipay.marketing.qipan.crowdwithtag.query + * 棋盘人群圈选标签基本信息查询接口:`client.MarketingQipanTagBaseBatchQuery()` + * 棋盘标签圈选值查询接口:`client.MarketingQipanTagQuery()` + * 棋盘人群创建接口:`client.MarketingQipanCrowdOperationCreate()` + * 查询圈选标签列表接口:`client.MarketingQipanCrowdTagQuery()` + * 标签圈选创建人群接口:`client.MarketingQipanCrowdWithTagCreate()` + * 标签圈选预估人群规模接口:`client.MarketingQipanCrowdWithTagQuery()` * 管理人群 - * 查询人群列表接口:TODO:https://opendocs.alipay.com/open/b7f3caec_alipay.merchant.qipan.crowd.batchquery - * 查询人群详情接口:TODO:https://opendocs.alipay.com/open/be384367_alipay.merchant.qipan.crowd.query - * 修改人群接口:TODO:https://opendocs.alipay.com/open/6c8ebb31_alipay.merchant.qipan.crowd.modify + * 查询人群列表接口:`client.MarketingQipanCrowdBatchQuery()` + * 查询人群详情接口:`client.MarketingQipanCrowdQuery()` + * 修改人群接口:`client.MarketingQipanCrowdModify()` * 数据洞察 - * 看板分析接口:TODO:https://opendocs.alipay.com/open/aa5066aa_alipay.merchant.qipan.board.query - * 画像分析接口:TODO:https://opendocs.alipay.com/open/46a75f4e_alipay.merchant.qipan.insight.query - * 行为分析接口:TODO:https://opendocs.alipay.com/open/56735ac5_alipay.merchant.qipan.behavior.query - * 趋势分析接口:TODO:https://opendocs.alipay.com/open/8ee7795a_alipay.merchant.qipan.trend.query - * 常住省市查询接口:TODO:https://opendocs.alipay.com/open/f7d99821_alipay.merchant.qipan.insightcity.query + * 看板分析接口:`client.MarketingQipanBoardQuery()` + * 画像分析接口:`client.MarketingQipanInsightQuery()` + * 行为分析接口:`client.MarketingQipanBehaviorQuery()` + * 趋势分析接口:`client.MarketingQipanTrendQuery()` + * 常住省市查询接口:`client.MarketingQipanInsightCityQuery()` * 资金产品 * 转账到支付宝账户 * 支付宝资金账户资产查询接口:`client.FundAccountQuery()` diff --git a/error.go b/error.go index 9bd91001..36d7db11 100644 --- a/error.go +++ b/error.go @@ -15,4 +15,5 @@ var ( VerifySignatureErr = errors.New("verify signature error") CertNotMatchErr = errors.New("cert not match error") GetSignDataErr = errors.New("get signature data error") + BodyMapNilErr = errors.New("body map is nil") ) diff --git a/go.mod b/go.mod index 1eb9f971..a473f194 100644 --- a/go.mod +++ b/go.mod @@ -8,5 +8,5 @@ require ( github.com/go-pay/util v0.0.4 github.com/go-pay/xlog v0.0.3 github.com/go-pay/xtime v0.0.2 - golang.org/x/crypto v0.26.0 + golang.org/x/crypto v0.27.0 ) diff --git a/go.sum b/go.sum index 749fb83b..933ff206 100644 --- a/go.sum +++ b/go.sum @@ -8,5 +8,5 @@ github.com/go-pay/xlog v0.0.3 h1:avyMhCL/JgBHreoGx/am/kHxfs1udDOAeVqbmzP/Yes= github.com/go-pay/xlog v0.0.3/go.mod h1:mH47xbobrdsSHWsmFtSF5agWbMHFP+tK0ZbVCk5OAEw= github.com/go-pay/xtime v0.0.2 h1:7YR4/iuELsEHpJ6LUO0SVK80hQxDO9MLCfuVYIiTCRM= github.com/go-pay/xtime v0.0.2/go.mod h1:W1yRbJaSt4CSBcdAtLBQ8xajiN/Pl5hquGczUcUE9xE= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= diff --git a/release_note.txt b/release_note.txt index 189a8b33..e4775862 100644 --- a/release_note.txt +++ b/release_note.txt @@ -1,3 +1,34 @@ +版本号:Release 1.5.105 +修改记录: + (1) gopay:golang.org/x/crypto v0.26.0 版本升级到 v0.27.0。 + (2) 支付宝:新增 client.MarketingCampaignCashCreate(),创建现金活动接口。 + (3) 支付宝:新增 client.MarketingCampaignCashTrigger(),触发现金红包活动接口。 + (4) 支付宝:新增 client.MarketingCampaignCashStatusModify(),更改现金活动状态接口。 + (5) 支付宝:新增 client.MarketingCampaignCashListQuery(),现金活动列表查询接口。 + (6) 支付宝:新增 client.MarketingCampaignCashDetailQuery(),现金活动详情查询接口。 + (7) 支付宝:新增 client.MerchantQipanCrowdCreate(),上传创建人群接口。 + (8) 支付宝:新增 client.MerchantQipanCrowdUserAdd(),人群中追加用户接口。 + (9) 支付宝:新增 client.MerchantQipanCrowdUserDelete(),人群中删除用户接口。 + (10) 支付宝:新增 client.MarketingQipanTagBaseBatchQuery(),棋盘人群圈选标签基本信息查询接口。 + (11) 支付宝:新增 client.MarketingQipanTagQuery(),棋盘标签圈选值查询接口。 + (12) 支付宝:新增 client.MarketingQipanCrowdOperationCreate(),棋盘人群创建接口。 + (13) 支付宝:新增 client.MarketingQipanCrowdTagQuery(),查询圈选标签列表接口。 + (14) 支付宝:新增 client.MarketingQipanCrowdWithTagCreate(),标签圈选创建人群接口。 + (15) 支付宝:新增 client.MarketingQipanCrowdWithTagQuery(),标签圈选预估人群规模接口。 + (16) 支付宝:新增 client.MarketingQipanCrowdBatchQuery(),查询人群列表接口。 + (17) 支付宝:新增 client.MarketingQipanCrowdQuery(),查询人群详情接口。 + (18) 支付宝:新增 client.MarketingQipanCrowdModify(),修改人群接口。 + (19) 支付宝:新增 client.MarketingQipanBoardQuery(),看板分析接口。 + (20) 支付宝:新增 client.MarketingQipanInsightQuery(),画像分析接口。 + (21) 支付宝:新增 client.MarketingQipanBehaviorQuery(),行为分析接口。 + (22) 支付宝:新增 client.MarketingQipanTrendQuery(),趋势分析接口。 + (23) 支付宝:新增 client.MarketingQipanInsightCityQuery(),常住省市查询接口。 + (24) PayPal:新增 client.AddTrackingNumber(),添加物流单号接口。 + (25) PayPal:优化部分结构体字段。。 + (26) 支付宝:FundTransCommonQuery 结构体补充字段。 + (27) Apple:client.SendConsumptionInformation() 方法成功状态码判断修改。 + (28) gopay:升级内部依赖module库。 + 版本号:Release 1.5.104 修改记录: (1) gopay:golang.org/x/crypto v0.24.0 版本升级到 v0.26.0。