package v1 import ( "fmt" "git.getensh.com/common/gopkgs/logger" "git.getensh.com/common/gopkgs/tasker/httptasker" "git.getensh.com/common/gopkgs/util" "github.com/gin-gonic/gin" "go.uber.org/zap" "google.golang.org/grpc/status" "net/http" "property-household-gateway/errors" param_v1 "property-household-gateway/param/v1" "property-household-gateway/pb" "property-household-gateway/pb/v1" "property-household-gateway/utils" "time" ) const ( ObjTypeHouse = 1 ObjTypeSpace = 2 ObjTypeVehicle = 3 ) const ( ChargeTypeProperty = 1 ChargeTypeWater = 2 ChargeTypeElectricity = 3 ChargeTypeGas = 4 ChargeTypeSpace = 5 ChargeTypeVehicle = 6 ChargeTypeOther = 99 ) // // @Summary 支付测试 // @Description 支付测试 // @Tags 支付测试 // @Accept json // @Produce json // @Param token header string true "token" // @Param body body v1.ChargeWxPayTestBody true " " // @Success 200 {object} v1.ChargeWxPayTestResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/pay_test [put] func (c *Controller) ChargeWxPayTest(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeWxPayTestRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeWxPayTestBody) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { tokenInfo, err := utils.GetJwtTokenInfo(ctx) if err != nil { return err } // 响应数据 resp := param_v1.ChargeWxPayTestResponse{} rpcReq := &v1.WxAppletPrepayRequest{ InputIp: ctx.ClientIP(), //HouseholdUid:tokenInfo.Uid, OpenId: tokenInfo.OpenId, Order: fmt.Sprintf("paytests%d", time.Now().Unix()), Product: "pay tests", Amount: req.PayAmount, MchId: "1628975670", } rpcRsp, err := pb.Thirdparty.WxAppletPrepay(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Thirdparty.WxAppletPrepay"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 欠费线上缴费 // @Description 欠费线上缴费 // @Tags 生活缴费 // @Accept json // @Produce json // @Param token header string true "token" // @Param body body v1.ChargeBillPayByHouseholdBody true " " // @Success 200 {object} v1.ChargeBillPayByHouseholdResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/pay [put] func (c *Controller) ChargeBillPayByHousehold(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeBillPayByHouseholdRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeBillPayByHouseholdBody) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { tokenInfo, err := utils.GetJwtTokenInfo(ctx) if err != nil { return err } // 响应数据 resp := param_v1.ChargeBillPayByHouseholdResponse{} rpcReq := &v1.ChargeBillPayByHouseholdRequest{ GardenId: req.GardenId, BindIds: req.BindIds, ShouldPayAmount: req.ShouldPayAmount, PayAmount: req.PayAmount, PayType: 6, Comment: req.Comment, InputIp: ctx.ClientIP(), HouseholdUid: tokenInfo.Uid, OpenId: tokenInfo.OpenId, BillIds: req.BillIds, } rpcRsp, err := pb.Garden.ChargeBillPayByHousehold(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeBillPayByHousehold"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 待缴费的费项列表 // @Description 待缴费的费项列表 // @Tags 生活缴费 // @Accept json // @Produce json // @Param token header string true "token" // @Param garden_id query int true "小区id" // @Param house_id query int true "房屋id" // @Param page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.ChargeUnpayListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/unpay_list [get] func (c *Controller) ChargeUnpayList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeUnpayListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeUnpayListQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetJwtTokenInfo(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ChargeUnpayListResponse{} rpcReq := &v1.ChargeUnpayListRequest{ GardenId: req.GardenId, PageSize: req.PageSize, Page: req.Page, HouseId: req.HouseId, Status: 1, } rpcRsp, err := pb.Garden.ChargeUnpayList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeUnpayList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeUnpayItem, 0) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 已缴费的账单列表 // @Description 已缴费的账单列表 // @Tags 生活缴费 // @Accept json // @Produce json // @Param token header string true "token" // @Param garden_id query int true "小区id" // @Param house_id query int true "房屋id" // @Param pay_time query int false "支付时间" // @Param page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.ChargeUnpayListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/payed_bill_list [get] func (c *Controller) ChargePayedBillList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargePayedBillListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargePayedBillListQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetJwtTokenInfo(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ChargePayedBillListResponse{} rpcReq := &v1.ChargePayedBillListRequest{ GardenId: req.GardenId, PageSize: req.PageSize, Page: req.Page, HouseId: req.HouseId, PayTime: req.PayTime, } rpcRsp, err := pb.Garden.ChargePayedBillList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargePayedBillList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargePayedBillItem, 0) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 待缴费某个费项的账单列表 // @Description 待缴费某个费项的账单列表 // @Tags 生活缴费 // @Accept json // @Produce json // @Param token header string true "token" // @Param garden_id query int true "小区id" // @Param bind_id query int true "绑定关系id" // @Param page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.ChargeBillListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/bill_list [get] func (c *Controller) ChargeBillList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeBillListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeBillListQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetSubjectValue(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ChargeBillListResponse{} rpcReq := &v1.ChargeBillListRequest{ GardenId: req.GardenId, PageSize: req.PageSize, Page: req.Page, BindId: req.BindId, Status: 1, } rpcRsp, err := pb.Garden.ChargeBillList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeBillList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeBillItem, 0) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // @Summary 未支付订单列表 // @Description 未支付订单列表 // @Tags 生活缴费 // @Accept json // @Produce json // @Param token header string true "token" // @Param page query int false " " // @Param page_size query int false " " // @Param garden_id query int true "小区id" // @Success 200 {object} v1.ChargeOrderListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/order/list [get] func (c *Controller) ChargeOrderList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeOrderListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeOrderListQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { tokenInfo, err := utils.GetJwtTokenInfo(ctx) if err != nil { return err } // 响应数据 resp := param_v1.ChargeOrderListResponse{} rpcReq := &v1.ChargeOrderListRequest{ GardenId: req.GardenId, PageSize: req.PageSize, Page: req.Page, PayStatus: 1, Uid: tokenInfo.Uid, } if tokenInfo.Uid == 0 { return errors.TokenFailedError } rpcRsp, err := pb.Garden.ChargeOrderList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeOrderList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeOrderItem, 0) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // @Summary 未支付订单的订单详情 // @Description 未支付订单的订单详情 // @Tags 生活缴费 // @Accept json // @Produce json // @Param token header string true "token" // @Param garden_id query int true "小区id" // @Param order_id query string true "订单详情" // @Success 200 {object} v1.ChargeOrderInfoResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/order/info [get] func (c *Controller) ChargeOrderInfo(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeOrderInfoRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeOrderInfoQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { // 响应数据 resp := param_v1.ChargeOrderInfoResponse{} rpcReq := &v1.ChargeOrderInfoRequest{ GardenId: req.GardenId, OrderId: req.OrderId, } rpcRsp, err := pb.Garden.ChargeOrderInfo(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeOrderInfo"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeOrderBillItem, 0) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // @Summary 预缴物业费前获取月数和赠送信息 // @Description 预缴物业费前获取月数和赠送信息 // @Tags 预缴 // @Accept json // @Produce json // @Param token header string true "token" // @Param garden_id query int true "小区id" // @Param house_id query int true "房屋id" // @Success 200 {object} v1.ChargePropertyMonthInfoResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/months/property [get] func (c *Controller) ChargePropertyMonthInfo(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargePropertyMonthInfoRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargePropertyMonthInfoQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetSubjectValue(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ChargePropertyMonthInfoResponse{} rpcReq := &v1.ChargeMonthInfoRequest{ GardenId: req.GardenId, ObjId: req.HouseId, ObjType: ObjTypeHouse, ChargeType: ChargeTypeProperty, } rpcRsp, err := pb.Garden.ChargeMonthInfo(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeMonthInfo"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // @Summary 预缴车位管理费前获取月数和赠送信息 // @Description 预缴车位管理前获取月数和赠送信息 // @Tags 预缴 // @Accept json // @Produce json // @Param token header string true "token" // @Param garden_id query int true "小区id" // @Param space_id query int true "车位id" // @Success 200 {object} v1.ChargeSpaceMonthInfoResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/months/space [get] func (c *Controller) ChargeSpaceMonthInfo(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeSpaceMonthInfoRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeSpaceMonthInfoQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetSubjectValue(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ChargeSpaceMonthInfoResponse{} rpcReq := &v1.ChargeMonthInfoRequest{ GardenId: req.GardenId, ObjId: req.SpaceId, ObjType: ObjTypeSpace, ChargeType: ChargeTypeSpace, } rpcRsp, err := pb.Garden.ChargeMonthInfo(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeMonthInfo"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // @Summary 预缴月租停车费前获取月数和赠送信息 // @Description 预缴月租停车费前获取月数和赠送信息 // @Tags 预缴 // @Accept json // @Produce json // @Param token header string true "token" // @Param garden_id query int true "小区id" // @Param vehicle_id query int true "车辆id" // @Success 200 {object} v1.ChargeVehicleMonthInfoResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/months/vehicle [get] func (c *Controller) ChargeVehicleMonthInfo(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeVehicleMonthInfoRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeVehicleMonthInfoQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetSubjectValue(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ChargeVehicleMonthInfoResponse{} rpcReq := &v1.ChargeMonthInfoRequest{ GardenId: req.GardenId, ObjId: req.VehicleId, ObjType: ObjTypeVehicle, ChargeType: ChargeTypeVehicle, } rpcRsp, err := pb.Garden.ChargeMonthInfo(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeMonthInfo"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // @Summary 预缴物业费或车位费前获取对应的金额信息 // @Description 预缴物业费或车位费前获取对应的金额信息 // @Tags 预缴 // @Accept json // @Produce json // @Param token header string true "token" // @Param garden_id query int true "小区id" // @Param bind_id query int true "关系id" // @Param months query int true "缴费月数" // @Success 200 {object} v1.ChargePrePayInfoResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/pre_pay_info [get] func (c *Controller) ChargePrePayInfo(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargePrePayInfoRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargePrePayInfoQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetSubjectValue(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ChargePrePayInfoResponse{} rpcReq := &v1.ChargePrePayInfoRequest{ GardenId: req.GardenId, BindId: req.BindId, Months: req.Months, } if req.BindId == 0 { return status.Error(10003, "没有绑定费用") } rpcRsp, err := pb.Garden.ChargePrePayInfo(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargePrePayInfo"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 线上预缴物业费、停车费 // @Description 线上预缴物业费、停车费 // @Tags 预缴 // @Accept json // @Produce json // @Param token header string true "token" // @Param body body v1.ChargePrePayByHouseholdBody true " " // @Success 200 {object} v1.ChargePrePayByHouseholdResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/pre_pay [put] func (c *Controller) ChargePrePayByHousehold(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargePrePayByHouseholdRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargePrePayByHouseholdBody) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { tokenInfo, err := utils.GetJwtTokenInfo(ctx) if err != nil { return err } // 响应数据 resp := param_v1.ChargePrePayByHouseholdResponse{} rpcReq := &v1.ChargePrePayByHouseholdRequest{ GardenId: req.GardenId, BindId: req.BindId, ShouldPayAmount: req.ShouldPayAmount, PayAmount: req.PayAmount, PayType: 6, Comment: "", Months: req.Months, InputIp: ctx.ClientIP(), OpenId: tokenInfo.OpenId, HouseholdUid: tokenInfo.Uid, PackageId: req.PackageId, } rpcRsp, err := pb.Garden.ChargePrePayByHousehold(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargePrePayByHousehold"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 取消支付 // @Description 取消支付 // @Tags 取消支付 // @Accept json // @Produce json // @Param token header string true "token" // @Param body body v1.ChargeOrderCancelBody true " " // @Success 200 {object} v1.ChargeOrderCancelResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/order/cancel [put] func (c *Controller) ChargeOrderCancel(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeOrderCancelRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeOrderCancelBody) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetJwtTokenInfo(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ChargeOrderCancelResponse{} rpcReq := &v1.ChargeOrderCancelRequest{ GardenId: req.GardenId, OrderId: req.OrderId, ByUser: req.ByUser, } _, err := pb.Garden.ChargeOrderCancel(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeOrderCancel"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 查看对象下的费项 // @Description 查看对象下的费项 // @Tags 预缴 // @Accept json // @Produce json // @Param token header string true "token" // @Param obj_id query int true "房屋/车位/车辆id" // @Param obj_type query int true "1 房屋 2 车位 3 车辆 " // @Param charge_type query int true "费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他" // @Param page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.ChargeListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/obj_charge/charge_list [get] func (c *Controller) ChargeList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeListQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { //tokenInfo, err := utils.GetSubjectValue(ctx) //if err != nil { // return err //} // 响应数据 resp := param_v1.ChargeListResponse{} rpcReq := &v1.ChargeListRequest{ GardenId: req.GardenId, PageSize: req.PageSize, Page: req.Page, ObjType: req.ObjType, ObjId: req.ObjId, ChargeType: req.ChargeType, } rpcRsp, err := pb.Garden.ChargeList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeItem, 0) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) }