From 83c44495006630066abdab64b28d8328551da235 Mon Sep 17 00:00:00 2001 From: duancheng Date: Tue, 5 Nov 2024 08:32:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yaml | 20 ++++++ controller/pay.go | 16 +++++ go.mod | 38 +++++++++++ go.sum | 129 ++++++++++++++++++++++++++++++++++++++ log/2024-11-04.log | 3 + log/sqlLog/2024-11-04.log | 31 +++++++++ main.go | 33 ++++++++++ middle/middle.go | 69 ++++++++++++++++++++ repo/pay_order.go | 15 +++++ service/pay.go | 87 +++++++++++++++++++++++++ service/po/pay_order.go | 15 +++++ service/vo/pay.go | 19 ++++++ 12 files changed, 475 insertions(+) create mode 100644 config.yaml create mode 100644 controller/pay.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 log/2024-11-04.log create mode 100644 log/sqlLog/2024-11-04.log create mode 100644 main.go create mode 100644 middle/middle.go create mode 100644 repo/pay_order.go create mode 100644 service/pay.go create mode 100644 service/po/pay_order.go create mode 100644 service/vo/pay.go diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..4c75d75 --- /dev/null +++ b/config.yaml @@ -0,0 +1,20 @@ +server: + port: 8080 + openapiPath: "/api.json" + swaggerPath: "/swagger" +logger: + path: "log" + level: "all" + stdout: false + #rotateExpire: 1 + #rotateBackupLimit: 1 +database: + logger: + path: "log/sqlLog" + level: "all" + stdout: true + default: + link: "pgsql:root:root@tcp(101.200.127.15:5431)/yuledui" + debug: true +weixin: + appId:"aaabbcc" \ No newline at end of file diff --git a/controller/pay.go b/controller/pay.go new file mode 100644 index 0000000..2482b18 --- /dev/null +++ b/controller/pay.go @@ -0,0 +1,16 @@ +package controller + +import ( + "yuleduiPay/service" + + "github.com/gogf/gf/v2/net/ghttp" +) + +// 路由控制类 +type Pay struct { + payService service.Pay //服务类 +} + +func (t *Pay) RouterGroup(group *ghttp.RouterGroup) { + group.POST("/payQrCode", t.payService.PayQrCode) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..f6d9f33 --- /dev/null +++ b/go.mod @@ -0,0 +1,38 @@ +module yuleduiPay + +go 1.22.3 + +require github.com/gogf/gf/v2 v2.7.4 + +require ( + github.com/BurntSushi/toml v1.4.0 // indirect + github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 // indirect + github.com/clbanning/mxj/v2 v2.7.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/fatih/color v1.18.0 // indirect + github.com/fsnotify/fsnotify v1.8.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-sql-driver/mysql v1.6.0 // indirect + github.com/gogf/gf v1.16.9 // indirect + github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.7.4 // indirect + github.com/gomodule/redigo v1.8.5 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/gorilla/websocket v1.5.3 // indirect + github.com/grokify/html-strip-tags-go v0.1.0 // indirect + github.com/lib/pq v1.10.9 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/rivo/uniseg v0.4.7 // indirect + go.opentelemetry.io/otel v1.31.0 // indirect + go.opentelemetry.io/otel/metric v1.31.0 // indirect + go.opentelemetry.io/otel/sdk v1.31.0 // indirect + go.opentelemetry.io/otel/trace v1.31.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c3465dc --- /dev/null +++ b/go.sum @@ -0,0 +1,129 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 h1:LdXxtjzvZYhhUaonAaAKArG3pyC67kGL3YY+6hGG8G4= +github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= +github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= +github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= +github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/gogf/gf v1.16.9 h1:Q803UmmRo59+Ws08sMVFOcd8oNpkSWL9vS33hlo/Cyk= +github.com/gogf/gf v1.16.9/go.mod h1:8Q/kw05nlVRp+4vv7XASBsMe9L1tsVKiGoeP2AHnlkk= +github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.7.4 h1:6eaV81MUtE7NUqYR95wOLQcdZ+OlLxn2GEs+rN+wtrM= +github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.7.4/go.mod h1:JjZO8Ic5UxnFVtEY4cDkpFQQ1tx7pX7ZAQnlJ8ux0Kc= +github.com/gogf/gf/v2 v2.7.4 h1:cGHUBO5Jr8ty21GN5EO+S2rFYhprdcqnwS7PnWL7+t4= +github.com/gogf/gf/v2 v2.7.4/go.mod h1:EBXneAg/wes86rfeh68XC0a2JBNQylmT7Sp6/8Axk88= +github.com/gomodule/redigo v1.8.5 h1:nRAxCa+SVsyjSBrtZmG/cqb6VbTmuRzpg/PoTFlpumc= +github.com/gomodule/redigo v1.8.5/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78= +github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= +github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg= +go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= +go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= +go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= +go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= +go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= +go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= +go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY= +go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM= +go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= +go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= +go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs= +go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= +go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= +go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= +go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= +golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/log/2024-11-04.log b/log/2024-11-04.log new file mode 100644 index 0000000..b38c870 --- /dev/null +++ b/log/2024-11-04.log @@ -0,0 +1,3 @@ +2024-11-04 16:57:48.549 {14e8d8ef2eb804182e267b7df4dbc6ae} main.go:30: 初始化成功 +2024-11-04 16:57:54.140 pay.go:27: {ShopId:ccccwsdfwefwefwef Price:65.3 Amount:65.2 Bean:0.1 OpenId:aaaaaaaaaaaaaaaaabbbbbbbb Mobile:15963264270} +2024-11-04 16:57:54.257 200 /wxApi/payQrCode cuowu!!!!! diff --git a/log/sqlLog/2024-11-04.log b/log/sqlLog/2024-11-04.log new file mode 100644 index 0000000..c6e8486 --- /dev/null +++ b/log/sqlLog/2024-11-04.log @@ -0,0 +1,31 @@ +2024-11-04 16:05:15.154 [DEBU] {64b7c1b450b5041821e3ff1223397e38} [103 ms] [default] [test] [rows:0 ] SELECT a.attname AS field, t.typname AS type,a.attnotnull as null, (case when d.contype = 'p' then 'pri' when d.contype = 'u' then 'uni' else '' end) as key ,ic.column_default as default_value,b.description as comment ,coalesce(character_maximum_length, numeric_precision, -1) as length ,numeric_scale as scale FROM pg_attribute a left join pg_class c on a.attrelid = c.oid left join pg_constraint d on d.conrelid = c.oid and a.attnum = d.conkey[1] left join pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid left join pg_type t ON a.atttypid = t.oid left join information_schema.columns ic on ic.column_name = a.attname and ic.table_name = c.relname WHERE c.relname = 'pay_order' and a.attisdropped is false and a.attnum > 0 ORDER BY a.attnum +2024-11-04 16:05:15.173 [ERRO] {988cfdba50b5041822e3ff126c4a2ee6} [ 17 ms] [default] [test] [rows:0 ] SELECT * FROM "pay_order" WHERE orderid = 2 +Error: pq: relation "pay_order" does not exist +Stack: +1. yuleduiPay/service.(*Pay).PayQrCode + C:/Users/Administrator/Desktop/Code/yuleduiPay/service/pay.go:51 +2. yuleduiPay/middle.MiddlewareCORS + C:/Users/Administrator/Desktop/Code/yuleduiPay/middle/middle.go:7 + +2024-11-04 16:05:44.141 [DEBU] {048d897557b5041818db8b7667b34ea7} [ 87 ms] [default] [yuledui] [rows:9 ] SELECT a.attname AS field, t.typname AS type,a.attnotnull as null, (case when d.contype = 'p' then 'pri' when d.contype = 'u' then 'uni' else '' end) as key ,ic.column_default as default_value,b.description as comment ,coalesce(character_maximum_length, numeric_precision, -1) as length ,numeric_scale as scale FROM pg_attribute a left join pg_class c on a.attrelid = c.oid left join pg_constraint d on d.conrelid = c.oid and a.attnum = d.conkey[1] left join pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid left join pg_type t ON a.atttypid = t.oid left join information_schema.columns ic on ic.column_name = a.attname and ic.table_name = c.relname WHERE c.relname = 'pay_order' and a.attisdropped is false and a.attnum > 0 ORDER BY a.attnum +2024-11-04 16:05:44.156 [ERRO] {b809ae7a57b5041819db8b76ec30a2be} [ 14 ms] [default] [yuledui] [rows:0 ] SELECT * FROM "pay_order" WHERE orderid = 2 +Error: pq: column "orderid" does not exist +Stack: +1. yuleduiPay/service.(*Pay).PayQrCode + C:/Users/Administrator/Desktop/Code/yuleduiPay/service/pay.go:51 +2. yuleduiPay/middle.MiddlewareCORS + C:/Users/Administrator/Desktop/Code/yuleduiPay/middle/middle.go:7 + +2024-11-04 16:12:03.361 [DEBU] {7c63e7c0afb5041867655f5b4aea7818} [ 84 ms] [default] [yuledui] [rows:9 ] SELECT a.attname AS field, t.typname AS type,a.attnotnull as null, (case when d.contype = 'p' then 'pri' when d.contype = 'u' then 'uni' else '' end) as key ,ic.column_default as default_value,b.description as comment ,coalesce(character_maximum_length, numeric_precision, -1) as length ,numeric_scale as scale FROM pg_attribute a left join pg_class c on a.attrelid = c.oid left join pg_constraint d on d.conrelid = c.oid and a.attnum = d.conkey[1] left join pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid left join pg_type t ON a.atttypid = t.oid left join information_schema.columns ic on ic.column_name = a.attname and ic.table_name = c.relname WHERE c.relname = 'pay_order' and a.attisdropped is false and a.attnum > 0 ORDER BY a.attnum +2024-11-04 16:12:03.391 [DEBU] {a493fdc5afb5041868655f5b11dd1295} [ 29 ms] [default] [yuledui] [rows:1 ] INSERT INTO "pay_order"("orderId","price","amount","bean","openId","mobile","shopId","created","updated") VALUES('pyacyq0hrw0d5d8r7ssp2ao10069gcnf',65.3,65.2,0.1,'aaaaaaaaaaaaaaaaabbbbbbbb','15963264270','ccccwsdfwefwefwef','2024-11-04 16:12:03','2024-11-04 16:12:03') RETURNING "orderId" +2024-11-04 16:29:09.295 [DEBU] {74d94b9f9eb6041893c9603f4874f219} [ 85 ms] [default] [yuledui] [rows:9 ] SELECT a.attname AS field, t.typname AS type,a.attnotnull as null, (case when d.contype = 'p' then 'pri' when d.contype = 'u' then 'uni' else '' end) as key ,ic.column_default as default_value,b.description as comment ,coalesce(character_maximum_length, numeric_precision, -1) as length ,numeric_scale as scale FROM pg_attribute a left join pg_class c on a.attrelid = c.oid left join pg_constraint d on d.conrelid = c.oid and a.attnum = d.conkey[1] left join pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid left join pg_type t ON a.atttypid = t.oid left join information_schema.columns ic on ic.column_name = a.attname and ic.table_name = c.relname WHERE c.relname = 'pay_order' and a.attisdropped is false and a.attnum > 0 ORDER BY a.attnum +2024-11-04 16:29:09.327 [DEBU] {88da9aa49eb6041894c9603ff239cd00} [ 28 ms] [default] [yuledui] [rows:1 ] INSERT INTO "pay_order"("orderId","price","amount","bean","openId","mobile","shopId","created","updated") VALUES('pyacyq0akg0d5d947s5kla0100d16lio',65.3,65.2,0.1,'aaaaaaaaaaaaaaaaabbbbbbbb','15963264270','ccccwsdfwefwefwef','2024-11-04 16:29:01','2024-11-04 16:29:01') RETURNING "orderId" +2024-11-04 16:29:52.957 [DEBU] {bce0bdc9a8b6041896c9603ffb731790} [ 85 ms] [default] [yuledui] [rows:1 ] INSERT INTO "pay_order"("orderId","price","amount","bean","openId","mobile","shopId","created","updated") VALUES('pyacyq0akg0d5d94tuhxjx0200lurlnt',65.3,65.2,0.1,'aaaaaaaaaaaaaaaaabbbbbbbb','15963264270','ccccwsdfwefwefwef','2024-11-04 16:29:50','2024-11-04 16:29:50') RETURNING "orderId" +2024-11-04 16:30:54.940 [DEBU] {d07fd937b7b604181d9e4d653a5797dd} [ 91 ms] [default] [yuledui] [rows:9 ] SELECT a.attname AS field, t.typname AS type,a.attnotnull as null, (case when d.contype = 'p' then 'pri' when d.contype = 'u' then 'uni' else '' end) as key ,ic.column_default as default_value,b.description as comment ,coalesce(character_maximum_length, numeric_precision, -1) as length ,numeric_scale as scale FROM pg_attribute a left join pg_class c on a.attrelid = c.oid left join pg_constraint d on d.conrelid = c.oid and a.attnum = d.conkey[1] left join pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid left join pg_type t ON a.atttypid = t.oid left join information_schema.columns ic on ic.column_name = a.attname and ic.table_name = c.relname WHERE c.relname = 'pay_order' and a.attisdropped is false and a.attnum > 0 ORDER BY a.attnum +2024-11-04 16:30:54.972 [DEBU] {b8d6583db7b604181e9e4d656f104bed} [ 31 ms] [default] [yuledui] [rows:1 ] INSERT INTO "pay_order"("orderId","price","amount","bean","openId","mobile","shopId","created","updated") VALUES('pyacyq0cfw0d5d95m4jwqac1000wq5ea',65.3,65.2,0.1,'aaaaaaaaaaaaaaaaabbbbbbbb','15963264270','ccccwsdfwefwefwef','2024-11-04 16:30:51','2024-11-04 16:30:51') RETURNING "orderId" +2024-11-04 16:35:49.311 [DEBU] {a02c15c2fbb60418d3785163710dec0f} [ 85 ms] [default] [yuledui] [rows:9 ] SELECT a.attname AS field, t.typname AS type,a.attnotnull as null, (case when d.contype = 'p' then 'pri' when d.contype = 'u' then 'uni' else '' end) as key ,ic.column_default as default_value,b.description as comment ,coalesce(character_maximum_length, numeric_precision, -1) as length ,numeric_scale as scale FROM pg_attribute a left join pg_class c on a.attrelid = c.oid left join pg_constraint d on d.conrelid = c.oid and a.attnum = d.conkey[1] left join pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid left join pg_type t ON a.atttypid = t.oid left join information_schema.columns ic on ic.column_name = a.attname and ic.table_name = c.relname WHERE c.relname = 'pay_order' and a.attisdropped is false and a.attnum > 0 ORDER BY a.attnum +2024-11-04 16:35:49.334 [DEBU] {d4422fc7fbb60418d4785163f713427d} [ 23 ms] [default] [yuledui] [rows:1 ] INSERT INTO "pay_order"("orderId","price","amount","bean","openId","mobile","shopId","created","updated") VALUES('pyacyq0i2c0d5d99dp6usko100d2t9us',65.3,65.2,0.1,'aaaaaaaaaaaaaaaaabbbbbbbb','15963264270','ccccwsdfwefwefwef','2024-11-04 16:35:46','2024-11-04 16:35:46') RETURNING "orderId" +2024-11-04 16:56:37.136 [DEBU] {24f94b491eb80418c0a3bf749f672c2b} [101 ms] [default] [yuledui] [rows:9 ] SELECT a.attname AS field, t.typname AS type,a.attnotnull as null, (case when d.contype = 'p' then 'pri' when d.contype = 'u' then 'uni' else '' end) as key ,ic.column_default as default_value,b.description as comment ,coalesce(character_maximum_length, numeric_precision, -1) as length ,numeric_scale as scale FROM pg_attribute a left join pg_class c on a.attrelid = c.oid left join pg_constraint d on d.conrelid = c.oid and a.attnum = d.conkey[1] left join pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid left join pg_type t ON a.atttypid = t.oid left join information_schema.columns ic on ic.column_name = a.attname and ic.table_name = c.relname WHERE c.relname = 'pay_order' and a.attisdropped is false and a.attnum > 0 ORDER BY a.attnum +2024-11-04 16:56:37.173 [DEBU] {88e6584f1eb80418c1a3bf74ba11171e} [ 37 ms] [default] [yuledui] [rows:1 ] INSERT INTO "pay_order"("orderId","price","amount","bean","openId","mobile","shopId","created","updated") VALUES('pyacyq0x400d5d9pc3v1wco1000o37tg',65.3,65.2,0.1,'aaaaaaaaaaaaaaaaabbbbbbbb','15963264270','ccccwsdfwefwefwef','2024-11-04 16:56:37','2024-11-04 16:56:37') RETURNING "orderId" +2024-11-04 16:57:54.227 [DEBU] {0c4a213d30b8041830267b7d0c54718b} [ 87 ms] [default] [yuledui] [rows:9 ] SELECT a.attname AS field, t.typname AS type,a.attnotnull as null, (case when d.contype = 'p' then 'pri' when d.contype = 'u' then 'uni' else '' end) as key ,ic.column_default as default_value,b.description as comment ,coalesce(character_maximum_length, numeric_precision, -1) as length ,numeric_scale as scale FROM pg_attribute a left join pg_class c on a.attrelid = c.oid left join pg_constraint d on d.conrelid = c.oid and a.attnum = d.conkey[1] left join pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid left join pg_type t ON a.atttypid = t.oid left join information_schema.columns ic on ic.column_name = a.attname and ic.table_name = c.relname WHERE c.relname = 'pay_order' and a.attisdropped is false and a.attnum > 0 ORDER BY a.attnum +2024-11-04 16:57:54.256 [DEBU] {94a7634230b8041831267b7d9a93dcb4} [ 28 ms] [default] [yuledui] [rows:1 ] INSERT INTO "pay_order"("orderId","price","amount","bean","openId","mobile","shopId","created","updated") VALUES('pyacyq0d3g0d5d9qbj1y4uk1001qdhxs',65.3,65.2,0.1,'aaaaaaaaaaaaaaaaabbbbbbbb','15963264270','ccccwsdfwefwefwef','2024-11-04 16:57:54','2024-11-04 16:57:54') RETURNING "orderId" diff --git a/main.go b/main.go new file mode 100644 index 0000000..61788ed --- /dev/null +++ b/main.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "yuleduiPay/controller" + "yuleduiPay/middle" + + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" + + _ "github.com/gogf/gf/contrib/drivers/pgsql/v2" +) + +func main() { + s := g.Server() + ctx := gctx.New() + portStr, err := g.Cfg().Get(ctx, "server.port") + if err != nil { + fmt.Println(err) + return + } + + port := portStr.Int() + s.Use(middle.MiddlewareCORS, middle.MiddlewareHandlerResponse) + payRouter := controller.Pay{} + s.Group("/wxApi", payRouter.RouterGroup) + //s.SetOpenApiPath("/api.json") + //s.SetSwaggerPath("/swagger") //swagger路径 + s.SetPort(port) + g.Log().Line().Print(ctx, "初始化成功") + s.Run() + +} diff --git a/middle/middle.go b/middle/middle.go new file mode 100644 index 0000000..6bac453 --- /dev/null +++ b/middle/middle.go @@ -0,0 +1,69 @@ +package middle + +import ( + "net/http" + + "github.com/gogf/gf/errors/gcode" + "github.com/gogf/gf/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" +) + +// 跨域设置 +func MiddlewareCORS(r *ghttp.Request) { + r.Response.CORSDefault() + r.Middleware.Next() +} + +type DefaultHandlerResponse struct { + Code int `json:"code" dc:"Error code"` + Message string `json:"message" dc:"Error message"` + Data interface{} `json:"data" dc:"Result data for certain request according API definition"` +} + +// 返回值统一处理 +func MiddlewareHandlerResponse(r *ghttp.Request) { + r.Middleware.Next() + + // There's custom buffer content, it then exits current handler. + if r.Response.BufferLength() > 0 { + return + } + + var ( + msg string + err = r.GetError() + res = r.GetHandlerResponse() + code = gerror.Code(err) + ) + if err != nil { + if code == gcode.CodeNil { + code = gcode.CodeInternalError + } + msg = err.Error() + } else { + if r.Response.Status > 0 && r.Response.Status != http.StatusOK { + msg = http.StatusText(r.Response.Status) + switch r.Response.Status { + case http.StatusNotFound: + code = gcode.CodeNotFound + case http.StatusForbidden: + code = gcode.CodeNotAuthorized + default: + code = gcode.CodeUnknown + } + // It creates error as it can be retrieved by other middlewares. + err = gerror.NewCode(code, msg) + r.SetError(err) + } else { + code = gcode.CodeOK + } + } + g.Log().Print(nil, r.Response.Status, r.URL.Path, err) + + r.Response.WriteJson(DefaultHandlerResponse{ + Code: code.Code(), + Message: msg, + Data: res, + }) +} diff --git a/repo/pay_order.go b/repo/pay_order.go new file mode 100644 index 0000000..605a0e6 --- /dev/null +++ b/repo/pay_order.go @@ -0,0 +1,15 @@ +package repo + +import ( + "yuleduiPay/service/po" + + "github.com/gogf/gf/v2/frame/g" +) + +type PayOrder struct { +} + +func (t *PayOrder) CreatePayOrder(payOrder *po.PayOrder) error { + _, err := g.Model("pay_order").Data(payOrder).Insert() + return err +} diff --git a/service/pay.go b/service/pay.go new file mode 100644 index 0000000..3a2d31c --- /dev/null +++ b/service/pay.go @@ -0,0 +1,87 @@ +package service + +import ( + "errors" + "strconv" + "time" + "yuleduiPay/repo" + "yuleduiPay/service/po" + "yuleduiPay/service/vo" + + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/util/guid" +) + +type Pay struct { + payOrderRepo repo.PayOrder +} + +func (t *Pay) PayQrCode(r *ghttp.Request) { + req := vo.PayQrCodeReq{} + err := r.Parse(&req) + if err != nil { + r.Response.Writeln(err) + return + } + g.Log().Line().Printf(nil, "%+v", req) + //获取订单信息 + + //创建订单记录 + payOrder := po.PayOrder{} + payOrder.OrderId = guid.S() + payOrder.Price, err = strconv.ParseFloat(req.Price, 64) + if err != nil { + r.SetError(err) + return + } + payOrder.Amount, err = strconv.ParseFloat(req.Amount, 64) + if err != nil { + r.SetError(err) + return + } + payOrder.Bean, err = strconv.ParseFloat(req.Bean, 64) + if err != nil { + r.SetError(err) + return + } + payOrder.OpenId = req.OpenId + payOrder.Mobile = req.Mobile + payOrder.ShopId = req.ShopId + payOrder.Created = time.Now() + payOrder.Updated = payOrder.Created + + err = t.payOrderRepo.CreatePayOrder(&payOrder) + if err != nil { + r.SetError(err) + return + } + //调用银盛的微信小程序接口(银盛接口) + mMap := g.Map{} + mMap["orderId"] = payOrder.OpenId //订单编号 + mMap["shopdate"] = payOrder.Created.Format("20060102") //商户系统的交易发生日期格式 + mMap["subject"] = "余乐兑小程序订单" //订单备注 + mMap["total_amount"] = payOrder.Amount //该笔订单的资金总额???????? + mMap["currency"] = "CNY" //默认人民币 //订单备注 + mMap["seller_id"] = 0 //???? + mMap["seller_name"] = "商户名称" //??? + mMap["timeout_express"] = "1h" //设置未付款交易的超时时间,一个小时 + mMap["sub_openid"] = payOrder.OpenId //微信OpenId + mMap["is_minipg"] = "1" //微信小程序支付:1 + appId,err = g.Cfg().Get(ctx, "weixin.appId") + if err != nil { + r.SetError(err) + return + } + mMap["appid"] = + + err = errors.New("cuowu!!!!!") + r.SetError(err) + return + /* + resp := vo.PayQrCodeResp{} + resp.Code = 0 + resp.Message = "success" + r.Response.WriteJson(resp) + */ +} diff --git a/service/po/pay_order.go b/service/po/pay_order.go new file mode 100644 index 0000000..738216b --- /dev/null +++ b/service/po/pay_order.go @@ -0,0 +1,15 @@ +package po + +import "time" + +type PayOrder struct { + OrderId string `gorm:"column:orderId"` //订单ID + Price float64 `gorm:"column:price"` //订单原价 + Amount float64 `gorm:"column:amount"` //支付价格 + Bean float64 `gorm:"column:bean"` //金豆抵扣价格 + OpenId string `gorm:"column:openId"` //支付用户微信OpenID + Mobile string `gorm:"column:mobile"` //支付用户手机号 + ShopId string `gorm:"column:shopId"` //商户ID + Created time.Time `gorm:"column:created"` //创建时间 + Updated time.Time `gorm:"column:updated"` //更新时间 +} diff --git a/service/vo/pay.go b/service/vo/pay.go new file mode 100644 index 0000000..3c29928 --- /dev/null +++ b/service/vo/pay.go @@ -0,0 +1,19 @@ +package vo + +type RespBase struct { + Code int `json:"code"` //错误码 + Message string `json:"message"` //成功还是失败 +} + +type PayQrCodeReq struct { + //g.Meta `path:"/wxApi/payQrCode" method:"post" tags:"PayService" summary:"Sign up a new user account"` + ShopId string `json:"shopId"` //商户ID + Price string `json:"price"` //商品原价 + Amount string `json:"amount"` //支付价格 + Bean string `json:"bean"` //抵扣金豆 + OpenId string `json:"openId"` //微信OpenId + Mobile string `json:"mobile"` //支付用户手机号 +} +type PayQrCodeResp struct { + RespBase +}