change order pais
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 查看列表 - 提示消息
|
||||
|
||||
Reference in New Issue
Block a user