123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962 |
- 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)
- }
|