From 4e69601b0efd8294868f50ecc3d937849194395b Mon Sep 17 00:00:00 2001 From: gjs Date: Thu, 27 Aug 2026 14:11:34 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=BF=AB=E9=80=92=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E3=80=81=E7=BC=96=E8=BE=91=E3=80=81=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E3=80=81=E5=88=97=E8=A1=A8=E3=80=81=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/express/internal/dao/express.go | 8 ++- .../express/internal/logic/createLogic.go | 48 ++++++++++++++- services/express/internal/logic/editLogic.go | 58 ++++++++++++++++++- services/express/internal/logic/infoLogic.go | 22 ++++++- services/express/internal/logic/itemsLogic.go | 4 +- services/express/internal/logic/namesLogic.go | 17 +++++- .../express/internal/logic/statusLogic.go | 47 ++++++++++++++- 7 files changed, 186 insertions(+), 18 deletions(-) diff --git a/services/express/internal/dao/express.go b/services/express/internal/dao/express.go index 3bd0a4f..df64d58 100644 --- a/services/express/internal/dao/express.go +++ b/services/express/internal/dao/express.go @@ -49,7 +49,9 @@ type ExpressNames struct { } type ExpressStatus struct { - Id int64 `json:"id" gorm:"id"` // ID - Status uint8 `json:"status" gorm:"status"` // 状态,1为正常,2为禁用 - Reason string `json:"reason" gorm:"reason"` // 原因 + Id int64 `json:"id" gorm:"id"` // ID + Status uint8 `json:"status" gorm:"status"` // 状态,1为正常,2为禁用 + Reason string `json:"reason" gorm:"reason"` // 原因 + AdminId int64 `json:"admin_id" gorm:"admin_id"` // 操作人ID + AdminName string `json:"admin_name" gorm:"admin_name"` // 操作人姓名 } diff --git a/services/express/internal/logic/createLogic.go b/services/express/internal/logic/createLogic.go index 6d73b62..5509dbd 100644 --- a/services/express/internal/logic/createLogic.go +++ b/services/express/internal/logic/createLogic.go @@ -2,9 +2,12 @@ package logic import ( "context" - + "lone-services/pkg/utils" "lone-services/rpc/express/pb" + "lone-services/services/express/internal/dao" + "lone-services/services/express/internal/model" "lone-services/services/express/internal/svc" + "lone-services/services/express/validator" "github.com/zeromicro/go-zero/core/logx" ) @@ -25,7 +28,46 @@ func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogi } func (l *CreateLogic) Create(in *express.CreateRequest) (*express.Response, error) { - // todo: add your logic here and delete this line + var v validator.EditValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + data := dao.Express{ + Name: in.Name, + TransitId: uint8(in.TransitId), + AppCode: in.AppCode, + AppSecretKey: in.AppSecretKey, + AppUrl: in.AppUrl, + CardNumber: in.CardNumber, + PdfCode: in.PdfCode, + Province: in.Province, + City: in.City, + County: in.County, + Address: in.Address, + CompanyName: in.CompanyName, + Contact: in.Contact, + Mobile: in.Mobile, + Other: in.Other, + AdminId: adminInfo.ID, + AdminName: adminInfo.Name, + } - return &express.Response{}, nil + err := model.ExpressModel{}.Init().Create(&data) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail) + } + + action := utils.ActionAdd{ + NewContent: data, + Type: utils.LogActionTypeAdd, + ModuleName: utils.LogActionModuleExpress, + } + utils.SetActionLog(adminInfo, action) + + return l.ok(data.Id) } diff --git a/services/express/internal/logic/editLogic.go b/services/express/internal/logic/editLogic.go index c751486..09dc965 100644 --- a/services/express/internal/logic/editLogic.go +++ b/services/express/internal/logic/editLogic.go @@ -2,6 +2,12 @@ package logic import ( "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/express/internal/dao" + "lone-services/services/express/internal/model" + "lone-services/services/express/validator" + "strconv" "lone-services/rpc/express/pb" "lone-services/services/express/internal/svc" @@ -25,7 +31,55 @@ func NewEditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditLogic { } func (l *EditLogic) Edit(in *express.CreateRequest) (*express.Response, error) { - // todo: add your logic here and delete this line + var v validator.EditValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } - return &express.Response{}, nil + var info dao.Express + w := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(int(in.Id))}} + err := model.ExpressModel{}.Init().GetOne(w, &info) + if err != nil { + return l.fail(utils.ErrorNotFund) + } + action := utils.ActionAdd{ + OldContent: info, + Type: utils.LogActionTypeEdit, + ModuleName: utils.LogActionModuleExpress, + } + + info.AdminId = adminInfo.ID + info.AdminName = adminInfo.Name + info.Name = in.Name + info.TransitId = uint8(in.TransitId) + info.AppCode = in.AppCode + info.AppSecretKey = in.AppSecretKey + info.AppUrl = in.AppUrl + info.CardNumber = in.CardNumber + info.PdfCode = in.PdfCode + info.Province = in.Province + info.City = in.City + info.County = in.County + info.Address = in.Address + info.CompanyName = in.CompanyName + info.Contact = in.Contact + info.Mobile = in.Mobile + info.Other = in.Other + + row, err := model.ExpressModel{}.Init().Edit(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail) + } + + if row > utils.NumberZero { + action.NewContent = info + utils.SetActionLog(adminInfo, action) + } + + return l.ok(info.Id) } diff --git a/services/express/internal/logic/infoLogic.go b/services/express/internal/logic/infoLogic.go index d6829bb..7cc1198 100644 --- a/services/express/internal/logic/infoLogic.go +++ b/services/express/internal/logic/infoLogic.go @@ -2,9 +2,14 @@ package logic import ( "context" - + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" "lone-services/rpc/express/pb" + "lone-services/services/admin/validator" + "lone-services/services/express/internal/dao" + "lone-services/services/express/internal/model" "lone-services/services/express/internal/svc" + "strconv" "github.com/zeromicro/go-zero/core/logx" ) @@ -25,7 +30,18 @@ func NewInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoLogic { } func (l *InfoLogic) Info(in *express.IdRequest) (*express.Response, error) { - // todo: add your logic here and delete this line + var v validator.AdminInfoValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } - return &express.Response{}, nil + var info dao.ExpressInfo + modelObj := model.ExpressModel{}.Init() + w := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(int(in.Id))}} + err := modelObj.GetOne(w, &info) + if err != nil { + return l.fail(utils.ErrorNotFund) + } + + return l.ok(info) } diff --git a/services/express/internal/logic/itemsLogic.go b/services/express/internal/logic/itemsLogic.go index c7b7876..2ca56f9 100644 --- a/services/express/internal/logic/itemsLogic.go +++ b/services/express/internal/logic/itemsLogic.go @@ -31,8 +31,8 @@ func (l *ItemsLogic) Items(in *express.EmtpyRequest) (*express.Response, error) w := modelbase.Params{} var data []dao.ExpressInfo - items, _ := modelObj.Page(w, &data) + modelObj.Items(w, &data) - return l.ok(items) + return l.ok(data) } diff --git a/services/express/internal/logic/namesLogic.go b/services/express/internal/logic/namesLogic.go index 102bb3f..490208e 100644 --- a/services/express/internal/logic/namesLogic.go +++ b/services/express/internal/logic/namesLogic.go @@ -2,6 +2,10 @@ package logic import ( "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/express/internal/dao" + "lone-services/services/express/internal/model" "lone-services/rpc/express/pb" "lone-services/services/express/internal/svc" @@ -25,7 +29,16 @@ func NewNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NamesLogic } func (l *NamesLogic) Names(in *express.EmtpyRequest) (*express.Response, error) { - // todo: add your logic here and delete this line + modelObj := model.ExpressModel{}.Init() + w := modelbase.Params{ + Order: "id desc", + } + var items []dao.ExpressNames + err := modelObj.Items(w, &items) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail) + } - return &express.Response{}, nil + return l.ok(items) } diff --git a/services/express/internal/logic/statusLogic.go b/services/express/internal/logic/statusLogic.go index dafba27..beac9dd 100644 --- a/services/express/internal/logic/statusLogic.go +++ b/services/express/internal/logic/statusLogic.go @@ -2,6 +2,12 @@ package logic import ( "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/express/internal/dao" + "lone-services/services/express/internal/model" + "lone-services/services/express/validator" + "strconv" "lone-services/rpc/express/pb" "lone-services/services/express/internal/svc" @@ -25,7 +31,42 @@ func NewStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StatusLogi } func (l *StatusLogic) Status(in *express.StatusRequest) (*express.Response, error) { - // todo: add your logic here and delete this line - - return &express.Response{}, nil + var v validator.StatusValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + var action = utils.ActionAdd{} + var info dao.ExpressStatus + w := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(int(in.Id))}} + modelObj := model.ExpressModel{}.Init() + err := modelObj.GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail) + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund) + } + action.OldContent = info + info.Status = uint8(in.Status) + info.Reason = in.Reason + info.AdminName = adminInfo.Name + info.AdminId = adminInfo.ID + row, editErr := modelObj.Edit(w, info) + if editErr != nil { + l.Logger.Error(editErr) + return l.fail(utils.Fail) + } + if row > utils.NumberZero { + action.NewContent = info + action.Reason = in.Reason + action.Type = utils.LogActionTypeStatus + action.ModuleName = utils.LogActionModuleExpress + utils.SetActionLog(adminInfo, action) + } + return l.ok(utils.NumberOne) } From 433a17140cb5e3aa6e883e2cc577bd5eb55767af Mon Sep 17 00:00:00 2001 From: gjs Date: Thu, 27 Aug 2026 16:54:51 +0800 Subject: [PATCH 2/5] address add bystoreid api --- rpc/order/order.pb | Bin 16343 -> 16513 bytes rpc/order/order.proto | 12 +- rpc/order/pb/order.pb.go | 163 ++++++++++++------ rpc/order/pb/order_grpc.pb.go | 38 ++++ services/order/internal/dao/order.go | 2 +- services/order/internal/dao/orderProduct.go | 6 +- .../internal/logic/addressByStoreLogic.go | 65 +++++++ services/order/internal/logic/base.go | 4 + .../order/internal/logic/webCreateLogic.go | 93 ++++++---- .../order/internal/logic/webCreateOneLogic.go | 135 ++++++++++++++- services/order/internal/server/orderServer.go | 104 +++++++++++ services/order/internal/svc/order.go | 59 ++++--- services/order/internal/svc/servicecontext.go | 10 +- services/order/orderClient/order.go | 39 +++-- services/order/validator/address.go | 11 ++ 15 files changed, 596 insertions(+), 145 deletions(-) create mode 100644 services/order/internal/logic/addressByStoreLogic.go create mode 100644 services/order/internal/server/orderServer.go diff --git a/rpc/order/order.pb b/rpc/order/order.pb index 46626dddea65347d11821fe7973ee52a2af034a7..8771e2eb626989bf68f5998e3ab9798aa84fb221 100644 GIT binary patch delta 188 zcmca!-`L2w;juB(9Ldd3jn6Q$^fPjaPO=uAe9F{ha*T=mW*IYKW(#vJDaVwQqSWGI zr^?`x{GwFPlGNPdpwzLVk=#aU34pHiA!l9?jGtiY(j90V8GENv#r VJUP?yKV!@0Oe=4e%_{b>i~!*28A|{F diff --git a/rpc/order/order.proto b/rpc/order/order.proto index 83c8b1e..963f0b0 100644 --- a/rpc/order/order.proto +++ b/rpc/order/order.proto @@ -33,7 +33,7 @@ message CreateOrderRequest { message CreateOrderOneRequest { int64 address_id = 1; string note = 2; - int64 productid = 3; + int64 product_id = 3; int32 num = 4; int32 type = 5; } @@ -91,6 +91,10 @@ message AddressItemsRequest { repeated string time = 8; } +message AddressByStoreItemsRequest { + int64 store_id = 1; +} + message OrderAuditingItemsRequest { int32 page = 1; int32 size = 2; @@ -186,6 +190,12 @@ service order { body: "*" }; }; + rpc AddressByStore(AddressByStoreItemsRequest) returns(Response){ + option (google.api.http) = { + get: "/admin/v3/address/store/items" + body: "*" + }; + }; rpc OrderAuditingItems(OrderAuditingItemsRequest) returns(Response){ option (google.api.http) = { diff --git a/rpc/order/pb/order.pb.go b/rpc/order/pb/order.pb.go index 28198ec..a7afee9 100644 --- a/rpc/order/pb/order.pb.go +++ b/rpc/order/pb/order.pb.go @@ -254,7 +254,7 @@ type CreateOrderOneRequest struct { state protoimpl.MessageState `protogen:"open.v1"` AddressId int64 `protobuf:"varint,1,opt,name=address_id,json=addressId,proto3" json:"address_id,omitempty"` Note string `protobuf:"bytes,2,opt,name=note,proto3" json:"note,omitempty"` - Productid int64 `protobuf:"varint,3,opt,name=productid,proto3" json:"productid,omitempty"` + ProductId int64 `protobuf:"varint,3,opt,name=product_id,json=productId,proto3" json:"product_id,omitempty"` Num int32 `protobuf:"varint,4,opt,name=num,proto3" json:"num,omitempty"` Type int32 `protobuf:"varint,5,opt,name=type,proto3" json:"type,omitempty"` unknownFields protoimpl.UnknownFields @@ -305,9 +305,9 @@ func (x *CreateOrderOneRequest) GetNote() string { return "" } -func (x *CreateOrderOneRequest) GetProductid() int64 { +func (x *CreateOrderOneRequest) GetProductId() int64 { if x != nil { - return x.Productid + return x.ProductId } return 0 } @@ -858,6 +858,50 @@ func (x *AddressItemsRequest) GetTime() []string { return nil } +type AddressByStoreItemsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + StoreId int64 `protobuf:"varint,1,opt,name=store_id,json=storeId,proto3" json:"store_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AddressByStoreItemsRequest) Reset() { + *x = AddressByStoreItemsRequest{} + mi := &file_order_order_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AddressByStoreItemsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddressByStoreItemsRequest) ProtoMessage() {} + +func (x *AddressByStoreItemsRequest) ProtoReflect() protoreflect.Message { + mi := &file_order_order_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddressByStoreItemsRequest.ProtoReflect.Descriptor instead. +func (*AddressByStoreItemsRequest) Descriptor() ([]byte, []int) { + return file_order_order_proto_rawDescGZIP(), []int{13} +} + +func (x *AddressByStoreItemsRequest) GetStoreId() int64 { + if x != nil { + return x.StoreId + } + return 0 +} + type OrderAuditingItemsRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` @@ -868,7 +912,7 @@ type OrderAuditingItemsRequest struct { func (x *OrderAuditingItemsRequest) Reset() { *x = OrderAuditingItemsRequest{} - mi := &file_order_order_proto_msgTypes[13] + mi := &file_order_order_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -880,7 +924,7 @@ func (x *OrderAuditingItemsRequest) String() string { func (*OrderAuditingItemsRequest) ProtoMessage() {} func (x *OrderAuditingItemsRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[13] + mi := &file_order_order_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -893,7 +937,7 @@ func (x *OrderAuditingItemsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use OrderAuditingItemsRequest.ProtoReflect.Descriptor instead. func (*OrderAuditingItemsRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{13} + return file_order_order_proto_rawDescGZIP(), []int{14} } func (x *OrderAuditingItemsRequest) GetPage() int32 { @@ -921,7 +965,7 @@ type OrderAuditingRequest struct { func (x *OrderAuditingRequest) Reset() { *x = OrderAuditingRequest{} - mi := &file_order_order_proto_msgTypes[14] + mi := &file_order_order_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -933,7 +977,7 @@ func (x *OrderAuditingRequest) String() string { func (*OrderAuditingRequest) ProtoMessage() {} func (x *OrderAuditingRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[14] + mi := &file_order_order_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -946,7 +990,7 @@ func (x *OrderAuditingRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use OrderAuditingRequest.ProtoReflect.Descriptor instead. func (*OrderAuditingRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{14} + return file_order_order_proto_rawDescGZIP(), []int{15} } func (x *OrderAuditingRequest) GetId() int64 { @@ -981,7 +1025,7 @@ type AdminCreateOrderRequest struct { func (x *AdminCreateOrderRequest) Reset() { *x = AdminCreateOrderRequest{} - mi := &file_order_order_proto_msgTypes[15] + mi := &file_order_order_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -993,7 +1037,7 @@ func (x *AdminCreateOrderRequest) String() string { func (*AdminCreateOrderRequest) ProtoMessage() {} func (x *AdminCreateOrderRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[15] + mi := &file_order_order_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1006,7 +1050,7 @@ func (x *AdminCreateOrderRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AdminCreateOrderRequest.ProtoReflect.Descriptor instead. func (*AdminCreateOrderRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{15} + return file_order_order_proto_rawDescGZIP(), []int{16} } func (x *AdminCreateOrderRequest) GetAddressId() int64 { @@ -1054,12 +1098,13 @@ const file_order_order_proto_rawDesc = "" + "\n" + "address_id\x18\x01 \x01(\x03R\taddressId\x12\x12\n" + "\x04note\x18\x02 \x01(\tR\x04note\x12\x12\n" + - "\x04type\x18\x03 \x01(\x05R\x04type\"\x8e\x01\n" + + "\x04type\x18\x03 \x01(\x05R\x04type\"\x8f\x01\n" + "\x15CreateOrderOneRequest\x12\x1d\n" + "\n" + "address_id\x18\x01 \x01(\x03R\taddressId\x12\x12\n" + - "\x04note\x18\x02 \x01(\tR\x04note\x12\x1c\n" + - "\tproductid\x18\x03 \x01(\x03R\tproductid\x12\x10\n" + + "\x04note\x18\x02 \x01(\tR\x04note\x12\x1d\n" + + "\n" + + "product_id\x18\x03 \x01(\x03R\tproductId\x12\x10\n" + "\x03num\x18\x04 \x01(\x05R\x03num\x12\x12\n" + "\x04type\x18\x05 \x01(\x05R\x04type\"\xd7\x01\n" + "\x12EditAddressRequest\x12\x1a\n" + @@ -1097,7 +1142,9 @@ const file_order_order_proto_rawDesc = "" + "\x06mobile\x18\x05 \x01(\tR\x06mobile\x12\x19\n" + "\bstore_id\x18\x06 \x01(\x03R\astoreId\x12\x17\n" + "\asale_id\x18\a \x01(\x03R\x06saleId\x12\x12\n" + - "\x04time\x18\b \x03(\tR\x04time\"C\n" + + "\x04time\x18\b \x03(\tR\x04time\"7\n" + + "\x1aAddressByStoreItemsRequest\x12\x19\n" + + "\bstore_id\x18\x01 \x01(\x03R\astoreId\"C\n" + "\x19OrderAuditingItemsRequest\x12\x12\n" + "\x04page\x18\x01 \x01(\x05R\x04page\x12\x12\n" + "\x04size\x18\x02 \x01(\x05R\x04size\"V\n" + @@ -1109,7 +1156,7 @@ const file_order_order_proto_rawDesc = "" + "\n" + "address_id\x18\x01 \x01(\x03R\taddressId\x12\x12\n" + "\x04note\x18\x02 \x01(\tR\x04note\x12\x12\n" + - "\x04info\x18\x03 \x01(\tR\x04info2\x84\v\n" + + "\x04info\x18\x03 \x01(\tR\x04info2\xf4\v\n" + "\x05order\x12T\n" + "\x05Items\x12\x18.order.OrderItemsRequest\x1a\x0f.order.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x12\x15/admin/v3/order/items\x12X\n" + "\tWebCreate\x12\x19.order.CreateOrderRequest\x1a\x0f.order.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/api/v3/order/create\x12b\n" + @@ -1122,7 +1169,8 @@ const file_order_order_proto_rawDesc = "" + "\x0fWebAddressItems\x12\x12.order.TypeRequest\x1a\x0f.order.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x12\x15/api/v3/address/items\x12G\n" + "\aWebCart\x12\x12.order.CartRequest\x1a\x0f.order.Response\"\x17\x82\xd3\xe4\x93\x02\x11:\x01*\x12\f/api/v3/cart\x12T\n" + "\vWebCartEdit\x12\x16.order.EditCartRequest\x1a\x0f.order.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\"\x11/api/v3/cart/edit\x12^\n" + - "\vAddressItem\x12\x1a.order.AddressItemsRequest\x1a\x0f.order.Response\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\x12\x17/admin/v3/address/items\x12r\n" + + "\vAddressItem\x12\x1a.order.AddressItemsRequest\x1a\x0f.order.Response\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\x12\x17/admin/v3/address/items\x12n\n" + + "\x0eAddressByStore\x12!.order.AddressByStoreItemsRequest\x1a\x0f.order.Response\"(\x82\xd3\xe4\x93\x02\":\x01*\x12\x1d/admin/v3/address/store/items\x12r\n" + "\x12OrderAuditingItems\x12 .order.OrderAuditingItemsRequest\x1a\x0f.order.Response\")\x82\xd3\xe4\x93\x02#:\x01*\x12\x1e/admin/v3/order/auditing/items\x12b\n" + "\rOrderAuditing\x12\x1b.order.OrderAuditingRequest\x1a\x0f.order.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/admin/v3/order/auditing\x12a\n" + "\vOrderCreate\x12\x1e.order.AdminCreateOrderRequest\x1a\x0f.order.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\"\x16/admin/v3/order/createB\x19Z\x17lone-services/rpc/orderb\x06proto3" @@ -1139,24 +1187,25 @@ func file_order_order_proto_rawDescGZIP() []byte { return file_order_order_proto_rawDescData } -var file_order_order_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_order_order_proto_msgTypes = make([]protoimpl.MessageInfo, 17) var file_order_order_proto_goTypes = []any{ - (*OrderItemsRequest)(nil), // 0: order.OrderItemsRequest - (*Response)(nil), // 1: order.Response - (*CreateOrderRequest)(nil), // 2: order.CreateOrderRequest - (*CreateOrderOneRequest)(nil), // 3: order.CreateOrderOneRequest - (*EditAddressRequest)(nil), // 4: order.EditAddressRequest - (*StatusAddressRequest)(nil), // 5: order.StatusAddressRequest - (*EmptyRequest)(nil), // 6: order.EmptyRequest - (*EditCartRequest)(nil), // 7: order.EditCartRequest - (*CartRequest)(nil), // 8: order.CartRequest - (*IdRequest)(nil), // 9: order.IdRequest - (*IdAndTypeRequest)(nil), // 10: order.IdAndTypeRequest - (*TypeRequest)(nil), // 11: order.TypeRequest - (*AddressItemsRequest)(nil), // 12: order.AddressItemsRequest - (*OrderAuditingItemsRequest)(nil), // 13: order.OrderAuditingItemsRequest - (*OrderAuditingRequest)(nil), // 14: order.OrderAuditingRequest - (*AdminCreateOrderRequest)(nil), // 15: order.AdminCreateOrderRequest + (*OrderItemsRequest)(nil), // 0: order.OrderItemsRequest + (*Response)(nil), // 1: order.Response + (*CreateOrderRequest)(nil), // 2: order.CreateOrderRequest + (*CreateOrderOneRequest)(nil), // 3: order.CreateOrderOneRequest + (*EditAddressRequest)(nil), // 4: order.EditAddressRequest + (*StatusAddressRequest)(nil), // 5: order.StatusAddressRequest + (*EmptyRequest)(nil), // 6: order.EmptyRequest + (*EditCartRequest)(nil), // 7: order.EditCartRequest + (*CartRequest)(nil), // 8: order.CartRequest + (*IdRequest)(nil), // 9: order.IdRequest + (*IdAndTypeRequest)(nil), // 10: order.IdAndTypeRequest + (*TypeRequest)(nil), // 11: order.TypeRequest + (*AddressItemsRequest)(nil), // 12: order.AddressItemsRequest + (*AddressByStoreItemsRequest)(nil), // 13: order.AddressByStoreItemsRequest + (*OrderAuditingItemsRequest)(nil), // 14: order.OrderAuditingItemsRequest + (*OrderAuditingRequest)(nil), // 15: order.OrderAuditingRequest + (*AdminCreateOrderRequest)(nil), // 16: order.AdminCreateOrderRequest } var file_order_order_proto_depIdxs = []int32{ 0, // 0: order.order.Items:input_type -> order.OrderItemsRequest @@ -1171,26 +1220,28 @@ var file_order_order_proto_depIdxs = []int32{ 8, // 9: order.order.WebCart:input_type -> order.CartRequest 7, // 10: order.order.WebCartEdit:input_type -> order.EditCartRequest 12, // 11: order.order.AddressItem:input_type -> order.AddressItemsRequest - 13, // 12: order.order.OrderAuditingItems:input_type -> order.OrderAuditingItemsRequest - 14, // 13: order.order.OrderAuditing:input_type -> order.OrderAuditingRequest - 15, // 14: order.order.OrderCreate:input_type -> order.AdminCreateOrderRequest - 1, // 15: order.order.Items:output_type -> order.Response - 1, // 16: order.order.WebCreate:output_type -> order.Response - 1, // 17: order.order.WebCreateOne:output_type -> order.Response - 1, // 18: order.order.WebAddressCreate:output_type -> order.Response - 1, // 19: order.order.WebAddressEdit:output_type -> order.Response - 1, // 20: order.order.WebAddressDel:output_type -> order.Response - 1, // 21: order.order.WebAddressDef:output_type -> order.Response - 1, // 22: order.order.WebAddressInfo:output_type -> order.Response - 1, // 23: order.order.WebAddressItems:output_type -> order.Response - 1, // 24: order.order.WebCart:output_type -> order.Response - 1, // 25: order.order.WebCartEdit:output_type -> order.Response - 1, // 26: order.order.AddressItem:output_type -> order.Response - 1, // 27: order.order.OrderAuditingItems:output_type -> order.Response - 1, // 28: order.order.OrderAuditing:output_type -> order.Response - 1, // 29: order.order.OrderCreate:output_type -> order.Response - 15, // [15:30] is the sub-list for method output_type - 0, // [0:15] is the sub-list for method input_type + 13, // 12: order.order.AddressByStore:input_type -> order.AddressByStoreItemsRequest + 14, // 13: order.order.OrderAuditingItems:input_type -> order.OrderAuditingItemsRequest + 15, // 14: order.order.OrderAuditing:input_type -> order.OrderAuditingRequest + 16, // 15: order.order.OrderCreate:input_type -> order.AdminCreateOrderRequest + 1, // 16: order.order.Items:output_type -> order.Response + 1, // 17: order.order.WebCreate:output_type -> order.Response + 1, // 18: order.order.WebCreateOne:output_type -> order.Response + 1, // 19: order.order.WebAddressCreate:output_type -> order.Response + 1, // 20: order.order.WebAddressEdit:output_type -> order.Response + 1, // 21: order.order.WebAddressDel:output_type -> order.Response + 1, // 22: order.order.WebAddressDef:output_type -> order.Response + 1, // 23: order.order.WebAddressInfo:output_type -> order.Response + 1, // 24: order.order.WebAddressItems:output_type -> order.Response + 1, // 25: order.order.WebCart:output_type -> order.Response + 1, // 26: order.order.WebCartEdit:output_type -> order.Response + 1, // 27: order.order.AddressItem:output_type -> order.Response + 1, // 28: order.order.AddressByStore:output_type -> order.Response + 1, // 29: order.order.OrderAuditingItems:output_type -> order.Response + 1, // 30: order.order.OrderAuditing:output_type -> order.Response + 1, // 31: order.order.OrderCreate:output_type -> order.Response + 16, // [16:32] is the sub-list for method output_type + 0, // [0:16] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -1207,7 +1258,7 @@ func file_order_order_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_order_order_proto_rawDesc), len(file_order_order_proto_rawDesc)), NumEnums: 0, - NumMessages: 16, + NumMessages: 17, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/order/pb/order_grpc.pb.go b/rpc/order/pb/order_grpc.pb.go index 4124cea..cf3fd83 100644 --- a/rpc/order/pb/order_grpc.pb.go +++ b/rpc/order/pb/order_grpc.pb.go @@ -31,6 +31,7 @@ const ( Order_WebCart_FullMethodName = "/order.order/WebCart" Order_WebCartEdit_FullMethodName = "/order.order/WebCartEdit" Order_AddressItem_FullMethodName = "/order.order/AddressItem" + Order_AddressByStore_FullMethodName = "/order.order/AddressByStore" Order_OrderAuditingItems_FullMethodName = "/order.order/OrderAuditingItems" Order_OrderAuditing_FullMethodName = "/order.order/OrderAuditing" Order_OrderCreate_FullMethodName = "/order.order/OrderCreate" @@ -52,6 +53,7 @@ type OrderClient interface { WebCart(ctx context.Context, in *CartRequest, opts ...grpc.CallOption) (*Response, error) WebCartEdit(ctx context.Context, in *EditCartRequest, opts ...grpc.CallOption) (*Response, error) AddressItem(ctx context.Context, in *AddressItemsRequest, opts ...grpc.CallOption) (*Response, error) + AddressByStore(ctx context.Context, in *AddressByStoreItemsRequest, opts ...grpc.CallOption) (*Response, error) OrderAuditingItems(ctx context.Context, in *OrderAuditingItemsRequest, opts ...grpc.CallOption) (*Response, error) OrderAuditing(ctx context.Context, in *OrderAuditingRequest, opts ...grpc.CallOption) (*Response, error) OrderCreate(ctx context.Context, in *AdminCreateOrderRequest, opts ...grpc.CallOption) (*Response, error) @@ -185,6 +187,16 @@ func (c *orderClient) AddressItem(ctx context.Context, in *AddressItemsRequest, return out, nil } +func (c *orderClient) AddressByStore(ctx context.Context, in *AddressByStoreItemsRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Order_AddressByStore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *orderClient) OrderAuditingItems(ctx context.Context, in *OrderAuditingItemsRequest, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) @@ -231,6 +243,7 @@ type OrderServer interface { WebCart(context.Context, *CartRequest) (*Response, error) WebCartEdit(context.Context, *EditCartRequest) (*Response, error) AddressItem(context.Context, *AddressItemsRequest) (*Response, error) + AddressByStore(context.Context, *AddressByStoreItemsRequest) (*Response, error) OrderAuditingItems(context.Context, *OrderAuditingItemsRequest) (*Response, error) OrderAuditing(context.Context, *OrderAuditingRequest) (*Response, error) OrderCreate(context.Context, *AdminCreateOrderRequest) (*Response, error) @@ -280,6 +293,9 @@ func (UnimplementedOrderServer) WebCartEdit(context.Context, *EditCartRequest) ( func (UnimplementedOrderServer) AddressItem(context.Context, *AddressItemsRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method AddressItem not implemented") } +func (UnimplementedOrderServer) AddressByStore(context.Context, *AddressByStoreItemsRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method AddressByStore not implemented") +} func (UnimplementedOrderServer) OrderAuditingItems(context.Context, *OrderAuditingItemsRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method OrderAuditingItems not implemented") } @@ -526,6 +542,24 @@ func _Order_AddressItem_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Order_AddressByStore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddressByStoreItemsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OrderServer).AddressByStore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Order_AddressByStore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OrderServer).AddressByStore(ctx, req.(*AddressByStoreItemsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Order_OrderAuditingItems_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(OrderAuditingItemsRequest) if err := dec(in); err != nil { @@ -635,6 +669,10 @@ var Order_ServiceDesc = grpc.ServiceDesc{ MethodName: "AddressItem", Handler: _Order_AddressItem_Handler, }, + { + MethodName: "AddressByStore", + Handler: _Order_AddressByStore_Handler, + }, { MethodName: "OrderAuditingItems", Handler: _Order_OrderAuditingItems_Handler, diff --git a/services/order/internal/dao/order.go b/services/order/internal/dao/order.go index 9e46bf2..f0dc646 100644 --- a/services/order/internal/dao/order.go +++ b/services/order/internal/dao/order.go @@ -23,7 +23,7 @@ const ( type OrderCreate struct { Id int64 `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` - OrderSn string `gorm:"column:ordersn;type:varchar(100);comment:订单号;NOT NULL" json:"ordersn"` + OrderSn string `gorm:"column:order_sn;type:varchar(100);comment:订单号;NOT NULL" json:"order_sn"` StoreId int `gorm:"column:store_id;type:int(11);comment:美容院关联ID号" json:"store_id"` StoreName string `gorm:"column:store_name;type:varchar(50);comment:门店名" json:"store_name"` SaleName string `gorm:"column:sale_name;type:varchar(50);comment:销售姓名" json:"sale_name"` diff --git a/services/order/internal/dao/orderProduct.go b/services/order/internal/dao/orderProduct.go index b29399c..a575279 100644 --- a/services/order/internal/dao/orderProduct.go +++ b/services/order/internal/dao/orderProduct.go @@ -4,7 +4,7 @@ import "lone-services/pkg/utils" type OrderProductCreate struct { Id int64 `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` - Ordersn string `gorm:"column:ordersn;type:varchar(100);comment:订单号;NOT NULL" json:"ordersn"` + OrderSn string `gorm:"column:order_sn;type:varchar(100);comment:订单号;NOT NULL" json:"order_sn"` ProductId int `gorm:"column:product_id;type:int(11);comment:产品ID;NOT NULL" json:"product_id"` ProductName string `gorm:"column:product_name;type:varchar(255);comment:产品名;NOT NULL" json:"product_name"` Price float64 `gorm:"column:price;type:decimal(10,2);comment:产品单价格;NOT NULL" json:"price"` @@ -15,7 +15,7 @@ type OrderProductCreate struct { type OrderProductInfo struct { Id int64 `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` - Ordersn string `gorm:"column:ordersn;type:varchar(100);comment:订单号;NOT NULL" json:"ordersn"` + OrderSn string `gorm:"column:order_sn;type:varchar(100);comment:订单号;NOT NULL" json:"order_sn"` ProductId int `gorm:"column:product_id;type:int(11);comment:产品ID;NOT NULL" json:"product_id"` ProductName string `gorm:"column:product_name;type:varchar(255);comment:产品名;NOT NULL" json:"product_name"` Price float64 `gorm:"column:price;type:decimal(10,2);comment:产品单价格;NOT NULL" json:"price"` @@ -36,7 +36,7 @@ type OrderProductPay struct { type OrderProducts struct { Id int `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` - OrderSn string `gorm:"column:ordersn;type:varchar(100);comment:订单号;NOT NULL" json:"ordersn"` + OrderSn string `gorm:"column:order_sn;type:varchar(100);comment:订单号;NOT NULL" json:"order_sn"` ProductId int `gorm:"column:product_id;type:int(11);comment:产品ID;NOT NULL" json:"product_id"` ProductName string `gorm:"column:product_name;type:varchar(255);comment:产品名;NOT NULL" json:"product_name"` Price float32 `gorm:"column:price;type:decimal(10,2);comment:产品单价格;NOT NULL" json:"price"` diff --git a/services/order/internal/logic/addressByStoreLogic.go b/services/order/internal/logic/addressByStoreLogic.go new file mode 100644 index 0000000..68fb61c --- /dev/null +++ b/services/order/internal/logic/addressByStoreLogic.go @@ -0,0 +1,65 @@ +package logic + +import ( + "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/order/internal/dao" + "lone-services/services/order/internal/model" + "lone-services/services/order/validator" + "strconv" + + "lone-services/rpc/order/pb" + "lone-services/services/order/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AddressByStoreLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewAddressByStoreLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressByStoreLogic { + return &AddressByStoreLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *AddressByStoreLogic) AddressByStore(in *order.AddressByStoreItemsRequest) (*order.Response, error) { + var v validator.AddressByStoreItemsValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + var info []dao.Address + w := modelbase.Params{ + Order: "id desc", + Eq: map[string]string{ + "target_id": strconv.FormatInt(in.StoreId, utils.NumberTen), + "type": strconv.Itoa(dao.AddressTypeStore), + "status": utils.StringStatusOk, + }, + } + + err := model.AddressModel{}.Init().Items(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.ErrorNotFund) + } + for key, v := range info { + mobile, aErr := utils.DecryptPhone(v.Mobile) + if aErr == nil { + info[key].AesMobile = v.Mobile + info[key].Mobile = utils.DecryptPhoneReplace(mobile) + } + } + return l.ok(info) +} diff --git a/services/order/internal/logic/base.go b/services/order/internal/logic/base.go index 16ca9b6..82a0c0a 100644 --- a/services/order/internal/logic/base.go +++ b/services/order/internal/logic/base.go @@ -38,6 +38,10 @@ func (l *BaseLogic) out(status utils.Status, msg string) (*order.Response, error return &order.Response{Code: status.Code, Msg: msg}, nil } +func (l *BaseLogic) outData(status utils.Status, msg, data string) (*order.Response, error) { + return &order.Response{Code: status.Code, Msg: msg, Data: data}, nil +} + func (l *BaseLogic) ok(data any) (*order.Response, error) { buf, _ := jsoniter.Marshal(data) return &order.Response{Code: utils.Ok.Code, Msg: utils.Ok.Msg, Data: string(buf)}, nil diff --git a/services/order/internal/logic/webCreateLogic.go b/services/order/internal/logic/webCreateLogic.go index 7c3c6ca..b68239d 100644 --- a/services/order/internal/logic/webCreateLogic.go +++ b/services/order/internal/logic/webCreateLogic.go @@ -66,7 +66,7 @@ func (l *WebCreateLogic) WebCreate(in *order.CreateOrderRequest) (*order.Respons DistrictIds: address.DistrictIds, } - w = modelbase.Params{ + ww := modelbase.Params{ Eq: map[string]string{ "type": strconv.Itoa(int(in.Type)), }, @@ -78,14 +78,14 @@ func (l *WebCreateLogic) WebCreate(in *order.CreateOrderRequest) (*order.Respons data.SaleName = adminInfo.Name data.CreateType = dao.OrderTypeSale data.Type = dao.OrderTypeSale - w.Eq["sale_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + ww.Eq["sale_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) orderSn = svc.GetOrderSn(strconv.Itoa(dao.OrderTypeSale), adminInfo.ID) case dao.CartTypeUser: data.UserId = int(adminInfo.ID) data.UserName = adminInfo.Name data.CreateType = dao.OrderTypePersonal data.Type = dao.OrderTypePersonal - w.Eq["user_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + ww.Eq["user_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) orderSn = svc.GetOrderSn(strconv.Itoa(dao.OrderTypePersonal), adminInfo.ID) case dao.CartTypeStore: data.StoreId = int(adminInfo.ID) @@ -96,13 +96,15 @@ func (l *WebCreateLogic) WebCreate(in *order.CreateOrderRequest) (*order.Respons data.SaleProvince = int(adminInfo.SaleProvince) data.CreateType = dao.OrderTypeStore data.Type = dao.OrderTypeStore - w.Eq["store_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + ww.Eq["store_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) orderSn = svc.GetOrderSn(strconv.Itoa(dao.OrderTypeStore), adminInfo.ID) } data.OrderSn = orderSn var cart dao.Cart - err = model.CartModel{}.Init().GetOne(w, &address) + + err = model.CartModel{}.Init().GetOne(ww, &cart) + l.Logger.Error(cart) if err != nil { return l.fail(utils.Fail) } @@ -114,20 +116,40 @@ func (l *WebCreateLogic) WebCreate(in *order.CreateOrderRequest) (*order.Respons if pErr != utils.Ok { return l.fail(utils.Fail) } - products, pErr := svc.GetCartData(ids) + products, pErr := svc.GetCartData(l.svcCtx.ProductSvcName, ids) if pErr != utils.Ok { return l.fail(utils.Fail) } - keys := make([]string, utils.NumberZero, len(products)) + keys := make([]string, utils.NumberZero, len(products.Items)) var totalPrice float64 - for _, item := range products { - keys = append(keys, strconv.Itoa(int(item.Id))) - totalPrice += item.Price * float64(item.Number) + errData := make(map[int64]int64) + productItems := []dao.OrderProductCreate{} + for _, item := range products.Items { + if buyNum, ok := ids[item.Id]; ok { + if buyNum > int64(item.Number) { + errData[item.Id] = int64(item.Number) + return l.out(utils.Fail, + item.Name+"购买数量超出库存,目前可以够买:"+strconv.Itoa(int(item.Number))) + } else { + keys = append(keys, strconv.Itoa(int(item.Id))) + totalPrice += item.Price * float64(buyNum) + productItems = append(productItems, dao.OrderProductCreate{ + OrderSn: data.OrderSn, + ProductId: int(item.Id), + ProductName: item.Name, + Price: item.Price, + Number: int(buyNum), + }) + } + } + } + if len(keys) < utils.NumberOne { + return l.out(utils.Fail, "购买信息不存在") } data.ProductIds = strings.Join(keys, utils.DecollatorComma) data.TotalPrice = totalPrice - mobileObj := model.OrderModel{}.Init() + mobileObj.Begin() err = mobileObj.Create(&data) if err != nil { @@ -135,38 +157,35 @@ func (l *WebCreateLogic) WebCreate(in *order.CreateOrderRequest) (*order.Respons return l.fail(utils.Fail) } - for _, item := range products { - orderProduct := dao.OrderProductCreate{ - Ordersn: data.OrderSn, - ProductId: int(item.Id), - ProductName: item.Name, - Price: item.Price, - Number: item.Number, - } - err = model.OrderProductModel{}.Init().Create(&orderProduct) + for _, item := range productItems { + err = model.OrderProductModel{}.Init().Create(&item) if err != nil { mobileObj.Rollback() return l.fail(utils.Fail) } - - _, err = model.CartModel{}.Init().Del(w, &cart) - if err != nil { - mobileObj.Rollback() - return l.fail(utils.Fail) - } - //TODO 扣除库存 - //$decrease = Product::decrease( - //['id' => $item['id'], ['number', '>=', $item['number']]], - //'number', - //$item['number'] - //); - //if ($decrease < 1) { - //Order::rollBack(); - //$retData['code'] = Code::code('low_stocks'); - //$retData['data'] = [$item['id'] => Product::value(['id' => $item['id']], 'number')]; - //return $retData; } + _, err = model.CartModel{}.Init().Del(ww, &cart) + if err != nil { + mobileObj.Rollback() + return l.fail(utils.Fail) + } + + //TODO 扣库存接口 + //cli, err := svc.GetRpcClient(l.svcCtx.ProductSvcName) + //if err != nil { + // mobileObj.Rollback() + // return l.fail(utils.Fail) + //} + + //productClient := product.NewProductClient(cli.Conn()) + //_, err = productClient.Number(l.ctx, &product.NumberReq{Id: item.Id, Type: utils.NumberOne, Number: buyNum}) + //if err != nil { + // mobileObj.Rollback() + // logx.Errorf("get products err: %v", err) + // return l.fail(utils.Fail, "产品库存不足") + //} + mobileObj.Commit() return l.ok(utils.NumberOne) diff --git a/services/order/internal/logic/webCreateOneLogic.go b/services/order/internal/logic/webCreateOneLogic.go index a57acdf..4063edc 100644 --- a/services/order/internal/logic/webCreateOneLogic.go +++ b/services/order/internal/logic/webCreateOneLogic.go @@ -2,9 +2,15 @@ package logic import ( "context" - + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" "lone-services/rpc/order/pb" + product "lone-services/rpc/product/pb" + "lone-services/services/order/internal/dao" + "lone-services/services/order/internal/model" "lone-services/services/order/internal/svc" + "lone-services/services/order/validator" + "strconv" "github.com/zeromicro/go-zero/core/logx" ) @@ -13,6 +19,7 @@ type WebCreateOneLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger + BaseLogic } func NewWebCreateOneLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebCreateOneLogic { @@ -24,7 +31,129 @@ func NewWebCreateOneLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebC } func (l *WebCreateOneLogic) WebCreateOne(in *order.CreateOrderOneRequest) (*order.Response, error) { - // todo: add your logic here and delete this line + var v validator.OrderOneCreateValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } - return &order.Response{}, nil + w := modelbase.Params{ + Eq: map[string]string{ + "id": strconv.FormatInt(in.AddressId, utils.NumberTen), + "type": strconv.Itoa(int(in.Type)), + "target_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen), + }, + } + var address dao.Address + err := model.AddressModel{}.Init().GetOne(w, &address) + if err != nil { + return l.fail(utils.Fail) + } + if address.Id < utils.NumberOne { + return l.out(utils.Fail, "地址不存在") + } + + data := dao.OrderCreate{ + Note: in.Note, + ExpiredTime: utils.GetAfterMinutes(utils.NumberThirty), + Mobile: address.Mobile, + Address: address.Address, + Addressee: address.Name, + DistrictIds: address.DistrictIds, + } + + ww := modelbase.Params{ + Eq: map[string]string{ + "type": strconv.Itoa(int(in.Type)), + }, + } + var orderSn string + switch in.Type { + case dao.CartTypeSale: + data.SaleId = int(adminInfo.ID) + data.SaleName = adminInfo.Name + data.CreateType = dao.OrderTypeSale + data.Type = dao.OrderTypeSale + ww.Eq["sale_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + orderSn = svc.GetOrderSn(strconv.Itoa(dao.OrderTypeSale), adminInfo.ID) + case dao.CartTypeUser: + data.UserId = int(adminInfo.ID) + data.UserName = adminInfo.Name + data.CreateType = dao.OrderTypePersonal + data.Type = dao.OrderTypePersonal + ww.Eq["user_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + orderSn = svc.GetOrderSn(strconv.Itoa(dao.OrderTypePersonal), adminInfo.ID) + case dao.CartTypeStore: + data.StoreId = int(adminInfo.ID) + data.StoreName = adminInfo.Name + data.SaleId = int(adminInfo.SaleId) + data.GroupId = int(adminInfo.GroupId) + data.SaleMobile = adminInfo.SaleMobile + data.SaleProvince = int(adminInfo.SaleProvince) + data.CreateType = dao.OrderTypeStore + data.Type = dao.OrderTypeStore + ww.Eq["store_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + orderSn = svc.GetOrderSn(strconv.Itoa(dao.OrderTypeStore), adminInfo.ID) + } + data.OrderSn = orderSn + + productInfo, pErr := svc.GetOneData(l.svcCtx.ProductSvcName, in.ProductId) + if pErr != utils.Ok { + return l.fail(utils.Fail) + } + if productInfo.Id != in.ProductId { + return l.out(utils.Fail, "购买信息不存在") + } + + if uint32(in.Num) > productInfo.Number { + return l.out(utils.Fail, + productInfo.Name+"购买数量超出库存,目前可以够买:"+strconv.Itoa(int(in.Num))) + } + + orderProduct := dao.OrderProductCreate{ + OrderSn: data.OrderSn, + ProductId: int(in.ProductId), + ProductName: productInfo.Name, + Price: productInfo.Price, + Number: int(in.Num), + } + + data.ProductIds = strconv.FormatInt(in.ProductId, utils.NumberTen) + data.TotalPrice = float64(in.Num) * productInfo.Price + mobileObj := model.OrderModel{}.Init() + + mobileObj.Begin() + err = mobileObj.Create(&data) + if err != nil { + mobileObj.Rollback() + return l.fail(utils.Fail) + } + + err = model.OrderProductModel{}.Init().Create(&orderProduct) + if err != nil { + mobileObj.Rollback() + return l.fail(utils.Fail) + } + + cli, err := svc.GetRpcClient(l.svcCtx.ProductSvcName) + if err != nil { + mobileObj.Rollback() + return l.fail(utils.Fail) + } + + productClient := product.NewProductClient(cli.Conn()) + _, err = productClient.Number(l.ctx, &product.NumberReq{Id: in.ProductId, Type: utils.NumberOne, Number: uint32(in.Num)}) + if err != nil { + mobileObj.Rollback() + logx.Errorf("get products err: %v", err) + return l.out(utils.Fail, + productInfo.Name+"购买数量超出库存,目前可以够买:"+strconv.Itoa(int(in.Num))) + } + + mobileObj.Commit() + + return l.ok(utils.NumberOne) } diff --git a/services/order/internal/server/orderServer.go b/services/order/internal/server/orderServer.go new file mode 100644 index 0000000..ec8d70a --- /dev/null +++ b/services/order/internal/server/orderServer.go @@ -0,0 +1,104 @@ +// Code generated by goctl. DO NOT EDIT. +// goctl 1.10.2 +// Source: order.proto + +package server + +import ( + "context" + + "lone-services/rpc/order/pb" + "lone-services/services/order/internal/logic" + "lone-services/services/order/internal/svc" +) + +type OrderServer struct { + svcCtx *svc.ServiceContext + order.UnimplementedOrderServer +} + +func NewOrderServer(svcCtx *svc.ServiceContext) *OrderServer { + return &OrderServer{ + svcCtx: svcCtx, + } +} + +func (s *OrderServer) Items(ctx context.Context, in *order.OrderItemsRequest) (*order.Response, error) { + l := logic.NewItemsLogic(ctx, s.svcCtx) + return l.Items(in) +} + +func (s *OrderServer) WebCreate(ctx context.Context, in *order.CreateOrderRequest) (*order.Response, error) { + l := logic.NewWebCreateLogic(ctx, s.svcCtx) + return l.WebCreate(in) +} + +func (s *OrderServer) WebCreateOne(ctx context.Context, in *order.CreateOrderOneRequest) (*order.Response, error) { + l := logic.NewWebCreateOneLogic(ctx, s.svcCtx) + return l.WebCreateOne(in) +} + +func (s *OrderServer) WebAddressCreate(ctx context.Context, in *order.EditAddressRequest) (*order.Response, error) { + l := logic.NewWebAddressCreateLogic(ctx, s.svcCtx) + return l.WebAddressCreate(in) +} + +func (s *OrderServer) WebAddressEdit(ctx context.Context, in *order.EditAddressRequest) (*order.Response, error) { + l := logic.NewWebAddressEditLogic(ctx, s.svcCtx) + return l.WebAddressEdit(in) +} + +func (s *OrderServer) WebAddressDel(ctx context.Context, in *order.IdAndTypeRequest) (*order.Response, error) { + l := logic.NewWebAddressDelLogic(ctx, s.svcCtx) + return l.WebAddressDel(in) +} + +func (s *OrderServer) WebAddressDef(ctx context.Context, in *order.IdAndTypeRequest) (*order.Response, error) { + l := logic.NewWebAddressDefLogic(ctx, s.svcCtx) + return l.WebAddressDef(in) +} + +func (s *OrderServer) WebAddressInfo(ctx context.Context, in *order.IdAndTypeRequest) (*order.Response, error) { + l := logic.NewWebAddressInfoLogic(ctx, s.svcCtx) + return l.WebAddressInfo(in) +} + +func (s *OrderServer) WebAddressItems(ctx context.Context, in *order.TypeRequest) (*order.Response, error) { + l := logic.NewWebAddressItemsLogic(ctx, s.svcCtx) + return l.WebAddressItems(in) +} + +func (s *OrderServer) WebCart(ctx context.Context, in *order.CartRequest) (*order.Response, error) { + l := logic.NewWebCartLogic(ctx, s.svcCtx) + return l.WebCart(in) +} + +func (s *OrderServer) WebCartEdit(ctx context.Context, in *order.EditCartRequest) (*order.Response, error) { + l := logic.NewWebCartEditLogic(ctx, s.svcCtx) + return l.WebCartEdit(in) +} + +func (s *OrderServer) AddressItem(ctx context.Context, in *order.AddressItemsRequest) (*order.Response, error) { + l := logic.NewAddressItemLogic(ctx, s.svcCtx) + return l.AddressItem(in) +} + +func (s *OrderServer) AddressByStore(ctx context.Context, in *order.AddressByStoreItemsRequest) (*order.Response, error) { + l := logic.NewAddressByStoreLogic(ctx, s.svcCtx) + return l.AddressByStore(in) +} + +func (s *OrderServer) OrderAuditingItems(ctx context.Context, in *order.OrderAuditingItemsRequest) (*order.Response, error) { + l := logic.NewOrderAuditingItemsLogic(ctx, s.svcCtx) + return l.OrderAuditingItems(in) +} + +func (s *OrderServer) OrderAuditing(ctx context.Context, in *order.OrderAuditingRequest) (*order.Response, error) { + l := logic.NewOrderAuditingLogic(ctx, s.svcCtx) + return l.OrderAuditing(in) +} + +func (s *OrderServer) OrderCreate(ctx context.Context, in *order.AdminCreateOrderRequest) (*order.Response, error) { + l := logic.NewOrderCreateLogic(ctx, s.svcCtx) + return l.OrderCreate(in) +} diff --git a/services/order/internal/svc/order.go b/services/order/internal/svc/order.go index 03bdded..0d0dc10 100644 --- a/services/order/internal/svc/order.go +++ b/services/order/internal/svc/order.go @@ -1,14 +1,15 @@ package svc import ( + "context" "fmt" "lone-services/pkg/utils" - "lone-services/services/order/internal/dao" + product "lone-services/rpc/product/pb" "math/rand" - "strconv" "time" jsoniter "github.com/json-iterator/go" + "github.com/zeromicro/go-zero/core/logx" ) func GetOrderSn(orderType string, adminId int64) string { @@ -20,42 +21,54 @@ func GetOrderSn(orderType string, adminId int64) string { return sn } -func GetCartData(info map[string]int) ([]dao.ProductInfo, utils.Status) { - keys := make([]string, utils.NumberZero, len(info)) +func GetCartData(name string, info map[int64]int64) (*product.ItemsByIdsData, utils.Status) { + keys := make([]int64, utils.NumberZero, len(info)) for k := range info { keys = append(keys, k) } - //TODO keys 查询产品 - var products []dao.ProductInfo + cli, err := GetRpcClient(name) + if err != nil { + logx.Errorf("get rpc client err: %v", err) + return nil, utils.Fail + } + productClient := product.NewProductClient(cli.Conn()) + products, err := productClient.ItemsByIds(context.Background(), &product.ItemsByIdsReq{Ids: keys}) + if err != nil { + logx.Errorf("get products err: %v", err) + return nil, utils.Fail + } - products = append(products, dao.ProductInfo{ - Id: 1, Name: "Product 1", - Price: 100, - Number: 5, - Images: "image1.jpg", - Stock: 10}) - products = append(products, dao.ProductInfo{ - Id: 2, Name: "Product 2", - Price: 100.33, - Number: 2, - Images: "image1.jpg", - Stock: 1033}) return products, utils.Ok } -func GetCartInfo(info string) (map[string]int, utils.Status) { - var list [][]int +func GetCartInfo(info string) (map[int64]int64, utils.Status) { + var list [][]int64 err := jsoniter.Unmarshal([]byte(info), &list) if err != nil { return nil, utils.ErrorJsonDataError } - - m := make(map[string]int, len(list)) + m := make(map[int64]int64, len(list)) for _, item := range list { if len(item) >= 2 { - m[strconv.Itoa(item[0])] = item[1] + m[item[0]] = item[1] } } return m, utils.Ok } + +func GetOneData(name string, id int64) (*product.Item, utils.Status) { + cli, err := GetRpcClient(name) + if err != nil { + logx.Errorf("get rpc client err: %v", err) + return nil, utils.Fail + } + productClient := product.NewProductClient(cli.Conn()) + productInfo, err := productClient.InfoById(context.Background(), &product.InfoByIdReq{Id: id}) + if err != nil { + logx.Errorf("get products err: %v", err) + return nil, utils.Fail + } + + return productInfo, utils.Ok +} diff --git a/services/order/internal/svc/servicecontext.go b/services/order/internal/svc/servicecontext.go index f85286e..ab2c079 100644 --- a/services/order/internal/svc/servicecontext.go +++ b/services/order/internal/svc/servicecontext.go @@ -78,22 +78,22 @@ type ServiceContext struct { DB *gorm.DB Prefix string - ExpressSvcName string //服务名 + ProductSvcName string //服务名 } func NewServiceContext(c config.Config, db *gorm.DB) *ServiceContext { //启动仅读取配置,不建立rpc连接 多个服务就多个 - expressSvc := utils.GetConfigString("services.express") + productSvc := utils.GetConfigString("services.product") - if expressSvc == utils.StringEmpty { - logx.Error("config services.express empty") + if productSvc == utils.StringEmpty { + logx.Error("config services.product empty") } svcCtx := &ServiceContext{ Config: c, DB: db, Prefix: utils.GetConfigString("mysql.prefix"), - ExpressSvcName: expressSvc, + ProductSvcName: productSvc, } return svcCtx diff --git a/services/order/orderClient/order.go b/services/order/orderClient/order.go index fa85849..76def06 100644 --- a/services/order/orderClient/order.go +++ b/services/order/orderClient/order.go @@ -14,22 +14,23 @@ import ( ) type ( - AddressItemsRequest = order.AddressItemsRequest - AdminCreateOrderRequest = order.AdminCreateOrderRequest - CartRequest = order.CartRequest - CreateOrderOneRequest = order.CreateOrderOneRequest - CreateOrderRequest = order.CreateOrderRequest - EditAddressRequest = order.EditAddressRequest - EditCartRequest = order.EditCartRequest - EmptyRequest = order.EmptyRequest - IdAndTypeRequest = order.IdAndTypeRequest - IdRequest = order.IdRequest - OrderAuditingItemsRequest = order.OrderAuditingItemsRequest - OrderAuditingRequest = order.OrderAuditingRequest - OrderItemsRequest = order.OrderItemsRequest - Response = order.Response - StatusAddressRequest = order.StatusAddressRequest - TypeRequest = order.TypeRequest + AddressByStoreItemsRequest = order.AddressByStoreItemsRequest + AddressItemsRequest = order.AddressItemsRequest + AdminCreateOrderRequest = order.AdminCreateOrderRequest + CartRequest = order.CartRequest + CreateOrderOneRequest = order.CreateOrderOneRequest + CreateOrderRequest = order.CreateOrderRequest + EditAddressRequest = order.EditAddressRequest + EditCartRequest = order.EditCartRequest + EmptyRequest = order.EmptyRequest + IdAndTypeRequest = order.IdAndTypeRequest + IdRequest = order.IdRequest + OrderAuditingItemsRequest = order.OrderAuditingItemsRequest + OrderAuditingRequest = order.OrderAuditingRequest + OrderItemsRequest = order.OrderItemsRequest + Response = order.Response + StatusAddressRequest = order.StatusAddressRequest + TypeRequest = order.TypeRequest Order interface { Items(ctx context.Context, in *OrderItemsRequest, opts ...grpc.CallOption) (*Response, error) @@ -44,6 +45,7 @@ type ( WebCart(ctx context.Context, in *CartRequest, opts ...grpc.CallOption) (*Response, error) WebCartEdit(ctx context.Context, in *EditCartRequest, opts ...grpc.CallOption) (*Response, error) AddressItem(ctx context.Context, in *AddressItemsRequest, opts ...grpc.CallOption) (*Response, error) + AddressByStore(ctx context.Context, in *AddressByStoreItemsRequest, opts ...grpc.CallOption) (*Response, error) OrderAuditingItems(ctx context.Context, in *OrderAuditingItemsRequest, opts ...grpc.CallOption) (*Response, error) OrderAuditing(ctx context.Context, in *OrderAuditingRequest, opts ...grpc.CallOption) (*Response, error) OrderCreate(ctx context.Context, in *AdminCreateOrderRequest, opts ...grpc.CallOption) (*Response, error) @@ -120,6 +122,11 @@ func (m *defaultOrder) AddressItem(ctx context.Context, in *AddressItemsRequest, return client.AddressItem(ctx, in, opts...) } +func (m *defaultOrder) AddressByStore(ctx context.Context, in *AddressByStoreItemsRequest, opts ...grpc.CallOption) (*Response, error) { + client := order.NewOrderClient(m.cli.Conn()) + return client.AddressByStore(ctx, in, opts...) +} + func (m *defaultOrder) OrderAuditingItems(ctx context.Context, in *OrderAuditingItemsRequest, opts ...grpc.CallOption) (*Response, error) { client := order.NewOrderClient(m.cli.Conn()) return client.OrderAuditingItems(ctx, in, opts...) diff --git a/services/order/validator/address.go b/services/order/validator/address.go index 5b897c0..286f455 100644 --- a/services/order/validator/address.go +++ b/services/order/validator/address.go @@ -86,3 +86,14 @@ func (p WebAddressItemsValidator) GetMessage() validate.ValidatorMessages { "Type.oneof": "类型不对", } } + +type AddressByStoreItemsValidator struct { + StoreId int64 `validate:"required"` +} + +// GetMessage 查看列表 - 提示消息 +func (p AddressByStoreItemsValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "StoreId.required": "Id不能为空", + } +} From e23bf8dea357d3ed85cca17dca27761215399eff Mon Sep 17 00:00:00 2001 From: gjs Date: Thu, 27 Aug 2026 17:12:00 +0800 Subject: [PATCH 3/5] change order pais --- go.mod | 1 + go.sum | 2 + rpc/order/order.pb | Bin 16513 -> 16557 bytes rpc/order/order.proto | 2 + rpc/order/pb/order.pb.go | 22 +++++- services/order/internal/dao/order.go | 1 + services/order/internal/logic/itemsLogic.go | 20 +++++- .../internal/logic/orderAuditingItemsLogic.go | 63 +++++++++++++++++- services/order/validator/order.go | 6 +- 9 files changed, 109 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index a2d0ec2..d978be5 100644 --- a/go.mod +++ b/go.mod @@ -108,6 +108,7 @@ require ( github.com/richardlehane/mscfb v1.0.7 // indirect github.com/richardlehane/msoleps v1.0.6 // indirect github.com/sagikazarmark/locafero v0.11.0 // indirect + github.com/samber/lo v1.53.0 // indirect github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.15.0 // indirect diff --git a/go.sum b/go.sum index 4cfedf8..a36fde8 100644 --- a/go.sum +++ b/go.sum @@ -304,6 +304,8 @@ github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0t github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc= github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik= +github.com/samber/lo v1.53.0 h1:t975lj2py4kJPQ6haz1QMgtId2gtmfktACxIXArw3HM= +github.com/samber/lo v1.53.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.1.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= diff --git a/rpc/order/order.pb b/rpc/order/order.pb index 8771e2eb626989bf68f5998e3ab9798aa84fb221..dcaebd21af4e31deb5b224d224e8f74997cb892c 100644 GIT binary patch delta 71 zcmZo{WL(?GxZ$xe ?": strconv.Itoa(utils.NumberZero)}, + } + + if v.Status > utils.NumberZero { + w.Eq = map[string]string{"verify_status": strconv.Itoa(int(v.Status))} + } + + if len(in.Time) > utils.NumberZero { + w.Other["create_time > ?"] = in.Time[utils.NumberZero] + w.Other["create_time < ?"] = in.Time[utils.NumberOne] + } + + items, err := model.OrderModel{}.Init().Page(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.ErrorNotFund) + } + var productItems []dao.OrderProducts + err = model.OrderProductModel{}.Init().Items(w, &productItems) + if err != nil { + utils.Logger.Error("product err:", err) + return l.fail(utils.ErrorNotFund) + } + + productMap := lo.GroupBy(productItems, func(item dao.OrderProducts) string { + return item.OrderSn + }) + + for key, v := range info { + mobile, aErr := utils.DecryptPhone(v.Mobile) + if aErr == nil { + if _, ok := productMap[v.OrderSn]; ok { + info[key].ProductItems = productMap[v.OrderSn] + } + info[key].AesMobile = v.Mobile + info[key].Mobile = utils.DecryptPhoneReplace(mobile) + } + } + items.Items = info + return l.ok(items) } diff --git a/services/order/validator/order.go b/services/order/validator/order.go index a16c935..8b64974 100644 --- a/services/order/validator/order.go +++ b/services/order/validator/order.go @@ -3,8 +3,10 @@ package validator import "lone-services/pkg/validate" type AdminOrderAuditingItemsValidator struct { - Page int32 - Size int32 + Page int32 + Size int32 + Time []string + Status int32 } // GetMessage 查看列表 - 提示消息 From 31d84236d3a4a1147119ddf8bf37992eab0ad7d7 Mon Sep 17 00:00:00 2001 From: gjs Date: Thu, 27 Aug 2026 17:24:18 +0800 Subject: [PATCH 4/5] express --- .gitea/workflows/ci.yml | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 9b0ffaf..5935876 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -11,11 +11,13 @@ on: - "services/user/**" - "services/ad/**" - "services/chore/**" + - "services/express/**" - "rpc/product/**" - "rpc/admin/**" - "rpc/user/**" - "rpc/ad/**" - "rpc/chore/**" + - "rpc/express/**" - "pkg/**" - ".gitea/workflows/ci.yml" workflow_dispatch: @@ -30,6 +32,7 @@ jobs: user: ${{ steps.filter.outputs.user }} ad: ${{ steps.filter.outputs.ad }} chore: ${{ steps.filter.outputs.chore }} + express: ${{ steps.filter.outputs.express }} steps: - name: Checkout uses: https://git.ailuowan.com/deploy/checkout@v4 @@ -45,6 +48,7 @@ jobs: user=false ad=false chore=false + express=false if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then bff=true @@ -53,6 +57,7 @@ jobs: user=true ad=true chore=true + express=true else before="${{ github.event.before }}" if [ -z "$before" ] || [ "$before" = "0000000000000000000000000000000000000000" ]; then @@ -70,6 +75,7 @@ jobs: echo "$changed" | grep -qE '^(services/user|rpc/user|pkg)/|^\.gitea/workflows/ci\.yml$' && user=true || true echo "$changed" | grep -qE '^(services/ad|rpc/ad|pkg)/|^\.gitea/workflows/ci\.yml$' && ad=true || true echo "$changed" | grep -qE '^(services/chore|rpc/chore|pkg)/|^\.gitea/workflows/ci\.yml$' && chore=true || true + echo "$changed" | grep -qE '^(services/express|rpc/express|pkg)/|^\.gitea/workflows/ci\.yml$' && express=true || true fi echo "bff=$bff" >> "$GITHUB_OUTPUT" @@ -78,6 +84,7 @@ jobs: echo "user=$user" >> "$GITHUB_OUTPUT" echo "ad=$ad" >> "$GITHUB_OUTPUT" echo "chore=$chore" >> "$GITHUB_OUTPUT" + echo "chore=express" >> "$GITHUB_OUTPUT" echo "bff=$bff product=$product admin=$admin user=$user ad=$ad chore=$chore" docker-bff: @@ -234,4 +241,30 @@ jobs: - name: Docker push run: | - docker push ${{ vars.REGISTRY }}/$NAME:latest \ No newline at end of file + docker push ${{ vars.REGISTRY }}/$NAME:latest + + docker-express: + needs: changes + if: needs.changes.outputs.express == 'true' + runs-on: runner + env: + NAME: lone/express + steps: + - name: Checkout + uses: https://git.ailuowan.com/deploy/checkout@v4 + + - name: Login Registry + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ vars.REGISTRY }} -u "${{ vars.REGISTRY_USERNAME }}" --password-stdin + + - name: Docker build + run: | + docker buildx use default + docker buildx build --builder default --load \ + -f services/express/Dockerfile \ + -t ${{ vars.REGISTRY }}/$NAME:latest \ + . + + - name: Docker push + run: | + docker push ${{ vars.REGISTRY }}/$NAME:latest From cd8a571f5776b5fea45e9d4cf556b910661afb82 Mon Sep 17 00:00:00 2001 From: gjs Date: Thu, 27 Aug 2026 17:27:55 +0800 Subject: [PATCH 5/5] express --- .gitea/workflows/cd-test.yml | 1 + services/express/internal/logic/namesLogic.go | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitea/workflows/cd-test.yml b/.gitea/workflows/cd-test.yml index 9e2614c..536194a 100644 --- a/.gitea/workflows/cd-test.yml +++ b/.gitea/workflows/cd-test.yml @@ -39,4 +39,5 @@ jobs: docker pull ${{ vars.REGISTRY }}/lone/product:latest docker pull ${{ vars.REGISTRY }}/lone/admin:latest docker pull ${{ vars.REGISTRY }}/lone/user:latest + docker pull ${{ vars.REGISTRY }}/lone/express:latest docker compose up -d diff --git a/services/express/internal/logic/namesLogic.go b/services/express/internal/logic/namesLogic.go index 490208e..799efe3 100644 --- a/services/express/internal/logic/namesLogic.go +++ b/services/express/internal/logic/namesLogic.go @@ -20,6 +20,7 @@ type NamesLogic struct { BaseLogic } +// NewNamesLogic 创建一个NamesLogic实例 func NewNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NamesLogic { return &NamesLogic{ ctx: ctx,