Forráskód Böngészése

feature(计费): 已出账单、未出账单、收费明细的查询接口实现

likai 4 éve
szülő
commit
b1be48b83e

+ 3 - 3
dao/account/internal/settle_account_detail.go

@@ -29,7 +29,7 @@ type settleAccountDetailColumns struct {
 	Id              string // 主键
 	Pid             string // 结算明细主表Id
 	UnitPrice       string // 计费单价
-	ActuralMinutes  string // 实际机时(分钟)
+	ActualMinutes   string // 实际机时(分钟)
 	Minutes         string // 计费时长(分钟)
 	PaymentType     string // 计费类型:0计时收费;1违约收费;2辅助收费
 	PaymentAccount  string // 费用
@@ -62,7 +62,7 @@ var (
 			Id:             "Id",
 			Pid:            "pid",
 			UnitPrice:      "UnitPrice",
-			ActuralMinutes: "ActuralMinutes",
+			ActualMinutes:  "ActualMinutes",
 			Minutes:        "Minutes",
 			PaymentType:    "PaymentType",
 			PaymentAccount: "PaymentAccount",
@@ -97,7 +97,7 @@ func NewSettleAccountDetailDao(tenant string) SettleAccountDetailDao {
 			Id:             "Id",
 			Pid:            "pid",
 			UnitPrice:      "UnitPrice",
-			ActuralMinutes: "ActuralMinutes",
+			ActualMinutes:  "ActualMinutes",
 			Minutes:        "Minutes",
 			PaymentType:    "PaymentType",
 			PaymentAccount: "PaymentAccount",

+ 36 - 0
handler/settle_account_bill.go

@@ -1 +1,37 @@
 package handler
+
+import (
+	"context"
+	"dashoo.cn/common_definition/comm_def"
+	"dashoo.cn/micro_libary/micro_srv"
+	"dashoo.cn/micro_libary/myerrors"
+	"github.com/gogf/gf/frame/g"
+	"lims_adapter/model"
+	service "lims_adapter/service/settle_account_bill"
+)
+
+// 结算
+type SettleAccountBillController struct{}
+
+// 结算账单(已出账单)分页
+func (a *SettleAccountBillController) SettleAccountBillList(ctx context.Context, req *model.ListReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Account.SettleAccountBillList request @ " + tenant)
+	if req.Current < 0 {
+		req.Current = DefaultPageCurrent
+	}
+
+	var list, total, errors = service.NewService(tenant).List(*req)
+	_, err, code, msg := myerrors.CheckError(errors)
+	if err != nil {
+		return err
+	}
+
+	rsp.Code = code
+	rsp.Msg = msg
+	rsp.Data = g.Map{"total": total, "list": list}
+	return nil
+}

+ 36 - 0
handler/settle_account_detail.go

@@ -1 +1,37 @@
 package handler
+
+import (
+	"context"
+	"dashoo.cn/common_definition/comm_def"
+	"dashoo.cn/micro_libary/micro_srv"
+	"dashoo.cn/micro_libary/myerrors"
+	"github.com/gogf/gf/frame/g"
+	"lims_adapter/model"
+	service "lims_adapter/service/settle_account_detail"
+)
+
+// 结算
+type SettleAccountDetailController struct{}
+
+// 收费明细
+func (a *SettleAccountDetailController) SettleAccountDetailList(ctx context.Context, req *model.ListReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Account.SettleAccountDetailList request @ " + tenant)
+	if req.Current < 0 {
+		req.Current = DefaultPageCurrent
+	}
+
+	var list, errors = service.NewService(tenant).List(*req)
+	_, err, code, msg := myerrors.CheckError(errors)
+	if err != nil {
+		return err
+	}
+
+	rsp.Code = code
+	rsp.Msg = msg
+	rsp.Data = g.Map{"list": list}
+	return nil
+}

+ 36 - 0
handler/settle_account_main.go

@@ -1 +1,37 @@
 package handler
+
+import (
+	"context"
+	"dashoo.cn/common_definition/comm_def"
+	"dashoo.cn/micro_libary/micro_srv"
+	"dashoo.cn/micro_libary/myerrors"
+	"github.com/gogf/gf/frame/g"
+	"lims_adapter/model"
+	service "lims_adapter/service/settle_account_main"
+)
+
+// 结算
+type SettleAccountMainController struct{}
+
+// 结算明细(未出账单)分页
+func (a *SettleAccountMainController) SettleAccountMainList(ctx context.Context, req *model.ListReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Account.SettleAccountMainList request @ " + tenant)
+	if req.Current < 0 {
+		req.Current = DefaultPageCurrent
+	}
+
+	var list, total, errors = service.NewService(tenant).List(*req)
+	_, err, code, msg := myerrors.CheckError(errors)
+	if err != nil {
+		return err
+	}
+
+	rsp.Code = code
+	rsp.Msg = msg
+	rsp.Data = g.Map{"total": total, "list": list}
+	return nil
+}

+ 3 - 0
main.go

@@ -24,6 +24,9 @@ func main() {
 	s.RegisterName("System", new(handler.System), "")
 	s.RegisterName("Result", new(handler.Result), "")
 	s.RegisterName("Account", new(handler.Account), "")
+	s.RegisterName("SettleAccountBill", new(handler.SettleAccountBillController), "")
+	s.RegisterName("SettleAccountMain", new(handler.SettleAccountMainController), "")
+	s.RegisterName("SettleAccountDetail", new(handler.SettleAccountDetailController), "")
 	// 注册auth处理
 	s.AuthFunc = handleAuth
 	// 运行服务

+ 1 - 1
model/account/internal/settle_account_detail.go

@@ -13,7 +13,7 @@ type SettleAccountDetail struct {
 	Id             int         `orm:"Id,primary"     json:"id"`              // 主键
 	Pid            int         `orm:"pid"            json:"pid"`             // 结算明细主表Id
 	UnitPrice      float64     `orm:"UnitPrice"      json:"unit_price"`      // 计费单价
-	ActuralMinutes string      `orm:"ActuralMinutes" json:"actural_minutes"` // 实际机时(分钟)
+	ActualMinutes string      `orm:"ActualMinutes" json:"actual_minutes"` // 实际机时(分钟)
 	Minutes        string      `orm:"Minutes"        json:"minutes"`         // 计费时长(分钟)
 	PaymentType    string      `orm:"PaymentType"    json:"payment_type"`    // 计费类型:0计时收费;1违约收费;2辅助收费
 	PaymentAccount float64     `orm:"PaymentAccount" json:"payment_account"` // 费用

+ 2 - 5
model/account/settle_account_bill.go

@@ -14,9 +14,6 @@ type SettleAccountBill internal.SettleAccountBill
 // Fill with you ideas below.
 
 type SettleAccountBillReq struct {
-	PageNun     int    `json:"pageNum"`
-	PageSize    int    `json:"pageSize"`
-	Account     string `json:"account"`
-	AccountName string `json:"accountName"`
-	RealName    string `json:"realName"`
+	MainUserId  int `json:"mainUserId"`
+	Status      string `json:"status"`
 }

+ 3 - 5
model/account/settle_account_detail.go

@@ -64,9 +64,7 @@ type SearchUser struct {
 }
 
 type SettleAccountDetailReq struct {
-	PageNun     int    `json:"pageNum"`
-	PageSize    int    `json:"pageSize"`
-	Account     string `json:"account"`
-	AccountName string `json:"accountName"`
-	RealName    string `json:"realName"`
+	MainUserId  int `json:"mainUserId"`
+	AttachUserId int `json:"attachUserId"`
+	Pid int32 `json:"pid"`
 }

+ 6 - 4
model/account/settle_account_main.go

@@ -14,8 +14,10 @@ type SettleAccountMain internal2.SettleAccountMain
 // Fill with you ideas below.
 
 type SettleAccountMainReq struct {
-	PageNun     int    `json:"pageNum"`
-	PageSize    int    `json:"pageSize"`
-	AppointUserId int `orm:"AppointUserId"           json:"appoint_user_id"`
-	RelevanceId   int `orm:"RelevanceId"             json:"relevance_id"`
+	MainUserId  int `json:"mainUserId"`
+	AttachUserId int `json:"attachUserId"`
+	InstrumentId int `json:"instrumentId"`
+	Status      string `json:"status"`
+	SettleStatus      string `json:"settleStatus"`
+	FeeType   string `json:"feeType"`
 }

+ 6 - 6
service/account/account.go

@@ -43,12 +43,12 @@ func (s Service) SettleAccountList(req model.ListReq, info request.UserInfo) ([]
 	if req.Entity != nil {
 		entity := new(account.SettleAccountMainReq)
 		gconv.Struct(req.Entity, entity)
-		if strconv.Itoa(entity.AppointUserId) != "" {
-			entityModel = entityModel.WhereLike(s.Dao.Columns.AppointUserId, "%"+strconv.Itoa(entity.AppointUserId)+"%")
-		}
-		if strconv.Itoa(entity.RelevanceId) != "" {
-			entityModel = entityModel.WhereLike("RelevanceId", "%"+strconv.Itoa(entity.RelevanceId)+"%")
-		}
+		//if strconv.Itoa(entity.AppointUserId) != "" {
+		//	entityModel = entityModel.WhereLike(s.Dao.Columns.AppointUserId, "%"+strconv.Itoa(entity.AppointUserId)+"%")
+		//}
+		//if strconv.Itoa(entity.RelevanceId) != "" {
+		//	entityModel = entityModel.WhereLike("RelevanceId", "%"+strconv.Itoa(entity.RelevanceId)+"%")
+		//}
 	}
 	total, err := entityModel.Count()
 	if err != nil {

+ 64 - 0
service/settle_account_bill/settle_account_bill.go

@@ -0,0 +1,64 @@
+package settle_account_bill
+
+import (
+	"fmt"
+	"github.com/gogf/gf/util/gconv"
+	"lims_adapter/dao/account"
+	"lims_adapter/model"
+	accountModel "lims_adapter/model/account"
+)
+
+// Service 会议室服务
+type Service struct {
+	Dao    *account.SettleAccountBillDao
+	Tenant string
+}
+
+// NewSrv 服务初始化
+func NewService(tenant string) Service {
+	return Service{Dao: account.NewSettleAccountBillDao(tenant), Tenant: tenant}
+}
+
+// List 会议室列表
+func (s Service)  List(req model.ListReq) ([]accountModel.SettleAccountBill, int, error) {
+	entityModel := s.Dao.M
+	where := "1=1"
+
+	if req.Entity != nil {
+		entity := new(accountModel.SettleAccountBillReq)
+		err := gconv.Struct(req.Entity, entity)
+		if err != nil {
+			return nil, 0, err
+		}
+		if entity.MainUserId != 0 {
+			where += fmt.Sprintf(" AND MainUserId='%v'", entity.MainUserId)
+		}
+		if entity.Status != "" {
+			where += fmt.Sprintf(" AND Status='%v'", entity.Status)
+		}
+	}
+	entityModel = entityModel.Where(where)
+	total, err := entityModel.Count()
+	if err != nil {
+		return nil, 0, err
+	}
+	if total == 0 {
+		return nil, 0, nil
+	}
+
+	res, err := entityModel.Page(req.Current, req.Size).Order("settle_account_bill.CreateOn DESC").Fields("settle_account_bill.*").FindAll()
+	if err != nil {
+		return nil, 0, err
+	}
+	if res.IsEmpty() {
+		return nil, 0, nil
+	}
+
+	list := make([]accountModel.SettleAccountBill, 0)
+	err = res.Structs(&list)
+	if err != nil {
+		return nil, 0, err
+	}
+
+	return list, total, nil
+}

+ 59 - 0
service/settle_account_detail/settle_account_detail.go

@@ -0,0 +1,59 @@
+package settle_account_detail
+
+import (
+	"database/sql"
+	"fmt"
+	"github.com/gogf/gf/util/gconv"
+	"lims_adapter/dao/account"
+	"lims_adapter/model"
+	accountModel "lims_adapter/model/account"
+)
+
+// Service 会议室服务
+type Service struct {
+	Dao    *account.SettleAccountDetailDao
+	Tenant string
+}
+
+// NewSrv 服务初始化
+func NewService(tenant string) Service {
+	return Service{Dao: account.NewSettleAccountDetailDao(tenant), Tenant: tenant}
+}
+
+// List 获取数据列表
+func (s Service) List(req model.ListReq) ([]accountModel.SettleAccountDetail, error) {
+	entityModel := s.Dao.M
+	where := "1=1"
+
+	if req.Entity != nil {
+		entity := new(accountModel.SettleAccountDetailReq)
+		err := gconv.Struct(req.Entity, entity)
+		if err != nil {
+			return nil, err
+		}
+		if entity.MainUserId != 0 {
+			where += fmt.Sprintf(" AND MainUserId='%v'", entity.MainUserId)
+		}
+		if entity.AttachUserId != 0 {
+			where += fmt.Sprintf(" AND AttachUserId='%v'", entity.AttachUserId)
+		}
+		if entity.Pid != 0 {
+			where += fmt.Sprintf(" AND pid='%v'", entity.Pid)
+		}
+	}
+	entityModel = entityModel.Where(where)
+
+	res, err := entityModel.Fields("settle_account_detail.*").FindAll()
+	if err != nil {
+		return nil, err
+	}
+
+	list := make([]accountModel.SettleAccountDetail, 0)
+
+	err = res.Structs(&list)
+	if err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+
+	return list, nil
+}

+ 76 - 0
service/settle_account_main/settle_account_main.go

@@ -0,0 +1,76 @@
+package settle_account_main
+
+import (
+	"fmt"
+	"github.com/gogf/gf/util/gconv"
+	"lims_adapter/dao/account"
+	"lims_adapter/model"
+	accountModel "lims_adapter/model/account"
+)
+
+// Service 会议室服务
+type Service struct {
+	Dao    *account.SettleAccountMainDao
+	Tenant string
+}
+
+// NewSrv 服务初始化
+func NewService(tenant string) Service {
+	return Service{Dao: account.NewSettleAccountMainDao(tenant), Tenant: tenant}
+}
+
+// List 会议室列表
+func (s Service) List(req model.ListReq) ([]accountModel.SettleAccountMain, int, error) {
+	entityModel := s.Dao.M
+	where := "1=1"
+
+	if req.Entity != nil {
+		entity := new(accountModel.SettleAccountMainReq)
+		err := gconv.Struct(req.Entity, entity)
+		if err != nil {
+			return nil, 0, err
+		}
+		if entity.MainUserId != 0 {
+			where += fmt.Sprintf(" AND MainUserId='%v'", entity.MainUserId)
+		}
+		if entity.AttachUserId != 0 {
+			where += fmt.Sprintf(" AND AttachUserId='%v'", entity.AttachUserId)
+		}
+		if entity.InstrumentId != 0 {
+			where += fmt.Sprintf(" AND InstrumentId='%v'", entity.InstrumentId)
+		}
+		if entity.Status != "" {
+			where += fmt.Sprintf(" AND Status='%v'", entity.Status)
+		}
+		if entity.SettleStatus != "" {
+			where += fmt.Sprintf(" AND SettleStatus='%v'", entity.SettleStatus)
+		}
+		if entity.FeeType != "" {
+			where += fmt.Sprintf(" AND FeeType='%v'", entity.FeeType)
+		}
+	}
+	entityModel = entityModel.Where(where)
+	total, err := entityModel.Count()
+	if err != nil {
+		return nil, 0, err
+	}
+	if total == 0 {
+		return nil, 0, nil
+	}
+
+	res, err := entityModel.Page(req.Current, req.Size).Order("settle_account_main.CreateOn DESC").Fields("settle_account_main.*").FindAll()
+	if err != nil {
+		return nil, 0, err
+	}
+	if res.IsEmpty() {
+		return nil, 0, nil
+	}
+
+	list := make([]accountModel.SettleAccountMain, 0)
+	err = res.Structs(&list)
+	if err != nil {
+		return nil, 0, err
+	}
+
+	return list, total, nil
+}