-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #477 from ArtisanCloud/develop
Develop
- Loading branch information
Showing
9 changed files
with
355 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
package merchantService | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/ArtisanCloud/PowerLibs/v3/object" | ||
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel" | ||
response2 "github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/response" | ||
payment "github.com/ArtisanCloud/PowerWeChat/v3/src/payment/kernel" | ||
"github.com/ArtisanCloud/PowerWeChat/v3/src/payment/merchantService/request" | ||
"github.com/ArtisanCloud/PowerWeChat/v3/src/payment/merchantService/response" | ||
"net/http" | ||
) | ||
|
||
type Client struct { | ||
*payment.BaseClient | ||
} | ||
|
||
func NewClient(app *payment.ApplicationPaymentInterface) (*Client, error) { | ||
baseClient, err := payment.NewBaseClient(app) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &Client{ | ||
baseClient, | ||
}, nil | ||
} | ||
|
||
// 查询投诉单列表 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaints/list-complaints-v2.html | ||
func (comp *Client) Complaints(ctx context.Context, params *request.RequestComplaints) (*response.ResponseComplaints, error) { | ||
|
||
result := &response.ResponseComplaints{} | ||
|
||
data, _ := object.StructToStringMap(params) | ||
|
||
endpoint := "/v3/merchant-service/complaints-v2" | ||
_, err := comp.Request(ctx, endpoint, data, http.MethodGet, &object.HashMap{}, false, nil, result) | ||
|
||
return result, err | ||
} | ||
|
||
// 查询投诉单详情 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaints/query-complaint-v2.html | ||
func (comp *Client) QueryComplaint(ctx context.Context, complaintId string) (*response.ResponseQueryComplaint, error) { | ||
|
||
result := &response.ResponseQueryComplaint{} | ||
|
||
endpoint := fmt.Sprintf("/v3/merchant-service/complaints-v2/%s", complaintId) | ||
_, err := comp.Request(ctx, endpoint, nil, http.MethodGet, &object.HashMap{}, false, nil, result) | ||
|
||
return result, err | ||
} | ||
|
||
// 查询投诉单协商历史 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaints/query-negotiation-history-v2.html | ||
func (comp *Client) QueryNegotiationHistoriesByComplaint(ctx context.Context, complaintId string, limit int8, offset int8) (*response.ResponseQueryNegotiationHistoriesByComplaint, error) { | ||
|
||
result := &response.ResponseQueryNegotiationHistoriesByComplaint{} | ||
|
||
data := &object.StringMap{ | ||
"limit": fmt.Sprintf("%d", limit), | ||
"offset": fmt.Sprintf("%d", offset), | ||
} | ||
|
||
endpoint := fmt.Sprintf("/v3/merchant-service/complaints-v2/%s/negotiation-historys", complaintId) | ||
_, err := comp.Request(ctx, endpoint, data, http.MethodGet, &object.HashMap{}, false, nil, result) | ||
|
||
return result, err | ||
} | ||
|
||
// 创建投诉通知回调 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaint-notifications/create-complaint-notifications.html | ||
func (comp *Client) CreateComplaintNotifications(ctx context.Context, url string) (*response.ResponseCreateComplaintNotifications, error) { | ||
|
||
result := &response.ResponseCreateComplaintNotifications{} | ||
|
||
data := &object.HashMap{ | ||
"url": url, | ||
} | ||
|
||
endpoint := "/v3/merchant-service/complaint-notifications" | ||
_, err := comp.Request(ctx, endpoint, nil, http.MethodPost, data, false, nil, result) | ||
|
||
return result, err | ||
} | ||
|
||
// 查询投诉通知回调 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaint-notifications/query-complaint-notifications.html | ||
func (comp *Client) QueryComplaintNotifications(ctx context.Context, complaintId string, limit int8, offset int8) (*response.ResponseCreateComplaintNotifications, error) { | ||
|
||
result := &response.ResponseCreateComplaintNotifications{} | ||
|
||
endpoint := "/v3/merchant-service/complaint-notifications" | ||
_, err := comp.Request(ctx, endpoint, nil, http.MethodGet, &object.HashMap{}, false, nil, result) | ||
|
||
return result, err | ||
} | ||
|
||
// 更新投诉通知回调 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaint-notifications/update-complaint-notifications.html | ||
func (comp *Client) UpdateComplaintNotifications(ctx context.Context, url string) (*response.ResponseCreateComplaintNotifications, error) { | ||
|
||
result := &response.ResponseCreateComplaintNotifications{} | ||
|
||
data := &object.HashMap{ | ||
"url": url, | ||
} | ||
|
||
endpoint := "/v3/merchant-service/complaint-notifications" | ||
_, err := comp.Request(ctx, endpoint, nil, http.MethodPut, data, false, nil, result) | ||
|
||
return result, err | ||
} | ||
|
||
// 删除投诉通知回调 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaint-notifications/delete-complaint-notifications.html | ||
func (comp *Client) DeleteComplaintNotifications(ctx context.Context, url string) (*response2.ResponsePayment, error) { | ||
|
||
result := &response2.ResponsePayment{} | ||
|
||
endpoint := "/v3/merchant-service/complaint-notifications" | ||
_, err := comp.Request(ctx, endpoint, nil, http.MethodDelete, &object.HashMap{}, false, nil, result) | ||
|
||
return result, err | ||
} | ||
|
||
// 回复用户 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaints/response-complaint-v2.html | ||
func (comp *Client) ReplyToUser(ctx context.Context, complaintId string, params *request.RequestReplyToUser) (*response2.ResponsePayment, error) { | ||
|
||
result := &response2.ResponsePayment{} | ||
|
||
data, _ := object.StructToHashMap(params) | ||
|
||
endpoint := fmt.Sprintf("/v3/merchant-service/complaints-v2/%s/response", complaintId) | ||
_, err := comp.Request(ctx, endpoint, nil, http.MethodPost, data, false, nil, result) | ||
|
||
return result, err | ||
} | ||
|
||
// 反馈处理完成 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaints/complete-complaint-v2.html | ||
func (comp *Client) CompleteFeedback(ctx context.Context, complaintId string) (*response2.ResponsePayment, error) { | ||
|
||
result := &response2.ResponsePayment{} | ||
|
||
endpoint := fmt.Sprintf("/v3/merchant-service/complaints-v2/%s/complete", complaintId) | ||
_, err := comp.Request(ctx, endpoint, nil, http.MethodPost, &object.HashMap{}, false, nil, result) | ||
|
||
return result, err | ||
} | ||
|
||
// 更新退款审批结果 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/complaints/complete-complaint-v2.html | ||
func (comp *Client) UpdateFeedback(ctx context.Context, complaintId string, params *request.RequestUpdateFeedback) (*response2.ResponsePayment, error) { | ||
|
||
result := &response2.ResponsePayment{} | ||
|
||
data, _ := object.StructToHashMap(params) | ||
|
||
endpoint := fmt.Sprintf("/v3/merchant-service/complaints-v2/%s/update-refund-progress", complaintId) | ||
_, err := comp.Request(ctx, endpoint, nil, http.MethodPost, data, false, nil, result) | ||
|
||
return result, err | ||
} | ||
|
||
// 图片上传接口 | ||
// https://pay.weixin.qq.com/docs/merchant/apis/consumer-complaint/images/create-images.html | ||
func (comp *Client) UploadImg(ctx context.Context, params *request.RequestMediaUpload) (*response.ResponseMediaUpload, error) { | ||
|
||
result := &response.ResponseMediaUpload{} | ||
|
||
var files *object.HashMap | ||
if params.File != "" { | ||
files = &object.HashMap{ | ||
"file": params.File, | ||
} | ||
} | ||
|
||
var formData *kernel.UploadForm | ||
if params.Meta != nil { | ||
formData = &kernel.UploadForm{ | ||
Contents: []*kernel.UploadContent{ | ||
&kernel.UploadContent{ | ||
Name: "file", | ||
Value: params.Meta.Filename, | ||
}, | ||
}, | ||
} | ||
} | ||
options, _ := object.StructToHashMap(params.Meta) | ||
|
||
_, err := comp.BaseClient.HttpUploadJson(ctx, "/v3/merchant-service/images/upload", files, formData, options, nil, nil, &result) | ||
return result, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package merchantService | ||
|
||
import ( | ||
"github.com/ArtisanCloud/PowerWeChat/v3/src/payment/kernel" | ||
) | ||
|
||
func RegisterProvider(app kernel.ApplicationPaymentInterface) (*Client, error) { | ||
|
||
return NewClient(&app) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package request | ||
|
||
type Meta struct { | ||
Filename string `json:"filename"` | ||
Sha256 string `json:"sha256"` | ||
} | ||
|
||
type RequestMediaUpload struct { | ||
File string `json:"file"` | ||
Meta *Meta `json:"meta"` | ||
} | ||
|
||
type RequestComplaints struct { | ||
Limit int8 `json:"limit"` | ||
Offset int8 `json:"offset"` | ||
BeginDate string `json:"begin_date"` | ||
EndDate string `json:"end_date"` | ||
ComplaintedMchId string `json:"complainted_mchid"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package request | ||
|
||
type RequestReplyToUser struct { | ||
ComplaintedMchid string `json:"complainted_mchid"` | ||
ResponseContent string `json:"response_content"` | ||
ResponseImages []string `json:"response_images"` | ||
JumpUrl string `json:"jump_url"` | ||
JumpUrlText string `json:"jump_url_text"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package request | ||
|
||
type RequestUpdateFeedback struct { | ||
Action string `json:"action"` | ||
LaunchRefundDay int `json:"launch_refund_day"` | ||
RejectReason string `json:"reject_reason"` | ||
RejectMediaList []string `json:"reject_media_list"` | ||
Remark string `json:"remark"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package response | ||
|
||
import ( | ||
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/response" | ||
"time" | ||
) | ||
|
||
type ResponseMediaUpload struct { | ||
response.ResponsePayment | ||
MediaId string `json:"media_id"` | ||
} | ||
|
||
type ReturnAddressInfo struct { | ||
ReturnAddress string `json:"return_address"` | ||
Longitude string `json:"longitude"` | ||
Latitude string `json:"latitude"` | ||
} | ||
|
||
type SharePowerInfo struct { | ||
ReturnTime time.Time `json:"return_time"` | ||
ReturnAddressInfo ReturnAddressInfo `json:"return_address_info"` | ||
} | ||
|
||
type AdditionalInfo struct { | ||
Type string `json:"type"` | ||
SharePowerInfo SharePowerInfo `json:"share_power_info"` | ||
} | ||
|
||
type ServiceOrderInfo struct { | ||
OrderId string `json:"order_id"` | ||
OutOrderNo string `json:"out_order_no"` | ||
State string `json:"state"` | ||
} | ||
|
||
type ComplaintMediaList struct { | ||
MediaType string `json:"media_type"` | ||
MediaUrl []string `json:"media_url"` | ||
} | ||
|
||
type ComplainOrderInfo struct { | ||
TransactionId string `json:"transaction_id"` | ||
OutTradeNo string `json:"out_trade_no"` | ||
Amount int `json:"amount"` | ||
} | ||
|
||
type ResponseQueryComplaint struct { | ||
response.ResponsePayment | ||
|
||
ComplaintId string `json:"complaint_id"` | ||
ComplaintTime time.Time `json:"complaint_time"` | ||
ComplaintDetail string `json:"complaint_detail"` | ||
ComplaintState string `json:"complaint_state"` | ||
PayerPhone string `json:"payer_phone"` | ||
ComplaintOrderInfo []ComplainOrderInfo `json:"complaint_order_info"` | ||
ComplaintFullRefunded bool `json:"complaint_full_refunded"` | ||
IncomingUserResponse bool `json:"incoming_user_response"` | ||
UserComplaintTimes int `json:"user_complaint_times"` | ||
ComplaintMediaList []ComplaintMediaList `json:"complaint_media_list"` | ||
ProblemDescription string `json:"problem_description"` | ||
ProblemType string `json:"problem_type"` | ||
ApplyRefundAmount int `json:"apply_refund_amount"` | ||
UserTagList []string `json:"user_tag_list"` | ||
ServiceOrderInfo []ServiceOrderInfo `json:"service_order_info"` | ||
AdditionalInfo AdditionalInfo `json:"additional_info"` | ||
} | ||
|
||
type ResponseComplaints struct { | ||
response.ResponsePayment | ||
|
||
Data []ResponseQueryComplaint `json:"data"` | ||
Limit int `json:"limit"` | ||
Offset int `json:"offset"` | ||
TotalCount int `json:"total_count"` | ||
} |
6 changes: 6 additions & 0 deletions
6
src/payment/merchantService/response/responseCreateComplaintNotifications.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package response | ||
|
||
type ResponseCreateComplaintNotifications struct { | ||
MchId string `json:"mchid"` | ||
Url string `json:"url"` | ||
} |
20 changes: 20 additions & 0 deletions
20
src/payment/merchantService/response/responseQueryNegotiationHistoriesByComplaint.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package response | ||
|
||
import "time" | ||
|
||
type Data struct { | ||
LogId string `json:"log_id"` | ||
Operator string `json:"operator"` | ||
OperateTime time.Time `json:"operate_time"` | ||
OperateType string `json:"operate_type"` | ||
OperateDetails string `json:"operate_details"` | ||
ImageList []string `json:"image_list"` | ||
ComplaintMediaList ComplaintMediaList `json:"complaint_media_list"` | ||
} | ||
|
||
type ResponseQueryNegotiationHistoriesByComplaint struct { | ||
Data []Data `json:"data"` | ||
Limit int `json:"limit"` | ||
Offset int `json:"offset"` | ||
TotalCount int `json:"total_count"` | ||
} |