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