浏览代码

新增Rpc接口

jiayuqi 4 年之前
父节点
当前提交
8e3939e4b9
共有 3 个文件被更改,包括 186 次插入0 次删除
  1. 64 0
      api/grpc/base.go
  2. 53 0
      assembly/base/repository/postgre/order.go
  3. 69 0
      assembly/base/service/order.go

+ 64 - 0
api/grpc/base.go

@@ -739,3 +739,67 @@ func (a Api) STTDetailAllowDelCheck(ctx context.Context, r *pb.StandardRequest)
 	rst := a.toWebFunc(rs)
 	return rst, nil
 }
+
+// ----------------------- 商家上下课管理 ---------------------------------------------
+
+// ----------------------- 商家预约管理 ---------------------------------------------
+
+// OrderListQuery 预约记录查询
+func (a Api) OrderListQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Order{}.OrderListQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// OrderAddByManager 管理员预约添加
+func (a Api) OrderAddByManager(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Order{}.OrderAddByManager(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// OrderCancelByManager 管理员预约取消
+func (a Api) OrderCancelByManager(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Order{}.OrderCancelByManager(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// OrderStatistics 商家预约统计
+func (a Api) OrderStatistics(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Order{}.OrderStatistics(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ClassOrderQuery 可预约课程预约列表查询
+func (a Api) ClassOrderQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Order{}.ClassOrderQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// VipUserOrderQuery 会员预约列表查询
+func (a Api) VipUserOrderQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Order{}.VipUserOrderQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}

+ 53 - 0
assembly/base/repository/postgre/order.go

@@ -0,0 +1,53 @@
+// Package postgre
+/**
+ * @ File:
+ * @ Date: 2021/5/4 11:26
+ * @ Author: JYQ
+ * @ Description:
+ */
+package postgre
+
+type PGOrder struct {
+}
+
+func (PGOrder) OrderListQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_order_List_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGOrder) OrderAdd(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_order_add(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGOrder) OrderCancel(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_order_cancel(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGOrder) OrderStatistics(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_order_statistics(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGOrder) ClassListByOrderDate(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_class_list_by_order_date(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGOrder) VipUserOrderQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_order_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}

+ 69 - 0
assembly/base/service/order.go

@@ -6,3 +6,72 @@
  * @ Description: 预约管理
  */
 package service
+
+import (
+	"sportfitness/base/assembly/base/repository/postgre"
+	"sportfitness/base/errors"
+)
+
+type Order struct {
+	base
+}
+
+func (o Order) OrderListQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := o.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGOrder{}.OrderListQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (o Order) OrderAddByManager(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := o.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGOrder{}.OrderAdd(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (o Order) OrderCancelByManager(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := o.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGOrder{}.OrderCancel(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (o Order) OrderStatistics(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := o.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGOrder{}.OrderStatistics(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (o Order) ClassOrderQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := o.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGOrder{}.ClassListByOrderDate(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (o Order) VipUserOrderQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := o.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGOrder{}.VipUserOrderQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}