From d01b31e4eaaa7c9ee0dfa02e2098800696fd4e3e Mon Sep 17 00:00:00 2001 From: jhc Date: Fri, 21 Feb 2025 21:09:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=97=E9=A4=90=20=E9=80=BB=E8=BE=91=20?= =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/bundle/bundle.pb.go | 160 +++++++++++++---------- api/bundle/bundle.proto | 4 +- api/bundle/bundle_triple.pb.go | 67 ++++++++-- cmd/app.go | 24 ++-- cmd/config/config.go | 4 + docs/dev/conf.ini | 14 +- docs/prod/conf.ini | 10 +- go.mod | 32 +++-- go.sum | 12 ++ pkg/common/msg.go | 8 +- pkg/e/code.go | 2 + pkg/e/msg.go | 2 + pkg/model/baidu.go | 12 ++ pkg/model/common.go | 23 ++++ pkg/model/upload.go | 7 + pkg/router/bundle.go | 27 ++++ pkg/router/bundleOrder.go | 33 +++++ pkg/router/router.go | 13 +- pkg/service/base.go | 19 +++ pkg/service/bundle/bundleOrder.go | 41 +++++- pkg/service/bundle/common/msg.go | 22 ++++ pkg/{ => service/bundle}/common/time.go | 0 pkg/service/bundle/logic/signContract.go | 81 ++++++++++++ pkg/service/bundle/model/orderStatus.go | 6 + pkg/service/bundle/pay.go | 137 +++++++++++++++++++ pkg/service/init.go | 5 +- 26 files changed, 633 insertions(+), 132 deletions(-) create mode 100644 pkg/model/baidu.go create mode 100644 pkg/model/common.go create mode 100644 pkg/model/upload.go create mode 100644 pkg/router/bundle.go create mode 100644 pkg/router/bundleOrder.go create mode 100644 pkg/service/bundle/common/msg.go rename pkg/{ => service/bundle}/common/time.go (100%) create mode 100644 pkg/service/bundle/logic/signContract.go create mode 100644 pkg/service/bundle/model/orderStatus.go create mode 100644 pkg/service/bundle/pay.go diff --git a/api/bundle/bundle.pb.go b/api/bundle/bundle.pb.go index 0962894..c6f5421 100644 --- a/api/bundle/bundle.pb.go +++ b/api/bundle/bundle.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 -// protoc v5.29.0--rc3 +// protoc-gen-go v1.26.0 +// protoc v3.10.1 // source: pb/bundle.proto package bundle @@ -480,7 +480,7 @@ type OrderRecord struct { PayTime string `protobuf:"bytes,12,opt,name=payTime,proto3" json:"payTime,omitempty"` CheckoutSessionId string `protobuf:"bytes,13,opt,name=checkoutSessionId,proto3" json:"checkoutSessionId,omitempty"` CheckoutSessionUrl string `protobuf:"bytes,14,opt,name=checkoutSessionUrl,proto3" json:"checkoutSessionUrl,omitempty"` - Status string `protobuf:"bytes,15,opt,name=status,proto3" json:"status,omitempty"` + Status int64 `protobuf:"varint,15,opt,name=status,proto3" json:"status,omitempty"` OrderNo string `protobuf:"bytes,16,opt,name=orderNo,proto3" json:"orderNo,omitempty"` BundleName string `protobuf:"bytes,17,opt,name=bundleName,proto3" json:"bundleName,omitempty"` } @@ -615,11 +615,11 @@ func (x *OrderRecord) GetCheckoutSessionUrl() string { return "" } -func (x *OrderRecord) GetStatus() string { +func (x *OrderRecord) GetStatus() int64 { if x != nil { return x.Status } - return "" + return 0 } func (x *OrderRecord) GetOrderNo() string { @@ -839,7 +839,8 @@ type OrderRecordsDetailRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` + Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` + OrderNo string `protobuf:"bytes,2,opt,name=orderNo,proto3" json:"orderNo,omitempty"` } func (x *OrderRecordsDetailRequest) Reset() { @@ -881,6 +882,13 @@ func (x *OrderRecordsDetailRequest) GetUuid() string { return "" } +func (x *OrderRecordsDetailRequest) GetOrderNo() string { + if x != nil { + return x.OrderNo + } + return "" +} + type OrderRecordsDetailResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1013,7 +1021,7 @@ var file_pb_bundle_proto_rawDesc = []byte{ 0x2e, 0x0a, 0x12, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x6f, 0x75, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x6f, 0x75, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x12, - 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x12, 0x1e, 0x0a, 0x0a, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, @@ -1051,60 +1059,66 @@ var file_pb_bundle_proto_rawDesc = []byte{ 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x22, 0x2f, 0x0a, 0x19, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x22, 0x49, 0x0a, 0x19, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x22, 0x65, 0x0a, - 0x1a, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x44, 0x65, 0x74, - 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x0b, 0x6f, - 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x13, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, - 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x0b, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, - 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6d, 0x73, 0x67, 0x32, 0x9a, 0x05, 0x0a, 0x06, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x12, - 0x3f, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x12, - 0x15, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x50, - 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x1a, 0x16, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x3f, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, - 0x12, 0x15, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, - 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x1a, 0x16, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x42, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x75, 0x6e, 0x64, 0x6c, - 0x65, 0x12, 0x18, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x42, 0x75, - 0x6e, 0x64, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x62, 0x75, - 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x0a, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4c, - 0x69, 0x73, 0x74, 0x12, 0x19, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x42, 0x75, 0x6e, - 0x64, 0x6c, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, - 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0c, - 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x1b, 0x2e, 0x62, - 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x44, 0x65, 0x74, 0x61, - 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x62, 0x75, 0x6e, 0x64, - 0x6c, 0x65, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x11, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x13, - 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, - 0x6f, 0x72, 0x64, 0x1a, 0x16, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x42, 0x0a, - 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, - 0x72, 0x64, 0x12, 0x13, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, - 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x1a, 0x16, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x4f, 0x0a, 0x10, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, - 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1b, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, - 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, - 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x5d, 0x0a, 0x12, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, - 0x64, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x21, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, - 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x62, 0x75, - 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, - 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x22, 0x65, 0x0a, 0x1a, 0x4f, 0x72, 0x64, 0x65, 0x72, + 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x0b, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, + 0x63, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x75, 0x6e, + 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, + 0x0b, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, + 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0xe7, + 0x05, 0x0a, 0x06, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x3f, 0x0a, 0x0c, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x15, 0x2e, 0x62, 0x75, 0x6e, 0x64, + 0x6c, 0x65, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, + 0x1a, 0x16, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x0c, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x15, 0x2e, 0x62, 0x75, 0x6e, + 0x64, 0x6c, 0x65, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, + 0x65, 0x1a, 0x16, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x0c, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x18, 0x2e, 0x62, 0x75, + 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x43, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x45, 0x0a, 0x0a, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x19, 0x2e, + 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, + 0x65, 0x2e, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0c, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, + 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x1b, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, + 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x42, 0x75, 0x6e, + 0x64, 0x6c, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, + 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x13, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, + 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x1a, 0x16, 0x2e, + 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x13, 0x2e, 0x62, + 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, + 0x64, 0x1a, 0x16, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x1a, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, + 0x42, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x12, 0x13, 0x2e, 0x62, 0x75, 0x6e, 0x64, + 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x1a, 0x16, + 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x10, 0x4f, 0x72, 0x64, 0x65, + 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1b, 0x2e, 0x62, + 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, + 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x62, 0x75, 0x6e, 0x64, + 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5d, 0x0a, 0x12, 0x4f, 0x72, 0x64, + 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, + 0x21, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, + 0x63, 0x6f, 0x72, 0x64, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, + 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x62, 0x75, + 0x6e, 0x64, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1146,19 +1160,21 @@ var file_pb_bundle_proto_depIdxs = []int32{ 5, // 8: bundle.Bundle.BundleDetail:input_type -> bundle.BundleDetailRequest 7, // 9: bundle.Bundle.CreateOrderRecord:input_type -> bundle.OrderRecord 7, // 10: bundle.Bundle.UpdateOrderRecord:input_type -> bundle.OrderRecord - 8, // 11: bundle.Bundle.OrderRecordsList:input_type -> bundle.OrderRecordsRequest - 10, // 12: bundle.Bundle.OrderRecordsDetail:input_type -> bundle.OrderRecordsDetailRequest - 0, // 13: bundle.Bundle.CreateBundle:output_type -> bundle.CommonResponse - 0, // 14: bundle.Bundle.UpdateBundle:output_type -> bundle.CommonResponse - 0, // 15: bundle.Bundle.DeleteBundle:output_type -> bundle.CommonResponse - 4, // 16: bundle.Bundle.BundleList:output_type -> bundle.BundleListResponse - 6, // 17: bundle.Bundle.BundleDetail:output_type -> bundle.BundleDetailResponse - 0, // 18: bundle.Bundle.CreateOrderRecord:output_type -> bundle.CommonResponse - 0, // 19: bundle.Bundle.UpdateOrderRecord:output_type -> bundle.CommonResponse - 9, // 20: bundle.Bundle.OrderRecordsList:output_type -> bundle.OrderRecordsResponse - 11, // 21: bundle.Bundle.OrderRecordsDetail:output_type -> bundle.OrderRecordsDetailResponse - 13, // [13:22] is the sub-list for method output_type - 4, // [4:13] is the sub-list for method input_type + 7, // 11: bundle.Bundle.UpdateOrderRecordByOrderNo:input_type -> bundle.OrderRecord + 8, // 12: bundle.Bundle.OrderRecordsList:input_type -> bundle.OrderRecordsRequest + 10, // 13: bundle.Bundle.OrderRecordsDetail:input_type -> bundle.OrderRecordsDetailRequest + 0, // 14: bundle.Bundle.CreateBundle:output_type -> bundle.CommonResponse + 0, // 15: bundle.Bundle.UpdateBundle:output_type -> bundle.CommonResponse + 0, // 16: bundle.Bundle.DeleteBundle:output_type -> bundle.CommonResponse + 4, // 17: bundle.Bundle.BundleList:output_type -> bundle.BundleListResponse + 6, // 18: bundle.Bundle.BundleDetail:output_type -> bundle.BundleDetailResponse + 0, // 19: bundle.Bundle.CreateOrderRecord:output_type -> bundle.CommonResponse + 0, // 20: bundle.Bundle.UpdateOrderRecord:output_type -> bundle.CommonResponse + 0, // 21: bundle.Bundle.UpdateOrderRecordByOrderNo:output_type -> bundle.CommonResponse + 9, // 22: bundle.Bundle.OrderRecordsList:output_type -> bundle.OrderRecordsResponse + 11, // 23: bundle.Bundle.OrderRecordsDetail:output_type -> bundle.OrderRecordsDetailResponse + 14, // [14:24] is the sub-list for method output_type + 4, // [4:14] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension extendee 0, // [0:4] is the sub-list for field type_name diff --git a/api/bundle/bundle.proto b/api/bundle/bundle.proto index 32687ff..c142f87 100644 --- a/api/bundle/bundle.proto +++ b/api/bundle/bundle.proto @@ -13,6 +13,7 @@ service Bundle { rpc CreateOrderRecord(OrderRecord) returns (CommonResponse) {} rpc UpdateOrderRecord(OrderRecord) returns (CommonResponse) {} + rpc UpdateOrderRecordByOrderNo(OrderRecord) returns (CommonResponse) {} rpc OrderRecordsList(OrderRecordsRequest) returns (OrderRecordsResponse) {} rpc OrderRecordsDetail(OrderRecordsDetailRequest) returns (OrderRecordsDetailResponse) {} @@ -75,7 +76,7 @@ message OrderRecord { string payTime = 12 [json_name = "payTime"]; string checkoutSessionId = 13 [json_name = "checkoutSessionId"]; string checkoutSessionUrl = 14 [json_name = "checkoutSessionUrl"]; - string status = 15 [json_name = "status"]; + int64 status = 15 [json_name = "status"]; string orderNo = 16 [json_name = "orderNo"]; string bundleName = 17 [json_name = "bundleName"]; } @@ -103,6 +104,7 @@ message OrderRecordsResponse { message OrderRecordsDetailRequest { string uuid = 1 [json_name = "uuid"]; + string orderNo = 2 [json_name = "orderNo"]; } message OrderRecordsDetailResponse { diff --git a/api/bundle/bundle_triple.pb.go b/api/bundle/bundle_triple.pb.go index 1691f10..eca8ba7 100644 --- a/api/bundle/bundle_triple.pb.go +++ b/api/bundle/bundle_triple.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-triple. DO NOT EDIT. // versions: -// - protoc-gen-go-triple v1.0.5 -// - protoc v5.29.0--rc3 +// - protoc-gen-go-triple v1.0.8 +// - protoc v3.10.1 // source: pb/bundle.proto package bundle @@ -35,6 +35,7 @@ type BundleClient interface { BundleDetail(ctx context.Context, in *BundleDetailRequest, opts ...grpc_go.CallOption) (*BundleDetailResponse, common.ErrorWithAttachment) CreateOrderRecord(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) UpdateOrderRecord(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) + UpdateOrderRecordByOrderNo(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) OrderRecordsList(ctx context.Context, in *OrderRecordsRequest, opts ...grpc_go.CallOption) (*OrderRecordsResponse, common.ErrorWithAttachment) OrderRecordsDetail(ctx context.Context, in *OrderRecordsDetailRequest, opts ...grpc_go.CallOption) (*OrderRecordsDetailResponse, common.ErrorWithAttachment) } @@ -44,15 +45,16 @@ type bundleClient struct { } type BundleClientImpl struct { - CreateBundle func(ctx context.Context, in *BundleProfile) (*CommonResponse, error) - UpdateBundle func(ctx context.Context, in *BundleProfile) (*CommonResponse, error) - DeleteBundle func(ctx context.Context, in *DelBundleRequest) (*CommonResponse, error) - BundleList func(ctx context.Context, in *BundleListRequest) (*BundleListResponse, error) - BundleDetail func(ctx context.Context, in *BundleDetailRequest) (*BundleDetailResponse, error) - CreateOrderRecord func(ctx context.Context, in *OrderRecord) (*CommonResponse, error) - UpdateOrderRecord func(ctx context.Context, in *OrderRecord) (*CommonResponse, error) - OrderRecordsList func(ctx context.Context, in *OrderRecordsRequest) (*OrderRecordsResponse, error) - OrderRecordsDetail func(ctx context.Context, in *OrderRecordsDetailRequest) (*OrderRecordsDetailResponse, error) + CreateBundle func(ctx context.Context, in *BundleProfile) (*CommonResponse, error) + UpdateBundle func(ctx context.Context, in *BundleProfile) (*CommonResponse, error) + DeleteBundle func(ctx context.Context, in *DelBundleRequest) (*CommonResponse, error) + BundleList func(ctx context.Context, in *BundleListRequest) (*BundleListResponse, error) + BundleDetail func(ctx context.Context, in *BundleDetailRequest) (*BundleDetailResponse, error) + CreateOrderRecord func(ctx context.Context, in *OrderRecord) (*CommonResponse, error) + UpdateOrderRecord func(ctx context.Context, in *OrderRecord) (*CommonResponse, error) + UpdateOrderRecordByOrderNo func(ctx context.Context, in *OrderRecord) (*CommonResponse, error) + OrderRecordsList func(ctx context.Context, in *OrderRecordsRequest) (*OrderRecordsResponse, error) + OrderRecordsDetail func(ctx context.Context, in *OrderRecordsDetailRequest) (*OrderRecordsDetailResponse, error) } func (c *BundleClientImpl) GetDubboStub(cc *triple.TripleConn) BundleClient { @@ -109,6 +111,12 @@ func (c *bundleClient) UpdateOrderRecord(ctx context.Context, in *OrderRecord, o return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateOrderRecord", in, out) } +func (c *bundleClient) UpdateOrderRecordByOrderNo(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) { + out := new(CommonResponse) + interfaceKey := ctx.Value(constant.InterfaceKey).(string) + return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateOrderRecordByOrderNo", in, out) +} + func (c *bundleClient) OrderRecordsList(ctx context.Context, in *OrderRecordsRequest, opts ...grpc_go.CallOption) (*OrderRecordsResponse, common.ErrorWithAttachment) { out := new(OrderRecordsResponse) interfaceKey := ctx.Value(constant.InterfaceKey).(string) @@ -132,6 +140,7 @@ type BundleServer interface { BundleDetail(context.Context, *BundleDetailRequest) (*BundleDetailResponse, error) CreateOrderRecord(context.Context, *OrderRecord) (*CommonResponse, error) UpdateOrderRecord(context.Context, *OrderRecord) (*CommonResponse, error) + UpdateOrderRecordByOrderNo(context.Context, *OrderRecord) (*CommonResponse, error) OrderRecordsList(context.Context, *OrderRecordsRequest) (*OrderRecordsResponse, error) OrderRecordsDetail(context.Context, *OrderRecordsDetailRequest) (*OrderRecordsDetailResponse, error) mustEmbedUnimplementedBundleServer() @@ -163,6 +172,9 @@ func (UnimplementedBundleServer) CreateOrderRecord(context.Context, *OrderRecord func (UnimplementedBundleServer) UpdateOrderRecord(context.Context, *OrderRecord) (*CommonResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateOrderRecord not implemented") } +func (UnimplementedBundleServer) UpdateOrderRecordByOrderNo(context.Context, *OrderRecord) (*CommonResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateOrderRecordByOrderNo not implemented") +} func (UnimplementedBundleServer) OrderRecordsList(context.Context, *OrderRecordsRequest) (*OrderRecordsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OrderRecordsList not implemented") } @@ -400,6 +412,35 @@ func _Bundle_UpdateOrderRecord_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Bundle_UpdateOrderRecordByOrderNo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { + in := new(OrderRecord) + if err := dec(in); err != nil { + return nil, err + } + base := srv.(dubbo3.Dubbo3GrpcService) + args := []interface{}{} + args = append(args, in) + md, _ := metadata.FromIncomingContext(ctx) + invAttachment := make(map[string]interface{}, len(md)) + for k, v := range md { + invAttachment[k] = v + } + invo := invocation.NewRPCInvocation("UpdateOrderRecordByOrderNo", args, invAttachment) + if interceptor == nil { + result := base.XXX_GetProxyImpl().Invoke(ctx, invo) + return result, result.Error() + } + info := &grpc_go.UnaryServerInfo{ + Server: srv, + FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + result := base.XXX_GetProxyImpl().Invoke(ctx, invo) + return result, result.Error() + } + return interceptor(ctx, in, info, handler) +} + func _Bundle_OrderRecordsList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { in := new(OrderRecordsRequest) if err := dec(in); err != nil { @@ -493,6 +534,10 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{ MethodName: "UpdateOrderRecord", Handler: _Bundle_UpdateOrderRecord_Handler, }, + { + MethodName: "UpdateOrderRecordByOrderNo", + Handler: _Bundle_UpdateOrderRecordByOrderNo_Handler, + }, { MethodName: "OrderRecordsList", Handler: _Bundle_OrderRecordsList_Handler, diff --git a/cmd/app.go b/cmd/app.go index 10a7a43..50efa4b 100644 --- a/cmd/app.go +++ b/cmd/app.go @@ -20,8 +20,6 @@ package main import ( "fmt" "fonchain-fiee/cmd/config" - "fonchain-fiee/pkg/cache" - "fonchain-fiee/pkg/common/gpt" "fonchain-fiee/pkg/router" ) @@ -45,16 +43,16 @@ func bootstrap() (err error) { fmt.Println(configEnv) fmt.Println(config.AppConfig) - //redis - redisConfig := cache.RedisConfig{ - RedisDB: configEnv.Redis.RedisDB, - RedisAddr: configEnv.Redis.RedisAddr, - RedisPw: configEnv.Redis.RedisPW, - RedisDbName: configEnv.Redis.RedisDBNAme, - } - - cache.LoadRedis(redisConfig) - - gpt.InitSet(configEnv.Ai.Host, configEnv.Ai.TelNum, configEnv.Ai.Password) + ////redis + //redisConfig := cache.RedisConfig{ + // RedisDB: configEnv.Redis.RedisDB, + // RedisAddr: configEnv.Redis.RedisAddr, + // RedisPw: configEnv.Redis.RedisPW, + // RedisDbName: configEnv.Redis.RedisDBNAme, + //} + // + //cache.LoadRedis(redisConfig) + // + //gpt.InitSet(configEnv.Ai.Host, configEnv.Ai.TelNum, configEnv.Ai.Password) return nil } diff --git a/cmd/config/config.go b/cmd/config/config.go index 40af4a9..967b326 100644 --- a/cmd/config/config.go +++ b/cmd/config/config.go @@ -86,6 +86,8 @@ var ( Key string PubKey string } + + Webhookkey string ) /********start-配置信息*********/ @@ -259,4 +261,6 @@ func LoadServer(file *ini.File) { Aliyun.AccessKeySecret = file.Section("aliyun").Key("accessKeySecret").String() Blockchain.PubKey = file.Section("blockchain").Key("PubKey").String() Blockchain.Key = file.Section("blockchain").Key("Key").String() + + Webhookkey = file.Section("stripe").Key("Webhookkey").String() } diff --git a/docs/dev/conf.ini b/docs/dev/conf.ini index 0fe5b0b..b91eb42 100644 --- a/docs/dev/conf.ini +++ b/docs/dev/conf.ini @@ -22,4 +22,16 @@ RedisDBNAme = "1" [ai] Host = "https://erpapi.fontree.cn" TelNum = "18021272627" -Password = "Gy.123456" \ No newline at end of file +Password = "Gy.123456" + +[stripe] +Webhookkey = "we_1QuursAB1Vm8VfJquKmHQSVg" + + +[oss] +AccessKeyId = "LTAI5tLz1fSK53FQAEC9uNSb" +AccessKeySecret = "oGB9chrQzQzITXR2IGv37Ji5WxZh4j" +Endpoint = "oss-cn-hangzhou.aliyuncs.com" +BucketName = "fontree-test" +BaseDir = "fiee" +CdnHost = "https://cdn-test.szjixun.cn" \ No newline at end of file diff --git a/docs/prod/conf.ini b/docs/prod/conf.ini index 0fe5b0b..8b8f14b 100644 --- a/docs/prod/conf.ini +++ b/docs/prod/conf.ini @@ -22,4 +22,12 @@ RedisDBNAme = "1" [ai] Host = "https://erpapi.fontree.cn" TelNum = "18021272627" -Password = "Gy.123456" \ No newline at end of file +Password = "Gy.123456" + +[oss] +AccessKeyId = "LTAI5tHfjSmWXHqfWgaL7Uo5" +AccessKeySecret = "kOPctFZ3DHsbdSSym1fLyDK39hkzPI" +Endpoint = "oss-cn-hangzhou-internal.aliyuncs.com" +BucketName = "erp-k8s-store" +BaseDir = "fiee" +CdnHost = "https://e-cdn.fontree.cn" \ No newline at end of file diff --git a/go.mod b/go.mod index 9128b16..e969d89 100644 --- a/go.mod +++ b/go.mod @@ -9,20 +9,20 @@ replace ( //github.com/fonchain_enterprise/utils/logger => ./docs/utils/logger //github.com/fonchain_enterprise/utils/rand => ./docs/utils/rand - github.com/fonchain/electronic-contract => ../../electronic-contract - github.com/fonchain_enterprise/utils/aes => ../utils/aes - github.com/fonchain_enterprise/utils/baidu => ../utils/baidu - github.com/fonchain_enterprise/utils/bankQuery => ../utils/bankQuery - github.com/fonchain_enterprise/utils/chain => ../utils/chain - github.com/fonchain_enterprise/utils/feie => ../utils/feie - github.com/fonchain_enterprise/utils/ipAddrQuery => ../utils/ipAddrQuery - github.com/fonchain_enterprise/utils/jwt => ../utils/jwt - github.com/fonchain_enterprise/utils/logger => ../utils/logger + //github.com/fonchain/electronic-contract => ../../electronic-contract + //github.com/fonchain_enterprise/utils/aes => ../utils/aes + //github.com/fonchain_enterprise/utils/baidu => ../utils/baidu + //github.com/fonchain_enterprise/utils/bankQuery => ../utils/bankQuery + //github.com/fonchain_enterprise/utils/chain => ../utils/chain + //github.com/fonchain_enterprise/utils/feie => ../utils/feie + //github.com/fonchain_enterprise/utils/ipAddrQuery => ../utils/ipAddrQuery + //github.com/fonchain_enterprise/utils/jwt => ../utils/jwt + //github.com/fonchain_enterprise/utils/logger => ../utils/logger github.com/fonchain_enterprise/utils/objstorage => ../utils/objstorage - github.com/fonchain_enterprise/utils/ocr => ../utils/ocr - github.com/fonchain_enterprise/utils/pay => ../utils/pay - github.com/fonchain_enterprise/utils/rand => ../utils/rand - github.com/fonchain_enterprise/utils/utils => ../utils/utils + //github.com/fonchain_enterprise/utils/ocr => ../utils/ocr + //github.com/fonchain_enterprise/utils/pay => ../utils/pay + //github.com/fonchain_enterprise/utils/rand => ../utils/rand + //github.com/fonchain_enterprise/utils/utils => ../utils/utils ) @@ -134,6 +134,7 @@ require ( github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/disintegration/imaging v1.6.2 // indirect github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 // indirect github.com/emicklei/go-restful/v3 v3.7.4 // indirect github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 // indirect @@ -162,9 +163,12 @@ require ( github.com/nxadm/tail v1.4.11 // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/onsi/gomega v1.18.1 // indirect + github.com/phpdave11/gofpdi v1.0.14-0.20211212211723-1f10f9844311 // indirect github.com/pierrec/lz4 v2.5.2+incompatible // indirect github.com/polarismesh/polaris-go v1.1.0 // indirect + github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd // indirect github.com/shirou/gopsutil/v3 v3.21.6 // indirect + github.com/signintech/gopdf v0.29.2 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/smartystreets/assertions v1.1.1 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect @@ -173,6 +177,7 @@ require ( github.com/spf13/jwalterweatherman v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.2.0 // indirect + github.com/tealeg/xlsx v1.0.5 // indirect github.com/tklauser/go-sysconf v0.3.6 // indirect github.com/tklauser/numcpus v0.2.2 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect @@ -183,6 +188,7 @@ require ( go.opentelemetry.io/otel v1.7.0 // indirect go.opentelemetry.io/otel/trace v1.7.0 // indirect golang.org/x/arch v0.3.0 // indirect + golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect golang.org/x/sync v0.1.0 // indirect golang.org/x/time v0.3.0 // indirect diff --git a/go.sum b/go.sum index aa93cc3..3e48fba 100644 --- a/go.sum +++ b/go.sum @@ -174,6 +174,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c= +github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4= github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 h1:XoR8SSVziXe698dt4uZYDfsmHpKLemqAgFyndQsq5Kw= github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= @@ -665,6 +667,8 @@ github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZO github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/phpdave11/gofpdi v1.0.14-0.20211212211723-1f10f9844311 h1:zyWXQ6vu27ETMpYsEMAsisQ+GqJ4e1TPvSNfdOPF0no= +github.com/phpdave11/gofpdi v1.0.14-0.20211212211723-1f10f9844311/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.5.2+incompatible h1:WCjObylUIOlKy/+7Abdn34TLIkXiA4UWUMhxq9m9ZXI= @@ -738,6 +742,8 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd h1:CmH9+J6ZSsIjUK3dcGsnCnO41eRBOnY12zwkn5qVwgc= +github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= @@ -750,6 +756,8 @@ github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMT github.com/shirou/gopsutil/v3 v3.21.6 h1:vU7jrp1Ic/2sHB7w6UNs7MIkn7ebVtTb5D9j45o9VYE= github.com/shirou/gopsutil/v3 v3.21.6/go.mod h1:JfVbDpIBLVzT8oKbvMg9P3wEIMDDpVn+LwHTKj0ST88= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/signintech/gopdf v0.29.2 h1:ksvYuHNwEBP8Mi/4q5MN1ZdW9OpMbWn3pEn3ewiWoSc= +github.com/signintech/gopdf v0.29.2/go.mod h1:d23eO35GpEliSrF22eJ4bsM3wVeQJTjXTHq5x5qGKjA= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= @@ -810,6 +818,8 @@ github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gt github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE= +github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM= github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k= @@ -943,6 +953,8 @@ golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8H golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U= +golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/pkg/common/msg.go b/pkg/common/msg.go index a590072..013ee4f 100644 --- a/pkg/common/msg.go +++ b/pkg/common/msg.go @@ -1,7 +1,9 @@ package common -// 套餐 +// upload const ( - MissBundleUUID = "缺少套餐UUID" - MissOrderSignature = "缺少客户签名信息" + ERROR_OPEN_FILE = "打开文件错误" + ErrorImgExt = "图片格式错误" + ErrorImgDecode = "图片解析错误" + ERROR_ROTATE_IMG = "旋转图片出错" ) diff --git a/pkg/e/code.go b/pkg/e/code.go index 5b5ed25..269a550 100644 --- a/pkg/e/code.go +++ b/pkg/e/code.go @@ -29,6 +29,8 @@ const ( Ok = 0 BindError = 2 JsonUnmarshal = 3 + ErrorHttp = 5 + ErrorBody = 6 NotLogin = 401 SUCCESS = 200 UpdatePasswordSuccess = 201 diff --git a/pkg/e/msg.go b/pkg/e/msg.go index 2908091..0959ede 100644 --- a/pkg/e/msg.go +++ b/pkg/e/msg.go @@ -46,6 +46,8 @@ var MsgFlags = map[int]string{ InvalidParams: "请求参数错误", BindError: "参数绑定错误,类型不一致", JsonUnmarshal: "Json解析错误", + ErrorHttp: "请求错误", + ErrorBody: "响应错误", ErrorExistNick: "已存在该昵称", ErrorExistUser: "已存在该用户名", diff --git a/pkg/model/baidu.go b/pkg/model/baidu.go new file mode 100644 index 0000000..1d0c1a9 --- /dev/null +++ b/pkg/model/baidu.go @@ -0,0 +1,12 @@ +package model + +type BaiduAccessToken struct { + Refresh_token string `json:"refresh_token"` + Expires_in uint64 `json:"expires_in"` + Scope string `json:"scope"` + Session_key string `json:"session_key"` + Access_token string `json:"access_token"` + Session_secret string `json:"session_secret"` + Error string `json:"error"` + Error_description string `json:"error_description"` +} diff --git a/pkg/model/common.go b/pkg/model/common.go new file mode 100644 index 0000000..54efde5 --- /dev/null +++ b/pkg/model/common.go @@ -0,0 +1,23 @@ +package model + +const ( + HttpType = "http://" + HttpsType = "https://" + TmpArtworkDir = "./runtime/tmp/artworks" + TmpArtistDir = "./runtime/tmp/artists" + MediaPath = "./runtime/" + TplPath = "./data/" + ImgActionRotate = "rotate" //旋转 + MediaTypeVideo = "video" + MediaTypeImage = "video" +) + +const ( + DateTimeFormat = "2006-01-02 15:04:05" + DateFormat = "2006-01-02" +) + +type RespSendIndexes struct { + Code int `json:"code"` + Msg string `json:"msg"` +} diff --git a/pkg/model/upload.go b/pkg/model/upload.go new file mode 100644 index 0000000..8fb9f40 --- /dev/null +++ b/pkg/model/upload.go @@ -0,0 +1,7 @@ +package model + +type UploadInfo struct { + Url string + Err string + FileKName string +} diff --git a/pkg/router/bundle.go b/pkg/router/bundle.go new file mode 100644 index 0000000..5f8d766 --- /dev/null +++ b/pkg/router/bundle.go @@ -0,0 +1,27 @@ +package router + +import ( + "fonchain-fiee/pkg/service/bundle" + "github.com/gin-gonic/gin" +) + +func BundleRouter(r *gin.RouterGroup) { + bundleRoute := r.Group("bundle") + + // 套餐 + { + bundleClientRoute := bundleRoute.Group("system") + { + bundleClientRoute.POST("create", bundle.CreateBundle) + bundleClientRoute.POST("update", bundle.UpdateBundle) + bundleClientRoute.POST("remove", bundle.DeleteBundle) + } + + bundleAppRoute := bundleRoute.Group("common") + { + bundleAppRoute.POST("bundle-list", bundle.BundleList) + } + + } + +} diff --git a/pkg/router/bundleOrder.go b/pkg/router/bundleOrder.go new file mode 100644 index 0000000..d47be59 --- /dev/null +++ b/pkg/router/bundleOrder.go @@ -0,0 +1,33 @@ +package router + +import ( + "fonchain-fiee/pkg/service/bundle" + "github.com/gin-gonic/gin" +) + +func BundleOrderRouter(r *gin.RouterGroup) { + + r.POST("/stripe-pay/callback", bundle.StripeCheckoutSessionWebhook) + + bundleOrderRoute := r.Group("bundle-order") + + // 套餐 + { + bundleOrderClientRoute := bundleOrderRoute.Group("common") + { + bundleOrderClientRoute.POST("bundle-order-list", bundle.OrderRecordsList) + } + + bundleOrderAppRoute := bundleOrderRoute.Group("app") + { + bundleOrderAppRoute.POST("order-signature", bundle.CreateBundleOrderSignature) + bundleOrderAppRoute.POST("update-Pay", bundle.UpdateBundleOrderStatusPaid) + bundleOrderAppRoute.POST("order-detail", bundle.OrderRecordsDetail) + + // stripe + bundleOrderAppRoute.POST("create-stripe-pay", bundle.CreateStripeCheckoutSession) + } + + } + +} diff --git a/pkg/router/router.go b/pkg/router/router.go index 36064ea..9bef297 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -36,6 +36,9 @@ func NewRouter() *gin.Engine { return }) + BundleRouter(privateGroup) + BundleOrderRouter(privateGroup) + { v1.POST("version", version.Version) //版本号公共 } @@ -89,16 +92,6 @@ func NewRouter() *gin.Engine { redirectRoute.POST("sdk/down/v3", auth.DownImgV3) } - // 套餐 - { - //bundleRoute := r.Group("bundle") - - //bundleClientRoute := bundleRoute.Group("system") - { - //bundleClientRoute.POST("create", bundle.CreateBundle) - } - } - //静态文件 r.StaticFS("/static", http.Dir("./runtime")) r.NoRoute(func(c *gin.Context) { diff --git a/pkg/service/base.go b/pkg/service/base.go index 4a7cbcb..5f788d5 100644 --- a/pkg/service/base.go +++ b/pkg/service/base.go @@ -8,6 +8,8 @@ import ( const ( Failed = 1 Ok = 0 + + RetryCode = 2 ) // Response 基础序列化器 @@ -16,6 +18,7 @@ type Response struct { Data interface{} `json:"data"` Msg string `json:"msg"` Code int `json:"code"` + Error error `json:"error"` } // Success Success(c,someMap) datas传结构体中文会有乱码问题 @@ -51,3 +54,19 @@ func Error(c *gin.Context, err error) { c.Abort() } + +// 重试 +func Retry(c *gin.Context, err error) { + errMsg := "" + if err != nil { + errMsg = err.Error() + } + + c.JSON(http.StatusOK, Response{ + Code: RetryCode, + Msg: errMsg, + Data: struct{}{}, + }) + + c.Abort() +} diff --git a/pkg/service/bundle/bundleOrder.go b/pkg/service/bundle/bundleOrder.go index 33e238a..448432e 100644 --- a/pkg/service/bundle/bundleOrder.go +++ b/pkg/service/bundle/bundleOrder.go @@ -4,13 +4,16 @@ import ( "context" "errors" "fonchain-fiee/api/bundle" - "fonchain-fiee/pkg/common" + "fonchain-fiee/pkg/model/login" "fonchain-fiee/pkg/service" + "fonchain-fiee/pkg/service/bundle/common" + bundleModel "fonchain-fiee/pkg/service/bundle/model" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" + "strconv" ) -func CreateBundleOrder(c *gin.Context) { +func CreateBundleOrderSignature(c *gin.Context) { var req bundle.OrderRecord if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil { @@ -29,6 +32,11 @@ func CreateBundleOrder(c *gin.Context) { } // 获取 用户信息 + userInfo := login.GetUserInfoFromC(c) + + req.CustomerNum = userInfo.SubNum + req.CustomerName = userInfo.Name + req.CustomerID = strconv.FormatUint(userInfo.ID, 10) // 获取 套餐信息 bundleDetailReq := &bundle.BundleDetailRequest{ @@ -49,6 +57,8 @@ func CreateBundleOrder(c *gin.Context) { req.SignedTime = common.GetBeijingTime() + req.Status = bundleModel.OrderSigned + res, err := service.BundleProvider.CreateOrderRecord(context.Background(), &req) if err != nil { service.Error(c, err) @@ -58,7 +68,7 @@ func CreateBundleOrder(c *gin.Context) { service.Success(c, res) } -func UpdateBundleOrder(c *gin.Context) { +func UpdateBundleOrderStatusPaid(c *gin.Context) { var req bundle.OrderRecord if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil { @@ -67,12 +77,35 @@ func UpdateBundleOrder(c *gin.Context) { } // 获取 用户信息 + userInfo := login.GetUserInfoFromC(c) + + if req.Uuid == "" { + service.Retry(c, errors.New(common.MissOrderUUID)) + return + } + + detail, detailErr := service.BundleProvider.OrderRecordsDetail(context.Background(), &bundle.OrderRecordsDetailRequest{ + Uuid: req.Uuid, + }) + + if detailErr != nil { + service.Retry(c, detailErr) + return + } // 判断 是否是 本人操作 + if strconv.FormatUint(userInfo.ID, 10) != detail.OrderRecord.CustomerID { + service.Error(c, errors.New(common.NotMatchOrderInfo)) + return + } + + req.Status = bundleModel.OrderPaid + + req.PayTime = common.GetBeijingTime() res, err := service.BundleProvider.UpdateOrderRecord(context.Background(), &req) if err != nil { - service.Error(c, err) + service.Retry(c, detailErr) return } diff --git a/pkg/service/bundle/common/msg.go b/pkg/service/bundle/common/msg.go new file mode 100644 index 0000000..4edf48d --- /dev/null +++ b/pkg/service/bundle/common/msg.go @@ -0,0 +1,22 @@ +package common + +// 套餐 +const ( + MissBundleUUID = "缺少套餐UUID" + MissOrderSignature = "缺少客户签名信息" +) + +// 订单 +const ( + MissOrderNo = "缺少订单号" + MissOrderUUID = "缺少订单信息" + + NotMatchOrderInfo = "非当前用户订单信息不可操作" + + HadPay = "订单已支付" +) + +// stripe +const ( + ErrorQueryStripeInfo = "查询支付信息失败" +) diff --git a/pkg/common/time.go b/pkg/service/bundle/common/time.go similarity index 100% rename from pkg/common/time.go rename to pkg/service/bundle/common/time.go diff --git a/pkg/service/bundle/logic/signContract.go b/pkg/service/bundle/logic/signContract.go new file mode 100644 index 0000000..ec28d6c --- /dev/null +++ b/pkg/service/bundle/logic/signContract.go @@ -0,0 +1,81 @@ +package logic + +import ( + "bytes" + "errors" + "fmt" + "github.com/signintech/gopdf" + "image" + "io" + "log" + "net/http" +) + +// 把用户签字内容 填充到 合同模版里面 +func insertSignature(templatePath string, outputPath string, signImgPath string) error { + pdf := gopdf.GoPdf{} + pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4}) + + resp, imageErr := http.Get(signImgPath) + if imageErr != nil { + return errors.New("error downloading signature image") + } + defer resp.Body.Close() + + b, _err := io.ReadAll(resp.Body) + if _err != nil { + return errors.New("error reading signature image") + } + + // Create a new reader from the bytes + imgReader := bytes.NewReader(b) + img, _, err := image.DecodeConfig(imgReader) + if err != nil { + return errors.New("error decoding signature image") + } + w := img.Width + h := img.Height + + // 导入模板文件中的页面 + err = pdf.ImportPagesFromSource(templatePath, "/MediaBox") + if err != nil { + log.Fatalf("无法导入页面: %v", err) + } + + // 获取模板文件的总页数 + totalPages := pdf.GetNumberOfPages() + fmt.Printf("模板文件的总页数: %d\n", totalPages) + + targetPage := totalPages + + // 遍历所有页 + for i := 1; i <= totalPages; i++ { + tpl := pdf.ImportPage(templatePath, i, "/MediaBox") + pdf.AddPage() + pdf.UseImportedTemplate(tpl, 0, 0, gopdf.PageSizeA4.W, gopdf.PageSizeA4.H) + // 只在目标页插入签名 + if i == targetPage { + + imgH1, _err := gopdf.ImageHolderByBytes(b) + if _err != nil { + //zap.L().Error("SignContract err", zap.Error(err)) + return errors.New("error processing signature image") + } + newWidth := 80.0 + newHeight := (newWidth / float64(w)) * float64(h) + err = pdf.ImageByHolder(imgH1, 380, 540, &gopdf.Rect{W: newWidth, H: newHeight}) + if err != nil { + //zap.L().Error("SignContract err", zap.Error(err)) + return errors.New("error inserting signature") + } + } + } + + // 生成新的 PDF + if err = pdf.WritePdf(outputPath); err != nil { + //zap.L().Error("WritePdf err", zap.Error(err)) + return errors.New("error writing final PDF") + } + + return nil +} diff --git a/pkg/service/bundle/model/orderStatus.go b/pkg/service/bundle/model/orderStatus.go new file mode 100644 index 0000000..b2868b1 --- /dev/null +++ b/pkg/service/bundle/model/orderStatus.go @@ -0,0 +1,6 @@ +package model + +const ( + OrderSigned = 1 + OrderPaid = 2 +) diff --git a/pkg/service/bundle/pay.go b/pkg/service/bundle/pay.go new file mode 100644 index 0000000..73f497f --- /dev/null +++ b/pkg/service/bundle/pay.go @@ -0,0 +1,137 @@ +package bundle + +import ( + "context" + "errors" + "fmt" + "fonchain-fiee/api/bundle" + "fonchain-fiee/api/order" + "fonchain-fiee/cmd/config" + "fonchain-fiee/pkg/model/login" + "fonchain-fiee/pkg/service" + "fonchain-fiee/pkg/service/bundle/common" + bundleModel "fonchain-fiee/pkg/service/bundle/model" + "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin/binding" + "io" + "net/http" + "strconv" +) + +func CreateStripeCheckoutSession(c *gin.Context) { + var req order.CreateStripeCheckoutSessionRequest + + if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil { + service.Error(c, err) + return + } + + // 获取 用户信息 + userInfo := login.GetUserInfoFromC(c) + + // 检查 订单信息 + detail, detailErr := service.BundleProvider.OrderRecordsDetail(context.Background(), &bundle.OrderRecordsDetailRequest{ + OrderNo: req.OutTradeNo, + }) + + if detailErr != nil { + service.Error(c, detailErr) + return + } + + // 判断 是否是 本人操作 + if strconv.FormatUint(userInfo.ID, 10) != detail.OrderRecord.CustomerID { + service.Error(c, errors.New(common.NotMatchOrderInfo)) + return + } + + // 如果 当前订单 是 已签未支付 且 存在 checkoutSessionId 需要 查询 支付结果 + if detail.OrderRecord.Status == bundleModel.OrderSigned && detail.OrderRecord.CheckoutSessionId != "" && detail.OrderRecord.PayTime == "" { + // 查询支付结果 + stripeInfosRes, stripeInfosErr := service.OrderProvider.QueryStripeInfoByCheckSessionIds(context.Background(), &order.QueryStripeInfoRequest{ + CheckoutSessionIds: []string{detail.OrderRecord.CheckoutSessionId}, + }) + + if stripeInfosErr != nil { + service.Error(c, errors.New(common.ErrorQueryStripeInfo)) + return + } + + if stripeInfosRes != nil && len(stripeInfosRes.StripeInfos) > 0 { + for _, stripeInfo := range stripeInfosRes.StripeInfos { + if stripeInfo.OutTradeNo == detail.OrderRecord.OrderNo { + _, updateOrderRecordErr := service.BundleProvider.UpdateOrderRecord(context.Background(), &bundle.OrderRecord{ + Uuid: detail.OrderRecord.Uuid, + Status: bundleModel.OrderPaid, + PayTime: common.GetBeijingTime(), + }) + if updateOrderRecordErr != nil { + service.Error(c, detailErr) + return + } + service.Success(c, &service.Response{ + Msg: common.HadPay, + Code: 0, + }) + return + } + } + } + } + + //调用微服务获取支付地址 + result, err := service.OrderProvider.CreateStripeCheckoutSession(context.Background(), &req) + if err != nil { + service.Error(c, err) + return + } + + //更新订单状态 + _, updateOrderRecordErr := service.BundleProvider.UpdateOrderRecord(context.Background(), &bundle.OrderRecord{ + Uuid: detail.OrderRecord.Uuid, + CheckoutSessionId: result.CheckoutSessionId, + CheckoutSessionUrl: result.CheckoutSessionUrl, + }) + + if updateOrderRecordErr != nil { + service.Error(c, updateOrderRecordErr) + return + } + + service.Success(c, result) + +} + +func StripeCheckoutSessionWebhook(c *gin.Context) { + var req order.GetCheckoutWebhookRequest + c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, int64(65536)) + payloadBytes, err := io.ReadAll(c.Request.Body) + if err != nil { + service.Error(c, err) + return + } + req.Payload = string(payloadBytes) + req.Signature = c.GetHeader("Stripe-Signature") + req.WebhookKey = config.Webhookkey + fmt.Printf("webhookKey:%s\n", req.WebhookKey) + resp, err := service.OrderProvider.CommonCheckoutWebhook(c, &req) + if err != nil { + service.Error(c, err) + return + } + fmt.Println("resp.PaymentIntentStatus:", resp.PaymentIntentStatus) + if resp.PaymentIntentStatus == "paid" { + //支付成功 + _, updateStatusErr := service.BundleProvider.UpdateOrderRecordByOrderNo(context.Background(), &bundle.OrderRecord{ + OrderNo: resp.OutTradeNo, + PayTime: common.GetBeijingTime(), + Status: bundleModel.OrderPaid, + }) + if updateStatusErr != nil { + service.Error(c, err) + return + } + + } + service.Success(c) +} diff --git a/pkg/service/init.go b/pkg/service/init.go index 417a35d..d1736d4 100644 --- a/pkg/service/init.go +++ b/pkg/service/init.go @@ -19,9 +19,8 @@ var OrderProvider = new(order.OrderClientImpl) func init() { config.SetConsumerService(BundleProvider) - config.SetConsumerService(OrderProvider) - config.SetConsumerService(AccountProvider) - //config.SetConsumerService(BundleProvider) + //config.SetConsumerService(OrderProvider) + //config.SetConsumerService(AccountProvider) if err := config.Load(); err != nil { panic(err)