123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package ctrl_v1
- import (
- "gd_management_gateway/errors"
- "gd_management_gateway/params/param_base"
- "gd_management_gateway/params/param_v1_0"
- "gd_management_gateway/rpc_apis"
- "gd_management_gateway/rpc_apis/gd_management"
- "fmt"
- "time"
- "gd_management_gateway/common.in/httper"
- "gd_management_gateway/common.in/task"
- "gd_management_gateway/common.in/utils"
- "github.com/astaxie/beego"
- "go.uber.org/zap"
- )
- // Operations about data api
- type AccountingController struct {
- metadata interface{} // 中继元数据
- beego.Controller
- LogID string
- }
- // @Title 获取账单列表
- // @Description 获取账单列表
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param page_number query int64 false "页号"
- // @Param merchant_id query int64 false "商户id"
- // @Param start_time query string false "开始时间"
- // @Param end_time query string false "结束时间"
- // @Success 200 {object} params.param_v1_0.BillListResp "响应信息"
- // @Failure 500 服务器错误
- // @router /bill_list [get]
- func (u *AccountingController) BillList() {
- u.LogID = fmt.Sprintf("BillList[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.BillListReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.BillListReq{}
- mreq.MerchantId = req.MerchantId
- mreq.PageNumber = req.PageNumber
- mreq.StartTime = req.StartTime
- mreq.EndTime = req.EndTime
- reply, err := rpc_apis.Management.BillList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "BillList"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.BillListResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = reply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 获取充值列表
- // @Description 获取充值列表
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param page_number query int64 false "页号"
- // @Param merchant_id query int64 false "商户id"
- // @Param start_time query string false "开始时间"
- // @Param end_time query string false "结束时间"
- // @Success 200 {object} params.param_v1_0.ChargeListResp "响应信息"
- // @Failure 500 服务器错误
- // @router /charge_list [get]
- func (u *AccountingController) ChargeList() {
- u.LogID = fmt.Sprintf("ChargeList[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.ChargeListReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.ChargeListReq{}
- mreq.MerchantId = req.MerchantId
- mreq.PageNumber = req.PageNumber
- mreq.StartTime = req.StartTime
- mreq.EndTime = req.EndTime
- reply, err := rpc_apis.Management.ChargeList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "ChargeList"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.ChargeListResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = reply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 获取消费列表
- // @Description 获取消费列表
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param page_number query int64 false "页号"
- // @Param merchant_id query int64 false "商户id"
- // @Param data_api_id query int64 false "数据api id"
- // @Param start_time query string false "开始时间"
- // @Param end_time query string false "结束时间"
- // @Param consume_order query int false "消费排序"
- // @Success 200 {object} params.param_v1_0.ConsumeListResp "响应信息"
- // @Failure 500 服务器错误
- // @router /consume_list [get]
- func (u *AccountingController) ConsumeList() {
- u.LogID = fmt.Sprintf("ConsumeList[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.ConsumeListReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.ConsumeListReq{}
- mreq.MerchantId = req.MerchantId
- mreq.PageNumber = req.PageNumber
- mreq.StartTime = req.StartTime
- mreq.EndTime = req.EndTime
- mreq.DataApiId = req.DataApiId
- mreq.ConsumeOrder = req.ConsumeOrder
- reply, err := rpc_apis.Management.ConsumeList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "ConsumeList"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.ConsumeListResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = reply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 消费趋势
- // @Description 消费趋势
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param merchant_id query int64 false "商户id"
- // @Param data_api_id query int64 false "数据api id"
- // @Param start_time query string false "开始时间"
- // @Param end_time query string false "结束时间"
- // @Success 200 {object} params.param_v1_0.ConsumeTrendListResp "响应信息"
- // @Failure 500 服务器错误
- // @router /consume_trend_list [get]
- func (u *AccountingController) ConsumeTrendList() {
- u.LogID = fmt.Sprintf("ConsumeTrendList[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.ConsumeTrendListReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.ConsumeTrendListReq{}
- mreq.MerchantId = req.MerchantId
- mreq.StartTime = req.StartTime
- mreq.EndTime = req.EndTime
- mreq.DataApiId = req.DataApiId
- reply, err := rpc_apis.Management.ConsumeTrendList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "ConsumeTrendList"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.ConsumeTrendListResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = reply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 商户数据api价格列表
- // @Description 商户数据api价格列表
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param merchant_id query int64 false "商户id"
- // @Success 200 {object} params.param_v1_0.MerchantDataApiPriceListResp "响应信息"
- // @Failure 500 服务器错误
- // @router /merchant_data_api_price_list [get]
- func (u *AccountingController) MerchantDataApiPriceList() {
- u.LogID = fmt.Sprintf("MerchantDataApiPriceList[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.MerchantDataApiPriceListReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.MerchantDataApiPriceListReq{}
- mreq.MerchantId = req.MerchantId
- reply, err := rpc_apis.Management.MerchantDataApiPriceList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "MerchantDataApiPriceList"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.MerchantDataApiPriceListResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = reply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 商户充值
- // @Description 商户充值
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param body body rpc_apis.gd_management.MerchantChargeReq true "参数"
- // @Success 200 {object} params.param_v1_0.MerchantChargeResp "响应信息"
- // @Failure 500 服务器错误
- // @router /merchant_charge [post]
- func (u *AccountingController) MerchantCharge() {
- u.LogID = fmt.Sprintf("MerchantCharge[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.MerchantChargeReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- // 加入行为日志
- /*AddActionLogTask := func() error {
- go func() {
- mreq := gd_management.ManagementDataApiGetQueryTypeReq{}
- mreq.QueryTypeId = req.Body.QueryTypeId
- reply, err := rpc_apis.Management.DataApiGetQueryType(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "DataApiGetQueryType"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return
- }
- // 构建json
- contentBytes, _ := json.Marshal(req.Body)
- areq := gd_admin.AddActionLogReq{
- Uid: req.Uid,
- Name: reply.QueryTypeInfo.QueryTypeName,
- Modules: "数据API",
- Func: "数据api添加基础api",
- Content: string(contentBytes),
- ModifyTime: time.Now().Format("2006-01-02 15:04:05"),
- }
- AddActionLog(areq)
- }()
- return nil
- }*/
- handleDataTask := func() error {
- userName := utils.GetUserNameFromToken(req.Token)
- req.Body.UserName = userName
- _, err := rpc_apis.Management.MerchantCharge(utils.NewContextFromBeegoCtx(u.Ctx), &req.Body)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "MerchantCharge"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.MerchantChargeResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 商户价格列表
- // @Description 商户价格()列表
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param merchant_id query int64 false "商户id"
- // @Param merchant_type_list query string false "商户类型列表"
- // @Param arrearage_order query int false "可欠费金额排序"
- // @Param page_number query int false "页号"
- // @Success 200 {object} params.param_v1_0.MerchantPriceListResp "响应信息"
- // @Failure 500 服务器错误
- // @router /merchant_price_list [get]
- func (u *AccountingController) MerchantPriceList() {
- u.LogID = fmt.Sprintf("MerchantPriceList[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.MerchantPriceListReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.MerchantPriceListReq{}
- mreq.MerchantId = req.MerchantId
- mreq.PageNumber = req.PageNumber
- mreq.ArrearageOrder = req.ArrearageOrder
- mreq.MerchantTypeList = req.MerchantTypeList
- reply, err := rpc_apis.Management.MerchantPriceList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "MerchantPriceList"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.MerchantPriceListResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = reply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 设置商户数据api单价
- // @Description 设置商户数据api单价
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param body body rpc_apis.gd_management.SetMerchantDataApiPriceReqReq true "参数"
- // @Success 200 {object} params.param_v1_0.SetMerchantDataApiPriceReqResp "响应信息"
- // @Failure 500 服务器错误
- // @router /merchant_data_api_price [put]
- func (u *AccountingController) SetMerchantDataApiPriceReq() {
- u.LogID = fmt.Sprintf("SetMerchantDataApiPriceReq[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.SetMerchantDataApiPriceReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- // 加入行为日志
- /*AddActionLogTask := func() error {
- go func() {
- mreq := gd_management.ManagementDataApiGetQueryTypeReq{}
- mreq.QueryTypeId = req.Body.QueryTypeId
- reply, err := rpc_apis.Management.DataApiGetQueryType(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "DataApiGetQueryType"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return
- }
- // 构建json
- contentBytes, _ := json.Marshal(req.Body)
- areq := gd_admin.AddActionLogReq{
- Uid: req.Uid,
- Name: reply.QueryTypeInfo.QueryTypeName,
- Modules: "数据API",
- Func: "数据api添加基础api",
- Content: string(contentBytes),
- ModifyTime: time.Now().Format("2006-01-02 15:04:05"),
- }
- AddActionLog(areq)
- }()
- return nil
- }*/
- handleDataTask := func() error {
- _, err := rpc_apis.Management.SetMerchantDataApiPrice(utils.NewContextFromBeegoCtx(u.Ctx), &req.Body)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "SetMerchantDataApiPrice"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.SetMerchantDataApiPriceResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 设置商户类型
- // @Description 设置商户类型
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param body body rpc_apis.gd_management.SetMerchantTypeReq true "参数"
- // @Success 200 {object} params.param_v1_0.SetMerchantTypeResp "响应信息"
- // @Failure 500 服务器错误
- // @router /merchant_type [put]
- func (u *AccountingController) SetMerchantType() {
- u.LogID = fmt.Sprintf("SetMerchantType[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.SetMerchantTypeReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- // 加入行为日志
- /*AddActionLogTask := func() error {
- go func() {
- mreq := gd_management.ManagementDataApiGetQueryTypeReq{}
- mreq.QueryTypeId = req.Body.QueryTypeId
- reply, err := rpc_apis.Management.DataApiGetQueryType(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "DataApiGetQueryType"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return
- }
- // 构建json
- contentBytes, _ := json.Marshal(req.Body)
- areq := gd_admin.AddActionLogReq{
- Uid: req.Uid,
- Name: reply.QueryTypeInfo.QueryTypeName,
- Modules: "数据API",
- Func: "数据api添加基础api",
- Content: string(contentBytes),
- ModifyTime: time.Now().Format("2006-01-02 15:04:05"),
- }
- AddActionLog(areq)
- }()
- return nil
- }*/
- handleDataTask := func() error {
- _, err := rpc_apis.Management.SetMerchantType(utils.NewContextFromBeegoCtx(u.Ctx), &req.Body)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "SetMerchantType"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.SetMerchantTypeResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 账单详情列表
- // @Description 商户价格()列表
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param merchant_id query int64 true "商户id"
- // @Param bill_id query int64 true "账单id"
- // @Param month query string true "月份(2022-02)"
- // @Success 200 {object} params.param_v1_0.BillDetailListResp "响应信息"
- // @Failure 500 服务器错误
- // @router /bill_detail_list [get]
- func (u *AccountingController) BillDetailList() {
- u.LogID = fmt.Sprintf("BillDetailList[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.BillDetailListReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.BillDetailListReq{}
- mreq.MerchantId = req.MerchantId
- mreq.Month = req.Month
- mreq.BillId = req.BillId
- reply, err := rpc_apis.Management.BillDetailList(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "BillDetailList"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.BillDetailListResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = reply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 更新账单详情(设置计费量)
- // @Description 更新账单详情(设置计费量)
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param body body rpc_apis.gd_management.UpdateBillDetailReq true "参数"
- // @Success 200 {object} params.param_v1_0.UpdateBillDetailResp "响应信息"
- // @Failure 500 服务器错误
- // @router /bill_detail [put]
- func (u *AccountingController) UpdateBillDetail() {
- u.LogID = fmt.Sprintf("UpdateBillDetail[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.UpdateBillDetailReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- // 加入行为日志
- /*AddActionLogTask := func() error {
- go func() {
- mreq := gd_management.ManagementDataApiGetQueryTypeReq{}
- mreq.QueryTypeId = req.Body.QueryTypeId
- reply, err := rpc_apis.Management.DataApiGetQueryType(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "DataApiGetQueryType"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return
- }
- // 构建json
- contentBytes, _ := json.Marshal(req.Body)
- areq := gd_admin.AddActionLogReq{
- Uid: req.Uid,
- Name: reply.QueryTypeInfo.QueryTypeName,
- Modules: "数据API",
- Func: "数据api添加基础api",
- Content: string(contentBytes),
- ModifyTime: time.Now().Format("2006-01-02 15:04:05"),
- }
- AddActionLog(areq)
- }()
- return nil
- }*/
- handleDataTask := func() error {
- userName := utils.GetUserNameFromToken(req.Token)
- req.Body.UserName = userName
- _, err := rpc_apis.Management.UpdateBillDetail(utils.NewContextFromBeegoCtx(u.Ctx), &req.Body)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "UpdateBillDetail"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.UpdateBillDetailResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 添加账单备注
- // @Description 添加账单备注
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param body body rpc_apis.gd_management.BillRemarkReq true "参数"
- // @Success 200 {object} params.param_v1_0.BillRemarkResp "响应信息"
- // @Failure 500 服务器错误
- // @router /bill_remark [put]
- func (u *AccountingController) BillRemark() {
- u.LogID = fmt.Sprintf("UpdateBillDetail[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.BillRemarkReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- // 加入行为日志
- /*AddActionLogTask := func() error {
- go func() {
- mreq := gd_management.ManagementDataApiGetQueryTypeReq{}
- mreq.QueryTypeId = req.Body.QueryTypeId
- reply, err := rpc_apis.Management.DataApiGetQueryType(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "DataApiGetQueryType"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return
- }
- // 构建json
- contentBytes, _ := json.Marshal(req.Body)
- areq := gd_admin.AddActionLogReq{
- Uid: req.Uid,
- Name: reply.QueryTypeInfo.QueryTypeName,
- Modules: "数据API",
- Func: "数据api添加基础api",
- Content: string(contentBytes),
- ModifyTime: time.Now().Format("2006-01-02 15:04:05"),
- }
- AddActionLog(areq)
- }()
- return nil
- }*/
- handleDataTask := func() error {
- _, err := rpc_apis.Management.BillRemark(utils.NewContextFromBeegoCtx(u.Ctx), &req.Body)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "BillRemark"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.BillRemarkResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 生成账单
- // @Description 生成账单
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param month query int64 false "页号"
- // @Success 200 {object} params.param_v1_0.BillListResp "响应信息"
- // @Failure 500 服务器错误
- // @router /generate_bill [get]
- func (u *AccountingController) GenerateBill() {
- u.LogID = fmt.Sprintf("GenerateBill[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.GenerateBillReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.GenerateBillReq{}
- mreq.Month = req.Month
- reply, err := rpc_apis.Management.GenerateBill(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "GenerateBill"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.GenerateBillResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = reply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
- // @Title 账单导出Excel
- // @Description 账单导出Excel
- // @Param token header string true "token"
- // @Param uid header int64 true "admin id"
- // @Param merchant_id query int64 true "商户id"
- // @Param bill_id query int64 true "账单id"
- // @Param month query string true "月份(2022-02)"
- // @Success 200 {object} params.param_v1_0.BillExportExcelResp "响应信息"
- // @Failure 500 服务器错误
- // @router /bill_export_excel [get]
- func (u *AccountingController) BillExportExcel() {
- u.LogID = fmt.Sprintf("BillExportExcel[%d]", time.Now().UnixNano())
- req := ¶m_v1_0.BillExportExcelReq{}
- getParamsTask := func() error {
- httper.FillRequireParams(u.Ctx, req, u.LogID)
- return nil
- }
- handleDataTask := func() error {
- mreq := gd_management.BillExportExcelReq{}
- mreq.MerchantId = req.MerchantId
- mreq.Month = req.Month
- mreq.BillId = req.BillId
- reply, err := rpc_apis.Management.BillExportExcel(utils.NewContextFromBeegoCtx(u.Ctx), &mreq)
- if err != nil {
- l.Error("rpc",
- zap.String("call", "BillExportExcel"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- return errors.ErrorTransform(err)
- }
- resp := param_v1_0.BillExportExcelResp{
- SimpleResp: param_base.SimpleResp{
- Code: 0,
- Msg: "SUCCESS",
- },
- }
- resp.Data = reply
- httper.JSON(u.Ctx, resp, u.LogID)
- return nil
- }
- // 执行以上定义的任务
- task.Do(&task.PanicRecover{
- Ctx: u.Ctx,
- LogID: u.LogID}, u.Ctx,
- getParamsTask, handleDataTask,
- )
- }
|