charge.go 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368
  1. package v1
  2. import (
  3. "fmt"
  4. "git.getensh.com/common/gopkgs/logger"
  5. "git.getensh.com/common/gopkgs/tasker/httptasker"
  6. "git.getensh.com/common/gopkgs/util"
  7. "github.com/gin-gonic/gin"
  8. "github.com/tealeg/xlsx"
  9. "go.uber.org/zap"
  10. "google.golang.org/grpc/status"
  11. "net/http"
  12. "os"
  13. "path"
  14. "property-system-gateway/errors"
  15. param_v1 "property-system-gateway/param/v1"
  16. "property-system-gateway/parser"
  17. "property-system-gateway/pb"
  18. "property-system-gateway/pb/v1"
  19. "property-system-gateway/utils"
  20. "strconv"
  21. "strings"
  22. "time"
  23. )
  24. func parseTime(data *xlsx.Cell) (int64, bool) {
  25. t, err := data.GetTime(false)
  26. if err != nil {
  27. return 0, false
  28. }
  29. return t.Add(-8 * time.Hour).Unix(), true
  30. }
  31. func parsePowerRecordContent(fileName string) ([]*v1.PowerRecordBatchData, error) {
  32. f, err := xlsx.OpenFile(fileName)
  33. if err != nil {
  34. return nil, status.Error(10003, "xlsx 打开失败")
  35. }
  36. if len(f.Sheets) == 0 {
  37. return nil, status.Error(10003, "参数文件没有sheet")
  38. }
  39. sheet := f.Sheets[0]
  40. if len(sheet.Rows) == 0 {
  41. return nil, status.Error(10003, "文件为空")
  42. }
  43. if len(sheet.Rows) > 1005 {
  44. return nil, status.Error(10003, "单次导入不能超过一千条记录, 请分批导入")
  45. }
  46. list := []*v1.PowerRecordBatchData{}
  47. for i, row := range sheet.Rows {
  48. if i == 0 {
  49. // 第1行是注释行
  50. continue
  51. }
  52. if len(row.Cells) < 7 {
  53. return nil, status.Error(10003, fmt.Sprintf("第%d行", i)+"列数错误,请使用模板")
  54. }
  55. if i == 1 {
  56. if row.Cells[0].Value != "楼栋编号" ||
  57. row.Cells[1].Value != "单元编号" ||
  58. row.Cells[2].Value != "房屋门牌号" ||
  59. row.Cells[3].Value != "开始时间" ||
  60. row.Cells[4].Value != "结束时间" ||
  61. row.Cells[5].Value != "上次抄表用量" ||
  62. row.Cells[6].Value != "本次抄表用量" {
  63. return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"标题错误,请使用模板")
  64. }
  65. continue
  66. }
  67. buidingNumber := strings.TrimSpace(row.Cells[0].Value)
  68. unitNumberStr := strings.TrimSpace(row.Cells[1].Value)
  69. houseNumber := strings.TrimSpace(row.Cells[2].Value)
  70. lastAmountStr := strings.TrimSpace(row.Cells[5].Value)
  71. currentAmountStr := strings.TrimSpace(row.Cells[6].Value)
  72. startStr := strings.TrimSpace(row.Cells[3].Value)
  73. endStr := strings.TrimSpace(row.Cells[4].Value)
  74. if buidingNumber == "" && unitNumberStr == "" &&
  75. houseNumber == "" && lastAmountStr == "" &&
  76. currentAmountStr == "" && startStr == "" && endStr == "" {
  77. continue
  78. }
  79. if buidingNumber == "" || unitNumberStr == "" ||
  80. houseNumber == "" || lastAmountStr == "" ||
  81. currentAmountStr == "" || startStr == "" || endStr == "" {
  82. return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"参数不能为空")
  83. }
  84. unitNumber, err := strconv.Atoi(unitNumberStr)
  85. if err != nil {
  86. return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"单元格式错误")
  87. }
  88. lastAmount, err := strconv.ParseFloat(lastAmountStr, 64)
  89. if err != nil {
  90. return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"上次抄表用量格式错误")
  91. }
  92. currentAmount, err := strconv.ParseFloat(currentAmountStr, 64)
  93. if err != nil {
  94. return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"本次抄表用量格式错误")
  95. }
  96. if currentAmount < lastAmount {
  97. return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"本次抄表用量不能小于上次抄表用量")
  98. }
  99. start, ok := parseTime(row.Cells[3])
  100. if !ok {
  101. return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"开始时间错误")
  102. }
  103. end, ok := parseTime(row.Cells[4])
  104. if !ok {
  105. return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"结束时间错误")
  106. }
  107. if end <= start {
  108. return nil, status.Error(10003, fmt.Sprintf("第%d行", i+1)+"结束时间必须晚于开始时间")
  109. }
  110. item := &v1.PowerRecordBatchData{
  111. Start: start,
  112. End: end,
  113. LastAmount: lastAmount,
  114. CurrentAmount: currentAmount,
  115. BuildingNumber: buidingNumber,
  116. UnitNumber: int64(unitNumber),
  117. HouseNumber: houseNumber,
  118. }
  119. list = append(list, item)
  120. }
  121. return list, nil
  122. }
  123. //
  124. // @Summary 批量抄表
  125. // @Description 批量抄表
  126. // @Tags 抄表
  127. // @Accept json
  128. // @Produce json
  129. // @Param token header string true "jwt token"
  130. // @Param charge_type query int32 true "费用类型 2 水费 3 电费 4 气费"
  131. // @Param file formData file true "file"
  132. // @Success 200 {object} v1.PowerRecordBatchAddResponse
  133. // @Failure 500 {object} base.HTTPError
  134. // @Router /api/v1/charge/power/batch [post]
  135. func (c Controller) PowerRecordBatchAdd(ctx *gin.Context) {
  136. // 解析参数
  137. req := &param_v1.PowerRecordBatchAddRequest{}
  138. newFile := ""
  139. var tokenInfo utils.TokenInfo
  140. parseParamTask := func() error {
  141. var err error
  142. tokenInfo, err = utils.GetSubjectValue(ctx)
  143. if err != nil {
  144. return err
  145. }
  146. err = util.ShouldBind(ctx, &req.Header, nil, &req.PowerRecordBatchAddQuery, nil)
  147. if err != nil {
  148. logger.Error("func",
  149. zap.String("call", "util.ShouldBind"),
  150. zap.String("error", err.Error()))
  151. return errors.ParamsError
  152. }
  153. file, err := ctx.FormFile("file")
  154. if err != nil {
  155. return errors.SystemError
  156. }
  157. if file.Size > 10*1024*1024 {
  158. return status.Error(10003, "文件过大")
  159. }
  160. ext := path.Ext(file.Filename)
  161. if ext != ".xlsx" {
  162. return status.Error(10003, "仅支持xlsx文件格式")
  163. }
  164. newFile = fmt.Sprintf("power-%s-%d-%d.xlsx", file.Filename, tokenInfo.Uid, time.Now().UnixNano())
  165. err = ctx.SaveUploadedFile(file, newFile)
  166. if err != nil {
  167. logger.Error("func",
  168. zap.String("call", "ctx.SaveUploadedFile"),
  169. zap.String("error", err.Error()))
  170. return status.Error(10003, "保存文件失败")
  171. }
  172. return nil
  173. }
  174. // 业务处理
  175. handleServiceTask := func() error {
  176. list, err := parsePowerRecordContent(newFile)
  177. if err != nil {
  178. os.Remove(newFile)
  179. return err
  180. }
  181. os.Remove(newFile)
  182. // 响应数据
  183. resp := param_v1.PowerRecordBatchAddResponse{}
  184. rpcReq := &v1.PowerRecordBatchAddRequest{
  185. GardenId: tokenInfo.GardenId,
  186. ChargeType: req.ChargeType,
  187. List: list,
  188. }
  189. _, err = pb.Garden.PowerRecordBatchAdd(ctx, rpcReq)
  190. if err != nil {
  191. s, _ := json.MarshalToString(req)
  192. logger.Error("func",
  193. zap.String("call", "pb.Garden.PowerRecordBatchAdd"),
  194. zap.String("params", s),
  195. zap.String("error", err.Error()))
  196. return errors.ErrorTransForm(err)
  197. }
  198. ctx.JSON(http.StatusOK, resp)
  199. return nil
  200. }
  201. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  202. }
  203. //
  204. // @Summary 添加费用配置
  205. // @Description 添加费用配置
  206. // @Tags 费用配置
  207. // @Accept json
  208. // @Produce json
  209. // @Param token header string true "token"
  210. // @Param body body v1.ChargeConfAddBody true "信息"
  211. // @Success 200 {object} v1.ChargeConfAddResponse
  212. // @Failure 500 {object} base.HTTPError
  213. // @Router /api/v1/charge/conf [post]
  214. func (c *Controller) ChargeConfAdd(ctx *gin.Context) {
  215. // 解析参数
  216. req := &param_v1.ChargeConfAddRequest{}
  217. parseParamTask := func() error {
  218. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeConfAddBody)
  219. if err != nil {
  220. logger.Error("func",
  221. zap.String("call", "util.ShouldBind"),
  222. zap.String("error", err.Error()))
  223. return errors.ParamsError
  224. }
  225. return nil
  226. }
  227. // 业务处理
  228. handleServiceTask := func() error {
  229. tokenInfo, err := utils.GetSubjectValue(ctx)
  230. if err != nil {
  231. return err
  232. }
  233. // 响应数据
  234. resp := param_v1.ChargeConfAddResponse{}
  235. rpcReq := &v1.ChargeConfAddRequest{
  236. GardenId: tokenInfo.GardenId,
  237. // 费用类型1 物业费 2 水费 3 电费 4 气费
  238. ChargeType: req.ChargeType,
  239. // 费用名称
  240. ChargeName: req.ChargeName,
  241. // 缴费时间类型 1 周期性缴 2 一次性
  242. ChargeTimeType: req.ChargeTimeType,
  243. // 1 按房屋面积 2 按使用面积 3 固定费用 4 按使用量 5 固定费用
  244. ChargeBasis: req.ChargeBasis,
  245. // 固定费用
  246. FixAmount: req.FixAmount,
  247. // 固定费用别名
  248. FixAmountName: req.FixAmountName,
  249. // 单价
  250. UnitPrice: req.UnitPrice,
  251. LateFeeEnable: req.LateFeeEnable,
  252. LateFeePercent: req.LateFeePercent,
  253. LateFeeDay: req.LateFeeDay,
  254. // 账单生成周期 1 按月 2 按季度 3 半年 4 年
  255. BillPeriod: req.BillPeriod,
  256. // 账单周期计算方式 1自然周期 2 费用生效时间
  257. BillPeriodType: req.BillPeriodType,
  258. ChargeEffectiveTime: req.ChargeEffectiveTime,
  259. }
  260. rpcRsp, err := pb.Garden.ChargeConfAdd(ctx, rpcReq)
  261. if err != nil {
  262. s, _ := json.MarshalToString(req)
  263. logger.Error("func",
  264. zap.String("call", "pb.Garden.ChargeConfAdd"),
  265. zap.String("params", s),
  266. zap.String("error", err.Error()))
  267. return errors.ErrorTransForm(err)
  268. }
  269. resp.Data = *rpcRsp
  270. ctx.JSON(http.StatusOK, resp)
  271. logReq := OperationLogRequest{
  272. Module: ModuleCharge,
  273. Action: ActionChargeConfAdd,
  274. Origin: nil,
  275. Target: req.ChargeConfAddBody,
  276. UserName: tokenInfo.UserName,
  277. Uid: tokenInfo.Uid,
  278. Cid: tokenInfo.Cid,
  279. GardenId: tokenInfo.GardenId,
  280. }
  281. go OperationLogAdd(&logReq)
  282. return nil
  283. }
  284. // 执行任务
  285. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  286. }
  287. //
  288. // @Summary 修改费用配置
  289. // @Description 修改费用配置
  290. // @Tags 费用配置
  291. // @Accept json
  292. // @Produce json
  293. // @Param token header string true "token"
  294. // @Param body body v1.ChargeConfUpdateBody true "信息"
  295. // @Success 200 {object} v1.ChargeConfUpdateResponse
  296. // @Failure 500 {object} base.HTTPError
  297. // @Router /api/v1/charge/conf [put]
  298. func (c *Controller) ChargeConfUpdate(ctx *gin.Context) {
  299. // 解析参数
  300. req := &param_v1.ChargeConfUpdateRequest{}
  301. parseParamTask := func() error {
  302. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeConfUpdateBody)
  303. if err != nil {
  304. logger.Error("func",
  305. zap.String("call", "util.ShouldBind"),
  306. zap.String("error", err.Error()))
  307. return errors.ParamsError
  308. }
  309. return nil
  310. }
  311. // 业务处理
  312. handleServiceTask := func() error {
  313. tokenInfo, err := utils.GetSubjectValue(ctx)
  314. if err != nil {
  315. return err
  316. }
  317. // 响应数据
  318. resp := param_v1.ChargeConfUpdateResponse{}
  319. rpcReq := &v1.ChargeConfUpdateRequest{
  320. GardenId: tokenInfo.GardenId,
  321. // 费用类型1 物业费 2 水费 3 电费 4 气费
  322. ChargeType: req.ChargeType,
  323. // 费用名称
  324. ChargeName: req.ChargeName,
  325. // 缴费时间类型 1 周期性缴 2 一次性
  326. ChargeTimeType: req.ChargeTimeType,
  327. // 1 按房屋面积 2 按使用面积 3 固定费用 4 按使用量 5 固定费用
  328. ChargeBasis: req.ChargeBasis,
  329. // 固定费用
  330. FixAmount: req.FixAmount,
  331. // 固定费用别名
  332. FixAmountName: req.FixAmountName,
  333. // 单价
  334. UnitPrice: req.UnitPrice,
  335. LateFeeEnable: req.LateFeeEnable,
  336. LateFeePercent: req.LateFeePercent,
  337. LateFeeDay: req.LateFeeDay,
  338. // 账单生成周期 1 按月 2 按季度 3 半年 4 年
  339. BillPeriod: req.BillPeriod,
  340. // 账单周期计算方式 1自然周期 2 费用生效时间
  341. BillPeriodType: req.BillPeriodType,
  342. ChargeEffectiveTime: req.ChargeEffectiveTime,
  343. Id: req.Id,
  344. }
  345. rpcRsp, err := pb.Garden.ChargeConfUpdate(ctx, rpcReq)
  346. if err != nil {
  347. s, _ := json.MarshalToString(req)
  348. logger.Error("func",
  349. zap.String("call", "pb.Garden.ChargeConfUpdate"),
  350. zap.String("params", s),
  351. zap.String("error", err.Error()))
  352. return errors.ErrorTransForm(err)
  353. }
  354. ctx.JSON(http.StatusOK, resp)
  355. logReq := OperationLogRequest{
  356. Module: ModuleCharge,
  357. Action: ActionChargeConfUpdate,
  358. Origin: rpcRsp.Origin,
  359. Target: req.ChargeConfUpdateBody,
  360. UserName: tokenInfo.UserName,
  361. Uid: tokenInfo.Uid,
  362. Cid: tokenInfo.Cid,
  363. GardenId: tokenInfo.GardenId,
  364. }
  365. go OperationLogAdd(&logReq)
  366. return nil
  367. }
  368. // 执行任务
  369. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  370. }
  371. //
  372. // @Summary 删除费用配置
  373. // @Description 删除费用配置
  374. // @Tags 费用配置
  375. // @Accept json
  376. // @Produce json
  377. // @Param id query int true " "
  378. // @Param token header string true "token"
  379. // @Success 200 {object} v1.ChargeConfDelResponse
  380. // @Failure 500 {object} base.HTTPError
  381. // @Router /api/v1/charge/conf [delete]
  382. func (c *Controller) ChargeConfDel(ctx *gin.Context) {
  383. // 解析参数
  384. req := &param_v1.ChargeConfDelRequest{}
  385. parseParamTask := func() error {
  386. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeConfDelQuery, nil)
  387. if err != nil {
  388. logger.Error("func",
  389. zap.String("call", "util.ShouldBind"),
  390. zap.String("error", err.Error()))
  391. return errors.ParamsError
  392. }
  393. return nil
  394. }
  395. // 业务处理
  396. handleServiceTask := func() error {
  397. tokenInfo, err := utils.GetSubjectValue(ctx)
  398. if err != nil {
  399. return err
  400. }
  401. // 响应数据
  402. resp := param_v1.ChargeConfDelResponse{}
  403. rpcReq := &v1.ChargeConfDelRequest{
  404. GardenId: tokenInfo.GardenId,
  405. Id: req.Id,
  406. }
  407. rpcRsp, err := pb.Garden.ChargeConfDel(ctx, rpcReq)
  408. if err != nil {
  409. s, _ := json.MarshalToString(req)
  410. logger.Error("func",
  411. zap.String("call", "pb.Garden.ChargeConfDel"),
  412. zap.String("params", s),
  413. zap.String("error", err.Error()))
  414. return errors.ErrorTransForm(err)
  415. }
  416. ctx.JSON(http.StatusOK, resp)
  417. logReq := OperationLogRequest{
  418. Module: ModuleCharge,
  419. Action: ActionChargeConfDel,
  420. Origin: rpcRsp.Origin,
  421. Target: nil,
  422. UserName: tokenInfo.UserName,
  423. Uid: tokenInfo.Uid,
  424. Cid: tokenInfo.Cid,
  425. GardenId: tokenInfo.GardenId,
  426. }
  427. go OperationLogAdd(&logReq)
  428. return nil
  429. }
  430. // 执行任务
  431. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  432. }
  433. //
  434. // @Summary 费用配置列表
  435. // @Description 费用配置列表
  436. // @Tags 费用配置
  437. // @Accept json
  438. // @Produce json
  439. // @Param page query int false " "
  440. // @Param page_size query int false " "
  441. // @Param charge_type query int false "费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他"
  442. // @Param token header string true "token"
  443. // @Success 200 {object} v1.ChargeConfListResponse
  444. // @Failure 500 {object} base.HTTPError
  445. // @Router /api/v1/charge/conf [get]
  446. func (c *Controller) ChargeConfList(ctx *gin.Context) {
  447. // 解析参数
  448. req := &param_v1.ChargeConfListRequest{}
  449. parseParamTask := func() error {
  450. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeConfListQuery, nil)
  451. if err != nil {
  452. logger.Error("func",
  453. zap.String("call", "util.ShouldBind"),
  454. zap.String("error", err.Error()))
  455. return errors.ParamsError
  456. }
  457. return nil
  458. }
  459. // 业务处理
  460. handleServiceTask := func() error {
  461. tokenInfo, err := utils.GetSubjectValue(ctx)
  462. if err != nil {
  463. return err
  464. }
  465. // 响应数据
  466. resp := param_v1.ChargeConfListResponse{}
  467. rpcReq := &v1.ChargeConfListRequest{
  468. GardenId: tokenInfo.GardenId,
  469. ChargeName: req.ChargeName,
  470. ChargeType: req.ChargeType,
  471. Page: req.Page,
  472. PageSize: req.PageSize,
  473. }
  474. rpcRsp, err := pb.Garden.ChargeConfList(ctx, rpcReq)
  475. if err != nil {
  476. s, _ := json.MarshalToString(req)
  477. logger.Error("func",
  478. zap.String("call", "pb.Garden.ChargeConfList"),
  479. zap.String("params", s),
  480. zap.String("error", err.Error()))
  481. return errors.ErrorTransForm(err)
  482. }
  483. if rpcRsp.List == nil {
  484. rpcRsp.List = make([]*v1.ChargeConfItem, 0)
  485. }
  486. resp.Data = *rpcRsp
  487. ctx.JSON(http.StatusOK, resp)
  488. return nil
  489. }
  490. // 执行任务
  491. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  492. }
  493. //
  494. // @Summary 添加抄表记录
  495. // @Description 添加抄表记录
  496. // @Tags 抄表
  497. // @Accept json
  498. // @Produce json
  499. // @Param token header string true "token"
  500. // @Param body body v1.PowerRecordAddBody true "信息"
  501. // @Success 200 {object} v1.PowerRecordAddResponse
  502. // @Failure 500 {object} base.HTTPError
  503. // @Router /api/v1/charge/power [post]
  504. func (c *Controller) PowerRecordAdd(ctx *gin.Context) {
  505. // 解析参数
  506. req := &param_v1.PowerRecordAddRequest{}
  507. parseParamTask := func() error {
  508. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.PowerRecordAddBody)
  509. if err != nil {
  510. logger.Error("func",
  511. zap.String("call", "util.ShouldBind"),
  512. zap.String("error", err.Error()))
  513. return errors.ParamsError
  514. }
  515. return nil
  516. }
  517. // 业务处理
  518. handleServiceTask := func() error {
  519. tokenInfo, err := utils.GetSubjectValue(ctx)
  520. if err != nil {
  521. return err
  522. }
  523. // 响应数据
  524. resp := param_v1.PowerRecordAddResponse{}
  525. rpcReq := &v1.PowerRecordAddRequest{
  526. GardenId: tokenInfo.GardenId,
  527. LastAmount: req.LastAmount,
  528. CurrentAmount: req.CurrentAmount,
  529. Start: req.Start,
  530. End: req.End,
  531. Comment: req.Comment,
  532. HouseId: req.HouseId,
  533. ChargeType: req.ChargeType,
  534. }
  535. rpcRsp, err := pb.Garden.PowerRecordAdd(ctx, rpcReq)
  536. if err != nil {
  537. s, _ := json.MarshalToString(req)
  538. logger.Error("func",
  539. zap.String("call", "pb.Garden.PowerRecordAdd"),
  540. zap.String("params", s),
  541. zap.String("error", err.Error()))
  542. return errors.ErrorTransForm(err)
  543. }
  544. resp.Data = *rpcRsp
  545. ctx.JSON(http.StatusOK, resp)
  546. logReq := OperationLogRequest{
  547. Module: ModuleCharge,
  548. Action: ActionChargePowerRecordAdd,
  549. Origin: nil,
  550. Target: req.PowerRecordAddBody,
  551. UserName: tokenInfo.UserName,
  552. Uid: tokenInfo.Uid,
  553. Cid: tokenInfo.Cid,
  554. GardenId: tokenInfo.GardenId,
  555. }
  556. go OperationLogAdd(&logReq)
  557. return nil
  558. }
  559. // 执行任务
  560. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  561. }
  562. //
  563. // @Summary 获取抄表模板
  564. // @Description 获取抄表模板
  565. // @Tags 抄表
  566. // @Accept json
  567. // @Produce json
  568. // @Param token header string true "token"
  569. // @Success 200 {object} v1.TemplateResponse
  570. // @Failure 500 {object} base.HTTPError
  571. // @Router /api/v1/charge/power/template [get]
  572. func (c *Controller) ChargePowerTemplate(ctx *gin.Context) {
  573. // 解析参数
  574. req := &param_v1.TemplateRequest{}
  575. parseParamTask := func() error {
  576. err := util.ShouldBind(ctx, &req.Header, nil, nil, nil)
  577. if err != nil {
  578. logger.Error("func",
  579. zap.String("call", "util.ShouldBind"),
  580. zap.String("error", err.Error()))
  581. return errors.ParamsError
  582. }
  583. return nil
  584. }
  585. // 业务处理
  586. handleServiceTask := func() error {
  587. // 响应数据
  588. resp := param_v1.TemplateResponse{}
  589. resp.Data.Url = parser.Conf.Oss.PowerTempUrl
  590. ctx.JSON(http.StatusOK, resp)
  591. return nil
  592. }
  593. // 执行任务
  594. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  595. }
  596. //
  597. // @Summary 删除抄表记录
  598. // @Description 删除抄表记录
  599. // @Tags 抄表
  600. // @Accept json
  601. // @Produce json
  602. // @Param id query int true " "
  603. // @Param token header string true "token"
  604. // @Success 200 {object} v1.PowerRecordDelResponse
  605. // @Failure 500 {object} base.HTTPError
  606. // @Router /api/v1/charge/power [delete]
  607. func (c *Controller) PowerRecordDel(ctx *gin.Context) {
  608. // 解析参数
  609. req := &param_v1.PowerRecordDelRequest{}
  610. parseParamTask := func() error {
  611. err := util.ShouldBind(ctx, &req.Header, nil, &req.PowerRecordDelQuery, nil)
  612. if err != nil {
  613. logger.Error("func",
  614. zap.String("call", "util.ShouldBind"),
  615. zap.String("error", err.Error()))
  616. return errors.ParamsError
  617. }
  618. return nil
  619. }
  620. // 业务处理
  621. handleServiceTask := func() error {
  622. tokenInfo, err := utils.GetSubjectValue(ctx)
  623. if err != nil {
  624. return err
  625. }
  626. // 响应数据
  627. resp := param_v1.PowerRecordDelResponse{}
  628. rpcReq := &v1.PowerRecordDelRequest{
  629. GardenId: tokenInfo.GardenId,
  630. Id: req.Id,
  631. }
  632. rpcRsp, err := pb.Garden.PowerRecordDel(ctx, rpcReq)
  633. if err != nil {
  634. s, _ := json.MarshalToString(req)
  635. logger.Error("func",
  636. zap.String("call", "pb.Garden.PowerRecordDel"),
  637. zap.String("params", s),
  638. zap.String("error", err.Error()))
  639. return errors.ErrorTransForm(err)
  640. }
  641. ctx.JSON(http.StatusOK, resp)
  642. logReq := OperationLogRequest{
  643. Module: ModuleCharge,
  644. Action: ActionChargePowerRecordDel,
  645. Origin: rpcRsp.Origin,
  646. Target: nil,
  647. UserName: tokenInfo.UserName,
  648. Uid: tokenInfo.Uid,
  649. Cid: tokenInfo.Cid,
  650. GardenId: tokenInfo.GardenId,
  651. }
  652. go OperationLogAdd(&logReq)
  653. return nil
  654. }
  655. // 执行任务
  656. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  657. }
  658. //
  659. // @Summary 抄表列表
  660. // @Description 抄表列表
  661. // @Tags 抄表
  662. // @Accept json
  663. // @Produce json
  664. // @Param page query int false " "
  665. // @Param page_size query int false " "
  666. // @Param charge_type query int false "费用类型 2 水费 3 电费 4 气费 "
  667. // @Param token header string true "token"
  668. // @Success 200 {object} v1.PowerRecordListResponse
  669. // @Failure 500 {object} base.HTTPError
  670. // @Router /api/v1/charge/power [get]
  671. func (c *Controller) PowerRecordList(ctx *gin.Context) {
  672. // 解析参数
  673. req := &param_v1.PowerRecordListRequest{}
  674. parseParamTask := func() error {
  675. err := util.ShouldBind(ctx, &req.Header, nil, &req.PowerRecordListQuery, nil)
  676. if err != nil {
  677. logger.Error("func",
  678. zap.String("call", "util.ShouldBind"),
  679. zap.String("error", err.Error()))
  680. return errors.ParamsError
  681. }
  682. return nil
  683. }
  684. // 业务处理
  685. handleServiceTask := func() error {
  686. tokenInfo, err := utils.GetSubjectValue(ctx)
  687. if err != nil {
  688. return err
  689. }
  690. // 响应数据
  691. resp := param_v1.PowerRecordListResponse{}
  692. rpcReq := &v1.PowerRecordListRequest{
  693. GardenId: tokenInfo.GardenId,
  694. ChargeType: req.ChargeType,
  695. Page: req.Page,
  696. PageSize: req.PageSize,
  697. HouseId: req.HouseId,
  698. }
  699. rpcRsp, err := pb.Garden.PowerRecordList(ctx, rpcReq)
  700. if err != nil {
  701. s, _ := json.MarshalToString(req)
  702. logger.Error("func",
  703. zap.String("call", "pb.Garden.PowerRecordList"),
  704. zap.String("params", s),
  705. zap.String("error", err.Error()))
  706. return errors.ErrorTransForm(err)
  707. }
  708. if rpcRsp.List == nil {
  709. rpcRsp.List = make([]*v1.PowerRecordItem, 0)
  710. }
  711. resp.Data = *rpcRsp
  712. ctx.JSON(http.StatusOK, resp)
  713. return nil
  714. }
  715. // 执行任务
  716. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  717. }
  718. //
  719. // @Summary 费用绑定对象
  720. // @Description 费用绑定对象
  721. // @Tags 费用绑定相关
  722. // @Accept json
  723. // @Produce json
  724. // @Param token header string true "token"
  725. // @Param body body v1.ChargeBindBody true "信息"
  726. // @Success 200 {object} v1.ChargeBindResponse
  727. // @Failure 500 {object} base.HTTPError
  728. // @Router /api/v1/charge/bind [put]
  729. func (c *Controller) ChargeBind(ctx *gin.Context) {
  730. // 解析参数
  731. req := &param_v1.ChargeBindRequest{}
  732. parseParamTask := func() error {
  733. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeBindBody)
  734. if err != nil {
  735. logger.Error("func",
  736. zap.String("call", "util.ShouldBind"),
  737. zap.String("error", err.Error()))
  738. return errors.ParamsError
  739. }
  740. return nil
  741. }
  742. // 业务处理
  743. handleServiceTask := func() error {
  744. tokenInfo, err := utils.GetSubjectValue(ctx)
  745. if err != nil {
  746. return err
  747. }
  748. // 响应数据
  749. resp := param_v1.ChargeBindResponse{}
  750. rpcReq := &v1.ChargeBindRequest{
  751. GardenId: tokenInfo.GardenId,
  752. Start: req.Start,
  753. End: req.End,
  754. ObjIds: req.ObjIds,
  755. ChargeId: req.ChargeId,
  756. VehicleFee: req.CustomFee,
  757. }
  758. _, err = pb.Garden.ChargeBind(ctx, rpcReq)
  759. if err != nil {
  760. s, _ := json.MarshalToString(req)
  761. logger.Error("func",
  762. zap.String("call", "pb.Garden.ChargeBind"),
  763. zap.String("params", s),
  764. zap.String("error", err.Error()))
  765. return errors.ErrorTransForm(err)
  766. }
  767. ctx.JSON(http.StatusOK, resp)
  768. logReq := OperationLogRequest{
  769. Module: ModuleCharge,
  770. Action: ActionChargeBind,
  771. Origin: nil,
  772. Target: req.ChargeBindBody,
  773. UserName: tokenInfo.UserName,
  774. Uid: tokenInfo.Uid,
  775. Cid: tokenInfo.Cid,
  776. GardenId: tokenInfo.GardenId,
  777. }
  778. go OperationLogAdd(&logReq)
  779. return nil
  780. }
  781. // 执行任务
  782. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  783. }
  784. //
  785. // @Summary 费用解绑对象
  786. // @Description 费用解绑对象
  787. // @Tags 费用绑定相关
  788. // @Accept json
  789. // @Produce json
  790. // @Param token header string true "token"
  791. // @Param body body v1.ChargeUnbindBody true "信息"
  792. // @Success 200 {object} v1.ChargeUnbindResponse
  793. // @Failure 500 {object} base.HTTPError
  794. // @Router /api/v1/charge/unbind [put]
  795. func (c *Controller) ChargeUnbind(ctx *gin.Context) {
  796. // 解析参数
  797. req := &param_v1.ChargeUnbindRequest{}
  798. parseParamTask := func() error {
  799. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeUnbindBody)
  800. if err != nil {
  801. logger.Error("func",
  802. zap.String("call", "util.ShouldBind"),
  803. zap.String("error", err.Error()))
  804. return errors.ParamsError
  805. }
  806. return nil
  807. }
  808. // 业务处理
  809. handleServiceTask := func() error {
  810. tokenInfo, err := utils.GetSubjectValue(ctx)
  811. if err != nil {
  812. return err
  813. }
  814. // 响应数据
  815. resp := param_v1.ChargeUnbindResponse{}
  816. rpcReq := &v1.ChargeUnbindRequest{
  817. GardenId: tokenInfo.GardenId,
  818. ObjId: req.ObjId,
  819. ChargeId: req.ChargeId,
  820. }
  821. _, err = pb.Garden.ChargeUnbind(ctx, rpcReq)
  822. if err != nil {
  823. s, _ := json.MarshalToString(req)
  824. logger.Error("func",
  825. zap.String("call", "pb.Garden.ChargeUnbind"),
  826. zap.String("params", s),
  827. zap.String("error", err.Error()))
  828. return errors.ErrorTransForm(err)
  829. }
  830. ctx.JSON(http.StatusOK, resp)
  831. logReq := OperationLogRequest{
  832. Module: ModuleCharge,
  833. Action: ActionChargeUnbind,
  834. Origin: nil,
  835. Target: req.ChargeUnbindBody,
  836. UserName: tokenInfo.UserName,
  837. Uid: tokenInfo.Uid,
  838. Cid: tokenInfo.Cid,
  839. GardenId: tokenInfo.GardenId,
  840. }
  841. go OperationLogAdd(&logReq)
  842. return nil
  843. }
  844. // 执行任务
  845. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  846. }
  847. //
  848. // @Summary 绑定了项目的房屋列表
  849. // @Description 绑定了项目的房屋列表
  850. // @Tags 费用绑定相关
  851. // @Accept json
  852. // @Produce json
  853. // @Param token header string true "token"
  854. // @Param charge_id query int true "费项id"
  855. // @Param page query int false " "
  856. // @Param page_size query int false " "
  857. // @Success 200 {object} v1.ChargeHouseBindedListResponse
  858. // @Failure 500 {object} base.HTTPError
  859. // @Router /api/v1/charge/house/binded_list [get]
  860. func (c *Controller) ChargeHouseBindedList(ctx *gin.Context) {
  861. // 解析参数
  862. req := &param_v1.ChargeHouseBindedListRequest{}
  863. parseParamTask := func() error {
  864. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeHouseBindedListQuery, nil)
  865. if err != nil {
  866. logger.Error("func",
  867. zap.String("call", "util.ShouldBind"),
  868. zap.String("error", err.Error()))
  869. return errors.ParamsError
  870. }
  871. return nil
  872. }
  873. // 业务处理
  874. handleServiceTask := func() error {
  875. tokenInfo, err := utils.GetSubjectValue(ctx)
  876. if err != nil {
  877. return err
  878. }
  879. // 响应数据
  880. resp := param_v1.ChargeHouseBindedListResponse{}
  881. rpcReq := &v1.ChargeHouseBindedListRequest{
  882. GardenId: tokenInfo.GardenId,
  883. ChargeId: req.ChargeId,
  884. PageSize: req.PageSize,
  885. Page: req.Page,
  886. }
  887. rpcRsp, err := pb.Garden.ChargeHouseBindedList(ctx, rpcReq)
  888. if err != nil {
  889. s, _ := json.MarshalToString(req)
  890. logger.Error("func",
  891. zap.String("call", "pb.Garden.ChargeHouseBindedList"),
  892. zap.String("params", s),
  893. zap.String("error", err.Error()))
  894. return errors.ErrorTransForm(err)
  895. }
  896. if rpcRsp.List == nil {
  897. rpcRsp.List = make([]*v1.ChargeHouseData, 0)
  898. }
  899. resp.Data = *rpcRsp
  900. ctx.JSON(http.StatusOK, resp)
  901. return nil
  902. }
  903. // 执行任务
  904. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  905. }
  906. //
  907. // @Summary 可以绑定某项目的房屋列表
  908. // @Description 可以绑定某项目的房屋列表
  909. // @Tags 费用绑定相关
  910. // @Accept json
  911. // @Produce json
  912. // @Param token header string true "token"
  913. // @Param charge_id query int true "费项id"
  914. // @Param page query int false " "
  915. // @Param page_size query int false " "
  916. // @Param house_name query string false "房号1-2-906"
  917. // @Success 200 {object} v1.ChargeHouseNotBindListResponse
  918. // @Failure 500 {object} base.HTTPError
  919. // @Router /api/v1/charge/house/can_bind_list [get]
  920. func (c *Controller) ChargeHouseNotBindList(ctx *gin.Context) {
  921. // 解析参数
  922. req := &param_v1.ChargeHouseNotBindListRequest{}
  923. parseParamTask := func() error {
  924. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeHouseNotBindListQuery, nil)
  925. if err != nil {
  926. logger.Error("func",
  927. zap.String("call", "util.ShouldBind"),
  928. zap.String("error", err.Error()))
  929. return errors.ParamsError
  930. }
  931. return nil
  932. }
  933. // 业务处理
  934. handleServiceTask := func() error {
  935. tokenInfo, err := utils.GetSubjectValue(ctx)
  936. if err != nil {
  937. return err
  938. }
  939. resp := param_v1.ChargeHouseNotBindListResponse{}
  940. resp.Data = v1.ChargeHouseNotBindListReply{
  941. Page: 1,
  942. Total: 0,
  943. List: make([]*v1.ChargeHouseData, 0),
  944. }
  945. buildingId, unitId := int64(0), int64(0)
  946. houseNumber := ""
  947. if req.HouseName != "" {
  948. shouldReturn := false
  949. var err error
  950. buildingId, unitId, houseNumber, shouldReturn, err = handleHouseName(ctx, req.HouseName, tokenInfo)
  951. if err != nil {
  952. return err
  953. }
  954. if shouldReturn {
  955. ctx.JSON(http.StatusOK, resp)
  956. return nil
  957. }
  958. }
  959. // 响应数据
  960. rpcReq := &v1.ChargeHouseNotBindListRequest{
  961. GardenId: tokenInfo.GardenId,
  962. ChargeId: req.ChargeId,
  963. PageSize: req.PageSize,
  964. Page: req.Page,
  965. BuildingId: buildingId,
  966. HouseNumber: houseNumber,
  967. UnitId: unitId,
  968. }
  969. rpcRsp, err := pb.Garden.ChargeHouseNotBindList(ctx, rpcReq)
  970. if err != nil {
  971. s, _ := json.MarshalToString(req)
  972. logger.Error("func",
  973. zap.String("call", "pb.Garden.ChargeHouseNotBindList"),
  974. zap.String("params", s),
  975. zap.String("error", err.Error()))
  976. return errors.ErrorTransForm(err)
  977. }
  978. if rpcRsp.List == nil {
  979. rpcRsp.List = make([]*v1.ChargeHouseData, 0)
  980. }
  981. resp.Data = *rpcRsp
  982. ctx.JSON(http.StatusOK, resp)
  983. return nil
  984. }
  985. // 执行任务
  986. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  987. }
  988. //
  989. // @Summary 绑定了项目的车位列表
  990. // @Description 绑定了项目的车位列表
  991. // @Tags 费用绑定相关
  992. // @Accept json
  993. // @Produce json
  994. // @Param token header string true "token"
  995. // @Param charge_id query int true "费项id"
  996. // @Param page query int false " "
  997. // @Param page_size query int false " "
  998. // @Success 200 {object} v1.ChargeSpaceBindedListResponse
  999. // @Failure 500 {object} base.HTTPError
  1000. // @Router /api/v1/charge/space/binded_list [get]
  1001. func (c *Controller) ChargeSpaceBindedList(ctx *gin.Context) {
  1002. // 解析参数
  1003. req := &param_v1.ChargeSpaceBindedListRequest{}
  1004. parseParamTask := func() error {
  1005. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeSpaceBindedListQuery, nil)
  1006. if err != nil {
  1007. logger.Error("func",
  1008. zap.String("call", "util.ShouldBind"),
  1009. zap.String("error", err.Error()))
  1010. return errors.ParamsError
  1011. }
  1012. return nil
  1013. }
  1014. // 业务处理
  1015. handleServiceTask := func() error {
  1016. tokenInfo, err := utils.GetSubjectValue(ctx)
  1017. if err != nil {
  1018. return err
  1019. }
  1020. // 响应数据
  1021. resp := param_v1.ChargeSpaceBindedListResponse{}
  1022. rpcReq := &v1.ChargeSpaceBindedListRequest{
  1023. GardenId: tokenInfo.GardenId,
  1024. ChargeId: req.ChargeId,
  1025. PageSize: req.PageSize,
  1026. Page: req.Page,
  1027. }
  1028. rpcRsp, err := pb.Garden.ChargeSpaceBindedList(ctx, rpcReq)
  1029. if err != nil {
  1030. s, _ := json.MarshalToString(req)
  1031. logger.Error("func",
  1032. zap.String("call", "pb.Garden.ChargeSpaceBindedList"),
  1033. zap.String("params", s),
  1034. zap.String("error", err.Error()))
  1035. return errors.ErrorTransForm(err)
  1036. }
  1037. if rpcRsp.List == nil {
  1038. rpcRsp.List = make([]*v1.ChargeSpaceData, 0)
  1039. }
  1040. resp.Data = *rpcRsp
  1041. ctx.JSON(http.StatusOK, resp)
  1042. return nil
  1043. }
  1044. // 执行任务
  1045. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1046. }
  1047. //
  1048. // @Summary 可以绑定某项目的车位列表
  1049. // @Description 可以绑定某项目的车位列表
  1050. // @Tags 费用绑定相关
  1051. // @Accept json
  1052. // @Produce json
  1053. // @Param token header string true "token"
  1054. // @Param charge_id query int true "费项id"
  1055. // @Param page query int false " "
  1056. // @Param page_size query int false " "
  1057. // @Success 200 {object} v1.ChargeSpaceNotBindListResponse
  1058. // @Failure 500 {object} base.HTTPError
  1059. // @Router /api/v1/charge/space/can_bind_list [get]
  1060. func (c *Controller) ChargeSpaceNotBindList(ctx *gin.Context) {
  1061. // 解析参数
  1062. req := &param_v1.ChargeSpaceNotBindListRequest{}
  1063. parseParamTask := func() error {
  1064. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeSpaceNotBindListQuery, nil)
  1065. if err != nil {
  1066. logger.Error("func",
  1067. zap.String("call", "util.ShouldBind"),
  1068. zap.String("error", err.Error()))
  1069. return errors.ParamsError
  1070. }
  1071. return nil
  1072. }
  1073. // 业务处理
  1074. handleServiceTask := func() error {
  1075. tokenInfo, err := utils.GetSubjectValue(ctx)
  1076. if err != nil {
  1077. return err
  1078. }
  1079. // 响应数据
  1080. resp := param_v1.ChargeSpaceNotBindListResponse{}
  1081. rpcReq := &v1.ChargeSpaceNotBindListRequest{
  1082. GardenId: tokenInfo.GardenId,
  1083. ChargeId: req.ChargeId,
  1084. PageSize: req.PageSize,
  1085. Page: req.Page,
  1086. }
  1087. rpcRsp, err := pb.Garden.ChargeSpaceNotBindList(ctx, rpcReq)
  1088. if err != nil {
  1089. s, _ := json.MarshalToString(req)
  1090. logger.Error("func",
  1091. zap.String("call", "pb.Garden.ChargeSpaceNotBindList"),
  1092. zap.String("params", s),
  1093. zap.String("error", err.Error()))
  1094. return errors.ErrorTransForm(err)
  1095. }
  1096. if rpcRsp.List == nil {
  1097. rpcRsp.List = make([]*v1.ChargeSpaceData, 0)
  1098. }
  1099. resp.Data = *rpcRsp
  1100. ctx.JSON(http.StatusOK, resp)
  1101. return nil
  1102. }
  1103. // 执行任务
  1104. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1105. }
  1106. //
  1107. // @Summary 绑定了项目的车辆列表
  1108. // @Description 绑定了项目的车辆列表
  1109. // @Tags 费用绑定相关
  1110. // @Accept json
  1111. // @Produce json
  1112. // @Param token header string true "token"
  1113. // @Param charge_id query int true "费项id"
  1114. // @Param page query int false " "
  1115. // @Param page_size query int false " "
  1116. // @Success 200 {object} v1.ChargeVehicleBindedListResponse
  1117. // @Failure 500 {object} base.HTTPError
  1118. // @Router /api/v1/charge/vehicle/binded_list [get]
  1119. func (c *Controller) ChargeVehicleBindedList(ctx *gin.Context) {
  1120. // 解析参数
  1121. req := &param_v1.ChargeVehicleBindedListRequest{}
  1122. parseParamTask := func() error {
  1123. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeVehicleBindedListQuery, nil)
  1124. if err != nil {
  1125. logger.Error("func",
  1126. zap.String("call", "util.ShouldBind"),
  1127. zap.String("error", err.Error()))
  1128. return errors.ParamsError
  1129. }
  1130. return nil
  1131. }
  1132. // 业务处理
  1133. handleServiceTask := func() error {
  1134. tokenInfo, err := utils.GetSubjectValue(ctx)
  1135. if err != nil {
  1136. return err
  1137. }
  1138. // 响应数据
  1139. resp := param_v1.ChargeVehicleBindedListResponse{}
  1140. rpcReq := &v1.ChargeVehicleBindedListRequest{
  1141. GardenId: tokenInfo.GardenId,
  1142. ChargeId: req.ChargeId,
  1143. PageSize: req.PageSize,
  1144. Page: req.Page,
  1145. }
  1146. rpcRsp, err := pb.Garden.ChargeVehicleBindedList(ctx, rpcReq)
  1147. if err != nil {
  1148. s, _ := json.MarshalToString(req)
  1149. logger.Error("func",
  1150. zap.String("call", "pb.Garden.ChargeVehicleBindedList"),
  1151. zap.String("params", s),
  1152. zap.String("error", err.Error()))
  1153. return errors.ErrorTransForm(err)
  1154. }
  1155. if rpcRsp.List == nil {
  1156. rpcRsp.List = make([]*v1.ChargeVehicleData, 0)
  1157. }
  1158. resp.Data = *rpcRsp
  1159. ctx.JSON(http.StatusOK, resp)
  1160. return nil
  1161. }
  1162. // 执行任务
  1163. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1164. }
  1165. //
  1166. // @Summary 可以绑定某项目的车辆列表
  1167. // @Description 可以绑定某项目的车辆列表
  1168. // @Tags 费用绑定相关
  1169. // @Accept json
  1170. // @Produce json
  1171. // @Param token header string true "token"
  1172. // @Param charge_id query int true "费项id"
  1173. // @Param page query int false " "
  1174. // @Param page_size query int false " "
  1175. // @Success 200 {object} v1.ChargeVehicleNotBindListResponse
  1176. // @Failure 500 {object} base.HTTPError
  1177. // @Router /api/v1/charge/vehicle/can_bind_list [get]
  1178. func (c *Controller) ChargeVehicleNotBindList(ctx *gin.Context) {
  1179. // 解析参数
  1180. req := &param_v1.ChargeVehicleNotBindListRequest{}
  1181. parseParamTask := func() error {
  1182. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeVehicleNotBindListQuery, nil)
  1183. if err != nil {
  1184. logger.Error("func",
  1185. zap.String("call", "util.ShouldBind"),
  1186. zap.String("error", err.Error()))
  1187. return errors.ParamsError
  1188. }
  1189. return nil
  1190. }
  1191. // 业务处理
  1192. handleServiceTask := func() error {
  1193. tokenInfo, err := utils.GetSubjectValue(ctx)
  1194. if err != nil {
  1195. return err
  1196. }
  1197. // 响应数据
  1198. resp := param_v1.ChargeVehicleNotBindListResponse{}
  1199. rpcReq := &v1.ChargeVehicleNotBindListRequest{
  1200. GardenId: tokenInfo.GardenId,
  1201. ChargeId: req.ChargeId,
  1202. PageSize: req.PageSize,
  1203. Page: req.Page,
  1204. }
  1205. rpcRsp, err := pb.Garden.ChargeVehicleNotBindList(ctx, rpcReq)
  1206. if err != nil {
  1207. s, _ := json.MarshalToString(req)
  1208. logger.Error("func",
  1209. zap.String("call", "pb.Garden.ChargeVehicleNotBindList"),
  1210. zap.String("params", s),
  1211. zap.String("error", err.Error()))
  1212. return errors.ErrorTransForm(err)
  1213. }
  1214. if rpcRsp.List == nil {
  1215. rpcRsp.List = make([]*v1.ChargeVehicleData, 0)
  1216. }
  1217. resp.Data = *rpcRsp
  1218. ctx.JSON(http.StatusOK, resp)
  1219. return nil
  1220. }
  1221. // 执行任务
  1222. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1223. }
  1224. //
  1225. // @Summary 房屋收费 房屋列表
  1226. // @Description 房屋收费 房屋列表
  1227. // @Tags 对象收费相关
  1228. // @Accept json
  1229. // @Produce json
  1230. // @Param token header string true "token"
  1231. // @Param page query int false " "
  1232. // @Param page_size query int false " "
  1233. // @Success 200 {object} v1.ChargeHouseGroupResponse
  1234. // @Failure 500 {object} base.HTTPError
  1235. // @Router /api/v1/charge/obj_charge/house_list [get]
  1236. func (c *Controller) ChargeHouseGroup(ctx *gin.Context) {
  1237. // 解析参数
  1238. req := &param_v1.ChargeHouseGroupRequest{}
  1239. parseParamTask := func() error {
  1240. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeHouseGroupQuery, nil)
  1241. if err != nil {
  1242. logger.Error("func",
  1243. zap.String("call", "util.ShouldBind"),
  1244. zap.String("error", err.Error()))
  1245. return errors.ParamsError
  1246. }
  1247. return nil
  1248. }
  1249. // 业务处理
  1250. handleServiceTask := func() error {
  1251. tokenInfo, err := utils.GetSubjectValue(ctx)
  1252. if err != nil {
  1253. return err
  1254. }
  1255. // 响应数据
  1256. resp := param_v1.ChargeHouseGroupResponse{}
  1257. rpcReq := &v1.ChargeHouseGroupRequest{
  1258. GardenId: tokenInfo.GardenId,
  1259. PageSize: req.PageSize,
  1260. Page: req.Page,
  1261. }
  1262. rpcRsp, err := pb.Garden.ChargeHouseGroup(ctx, rpcReq)
  1263. if err != nil {
  1264. s, _ := json.MarshalToString(req)
  1265. logger.Error("func",
  1266. zap.String("call", "pb.Garden.ChargeHouseGroup"),
  1267. zap.String("params", s),
  1268. zap.String("error", err.Error()))
  1269. return errors.ErrorTransForm(err)
  1270. }
  1271. if rpcRsp.List == nil {
  1272. rpcRsp.List = make([]*v1.ChargeHouseGroupItem, 0)
  1273. }
  1274. resp.Data = *rpcRsp
  1275. ctx.JSON(http.StatusOK, resp)
  1276. return nil
  1277. }
  1278. // 执行任务
  1279. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1280. }
  1281. //
  1282. // @Summary 批量催缴单
  1283. // @Description 批量催缴单
  1284. // @Tags 对象收费相关
  1285. // @Accept json
  1286. // @Produce json
  1287. // @Param token header string true "token"
  1288. // @Param obj_type query int true "1 房屋 2 车位"
  1289. // @Success 200 {object} v1.BatchUrgeResponse
  1290. // @Failure 500 {object} base.HTTPError
  1291. // @Router /api/v1/charge/batch_urge [get]
  1292. func (c *Controller) BatchUrge(ctx *gin.Context) {
  1293. // 解析参数
  1294. req := &param_v1.BatchUrgeRequest{}
  1295. list := []param_v1.BatchUrgeItem{}
  1296. parseParamTask := func() error {
  1297. err := util.ShouldBind(ctx, &req.Header, nil, &req.BatchUrgeQuery, nil)
  1298. if err != nil {
  1299. logger.Error("func",
  1300. zap.String("call", "util.ShouldBind"),
  1301. zap.String("error", err.Error()))
  1302. return errors.ParamsError
  1303. }
  1304. return nil
  1305. }
  1306. // 业务处理
  1307. handleServiceTask := func() error {
  1308. tokenInfo, err := utils.GetSubjectValue(ctx)
  1309. if err != nil {
  1310. return err
  1311. }
  1312. if req.ObjType == 1 {
  1313. rpcReq := &v1.ChargeHouseGroupRequest{
  1314. GardenId: tokenInfo.GardenId,
  1315. Page: -1,
  1316. PageSize: -1,
  1317. }
  1318. rpcRsp, err := pb.Garden.ChargeHouseGroup(ctx, rpcReq)
  1319. if err != nil {
  1320. s, _ := json.MarshalToString(req)
  1321. logger.Error("func",
  1322. zap.String("call", "pb.Garden.ChargeHouseGroup"),
  1323. zap.String("params", s),
  1324. zap.String("error", err.Error()))
  1325. return errors.ErrorTransForm(err)
  1326. }
  1327. for _, v := range rpcRsp.List {
  1328. if !v.HasUnpayBill {
  1329. continue
  1330. }
  1331. mreq := &v1.ChargeUnpayListRequest{
  1332. GardenId: tokenInfo.GardenId,
  1333. PageSize: -1,
  1334. Page: -1,
  1335. ObjType: req.ObjType,
  1336. ObjId: v.HouseId,
  1337. }
  1338. mreply, err := pb.Garden.ChargeUnpayList(ctx, mreq)
  1339. if err != nil {
  1340. s, _ := json.MarshalToString(req)
  1341. logger.Error("func",
  1342. zap.String("call", "pb.Garden.ChargeUnpayList"),
  1343. zap.String("params", s),
  1344. zap.String("error", err.Error()))
  1345. return errors.ErrorTransForm(err)
  1346. }
  1347. fees := []param_v1.BatchUrgeFeeItem{}
  1348. for _, bill := range mreply.List {
  1349. item := param_v1.BatchUrgeFeeItem{
  1350. ChargeName: bill.ChargeName,
  1351. ChargeType: bill.ChargeType,
  1352. Fee: bill.UnpayAmount,
  1353. }
  1354. fees = append(fees, item)
  1355. }
  1356. item := param_v1.BatchUrgeItem{
  1357. ObjName: fmt.Sprintf("%d 房屋", v.HouseName),
  1358. List: fees,
  1359. }
  1360. list = append(list, item)
  1361. }
  1362. } else if req.ObjType == 2 {
  1363. rpcReq := &v1.ChargeSpaceGroupRequest{
  1364. GardenId: tokenInfo.GardenId,
  1365. Page: -1,
  1366. PageSize: -1,
  1367. }
  1368. rpcRsp, err := pb.Garden.ChargeSpaceGroup(ctx, rpcReq)
  1369. if err != nil {
  1370. s, _ := json.MarshalToString(req)
  1371. logger.Error("func",
  1372. zap.String("call", "pb.Garden.ChargeSpaceGroup"),
  1373. zap.String("params", s),
  1374. zap.String("error", err.Error()))
  1375. return errors.ErrorTransForm(err)
  1376. }
  1377. for _, v := range rpcRsp.List {
  1378. if !v.HasUnpayBill {
  1379. continue
  1380. }
  1381. mreq := &v1.ChargeUnpayListRequest{
  1382. GardenId: tokenInfo.GardenId,
  1383. PageSize: -1,
  1384. Page: -1,
  1385. ObjType: req.ObjType,
  1386. ObjId: v.SpaceId,
  1387. }
  1388. mreply, err := pb.Garden.ChargeUnpayList(ctx, mreq)
  1389. if err != nil {
  1390. s, _ := json.MarshalToString(req)
  1391. logger.Error("func",
  1392. zap.String("call", "pb.Garden.ChargeUnpayList"),
  1393. zap.String("params", s),
  1394. zap.String("error", err.Error()))
  1395. return errors.ErrorTransForm(err)
  1396. }
  1397. fees := []param_v1.BatchUrgeFeeItem{}
  1398. for _, bill := range mreply.List {
  1399. item := param_v1.BatchUrgeFeeItem{
  1400. ChargeName: bill.ChargeName,
  1401. ChargeType: bill.ChargeType,
  1402. Fee: bill.UnpayAmount,
  1403. }
  1404. fees = append(fees, item)
  1405. }
  1406. item := param_v1.BatchUrgeItem{
  1407. ObjName: fmt.Sprintf("%d 车位", v.SpaceNumber),
  1408. List: fees,
  1409. }
  1410. list = append(list, item)
  1411. }
  1412. } else {
  1413. return errors.ParamsError
  1414. }
  1415. resp := param_v1.BatchUrgeResponse{}
  1416. resp.Data = param_v1.BatchUrgeData{List: list}
  1417. ctx.JSON(http.StatusOK, resp)
  1418. return nil
  1419. }
  1420. // 执行任务
  1421. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1422. }
  1423. //
  1424. // @Summary 车位收费 车位列表
  1425. // @Description 车位收费 车位列表
  1426. // @Tags 对象收费相关
  1427. // @Accept json
  1428. // @Produce json
  1429. // @Param token header string true "token"
  1430. // @Param page query int false " "
  1431. // @Param page_size query int false " "
  1432. // @Success 200 {object} v1.ChargeSpaceGroupResponse
  1433. // @Failure 500 {object} base.HTTPError
  1434. // @Router /api/v1/charge/obj_charge/space_list [get]
  1435. func (c *Controller) ChargeSpaceGroup(ctx *gin.Context) {
  1436. // 解析参数
  1437. req := &param_v1.ChargeSpaceGroupRequest{}
  1438. parseParamTask := func() error {
  1439. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeSpaceGroupQuery, nil)
  1440. if err != nil {
  1441. logger.Error("func",
  1442. zap.String("call", "util.ShouldBind"),
  1443. zap.String("error", err.Error()))
  1444. return errors.ParamsError
  1445. }
  1446. return nil
  1447. }
  1448. // 业务处理
  1449. handleServiceTask := func() error {
  1450. tokenInfo, err := utils.GetSubjectValue(ctx)
  1451. if err != nil {
  1452. return err
  1453. }
  1454. // 响应数据
  1455. resp := param_v1.ChargeSpaceGroupResponse{}
  1456. rpcReq := &v1.ChargeSpaceGroupRequest{
  1457. GardenId: tokenInfo.GardenId,
  1458. PageSize: req.PageSize,
  1459. Page: req.Page,
  1460. }
  1461. rpcRsp, err := pb.Garden.ChargeSpaceGroup(ctx, rpcReq)
  1462. if err != nil {
  1463. s, _ := json.MarshalToString(req)
  1464. logger.Error("func",
  1465. zap.String("call", "pb.Garden.ChargeSpaceGroup"),
  1466. zap.String("params", s),
  1467. zap.String("error", err.Error()))
  1468. return errors.ErrorTransForm(err)
  1469. }
  1470. if rpcRsp.List == nil {
  1471. rpcRsp.List = make([]*v1.ChargeSpaceGroupItem, 0)
  1472. }
  1473. resp.Data = *rpcRsp
  1474. ctx.JSON(http.StatusOK, resp)
  1475. return nil
  1476. }
  1477. // 执行任务
  1478. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1479. }
  1480. //
  1481. // @Summary 车辆收费 车辆列表
  1482. // @Description 车辆收费 车辆列表
  1483. // @Tags 对象收费相关
  1484. // @Accept json
  1485. // @Produce json
  1486. // @Param token header string true "token"
  1487. // @Param page query int false " "
  1488. // @Param page_size query int false " "
  1489. // @Success 200 {object} v1.ChargeVehicleGroupResponse
  1490. // @Failure 500 {object} base.HTTPError
  1491. // @Router /api/v1/charge/obj_charge/vehicle_list [get]
  1492. func (c *Controller) ChargeVehicleGroup(ctx *gin.Context) {
  1493. // 解析参数
  1494. req := &param_v1.ChargeVehicleGroupRequest{}
  1495. parseParamTask := func() error {
  1496. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeVehicleGroupQuery, nil)
  1497. if err != nil {
  1498. logger.Error("func",
  1499. zap.String("call", "util.ShouldBind"),
  1500. zap.String("error", err.Error()))
  1501. return errors.ParamsError
  1502. }
  1503. return nil
  1504. }
  1505. // 业务处理
  1506. handleServiceTask := func() error {
  1507. tokenInfo, err := utils.GetSubjectValue(ctx)
  1508. if err != nil {
  1509. return err
  1510. }
  1511. // 响应数据
  1512. resp := param_v1.ChargeVehicleGroupResponse{}
  1513. rpcReq := &v1.ChargeVehicleGroupRequest{
  1514. GardenId: tokenInfo.GardenId,
  1515. PageSize: req.PageSize,
  1516. Page: req.Page,
  1517. }
  1518. rpcRsp, err := pb.Garden.ChargeVehicleGroup(ctx, rpcReq)
  1519. if err != nil {
  1520. s, _ := json.MarshalToString(req)
  1521. logger.Error("func",
  1522. zap.String("call", "pb.Garden.ChargeVehicleGroup"),
  1523. zap.String("params", s),
  1524. zap.String("error", err.Error()))
  1525. return errors.ErrorTransForm(err)
  1526. }
  1527. if rpcRsp.List == nil {
  1528. rpcRsp.List = make([]*v1.ChargeVehicleGroupItem, 0)
  1529. }
  1530. resp.Data = *rpcRsp
  1531. ctx.JSON(http.StatusOK, resp)
  1532. return nil
  1533. }
  1534. // 执行任务
  1535. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1536. }
  1537. //
  1538. // @Summary 欠费线下缴费
  1539. // @Description 欠费线下缴费
  1540. // @Tags 对象收费相关
  1541. // @Accept json
  1542. // @Produce json
  1543. // @Param token header string true "token"
  1544. // @Param body body v1.ChargeBillPayBody true " "
  1545. // @Success 200 {object} v1.ChargeBillPayResponse
  1546. // @Failure 500 {object} base.HTTPError
  1547. // @Router /api/v1/charge/obj_charge/pay [put]
  1548. func (c *Controller) ChargeBillPay(ctx *gin.Context) {
  1549. // 解析参数
  1550. req := &param_v1.ChargeBillPayRequest{}
  1551. parseParamTask := func() error {
  1552. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeBillPayBody)
  1553. if err != nil {
  1554. logger.Error("func",
  1555. zap.String("call", "util.ShouldBind"),
  1556. zap.String("error", err.Error()))
  1557. return errors.ParamsError
  1558. }
  1559. return nil
  1560. }
  1561. // 业务处理
  1562. handleServiceTask := func() error {
  1563. tokenInfo, err := utils.GetSubjectValue(ctx)
  1564. if err != nil {
  1565. return err
  1566. }
  1567. // 响应数据
  1568. resp := param_v1.ChargeBillPayResponse{}
  1569. rpcReq := &v1.ChargeBillPayRequest{
  1570. GardenId: tokenInfo.GardenId,
  1571. BindIds: req.BindIds,
  1572. ShouldPayAmount: req.ShouldPayAmount,
  1573. PayAmount: req.PayAmount,
  1574. PayType: req.PayType,
  1575. Comment: req.Comment,
  1576. }
  1577. rpcRsp, err := pb.Garden.ChargeBillPay(ctx, rpcReq)
  1578. if err != nil {
  1579. s, _ := json.MarshalToString(req)
  1580. logger.Error("func",
  1581. zap.String("call", "pb.Garden.ChargeBillPay"),
  1582. zap.String("params", s),
  1583. zap.String("error", err.Error()))
  1584. return errors.ErrorTransForm(err)
  1585. }
  1586. resp.Data = *rpcRsp
  1587. ctx.JSON(http.StatusOK, resp)
  1588. return nil
  1589. }
  1590. // 执行任务
  1591. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1592. }
  1593. //
  1594. // @Summary 欠费缴费欠费列表
  1595. // @Description 欠费缴费欠费列表
  1596. // @Tags 对象收费相关
  1597. // @Accept json
  1598. // @Produce json
  1599. // @Param token header string true "token"
  1600. // @Param obj_id query int true "房屋/车位/车辆id"
  1601. // @Param obj_type query int true "1 房屋 2 车位 3 车辆 "
  1602. // @Param page query int false " "
  1603. // @Param page_size query int false " "
  1604. // @Success 200 {object} v1.ChargeUnpayListResponse
  1605. // @Failure 500 {object} base.HTTPError
  1606. // @Router /api/v1/charge/obj_charge/unpay_list [get]
  1607. func (c *Controller) ChargeUnpayList(ctx *gin.Context) {
  1608. // 解析参数
  1609. req := &param_v1.ChargeUnpayListRequest{}
  1610. parseParamTask := func() error {
  1611. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeUnpayListQuery, nil)
  1612. if err != nil {
  1613. logger.Error("func",
  1614. zap.String("call", "util.ShouldBind"),
  1615. zap.String("error", err.Error()))
  1616. return errors.ParamsError
  1617. }
  1618. return nil
  1619. }
  1620. // 业务处理
  1621. handleServiceTask := func() error {
  1622. tokenInfo, err := utils.GetSubjectValue(ctx)
  1623. if err != nil {
  1624. return err
  1625. }
  1626. // 响应数据
  1627. resp := param_v1.ChargeUnpayListResponse{}
  1628. rpcReq := &v1.ChargeUnpayListRequest{
  1629. GardenId: tokenInfo.GardenId,
  1630. PageSize: req.PageSize,
  1631. Page: req.Page,
  1632. ObjType: req.ObjType,
  1633. ObjId: req.ObjId,
  1634. }
  1635. rpcRsp, err := pb.Garden.ChargeUnpayList(ctx, rpcReq)
  1636. if err != nil {
  1637. s, _ := json.MarshalToString(req)
  1638. logger.Error("func",
  1639. zap.String("call", "pb.Garden.ChargeUnpayList"),
  1640. zap.String("params", s),
  1641. zap.String("error", err.Error()))
  1642. return errors.ErrorTransForm(err)
  1643. }
  1644. if rpcRsp.List == nil {
  1645. rpcRsp.List = make([]*v1.ChargeUnpayItem, 0)
  1646. }
  1647. resp.Data = *rpcRsp
  1648. ctx.JSON(http.StatusOK, resp)
  1649. return nil
  1650. }
  1651. // 执行任务
  1652. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1653. }
  1654. //
  1655. // @Summary 查看费用,费项列表
  1656. // @Description 查看费用,费项列表
  1657. // @Tags 对象收费相关
  1658. // @Accept json
  1659. // @Produce json
  1660. // @Param token header string true "token"
  1661. // @Param obj_id query int true "房屋/车位/车辆id"
  1662. // @Param obj_type query int true "1 房屋 2 车位 3 车辆 "
  1663. // @Param page query int false " "
  1664. // @Param page_size query int false " "
  1665. // @Success 200 {object} v1.ChargeListResponse
  1666. // @Failure 500 {object} base.HTTPError
  1667. // @Router /api/v1/charge/obj_charge/charge_list [get]
  1668. func (c *Controller) ChargeList(ctx *gin.Context) {
  1669. // 解析参数
  1670. req := &param_v1.ChargeListRequest{}
  1671. parseParamTask := func() error {
  1672. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeListQuery, nil)
  1673. if err != nil {
  1674. logger.Error("func",
  1675. zap.String("call", "util.ShouldBind"),
  1676. zap.String("error", err.Error()))
  1677. return errors.ParamsError
  1678. }
  1679. return nil
  1680. }
  1681. // 业务处理
  1682. handleServiceTask := func() error {
  1683. tokenInfo, err := utils.GetSubjectValue(ctx)
  1684. if err != nil {
  1685. return err
  1686. }
  1687. // 响应数据
  1688. resp := param_v1.ChargeListResponse{}
  1689. rpcReq := &v1.ChargeListRequest{
  1690. GardenId: tokenInfo.GardenId,
  1691. PageSize: req.PageSize,
  1692. Page: req.Page,
  1693. ObjType: req.ObjType,
  1694. ObjId: req.ObjId,
  1695. }
  1696. rpcRsp, err := pb.Garden.ChargeList(ctx, rpcReq)
  1697. if err != nil {
  1698. s, _ := json.MarshalToString(req)
  1699. logger.Error("func",
  1700. zap.String("call", "pb.Garden.ChargeList"),
  1701. zap.String("params", s),
  1702. zap.String("error", err.Error()))
  1703. return errors.ErrorTransForm(err)
  1704. }
  1705. if rpcRsp.List == nil {
  1706. rpcRsp.List = make([]*v1.ChargeItem, 0)
  1707. }
  1708. resp.Data = *rpcRsp
  1709. ctx.JSON(http.StatusOK, resp)
  1710. return nil
  1711. }
  1712. // 执行任务
  1713. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1714. }
  1715. //
  1716. // @Summary 对象的某费项下的待缴账单列表
  1717. // @Description 对象的某费项下的待缴账单列表
  1718. // @Tags 对象收费相关
  1719. // @Accept json
  1720. // @Produce json
  1721. // @Param token header string true "token"
  1722. // @Param bind_id query int true "绑定关系id"
  1723. // @Param page query int false " "
  1724. // @Param page_size query int false " "
  1725. // @Success 200 {object} v1.ChargeBillListResponse
  1726. // @Failure 500 {object} base.HTTPError
  1727. // @Router /api/v1/charge/obj_charge/bill_list [get]
  1728. func (c *Controller) ChargeBillList(ctx *gin.Context) {
  1729. // 解析参数
  1730. req := &param_v1.ChargeBillListRequest{}
  1731. parseParamTask := func() error {
  1732. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeBillListQuery, nil)
  1733. if err != nil {
  1734. logger.Error("func",
  1735. zap.String("call", "util.ShouldBind"),
  1736. zap.String("error", err.Error()))
  1737. return errors.ParamsError
  1738. }
  1739. return nil
  1740. }
  1741. // 业务处理
  1742. handleServiceTask := func() error {
  1743. tokenInfo, err := utils.GetSubjectValue(ctx)
  1744. if err != nil {
  1745. return err
  1746. }
  1747. // 响应数据
  1748. resp := param_v1.ChargeBillListResponse{}
  1749. rpcReq := &v1.ChargeBillListRequest{
  1750. GardenId: tokenInfo.GardenId,
  1751. PageSize: req.PageSize,
  1752. Page: req.Page,
  1753. BindId: req.BindId,
  1754. }
  1755. rpcRsp, err := pb.Garden.ChargeBillList(ctx, rpcReq)
  1756. if err != nil {
  1757. s, _ := json.MarshalToString(req)
  1758. logger.Error("func",
  1759. zap.String("call", "pb.Garden.ChargeBillList"),
  1760. zap.String("params", s),
  1761. zap.String("error", err.Error()))
  1762. return errors.ErrorTransForm(err)
  1763. }
  1764. if rpcRsp.List == nil {
  1765. rpcRsp.List = make([]*v1.ChargeBillItem, 0)
  1766. }
  1767. resp.Data = *rpcRsp
  1768. ctx.JSON(http.StatusOK, resp)
  1769. return nil
  1770. }
  1771. // 执行任务
  1772. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1773. }
  1774. //
  1775. // @Summary 手动生成账单,仅周期性费用和水电气可以生成
  1776. // @Description 手动生成账单,仅周期性费用和水电气可以生成
  1777. // @Tags 对象收费相关
  1778. // @Accept json
  1779. // @Produce json
  1780. // @Param token header string true "token"
  1781. // @Param body body v1.ChargeGenerateBillBody true " "
  1782. // @Success 200 {object} v1.ChargeGenerateBillResponse
  1783. // @Failure 500 {object} base.HTTPError
  1784. // @Router /api/v1/charge/obj_charge/bill [put]
  1785. func (c *Controller) ChargeGenerateBill(ctx *gin.Context) {
  1786. // 解析参数
  1787. req := &param_v1.ChargeGenerateBillRequest{}
  1788. parseParamTask := func() error {
  1789. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeGenerateBillBody)
  1790. if err != nil {
  1791. logger.Error("func",
  1792. zap.String("call", "util.ShouldBind"),
  1793. zap.String("error", err.Error()))
  1794. return errors.ParamsError
  1795. }
  1796. return nil
  1797. }
  1798. // 业务处理
  1799. handleServiceTask := func() error {
  1800. tokenInfo, err := utils.GetSubjectValue(ctx)
  1801. if err != nil {
  1802. return err
  1803. }
  1804. // 响应数据
  1805. resp := param_v1.ChargeGenerateBillResponse{}
  1806. rpcReq := &v1.ChargeGenerateBillRequest{
  1807. GardenId: tokenInfo.GardenId,
  1808. End: req.End,
  1809. BindId: req.BindId,
  1810. }
  1811. _, err = pb.Garden.ChargeGenerateBill(ctx, rpcReq)
  1812. if err != nil {
  1813. s, _ := json.MarshalToString(req)
  1814. logger.Error("func",
  1815. zap.String("call", "pb.Garden.ChargeGenerateBill"),
  1816. zap.String("params", s),
  1817. zap.String("error", err.Error()))
  1818. return errors.ErrorTransForm(err)
  1819. }
  1820. ctx.JSON(http.StatusOK, resp)
  1821. return nil
  1822. }
  1823. // 执行任务
  1824. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1825. }
  1826. //
  1827. // @Summary 变更时间
  1828. // @Description 变更时间
  1829. // @Tags 对象收费相关
  1830. // @Accept json
  1831. // @Produce json
  1832. // @Param token header string true "token"
  1833. // @Param body body v1.ChargeTimeSetBody true " "
  1834. // @Success 200 {object} v1.ChargeTimeSetResponse
  1835. // @Failure 500 {object} base.HTTPError
  1836. // @Router /api/v1/charge/obj_charge/time [put]
  1837. func (c *Controller) ChargeTimeSet(ctx *gin.Context) {
  1838. // 解析参数
  1839. req := &param_v1.ChargeTimeSetRequest{}
  1840. parseParamTask := func() error {
  1841. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeTimeSetBody)
  1842. if err != nil {
  1843. logger.Error("func",
  1844. zap.String("call", "util.ShouldBind"),
  1845. zap.String("error", err.Error()))
  1846. return errors.ParamsError
  1847. }
  1848. return nil
  1849. }
  1850. // 业务处理
  1851. handleServiceTask := func() error {
  1852. tokenInfo, err := utils.GetSubjectValue(ctx)
  1853. if err != nil {
  1854. return err
  1855. }
  1856. // 响应数据
  1857. resp := param_v1.ChargeTimeSetResponse{}
  1858. rpcReq := &v1.ChargeTimeSetRequest{
  1859. GardenId: tokenInfo.GardenId,
  1860. Start: req.Start,
  1861. End: req.End,
  1862. BindId: req.BindId,
  1863. }
  1864. _, err = pb.Garden.ChargeTimeSet(ctx, rpcReq)
  1865. if err != nil {
  1866. s, _ := json.MarshalToString(req)
  1867. logger.Error("func",
  1868. zap.String("call", "pb.Garden.ChargeTimeSet"),
  1869. zap.String("params", s),
  1870. zap.String("error", err.Error()))
  1871. return errors.ErrorTransForm(err)
  1872. }
  1873. ctx.JSON(http.StatusOK, resp)
  1874. return nil
  1875. }
  1876. // 执行任务
  1877. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1878. }
  1879. // @Summary 小票和收据信息
  1880. // @Description 小票和收据信息
  1881. // @Tags 对象收费相关
  1882. // @Accept json
  1883. // @Produce json
  1884. // @Param token header string true "token"
  1885. // @Param order_id query string true "订单号 "
  1886. // @Success 200 {object} v1.ChargeOrderTicketResponse
  1887. // @Failure 500 {object} base.HTTPError
  1888. // @Router /api/v1/charge/obj_charge/ticket [get]
  1889. func (c *Controller) ChargeOrderTicket(ctx *gin.Context) {
  1890. // 解析参数
  1891. req := &param_v1.ChargeOrderTicketRequest{}
  1892. parseParamTask := func() error {
  1893. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeOrderTicketQuery, nil)
  1894. if err != nil {
  1895. logger.Error("func",
  1896. zap.String("call", "util.ShouldBind"),
  1897. zap.String("error", err.Error()))
  1898. return errors.ParamsError
  1899. }
  1900. return nil
  1901. }
  1902. // 业务处理
  1903. handleServiceTask := func() error {
  1904. tokenInfo, err := utils.GetSubjectValue(ctx)
  1905. if err != nil {
  1906. return err
  1907. }
  1908. // 响应数据
  1909. resp := param_v1.ChargeOrderTicketResponse{}
  1910. rpcReq := &v1.ChargeOrderTicketRequest{
  1911. GardenId: tokenInfo.GardenId,
  1912. OrderId: req.OrderId,
  1913. }
  1914. rpcRsp, err := pb.Garden.ChargeOrderTicket(ctx, rpcReq)
  1915. if err != nil {
  1916. s, _ := json.MarshalToString(req)
  1917. logger.Error("func",
  1918. zap.String("call", "pb.Garden.ChargeOrderTicket"),
  1919. zap.String("params", s),
  1920. zap.String("error", err.Error()))
  1921. return errors.ErrorTransForm(err)
  1922. }
  1923. if rpcRsp.List == nil {
  1924. rpcRsp.List = make([]*v1.ChargeOrderTicketItem, 0)
  1925. }
  1926. resp.Data = *rpcRsp
  1927. ctx.JSON(http.StatusOK, resp)
  1928. return nil
  1929. }
  1930. // 执行任务
  1931. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1932. }
  1933. // @Summary 预缴物业费或车位费前获取对应的金额信息
  1934. // @Description 预缴物业费或车位费前获取对应的金额信息
  1935. // @Tags 对象收费相关
  1936. // @Accept json
  1937. // @Produce json
  1938. // @Param token header string true "token"
  1939. // @Param bind_id query int true "关系id"
  1940. // @Param months query int true "缴费月数"
  1941. // @Success 200 {object} v1.ChargePrePayInfoResponse
  1942. // @Failure 500 {object} base.HTTPError
  1943. // @Router /api/v1/charge/obj_charge/pre_pay_info [get]
  1944. func (c *Controller) ChargePrePayInfo(ctx *gin.Context) {
  1945. // 解析参数
  1946. req := &param_v1.ChargePrePayInfoRequest{}
  1947. parseParamTask := func() error {
  1948. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargePrePayInfoQuery, nil)
  1949. if err != nil {
  1950. logger.Error("func",
  1951. zap.String("call", "util.ShouldBind"),
  1952. zap.String("error", err.Error()))
  1953. return errors.ParamsError
  1954. }
  1955. return nil
  1956. }
  1957. // 业务处理
  1958. handleServiceTask := func() error {
  1959. tokenInfo, err := utils.GetSubjectValue(ctx)
  1960. if err != nil {
  1961. return err
  1962. }
  1963. // 响应数据
  1964. resp := param_v1.ChargePrePayInfoResponse{}
  1965. rpcReq := &v1.ChargePrePayInfoRequest{
  1966. GardenId: tokenInfo.GardenId,
  1967. BindId: req.BindId,
  1968. Months: req.Months,
  1969. }
  1970. rpcRsp, err := pb.Garden.ChargePrePayInfo(ctx, rpcReq)
  1971. if err != nil {
  1972. s, _ := json.MarshalToString(req)
  1973. logger.Error("func",
  1974. zap.String("call", "pb.Garden.ChargePrePayInfo"),
  1975. zap.String("params", s),
  1976. zap.String("error", err.Error()))
  1977. return errors.ErrorTransForm(err)
  1978. }
  1979. resp.Data = *rpcRsp
  1980. ctx.JSON(http.StatusOK, resp)
  1981. return nil
  1982. }
  1983. // 执行任务
  1984. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1985. }
  1986. //
  1987. // @Summary 线下预缴物业费或车位费
  1988. // @Description 线下预缴物业费或车位费
  1989. // @Tags 对象收费相关
  1990. // @Accept json
  1991. // @Produce json
  1992. // @Param token header string true "token"
  1993. // @Param body body v1.ChargePrePayBody true " "
  1994. // @Success 200 {object} v1.ChargePrePayResponse
  1995. // @Failure 500 {object} base.HTTPError
  1996. // @Router /api/v1/charge/obj_charge/pre_pay [put]
  1997. func (c *Controller) ChargePrePay(ctx *gin.Context) {
  1998. // 解析参数
  1999. req := &param_v1.ChargePrePayRequest{}
  2000. parseParamTask := func() error {
  2001. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargePrePayBody)
  2002. if err != nil {
  2003. logger.Error("func",
  2004. zap.String("call", "util.ShouldBind"),
  2005. zap.String("error", err.Error()))
  2006. return errors.ParamsError
  2007. }
  2008. return nil
  2009. }
  2010. // 业务处理
  2011. handleServiceTask := func() error {
  2012. tokenInfo, err := utils.GetSubjectValue(ctx)
  2013. if err != nil {
  2014. return err
  2015. }
  2016. // 响应数据
  2017. resp := param_v1.ChargePrePayResponse{}
  2018. rpcReq := &v1.ChargePrePayRequest{
  2019. GardenId: tokenInfo.GardenId,
  2020. BindId: req.BindId,
  2021. ShouldPayAmount: req.ShouldPayAmount,
  2022. PayAmount: req.PayAmount,
  2023. PayType: req.PayType,
  2024. Comment: req.Comment,
  2025. Months: req.Months,
  2026. }
  2027. rpcRsp, err := pb.Garden.ChargePrePay(ctx, rpcReq)
  2028. if err != nil {
  2029. s, _ := json.MarshalToString(req)
  2030. logger.Error("func",
  2031. zap.String("call", "pb.Garden.ChargePrePay"),
  2032. zap.String("params", s),
  2033. zap.String("error", err.Error()))
  2034. return errors.ErrorTransForm(err)
  2035. }
  2036. resp.Data = *rpcRsp
  2037. ctx.JSON(http.StatusOK, resp)
  2038. return nil
  2039. }
  2040. // 执行任务
  2041. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2042. }
  2043. // @Summary 应收账单中的对象列表(已废弃)
  2044. // @Description 应收账单中的对象列表(已废弃)
  2045. // @Tags 应收账单
  2046. // @Accept json
  2047. // @Produce json
  2048. // @Param token header string true "token"
  2049. // @Param page query int false " "
  2050. // @Param page_size query int false " "
  2051. // @Success 200 {object} v1.ChargeBillObjListResponse
  2052. // @Failure 500 {object} base.HTTPError
  2053. // @Router /api/v1/charge/unpay_bill/obj_list [get]
  2054. func (c *Controller) ChargeBillObjList(ctx *gin.Context) {
  2055. // 解析参数
  2056. req := &param_v1.ChargeBillObjListRequest{}
  2057. parseParamTask := func() error {
  2058. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeBillObjListQuery, nil)
  2059. if err != nil {
  2060. logger.Error("func",
  2061. zap.String("call", "util.ShouldBind"),
  2062. zap.String("error", err.Error()))
  2063. return errors.ParamsError
  2064. }
  2065. return nil
  2066. }
  2067. // 业务处理
  2068. handleServiceTask := func() error {
  2069. tokenInfo, err := utils.GetSubjectValue(ctx)
  2070. if err != nil {
  2071. return err
  2072. }
  2073. // 响应数据
  2074. resp := param_v1.ChargeBillObjListResponse{}
  2075. rpcReq := &v1.ChargeBillObjListRequest{
  2076. GardenId: tokenInfo.GardenId,
  2077. PageSize: req.PageSize,
  2078. Page: req.Page,
  2079. }
  2080. rpcRsp, err := pb.Garden.ChargeBillObjList(ctx, rpcReq)
  2081. if err != nil {
  2082. s, _ := json.MarshalToString(req)
  2083. logger.Error("func",
  2084. zap.String("call", "pb.Garden.ChargeBillObjList"),
  2085. zap.String("params", s),
  2086. zap.String("error", err.Error()))
  2087. return errors.ErrorTransForm(err)
  2088. }
  2089. if rpcRsp.List == nil {
  2090. rpcRsp.List = make([]*v1.ChargeBillObjItem, 0)
  2091. }
  2092. resp.Data = *rpcRsp
  2093. ctx.JSON(http.StatusOK, resp)
  2094. return nil
  2095. }
  2096. // 执行任务
  2097. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2098. }
  2099. // @Summary 应收账单平铺列表
  2100. // @Description 应收账单平铺列表
  2101. // @Tags 应收账单
  2102. // @Accept json
  2103. // @Produce json
  2104. // @Param token header string true "token"
  2105. // @Param page query int false " "
  2106. // @Param page_size query int false " "
  2107. // @Param obj_id query int false "房屋/车位/车辆id"
  2108. // @Param obj_type query int false "1 房屋 2 车位 3 车辆 "
  2109. // @Param charge_type query int false "费用类型 费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他"
  2110. // @Param obj_name query string false "对象名"
  2111. // @Param charge_name query string false "费项名"
  2112. // @Success 200 {object} v1.ChargeObjBillListResponse
  2113. // @Failure 500 {object} base.HTTPError
  2114. // @Router /api/v1/charge/unpay_bill/obj_bill_list [get]
  2115. func (c *Controller) ChargeObjBillList(ctx *gin.Context) {
  2116. // 解析参数
  2117. req := &param_v1.ChargeObjBillListRequest{}
  2118. parseParamTask := func() error {
  2119. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeObjBillListQuery, nil)
  2120. if err != nil {
  2121. logger.Error("func",
  2122. zap.String("call", "util.ShouldBind"),
  2123. zap.String("error", err.Error()))
  2124. return errors.ParamsError
  2125. }
  2126. return nil
  2127. }
  2128. // 业务处理
  2129. handleServiceTask := func() error {
  2130. tokenInfo, err := utils.GetSubjectValue(ctx)
  2131. if err != nil {
  2132. return err
  2133. }
  2134. // 响应数据
  2135. resp := param_v1.ChargeObjBillListResponse{}
  2136. rpcReq := &v1.ChargeObjBillListRequest{
  2137. GardenId: tokenInfo.GardenId,
  2138. PageSize: req.PageSize,
  2139. Page: req.Page,
  2140. ObjType: req.ObjType,
  2141. ObjId: req.ObjId,
  2142. ObjName: req.ObjName,
  2143. ChargeType: req.ChargeType,
  2144. ChargeName: req.ChargeName,
  2145. //All:true,
  2146. }
  2147. rpcRsp, err := pb.Garden.ChargeObjBillList(ctx, rpcReq)
  2148. if err != nil {
  2149. s, _ := json.MarshalToString(req)
  2150. logger.Error("func",
  2151. zap.String("call", "pb.Garden.ChargeObjBillList"),
  2152. zap.String("params", s),
  2153. zap.String("error", err.Error()))
  2154. return errors.ErrorTransForm(err)
  2155. }
  2156. if rpcRsp.List == nil {
  2157. rpcRsp.List = make([]*v1.ChargeBillItem, 0)
  2158. }
  2159. resp.Data = *rpcRsp
  2160. ctx.JSON(http.StatusOK, resp)
  2161. return nil
  2162. }
  2163. // 执行任务
  2164. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2165. }
  2166. // @Summary 作废账单
  2167. // @Description 作废账单
  2168. // @Tags 应收账单
  2169. // @Accept json
  2170. // @Produce json
  2171. // @Param token header string true "token"
  2172. // @Param body body v1.ChargeDelBillBody true " "
  2173. // @Success 200 {object} v1.ChargeDelBillResponse
  2174. // @Failure 500 {object} base.HTTPError
  2175. // @Router /api/v1/charge/unpay_bill/discard [put]
  2176. func (c *Controller) ChargeDelBill(ctx *gin.Context) {
  2177. // 解析参数
  2178. req := &param_v1.ChargeDelBillRequest{}
  2179. parseParamTask := func() error {
  2180. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeDelBillBody)
  2181. if err != nil {
  2182. logger.Error("func",
  2183. zap.String("call", "util.ShouldBind"),
  2184. zap.String("error", err.Error()))
  2185. return errors.ParamsError
  2186. }
  2187. return nil
  2188. }
  2189. // 业务处理
  2190. handleServiceTask := func() error {
  2191. tokenInfo, err := utils.GetSubjectValue(ctx)
  2192. if err != nil {
  2193. return err
  2194. }
  2195. // 响应数据
  2196. resp := param_v1.ChargeDelBillResponse{}
  2197. rpcReq := &v1.ChargeDelBillRequest{
  2198. GardenId: tokenInfo.GardenId,
  2199. BillId: req.BillId,
  2200. DelReason: req.DelReason,
  2201. }
  2202. _, err = pb.Garden.ChargeDelBill(ctx, rpcReq)
  2203. if err != nil {
  2204. s, _ := json.MarshalToString(req)
  2205. logger.Error("func",
  2206. zap.String("call", "pb.Garden.ChargeDelBill"),
  2207. zap.String("params", s),
  2208. zap.String("error", err.Error()))
  2209. return errors.ErrorTransForm(err)
  2210. }
  2211. ctx.JSON(http.StatusOK, resp)
  2212. return nil
  2213. }
  2214. // 执行任务
  2215. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2216. }
  2217. // @Summary 一键催缴
  2218. // @Description 一键催缴
  2219. // @Tags 应收账单
  2220. // @Accept json
  2221. // @Produce json
  2222. // @Param token header string true "token"
  2223. // @Param body body v1.ChargeUrgeBody true " "
  2224. // @Success 200 {object} v1.ChargeUrgeResponse
  2225. // @Failure 500 {object} base.HTTPError
  2226. // @Router /api/v1/charge/unpay_bill/urge [post]
  2227. func (c *Controller) ChargeUrge(ctx *gin.Context) {
  2228. // 解析参数
  2229. req := &param_v1.ChargeUrgeRequest{}
  2230. parseParamTask := func() error {
  2231. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeUrgeBody)
  2232. if err != nil {
  2233. logger.Error("func",
  2234. zap.String("call", "util.ShouldBind"),
  2235. zap.String("error", err.Error()))
  2236. return errors.ParamsError
  2237. }
  2238. return nil
  2239. }
  2240. // 业务处理
  2241. handleServiceTask := func() error {
  2242. tokenInfo, err := utils.GetSubjectValue(ctx)
  2243. if err != nil {
  2244. return err
  2245. }
  2246. // 响应数据
  2247. resp := param_v1.ChargeUrgeResponse{}
  2248. rpcReq := &v1.ChargeUrgeRequest{
  2249. GardenId: tokenInfo.GardenId,
  2250. ObjType: req.ObjType,
  2251. ObjId: req.ObjId,
  2252. }
  2253. _, err = pb.Garden.ChargeUrge(ctx, rpcReq)
  2254. if err != nil {
  2255. s, _ := json.MarshalToString(req)
  2256. logger.Error("func",
  2257. zap.String("call", "pb.Garden.ChargeUrge"),
  2258. zap.String("params", s),
  2259. zap.String("error", err.Error()))
  2260. return errors.ErrorTransForm(err)
  2261. }
  2262. ctx.JSON(http.StatusOK, resp)
  2263. return nil
  2264. }
  2265. // 执行任务
  2266. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2267. }
  2268. // @Summary 已缴账单
  2269. // @Description 已缴账单
  2270. // @Tags 已缴账单
  2271. // @Accept json
  2272. // @Produce json
  2273. // @Param token header string true "token"
  2274. // @Param page query int false " "
  2275. // @Param page_size query int false " "
  2276. // @Param charge_type query int false "费用类型 费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他"
  2277. // @Param obj_name query string false "对象名"
  2278. // @Param charge_name query string false "费项名"
  2279. // @Param obj_type query int false "1 房屋 2 车位 3 车辆 "
  2280. // @Success 200 {object} v1.ChargePayedBillListResponse
  2281. // @Failure 500 {object} base.HTTPError
  2282. // @Router /api/v1/charge/payed_bill/list [get]
  2283. func (c *Controller) ChargePayedBillList(ctx *gin.Context) {
  2284. // 解析参数
  2285. req := &param_v1.ChargePayedBillListRequest{}
  2286. parseParamTask := func() error {
  2287. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargePayedBillListQuery, nil)
  2288. if err != nil {
  2289. logger.Error("func",
  2290. zap.String("call", "util.ShouldBind"),
  2291. zap.String("error", err.Error()))
  2292. return errors.ParamsError
  2293. }
  2294. return nil
  2295. }
  2296. // 业务处理
  2297. handleServiceTask := func() error {
  2298. tokenInfo, err := utils.GetSubjectValue(ctx)
  2299. if err != nil {
  2300. return err
  2301. }
  2302. // 响应数据
  2303. resp := param_v1.ChargePayedBillListResponse{}
  2304. rpcReq := &v1.ChargePayedBillListRequest{
  2305. GardenId: tokenInfo.GardenId,
  2306. PageSize: req.PageSize,
  2307. Page: req.Page,
  2308. ChargeType: req.ChargeType,
  2309. ChargeName: req.ChargeName,
  2310. ObjName: req.ObjName,
  2311. ObjType: req.ObjType,
  2312. }
  2313. rpcRsp, err := pb.Garden.ChargePayedBillList(ctx, rpcReq)
  2314. if err != nil {
  2315. s, _ := json.MarshalToString(req)
  2316. logger.Error("func",
  2317. zap.String("call", "pb.Garden.ChargePayedBillList"),
  2318. zap.String("params", s),
  2319. zap.String("error", err.Error()))
  2320. return errors.ErrorTransForm(err)
  2321. }
  2322. if rpcRsp.List == nil {
  2323. rpcRsp.List = make([]*v1.ChargePayedBillItem, 0)
  2324. }
  2325. resp.Data = *rpcRsp
  2326. ctx.JSON(http.StatusOK, resp)
  2327. return nil
  2328. }
  2329. // 执行任务
  2330. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2331. }
  2332. // @Summary 恢复账单
  2333. // @Description 恢复账单
  2334. // @Tags 作废账单
  2335. // @Accept json
  2336. // @Produce json
  2337. // @Param token header string true "token"
  2338. // @Param body body v1.ChargeRecoverBillBody true " "
  2339. // @Success 200 {object} v1.ChargeRecoverBillResponse
  2340. // @Failure 500 {object} base.HTTPError
  2341. // @Router /api/v1/charge/discard_bill/recover [put]
  2342. func (c *Controller) ChargeRecoverBill(ctx *gin.Context) {
  2343. // 解析参数
  2344. req := &param_v1.ChargeRecoverBillRequest{}
  2345. parseParamTask := func() error {
  2346. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeRecoverBillBody)
  2347. if err != nil {
  2348. logger.Error("func",
  2349. zap.String("call", "util.ShouldBind"),
  2350. zap.String("error", err.Error()))
  2351. return errors.ParamsError
  2352. }
  2353. return nil
  2354. }
  2355. // 业务处理
  2356. handleServiceTask := func() error {
  2357. tokenInfo, err := utils.GetSubjectValue(ctx)
  2358. if err != nil {
  2359. return err
  2360. }
  2361. // 响应数据
  2362. resp := param_v1.ChargeRecoverBillResponse{}
  2363. rpcReq := &v1.ChargeRecoverBillRequest{
  2364. GardenId: tokenInfo.GardenId,
  2365. BillId: req.BillId,
  2366. }
  2367. _, err = pb.Garden.ChargeRecoverBill(ctx, rpcReq)
  2368. if err != nil {
  2369. s, _ := json.MarshalToString(req)
  2370. logger.Error("func",
  2371. zap.String("call", "pb.Garden.ChargeRecoverBill"),
  2372. zap.String("params", s),
  2373. zap.String("error", err.Error()))
  2374. return errors.ErrorTransForm(err)
  2375. }
  2376. ctx.JSON(http.StatusOK, resp)
  2377. return nil
  2378. }
  2379. // 执行任务
  2380. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2381. }
  2382. // @Summary 作废账单列表
  2383. // @Description 作废账单列表
  2384. // @Tags 作废账单
  2385. // @Accept json
  2386. // @Produce json
  2387. // @Param token header string true "token"
  2388. // @Param page query int false " "
  2389. // @Param page_size query int false " "
  2390. // @Param charge_type query int false "费用类型 费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他"
  2391. // @Param obj_name query string false "对象名"
  2392. // @Param charge_name query string false "费项名"
  2393. // @Param obj_type query int false "1 房屋 2 车位 3 车辆 "
  2394. // @Success 200 {object} v1.ChargeDelBillListResponse
  2395. // @Failure 500 {object} base.HTTPError
  2396. // @Router /api/v1/charge/discard_bill/list [get]
  2397. func (c *Controller) ChargeDelBillList(ctx *gin.Context) {
  2398. // 解析参数
  2399. req := &param_v1.ChargeDelBillListRequest{}
  2400. parseParamTask := func() error {
  2401. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeDelBillListQuery, nil)
  2402. if err != nil {
  2403. logger.Error("func",
  2404. zap.String("call", "util.ShouldBind"),
  2405. zap.String("error", err.Error()))
  2406. return errors.ParamsError
  2407. }
  2408. return nil
  2409. }
  2410. // 业务处理
  2411. handleServiceTask := func() error {
  2412. tokenInfo, err := utils.GetSubjectValue(ctx)
  2413. if err != nil {
  2414. return err
  2415. }
  2416. // 响应数据
  2417. resp := param_v1.ChargeDelBillListResponse{}
  2418. rpcReq := &v1.ChargeDelBillListRequest{
  2419. GardenId: tokenInfo.GardenId,
  2420. PageSize: req.PageSize,
  2421. Page: req.Page,
  2422. ChargeType: req.ChargeType,
  2423. ChargeName: req.ChargeName,
  2424. ObjName: req.ObjName,
  2425. ObjType: req.ObjType,
  2426. }
  2427. rpcRsp, err := pb.Garden.ChargeDelBillList(ctx, rpcReq)
  2428. if err != nil {
  2429. s, _ := json.MarshalToString(req)
  2430. logger.Error("func",
  2431. zap.String("call", "pb.Garden.ChargeDelBillList"),
  2432. zap.String("params", s),
  2433. zap.String("error", err.Error()))
  2434. return errors.ErrorTransForm(err)
  2435. }
  2436. if rpcRsp.List == nil {
  2437. rpcRsp.List = make([]*v1.ChargeDelBillItem, 0)
  2438. }
  2439. resp.Data = *rpcRsp
  2440. ctx.JSON(http.StatusOK, resp)
  2441. return nil
  2442. }
  2443. // 执行任务
  2444. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2445. }
  2446. // @Summary 缴费订单列表
  2447. // @Description 缴费订单列表
  2448. // @Tags 缴费订单
  2449. // @Accept json
  2450. // @Produce json
  2451. // @Param token header string true "token"
  2452. // @Param page query int false " "
  2453. // @Param page_size query int false " "
  2454. // @Param pay_type query int false "1 现金 2 微信 3 支付宝 4 pos 5 转账 6 小程序微信支付 7 小程序支付宝支付 8 app 微信支付 9 app 支付宝支付"
  2455. // @Param obj_name query string false "对象名"
  2456. // @Param pay_status query int false "1 待支付 2 已支付"
  2457. // @Success 200 {object} v1.ChargeOrderListResponse
  2458. // @Failure 500 {object} base.HTTPError
  2459. // @Router /api/v1/charge/order/list [get]
  2460. func (c *Controller) ChargeOrderList(ctx *gin.Context) {
  2461. // 解析参数
  2462. req := &param_v1.ChargeOrderListRequest{}
  2463. parseParamTask := func() error {
  2464. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeOrderListQuery, nil)
  2465. if err != nil {
  2466. logger.Error("func",
  2467. zap.String("call", "util.ShouldBind"),
  2468. zap.String("error", err.Error()))
  2469. return errors.ParamsError
  2470. }
  2471. return nil
  2472. }
  2473. // 业务处理
  2474. handleServiceTask := func() error {
  2475. tokenInfo, err := utils.GetSubjectValue(ctx)
  2476. if err != nil {
  2477. return err
  2478. }
  2479. // 响应数据
  2480. resp := param_v1.ChargeOrderListResponse{}
  2481. rpcReq := &v1.ChargeOrderListRequest{
  2482. GardenId: tokenInfo.GardenId,
  2483. PageSize: req.PageSize,
  2484. Page: req.Page,
  2485. ObjName: req.ObjName,
  2486. PayType: req.PayType,
  2487. PayStatus: req.PayStatus,
  2488. }
  2489. rpcRsp, err := pb.Garden.ChargeOrderList(ctx, rpcReq)
  2490. if err != nil {
  2491. s, _ := json.MarshalToString(req)
  2492. logger.Error("func",
  2493. zap.String("call", "pb.Garden.ChargeOrderList"),
  2494. zap.String("params", s),
  2495. zap.String("error", err.Error()))
  2496. return errors.ErrorTransForm(err)
  2497. }
  2498. if rpcRsp.List == nil {
  2499. rpcRsp.List = make([]*v1.ChargeOrderItem, 0)
  2500. }
  2501. resp.Data = *rpcRsp
  2502. ctx.JSON(http.StatusOK, resp)
  2503. return nil
  2504. }
  2505. // 执行任务
  2506. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2507. }
  2508. // @Summary 订单详情
  2509. // @Description 订单详情
  2510. // @Tags 缴费订单
  2511. // @Accept json
  2512. // @Produce json
  2513. // @Param token header string true "token"
  2514. // @Param order_id query string true "订单详情"
  2515. // @Success 200 {object} v1.ChargeOrderInfoResponse
  2516. // @Failure 500 {object} base.HTTPError
  2517. // @Router /api/v1/charge/order/info [get]
  2518. func (c *Controller) ChargeOrderInfo(ctx *gin.Context) {
  2519. // 解析参数
  2520. req := &param_v1.ChargeOrderInfoRequest{}
  2521. parseParamTask := func() error {
  2522. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeOrderInfoQuery, nil)
  2523. if err != nil {
  2524. logger.Error("func",
  2525. zap.String("call", "util.ShouldBind"),
  2526. zap.String("error", err.Error()))
  2527. return errors.ParamsError
  2528. }
  2529. return nil
  2530. }
  2531. // 业务处理
  2532. handleServiceTask := func() error {
  2533. tokenInfo, err := utils.GetSubjectValue(ctx)
  2534. if err != nil {
  2535. return err
  2536. }
  2537. // 响应数据
  2538. resp := param_v1.ChargeOrderInfoResponse{}
  2539. rpcReq := &v1.ChargeOrderInfoRequest{
  2540. GardenId: tokenInfo.GardenId,
  2541. OrderId: req.OrderId,
  2542. }
  2543. rpcRsp, err := pb.Garden.ChargeOrderInfo(ctx, rpcReq)
  2544. if err != nil {
  2545. s, _ := json.MarshalToString(req)
  2546. logger.Error("func",
  2547. zap.String("call", "pb.Garden.ChargeOrderInfo"),
  2548. zap.String("params", s),
  2549. zap.String("error", err.Error()))
  2550. return errors.ErrorTransForm(err)
  2551. }
  2552. if rpcRsp.List == nil {
  2553. rpcRsp.List = make([]*v1.ChargeOrderBillItem, 0)
  2554. }
  2555. resp.Data = *rpcRsp
  2556. ctx.JSON(http.StatusOK, resp)
  2557. return nil
  2558. }
  2559. // 执行任务
  2560. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2561. }
  2562. // @Summary 确认订单已支付
  2563. // @Description 确认订单已支付
  2564. // @Tags 缴费订单
  2565. // @Accept json
  2566. // @Produce json
  2567. // @Param token header string true "token"
  2568. // @Param body body v1.ChargeOrderPayBody true " "
  2569. // @Success 200 {object} v1.ChargeOrderPayResponse
  2570. // @Failure 500 {object} base.HTTPError
  2571. // @Router /api/v1/charge/order/confirm [put]
  2572. func (c *Controller) ChargeOrderPay(ctx *gin.Context) {
  2573. // 解析参数
  2574. req := &param_v1.ChargeOrderPayRequest{}
  2575. parseParamTask := func() error {
  2576. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeOrderPayBody)
  2577. if err != nil {
  2578. logger.Error("func",
  2579. zap.String("call", "util.ShouldBind"),
  2580. zap.String("error", err.Error()))
  2581. return errors.ParamsError
  2582. }
  2583. return nil
  2584. }
  2585. // 业务处理
  2586. handleServiceTask := func() error {
  2587. tokenInfo, err := utils.GetSubjectValue(ctx)
  2588. if err != nil {
  2589. return err
  2590. }
  2591. // 响应数据
  2592. resp := param_v1.ChargeOrderPayResponse{}
  2593. rpcReq := &v1.ChargeOrderPayRequest{
  2594. GardenId: tokenInfo.GardenId,
  2595. OrderId: req.OrderId,
  2596. IsComfirm: true,
  2597. }
  2598. _, err = pb.Garden.ChargeOrderPay(ctx, rpcReq)
  2599. if err != nil {
  2600. s, _ := json.MarshalToString(req)
  2601. logger.Error("func",
  2602. zap.String("call", "pb.Garden.ChargeOrderPay"),
  2603. zap.String("params", s),
  2604. zap.String("error", err.Error()))
  2605. return errors.ErrorTransForm(err)
  2606. }
  2607. logReq := OperationLogRequest{
  2608. Module: "费用",
  2609. Action: "确认支付",
  2610. Origin: nil,
  2611. Target: req.ChargeOrderPayBody,
  2612. UserName: tokenInfo.UserName,
  2613. Uid: tokenInfo.Uid,
  2614. Cid: tokenInfo.Cid,
  2615. GardenId: tokenInfo.GardenId,
  2616. }
  2617. go OperationLogAdd(&logReq)
  2618. ctx.JSON(http.StatusOK, resp)
  2619. return nil
  2620. }
  2621. // 执行任务
  2622. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2623. }
  2624. //
  2625. // @Summary 添加物业费套餐
  2626. // @Description 添加物业费套餐
  2627. // @Tags 物业费套餐
  2628. // @Accept json
  2629. // @Produce json
  2630. // @Param token header string true "token"
  2631. // @Param body body v1.PropertyPackageAddBody true "信息"
  2632. // @Success 200 {object} v1.PropertyPackageAddResponse
  2633. // @Failure 500 {object} base.HTTPError
  2634. // @Router /api/v1/charge/property_package [post]
  2635. func (c *Controller) PropertyPackageAdd(ctx *gin.Context) {
  2636. // 解析参数
  2637. req := &param_v1.PropertyPackageAddRequest{}
  2638. parseParamTask := func() error {
  2639. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.PropertyPackageAddBody)
  2640. if err != nil {
  2641. logger.Error("func",
  2642. zap.String("call", "util.ShouldBind"),
  2643. zap.String("error", err.Error()))
  2644. return errors.ParamsError
  2645. }
  2646. return nil
  2647. }
  2648. // 业务处理
  2649. handleServiceTask := func() error {
  2650. tokenInfo, err := utils.GetSubjectValue(ctx)
  2651. if err != nil {
  2652. return err
  2653. }
  2654. // 响应数据
  2655. resp := param_v1.PropertyPackageAddResponse{}
  2656. rpcReq := &v1.PropertyPackageAddRequest{
  2657. GardenId: tokenInfo.GardenId,
  2658. GiveMonths: req.GiveMonths,
  2659. GiveContent: req.GiveContent,
  2660. PackageType: req.PackageType,
  2661. Enable: req.Enable,
  2662. PayMonths: req.PayMonths,
  2663. }
  2664. rpcRsp, err := pb.Garden.PropertyPackageAdd(ctx, rpcReq)
  2665. if err != nil {
  2666. s, _ := json.MarshalToString(req)
  2667. logger.Error("func",
  2668. zap.String("call", "pb.Garden.PropertyPackageAdd"),
  2669. zap.String("params", s),
  2670. zap.String("error", err.Error()))
  2671. return errors.ErrorTransForm(err)
  2672. }
  2673. resp.Data = *rpcRsp
  2674. ctx.JSON(http.StatusOK, resp)
  2675. logReq := OperationLogRequest{
  2676. Module: ModuleCharge,
  2677. Action: ActionChargePropertyPackageAdd,
  2678. Origin: nil,
  2679. Target: req.PropertyPackageAddBody,
  2680. UserName: tokenInfo.UserName,
  2681. Uid: tokenInfo.Uid,
  2682. Cid: tokenInfo.Cid,
  2683. GardenId: tokenInfo.GardenId,
  2684. }
  2685. go OperationLogAdd(&logReq)
  2686. return nil
  2687. }
  2688. // 执行任务
  2689. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2690. }
  2691. //
  2692. // @Summary 修改物业费套餐
  2693. // @Description 修改物业费套餐
  2694. // @Tags 物业费套餐
  2695. // @Accept json
  2696. // @Produce json
  2697. // @Param token header string true "token"
  2698. // @Param body body v1.PropertyPackageUpdateBody true "信息"
  2699. // @Success 200 {object} v1.PropertyPackageUpdateResponse
  2700. // @Failure 500 {object} base.HTTPError
  2701. // @Router /api/v1/charge/property_package [put]
  2702. func (c *Controller) PropertyPackageUpdate(ctx *gin.Context) {
  2703. // 解析参数
  2704. req := &param_v1.PropertyPackageUpdateRequest{}
  2705. parseParamTask := func() error {
  2706. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.PropertyPackageUpdateBody)
  2707. if err != nil {
  2708. logger.Error("func",
  2709. zap.String("call", "util.ShouldBind"),
  2710. zap.String("error", err.Error()))
  2711. return errors.ParamsError
  2712. }
  2713. return nil
  2714. }
  2715. // 业务处理
  2716. handleServiceTask := func() error {
  2717. tokenInfo, err := utils.GetSubjectValue(ctx)
  2718. if err != nil {
  2719. return err
  2720. }
  2721. // 响应数据
  2722. resp := param_v1.PropertyPackageUpdateResponse{}
  2723. rpcReq := &v1.PropertyPackageUpdateRequest{
  2724. GardenId: tokenInfo.GardenId,
  2725. GiveMonths: req.GiveMonths,
  2726. GiveContent: req.GiveContent,
  2727. PackageType: req.PackageType,
  2728. Enable: req.Enable,
  2729. PayMonths: req.PayMonths,
  2730. Id: req.Id,
  2731. }
  2732. rpcRsp, err := pb.Garden.PropertyPackageUpdate(ctx, rpcReq)
  2733. if err != nil {
  2734. s, _ := json.MarshalToString(req)
  2735. logger.Error("func",
  2736. zap.String("call", "pb.Garden.PropertyPackageUpdate"),
  2737. zap.String("params", s),
  2738. zap.String("error", err.Error()))
  2739. return errors.ErrorTransForm(err)
  2740. }
  2741. ctx.JSON(http.StatusOK, resp)
  2742. logReq := OperationLogRequest{
  2743. Module: ModuleCharge,
  2744. Action: ActionChargePropertyPackageUpdate,
  2745. Origin: rpcRsp.Origin,
  2746. Target: req.PropertyPackageUpdateBody,
  2747. UserName: tokenInfo.UserName,
  2748. Uid: tokenInfo.Uid,
  2749. Cid: tokenInfo.Cid,
  2750. GardenId: tokenInfo.GardenId,
  2751. }
  2752. go OperationLogAdd(&logReq)
  2753. return nil
  2754. }
  2755. // 执行任务
  2756. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2757. }
  2758. //
  2759. // @Summary 删除物业费套餐
  2760. // @Description 删除物业费套餐
  2761. // @Tags 物业费套餐
  2762. // @Accept json
  2763. // @Produce json
  2764. // @Param id query int true " "
  2765. // @Param token header string true "token"
  2766. // @Success 200 {object} v1.PropertyPackageDelResponse
  2767. // @Failure 500 {object} base.HTTPError
  2768. // @Router /api/v1/charge/property_package [delete]
  2769. func (c *Controller) PropertyPackageDel(ctx *gin.Context) {
  2770. // 解析参数
  2771. req := &param_v1.PropertyPackageDelRequest{}
  2772. parseParamTask := func() error {
  2773. err := util.ShouldBind(ctx, &req.Header, nil, &req.PropertyPackageDelQuery, nil)
  2774. if err != nil {
  2775. logger.Error("func",
  2776. zap.String("call", "util.ShouldBind"),
  2777. zap.String("error", err.Error()))
  2778. return errors.ParamsError
  2779. }
  2780. return nil
  2781. }
  2782. // 业务处理
  2783. handleServiceTask := func() error {
  2784. tokenInfo, err := utils.GetSubjectValue(ctx)
  2785. if err != nil {
  2786. return err
  2787. }
  2788. // 响应数据
  2789. resp := param_v1.PropertyPackageDelResponse{}
  2790. rpcReq := &v1.PropertyPackageDelRequest{
  2791. GardenId: tokenInfo.GardenId,
  2792. Id: req.Id,
  2793. }
  2794. rpcRsp, err := pb.Garden.PropertyPackageDel(ctx, rpcReq)
  2795. if err != nil {
  2796. s, _ := json.MarshalToString(req)
  2797. logger.Error("func",
  2798. zap.String("call", "pb.Garden.PropertyPackageDel"),
  2799. zap.String("params", s),
  2800. zap.String("error", err.Error()))
  2801. return errors.ErrorTransForm(err)
  2802. }
  2803. ctx.JSON(http.StatusOK, resp)
  2804. logReq := OperationLogRequest{
  2805. Module: ModuleCharge,
  2806. Action: ActionChargePropertyPackageDel,
  2807. Origin: rpcRsp.Origin,
  2808. Target: nil,
  2809. UserName: tokenInfo.UserName,
  2810. Uid: tokenInfo.Uid,
  2811. Cid: tokenInfo.Cid,
  2812. GardenId: tokenInfo.GardenId,
  2813. }
  2814. go OperationLogAdd(&logReq)
  2815. return nil
  2816. }
  2817. // 执行任务
  2818. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2819. }
  2820. //
  2821. // @Summary 物业费套餐列表
  2822. // @Description 物业费套餐列表
  2823. // @Tags 物业费套餐
  2824. // @Accept json
  2825. // @Produce json
  2826. // @Param page query int false " "
  2827. // @Param page_size query int false " "
  2828. // @Param token header string true "token"
  2829. // @Success 200 {object} v1.PropertyPackageListResponse
  2830. // @Failure 500 {object} base.HTTPError
  2831. // @Router /api/v1/charge/property_package [get]
  2832. func (c *Controller) PropertyPackageList(ctx *gin.Context) {
  2833. // 解析参数
  2834. req := &param_v1.PropertyPackageListRequest{}
  2835. parseParamTask := func() error {
  2836. err := util.ShouldBind(ctx, &req.Header, nil, &req.PropertyPackageListQuery, nil)
  2837. if err != nil {
  2838. logger.Error("func",
  2839. zap.String("call", "util.ShouldBind"),
  2840. zap.String("error", err.Error()))
  2841. return errors.ParamsError
  2842. }
  2843. return nil
  2844. }
  2845. // 业务处理
  2846. handleServiceTask := func() error {
  2847. tokenInfo, err := utils.GetSubjectValue(ctx)
  2848. if err != nil {
  2849. return err
  2850. }
  2851. // 响应数据
  2852. resp := param_v1.PropertyPackageListResponse{}
  2853. rpcReq := &v1.PropertyPackageListRequest{
  2854. GardenId: tokenInfo.GardenId,
  2855. Page: req.Page,
  2856. PageSize: req.PageSize,
  2857. }
  2858. rpcRsp, err := pb.Garden.PropertyPackageList(ctx, rpcReq)
  2859. if err != nil {
  2860. s, _ := json.MarshalToString(req)
  2861. logger.Error("func",
  2862. zap.String("call", "pb.Garden.PropertyPackageList"),
  2863. zap.String("params", s),
  2864. zap.String("error", err.Error()))
  2865. return errors.ErrorTransForm(err)
  2866. }
  2867. if rpcRsp.List == nil {
  2868. rpcRsp.List = make([]*v1.PropertyPackageItem, 0)
  2869. }
  2870. resp.Data = *rpcRsp
  2871. ctx.JSON(http.StatusOK, resp)
  2872. return nil
  2873. }
  2874. // 执行任务
  2875. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2876. }
  2877. //
  2878. // @Summary 催缴设置
  2879. // @Description 催缴设置
  2880. // @Tags 催缴设置
  2881. // @Accept json
  2882. // @Produce json
  2883. // @Param token header string true "token"
  2884. // @Param body body v1.ChargeUrgeSetBody true " "
  2885. // @Success 200 {object} v1.ChargeUrgeSetResponse
  2886. // @Failure 500 {object} base.HTTPError
  2887. // @Router /api/v1/charge/urge [put]
  2888. func (c *Controller) ChargeUrgeSet(ctx *gin.Context) {
  2889. // 解析参数
  2890. req := &param_v1.ChargeUrgeSetRequest{}
  2891. parseParamTask := func() error {
  2892. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeUrgeSetBody)
  2893. if err != nil {
  2894. logger.Error("func",
  2895. zap.String("call", "util.ShouldBind"),
  2896. zap.String("error", err.Error()))
  2897. return errors.ParamsError
  2898. }
  2899. return nil
  2900. }
  2901. // 业务处理
  2902. handleServiceTask := func() error {
  2903. tokenInfo, err := utils.GetSubjectValue(ctx)
  2904. if err != nil {
  2905. return err
  2906. }
  2907. // 响应数据
  2908. resp := param_v1.ChargeUrgeSetResponse{}
  2909. rpcReq := &v1.ChargeUrgeSetRequest{
  2910. GardenId: tokenInfo.GardenId,
  2911. UrgeDay: req.UrgeDay,
  2912. UrgeTarget: req.UrgeTarget,
  2913. UrgeMsgType: req.UrgeMsgType,
  2914. Id: req.Id,
  2915. }
  2916. if req.UrgeMsgType == 1 || req.UrgeMsgType == 3 {
  2917. mreq := v1.MsgPackageOrderListRequest{GardenId: tokenInfo.GardenId, Available: true}
  2918. mreply, err := pb.System.MsgPackageOrderList(ctx, &mreq)
  2919. if err != nil {
  2920. s, _ := json.MarshalToString(mreq)
  2921. logger.Error("func",
  2922. zap.String("call", "pb.System.MsgPackageOrderList"),
  2923. zap.String("params", s),
  2924. zap.String("error", err.Error()))
  2925. return errors.ErrorTransForm(err)
  2926. }
  2927. if len(mreply.List) == 0 {
  2928. return status.Error(10003, "当前没有可用短信套餐,请购买短信")
  2929. }
  2930. }
  2931. _, err = pb.Garden.ChargeUrgeSet(ctx, rpcReq)
  2932. if err != nil {
  2933. s, _ := json.MarshalToString(req)
  2934. logger.Error("func",
  2935. zap.String("call", "pb.Garden.ChargeUrgeSet"),
  2936. zap.String("params", s),
  2937. zap.String("error", err.Error()))
  2938. return errors.ErrorTransForm(err)
  2939. }
  2940. ctx.JSON(http.StatusOK, resp)
  2941. return nil
  2942. }
  2943. // 执行任务
  2944. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2945. }
  2946. //
  2947. // @Summary 催缴信息
  2948. // @Description 催缴信息
  2949. // @Tags 催缴设置
  2950. // @Accept json
  2951. // @Produce json
  2952. // @Param token header string true "token"
  2953. // @Success 200 {object} v1.ChargeUrgeInfoResponse
  2954. // @Failure 500 {object} base.HTTPError
  2955. // @Router /api/v1/charge/urge [get]
  2956. func (c *Controller) ChargeUrgeInfo(ctx *gin.Context) {
  2957. // 解析参数
  2958. req := &param_v1.ChargeUrgeInfoRequest{}
  2959. parseParamTask := func() error {
  2960. err := util.ShouldBind(ctx, &req.Header, nil, nil, nil)
  2961. if err != nil {
  2962. logger.Error("func",
  2963. zap.String("call", "util.ShouldBind"),
  2964. zap.String("error", err.Error()))
  2965. return errors.ParamsError
  2966. }
  2967. return nil
  2968. }
  2969. // 业务处理
  2970. handleServiceTask := func() error {
  2971. tokenInfo, err := utils.GetSubjectValue(ctx)
  2972. if err != nil {
  2973. return err
  2974. }
  2975. // 响应数据
  2976. resp := param_v1.ChargeUrgeInfoResponse{}
  2977. rpcReq := &v1.ChargeUrgeInfoRequest{
  2978. GardenId: tokenInfo.GardenId,
  2979. }
  2980. rpcRsp, err := pb.Garden.ChargeUrgeInfo(ctx, rpcReq)
  2981. if err != nil {
  2982. s, _ := json.MarshalToString(req)
  2983. logger.Error("func",
  2984. zap.String("call", "pb.Garden.ChargeUrgeInfo"),
  2985. zap.String("params", s),
  2986. zap.String("error", err.Error()))
  2987. return errors.ErrorTransForm(err)
  2988. }
  2989. resp.Data = *rpcRsp
  2990. ctx.JSON(http.StatusOK, resp)
  2991. return nil
  2992. }
  2993. // 执行任务
  2994. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2995. }