新增APP查询页
This commit is contained in:
parent
ece4b5d1b1
commit
0e6cb95499
@ -23,3 +23,11 @@ service main {
|
|||||||
get /en/:product_en (GetProductByEnRequest) returns (ProductResponse)
|
get /en/:product_en (GetProductByEnRequest) returns (ProductResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@server (
|
||||||
|
prefix: api/v1/product
|
||||||
|
group: product
|
||||||
|
)
|
||||||
|
service main {
|
||||||
|
@handler GetProductAppByEn
|
||||||
|
get /app_en/:product_en (GetProductByEnRequest) returns (ProductResponse)
|
||||||
|
}
|
||||||
|
@ -21,6 +21,9 @@ service main {
|
|||||||
@doc "query service agent"
|
@doc "query service agent"
|
||||||
@handler queryServiceAgent
|
@handler queryServiceAgent
|
||||||
post /query/service_agent/:product (QueryServiceReq) returns (QueryServiceResp)
|
post /query/service_agent/:product (QueryServiceReq) returns (QueryServiceResp)
|
||||||
|
|
||||||
|
@handler queryServiceApp
|
||||||
|
post /query/service_app/:product (QueryServiceReq) returns (QueryServiceResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@server (
|
@server (
|
||||||
@ -34,8 +37,6 @@ service main {
|
|||||||
post /query/service/:product (QueryServiceReq) returns (QueryServiceResp)
|
post /query/service/:product (QueryServiceReq) returns (QueryServiceResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@server (
|
@server (
|
||||||
prefix: api/v1
|
prefix: api/v1
|
||||||
group: query
|
group: query
|
||||||
@ -56,15 +57,15 @@ service main {
|
|||||||
|
|
||||||
@doc "查询详情 按订单号 付款查询时"
|
@doc "查询详情 按订单号 付款查询时"
|
||||||
@handler queryDetailByOrderId
|
@handler queryDetailByOrderId
|
||||||
get /query/orderId/:order_id (QueryDetailByOrderIdReq) returns (QueryDetailByOrderIdResp)
|
get /query/orderId/:order_id (QueryDetailByOrderIdReq) returns (QueryDetailByOrderIdResp)
|
||||||
|
|
||||||
@doc "查询详情 按订单号"
|
@doc "查询详情 按订单号"
|
||||||
@handler queryDetailByOrderNo
|
@handler queryDetailByOrderNo
|
||||||
get /query/orderNo/:order_no (QueryDetailByOrderNoReq) returns (QueryDetailByOrderNoResp)
|
get /query/orderNo/:order_no (QueryDetailByOrderNoReq) returns (QueryDetailByOrderNoResp)
|
||||||
|
|
||||||
@doc "查询详情"
|
@doc "查询详情"
|
||||||
@handler queryDetail
|
@handler queryDetail
|
||||||
get /query/:id (QueryDetailReq) returns (QueryDetailResp)
|
get /query/:id (QueryDetailReq) returns (QueryDetailResp)
|
||||||
|
|
||||||
@doc "重试查询"
|
@doc "重试查询"
|
||||||
@handler queryRetry
|
@handler queryRetry
|
||||||
@ -79,3 +80,4 @@ service main {
|
|||||||
@handler querySingleTest
|
@handler querySingleTest
|
||||||
post /query/single/test (QuerySingleTestReq) returns (QuerySingleTestResp)
|
post /query/single/test (QuerySingleTestReq) returns (QuerySingleTestResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ type (
|
|||||||
Product string `path:"product"`
|
Product string `path:"product"`
|
||||||
Data string `json:"data" validate:"required"`
|
Data string `json:"data" validate:"required"`
|
||||||
AgentIdentifier string `json:"agent_identifier,optional"`
|
AgentIdentifier string `json:"agent_identifier,optional"`
|
||||||
|
App bool `json:"app,optional"`
|
||||||
}
|
}
|
||||||
QueryServiceResp {
|
QueryServiceResp {
|
||||||
id string `json:"id"`
|
id string `json:"id"`
|
||||||
@ -121,6 +122,6 @@ type QuerySingleTestReq {
|
|||||||
|
|
||||||
type QuerySingleTestResp {
|
type QuerySingleTestResp {
|
||||||
Data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
Api string `json:"api"`
|
Api string `json:"api"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package product
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/logic/product"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/svc"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/types"
|
||||||
|
"tydata-server/common/result"
|
||||||
|
"tydata-server/pkg/lzkit/validator"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetProductAppByEnHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.GetProductByEnRequest
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
result.ParamErrorResult(r, w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := validator.Validate(req); err != nil {
|
||||||
|
result.ParamValidateErrorResult(r, w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
l := product.NewGetProductAppByEnLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetProductAppByEn(&req)
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package query
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/logic/query"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/svc"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/types"
|
||||||
|
"tydata-server/common/result"
|
||||||
|
"tydata-server/pkg/lzkit/validator"
|
||||||
|
)
|
||||||
|
|
||||||
|
func QueryServiceAppHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.QueryServiceReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
result.ParamErrorResult(r, w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := validator.Validate(req); err != nil {
|
||||||
|
result.ParamValidateErrorResult(r, w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
l := query.NewQueryServiceLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.QueryService(&req)
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
@ -182,6 +182,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
rest.WithPrefix("/api/v1/product"),
|
rest.WithPrefix("/api/v1/product"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
server.AddRoutes(
|
||||||
|
[]rest.Route{
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/app_en/:product_en",
|
||||||
|
Handler: product.GetProductAppByEnHandler(serverCtx),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rest.WithPrefix("/api/v1/product"),
|
||||||
|
)
|
||||||
|
|
||||||
server.AddRoutes(
|
server.AddRoutes(
|
||||||
[]rest.Route{
|
[]rest.Route{
|
||||||
{
|
{
|
||||||
@ -190,6 +201,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/query/service_agent/:product",
|
Path: "/query/service_agent/:product",
|
||||||
Handler: query.QueryServiceAgentHandler(serverCtx),
|
Handler: query.QueryServiceAgentHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/query/service_app/:product",
|
||||||
|
Handler: query.QueryServiceAppHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rest.WithPrefix("/api/v1"),
|
rest.WithPrefix("/api/v1"),
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,6 @@ package agent
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/jinzhu/copier"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"tydata-server/app/user/model"
|
"tydata-server/app/user/model"
|
||||||
"tydata-server/common/ctxdata"
|
"tydata-server/common/ctxdata"
|
||||||
@ -41,10 +40,14 @@ func (l *SaveAgentMembershipUserConfigLogic) SaveAgentMembershipUserConfig(req *
|
|||||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = copier.Copy(&agentMembershipUserConfigModel, &req)
|
//err = copier.Copy(&agentMembershipUserConfigModel, &req)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "保存会员代理报告配置: %v", err)
|
// return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "保存会员代理报告配置: %v", err)
|
||||||
}
|
//}
|
||||||
|
agentMembershipUserConfigModel.PriceRatio = req.PriceRatio
|
||||||
|
agentMembershipUserConfigModel.PriceIncreaseAmount = req.PriceIncreaseAmount
|
||||||
|
agentMembershipUserConfigModel.PriceRangeFrom = req.PriceRangeFrom
|
||||||
|
agentMembershipUserConfigModel.PriceRangeTo = req.PriceRangeTo
|
||||||
if agentMembershipUserConfigModel == nil {
|
if agentMembershipUserConfigModel == nil {
|
||||||
agentMembershipUserConfigModel.UserId = userID
|
agentMembershipUserConfigModel.UserId = userID
|
||||||
agentMembershipUserConfigModel.AgentId = agentModel.Id
|
agentMembershipUserConfigModel.AgentId = agentModel.Id
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
package product
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/zeromicro/go-zero/core/mr"
|
||||||
|
"tydata-server/app/user/model"
|
||||||
|
"tydata-server/common/xerr"
|
||||||
|
|
||||||
|
"tydata-server/app/user/cmd/api/internal/svc"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetProductAppByEnLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetProductAppByEnLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetProductAppByEnLogic {
|
||||||
|
return &GetProductAppByEnLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetProductAppByEnLogic) GetProductAppByEn(req *types.GetProductByEnRequest) (resp *types.ProductResponse, err error) {
|
||||||
|
productModel, err := l.svcCtx.ProductModel.FindOneByProductEn(l.ctx, req.ProductEn)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "产品查询, 查找产品错误: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
build := l.svcCtx.ProductFeatureModel.SelectBuilder().Where(squirrel.Eq{
|
||||||
|
"product_id": productModel.Id,
|
||||||
|
})
|
||||||
|
productFeatureAll, err := l.svcCtx.ProductFeatureModel.FindAll(l.ctx, build, "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "产品查询, 查找产品关联错误: %v", err)
|
||||||
|
}
|
||||||
|
var product types.Product
|
||||||
|
err = copier.Copy(&product, productModel)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "用户信息, 用户信息结构体复制失败, %v", err)
|
||||||
|
}
|
||||||
|
mr.MapReduceVoid(func(source chan<- interface{}) {
|
||||||
|
for _, productFeature := range productFeatureAll {
|
||||||
|
source <- productFeature.FeatureId
|
||||||
|
}
|
||||||
|
}, func(item interface{}, writer mr.Writer[*model.Feature], cancel func(error)) {
|
||||||
|
id := item.(int64)
|
||||||
|
|
||||||
|
feature, findFeatureErr := l.svcCtx.FeatureModel.FindOne(l.ctx, id)
|
||||||
|
if findFeatureErr != nil {
|
||||||
|
logx.WithContext(l.ctx).Errorf("产品查询, 查找关联feature错误: %d, err:%v", id, findFeatureErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if feature != nil && feature.Id > 0 {
|
||||||
|
writer.Write(feature)
|
||||||
|
}
|
||||||
|
}, func(pipe <-chan *model.Feature, cancel func(error)) {
|
||||||
|
for item := range pipe {
|
||||||
|
var feature types.Feature
|
||||||
|
_ = copier.Copy(&feature, item)
|
||||||
|
product.Features = append(product.Features, feature)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return &types.ProductResponse{Product: product}, nil
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package query
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"tydata-server/app/user/cmd/api/internal/svc"
|
||||||
|
"tydata-server/app/user/cmd/api/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type QueryServiceAppLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewQueryServiceAppLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryServiceAppLogic {
|
||||||
|
return &QueryServiceAppLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *QueryServiceAppLogic) QueryServiceApp(req *types.QueryServiceReq) (resp *types.QueryServiceResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
@ -40,30 +40,12 @@ func NewQueryServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Quer
|
|||||||
func (l *QueryServiceLogic) QueryService(req *types.QueryServiceReq) (resp *types.QueryServiceResp, err error) {
|
func (l *QueryServiceLogic) QueryService(req *types.QueryServiceReq) (resp *types.QueryServiceResp, err error) {
|
||||||
if req.AgentIdentifier != "" {
|
if req.AgentIdentifier != "" {
|
||||||
l.ctx = context.WithValue(l.ctx, "agentIdentifier", req.AgentIdentifier)
|
l.ctx = context.WithValue(l.ctx, "agentIdentifier", req.AgentIdentifier)
|
||||||
return l.PreprocessLogic(req, req.Product)
|
} else if req.App {
|
||||||
|
l.ctx = context.WithValue(l.ctx, "app", req.App)
|
||||||
}
|
}
|
||||||
return l.PreprocessLogic(req, req.Product)
|
return l.PreprocessLogic(req, req.Product)
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (l *QueryServiceLogic) agentParsing(req *types.QueryServiceReq) (*types.AgentIdentifier, error) {
|
|
||||||
// key, decodeErr := hex.DecodeString("8e3e7a2f60edb49221e953b9c029ed10")
|
|
||||||
// if decodeErr != nil {
|
|
||||||
// return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 获取AES密钥失败: %+v", decodeErr)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// encrypted, err := crypto.AesDecryptURL(req.Product, key)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, %v", err)
|
|
||||||
// }
|
|
||||||
// var agentIdentifier types.AgentIdentifier
|
|
||||||
// err = json.Unmarshal(encrypted, &agentIdentifier)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务,反序列化失败 %v", err)
|
|
||||||
// }
|
|
||||||
// l.ctx = context.WithValue(l.ctx, "agent", req.Agent)
|
|
||||||
// return &agentIdentifier, nil
|
|
||||||
//}
|
|
||||||
|
|
||||||
var productProcessors = map[string]func(*QueryServiceLogic, *types.QueryServiceReq) (*types.QueryServiceResp, error){
|
var productProcessors = map[string]func(*QueryServiceLogic, *types.QueryServiceReq) (*types.QueryServiceResp, error){
|
||||||
"marriage": (*QueryServiceLogic).ProcessMarriageLogic,
|
"marriage": (*QueryServiceLogic).ProcessMarriageLogic,
|
||||||
"homeservice": (*QueryServiceLogic).ProcessHomeServiceLogic,
|
"homeservice": (*QueryServiceLogic).ProcessHomeServiceLogic,
|
||||||
@ -1387,7 +1369,8 @@ func (l *QueryServiceLogic) CacheData(params map[string]interface{}, Product str
|
|||||||
|
|
||||||
func (l *QueryServiceLogic) GetOrCreateUser(mobile string) (int64, error) {
|
func (l *QueryServiceLogic) GetOrCreateUser(mobile string) (int64, error) {
|
||||||
agentIdentifier, ok := l.ctx.Value("agentIdentifier").(string)
|
agentIdentifier, ok := l.ctx.Value("agentIdentifier").(string)
|
||||||
if !ok || agentIdentifier == "" {
|
app, appOk := l.ctx.Value("app").(bool)
|
||||||
|
if (!ok || agentIdentifier == "") && (!appOk || app == false) {
|
||||||
// 不是代理查询
|
// 不是代理查询
|
||||||
userID, getUidErr := ctxdata.GetUidFromCtx(l.ctx)
|
userID, getUidErr := ctxdata.GetUidFromCtx(l.ctx)
|
||||||
if getUidErr != nil {
|
if getUidErr != nil {
|
||||||
|
@ -341,6 +341,7 @@ type QueryServiceReq struct {
|
|||||||
Product string `path:"product"`
|
Product string `path:"product"`
|
||||||
Data string `json:"data" validate:"required"`
|
Data string `json:"data" validate:"required"`
|
||||||
AgentIdentifier string `json:"agent_identifier,optional"`
|
AgentIdentifier string `json:"agent_identifier,optional"`
|
||||||
|
App bool `json:"app,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type QueryServiceResp struct {
|
type QueryServiceResp struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user