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 8771e2e..dcaebd2 100644 Binary files a/rpc/order/order.pb and b/rpc/order/order.pb differ diff --git a/rpc/order/order.proto b/rpc/order/order.proto index 963f0b0..37fc32c 100644 --- a/rpc/order/order.proto +++ b/rpc/order/order.proto @@ -98,6 +98,8 @@ message AddressByStoreItemsRequest { message OrderAuditingItemsRequest { int32 page = 1; int32 size = 2; + int32 status = 3; + repeated string time = 8; } message OrderAuditingRequest { diff --git a/rpc/order/pb/order.pb.go b/rpc/order/pb/order.pb.go index a7afee9..2419dd4 100644 --- a/rpc/order/pb/order.pb.go +++ b/rpc/order/pb/order.pb.go @@ -906,6 +906,8 @@ type OrderAuditingItemsRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` Size int32 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` + Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"` + Time []string `protobuf:"bytes,8,rep,name=time,proto3" json:"time,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -954,6 +956,20 @@ func (x *OrderAuditingItemsRequest) GetSize() int32 { return 0 } +func (x *OrderAuditingItemsRequest) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *OrderAuditingItemsRequest) GetTime() []string { + if x != nil { + return x.Time + } + return nil +} + type OrderAuditingRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -1144,10 +1160,12 @@ const file_order_order_proto_rawDesc = "" + "\asale_id\x18\a \x01(\x03R\x06saleId\x12\x12\n" + "\x04time\x18\b \x03(\tR\x04time\"7\n" + "\x1aAddressByStoreItemsRequest\x12\x19\n" + - "\bstore_id\x18\x01 \x01(\x03R\astoreId\"C\n" + + "\bstore_id\x18\x01 \x01(\x03R\astoreId\"o\n" + "\x19OrderAuditingItemsRequest\x12\x12\n" + "\x04page\x18\x01 \x01(\x05R\x04page\x12\x12\n" + - "\x04size\x18\x02 \x01(\x05R\x04size\"V\n" + + "\x04size\x18\x02 \x01(\x05R\x04size\x12\x16\n" + + "\x06status\x18\x03 \x01(\x05R\x06status\x12\x12\n" + + "\x04time\x18\b \x03(\tR\x04time\"V\n" + "\x14OrderAuditingRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + "\x06status\x18\x02 \x01(\x05R\x06status\x12\x16\n" + diff --git a/services/order/internal/dao/order.go b/services/order/internal/dao/order.go index f0dc646..41e604b 100644 --- a/services/order/internal/dao/order.go +++ b/services/order/internal/dao/order.go @@ -187,6 +187,7 @@ type OrderImitateInfo struct { type OrderImitateItems struct { OrderImitateInfo ProductItems []OrderProducts `gorm:"-" json:"product_items"` + AesMobile string `gorm:"-" json:"aes_mobile"` } type OrderDownInfo struct { diff --git a/services/order/internal/logic/itemsLogic.go b/services/order/internal/logic/itemsLogic.go index cf43517..b48cb03 100644 --- a/services/order/internal/logic/itemsLogic.go +++ b/services/order/internal/logic/itemsLogic.go @@ -12,6 +12,7 @@ import ( order "lone-services/rpc/order/pb" "lone-services/services/order/internal/svc" + "github.com/samber/lo" "github.com/zeromicro/go-zero/core/logx" ) @@ -80,18 +81,33 @@ func (l *ItemsLogic) Items(in *order.OrderItemsRequest) (*order.Response, error) w.Other["create_time < ?"] = strconv.Itoa(int(in.Time[utils.NumberOne])) } - err := model.OrderModel{}.Init().Items(w, &info) + 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) } } - return l.ok(info) + items.Items = info + return l.ok(items) } diff --git a/services/order/internal/logic/orderAuditingItemsLogic.go b/services/order/internal/logic/orderAuditingItemsLogic.go index 1997b29..6e14399 100644 --- a/services/order/internal/logic/orderAuditingItemsLogic.go +++ b/services/order/internal/logic/orderAuditingItemsLogic.go @@ -2,10 +2,17 @@ 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/samber/lo" "github.com/zeromicro/go-zero/core/logx" ) @@ -25,7 +32,59 @@ func NewOrderAuditingItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) } func (l *OrderAuditingItemsLogic) OrderAuditingItems(in *order.OrderAuditingItemsRequest) (*order.Response, error) { - // todo: add your logic here and delete this line + var v validator.AdminOrderAuditingItemsValidator + 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 + var info []dao.OrderImitateItems + w := modelbase.Params{ + Page: int(v.Page), + Size: int(v.Size), + Order: "id desc", + Eq: map[string]string{}, + Other: map[string]string{"verify_status > ?": 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 查看列表 - 提示消息