123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489 |
- 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-applete-gateway/errors"
- param_v1 "property-applete-gateway/param/v1"
- "property-applete-gateway/parser"
- "property-applete-gateway/pb"
- "property-applete-gateway/pb/v1"
- "property-applete-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.ChargePowerTemplateResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/charge/power/template [get]
- func (c *Controller) ChargePowerTemplate(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.ChargePowerTemplateRequest{}
- 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.ChargePowerTemplateResponse{}
- 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 " "
- // @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{}
- rpcReq := &v1.ChargeHouseNotBindListRequest{
- GardenId:tokenInfo.GardenId,
- ChargeId:req.ChargeId,
- PageSize:req.PageSize,
- Page:req.Page,
- }
- 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 true "房屋/车位/车辆id"
- // @Param obj_type query int true "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,
- ChargeName:req.ChargeName,
- ChargeType:req.ChargeType,
- }
- 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 "费项名"
- // @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 "2 支付中 3 已支付"
- // @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.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.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)
- }
- 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,
- }
- _, 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)
- }
- //
- // @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/native_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.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.ChargeBillPayByHouseholdResponse{}
- rpcReq := &v1.ChargeBillPayByHouseholdRequest{
- GardenId:tokenInfo.GardenId,
- BindIds:req.BindIds,
- ShouldPayAmount:req.ShouldPayAmount,
- PayAmount:req.PayAmount,
- PayType:10,
- Comment:req.Comment,
- InputIp:ctx.ClientIP(),
- HouseholdUid:0,
- OpenId:"",
- Native:true,
- }
- 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)
- }
|