Skip to content

Commit 0fbfc49

Browse files
authored
Merge pull request #633 from ArtisanCloud/develop
Develop
2 parents 57b6fa6 + ceb3161 commit 0fbfc49

File tree

5 files changed

+95
-19
lines changed

5 files changed

+95
-19
lines changed

main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func GetOfficialConfig() *officialAccount.UserConfig {
2929
Log: officialAccount.Log{
3030
Level: "debug",
3131
Stdout: false,
32-
File: "/Users/michaelhu/wechat/official-account/info.log",
33-
Error: "/Users/michaelhu/wechat/official-account/error.log",
32+
File: "~/wechat/official-account/info.log",
33+
Error: "~/wechat/official-account/error.log",
3434
},
3535
Http: officialAccount.Http{
3636
ProxyURI: "",
@@ -59,8 +59,8 @@ func GetWorkConfig() *work.UserConfig {
5959
Level: "debug",
6060
//File: "./wechat/info.log",
6161
//Error: "./wechat/error.log",
62-
File: "/Users/michaelhu/wechat/work/info.log",
63-
Error: "/Users/michaelhu/wechat/work/error.log",
62+
File: "~/wechat/work/info.log",
63+
Error: "~/wechat/work/error.log",
6464
ENV: os.Getenv("work.env"),
6565
},
6666

@@ -107,8 +107,8 @@ func GetPaymentConfig() *payment.UserConfig {
107107
Level: "debug",
108108
//File: "./wechat/info.log",
109109
//Error: "./wechat/error.log",
110-
File: "/Users/michaelhu/wechat/payment/info.log",
111-
Error: "/Users/michaelhu/wechat/payment/error.log",
110+
File: "~/wechat/payment/info.log",
111+
Error: "~/wechat/payment/error.log",
112112
},
113113
Http: payment.Http{
114114
Timeout: 30.0,
@@ -141,8 +141,8 @@ func GetMiniProgramConfig() *miniProgram.UserConfig {
141141
ResponseType: os.Getenv("array"),
142142
Log: miniProgram.Log{
143143
Level: "debug",
144-
File: "/Users/michaelhu/wechat/mini-program/info.log",
145-
Error: "/Users/michaelhu/wechat/mini-program/error.log",
144+
File: "~/wechat/mini-program/info.log",
145+
Error: "~/wechat/mini-program/error.log",
146146
},
147147
Cache: kernel.NewRedisClient(&kernel.UniversalOptions{
148148
Addrs: []string{"127.0.0.1:6379"},
@@ -170,8 +170,8 @@ func GetOpenPlatformConfig() *openPlatform.UserConfig {
170170
Level: "debug",
171171
//File: "./wechat/info.log",
172172
//Error: "./wechat/error.log",
173-
File: "/Users/michaelhu/wechat/platform/info.log",
174-
Error: "/Users/michaelhu/wechat/platform/error.log",
173+
File: "~/wechat/platform/info.log",
174+
Error: "~/wechat/platform/error.log",
175175
},
176176
Cache: kernel.NewRedisClient(&kernel.UniversalOptions{
177177
Addrs: []string{"127.0.0.1:6379"},

src/payment/order/client.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (comp *Client) JSAPITransaction(ctx context.Context, params *request.Reques
3333
result := &response.ResponseUnitfy{}
3434

3535
endpoint := "/v3/pay/transactions/jsapi"
36-
_, err := comp.PayTransaction(ctx, endpoint, params, result)
36+
_, err := comp.PayTransaction(ctx, endpoint, params, result, true)
3737
return result, err
3838
}
3939

@@ -44,7 +44,7 @@ func (comp *Client) TransactionApp(ctx context.Context, params *request.RequestA
4444
result := &response.ResponseUnitfy{}
4545

4646
endpoint := "/v3/pay/transactions/app"
47-
_, err := comp.PayTransaction(ctx, endpoint, params, result)
47+
_, err := comp.PayTransaction(ctx, endpoint, params, result, true)
4848

4949
return result, err
5050
}
@@ -56,7 +56,7 @@ func (comp *Client) TransactionH5(ctx context.Context, params *request.RequestH5
5656
result := &response.ResponseH5URL{}
5757

5858
endpoint := "/v3/pay/transactions/h5"
59-
_, err := comp.PayTransaction(ctx, endpoint, params, result)
59+
_, err := comp.PayTransaction(ctx, endpoint, params, result, true)
6060
return result, err
6161
}
6262

@@ -67,7 +67,7 @@ func (comp *Client) TransactionNative(ctx context.Context, params *request.Reque
6767
result := &response.ResponseCodeURL{}
6868

6969
endpoint := "/v3/pay/transactions/native"
70-
_, err := comp.PayTransaction(ctx, endpoint, params, result)
70+
_, err := comp.PayTransaction(ctx, endpoint, params, result, true)
7171

7272
return result, err
7373
}
@@ -79,19 +79,31 @@ func (comp *Client) TransactionAppCombine(ctx context.Context, params *request.R
7979
result := &response.ResponseUnitfy{}
8080

8181
endpoint := "/v3/combine-transactions/app"
82-
_, err := comp.PayTransaction(ctx, endpoint, params, result)
82+
_, err := comp.PayTransaction(ctx, endpoint, params, result, true)
8383

8484
return result, err
8585
}
8686

87-
func (comp *Client) PayTransaction(ctx context.Context, entryPoint string, params request.Prepay, result interface{}) (interface{}, error) {
87+
// 付款码支付
88+
// https://pay.weixin.qq.com/docs/merchant/apis/code-payment-v3/direct/code-pay.html
89+
func (comp *Client) TransactionCodePay(ctx context.Context, params *request.RequestCodePay) (*response.ResponseCodePayResult, error) {
90+
91+
result := &response.ResponseCodePayResult{}
92+
93+
endpoint := "/v3/pay/transactions/codepay"
94+
_, err := comp.PayTransaction(ctx, endpoint, params, result, false)
95+
96+
return result, err
97+
}
98+
99+
func (comp *Client) PayTransaction(ctx context.Context, entryPoint string, params request.Prepay, result interface{}, needNotify bool) (interface{}, error) {
88100
config := comp.App.GetConfig()
89101

90102
if params.GetAppID() == "" {
91103
appID := config.GetString("app_id", "")
92104
params.SetAppID(appID)
93105
}
94-
if params.GetNotifyUrl() == "" {
106+
if params.GetNotifyUrl() == "" && needNotify {
95107
url := config.GetString("notify_url", "")
96108
params.SetNotifyUrl(url)
97109
}

src/payment/order/request/codepay.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package request
2+
3+
type CodePayPayer struct {
4+
AuthCode string `json:"auth_code,omitempty"` // 付款码支付授权码
5+
}
6+
7+
type CodePayAmount struct {
8+
Total int `json:"total,omitempty"` // 总金额
9+
Currency string `json:"currency,omitempty"` // 货币类型
10+
}
11+
12+
type CodePayStoreInfo struct {
13+
ID string `json:"id,omitempty"` // 门店编号
14+
OutID string `json:"out_id,omitempty"` // 商家自定义编码
15+
}
16+
17+
type CodePaySceneInfo struct {
18+
DeviceID string `json:"device_id,omitempty"` // 商户端设备号
19+
StoreInfo *CodePayStoreInfo `json:"store_info,omitempty"` // 商户门店信息
20+
DeviceIP string `json:"device_ip,omitempty"` // 用户终端IP
21+
}
22+
23+
type CodePayGoodsDetail struct {
24+
MerchantGoodsID string `json:"merchant_goods_id,omitempty"` // 商品编码
25+
WxpayGoodsID string `json:"wxpay_goods_id,omitempty"` // 微信支付商品编码
26+
GoodsName string `json:"goods_name,omitempty"` // 商品名称
27+
Quantity int `json:"quantity,omitempty"` // 商品数量
28+
UnitPrice int `json:"unit_price,omitempty"` // 商品单价
29+
}
30+
31+
type CodePayDetail struct {
32+
CostPrice int `json:"cost_price,omitempty"` // 订单原价
33+
InvoiceID string `json:"invoice_id,omitempty"` // 商品小票ID
34+
GoodsDetail []*CodePayGoodsDetail `json:"goods_detail,omitempty"` // 单品列表
35+
}
36+
37+
type CodePaySettleInfo struct {
38+
ProfitSharing bool `json:"profit_sharing,omitempty"` // 是否指定分账
39+
}
40+
41+
type RequestCodePay struct {
42+
PrepayBase
43+
Description string `json:"description"` // 商品描述
44+
OutTradeNo string `json:"out_trade_no"` // 商户订单号
45+
Attach string `json:"attach"` // 附加数据
46+
GoodsTag string `json:"goods_tag,omitempty"` // 订单优惠标记
47+
SupportFapiao bool `json:"support_fapiao,omitempty"` // 电子发票入口开放标识
48+
Payer *CodePayPayer `json:"payer,omitempty"` // 支付者
49+
Amount *CodePayAmount `json:"amount,omitempty"` // 订单金额
50+
SceneInfo *CodePaySceneInfo `json:"scene_info,omitempty"` // 场景信息
51+
Detail *CodePayDetail `json:"detail,omitempty"` // 优惠功能
52+
SettleInfo *CodePaySettleInfo `json:"settle_info,omitempty"` // 结算信息
53+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package response
2+
3+
import (
4+
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/response"
5+
)
6+
7+
type ResponseCodePayResult struct {
8+
response.ResponsePayment
9+
10+
ResponseOrder
11+
}

src/work/accountService/customer/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func NewClient(app kernel.ApplicationInterface) (*Client, error) {
2424
}, nil
2525
}
2626

27-
// 读取消息
28-
// https://developer.work.weixin.qq.com/document/path/94670
27+
// 获取客户基础信息
28+
// https://developer.work.weixin.qq.com/document/path/96429
2929
func (comp *Client) BatchGet(ctx context.Context, externalUserIDList []string, needEnterSessionContext int8) (*response.ResponseCustomerBatchGet, error) {
3030

3131
result := &response.ResponseCustomerBatchGet{}

0 commit comments

Comments
 (0)