feat: sale info
This commit is contained in:
@@ -20,6 +20,8 @@ type DecryptMobileData struct {
|
||||
Mobile string `json:"mobile"`
|
||||
}
|
||||
|
||||
const encryptedPhoneLen = 72
|
||||
|
||||
func NewDecryptMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DecryptMobileLogic {
|
||||
return &DecryptMobileLogic{
|
||||
ctx: ctx,
|
||||
@@ -38,6 +40,9 @@ func (l *DecryptMobileLogic) DecryptMobile(in *chore.DecryptMobileReq) (*chore.R
|
||||
if originMobile == utils.StringEmpty {
|
||||
return failResponse(utils.ErrorParams), nil
|
||||
}
|
||||
if len(originMobile) < encryptedPhoneLen {
|
||||
return failResponse(utils.ErrorMobileError), nil
|
||||
}
|
||||
|
||||
mobile, err := utils.DecryptPhone(originMobile)
|
||||
if err != nil {
|
||||
|
||||
@@ -31,15 +31,15 @@ func NewTestLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TestLogic {
|
||||
}
|
||||
|
||||
func (l *TestLogic) Test(in *chore.TestReq) (*chore.Response, error) {
|
||||
cli, err := rpcclient.Get(l.svcCtx.ProductSvcName)
|
||||
// cli, err := rpcclient.Get(l.svcCtx.SaleSvcName)
|
||||
// cli, err := rpcclient.Get(l.svcCtx.ProductSvcName)
|
||||
cli, err := rpcclient.Get(l.svcCtx.SaleSvcName)
|
||||
|
||||
if err != nil {
|
||||
l.Errorf("get rpc: %v", err)
|
||||
return failResponse(utils.ErrorInternalServer), nil
|
||||
}
|
||||
|
||||
// 产品库存更变
|
||||
// ——————————————————————————————产品库存更变——————————————————————————————
|
||||
// _, err = product.NewProductClient(cli.Conn()).Number(l.ctx, &product.NumberReq{
|
||||
// Id: in.GetId(),
|
||||
// Type: productNumberTypeDecr,
|
||||
@@ -53,7 +53,7 @@ func (l *TestLogic) Test(in *chore.TestReq) (*chore.Response, error) {
|
||||
|
||||
// fmt.Println(res.GetName())
|
||||
|
||||
// 获取多个产品详情
|
||||
// ——————————————————————————————获取多个产品详情——————————————————————————————
|
||||
// res, err := product.NewProductClient(cli.Conn()).ItemsByIds(l.ctx, &product.ItemsByIdsReq{
|
||||
// Ids: in.GetIds(),
|
||||
// })
|
||||
@@ -61,13 +61,22 @@ func (l *TestLogic) Test(in *chore.TestReq) (*chore.Response, error) {
|
||||
// fmt.Println(item.GetName())
|
||||
// }
|
||||
|
||||
// 销售 names
|
||||
res, err := sale.NewSaleClient(cli.Conn()).NamesInternal(l.ctx, &sale.NamesReq{
|
||||
Type: in.GetNumber(),
|
||||
Level: uint32(in.GetId()),
|
||||
})
|
||||
// ——————————————————————————————销售 names——————————————————————————————
|
||||
// Type:销售类型
|
||||
// 1 销售人员
|
||||
// 2 销售商(法人)
|
||||
// 3 销售商(个人)
|
||||
// 0 或不传:不按类型过滤
|
||||
|
||||
// TODO: 批量扣减库存
|
||||
// Level:层级过滤
|
||||
// 1:只查顶级(sale_id = 0,没有上级)
|
||||
// 0 或不传:不按层级过滤
|
||||
// res, err := sale.NewSaleClient(cli.Conn()).NamesInternal(l.ctx, &sale.NamesReq{
|
||||
// Type: in.GetNumber(),
|
||||
// Level: uint32(in.GetId()),
|
||||
// })
|
||||
|
||||
// ——————————————————————————————批量扣减库存——————————————————————————————
|
||||
// items := make([]*product.NumberItem, 0, len(in.GetIds()))
|
||||
// for _, id := range in.GetIds() {
|
||||
// items = append(items, &product.NumberItem{
|
||||
@@ -75,19 +84,37 @@ func (l *TestLogic) Test(in *chore.TestReq) (*chore.Response, error) {
|
||||
// Number: in.GetNumber(),
|
||||
// })
|
||||
// }
|
||||
// // {
|
||||
// // "items" : [
|
||||
// // {
|
||||
// // "id": 1,
|
||||
// // "number": 10
|
||||
// // }
|
||||
// // {
|
||||
// // "id": 2,
|
||||
// // "number": 20
|
||||
// // }
|
||||
// // ],
|
||||
// // "type": 1
|
||||
// // }
|
||||
// _, err = product.NewProductClient(cli.Conn()).NumberItems(l.ctx, &product.NumberItemsReq{
|
||||
// Type: productNumberTypeDecr,
|
||||
// Items: items,
|
||||
// })
|
||||
|
||||
// ——————————————————————————————销售详情——————————————————————————————
|
||||
res, err := sale.NewSaleClient(cli.Conn()).InfoInternal(l.ctx, &sale.InfoReq{
|
||||
Id: int64(in.GetId()),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
l.Errorf("XXXXXXXXXXX: %v", err)
|
||||
l.Errorf("XXXXXX: %v", err)
|
||||
return failResponse(utils.ErrorInternalServer), nil
|
||||
}
|
||||
if res == nil {
|
||||
l.Errorf("XXXXXXXXXXX res为空")
|
||||
l.Errorf("XXXXXXXXXX res为空")
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
return okResponse(nil), nil
|
||||
return okResponse(res), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user