Compare commits
37 Commits
0f84894264
...
9dace756a1
Author | SHA1 | Date | |
---|---|---|---|
9dace756a1 | |||
348ce14ed8 | |||
591a82a9e9 | |||
a07fa1843f | |||
7643c4ed27 | |||
c5e6c7fe5d | |||
a615b727fc | |||
cc9c4f2fe7 | |||
52fb7c301e | |||
e073be30a1 | |||
fb62be1f46 | |||
90a57845ce | |||
7a27df806f | |||
9b94fca511 | |||
6f881cfd9c | |||
7fc9c57be7 | |||
30a6b5cb7f | |||
4ae4003ec3 | |||
fbd8b91013 | |||
ce90dde920 | |||
b75973df17 | |||
2fe1df0ffc | |||
73efea5d23 | |||
3772ef9e26 | |||
ea593f9ba7 | |||
205459e15c | |||
a257d6737e | |||
135c77c3b3 | |||
464064ab3a | |||
f8f850e02b | |||
6340289cf5 | |||
780a93a746 | |||
|
59f78ed8e1 | ||
|
7ee1598a3b | ||
8c07611ada | |||
edb04ea533 | |||
b7df304b20 |
10
.idea/AugmentWebviewStateStore.xml
Normal file
10
.idea/AugmentWebviewStateStore.xml
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -116,3 +116,6 @@ func (this *ValueAddBundleDetailResponse) Validate() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *FinancialConfirmationRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-triple v1.0.5
|
||||
// - protoc v3.21.8
|
||||
// - protoc-gen-go-triple v1.0.8
|
||||
// - protoc v3.10.1
|
||||
// source: pb/bundle.proto
|
||||
|
||||
package bundle
|
||||
@ -38,7 +38,8 @@ type BundleClient interface {
|
||||
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)
|
||||
// 增值套餐
|
||||
UpdateFinancialConfirmationStatus(ctx context.Context, in *FinancialConfirmationRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
|
||||
//增值套餐
|
||||
CreateValueAddBundle(ctx context.Context, in *CreateValueAddBundleRequest, opts ...grpc_go.CallOption) (*CreateValueAddBundleResponse, common.ErrorWithAttachment)
|
||||
ValueAddBundleList(ctx context.Context, in *ValueAddBundleListRequest, opts ...grpc_go.CallOption) (*ValueAddBundleListResponse, common.ErrorWithAttachment)
|
||||
ValueAddBundleDetail(ctx context.Context, in *ValueAddBundleDetailRequest, opts ...grpc_go.CallOption) (*ValueAddBundleDetailResponse, common.ErrorWithAttachment)
|
||||
@ -49,19 +50,20 @@ 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)
|
||||
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)
|
||||
CreateValueAddBundle func(ctx context.Context, in *CreateValueAddBundleRequest) (*CreateValueAddBundleResponse, error)
|
||||
ValueAddBundleList func(ctx context.Context, in *ValueAddBundleListRequest) (*ValueAddBundleListResponse, error)
|
||||
ValueAddBundleDetail func(ctx context.Context, in *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, 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)
|
||||
UpdateFinancialConfirmationStatus func(ctx context.Context, in *FinancialConfirmationRequest) (*CommonResponse, error)
|
||||
CreateValueAddBundle func(ctx context.Context, in *CreateValueAddBundleRequest) (*CreateValueAddBundleResponse, error)
|
||||
ValueAddBundleList func(ctx context.Context, in *ValueAddBundleListRequest) (*ValueAddBundleListResponse, error)
|
||||
ValueAddBundleDetail func(ctx context.Context, in *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error)
|
||||
}
|
||||
|
||||
func (c *BundleClientImpl) GetDubboStub(cc *triple.TripleConn) BundleClient {
|
||||
@ -136,6 +138,12 @@ func (c *bundleClient) OrderRecordsDetail(ctx context.Context, in *OrderRecordsD
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/OrderRecordsDetail", in, out)
|
||||
}
|
||||
|
||||
func (c *bundleClient) UpdateFinancialConfirmationStatus(ctx context.Context, in *FinancialConfirmationRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) {
|
||||
out := new(CommonResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateFinancialConfirmationStatus", in, out)
|
||||
}
|
||||
|
||||
func (c *bundleClient) CreateValueAddBundle(ctx context.Context, in *CreateValueAddBundleRequest, opts ...grpc_go.CallOption) (*CreateValueAddBundleResponse, common.ErrorWithAttachment) {
|
||||
out := new(CreateValueAddBundleResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
@ -168,7 +176,8 @@ type BundleServer interface {
|
||||
UpdateOrderRecordByOrderNo(context.Context, *OrderRecord) (*CommonResponse, error)
|
||||
OrderRecordsList(context.Context, *OrderRecordsRequest) (*OrderRecordsResponse, error)
|
||||
OrderRecordsDetail(context.Context, *OrderRecordsDetailRequest) (*OrderRecordsDetailResponse, error)
|
||||
// 增值套餐
|
||||
UpdateFinancialConfirmationStatus(context.Context, *FinancialConfirmationRequest) (*CommonResponse, error)
|
||||
//增值套餐
|
||||
CreateValueAddBundle(context.Context, *CreateValueAddBundleRequest) (*CreateValueAddBundleResponse, error)
|
||||
ValueAddBundleList(context.Context, *ValueAddBundleListRequest) (*ValueAddBundleListResponse, error)
|
||||
ValueAddBundleDetail(context.Context, *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error)
|
||||
@ -210,6 +219,9 @@ func (UnimplementedBundleServer) OrderRecordsList(context.Context, *OrderRecords
|
||||
func (UnimplementedBundleServer) OrderRecordsDetail(context.Context, *OrderRecordsDetailRequest) (*OrderRecordsDetailResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method OrderRecordsDetail not implemented")
|
||||
}
|
||||
func (UnimplementedBundleServer) UpdateFinancialConfirmationStatus(context.Context, *FinancialConfirmationRequest) (*CommonResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateFinancialConfirmationStatus not implemented")
|
||||
}
|
||||
func (UnimplementedBundleServer) CreateValueAddBundle(context.Context, *CreateValueAddBundleRequest) (*CreateValueAddBundleResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateValueAddBundle not implemented")
|
||||
}
|
||||
@ -537,6 +549,35 @@ func _Bundle_OrderRecordsDetail_Handler(srv interface{}, ctx context.Context, de
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Bundle_UpdateFinancialConfirmationStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FinancialConfirmationRequest)
|
||||
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("UpdateFinancialConfirmationStatus", 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_CreateValueAddBundle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateValueAddBundleRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@ -671,6 +712,10 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
|
||||
MethodName: "OrderRecordsDetail",
|
||||
Handler: _Bundle_OrderRecordsDetail_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateFinancialConfirmationStatus",
|
||||
Handler: _Bundle_UpdateFinancialConfirmationStatus_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateValueAddBundle",
|
||||
Handler: _Bundle_CreateValueAddBundle_Handler,
|
||||
|
@ -22,4 +22,7 @@ RedisDBNAme = "1"
|
||||
[ai]
|
||||
Host = "https://erpapi.fontree.cn"
|
||||
TelNum = "18021272627"
|
||||
Password = "Gy.123456"
|
||||
Password = "Gy.123456"
|
||||
|
||||
[service]
|
||||
IsHTTPS = false
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -30,4 +30,7 @@ RedisDBNAme = "2"
|
||||
[ai]
|
||||
Host = "https://erpapi.fontree.cn"
|
||||
TelNum = "18021272627"
|
||||
Password = "Gy.123456"
|
||||
Password = "Gy.123456"
|
||||
|
||||
[service]
|
||||
IsHTTPS = false
|
5
go.mod
5
go.mod
@ -18,8 +18,9 @@ go 1.18
|
||||
//github.com/fonchain_enterprise/utils/jwt => ../utils/jwt
|
||||
//github.com/fonchain_enterprise/utils/logger => ../utils/logger
|
||||
//replace github.com/fonchain_enterprise/utils/objstorage => ../../tyfon-新/utils/objstorage
|
||||
replace github.com/fonchain_enterprise/utils/objstorage => ../utils/objstorage
|
||||
|
||||
replace github.com/fonchain_enterprise/utils/objstorage => ../utils/objstorage
|
||||
//
|
||||
require (
|
||||
dubbo.apache.org/dubbo-go/v3 v3.0.2
|
||||
github.com/dubbogo/grpc-go v1.42.9
|
||||
@ -123,6 +124,7 @@ require (
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.65.0 // indirect
|
||||
github.com/360EntSecGroup-Skylar/excelize v1.4.1 // indirect
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 // indirect
|
||||
github.com/alibaba/sentinel-golang v1.0.4 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18 // indirect
|
||||
@ -160,6 +162,7 @@ require (
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
|
||||
github.com/nxadm/tail v1.4.11 // indirect
|
||||
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||
|
5
go.sum
5
go.sum
@ -37,6 +37,8 @@ contrib.go.opencensus.io/exporter/prometheus v0.4.1/go.mod h1:t9wvfitlUjGXG2IXAZ
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
dubbo.apache.org/dubbo-go/v3 v3.0.2 h1:+WuMFN6RSjXHT41QS1Xi5tFfaPuczIVoeQuKq7pISYI=
|
||||
dubbo.apache.org/dubbo-go/v3 v3.0.2/go.mod h1:bODgByAf72kzG/5YIfZIODXx81pY3gaAdIQ8B4mN/Yk=
|
||||
github.com/360EntSecGroup-Skylar/excelize v1.4.1 h1:l55mJb6rkkaUzOpSsgEeKYtS6/0gHwBYyfo5Jcjv/Ks=
|
||||
github.com/360EntSecGroup-Skylar/excelize v1.4.1/go.mod h1:vnax29X2usfl7HHkBrX5EvSCJcmH3dT9luvxzu8iGAE=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
|
||||
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
@ -608,6 +610,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
||||
github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM=
|
||||
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
|
||||
@ -813,6 +817,7 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
|
||||
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
|
@ -23,6 +23,12 @@ func BundleOrderRouter(r *gin.RouterGroup) {
|
||||
bundleOrderClientRoute.POST("bundle-order-list", bundle.OrderRecordsList)
|
||||
}
|
||||
|
||||
bundleOrderWebRoute := bundleOrderRoute.Group("web")
|
||||
{
|
||||
bundleOrderWebRoute.POST("financial-confirm", bundle.UpdateFinancialConfirmationStatus)
|
||||
bundleOrderWebRoute.POST("order-export", bundle.ExportOrderInfo)
|
||||
}
|
||||
|
||||
bundleOrderAppRoute := bundleOrderRoute.Group("app")
|
||||
{
|
||||
bundleOrderAppRoute.POST("order-signature", bundle.CreateBundleOrderSignature)
|
||||
|
@ -3,6 +3,7 @@ package bundle
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"fonchain-fiee/api/account"
|
||||
"fonchain-fiee/api/bundle"
|
||||
"fonchain-fiee/api/order"
|
||||
@ -13,6 +14,7 @@ import (
|
||||
bundleModel "fonchain-fiee/pkg/service/bundle/model"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
@ -267,6 +269,7 @@ func OrderRecordsList(c *gin.Context) {
|
||||
orderRecord.CertificatePicture = userInfo.CertificatePicture
|
||||
orderRecord.PlaceOfResidence = userInfo.PlaceOfResidence
|
||||
orderRecord.GroupPhoto = userInfo.GroupPhoto
|
||||
orderRecord.TelNum = userInfo.TelNum
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,10 +286,10 @@ func OrderRecordsDetail(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取 用户信息
|
||||
/*// 获取 用户信息
|
||||
userInfo := login.GetUserInfoFromC(c)
|
||||
|
||||
req.CustomerID = strconv.FormatUint(userInfo.ID, 10)
|
||||
req.CustomerID = strconv.FormatUint(userInfo.ID, 10)*/
|
||||
|
||||
res, err := service.BundleProvider.OrderRecordsDetail(context.Background(), &req)
|
||||
if err != nil {
|
||||
@ -296,3 +299,135 @@ func OrderRecordsDetail(c *gin.Context) {
|
||||
|
||||
service.Success(c, res)
|
||||
}
|
||||
|
||||
// web
|
||||
func UpdateFinancialConfirmationStatus(c *gin.Context) {
|
||||
var req bundle.FinancialConfirmationRequest
|
||||
|
||||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||||
service.Error(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// 不限制 支付状态 未支付 也可确认
|
||||
//detail, err := service.BundleProvider.OrderRecordsDetail(context.Background(), &bundle.OrderRecordsDetailRequest{
|
||||
// OrderNo: req.OrderNo,
|
||||
//})
|
||||
//if err != nil {
|
||||
// service.Error(c, err)
|
||||
// return
|
||||
//}
|
||||
//if detail.OrderRecord.Status != bundleModel.OrderPaid {
|
||||
// service.Error(c, errors.New("订单未支付,不可确认"))
|
||||
// return
|
||||
//}
|
||||
|
||||
res, err := service.BundleProvider.UpdateFinancialConfirmationStatus(context.Background(), &req)
|
||||
if err != nil {
|
||||
service.Error(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
service.Success(c, res)
|
||||
}
|
||||
|
||||
func ExportOrderInfo(c *gin.Context) {
|
||||
var req bundle.OrderRecordsRequest
|
||||
|
||||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||||
service.Error(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
res, err := service.BundleProvider.OrderRecordsList(context.Background(), &req)
|
||||
if err != nil {
|
||||
service.Error(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
rows := make([][]interface{}, 0)
|
||||
|
||||
for _, orderRecord := range res.OrderRecords {
|
||||
if orderRecord.CustomerID != "" {
|
||||
var userID uint64
|
||||
userID, err = strconv.ParseUint(orderRecord.CustomerID, 10, 64)
|
||||
if err != nil {
|
||||
err = nil
|
||||
continue
|
||||
}
|
||||
|
||||
userInfo, _ := service.AccountProvider.Info(context.Background(), &account.InfoRequest{
|
||||
Domain: "app",
|
||||
ID: userID,
|
||||
})
|
||||
if userInfo != nil {
|
||||
orderRecord.Sex = userInfo.Sex
|
||||
orderRecord.Nationality = userInfo.Nationality
|
||||
orderRecord.TelNum = userInfo.TelNum
|
||||
}
|
||||
}
|
||||
|
||||
status := ""
|
||||
if orderRecord.Status == bundleModel.OrderSigned {
|
||||
status = "未支付"
|
||||
} else if orderRecord.Status == bundleModel.OrderPaid {
|
||||
status = "已支付"
|
||||
}
|
||||
financialConfirmation := ""
|
||||
if orderRecord.FinancialConfirmation == bundleModel.UnConfirm {
|
||||
financialConfirmation = "未确认"
|
||||
} else if orderRecord.FinancialConfirmation == bundleModel.Confirmed {
|
||||
financialConfirmation = "已确认"
|
||||
}
|
||||
|
||||
rows = append(rows, []interface{}{
|
||||
orderRecord.OrderNo,
|
||||
orderRecord.CustomerNum,
|
||||
orderRecord.CustomerName,
|
||||
orderRecord.Sex,
|
||||
orderRecord.TelNum,
|
||||
orderRecord.Nationality,
|
||||
orderRecord.BundleName,
|
||||
orderRecord.SignedTime,
|
||||
orderRecord.Amount,
|
||||
orderRecord.Num,
|
||||
orderRecord.ValueAddBundleAmount,
|
||||
orderRecord.TotalAmount,
|
||||
status,
|
||||
orderRecord.PayTime,
|
||||
financialConfirmation,
|
||||
})
|
||||
}
|
||||
|
||||
dirPath := "./runtime"
|
||||
|
||||
filePath, err := logic.WriteToExcel(dirPath, rows)
|
||||
if err != nil {
|
||||
service.Error(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
var httpType string = "http" // Default to http
|
||||
|
||||
// Safely check if Origin exists in c.Keys
|
||||
if origin, exists := c.Keys["Origin"]; exists && origin != nil {
|
||||
originStr, ok := origin.(string)
|
||||
if ok && originStr != "" {
|
||||
fmt.Printf("c.Request.Origin %+v\n", originStr)
|
||||
parts := strings.Split(originStr, ":")
|
||||
if len(parts) > 0 {
|
||||
httpType = parts[0]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Fallback: Check if the request was made over TLS
|
||||
if c.Request.TLS != nil || c.Request.Header.Get("X-Forwarded-Proto") == "https" {
|
||||
httpType = "https"
|
||||
}
|
||||
}
|
||||
|
||||
var exportUrl = strings.Replace(strings.Replace(filePath, ".", fmt.Sprintf("%s://%s", httpType, c.Request.Host), 1), "runtime", "static", 1)
|
||||
//var exportUrl = fmt.Sprintf("%s%s/%s", httpType, c.Request.Host, dirPath + path)
|
||||
fmt.Println("exportUrl : ", exportUrl)
|
||||
service.Success(c, &bundleModel.ExportResponse{ExportUrl: exportUrl})
|
||||
}
|
||||
|
@ -21,6 +21,10 @@ const (
|
||||
InvalidValueAddBundleNum = "套餐数量无效"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrorExportOrderInfo = "导出订单信息失败"
|
||||
)
|
||||
|
||||
// stripe
|
||||
const (
|
||||
ErrorQueryStripeInfo = "查询支付信息失败"
|
||||
|
42
pkg/service/bundle/logic/export.go
Normal file
42
pkg/service/bundle/logic/export.go
Normal file
@ -0,0 +1,42 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fonchain-fiee/pkg/service/bundle/common"
|
||||
"time"
|
||||
|
||||
"github.com/360EntSecGroup-Skylar/excelize"
|
||||
)
|
||||
|
||||
func WriteToExcel(dirPath string, orderInfos [][]interface{}) (string, error) {
|
||||
headRow := []interface{}{"订单编号", "用户编号", "姓名", "性别", "手机号", "国籍", "套餐名称", "签署时间", "套餐费用", "增值服务视频条数", "增值金额", "总额", "支付状态", "支付时间", "财务确认状态"}
|
||||
|
||||
xlsx := excelize.NewFile()
|
||||
index := "Sheet1"
|
||||
|
||||
style, _ := xlsx.NewStyle(`{"alignment":{
|
||||
"horizontal":"center"
|
||||
}}`)
|
||||
|
||||
xlsx.SetCellStyle(index, "A1", "A1", style)
|
||||
|
||||
xlsx.SetSheetRow(index, "A1", &headRow)
|
||||
|
||||
rowIndex := 2
|
||||
for i := 0; i < len(orderInfos); i++ {
|
||||
xlsx.SetCellStyle(index, fmt.Sprintf("A%v", rowIndex), fmt.Sprintf("O%v", rowIndex), style)
|
||||
xlsx.SetSheetRow(index, fmt.Sprintf("A%v", rowIndex), &orderInfos[i])
|
||||
rowIndex++
|
||||
}
|
||||
|
||||
//path := dirPath + "/" + artShowInfo.ArtistName + "-" + artShowInfo.ShowSeq + "-price" + ".xlsx"
|
||||
path := dirPath + "/orderInfo_" + time.Now().Format("20060102150405") + ".xlsx"
|
||||
err := xlsx.SaveAs(path)
|
||||
if err != nil {
|
||||
fmt.Println("save rows err :", err)
|
||||
return "", errors.New(common.ErrorExportOrderInfo)
|
||||
}
|
||||
|
||||
return path, nil
|
||||
}
|
@ -4,3 +4,12 @@ const (
|
||||
OrderSigned = 1
|
||||
OrderPaid = 2
|
||||
)
|
||||
|
||||
const (
|
||||
UnConfirm = 1
|
||||
Confirmed = 2
|
||||
)
|
||||
|
||||
type ExportResponse struct {
|
||||
ExportUrl string `json:"exportUrl"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user