service/library/payclients/alipaycli/client_test.go

132 lines
29 KiB
Go
Raw Normal View History

2023-12-21 22:17:40 +08:00
package alipaycli
import (
"context"
"fmt"
"os"
2024-02-12 23:41:41 +08:00
"service/app/mix/conf"
2024-02-03 17:23:08 +08:00
"service/bizcommon/util"
2023-12-21 22:17:40 +08:00
"service/library/configcenter"
"service/library/idgenerator"
"testing"
)
func TestMain(m *testing.M) {
2024-02-12 23:41:41 +08:00
cfg := new(conf.ConfigSt)
2024-02-19 09:05:49 +08:00
err := configcenter.LoadConfig("/Users/erwin/wishpalv2/service/etc/mix/mix-local.yaml", cfg)
2024-02-12 23:41:41 +08:00
if err != nil {
fmt.Printf("%v\n", err)
2023-12-21 22:17:40 +08:00
}
2024-02-12 23:41:41 +08:00
2024-02-18 23:47:58 +08:00
err = InitMulti(cfg.Alipay, cfg.AlipayMYTS)
2023-12-21 22:17:40 +08:00
if err != nil {
fmt.Println(err)
os.Exit(1)
}
m.Run()
}
2024-02-12 23:41:41 +08:00
func TestAlipayClient_WapPay(t *testing.T) {
2024-02-18 23:47:58 +08:00
cli := GetDefaultAlipayClient()
2024-02-12 23:41:41 +08:00
paramStr, err := cli.WapPay(context.Background(), &WapPayParam{
2023-12-21 22:17:40 +08:00
OutTradeNo: idgenerator.GenOrderId(),
Subject: "哈哈",
TotalAmount: 1,
TimeOutSeconds: 0,
})
if err != nil {
fmt.Println(err)
return
}
fmt.Println(paramStr)
}
2024-02-03 17:23:08 +08:00
func TestAlipayClient_QueryOrder(t *testing.T) {
2024-02-18 23:47:58 +08:00
cli := GetDefaultAlipayClient()
2024-02-03 17:23:08 +08:00
resp, err := cli.QueryOrder(context.Background(), &QueryOrderParam{
OutTradeNo: "1750539072771731456",
})
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(util.ToJson(resp))
}
2024-02-18 23:47:58 +08:00
func TestAlipayClient_RefundOne(t *testing.T) {
cli := GetAlipayClientByAppId(AppIdXinYiDaoLe)
resp, err := cli.RefundOne(context.Background(), &RefundOneParam{
2024-02-19 09:05:49 +08:00
OutTradeNo: "1744218982338015232",
RefundAmount: 100,
2024-02-18 23:47:58 +08:00
RefundReason: "测试退款",
})
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(util.ToJson(resp))
}
2024-02-19 09:05:49 +08:00
func TestAlipayClient_UniTransfer(t *testing.T) {
cli := GetAlipayClientByAppId(AppIdXinYiDaoLe)
resp, err := cli.UniTransfer(context.Background(), &UniTransferParam{
OutBizNo: idgenerator.GenWithdrawOrderId(),
Amount: 10,
Title: "提现测试",
AlipayLoginId: "lwl0608@foxmail.com",
AlipayName: "李旺林",
})
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(util.ToJson(resp))
}
2024-02-19 21:04:45 +08:00
func TestFillOid3(t *testing.T) {
orderIds := []string{"1742761440047017984", "1742852074682462208", "1742852552656957440", "1742924360517169152", "1743182205040996352", "1743520076063059968", "1743662852348063744", "1743663326795149312", "1743823244533706752", "1744218982338015232", "1744244263178219520", "1744350157970878464", "1744408716473544704", "1745042566375550976", "1745042654623707136", "1745721623425593344", "1746183337426300928", "1746421628100685824", "1746463772899291136", "1746470938301444096", "1746631560976674816", "1747243520520892416", "1747542908493377536", "1748967357042143232", "1748967481084489728", "1748967612680777728", "1749654946015358976", "1749753647039787008", "1749782915010539520", "1749792607422132224", "1749932249081458688", "1750539072771731456", "1751075580108877824", "1751165792092696576", "1751196454745026560", "1751432173375729664", "1751516934270103552", "1751575514667036672", "1751594471155314688", "1751793391655464960", "1751886129461735424", "1751946441451909120", "1751996064262533120", "1751997132975386624", "1752008184328892416", "1752014211006869504", "1752014764885684224", "1752027180163936256", "1752027550126714880", "1752027637821222912", "1752028008304095232", "1752077544233906176", "1752086426696036352", "1752120049658769408", "1752133978615197696", "1752299490192142336", "1752302624792653824", "1752406986378457088", "1752470842563899392", "1752486928067866624", "1752511566495887360", "1752574086808088576", "1752609115932209152", "1752617236729704448", "1752628266373492736", "1752676795091529728", "1752723355963764736", "1752744562419314688", "1752753531737092096", "1752754533919895552", "1752766191992057856", "1752882682368372736", "1752908112026677248", "1752920982437244928", "1753041808545296384", "1753052328052666368", "1753057343802716160", "1753075028104065024", "1753087953262882816", "1753088666751741952", "1753135004277288960", "1753165780310044672", "1753270954600968192", "1753274856683614208", "1753290280578068480", "1753291651377278976", "1753385044547743744", "1753456188839702528", "1753586844827660288", "1753594211489296384", "1753650088430809088", "1753651789619539968", "1753659385466335232", "1753696275661860864", "1753697226460246016", "1753698635968688128", "1753703849928962048", "1753769112124796928", "1753814530149855232", "1753846361020706816", "1753852803849138176", "1753987695459184640", "1754040300780662784", "1754083910163116032", "1754110276036210688", "1754138747760291840", "1754192230463057920", "1754252018832125952", "1754303879605923840", "1754351453889114112", "1754354646593318912", "1754372648122462208", "1754402526775488512", "1754417315002200064", "1754487065157840896", "1754525198553460736", "1754537829599293440", "1754558003379449856", "1754564554794217472", "1754571015964340224", "1754572009162944512", "1754576063519797248", "1754600989450579968", "1754623192195936256", "1754662992051449856", "1754672188390125568", "1754680462095167488", "1754682474849382400", "1754684059369353216", "1754689197429501952", "1754700702778667008", "1754722956178632704", "1754723877960822784", "1754728264863068160", "1754741175765446656", "1754745097544544256", "1754750391725076480", "1754759204503040000", "1754759471080419328", "1754769380295585792", "1754771557684621312", "1754774424587874304", "1754779489931374592", "1754799230922272768", "1754811322836463616", "1754812425984552960", "1754814285579563008", "1754816070062977024", "1754820528016732160", "1754836132710854656", "1754839165121343488", "1754850031359242240", "1754856552730210304", "1754873591788220416", "1754874866298793984", "1754886273958424576", "1754886321580552192", "1754886832132206592", "1754887107970609152", "1754897611296354304", "1754899978276319232", "1754902916105252864", "1754907977925537792", "1754910828605222912", "1754929720945815552", "1754930627502682112", "1754944453191151616", "1754946054568030208", "1754952278780948480", "1754961195950944256", "1754966414868885504", "1755017040944443392", "1755019012334432256", "1755027629800435712", "1755048721378193408", "1755058603925975040", "1755058902094852096", "1
cliXYDL := GetAlipayClientByAppId(AppIdXinYiDaoLe)
cliMYTS := GetAlipayClientByAppId(AppIdMiYuanTianShi)
ctx := context.Background()
res := map[string]string{}
fmt.Println(len(orderIds))
for i, orderId := range orderIds {
res[orderId] = ""
p := &QueryOrderParam{
OutTradeNo: orderId,
}
// 先查心意到了
resp1, _ := cliXYDL.QueryOrder(ctx, p)
if resp1 != nil && resp1.Response.Code == "10000" {
res[orderId] = AppIdXinYiDaoLe
t.Log(i+1, "心意到了")
continue
}
// 再查觅缘天使
resp2, _ := cliMYTS.QueryOrder(ctx, p)
if resp2 != nil && resp2.Response.Code == "10000" {
res[orderId] = AppIdMiYuanTianShi
t.Log(i+1, "觅缘天使")
continue
}
t.Log(i+1, "没有")
//break
}
f, _ := os.Create("id_pair.csv")
f.Write([]byte("order_id,oid3\n"))
defer f.Close()
for k, v := range res {
content := []byte(fmt.Sprintf("%s,%s\n", k, v))
f.Write(content)
}
}