change order pais
This commit is contained in:
@@ -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)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user