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" "github.com/tealeg/xlsx" "go.uber.org/zap" "google.golang.org/grpc/status" "net/http" "os" "path" "property-system-gateway/errors" param_v1 "property-system-gateway/param/v1" "property-system-gateway/parser" "property-system-gateway/pb" "property-system-gateway/pb/v1" "property-system-gateway/utils" "strconv" "strings" "time" ) func parseTime(data *xlsx.Cell) (int64, bool) { t, err := data.GetTime(false) if err != nil { return 0, false } return t.Add(-8 * time.Hour).Unix(), true } func parsePowerRecordContent(fileName string) ([]*v1.PowerRecordBatchData, error) { f, err := xlsx.OpenFile(fileName) if err != nil { return nil, status.Error(10003, "xlsx 打开失败") } if len(f.Sheets) == 0 { return nil, status.Error(10003, "参数文件没有sheet") } sheet := f.Sheets[0] if len(sheet.Rows) == 0 { return nil, status.Error(10003, "文件为空") } if len(sheet.Rows) > 1005 { return nil, status.Error(10003, "单次导入不能超过一千条记录, 请分批导入") } list := []*v1.PowerRecordBatchData{} for i, row := range sheet.Rows { if i == 0 { // 第1行是注释行 continue } if len(row.Cells) < 7 { return nil, status.Error(10003, fmt.Sprintf("第%d行", i)+"列数错误,请使用模板") } if i == 1 { if row.Cells[0].Value != "楼栋编号" || row.Cells[1].Value != "单元编号" || row.Cells[2].Value != "房屋门牌号" || row.Cells[3].Value != "开始时间" || row.Cells[4].Value != "结束时间" || row.Cells[5].Value != "上次抄表用量" || row.Cells[6].Value != "本次抄表用量" { return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"标题错误,请使用模板") } continue } buidingNumber := strings.TrimSpace(row.Cells[0].Value) unitNumberStr := strings.TrimSpace(row.Cells[1].Value) houseNumber := strings.TrimSpace(row.Cells[2].Value) lastAmountStr := strings.TrimSpace(row.Cells[5].Value) currentAmountStr := strings.TrimSpace(row.Cells[6].Value) startStr := strings.TrimSpace(row.Cells[3].Value) endStr := strings.TrimSpace(row.Cells[4].Value) if buidingNumber == "" && unitNumberStr == "" && houseNumber == "" && lastAmountStr == "" && currentAmountStr == "" && startStr == "" && endStr == "" { continue } if buidingNumber == "" || unitNumberStr == "" || houseNumber == "" || lastAmountStr == "" || currentAmountStr == "" || startStr == "" || endStr == "" { return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"参数不能为空") } unitNumber, err := strconv.Atoi(unitNumberStr) if err != nil { return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"单元格式错误") } lastAmount, err := strconv.ParseFloat(lastAmountStr, 64) if err != nil { return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"上次抄表用量格式错误") } currentAmount, err := strconv.ParseFloat(currentAmountStr, 64) if err != nil { return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"本次抄表用量格式错误") } if currentAmount < lastAmount { return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"本次抄表用量不能小于上次抄表用量") } start, ok := parseTime(row.Cells[3]) if !ok { return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"开始时间错误") } end, ok := parseTime(row.Cells[4]) if !ok { return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"结束时间错误") } if end <= start { return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"结束时间必须晚于开始时间") } item := &v1.PowerRecordBatchData{ Start: start, End: end, LastAmount: lastAmount, CurrentAmount: currentAmount, BuildingNumber: buidingNumber, UnitNumber: int64(unitNumber), HouseNumber: houseNumber, } list = append(list, item) } return list, nil } // // @Summary 批量抄表 // @Description 批量抄表 // @Tags 抄表 // @Accept json // @Produce json // @Param token header string true "jwt token" // @Param charge_type query int32 true "费用类型 2 水费 3 电费 4 气费" // @Param file formData file true "file" // @Success 200 {object} v1.PowerRecordBatchAddResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/power/batch [post] func (c Controller) PowerRecordBatchAdd(ctx *gin.Context) { // 解析参数 req := ¶m_v1.PowerRecordBatchAddRequest{} newFile := "" var tokenInfo utils.TokenInfo parseParamTask := func() error { var err error tokenInfo, err = utils.GetSubjectValue(ctx) if err != nil { return err } err = util.ShouldBind(ctx, &req.Header, nil, &req.PowerRecordBatchAddQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } file, err := ctx.FormFile("file") if err != nil { return errors.SystemError } if file.Size > 10*1024*1024 { return status.Error(10003, "文件过大") } ext := path.Ext(file.Filename) if ext != ".xlsx" { return status.Error(10003, "仅支持xlsx文件格式") } newFile = fmt.Sprintf("power-%s-%d-%d.xlsx", file.Filename, tokenInfo.Uid, time.Now().UnixNano()) err = ctx.SaveUploadedFile(file, newFile) if err != nil { logger.Error("func", zap.String("call", "ctx.SaveUploadedFile"), zap.String("error", err.Error())) return status.Error(10003, "保存文件失败") } return nil } // 业务处理 handleServiceTask := func() error { list, err := parsePowerRecordContent(newFile) if err != nil { os.Remove(newFile) return err } os.Remove(newFile) // 响应数据 resp := param_v1.PowerRecordBatchAddResponse{} rpcReq := &v1.PowerRecordBatchAddRequest{ GardenId: tokenInfo.GardenId, ChargeType: req.ChargeType, List: list, } _, err = pb.Garden.PowerRecordBatchAdd(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.PowerRecordBatchAdd"), 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 body body v1.ChargeConfAddBody true "信息" // @Success 200 {object} v1.ChargeConfAddResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/conf [post] func (c *Controller) ChargeConfAdd(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeConfAddRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeConfAddBody) 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.ChargeConfAddResponse{} rpcReq := &v1.ChargeConfAddRequest{ GardenId: tokenInfo.GardenId, // 费用类型1 物业费 2 水费 3 电费 4 气费 ChargeType: req.ChargeType, // 费用名称 ChargeName: req.ChargeName, // 缴费时间类型 1 周期性缴 2 一次性 ChargeTimeType: req.ChargeTimeType, // 1 按房屋面积 2 按使用面积 3 固定费用 4 按使用量 5 固定费用 ChargeBasis: req.ChargeBasis, // 固定费用 FixAmount: req.FixAmount, // 固定费用别名 FixAmountName: req.FixAmountName, // 单价 UnitPrice: req.UnitPrice, LateFeeEnable: req.LateFeeEnable, LateFeePercent: req.LateFeePercent, LateFeeDay: req.LateFeeDay, // 账单生成周期 1 按月 2 按季度 3 半年 4 年 BillPeriod: req.BillPeriod, // 账单周期计算方式 1自然周期 2 费用生效时间 BillPeriodType: req.BillPeriodType, ChargeEffectiveTime: req.ChargeEffectiveTime, } rpcRsp, err := pb.Garden.ChargeConfAdd(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeConfAdd"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module: ModuleCharge, Action: ActionChargeConfAdd, Origin: nil, Target: req.ChargeConfAddBody, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 修改费用配置 // @Description 修改费用配置 // @Tags 费用配置 // @Accept json // @Produce json // @Param token header string true "token" // @Param body body v1.ChargeConfUpdateBody true "信息" // @Success 200 {object} v1.ChargeConfUpdateResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/conf [put] func (c *Controller) ChargeConfUpdate(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeConfUpdateRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeConfUpdateBody) 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.ChargeConfUpdateResponse{} rpcReq := &v1.ChargeConfUpdateRequest{ GardenId: tokenInfo.GardenId, // 费用类型1 物业费 2 水费 3 电费 4 气费 ChargeType: req.ChargeType, // 费用名称 ChargeName: req.ChargeName, // 缴费时间类型 1 周期性缴 2 一次性 ChargeTimeType: req.ChargeTimeType, // 1 按房屋面积 2 按使用面积 3 固定费用 4 按使用量 5 固定费用 ChargeBasis: req.ChargeBasis, // 固定费用 FixAmount: req.FixAmount, // 固定费用别名 FixAmountName: req.FixAmountName, // 单价 UnitPrice: req.UnitPrice, LateFeeEnable: req.LateFeeEnable, LateFeePercent: req.LateFeePercent, LateFeeDay: req.LateFeeDay, // 账单生成周期 1 按月 2 按季度 3 半年 4 年 BillPeriod: req.BillPeriod, // 账单周期计算方式 1自然周期 2 费用生效时间 BillPeriodType: req.BillPeriodType, ChargeEffectiveTime: req.ChargeEffectiveTime, Id: req.Id, } rpcRsp, err := pb.Garden.ChargeConfUpdate(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeConfUpdate"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module: ModuleCharge, Action: ActionChargeConfUpdate, Origin: rpcRsp.Origin, Target: req.ChargeConfUpdateBody, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 删除费用配置 // @Description 删除费用配置 // @Tags 费用配置 // @Accept json // @Produce json // @Param id query int true " " // @Param token header string true "token" // @Success 200 {object} v1.ChargeConfDelResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/conf [delete] func (c *Controller) ChargeConfDel(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeConfDelRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeConfDelQuery, 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.ChargeConfDelResponse{} rpcReq := &v1.ChargeConfDelRequest{ GardenId: tokenInfo.GardenId, Id: req.Id, } rpcRsp, err := pb.Garden.ChargeConfDel(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeConfDel"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module: ModuleCharge, Action: ActionChargeConfDel, Origin: rpcRsp.Origin, Target: nil, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 费用配置列表 // @Description 费用配置列表 // @Tags 费用配置 // @Accept json // @Produce json // @Param page query int false " " // @Param page_size query int false " " // @Param charge_type query int false "费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他" // @Param token header string true "token" // @Success 200 {object} v1.ChargeConfListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/conf [get] func (c *Controller) ChargeConfList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeConfListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeConfListQuery, 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.ChargeConfListResponse{} rpcReq := &v1.ChargeConfListRequest{ GardenId: tokenInfo.GardenId, ChargeName: req.ChargeName, ChargeType: req.ChargeType, Page: req.Page, PageSize: req.PageSize, } rpcRsp, err := pb.Garden.ChargeConfList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeConfList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeConfItem, 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 body body v1.PowerRecordAddBody true "信息" // @Success 200 {object} v1.PowerRecordAddResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/power [post] func (c *Controller) PowerRecordAdd(ctx *gin.Context) { // 解析参数 req := ¶m_v1.PowerRecordAddRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.PowerRecordAddBody) 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.PowerRecordAddResponse{} rpcReq := &v1.PowerRecordAddRequest{ GardenId: tokenInfo.GardenId, LastAmount: req.LastAmount, CurrentAmount: req.CurrentAmount, Start: req.Start, End: req.End, Comment: req.Comment, HouseId: req.HouseId, ChargeType: req.ChargeType, } rpcRsp, err := pb.Garden.PowerRecordAdd(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.PowerRecordAdd"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module: ModuleCharge, Action: ActionChargePowerRecordAdd, Origin: nil, Target: req.PowerRecordAddBody, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 获取抄表模板 // @Description 获取抄表模板 // @Tags 抄表 // @Accept json // @Produce json // @Param token header string true "token" // @Success 200 {object} v1.TemplateResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/power/template [get] func (c *Controller) ChargePowerTemplate(ctx *gin.Context) { // 解析参数 req := ¶m_v1.TemplateRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, 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.TemplateResponse{} resp.Data.Url = parser.Conf.Oss.PowerTempUrl ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 删除抄表记录 // @Description 删除抄表记录 // @Tags 抄表 // @Accept json // @Produce json // @Param id query int true " " // @Param token header string true "token" // @Success 200 {object} v1.PowerRecordDelResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/power [delete] func (c *Controller) PowerRecordDel(ctx *gin.Context) { // 解析参数 req := ¶m_v1.PowerRecordDelRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.PowerRecordDelQuery, 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.PowerRecordDelResponse{} rpcReq := &v1.PowerRecordDelRequest{ GardenId: tokenInfo.GardenId, Id: req.Id, } rpcRsp, err := pb.Garden.PowerRecordDel(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.PowerRecordDel"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module: ModuleCharge, Action: ActionChargePowerRecordDel, Origin: rpcRsp.Origin, Target: nil, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 抄表列表 // @Description 抄表列表 // @Tags 抄表 // @Accept json // @Produce json // @Param page query int false " " // @Param page_size query int false " " // @Param charge_type query int false "费用类型 2 水费 3 电费 4 气费 " // @Param token header string true "token" // @Success 200 {object} v1.PowerRecordListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/power [get] func (c *Controller) PowerRecordList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.PowerRecordListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.PowerRecordListQuery, 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.PowerRecordListResponse{} rpcReq := &v1.PowerRecordListRequest{ GardenId: tokenInfo.GardenId, ChargeType: req.ChargeType, Page: req.Page, PageSize: req.PageSize, HouseId: req.HouseId, } rpcRsp, err := pb.Garden.PowerRecordList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.PowerRecordList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.PowerRecordItem, 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 body body v1.ChargeBindBody true "信息" // @Success 200 {object} v1.ChargeBindResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/bind [put] func (c *Controller) ChargeBind(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeBindRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeBindBody) 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.ChargeBindResponse{} rpcReq := &v1.ChargeBindRequest{ GardenId: tokenInfo.GardenId, Start: req.Start, End: req.End, ObjIds: req.ObjIds, ChargeId: req.ChargeId, VehicleFee: req.CustomFee, } _, err = pb.Garden.ChargeBind(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeBind"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module: ModuleCharge, Action: ActionChargeBind, Origin: nil, Target: req.ChargeBindBody, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 费用解绑对象 // @Description 费用解绑对象 // @Tags 费用绑定相关 // @Accept json // @Produce json // @Param token header string true "token" // @Param body body v1.ChargeUnbindBody true "信息" // @Success 200 {object} v1.ChargeUnbindResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/unbind [put] func (c *Controller) ChargeUnbind(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeUnbindRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeUnbindBody) 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.ChargeUnbindResponse{} rpcReq := &v1.ChargeUnbindRequest{ GardenId: tokenInfo.GardenId, ObjId: req.ObjId, ChargeId: req.ChargeId, } _, err = pb.Garden.ChargeUnbind(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeUnbind"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module: ModuleCharge, Action: ActionChargeUnbind, Origin: nil, Target: req.ChargeUnbindBody, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 绑定了项目的房屋列表 // @Description 绑定了项目的房屋列表 // @Tags 费用绑定相关 // @Accept json // @Produce json // @Param token header string true "token" // @Param charge_id query int true "费项id" // @Param page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.ChargeHouseBindedListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/house/binded_list [get] func (c *Controller) ChargeHouseBindedList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeHouseBindedListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeHouseBindedListQuery, 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.ChargeHouseBindedListResponse{} rpcReq := &v1.ChargeHouseBindedListRequest{ GardenId: tokenInfo.GardenId, ChargeId: req.ChargeId, PageSize: req.PageSize, Page: req.Page, } rpcRsp, err := pb.Garden.ChargeHouseBindedList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeHouseBindedList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeHouseData, 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 charge_id query int true "费项id" // @Param page query int false " " // @Param page_size query int false " " // @Param house_name query string false "房号1-2-906" // @Success 200 {object} v1.ChargeHouseNotBindListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/house/can_bind_list [get] func (c *Controller) ChargeHouseNotBindList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeHouseNotBindListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeHouseNotBindListQuery, 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.ChargeHouseNotBindListResponse{} resp.Data = v1.ChargeHouseNotBindListReply{ Page: 1, Total: 0, List: make([]*v1.ChargeHouseData, 0), } buildingId, unitId := int64(0), int64(0) houseNumber := "" if req.HouseName != "" { shouldReturn := false var err error buildingId, unitId, houseNumber, shouldReturn, err = handleHouseName(ctx, req.HouseName, tokenInfo) if err != nil { return err } if shouldReturn { ctx.JSON(http.StatusOK, resp) return nil } } // 响应数据 rpcReq := &v1.ChargeHouseNotBindListRequest{ GardenId: tokenInfo.GardenId, ChargeId: req.ChargeId, PageSize: req.PageSize, Page: req.Page, BuildingId: buildingId, HouseNumber: houseNumber, UnitId: unitId, } rpcRsp, err := pb.Garden.ChargeHouseNotBindList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeHouseNotBindList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeHouseData, 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 charge_id query int true "费项id" // @Param page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.ChargeSpaceBindedListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/space/binded_list [get] func (c *Controller) ChargeSpaceBindedList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeSpaceBindedListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeSpaceBindedListQuery, 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.ChargeSpaceBindedListResponse{} rpcReq := &v1.ChargeSpaceBindedListRequest{ GardenId: tokenInfo.GardenId, ChargeId: req.ChargeId, PageSize: req.PageSize, Page: req.Page, } rpcRsp, err := pb.Garden.ChargeSpaceBindedList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeSpaceBindedList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeSpaceData, 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 charge_id query int true "费项id" // @Param page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.ChargeSpaceNotBindListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/space/can_bind_list [get] func (c *Controller) ChargeSpaceNotBindList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeSpaceNotBindListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeSpaceNotBindListQuery, 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.ChargeSpaceNotBindListResponse{} rpcReq := &v1.ChargeSpaceNotBindListRequest{ GardenId: tokenInfo.GardenId, ChargeId: req.ChargeId, PageSize: req.PageSize, Page: req.Page, } rpcRsp, err := pb.Garden.ChargeSpaceNotBindList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeSpaceNotBindList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeSpaceData, 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 charge_id query int true "费项id" // @Param page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.ChargeVehicleBindedListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/vehicle/binded_list [get] func (c *Controller) ChargeVehicleBindedList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeVehicleBindedListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeVehicleBindedListQuery, 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.ChargeVehicleBindedListResponse{} rpcReq := &v1.ChargeVehicleBindedListRequest{ GardenId: tokenInfo.GardenId, ChargeId: req.ChargeId, PageSize: req.PageSize, Page: req.Page, } rpcRsp, err := pb.Garden.ChargeVehicleBindedList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeVehicleBindedList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeVehicleData, 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 charge_id query int true "费项id" // @Param page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.ChargeVehicleNotBindListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/vehicle/can_bind_list [get] func (c *Controller) ChargeVehicleNotBindList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeVehicleNotBindListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeVehicleNotBindListQuery, 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.ChargeVehicleNotBindListResponse{} rpcReq := &v1.ChargeVehicleNotBindListRequest{ GardenId: tokenInfo.GardenId, ChargeId: req.ChargeId, PageSize: req.PageSize, Page: req.Page, } rpcRsp, err := pb.Garden.ChargeVehicleNotBindList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeVehicleNotBindList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeVehicleData, 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 " " // @Success 200 {object} v1.ChargeHouseGroupResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/obj_charge/house_list [get] func (c *Controller) ChargeHouseGroup(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeHouseGroupRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeHouseGroupQuery, 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.ChargeHouseGroupResponse{} rpcReq := &v1.ChargeHouseGroupRequest{ GardenId: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, } rpcRsp, err := pb.Garden.ChargeHouseGroup(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeHouseGroup"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeHouseGroupItem, 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 obj_type query int true "1 房屋 2 车位" // @Success 200 {object} v1.BatchUrgeResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/batch_urge [get] func (c *Controller) BatchUrge(ctx *gin.Context) { // 解析参数 req := ¶m_v1.BatchUrgeRequest{} list := []param_v1.BatchUrgeItem{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.BatchUrgeQuery, 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 } if req.ObjType == 1 { rpcReq := &v1.ChargeHouseGroupRequest{ GardenId: tokenInfo.GardenId, Page: -1, PageSize: -1, } rpcRsp, err := pb.Garden.ChargeHouseGroup(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeHouseGroup"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } for _, v := range rpcRsp.List { if !v.HasUnpayBill { continue } mreq := &v1.ChargeUnpayListRequest{ GardenId: tokenInfo.GardenId, PageSize: -1, Page: -1, ObjType: req.ObjType, ObjId: v.HouseId, } mreply, err := pb.Garden.ChargeUnpayList(ctx, mreq) 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) } fees := []param_v1.BatchUrgeFeeItem{} for _, bill := range mreply.List { item := param_v1.BatchUrgeFeeItem{ ChargeName: bill.ChargeName, ChargeType: bill.ChargeType, Fee: bill.UnpayAmount, } fees = append(fees, item) } item := param_v1.BatchUrgeItem{ ObjName: fmt.Sprintf("%d 房屋", v.HouseName), List: fees, } list = append(list, item) } } else if req.ObjType == 2 { rpcReq := &v1.ChargeSpaceGroupRequest{ GardenId: tokenInfo.GardenId, Page: -1, PageSize: -1, } rpcRsp, err := pb.Garden.ChargeSpaceGroup(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeSpaceGroup"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } for _, v := range rpcRsp.List { if !v.HasUnpayBill { continue } mreq := &v1.ChargeUnpayListRequest{ GardenId: tokenInfo.GardenId, PageSize: -1, Page: -1, ObjType: req.ObjType, ObjId: v.SpaceId, } mreply, err := pb.Garden.ChargeUnpayList(ctx, mreq) 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) } fees := []param_v1.BatchUrgeFeeItem{} for _, bill := range mreply.List { item := param_v1.BatchUrgeFeeItem{ ChargeName: bill.ChargeName, ChargeType: bill.ChargeType, Fee: bill.UnpayAmount, } fees = append(fees, item) } item := param_v1.BatchUrgeItem{ ObjName: fmt.Sprintf("%d 车位", v.SpaceNumber), List: fees, } list = append(list, item) } } else { return errors.ParamsError } resp := param_v1.BatchUrgeResponse{} resp.Data = param_v1.BatchUrgeData{List: list} 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 " " // @Success 200 {object} v1.ChargeSpaceGroupResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/obj_charge/space_list [get] func (c *Controller) ChargeSpaceGroup(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeSpaceGroupRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeSpaceGroupQuery, 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.ChargeSpaceGroupResponse{} rpcReq := &v1.ChargeSpaceGroupRequest{ GardenId: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, } rpcRsp, err := pb.Garden.ChargeSpaceGroup(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeSpaceGroup"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeSpaceGroupItem, 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 " " // @Success 200 {object} v1.ChargeVehicleGroupResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/obj_charge/vehicle_list [get] func (c *Controller) ChargeVehicleGroup(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeVehicleGroupRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeVehicleGroupQuery, 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.ChargeVehicleGroupResponse{} rpcReq := &v1.ChargeVehicleGroupRequest{ GardenId: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, } rpcRsp, err := pb.Garden.ChargeVehicleGroup(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeVehicleGroup"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeVehicleGroupItem, 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 body body v1.ChargeBillPayBody true " " // @Success 200 {object} v1.ChargeBillPayResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/obj_charge/pay [put] func (c *Controller) ChargeBillPay(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeBillPayRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeBillPayBody) 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.ChargeBillPayResponse{} rpcReq := &v1.ChargeBillPayRequest{ GardenId: tokenInfo.GardenId, BindIds: req.BindIds, ShouldPayAmount: req.ShouldPayAmount, PayAmount: req.PayAmount, PayType: req.PayType, Comment: req.Comment, } rpcRsp, err := pb.Garden.ChargeBillPay(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeBillPay"), 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 obj_id query int true "房屋/车位/车辆id" // @Param obj_type query int true "1 房屋 2 车位 3 车辆 " // @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/obj_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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.ChargeUnpayListResponse{} rpcReq := &v1.ChargeUnpayListRequest{ GardenId: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, ObjType: req.ObjType, ObjId: req.ObjId, } 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 obj_id query int true "房屋/车位/车辆id" // @Param obj_type query int true "1 房屋 2 车位 3 车辆 " // @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: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, ObjType: req.ObjType, ObjId: req.ObjId, } 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) } // // @Summary 对象的某费项下的待缴账单列表 // @Description 对象的某费项下的待缴账单列表 // @Tags 对象收费相关 // @Accept json // @Produce json // @Param token header string true "token" // @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/obj_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: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, BindId: req.BindId, } 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 body body v1.ChargeGenerateBillBody true " " // @Success 200 {object} v1.ChargeGenerateBillResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/obj_charge/bill [put] func (c *Controller) ChargeGenerateBill(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeGenerateBillRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeGenerateBillBody) 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.ChargeGenerateBillResponse{} rpcReq := &v1.ChargeGenerateBillRequest{ GardenId: tokenInfo.GardenId, End: req.End, BindId: req.BindId, } _, err = pb.Garden.ChargeGenerateBill(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeGenerateBill"), 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 body body v1.ChargeTimeSetBody true " " // @Success 200 {object} v1.ChargeTimeSetResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/obj_charge/time [put] func (c *Controller) ChargeTimeSet(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeTimeSetRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeTimeSetBody) 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.ChargeTimeSetResponse{} rpcReq := &v1.ChargeTimeSetRequest{ GardenId: tokenInfo.GardenId, Start: req.Start, End: req.End, BindId: req.BindId, } _, err = pb.Garden.ChargeTimeSet(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeTimeSet"), 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 order_id query string true "订单号 " // @Success 200 {object} v1.ChargeOrderTicketResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/obj_charge/ticket [get] func (c *Controller) ChargeOrderTicket(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeOrderTicketRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeOrderTicketQuery, 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.ChargeOrderTicketResponse{} rpcReq := &v1.ChargeOrderTicketRequest{ GardenId: tokenInfo.GardenId, OrderId: req.OrderId, } rpcRsp, err := pb.Garden.ChargeOrderTicket(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeOrderTicket"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeOrderTicketItem, 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 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/obj_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: tokenInfo.GardenId, BindId: req.BindId, Months: req.Months, } 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.ChargePrePayBody true " " // @Success 200 {object} v1.ChargePrePayResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/obj_charge/pre_pay [put] func (c *Controller) ChargePrePay(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargePrePayRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargePrePayBody) 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.ChargePrePayResponse{} rpcReq := &v1.ChargePrePayRequest{ GardenId: tokenInfo.GardenId, BindId: req.BindId, ShouldPayAmount: req.ShouldPayAmount, PayAmount: req.PayAmount, PayType: req.PayType, Comment: req.Comment, Months: req.Months, } rpcRsp, err := pb.Garden.ChargePrePay(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargePrePay"), 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 page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.ChargeBillObjListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/unpay_bill/obj_list [get] func (c *Controller) ChargeBillObjList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeBillObjListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeBillObjListQuery, 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.ChargeBillObjListResponse{} rpcReq := &v1.ChargeBillObjListRequest{ GardenId: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, } rpcRsp, err := pb.Garden.ChargeBillObjList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeBillObjList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeBillObjItem, 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 obj_id query int false "房屋/车位/车辆id" // @Param obj_type query int false "1 房屋 2 车位 3 车辆 " // @Param charge_type query int false "费用类型 费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他" // @Param obj_name query string false "对象名" // @Param charge_name query string false "费项名" // @Success 200 {object} v1.ChargeObjBillListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/unpay_bill/obj_bill_list [get] func (c *Controller) ChargeObjBillList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeObjBillListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeObjBillListQuery, 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.ChargeObjBillListResponse{} rpcReq := &v1.ChargeObjBillListRequest{ GardenId: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, ObjType: req.ObjType, ObjId: req.ObjId, ObjName: req.ObjName, ChargeType: req.ChargeType, ChargeName: req.ChargeName, //All:true, } rpcRsp, err := pb.Garden.ChargeObjBillList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeObjBillList"), 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 body body v1.ChargeDelBillBody true " " // @Success 200 {object} v1.ChargeDelBillResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/unpay_bill/discard [put] func (c *Controller) ChargeDelBill(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeDelBillRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeDelBillBody) 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.ChargeDelBillResponse{} rpcReq := &v1.ChargeDelBillRequest{ GardenId: tokenInfo.GardenId, BillId: req.BillId, DelReason: req.DelReason, } _, err = pb.Garden.ChargeDelBill(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeDelBill"), 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 body body v1.ChargeUrgeBody true " " // @Success 200 {object} v1.ChargeUrgeResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/unpay_bill/urge [post] func (c *Controller) ChargeUrge(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeUrgeRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeUrgeBody) 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.ChargeUrgeResponse{} rpcReq := &v1.ChargeUrgeRequest{ GardenId: tokenInfo.GardenId, ObjType: req.ObjType, ObjId: req.ObjId, } _, err = pb.Garden.ChargeUrge(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeUrge"), 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 page query int false " " // @Param page_size query int false " " // @Param charge_type query int false "费用类型 费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他" // @Param obj_name query string false "对象名" // @Param charge_name query string false "费项名" // @Param obj_type query int false "1 房屋 2 车位 3 车辆 " // @Success 200 {object} v1.ChargePayedBillListResponse // @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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.ChargePayedBillListResponse{} rpcReq := &v1.ChargePayedBillListRequest{ GardenId: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, ChargeType: req.ChargeType, ChargeName: req.ChargeName, ObjName: req.ObjName, ObjType: req.ObjType, } 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 body body v1.ChargeRecoverBillBody true " " // @Success 200 {object} v1.ChargeRecoverBillResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/discard_bill/recover [put] func (c *Controller) ChargeRecoverBill(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeRecoverBillRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeRecoverBillBody) 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.ChargeRecoverBillResponse{} rpcReq := &v1.ChargeRecoverBillRequest{ GardenId: tokenInfo.GardenId, BillId: req.BillId, } _, err = pb.Garden.ChargeRecoverBill(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeRecoverBill"), 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 page query int false " " // @Param page_size query int false " " // @Param charge_type query int false "费用类型 费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他" // @Param obj_name query string false "对象名" // @Param charge_name query string false "费项名" // @Param obj_type query int false "1 房屋 2 车位 3 车辆 " // @Success 200 {object} v1.ChargeDelBillListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/discard_bill/list [get] func (c *Controller) ChargeDelBillList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeDelBillListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeDelBillListQuery, 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.ChargeDelBillListResponse{} rpcReq := &v1.ChargeDelBillListRequest{ GardenId: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, ChargeType: req.ChargeType, ChargeName: req.ChargeName, ObjName: req.ObjName, ObjType: req.ObjType, } rpcRsp, err := pb.Garden.ChargeDelBillList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeDelBillList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.ChargeDelBillItem, 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 pay_type query int false "1 现金 2 微信 3 支付宝 4 pos 5 转账 6 小程序微信支付 7 小程序支付宝支付 8 app 微信支付 9 app 支付宝支付" // @Param obj_name query string false "对象名" // @Param pay_status query int false "1 待支付 2 已支付" // @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.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.ChargeOrderListResponse{} rpcReq := &v1.ChargeOrderListRequest{ GardenId: tokenInfo.GardenId, PageSize: req.PageSize, Page: req.Page, ObjName: req.ObjName, PayType: req.PayType, PayStatus: req.PayStatus, } 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 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 { tokenInfo, err := utils.GetSubjectValue(ctx) if err != nil { return err } // 响应数据 resp := param_v1.ChargeOrderInfoResponse{} rpcReq := &v1.ChargeOrderInfoRequest{ GardenId: tokenInfo.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 body body v1.ChargeOrderPayBody true " " // @Success 200 {object} v1.ChargeOrderPayResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/order/confirm [put] func (c *Controller) ChargeOrderPay(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeOrderPayRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeOrderPayBody) 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.ChargeOrderPayResponse{} rpcReq := &v1.ChargeOrderPayRequest{ GardenId: tokenInfo.GardenId, OrderId: req.OrderId, IsComfirm: true, } _, err = pb.Garden.ChargeOrderPay(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeOrderPay"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } logReq := OperationLogRequest{ Module: "费用", Action: "确认支付", Origin: nil, Target: req.ChargeOrderPayBody, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) 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.PropertyPackageAddBody true "信息" // @Success 200 {object} v1.PropertyPackageAddResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/property_package [post] func (c *Controller) PropertyPackageAdd(ctx *gin.Context) { // 解析参数 req := ¶m_v1.PropertyPackageAddRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.PropertyPackageAddBody) 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.PropertyPackageAddResponse{} rpcReq := &v1.PropertyPackageAddRequest{ GardenId: tokenInfo.GardenId, GiveMonths: req.GiveMonths, GiveContent: req.GiveContent, PackageType: req.PackageType, Enable: req.Enable, PayMonths: req.PayMonths, } rpcRsp, err := pb.Garden.PropertyPackageAdd(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.PropertyPackageAdd"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module: ModuleCharge, Action: ActionChargePropertyPackageAdd, Origin: nil, Target: req.PropertyPackageAddBody, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 修改物业费套餐 // @Description 修改物业费套餐 // @Tags 物业费套餐 // @Accept json // @Produce json // @Param token header string true "token" // @Param body body v1.PropertyPackageUpdateBody true "信息" // @Success 200 {object} v1.PropertyPackageUpdateResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/property_package [put] func (c *Controller) PropertyPackageUpdate(ctx *gin.Context) { // 解析参数 req := ¶m_v1.PropertyPackageUpdateRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.PropertyPackageUpdateBody) 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.PropertyPackageUpdateResponse{} rpcReq := &v1.PropertyPackageUpdateRequest{ GardenId: tokenInfo.GardenId, GiveMonths: req.GiveMonths, GiveContent: req.GiveContent, PackageType: req.PackageType, Enable: req.Enable, PayMonths: req.PayMonths, Id: req.Id, } rpcRsp, err := pb.Garden.PropertyPackageUpdate(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.PropertyPackageUpdate"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module: ModuleCharge, Action: ActionChargePropertyPackageUpdate, Origin: rpcRsp.Origin, Target: req.PropertyPackageUpdateBody, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 删除物业费套餐 // @Description 删除物业费套餐 // @Tags 物业费套餐 // @Accept json // @Produce json // @Param id query int true " " // @Param token header string true "token" // @Success 200 {object} v1.PropertyPackageDelResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/property_package [delete] func (c *Controller) PropertyPackageDel(ctx *gin.Context) { // 解析参数 req := ¶m_v1.PropertyPackageDelRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.PropertyPackageDelQuery, 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.PropertyPackageDelResponse{} rpcReq := &v1.PropertyPackageDelRequest{ GardenId: tokenInfo.GardenId, Id: req.Id, } rpcRsp, err := pb.Garden.PropertyPackageDel(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.PropertyPackageDel"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } ctx.JSON(http.StatusOK, resp) logReq := OperationLogRequest{ Module: ModuleCharge, Action: ActionChargePropertyPackageDel, Origin: rpcRsp.Origin, Target: nil, UserName: tokenInfo.UserName, Uid: tokenInfo.Uid, Cid: tokenInfo.Cid, GardenId: tokenInfo.GardenId, } go OperationLogAdd(&logReq) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) } // // @Summary 物业费套餐列表 // @Description 物业费套餐列表 // @Tags 物业费套餐 // @Accept json // @Produce json // @Param page query int false " " // @Param page_size query int false " " // @Param token header string true "token" // @Success 200 {object} v1.PropertyPackageListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/property_package [get] func (c *Controller) PropertyPackageList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.PropertyPackageListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, &req.PropertyPackageListQuery, 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.PropertyPackageListResponse{} rpcReq := &v1.PropertyPackageListRequest{ GardenId: tokenInfo.GardenId, Page: req.Page, PageSize: req.PageSize, } rpcRsp, err := pb.Garden.PropertyPackageList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.PropertyPackageList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*v1.PropertyPackageItem, 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 body body v1.ChargeUrgeSetBody true " " // @Success 200 {object} v1.ChargeUrgeSetResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/urge [put] func (c *Controller) ChargeUrgeSet(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeUrgeSetRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeUrgeSetBody) 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.ChargeUrgeSetResponse{} rpcReq := &v1.ChargeUrgeSetRequest{ GardenId: tokenInfo.GardenId, UrgeDay: req.UrgeDay, UrgeTarget: req.UrgeTarget, UrgeMsgType: req.UrgeMsgType, Id: req.Id, } if req.UrgeMsgType == 1 || req.UrgeMsgType == 3 { mreq := v1.MsgPackageOrderListRequest{GardenId: tokenInfo.GardenId, Available: true} mreply, err := pb.System.MsgPackageOrderList(ctx, &mreq) if err != nil { s, _ := json.MarshalToString(mreq) logger.Error("func", zap.String("call", "pb.System.MsgPackageOrderList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if len(mreply.List) == 0 { return status.Error(10003, "当前没有可用短信套餐,请购买短信") } } _, err = pb.Garden.ChargeUrgeSet(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeUrgeSet"), 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" // @Success 200 {object} v1.ChargeUrgeInfoResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/charge/urge [get] func (c *Controller) ChargeUrgeInfo(ctx *gin.Context) { // 解析参数 req := ¶m_v1.ChargeUrgeInfoRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, &req.Header, nil, nil, 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.ChargeUrgeInfoResponse{} rpcReq := &v1.ChargeUrgeInfoRequest{ GardenId: tokenInfo.GardenId, } rpcRsp, err := pb.Garden.ChargeUrgeInfo(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "pb.Garden.ChargeUrgeInfo"), 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) }