charge.go 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489
  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-applete-gateway/errors"
  15. param_v1 "property-applete-gateway/param/v1"
  16. "property-applete-gateway/parser"
  17. "property-applete-gateway/pb"
  18. "property-applete-gateway/pb/v1"
  19. "property-applete-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.ChargePowerTemplateResponse
  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.ChargePowerTemplateRequest{}
  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.ChargePowerTemplateResponse{}
  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. // @Success 200 {object} v1.ChargeHouseNotBindListResponse
  917. // @Failure 500 {object} base.HTTPError
  918. // @Router /api/v1/charge/house/can_bind_list [get]
  919. func (c *Controller) ChargeHouseNotBindList(ctx *gin.Context) {
  920. // 解析参数
  921. req := &param_v1.ChargeHouseNotBindListRequest{}
  922. parseParamTask := func() error {
  923. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeHouseNotBindListQuery, nil)
  924. if err != nil {
  925. logger.Error("func",
  926. zap.String("call", "util.ShouldBind"),
  927. zap.String("error", err.Error()))
  928. return errors.ParamsError
  929. }
  930. return nil
  931. }
  932. // 业务处理
  933. handleServiceTask := func() error {
  934. tokenInfo, err := utils.GetSubjectValue(ctx)
  935. if err != nil {
  936. return err
  937. }
  938. // 响应数据
  939. resp := param_v1.ChargeHouseNotBindListResponse{}
  940. rpcReq := &v1.ChargeHouseNotBindListRequest{
  941. GardenId:tokenInfo.GardenId,
  942. ChargeId:req.ChargeId,
  943. PageSize:req.PageSize,
  944. Page:req.Page,
  945. }
  946. rpcRsp, err := pb.Garden.ChargeHouseNotBindList(ctx, rpcReq)
  947. if err != nil {
  948. s, _ := json.MarshalToString(req)
  949. logger.Error("func",
  950. zap.String("call", "pb.Garden.ChargeHouseNotBindList"),
  951. zap.String("params", s),
  952. zap.String("error", err.Error()))
  953. return errors.ErrorTransForm(err)
  954. }
  955. if rpcRsp.List == nil {
  956. rpcRsp.List = make([]*v1.ChargeHouseData, 0)
  957. }
  958. resp.Data = *rpcRsp
  959. ctx.JSON(http.StatusOK, resp)
  960. return nil
  961. }
  962. // 执行任务
  963. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  964. }
  965. //
  966. // @Summary 绑定了项目的车位列表
  967. // @Description 绑定了项目的车位列表
  968. // @Tags 费用绑定相关
  969. // @Accept json
  970. // @Produce json
  971. // @Param token header string true "token"
  972. // @Param charge_id query int true "费项id"
  973. // @Param page query int false " "
  974. // @Param page_size query int false " "
  975. // @Success 200 {object} v1.ChargeSpaceBindedListResponse
  976. // @Failure 500 {object} base.HTTPError
  977. // @Router /api/v1/charge/space/binded_list [get]
  978. func (c *Controller) ChargeSpaceBindedList(ctx *gin.Context) {
  979. // 解析参数
  980. req := &param_v1.ChargeSpaceBindedListRequest{}
  981. parseParamTask := func() error {
  982. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeSpaceBindedListQuery, nil)
  983. if err != nil {
  984. logger.Error("func",
  985. zap.String("call", "util.ShouldBind"),
  986. zap.String("error", err.Error()))
  987. return errors.ParamsError
  988. }
  989. return nil
  990. }
  991. // 业务处理
  992. handleServiceTask := func() error {
  993. tokenInfo, err := utils.GetSubjectValue(ctx)
  994. if err != nil {
  995. return err
  996. }
  997. // 响应数据
  998. resp := param_v1.ChargeSpaceBindedListResponse{}
  999. rpcReq := &v1.ChargeSpaceBindedListRequest{
  1000. GardenId:tokenInfo.GardenId,
  1001. ChargeId:req.ChargeId,
  1002. PageSize:req.PageSize,
  1003. Page:req.Page,
  1004. }
  1005. rpcRsp, err := pb.Garden.ChargeSpaceBindedList(ctx, rpcReq)
  1006. if err != nil {
  1007. s, _ := json.MarshalToString(req)
  1008. logger.Error("func",
  1009. zap.String("call", "pb.Garden.ChargeSpaceBindedList"),
  1010. zap.String("params", s),
  1011. zap.String("error", err.Error()))
  1012. return errors.ErrorTransForm(err)
  1013. }
  1014. if rpcRsp.List == nil {
  1015. rpcRsp.List = make([]*v1.ChargeSpaceData, 0)
  1016. }
  1017. resp.Data = *rpcRsp
  1018. ctx.JSON(http.StatusOK, resp)
  1019. return nil
  1020. }
  1021. // 执行任务
  1022. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1023. }
  1024. //
  1025. // @Summary 可以绑定某项目的车位列表
  1026. // @Description 可以绑定某项目的车位列表
  1027. // @Tags 费用绑定相关
  1028. // @Accept json
  1029. // @Produce json
  1030. // @Param token header string true "token"
  1031. // @Param charge_id query int true "费项id"
  1032. // @Param page query int false " "
  1033. // @Param page_size query int false " "
  1034. // @Success 200 {object} v1.ChargeSpaceNotBindListResponse
  1035. // @Failure 500 {object} base.HTTPError
  1036. // @Router /api/v1/charge/space/can_bind_list [get]
  1037. func (c *Controller) ChargeSpaceNotBindList(ctx *gin.Context) {
  1038. // 解析参数
  1039. req := &param_v1.ChargeSpaceNotBindListRequest{}
  1040. parseParamTask := func() error {
  1041. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeSpaceNotBindListQuery, nil)
  1042. if err != nil {
  1043. logger.Error("func",
  1044. zap.String("call", "util.ShouldBind"),
  1045. zap.String("error", err.Error()))
  1046. return errors.ParamsError
  1047. }
  1048. return nil
  1049. }
  1050. // 业务处理
  1051. handleServiceTask := func() error {
  1052. tokenInfo, err := utils.GetSubjectValue(ctx)
  1053. if err != nil {
  1054. return err
  1055. }
  1056. // 响应数据
  1057. resp := param_v1.ChargeSpaceNotBindListResponse{}
  1058. rpcReq := &v1.ChargeSpaceNotBindListRequest{
  1059. GardenId:tokenInfo.GardenId,
  1060. ChargeId:req.ChargeId,
  1061. PageSize:req.PageSize,
  1062. Page:req.Page,
  1063. }
  1064. rpcRsp, err := pb.Garden.ChargeSpaceNotBindList(ctx, rpcReq)
  1065. if err != nil {
  1066. s, _ := json.MarshalToString(req)
  1067. logger.Error("func",
  1068. zap.String("call", "pb.Garden.ChargeSpaceNotBindList"),
  1069. zap.String("params", s),
  1070. zap.String("error", err.Error()))
  1071. return errors.ErrorTransForm(err)
  1072. }
  1073. if rpcRsp.List == nil {
  1074. rpcRsp.List = make([]*v1.ChargeSpaceData, 0)
  1075. }
  1076. resp.Data = *rpcRsp
  1077. ctx.JSON(http.StatusOK, resp)
  1078. return nil
  1079. }
  1080. // 执行任务
  1081. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1082. }
  1083. //
  1084. // @Summary 绑定了项目的车辆列表
  1085. // @Description 绑定了项目的车辆列表
  1086. // @Tags 费用绑定相关
  1087. // @Accept json
  1088. // @Produce json
  1089. // @Param token header string true "token"
  1090. // @Param charge_id query int true "费项id"
  1091. // @Param page query int false " "
  1092. // @Param page_size query int false " "
  1093. // @Success 200 {object} v1.ChargeVehicleBindedListResponse
  1094. // @Failure 500 {object} base.HTTPError
  1095. // @Router /api/v1/charge/vehicle/binded_list [get]
  1096. func (c *Controller) ChargeVehicleBindedList(ctx *gin.Context) {
  1097. // 解析参数
  1098. req := &param_v1.ChargeVehicleBindedListRequest{}
  1099. parseParamTask := func() error {
  1100. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeVehicleBindedListQuery, nil)
  1101. if err != nil {
  1102. logger.Error("func",
  1103. zap.String("call", "util.ShouldBind"),
  1104. zap.String("error", err.Error()))
  1105. return errors.ParamsError
  1106. }
  1107. return nil
  1108. }
  1109. // 业务处理
  1110. handleServiceTask := func() error {
  1111. tokenInfo, err := utils.GetSubjectValue(ctx)
  1112. if err != nil {
  1113. return err
  1114. }
  1115. // 响应数据
  1116. resp := param_v1.ChargeVehicleBindedListResponse{}
  1117. rpcReq := &v1.ChargeVehicleBindedListRequest{
  1118. GardenId:tokenInfo.GardenId,
  1119. ChargeId:req.ChargeId,
  1120. PageSize:req.PageSize,
  1121. Page:req.Page,
  1122. }
  1123. rpcRsp, err := pb.Garden.ChargeVehicleBindedList(ctx, rpcReq)
  1124. if err != nil {
  1125. s, _ := json.MarshalToString(req)
  1126. logger.Error("func",
  1127. zap.String("call", "pb.Garden.ChargeVehicleBindedList"),
  1128. zap.String("params", s),
  1129. zap.String("error", err.Error()))
  1130. return errors.ErrorTransForm(err)
  1131. }
  1132. if rpcRsp.List == nil {
  1133. rpcRsp.List = make([]*v1.ChargeVehicleData, 0)
  1134. }
  1135. resp.Data = *rpcRsp
  1136. ctx.JSON(http.StatusOK, resp)
  1137. return nil
  1138. }
  1139. // 执行任务
  1140. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1141. }
  1142. //
  1143. // @Summary 可以绑定某项目的车辆列表
  1144. // @Description 可以绑定某项目的车辆列表
  1145. // @Tags 费用绑定相关
  1146. // @Accept json
  1147. // @Produce json
  1148. // @Param token header string true "token"
  1149. // @Param charge_id query int true "费项id"
  1150. // @Param page query int false " "
  1151. // @Param page_size query int false " "
  1152. // @Success 200 {object} v1.ChargeVehicleNotBindListResponse
  1153. // @Failure 500 {object} base.HTTPError
  1154. // @Router /api/v1/charge/vehicle/can_bind_list [get]
  1155. func (c *Controller) ChargeVehicleNotBindList(ctx *gin.Context) {
  1156. // 解析参数
  1157. req := &param_v1.ChargeVehicleNotBindListRequest{}
  1158. parseParamTask := func() error {
  1159. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeVehicleNotBindListQuery, nil)
  1160. if err != nil {
  1161. logger.Error("func",
  1162. zap.String("call", "util.ShouldBind"),
  1163. zap.String("error", err.Error()))
  1164. return errors.ParamsError
  1165. }
  1166. return nil
  1167. }
  1168. // 业务处理
  1169. handleServiceTask := func() error {
  1170. tokenInfo, err := utils.GetSubjectValue(ctx)
  1171. if err != nil {
  1172. return err
  1173. }
  1174. // 响应数据
  1175. resp := param_v1.ChargeVehicleNotBindListResponse{}
  1176. rpcReq := &v1.ChargeVehicleNotBindListRequest{
  1177. GardenId:tokenInfo.GardenId,
  1178. ChargeId:req.ChargeId,
  1179. PageSize:req.PageSize,
  1180. Page:req.Page,
  1181. }
  1182. rpcRsp, err := pb.Garden.ChargeVehicleNotBindList(ctx, rpcReq)
  1183. if err != nil {
  1184. s, _ := json.MarshalToString(req)
  1185. logger.Error("func",
  1186. zap.String("call", "pb.Garden.ChargeVehicleNotBindList"),
  1187. zap.String("params", s),
  1188. zap.String("error", err.Error()))
  1189. return errors.ErrorTransForm(err)
  1190. }
  1191. if rpcRsp.List == nil {
  1192. rpcRsp.List = make([]*v1.ChargeVehicleData, 0)
  1193. }
  1194. resp.Data = *rpcRsp
  1195. ctx.JSON(http.StatusOK, resp)
  1196. return nil
  1197. }
  1198. // 执行任务
  1199. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1200. }
  1201. //
  1202. // @Summary 房屋收费 房屋列表
  1203. // @Description 房屋收费 房屋列表
  1204. // @Tags 对象收费相关
  1205. // @Accept json
  1206. // @Produce json
  1207. // @Param token header string true "token"
  1208. // @Param page query int false " "
  1209. // @Param page_size query int false " "
  1210. // @Success 200 {object} v1.ChargeHouseGroupResponse
  1211. // @Failure 500 {object} base.HTTPError
  1212. // @Router /api/v1/charge/obj_charge/house_list [get]
  1213. func (c *Controller) ChargeHouseGroup(ctx *gin.Context) {
  1214. // 解析参数
  1215. req := &param_v1.ChargeHouseGroupRequest{}
  1216. parseParamTask := func() error {
  1217. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeHouseGroupQuery, nil)
  1218. if err != nil {
  1219. logger.Error("func",
  1220. zap.String("call", "util.ShouldBind"),
  1221. zap.String("error", err.Error()))
  1222. return errors.ParamsError
  1223. }
  1224. return nil
  1225. }
  1226. // 业务处理
  1227. handleServiceTask := func() error {
  1228. tokenInfo, err := utils.GetSubjectValue(ctx)
  1229. if err != nil {
  1230. return err
  1231. }
  1232. // 响应数据
  1233. resp := param_v1.ChargeHouseGroupResponse{}
  1234. rpcReq := &v1.ChargeHouseGroupRequest{
  1235. GardenId:tokenInfo.GardenId,
  1236. PageSize:req.PageSize,
  1237. Page:req.Page,
  1238. }
  1239. rpcRsp, err := pb.Garden.ChargeHouseGroup(ctx, rpcReq)
  1240. if err != nil {
  1241. s, _ := json.MarshalToString(req)
  1242. logger.Error("func",
  1243. zap.String("call", "pb.Garden.ChargeHouseGroup"),
  1244. zap.String("params", s),
  1245. zap.String("error", err.Error()))
  1246. return errors.ErrorTransForm(err)
  1247. }
  1248. if rpcRsp.List == nil {
  1249. rpcRsp.List = make([]*v1.ChargeHouseGroupItem, 0)
  1250. }
  1251. resp.Data = *rpcRsp
  1252. ctx.JSON(http.StatusOK, resp)
  1253. return nil
  1254. }
  1255. // 执行任务
  1256. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1257. }
  1258. //
  1259. // @Summary 批量催缴单
  1260. // @Description 批量催缴单
  1261. // @Tags 对象收费相关
  1262. // @Accept json
  1263. // @Produce json
  1264. // @Param token header string true "token"
  1265. // @Param obj_type query int true "1 房屋 2 车位"
  1266. // @Success 200 {object} v1.BatchUrgeResponse
  1267. // @Failure 500 {object} base.HTTPError
  1268. // @Router /api/v1/charge/batch_urge [get]
  1269. func (c *Controller) BatchUrge(ctx *gin.Context) {
  1270. // 解析参数
  1271. req := &param_v1.BatchUrgeRequest{}
  1272. list := []param_v1.BatchUrgeItem{}
  1273. parseParamTask := func() error {
  1274. err := util.ShouldBind(ctx, &req.Header, nil, &req.BatchUrgeQuery, nil)
  1275. if err != nil {
  1276. logger.Error("func",
  1277. zap.String("call", "util.ShouldBind"),
  1278. zap.String("error", err.Error()))
  1279. return errors.ParamsError
  1280. }
  1281. return nil
  1282. }
  1283. // 业务处理
  1284. handleServiceTask := func() error {
  1285. tokenInfo, err := utils.GetSubjectValue(ctx)
  1286. if err != nil {
  1287. return err
  1288. }
  1289. if req.ObjType == 1 {
  1290. rpcReq := &v1.ChargeHouseGroupRequest{
  1291. GardenId:tokenInfo.GardenId,
  1292. Page:-1,
  1293. PageSize:-1,
  1294. }
  1295. rpcRsp, err := pb.Garden.ChargeHouseGroup(ctx, rpcReq)
  1296. if err != nil {
  1297. s, _ := json.MarshalToString(req)
  1298. logger.Error("func",
  1299. zap.String("call", "pb.Garden.ChargeHouseGroup"),
  1300. zap.String("params", s),
  1301. zap.String("error", err.Error()))
  1302. return errors.ErrorTransForm(err)
  1303. }
  1304. for _, v := range rpcRsp.List {
  1305. if !v.HasUnpayBill {
  1306. continue
  1307. }
  1308. mreq := &v1.ChargeUnpayListRequest{
  1309. GardenId:tokenInfo.GardenId,
  1310. PageSize:-1,
  1311. Page:-1,
  1312. ObjType:req.ObjType,
  1313. ObjId:v.HouseId,
  1314. }
  1315. mreply, err := pb.Garden.ChargeUnpayList(ctx, mreq)
  1316. if err != nil {
  1317. s, _ := json.MarshalToString(req)
  1318. logger.Error("func",
  1319. zap.String("call", "pb.Garden.ChargeUnpayList"),
  1320. zap.String("params", s),
  1321. zap.String("error", err.Error()))
  1322. return errors.ErrorTransForm(err)
  1323. }
  1324. fees := []param_v1.BatchUrgeFeeItem{}
  1325. for _, bill := range mreply.List {
  1326. item := param_v1.BatchUrgeFeeItem{
  1327. ChargeName:bill.ChargeName,
  1328. ChargeType:bill.ChargeType,
  1329. Fee:bill.UnpayAmount,
  1330. }
  1331. fees = append(fees, item)
  1332. }
  1333. item := param_v1.BatchUrgeItem{
  1334. ObjName:fmt.Sprintf("%d 房屋", v.HouseName),
  1335. List:fees,
  1336. }
  1337. list = append(list, item)
  1338. }
  1339. } else if req.ObjType == 2 {
  1340. rpcReq := &v1.ChargeSpaceGroupRequest{
  1341. GardenId:tokenInfo.GardenId,
  1342. Page:-1,
  1343. PageSize:-1,
  1344. }
  1345. rpcRsp, err := pb.Garden.ChargeSpaceGroup(ctx, rpcReq)
  1346. if err != nil {
  1347. s, _ := json.MarshalToString(req)
  1348. logger.Error("func",
  1349. zap.String("call", "pb.Garden.ChargeSpaceGroup"),
  1350. zap.String("params", s),
  1351. zap.String("error", err.Error()))
  1352. return errors.ErrorTransForm(err)
  1353. }
  1354. for _, v := range rpcRsp.List {
  1355. if !v.HasUnpayBill {
  1356. continue
  1357. }
  1358. mreq := &v1.ChargeUnpayListRequest{
  1359. GardenId:tokenInfo.GardenId,
  1360. PageSize:-1,
  1361. Page:-1,
  1362. ObjType:req.ObjType,
  1363. ObjId:v.SpaceId,
  1364. }
  1365. mreply, err := pb.Garden.ChargeUnpayList(ctx, mreq)
  1366. if err != nil {
  1367. s, _ := json.MarshalToString(req)
  1368. logger.Error("func",
  1369. zap.String("call", "pb.Garden.ChargeUnpayList"),
  1370. zap.String("params", s),
  1371. zap.String("error", err.Error()))
  1372. return errors.ErrorTransForm(err)
  1373. }
  1374. fees := []param_v1.BatchUrgeFeeItem{}
  1375. for _, bill := range mreply.List {
  1376. item := param_v1.BatchUrgeFeeItem{
  1377. ChargeName:bill.ChargeName,
  1378. ChargeType:bill.ChargeType,
  1379. Fee:bill.UnpayAmount,
  1380. }
  1381. fees = append(fees, item)
  1382. }
  1383. item := param_v1.BatchUrgeItem{
  1384. ObjName:fmt.Sprintf("%d 车位", v.SpaceNumber),
  1385. List:fees,
  1386. }
  1387. list = append(list, item)
  1388. }
  1389. } else {
  1390. return errors.ParamsError
  1391. }
  1392. resp := param_v1.BatchUrgeResponse{}
  1393. resp.Data = param_v1.BatchUrgeData{List:list}
  1394. ctx.JSON(http.StatusOK, resp)
  1395. return nil
  1396. }
  1397. // 执行任务
  1398. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1399. }
  1400. //
  1401. // @Summary 车位收费 车位列表
  1402. // @Description 车位收费 车位列表
  1403. // @Tags 对象收费相关
  1404. // @Accept json
  1405. // @Produce json
  1406. // @Param token header string true "token"
  1407. // @Param page query int false " "
  1408. // @Param page_size query int false " "
  1409. // @Success 200 {object} v1.ChargeSpaceGroupResponse
  1410. // @Failure 500 {object} base.HTTPError
  1411. // @Router /api/v1/charge/obj_charge/space_list [get]
  1412. func (c *Controller) ChargeSpaceGroup(ctx *gin.Context) {
  1413. // 解析参数
  1414. req := &param_v1.ChargeSpaceGroupRequest{}
  1415. parseParamTask := func() error {
  1416. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeSpaceGroupQuery, nil)
  1417. if err != nil {
  1418. logger.Error("func",
  1419. zap.String("call", "util.ShouldBind"),
  1420. zap.String("error", err.Error()))
  1421. return errors.ParamsError
  1422. }
  1423. return nil
  1424. }
  1425. // 业务处理
  1426. handleServiceTask := func() error {
  1427. tokenInfo, err := utils.GetSubjectValue(ctx)
  1428. if err != nil {
  1429. return err
  1430. }
  1431. // 响应数据
  1432. resp := param_v1.ChargeSpaceGroupResponse{}
  1433. rpcReq := &v1.ChargeSpaceGroupRequest{
  1434. GardenId:tokenInfo.GardenId,
  1435. PageSize:req.PageSize,
  1436. Page:req.Page,
  1437. }
  1438. rpcRsp, err := pb.Garden.ChargeSpaceGroup(ctx, rpcReq)
  1439. if err != nil {
  1440. s, _ := json.MarshalToString(req)
  1441. logger.Error("func",
  1442. zap.String("call", "pb.Garden.ChargeSpaceGroup"),
  1443. zap.String("params", s),
  1444. zap.String("error", err.Error()))
  1445. return errors.ErrorTransForm(err)
  1446. }
  1447. if rpcRsp.List == nil {
  1448. rpcRsp.List = make([]*v1.ChargeSpaceGroupItem, 0)
  1449. }
  1450. resp.Data = *rpcRsp
  1451. ctx.JSON(http.StatusOK, resp)
  1452. return nil
  1453. }
  1454. // 执行任务
  1455. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1456. }
  1457. //
  1458. // @Summary 车辆收费 车辆列表
  1459. // @Description 车辆收费 车辆列表
  1460. // @Tags 对象收费相关
  1461. // @Accept json
  1462. // @Produce json
  1463. // @Param token header string true "token"
  1464. // @Param page query int false " "
  1465. // @Param page_size query int false " "
  1466. // @Success 200 {object} v1.ChargeVehicleGroupResponse
  1467. // @Failure 500 {object} base.HTTPError
  1468. // @Router /api/v1/charge/obj_charge/vehicle_list [get]
  1469. func (c *Controller) ChargeVehicleGroup(ctx *gin.Context) {
  1470. // 解析参数
  1471. req := &param_v1.ChargeVehicleGroupRequest{}
  1472. parseParamTask := func() error {
  1473. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeVehicleGroupQuery, nil)
  1474. if err != nil {
  1475. logger.Error("func",
  1476. zap.String("call", "util.ShouldBind"),
  1477. zap.String("error", err.Error()))
  1478. return errors.ParamsError
  1479. }
  1480. return nil
  1481. }
  1482. // 业务处理
  1483. handleServiceTask := func() error {
  1484. tokenInfo, err := utils.GetSubjectValue(ctx)
  1485. if err != nil {
  1486. return err
  1487. }
  1488. // 响应数据
  1489. resp := param_v1.ChargeVehicleGroupResponse{}
  1490. rpcReq := &v1.ChargeVehicleGroupRequest{
  1491. GardenId:tokenInfo.GardenId,
  1492. PageSize:req.PageSize,
  1493. Page:req.Page,
  1494. }
  1495. rpcRsp, err := pb.Garden.ChargeVehicleGroup(ctx, rpcReq)
  1496. if err != nil {
  1497. s, _ := json.MarshalToString(req)
  1498. logger.Error("func",
  1499. zap.String("call", "pb.Garden.ChargeVehicleGroup"),
  1500. zap.String("params", s),
  1501. zap.String("error", err.Error()))
  1502. return errors.ErrorTransForm(err)
  1503. }
  1504. if rpcRsp.List == nil {
  1505. rpcRsp.List = make([]*v1.ChargeVehicleGroupItem, 0)
  1506. }
  1507. resp.Data = *rpcRsp
  1508. ctx.JSON(http.StatusOK, resp)
  1509. return nil
  1510. }
  1511. // 执行任务
  1512. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1513. }
  1514. //
  1515. // @Summary 欠费线下缴费
  1516. // @Description 欠费线下缴费
  1517. // @Tags 对象收费相关
  1518. // @Accept json
  1519. // @Produce json
  1520. // @Param token header string true "token"
  1521. // @Param body body v1.ChargeBillPayBody true " "
  1522. // @Success 200 {object} v1.ChargeBillPayResponse
  1523. // @Failure 500 {object} base.HTTPError
  1524. // @Router /api/v1/charge/obj_charge/pay [put]
  1525. func (c *Controller) ChargeBillPay(ctx *gin.Context) {
  1526. // 解析参数
  1527. req := &param_v1.ChargeBillPayRequest{}
  1528. parseParamTask := func() error {
  1529. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeBillPayBody)
  1530. if err != nil {
  1531. logger.Error("func",
  1532. zap.String("call", "util.ShouldBind"),
  1533. zap.String("error", err.Error()))
  1534. return errors.ParamsError
  1535. }
  1536. return nil
  1537. }
  1538. // 业务处理
  1539. handleServiceTask := func() error {
  1540. tokenInfo, err := utils.GetSubjectValue(ctx)
  1541. if err != nil {
  1542. return err
  1543. }
  1544. // 响应数据
  1545. resp := param_v1.ChargeBillPayResponse{}
  1546. rpcReq := &v1.ChargeBillPayRequest{
  1547. GardenId:tokenInfo.GardenId,
  1548. BindIds:req.BindIds,
  1549. ShouldPayAmount:req.ShouldPayAmount,
  1550. PayAmount:req.PayAmount,
  1551. PayType:req.PayType,
  1552. Comment:req.Comment,
  1553. }
  1554. rpcRsp, err := pb.Garden.ChargeBillPay(ctx, rpcReq)
  1555. if err != nil {
  1556. s, _ := json.MarshalToString(req)
  1557. logger.Error("func",
  1558. zap.String("call", "pb.Garden.ChargeBillPay"),
  1559. zap.String("params", s),
  1560. zap.String("error", err.Error()))
  1561. return errors.ErrorTransForm(err)
  1562. }
  1563. resp.Data = *rpcRsp
  1564. ctx.JSON(http.StatusOK, resp)
  1565. return nil
  1566. }
  1567. // 执行任务
  1568. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1569. }
  1570. //
  1571. // @Summary 欠费缴费欠费列表
  1572. // @Description 欠费缴费欠费列表
  1573. // @Tags 对象收费相关
  1574. // @Accept json
  1575. // @Produce json
  1576. // @Param token header string true "token"
  1577. // @Param obj_id query int true "房屋/车位/车辆id"
  1578. // @Param obj_type query int true "1 房屋 2 车位 3 车辆 "
  1579. // @Param page query int false " "
  1580. // @Param page_size query int false " "
  1581. // @Success 200 {object} v1.ChargeUnpayListResponse
  1582. // @Failure 500 {object} base.HTTPError
  1583. // @Router /api/v1/charge/obj_charge/unpay_list [get]
  1584. func (c *Controller) ChargeUnpayList(ctx *gin.Context) {
  1585. // 解析参数
  1586. req := &param_v1.ChargeUnpayListRequest{}
  1587. parseParamTask := func() error {
  1588. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeUnpayListQuery, nil)
  1589. if err != nil {
  1590. logger.Error("func",
  1591. zap.String("call", "util.ShouldBind"),
  1592. zap.String("error", err.Error()))
  1593. return errors.ParamsError
  1594. }
  1595. return nil
  1596. }
  1597. // 业务处理
  1598. handleServiceTask := func() error {
  1599. tokenInfo, err := utils.GetSubjectValue(ctx)
  1600. if err != nil {
  1601. return err
  1602. }
  1603. // 响应数据
  1604. resp := param_v1.ChargeUnpayListResponse{}
  1605. rpcReq := &v1.ChargeUnpayListRequest{
  1606. GardenId:tokenInfo.GardenId,
  1607. PageSize:req.PageSize,
  1608. Page:req.Page,
  1609. ObjType:req.ObjType,
  1610. ObjId:req.ObjId,
  1611. }
  1612. rpcRsp, err := pb.Garden.ChargeUnpayList(ctx, rpcReq)
  1613. if err != nil {
  1614. s, _ := json.MarshalToString(req)
  1615. logger.Error("func",
  1616. zap.String("call", "pb.Garden.ChargeUnpayList"),
  1617. zap.String("params", s),
  1618. zap.String("error", err.Error()))
  1619. return errors.ErrorTransForm(err)
  1620. }
  1621. if rpcRsp.List == nil {
  1622. rpcRsp.List = make([]*v1.ChargeUnpayItem, 0)
  1623. }
  1624. resp.Data = *rpcRsp
  1625. ctx.JSON(http.StatusOK, resp)
  1626. return nil
  1627. }
  1628. // 执行任务
  1629. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1630. }
  1631. //
  1632. // @Summary 查看费用,费项列表
  1633. // @Description 查看费用,费项列表
  1634. // @Tags 对象收费相关
  1635. // @Accept json
  1636. // @Produce json
  1637. // @Param token header string true "token"
  1638. // @Param obj_id query int true "房屋/车位/车辆id"
  1639. // @Param obj_type query int true "1 房屋 2 车位 3 车辆 "
  1640. // @Param page query int false " "
  1641. // @Param page_size query int false " "
  1642. // @Success 200 {object} v1.ChargeListResponse
  1643. // @Failure 500 {object} base.HTTPError
  1644. // @Router /api/v1/charge/obj_charge/charge_list [get]
  1645. func (c *Controller) ChargeList(ctx *gin.Context) {
  1646. // 解析参数
  1647. req := &param_v1.ChargeListRequest{}
  1648. parseParamTask := func() error {
  1649. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeListQuery, nil)
  1650. if err != nil {
  1651. logger.Error("func",
  1652. zap.String("call", "util.ShouldBind"),
  1653. zap.String("error", err.Error()))
  1654. return errors.ParamsError
  1655. }
  1656. return nil
  1657. }
  1658. // 业务处理
  1659. handleServiceTask := func() error {
  1660. tokenInfo, err := utils.GetSubjectValue(ctx)
  1661. if err != nil {
  1662. return err
  1663. }
  1664. // 响应数据
  1665. resp := param_v1.ChargeListResponse{}
  1666. rpcReq := &v1.ChargeListRequest{
  1667. GardenId:tokenInfo.GardenId,
  1668. PageSize:req.PageSize,
  1669. Page:req.Page,
  1670. ObjType:req.ObjType,
  1671. ObjId:req.ObjId,
  1672. }
  1673. rpcRsp, err := pb.Garden.ChargeList(ctx, rpcReq)
  1674. if err != nil {
  1675. s, _ := json.MarshalToString(req)
  1676. logger.Error("func",
  1677. zap.String("call", "pb.Garden.ChargeList"),
  1678. zap.String("params", s),
  1679. zap.String("error", err.Error()))
  1680. return errors.ErrorTransForm(err)
  1681. }
  1682. if rpcRsp.List == nil {
  1683. rpcRsp.List = make([]*v1.ChargeItem, 0)
  1684. }
  1685. resp.Data = *rpcRsp
  1686. ctx.JSON(http.StatusOK, resp)
  1687. return nil
  1688. }
  1689. // 执行任务
  1690. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1691. }
  1692. //
  1693. // @Summary 对象的某费项下的待缴账单列表
  1694. // @Description 对象的某费项下的待缴账单列表
  1695. // @Tags 对象收费相关
  1696. // @Accept json
  1697. // @Produce json
  1698. // @Param token header string true "token"
  1699. // @Param bind_id query int true "绑定关系id"
  1700. // @Param page query int false " "
  1701. // @Param page_size query int false " "
  1702. // @Success 200 {object} v1.ChargeBillListResponse
  1703. // @Failure 500 {object} base.HTTPError
  1704. // @Router /api/v1/charge/obj_charge/bill_list [get]
  1705. func (c *Controller) ChargeBillList(ctx *gin.Context) {
  1706. // 解析参数
  1707. req := &param_v1.ChargeBillListRequest{}
  1708. parseParamTask := func() error {
  1709. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeBillListQuery, nil)
  1710. if err != nil {
  1711. logger.Error("func",
  1712. zap.String("call", "util.ShouldBind"),
  1713. zap.String("error", err.Error()))
  1714. return errors.ParamsError
  1715. }
  1716. return nil
  1717. }
  1718. // 业务处理
  1719. handleServiceTask := func() error {
  1720. tokenInfo, err := utils.GetSubjectValue(ctx)
  1721. if err != nil {
  1722. return err
  1723. }
  1724. // 响应数据
  1725. resp := param_v1.ChargeBillListResponse{}
  1726. rpcReq := &v1.ChargeBillListRequest{
  1727. GardenId:tokenInfo.GardenId,
  1728. PageSize:req.PageSize,
  1729. Page:req.Page,
  1730. BindId:req.BindId,
  1731. }
  1732. rpcRsp, err := pb.Garden.ChargeBillList(ctx, rpcReq)
  1733. if err != nil {
  1734. s, _ := json.MarshalToString(req)
  1735. logger.Error("func",
  1736. zap.String("call", "pb.Garden.ChargeBillList"),
  1737. zap.String("params", s),
  1738. zap.String("error", err.Error()))
  1739. return errors.ErrorTransForm(err)
  1740. }
  1741. if rpcRsp.List == nil {
  1742. rpcRsp.List = make([]*v1.ChargeBillItem, 0)
  1743. }
  1744. resp.Data = *rpcRsp
  1745. ctx.JSON(http.StatusOK, resp)
  1746. return nil
  1747. }
  1748. // 执行任务
  1749. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1750. }
  1751. //
  1752. // @Summary 手动生成账单,仅周期性费用和水电气可以生成
  1753. // @Description 手动生成账单,仅周期性费用和水电气可以生成
  1754. // @Tags 对象收费相关
  1755. // @Accept json
  1756. // @Produce json
  1757. // @Param token header string true "token"
  1758. // @Param body body v1.ChargeGenerateBillBody true " "
  1759. // @Success 200 {object} v1.ChargeGenerateBillResponse
  1760. // @Failure 500 {object} base.HTTPError
  1761. // @Router /api/v1/charge/obj_charge/bill [put]
  1762. func (c *Controller) ChargeGenerateBill(ctx *gin.Context) {
  1763. // 解析参数
  1764. req := &param_v1.ChargeGenerateBillRequest{}
  1765. parseParamTask := func() error {
  1766. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeGenerateBillBody)
  1767. if err != nil {
  1768. logger.Error("func",
  1769. zap.String("call", "util.ShouldBind"),
  1770. zap.String("error", err.Error()))
  1771. return errors.ParamsError
  1772. }
  1773. return nil
  1774. }
  1775. // 业务处理
  1776. handleServiceTask := func() error {
  1777. tokenInfo, err := utils.GetSubjectValue(ctx)
  1778. if err != nil {
  1779. return err
  1780. }
  1781. // 响应数据
  1782. resp := param_v1.ChargeGenerateBillResponse{}
  1783. rpcReq := &v1.ChargeGenerateBillRequest{
  1784. GardenId:tokenInfo.GardenId,
  1785. End:req.End,
  1786. BindId:req.BindId,
  1787. }
  1788. _, err = pb.Garden.ChargeGenerateBill(ctx, rpcReq)
  1789. if err != nil {
  1790. s, _ := json.MarshalToString(req)
  1791. logger.Error("func",
  1792. zap.String("call", "pb.Garden.ChargeGenerateBill"),
  1793. zap.String("params", s),
  1794. zap.String("error", err.Error()))
  1795. return errors.ErrorTransForm(err)
  1796. }
  1797. ctx.JSON(http.StatusOK, resp)
  1798. return nil
  1799. }
  1800. // 执行任务
  1801. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1802. }
  1803. //
  1804. // @Summary 变更时间
  1805. // @Description 变更时间
  1806. // @Tags 对象收费相关
  1807. // @Accept json
  1808. // @Produce json
  1809. // @Param token header string true "token"
  1810. // @Param body body v1.ChargeTimeSetBody true " "
  1811. // @Success 200 {object} v1.ChargeTimeSetResponse
  1812. // @Failure 500 {object} base.HTTPError
  1813. // @Router /api/v1/charge/obj_charge/time [put]
  1814. func (c *Controller) ChargeTimeSet(ctx *gin.Context) {
  1815. // 解析参数
  1816. req := &param_v1.ChargeTimeSetRequest{}
  1817. parseParamTask := func() error {
  1818. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeTimeSetBody)
  1819. if err != nil {
  1820. logger.Error("func",
  1821. zap.String("call", "util.ShouldBind"),
  1822. zap.String("error", err.Error()))
  1823. return errors.ParamsError
  1824. }
  1825. return nil
  1826. }
  1827. // 业务处理
  1828. handleServiceTask := func() error {
  1829. tokenInfo, err := utils.GetSubjectValue(ctx)
  1830. if err != nil {
  1831. return err
  1832. }
  1833. // 响应数据
  1834. resp := param_v1.ChargeTimeSetResponse{}
  1835. rpcReq := &v1.ChargeTimeSetRequest{
  1836. GardenId:tokenInfo.GardenId,
  1837. Start:req.Start,
  1838. End:req.End,
  1839. BindId:req.BindId,
  1840. }
  1841. _, err = pb.Garden.ChargeTimeSet(ctx, rpcReq)
  1842. if err != nil {
  1843. s, _ := json.MarshalToString(req)
  1844. logger.Error("func",
  1845. zap.String("call", "pb.Garden.ChargeTimeSet"),
  1846. zap.String("params", s),
  1847. zap.String("error", err.Error()))
  1848. return errors.ErrorTransForm(err)
  1849. }
  1850. ctx.JSON(http.StatusOK, resp)
  1851. return nil
  1852. }
  1853. // 执行任务
  1854. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1855. }
  1856. // @Summary 小票和收据信息
  1857. // @Description 小票和收据信息
  1858. // @Tags 对象收费相关
  1859. // @Accept json
  1860. // @Produce json
  1861. // @Param token header string true "token"
  1862. // @Param order_id query string true "订单号 "
  1863. // @Success 200 {object} v1.ChargeOrderTicketResponse
  1864. // @Failure 500 {object} base.HTTPError
  1865. // @Router /api/v1/charge/obj_charge/ticket [get]
  1866. func (c *Controller) ChargeOrderTicket(ctx *gin.Context) {
  1867. // 解析参数
  1868. req := &param_v1.ChargeOrderTicketRequest{}
  1869. parseParamTask := func() error {
  1870. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeOrderTicketQuery, nil)
  1871. if err != nil {
  1872. logger.Error("func",
  1873. zap.String("call", "util.ShouldBind"),
  1874. zap.String("error", err.Error()))
  1875. return errors.ParamsError
  1876. }
  1877. return nil
  1878. }
  1879. // 业务处理
  1880. handleServiceTask := func() error {
  1881. tokenInfo, err := utils.GetSubjectValue(ctx)
  1882. if err != nil {
  1883. return err
  1884. }
  1885. // 响应数据
  1886. resp := param_v1.ChargeOrderTicketResponse{}
  1887. rpcReq := &v1.ChargeOrderTicketRequest{
  1888. GardenId:tokenInfo.GardenId,
  1889. OrderId:req.OrderId,
  1890. }
  1891. rpcRsp, err := pb.Garden.ChargeOrderTicket(ctx, rpcReq)
  1892. if err != nil {
  1893. s, _ := json.MarshalToString(req)
  1894. logger.Error("func",
  1895. zap.String("call", "pb.Garden.ChargeOrderTicket"),
  1896. zap.String("params", s),
  1897. zap.String("error", err.Error()))
  1898. return errors.ErrorTransForm(err)
  1899. }
  1900. if rpcRsp.List == nil {
  1901. rpcRsp.List = make([]*v1.ChargeOrderTicketItem, 0)
  1902. }
  1903. resp.Data = *rpcRsp
  1904. ctx.JSON(http.StatusOK, resp)
  1905. return nil
  1906. }
  1907. // 执行任务
  1908. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1909. }
  1910. // @Summary 预缴物业费或车位费前获取对应的金额信息
  1911. // @Description 预缴物业费或车位费前获取对应的金额信息
  1912. // @Tags 对象收费相关
  1913. // @Accept json
  1914. // @Produce json
  1915. // @Param token header string true "token"
  1916. // @Param bind_id query int true "关系id"
  1917. // @Param months query int true "缴费月数"
  1918. // @Success 200 {object} v1.ChargePrePayInfoResponse
  1919. // @Failure 500 {object} base.HTTPError
  1920. // @Router /api/v1/charge/obj_charge/pre_pay_info [get]
  1921. func (c *Controller) ChargePrePayInfo(ctx *gin.Context) {
  1922. // 解析参数
  1923. req := &param_v1.ChargePrePayInfoRequest{}
  1924. parseParamTask := func() error {
  1925. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargePrePayInfoQuery, nil)
  1926. if err != nil {
  1927. logger.Error("func",
  1928. zap.String("call", "util.ShouldBind"),
  1929. zap.String("error", err.Error()))
  1930. return errors.ParamsError
  1931. }
  1932. return nil
  1933. }
  1934. // 业务处理
  1935. handleServiceTask := func() error {
  1936. tokenInfo, err := utils.GetSubjectValue(ctx)
  1937. if err != nil {
  1938. return err
  1939. }
  1940. // 响应数据
  1941. resp := param_v1.ChargePrePayInfoResponse{}
  1942. rpcReq := &v1.ChargePrePayInfoRequest{
  1943. GardenId:tokenInfo.GardenId,
  1944. BindId:req.BindId,
  1945. Months:req.Months,
  1946. }
  1947. rpcRsp, err := pb.Garden.ChargePrePayInfo(ctx, rpcReq)
  1948. if err != nil {
  1949. s, _ := json.MarshalToString(req)
  1950. logger.Error("func",
  1951. zap.String("call", "pb.Garden.ChargePrePayInfo"),
  1952. zap.String("params", s),
  1953. zap.String("error", err.Error()))
  1954. return errors.ErrorTransForm(err)
  1955. }
  1956. resp.Data = *rpcRsp
  1957. ctx.JSON(http.StatusOK, resp)
  1958. return nil
  1959. }
  1960. // 执行任务
  1961. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  1962. }
  1963. //
  1964. // @Summary 线下预缴物业费或车位费
  1965. // @Description 线下预缴物业费或车位费
  1966. // @Tags 对象收费相关
  1967. // @Accept json
  1968. // @Produce json
  1969. // @Param token header string true "token"
  1970. // @Param body body v1.ChargePrePayBody true " "
  1971. // @Success 200 {object} v1.ChargePrePayResponse
  1972. // @Failure 500 {object} base.HTTPError
  1973. // @Router /api/v1/charge/obj_charge/pre_pay [put]
  1974. func (c *Controller) ChargePrePay(ctx *gin.Context) {
  1975. // 解析参数
  1976. req := &param_v1.ChargePrePayRequest{}
  1977. parseParamTask := func() error {
  1978. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargePrePayBody)
  1979. if err != nil {
  1980. logger.Error("func",
  1981. zap.String("call", "util.ShouldBind"),
  1982. zap.String("error", err.Error()))
  1983. return errors.ParamsError
  1984. }
  1985. return nil
  1986. }
  1987. // 业务处理
  1988. handleServiceTask := func() error {
  1989. tokenInfo, err := utils.GetSubjectValue(ctx)
  1990. if err != nil {
  1991. return err
  1992. }
  1993. // 响应数据
  1994. resp := param_v1.ChargePrePayResponse{}
  1995. rpcReq := &v1.ChargePrePayRequest{
  1996. GardenId:tokenInfo.GardenId,
  1997. BindId:req.BindId,
  1998. ShouldPayAmount:req.ShouldPayAmount,
  1999. PayAmount:req.PayAmount,
  2000. PayType:req.PayType,
  2001. Comment:req.Comment,
  2002. Months:req.Months,
  2003. }
  2004. rpcRsp, err := pb.Garden.ChargePrePay(ctx, rpcReq)
  2005. if err != nil {
  2006. s, _ := json.MarshalToString(req)
  2007. logger.Error("func",
  2008. zap.String("call", "pb.Garden.ChargePrePay"),
  2009. zap.String("params", s),
  2010. zap.String("error", err.Error()))
  2011. return errors.ErrorTransForm(err)
  2012. }
  2013. resp.Data = *rpcRsp
  2014. ctx.JSON(http.StatusOK, resp)
  2015. return nil
  2016. }
  2017. // 执行任务
  2018. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2019. }
  2020. // @Summary 应收账单中的对象列表
  2021. // @Description 应收账单中的对象列表
  2022. // @Tags 应收账单
  2023. // @Accept json
  2024. // @Produce json
  2025. // @Param token header string true "token"
  2026. // @Param page query int false " "
  2027. // @Param page_size query int false " "
  2028. // @Success 200 {object} v1.ChargeBillObjListResponse
  2029. // @Failure 500 {object} base.HTTPError
  2030. // @Router /api/v1/charge/unpay_bill/obj_list [get]
  2031. func (c *Controller) ChargeBillObjList(ctx *gin.Context) {
  2032. // 解析参数
  2033. req := &param_v1.ChargeBillObjListRequest{}
  2034. parseParamTask := func() error {
  2035. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeBillObjListQuery, nil)
  2036. if err != nil {
  2037. logger.Error("func",
  2038. zap.String("call", "util.ShouldBind"),
  2039. zap.String("error", err.Error()))
  2040. return errors.ParamsError
  2041. }
  2042. return nil
  2043. }
  2044. // 业务处理
  2045. handleServiceTask := func() error {
  2046. tokenInfo, err := utils.GetSubjectValue(ctx)
  2047. if err != nil {
  2048. return err
  2049. }
  2050. // 响应数据
  2051. resp := param_v1.ChargeBillObjListResponse{}
  2052. rpcReq := &v1.ChargeBillObjListRequest{
  2053. GardenId:tokenInfo.GardenId,
  2054. PageSize:req.PageSize,
  2055. Page:req.Page,
  2056. }
  2057. rpcRsp, err := pb.Garden.ChargeBillObjList(ctx, rpcReq)
  2058. if err != nil {
  2059. s, _ := json.MarshalToString(req)
  2060. logger.Error("func",
  2061. zap.String("call", "pb.Garden.ChargeBillObjList"),
  2062. zap.String("params", s),
  2063. zap.String("error", err.Error()))
  2064. return errors.ErrorTransForm(err)
  2065. }
  2066. if rpcRsp.List == nil {
  2067. rpcRsp.List = make([]*v1.ChargeBillObjItem, 0)
  2068. }
  2069. resp.Data = *rpcRsp
  2070. ctx.JSON(http.StatusOK, resp)
  2071. return nil
  2072. }
  2073. // 执行任务
  2074. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2075. }
  2076. // @Summary 应收账单中某对象的账单明细
  2077. // @Description 应收账单中某对象的账单明细
  2078. // @Tags 应收账单
  2079. // @Accept json
  2080. // @Produce json
  2081. // @Param token header string true "token"
  2082. // @Param page query int false " "
  2083. // @Param page_size query int false " "
  2084. // @Param obj_id query int true "房屋/车位/车辆id"
  2085. // @Param obj_type query int true "1 房屋 2 车位 3 车辆 "
  2086. // @Param charge_type query int false "费用类型 费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他"
  2087. // @Param obj_name query string false "对象名"
  2088. // @Param charge_name query string false "费项名"
  2089. // @Success 200 {object} v1.ChargeObjBillListResponse
  2090. // @Failure 500 {object} base.HTTPError
  2091. // @Router /api/v1/charge/unpay_bill/obj_bill_list [get]
  2092. func (c *Controller) ChargeObjBillList(ctx *gin.Context) {
  2093. // 解析参数
  2094. req := &param_v1.ChargeObjBillListRequest{}
  2095. parseParamTask := func() error {
  2096. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeObjBillListQuery, nil)
  2097. if err != nil {
  2098. logger.Error("func",
  2099. zap.String("call", "util.ShouldBind"),
  2100. zap.String("error", err.Error()))
  2101. return errors.ParamsError
  2102. }
  2103. return nil
  2104. }
  2105. // 业务处理
  2106. handleServiceTask := func() error {
  2107. tokenInfo, err := utils.GetSubjectValue(ctx)
  2108. if err != nil {
  2109. return err
  2110. }
  2111. // 响应数据
  2112. resp := param_v1.ChargeObjBillListResponse{}
  2113. rpcReq := &v1.ChargeObjBillListRequest{
  2114. GardenId:tokenInfo.GardenId,
  2115. PageSize:req.PageSize,
  2116. Page:req.Page,
  2117. ObjType:req.ObjType,
  2118. ObjId:req.ObjId,
  2119. ObjName:req.ObjName,
  2120. ChargeName:req.ChargeName,
  2121. ChargeType:req.ChargeType,
  2122. }
  2123. rpcRsp, err := pb.Garden.ChargeObjBillList(ctx, rpcReq)
  2124. if err != nil {
  2125. s, _ := json.MarshalToString(req)
  2126. logger.Error("func",
  2127. zap.String("call", "pb.Garden.ChargeObjBillList"),
  2128. zap.String("params", s),
  2129. zap.String("error", err.Error()))
  2130. return errors.ErrorTransForm(err)
  2131. }
  2132. if rpcRsp.List == nil {
  2133. rpcRsp.List = make([]*v1.ChargeBillItem, 0)
  2134. }
  2135. resp.Data = *rpcRsp
  2136. ctx.JSON(http.StatusOK, resp)
  2137. return nil
  2138. }
  2139. // 执行任务
  2140. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2141. }
  2142. // @Summary 作废账单
  2143. // @Description 作废账单
  2144. // @Tags 应收账单
  2145. // @Accept json
  2146. // @Produce json
  2147. // @Param token header string true "token"
  2148. // @Param body body v1.ChargeDelBillBody true " "
  2149. // @Success 200 {object} v1.ChargeDelBillResponse
  2150. // @Failure 500 {object} base.HTTPError
  2151. // @Router /api/v1/charge/unpay_bill/discard [put]
  2152. func (c *Controller) ChargeDelBill(ctx *gin.Context) {
  2153. // 解析参数
  2154. req := &param_v1.ChargeDelBillRequest{}
  2155. parseParamTask := func() error {
  2156. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeDelBillBody)
  2157. if err != nil {
  2158. logger.Error("func",
  2159. zap.String("call", "util.ShouldBind"),
  2160. zap.String("error", err.Error()))
  2161. return errors.ParamsError
  2162. }
  2163. return nil
  2164. }
  2165. // 业务处理
  2166. handleServiceTask := func() error {
  2167. tokenInfo, err := utils.GetSubjectValue(ctx)
  2168. if err != nil {
  2169. return err
  2170. }
  2171. // 响应数据
  2172. resp := param_v1.ChargeDelBillResponse{}
  2173. rpcReq := &v1.ChargeDelBillRequest{
  2174. GardenId:tokenInfo.GardenId,
  2175. BillId:req.BillId,
  2176. DelReason:req.DelReason,
  2177. }
  2178. _, err = pb.Garden.ChargeDelBill(ctx, rpcReq)
  2179. if err != nil {
  2180. s, _ := json.MarshalToString(req)
  2181. logger.Error("func",
  2182. zap.String("call", "pb.Garden.ChargeDelBill"),
  2183. zap.String("params", s),
  2184. zap.String("error", err.Error()))
  2185. return errors.ErrorTransForm(err)
  2186. }
  2187. ctx.JSON(http.StatusOK, resp)
  2188. return nil
  2189. }
  2190. // 执行任务
  2191. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2192. }
  2193. // @Summary 一键催缴
  2194. // @Description 一键催缴
  2195. // @Tags 应收账单
  2196. // @Accept json
  2197. // @Produce json
  2198. // @Param token header string true "token"
  2199. // @Param body body v1.ChargeUrgeBody true " "
  2200. // @Success 200 {object} v1.ChargeUrgeResponse
  2201. // @Failure 500 {object} base.HTTPError
  2202. // @Router /api/v1/charge/unpay_bill/urge [post]
  2203. func (c *Controller) ChargeUrge(ctx *gin.Context) {
  2204. // 解析参数
  2205. req := &param_v1.ChargeUrgeRequest{}
  2206. parseParamTask := func() error {
  2207. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeUrgeBody)
  2208. if err != nil {
  2209. logger.Error("func",
  2210. zap.String("call", "util.ShouldBind"),
  2211. zap.String("error", err.Error()))
  2212. return errors.ParamsError
  2213. }
  2214. return nil
  2215. }
  2216. // 业务处理
  2217. handleServiceTask := func() error {
  2218. tokenInfo, err := utils.GetSubjectValue(ctx)
  2219. if err != nil {
  2220. return err
  2221. }
  2222. // 响应数据
  2223. resp := param_v1.ChargeUrgeResponse{}
  2224. rpcReq := &v1.ChargeUrgeRequest{
  2225. GardenId:tokenInfo.GardenId,
  2226. ObjType:req.ObjType,
  2227. ObjId:req.ObjId,
  2228. }
  2229. _, err = pb.Garden.ChargeUrge(ctx, rpcReq)
  2230. if err != nil {
  2231. s, _ := json.MarshalToString(req)
  2232. logger.Error("func",
  2233. zap.String("call", "pb.Garden.ChargeUrge"),
  2234. zap.String("params", s),
  2235. zap.String("error", err.Error()))
  2236. return errors.ErrorTransForm(err)
  2237. }
  2238. ctx.JSON(http.StatusOK, resp)
  2239. return nil
  2240. }
  2241. // 执行任务
  2242. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2243. }
  2244. // @Summary 已缴账单
  2245. // @Description 已缴账单
  2246. // @Tags 已缴账单
  2247. // @Accept json
  2248. // @Produce json
  2249. // @Param token header string true "token"
  2250. // @Param page query int false " "
  2251. // @Param page_size query int false " "
  2252. // @Param charge_type query int false "费用类型 费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他"
  2253. // @Param obj_name query string false "对象名"
  2254. // @Param charge_name query string false "费项名"
  2255. // @Success 200 {object} v1.ChargePayedBillListResponse
  2256. // @Failure 500 {object} base.HTTPError
  2257. // @Router /api/v1/charge/payed_bill/list [get]
  2258. func (c *Controller) ChargePayedBillList(ctx *gin.Context) {
  2259. // 解析参数
  2260. req := &param_v1.ChargePayedBillListRequest{}
  2261. parseParamTask := func() error {
  2262. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargePayedBillListQuery, nil)
  2263. if err != nil {
  2264. logger.Error("func",
  2265. zap.String("call", "util.ShouldBind"),
  2266. zap.String("error", err.Error()))
  2267. return errors.ParamsError
  2268. }
  2269. return nil
  2270. }
  2271. // 业务处理
  2272. handleServiceTask := func() error {
  2273. tokenInfo, err := utils.GetSubjectValue(ctx)
  2274. if err != nil {
  2275. return err
  2276. }
  2277. // 响应数据
  2278. resp := param_v1.ChargePayedBillListResponse{}
  2279. rpcReq := &v1.ChargePayedBillListRequest{
  2280. GardenId:tokenInfo.GardenId,
  2281. PageSize:req.PageSize,
  2282. Page:req.Page,
  2283. ChargeType:req.ChargeType,
  2284. ChargeName:req.ChargeName,
  2285. ObjName:req.ObjName,
  2286. ObjType:req.ObjType,
  2287. }
  2288. rpcRsp, err := pb.Garden.ChargePayedBillList(ctx, rpcReq)
  2289. if err != nil {
  2290. s, _ := json.MarshalToString(req)
  2291. logger.Error("func",
  2292. zap.String("call", "pb.Garden.ChargePayedBillList"),
  2293. zap.String("params", s),
  2294. zap.String("error", err.Error()))
  2295. return errors.ErrorTransForm(err)
  2296. }
  2297. if rpcRsp.List == nil {
  2298. rpcRsp.List = make([]*v1.ChargePayedBillItem, 0)
  2299. }
  2300. resp.Data = *rpcRsp
  2301. ctx.JSON(http.StatusOK, resp)
  2302. return nil
  2303. }
  2304. // 执行任务
  2305. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2306. }
  2307. // @Summary 恢复账单
  2308. // @Description 恢复账单
  2309. // @Tags 作废账单
  2310. // @Accept json
  2311. // @Produce json
  2312. // @Param token header string true "token"
  2313. // @Param body body v1.ChargeRecoverBillBody true " "
  2314. // @Success 200 {object} v1.ChargeRecoverBillResponse
  2315. // @Failure 500 {object} base.HTTPError
  2316. // @Router /api/v1/charge/discard_bill/recover [put]
  2317. func (c *Controller) ChargeRecoverBill(ctx *gin.Context) {
  2318. // 解析参数
  2319. req := &param_v1.ChargeRecoverBillRequest{}
  2320. parseParamTask := func() error {
  2321. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeRecoverBillBody)
  2322. if err != nil {
  2323. logger.Error("func",
  2324. zap.String("call", "util.ShouldBind"),
  2325. zap.String("error", err.Error()))
  2326. return errors.ParamsError
  2327. }
  2328. return nil
  2329. }
  2330. // 业务处理
  2331. handleServiceTask := func() error {
  2332. tokenInfo, err := utils.GetSubjectValue(ctx)
  2333. if err != nil {
  2334. return err
  2335. }
  2336. // 响应数据
  2337. resp := param_v1.ChargeRecoverBillResponse{}
  2338. rpcReq := &v1.ChargeRecoverBillRequest{
  2339. GardenId:tokenInfo.GardenId,
  2340. BillId:req.BillId,
  2341. }
  2342. _, err = pb.Garden.ChargeRecoverBill(ctx, rpcReq)
  2343. if err != nil {
  2344. s, _ := json.MarshalToString(req)
  2345. logger.Error("func",
  2346. zap.String("call", "pb.Garden.ChargeRecoverBill"),
  2347. zap.String("params", s),
  2348. zap.String("error", err.Error()))
  2349. return errors.ErrorTransForm(err)
  2350. }
  2351. ctx.JSON(http.StatusOK, resp)
  2352. return nil
  2353. }
  2354. // 执行任务
  2355. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2356. }
  2357. // @Summary 作废账单列表
  2358. // @Description 作废账单列表
  2359. // @Tags 作废账单
  2360. // @Accept json
  2361. // @Produce json
  2362. // @Param token header string true "token"
  2363. // @Param page query int false " "
  2364. // @Param page_size query int false " "
  2365. // @Param charge_type query int false "费用类型 费用类型1 物业费 2 水费 3 电费 4 气费 5 车位管理费 6 月租停车费 99 其他"
  2366. // @Param obj_name query string false "对象名"
  2367. // @Param charge_name query string false "费项名"
  2368. // @Param obj_type query int false "1 房屋 2 车位 3 车辆 "
  2369. // @Success 200 {object} v1.ChargeDelBillListResponse
  2370. // @Failure 500 {object} base.HTTPError
  2371. // @Router /api/v1/charge/discard_bill/list [get]
  2372. func (c *Controller) ChargeDelBillList(ctx *gin.Context) {
  2373. // 解析参数
  2374. req := &param_v1.ChargeDelBillListRequest{}
  2375. parseParamTask := func() error {
  2376. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeDelBillListQuery, nil)
  2377. if err != nil {
  2378. logger.Error("func",
  2379. zap.String("call", "util.ShouldBind"),
  2380. zap.String("error", err.Error()))
  2381. return errors.ParamsError
  2382. }
  2383. return nil
  2384. }
  2385. // 业务处理
  2386. handleServiceTask := func() error {
  2387. tokenInfo, err := utils.GetSubjectValue(ctx)
  2388. if err != nil {
  2389. return err
  2390. }
  2391. // 响应数据
  2392. resp := param_v1.ChargeDelBillListResponse{}
  2393. rpcReq := &v1.ChargeDelBillListRequest{
  2394. GardenId:tokenInfo.GardenId,
  2395. PageSize:req.PageSize,
  2396. Page:req.Page,
  2397. ChargeType:req.ChargeType,
  2398. ChargeName:req.ChargeName,
  2399. ObjName:req.ObjName,
  2400. ObjType:req.ObjType,
  2401. }
  2402. rpcRsp, err := pb.Garden.ChargeDelBillList(ctx, rpcReq)
  2403. if err != nil {
  2404. s, _ := json.MarshalToString(req)
  2405. logger.Error("func",
  2406. zap.String("call", "pb.Garden.ChargeDelBillList"),
  2407. zap.String("params", s),
  2408. zap.String("error", err.Error()))
  2409. return errors.ErrorTransForm(err)
  2410. }
  2411. if rpcRsp.List == nil {
  2412. rpcRsp.List = make([]*v1.ChargeDelBillItem, 0)
  2413. }
  2414. resp.Data = *rpcRsp
  2415. ctx.JSON(http.StatusOK, resp)
  2416. return nil
  2417. }
  2418. // 执行任务
  2419. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2420. }
  2421. // @Summary 缴费订单列表
  2422. // @Description 缴费订单列表
  2423. // @Tags 缴费订单
  2424. // @Accept json
  2425. // @Produce json
  2426. // @Param token header string true "token"
  2427. // @Param page query int false " "
  2428. // @Param page_size query int false " "
  2429. // @Param pay_type query int false "1 现金 2 微信 3 支付宝 4 pos 5 转账 6 小程序微信支付 7 小程序支付宝支付 8 app 微信支付 9 app 支付宝支付"
  2430. // @Param obj_name query string false "对象名"
  2431. // @Param pay_status query int false "2 支付中 3 已支付"
  2432. // @Success 200 {object} v1.ChargeOrderListResponse
  2433. // @Failure 500 {object} base.HTTPError
  2434. // @Router /api/v1/charge/order/list [get]
  2435. func (c *Controller) ChargeOrderList(ctx *gin.Context) {
  2436. // 解析参数
  2437. req := &param_v1.ChargeOrderListRequest{}
  2438. parseParamTask := func() error {
  2439. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeOrderListQuery, nil)
  2440. if err != nil {
  2441. logger.Error("func",
  2442. zap.String("call", "util.ShouldBind"),
  2443. zap.String("error", err.Error()))
  2444. return errors.ParamsError
  2445. }
  2446. return nil
  2447. }
  2448. // 业务处理
  2449. handleServiceTask := func() error {
  2450. tokenInfo, err := utils.GetSubjectValue(ctx)
  2451. if err != nil {
  2452. return err
  2453. }
  2454. // 响应数据
  2455. resp := param_v1.ChargeOrderListResponse{}
  2456. rpcReq := &v1.ChargeOrderListRequest{
  2457. GardenId:tokenInfo.GardenId,
  2458. PageSize:req.PageSize,
  2459. Page:req.Page,
  2460. ObjName:req.ObjName,
  2461. PayType:req.PayType,
  2462. PayStatus:req.PayStatus,
  2463. }
  2464. rpcRsp, err := pb.Garden.ChargeOrderList(ctx, rpcReq)
  2465. if err != nil {
  2466. s, _ := json.MarshalToString(req)
  2467. logger.Error("func",
  2468. zap.String("call", "pb.Garden.ChargeOrderList"),
  2469. zap.String("params", s),
  2470. zap.String("error", err.Error()))
  2471. return errors.ErrorTransForm(err)
  2472. }
  2473. if rpcRsp.List == nil {
  2474. rpcRsp.List = make([]*v1.ChargeOrderItem, 0)
  2475. }
  2476. resp.Data = *rpcRsp
  2477. ctx.JSON(http.StatusOK, resp)
  2478. return nil
  2479. }
  2480. // 执行任务
  2481. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2482. }
  2483. // @Summary 订单详情
  2484. // @Description 订单详情
  2485. // @Tags 缴费订单
  2486. // @Accept json
  2487. // @Produce json
  2488. // @Param token header string true "token"
  2489. // @Param order_id query string true "订单详情"
  2490. // @Success 200 {object} v1.ChargeOrderInfoResponse
  2491. // @Failure 500 {object} base.HTTPError
  2492. // @Router /api/v1/charge/order/info [get]
  2493. func (c *Controller) ChargeOrderInfo(ctx *gin.Context) {
  2494. // 解析参数
  2495. req := &param_v1.ChargeOrderListRequest{}
  2496. parseParamTask := func() error {
  2497. err := util.ShouldBind(ctx, &req.Header, nil, &req.ChargeOrderListQuery, nil)
  2498. if err != nil {
  2499. logger.Error("func",
  2500. zap.String("call", "util.ShouldBind"),
  2501. zap.String("error", err.Error()))
  2502. return errors.ParamsError
  2503. }
  2504. return nil
  2505. }
  2506. // 业务处理
  2507. handleServiceTask := func() error {
  2508. tokenInfo, err := utils.GetSubjectValue(ctx)
  2509. if err != nil {
  2510. return err
  2511. }
  2512. // 响应数据
  2513. resp := param_v1.ChargeOrderInfoResponse{}
  2514. rpcReq := &v1.ChargeOrderInfoRequest{
  2515. GardenId:tokenInfo.GardenId,
  2516. OrderId:req.OrderId,
  2517. }
  2518. rpcRsp, err := pb.Garden.ChargeOrderInfo(ctx, rpcReq)
  2519. if err != nil {
  2520. s, _ := json.MarshalToString(req)
  2521. logger.Error("func",
  2522. zap.String("call", "pb.Garden.ChargeOrderInfo"),
  2523. zap.String("params", s),
  2524. zap.String("error", err.Error()))
  2525. return errors.ErrorTransForm(err)
  2526. }
  2527. if rpcRsp.List == nil {
  2528. rpcRsp.List = make([]*v1.ChargeOrderBillItem, 0)
  2529. }
  2530. resp.Data = *rpcRsp
  2531. ctx.JSON(http.StatusOK, resp)
  2532. return nil
  2533. }
  2534. // 执行任务
  2535. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2536. }
  2537. // @Summary 确认订单已支付
  2538. // @Description 确认订单已支付
  2539. // @Tags 缴费订单
  2540. // @Accept json
  2541. // @Produce json
  2542. // @Param token header string true "token"
  2543. // @Param body body v1.ChargeOrderPayBody true " "
  2544. // @Success 200 {object} v1.ChargeOrderPayResponse
  2545. // @Failure 500 {object} base.HTTPError
  2546. // @Router /api/v1/charge/order/confirm [put]
  2547. func (c *Controller) ChargeOrderPay(ctx *gin.Context) {
  2548. // 解析参数
  2549. req := &param_v1.ChargeOrderPayRequest{}
  2550. parseParamTask := func() error {
  2551. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeOrderPayBody)
  2552. if err != nil {
  2553. logger.Error("func",
  2554. zap.String("call", "util.ShouldBind"),
  2555. zap.String("error", err.Error()))
  2556. return errors.ParamsError
  2557. }
  2558. return nil
  2559. }
  2560. // 业务处理
  2561. handleServiceTask := func() error {
  2562. tokenInfo, err := utils.GetSubjectValue(ctx)
  2563. if err != nil {
  2564. return err
  2565. }
  2566. // 响应数据
  2567. resp := param_v1.ChargeOrderPayResponse{}
  2568. rpcReq := &v1.ChargeOrderPayRequest{
  2569. GardenId:tokenInfo.GardenId,
  2570. OrderId:req.OrderId,
  2571. IsComfirm:true,
  2572. }
  2573. _, err = pb.Garden.ChargeOrderPay(ctx, rpcReq)
  2574. if err != nil {
  2575. s, _ := json.MarshalToString(req)
  2576. logger.Error("func",
  2577. zap.String("call", "pb.Garden.ChargeOrderPay"),
  2578. zap.String("params", s),
  2579. zap.String("error", err.Error()))
  2580. return errors.ErrorTransForm(err)
  2581. }
  2582. ctx.JSON(http.StatusOK, resp)
  2583. return nil
  2584. }
  2585. // 执行任务
  2586. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2587. }
  2588. //
  2589. // @Summary 添加物业费套餐
  2590. // @Description 添加物业费套餐
  2591. // @Tags 物业费套餐
  2592. // @Accept json
  2593. // @Produce json
  2594. // @Param token header string true "token"
  2595. // @Param body body v1.PropertyPackageAddBody true "信息"
  2596. // @Success 200 {object} v1.PropertyPackageAddResponse
  2597. // @Failure 500 {object} base.HTTPError
  2598. // @Router /api/v1/charge/property_package [post]
  2599. func (c *Controller) PropertyPackageAdd(ctx *gin.Context) {
  2600. // 解析参数
  2601. req := &param_v1.PropertyPackageAddRequest{}
  2602. parseParamTask := func() error {
  2603. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.PropertyPackageAddBody)
  2604. if err != nil {
  2605. logger.Error("func",
  2606. zap.String("call", "util.ShouldBind"),
  2607. zap.String("error", err.Error()))
  2608. return errors.ParamsError
  2609. }
  2610. return nil
  2611. }
  2612. // 业务处理
  2613. handleServiceTask := func() error {
  2614. tokenInfo, err := utils.GetSubjectValue(ctx)
  2615. if err != nil {
  2616. return err
  2617. }
  2618. // 响应数据
  2619. resp := param_v1.PropertyPackageAddResponse{}
  2620. rpcReq := &v1.PropertyPackageAddRequest{
  2621. GardenId:tokenInfo.GardenId,
  2622. GiveMonths:req.GiveMonths,
  2623. GiveContent:req.GiveContent,
  2624. PackageType:req.PackageType,
  2625. Enable:req.Enable,
  2626. PayMonths:req.PayMonths,
  2627. }
  2628. rpcRsp, err := pb.Garden.PropertyPackageAdd(ctx, rpcReq)
  2629. if err != nil {
  2630. s, _ := json.MarshalToString(req)
  2631. logger.Error("func",
  2632. zap.String("call", "pb.Garden.PropertyPackageAdd"),
  2633. zap.String("params", s),
  2634. zap.String("error", err.Error()))
  2635. return errors.ErrorTransForm(err)
  2636. }
  2637. resp.Data = *rpcRsp
  2638. ctx.JSON(http.StatusOK, resp)
  2639. logReq := OperationLogRequest{
  2640. Module:ModuleCharge,
  2641. Action:ActionChargePropertyPackageAdd,
  2642. Origin:nil,
  2643. Target:req.PropertyPackageAddBody,
  2644. UserName:tokenInfo.UserName,
  2645. Uid:tokenInfo.Uid,
  2646. Cid:tokenInfo.Cid,
  2647. GardenId:tokenInfo.GardenId,
  2648. }
  2649. go OperationLogAdd(&logReq)
  2650. return nil
  2651. }
  2652. // 执行任务
  2653. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2654. }
  2655. //
  2656. // @Summary 修改物业费套餐
  2657. // @Description 修改物业费套餐
  2658. // @Tags 物业费套餐
  2659. // @Accept json
  2660. // @Produce json
  2661. // @Param token header string true "token"
  2662. // @Param body body v1.PropertyPackageUpdateBody true "信息"
  2663. // @Success 200 {object} v1.PropertyPackageUpdateResponse
  2664. // @Failure 500 {object} base.HTTPError
  2665. // @Router /api/v1/charge/property_package [put]
  2666. func (c *Controller) PropertyPackageUpdate(ctx *gin.Context) {
  2667. // 解析参数
  2668. req := &param_v1.PropertyPackageUpdateRequest{}
  2669. parseParamTask := func() error {
  2670. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.PropertyPackageUpdateBody)
  2671. if err != nil {
  2672. logger.Error("func",
  2673. zap.String("call", "util.ShouldBind"),
  2674. zap.String("error", err.Error()))
  2675. return errors.ParamsError
  2676. }
  2677. return nil
  2678. }
  2679. // 业务处理
  2680. handleServiceTask := func() error {
  2681. tokenInfo, err := utils.GetSubjectValue(ctx)
  2682. if err != nil {
  2683. return err
  2684. }
  2685. // 响应数据
  2686. resp := param_v1.PropertyPackageUpdateResponse{}
  2687. rpcReq := &v1.PropertyPackageUpdateRequest{
  2688. GardenId:tokenInfo.GardenId,
  2689. GiveMonths:req.GiveMonths,
  2690. GiveContent:req.GiveContent,
  2691. PackageType:req.PackageType,
  2692. Enable:req.Enable,
  2693. PayMonths:req.PayMonths,
  2694. Id:req.Id,
  2695. }
  2696. rpcRsp, err := pb.Garden.PropertyPackageUpdate(ctx, rpcReq)
  2697. if err != nil {
  2698. s, _ := json.MarshalToString(req)
  2699. logger.Error("func",
  2700. zap.String("call", "pb.Garden.PropertyPackageUpdate"),
  2701. zap.String("params", s),
  2702. zap.String("error", err.Error()))
  2703. return errors.ErrorTransForm(err)
  2704. }
  2705. ctx.JSON(http.StatusOK, resp)
  2706. logReq := OperationLogRequest{
  2707. Module:ModuleCharge,
  2708. Action:ActionChargePropertyPackageUpdate,
  2709. Origin:rpcRsp.Origin,
  2710. Target:req.PropertyPackageUpdateBody,
  2711. UserName:tokenInfo.UserName,
  2712. Uid:tokenInfo.Uid,
  2713. Cid:tokenInfo.Cid,
  2714. GardenId:tokenInfo.GardenId,
  2715. }
  2716. go OperationLogAdd(&logReq)
  2717. return nil
  2718. }
  2719. // 执行任务
  2720. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2721. }
  2722. //
  2723. // @Summary 删除物业费套餐
  2724. // @Description 删除物业费套餐
  2725. // @Tags 物业费套餐
  2726. // @Accept json
  2727. // @Produce json
  2728. // @Param id query int true " "
  2729. // @Param token header string true "token"
  2730. // @Success 200 {object} v1.PropertyPackageDelResponse
  2731. // @Failure 500 {object} base.HTTPError
  2732. // @Router /api/v1/charge/property_package [delete]
  2733. func (c *Controller) PropertyPackageDel(ctx *gin.Context) {
  2734. // 解析参数
  2735. req := &param_v1.PropertyPackageDelRequest{}
  2736. parseParamTask := func() error {
  2737. err := util.ShouldBind(ctx, &req.Header, nil, &req.PropertyPackageDelQuery, nil)
  2738. if err != nil {
  2739. logger.Error("func",
  2740. zap.String("call", "util.ShouldBind"),
  2741. zap.String("error", err.Error()))
  2742. return errors.ParamsError
  2743. }
  2744. return nil
  2745. }
  2746. // 业务处理
  2747. handleServiceTask := func() error {
  2748. tokenInfo, err := utils.GetSubjectValue(ctx)
  2749. if err != nil {
  2750. return err
  2751. }
  2752. // 响应数据
  2753. resp := param_v1.PropertyPackageDelResponse{}
  2754. rpcReq := &v1.PropertyPackageDelRequest{
  2755. GardenId:tokenInfo.GardenId,
  2756. Id:req.Id,
  2757. }
  2758. rpcRsp, err := pb.Garden.PropertyPackageDel(ctx, rpcReq)
  2759. if err != nil {
  2760. s, _ := json.MarshalToString(req)
  2761. logger.Error("func",
  2762. zap.String("call", "pb.Garden.PropertyPackageDel"),
  2763. zap.String("params", s),
  2764. zap.String("error", err.Error()))
  2765. return errors.ErrorTransForm(err)
  2766. }
  2767. ctx.JSON(http.StatusOK, resp)
  2768. logReq := OperationLogRequest{
  2769. Module:ModuleCharge,
  2770. Action:ActionChargePropertyPackageDel,
  2771. Origin:rpcRsp.Origin,
  2772. Target:nil,
  2773. UserName:tokenInfo.UserName,
  2774. Uid:tokenInfo.Uid,
  2775. Cid:tokenInfo.Cid,
  2776. GardenId:tokenInfo.GardenId,
  2777. }
  2778. go OperationLogAdd(&logReq)
  2779. return nil
  2780. }
  2781. // 执行任务
  2782. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2783. }
  2784. //
  2785. // @Summary 物业费套餐列表
  2786. // @Description 物业费套餐列表
  2787. // @Tags 物业费套餐
  2788. // @Accept json
  2789. // @Produce json
  2790. // @Param page query int false " "
  2791. // @Param page_size query int false " "
  2792. // @Param token header string true "token"
  2793. // @Success 200 {object} v1.PropertyPackageListResponse
  2794. // @Failure 500 {object} base.HTTPError
  2795. // @Router /api/v1/charge/property_package [get]
  2796. func (c *Controller) PropertyPackageList(ctx *gin.Context) {
  2797. // 解析参数
  2798. req := &param_v1.PropertyPackageListRequest{}
  2799. parseParamTask := func() error {
  2800. err := util.ShouldBind(ctx, &req.Header, nil, &req.PropertyPackageListQuery, nil)
  2801. if err != nil {
  2802. logger.Error("func",
  2803. zap.String("call", "util.ShouldBind"),
  2804. zap.String("error", err.Error()))
  2805. return errors.ParamsError
  2806. }
  2807. return nil
  2808. }
  2809. // 业务处理
  2810. handleServiceTask := func() error {
  2811. tokenInfo, err := utils.GetSubjectValue(ctx)
  2812. if err != nil {
  2813. return err
  2814. }
  2815. // 响应数据
  2816. resp := param_v1.PropertyPackageListResponse{}
  2817. rpcReq := &v1.PropertyPackageListRequest{
  2818. GardenId:tokenInfo.GardenId,
  2819. Page:req.Page,
  2820. PageSize:req.PageSize,
  2821. }
  2822. rpcRsp, err := pb.Garden.PropertyPackageList(ctx, rpcReq)
  2823. if err != nil {
  2824. s, _ := json.MarshalToString(req)
  2825. logger.Error("func",
  2826. zap.String("call", "pb.Garden.PropertyPackageList"),
  2827. zap.String("params", s),
  2828. zap.String("error", err.Error()))
  2829. return errors.ErrorTransForm(err)
  2830. }
  2831. if rpcRsp.List == nil {
  2832. rpcRsp.List = make([]*v1.PropertyPackageItem, 0)
  2833. }
  2834. resp.Data = *rpcRsp
  2835. ctx.JSON(http.StatusOK, resp)
  2836. return nil
  2837. }
  2838. // 执行任务
  2839. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2840. }
  2841. //
  2842. // @Summary 催缴设置
  2843. // @Description 催缴设置
  2844. // @Tags 催缴设置
  2845. // @Accept json
  2846. // @Produce json
  2847. // @Param token header string true "token"
  2848. // @Param body body v1.ChargeUrgeSetBody true " "
  2849. // @Success 200 {object} v1.ChargeUrgeSetResponse
  2850. // @Failure 500 {object} base.HTTPError
  2851. // @Router /api/v1/charge/urge [put]
  2852. func (c *Controller) ChargeUrgeSet(ctx *gin.Context) {
  2853. // 解析参数
  2854. req := &param_v1.ChargeUrgeSetRequest{}
  2855. parseParamTask := func() error {
  2856. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeUrgeSetBody)
  2857. if err != nil {
  2858. logger.Error("func",
  2859. zap.String("call", "util.ShouldBind"),
  2860. zap.String("error", err.Error()))
  2861. return errors.ParamsError
  2862. }
  2863. return nil
  2864. }
  2865. // 业务处理
  2866. handleServiceTask := func() error {
  2867. tokenInfo, err := utils.GetSubjectValue(ctx)
  2868. if err != nil {
  2869. return err
  2870. }
  2871. // 响应数据
  2872. resp := param_v1.ChargeUrgeSetResponse{}
  2873. rpcReq := &v1.ChargeUrgeSetRequest{
  2874. GardenId:tokenInfo.GardenId,
  2875. UrgeDay:req.UrgeDay,
  2876. UrgeTarget:req.UrgeTarget,
  2877. UrgeMsgType:req.UrgeMsgType,
  2878. Id:req.Id,
  2879. }
  2880. _, err = pb.Garden.ChargeUrgeSet(ctx, rpcReq)
  2881. if err != nil {
  2882. s, _ := json.MarshalToString(req)
  2883. logger.Error("func",
  2884. zap.String("call", "pb.Garden.ChargeUrgeSet"),
  2885. zap.String("params", s),
  2886. zap.String("error", err.Error()))
  2887. return errors.ErrorTransForm(err)
  2888. }
  2889. ctx.JSON(http.StatusOK, resp)
  2890. return nil
  2891. }
  2892. // 执行任务
  2893. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2894. }
  2895. //
  2896. // @Summary 催缴信息
  2897. // @Description 催缴信息
  2898. // @Tags 催缴设置
  2899. // @Accept json
  2900. // @Produce json
  2901. // @Param token header string true "token"
  2902. // @Success 200 {object} v1.ChargeUrgeInfoResponse
  2903. // @Failure 500 {object} base.HTTPError
  2904. // @Router /api/v1/charge/urge [get]
  2905. func (c *Controller) ChargeUrgeInfo(ctx *gin.Context) {
  2906. // 解析参数
  2907. req := &param_v1.ChargeUrgeInfoRequest{}
  2908. parseParamTask := func() error {
  2909. err := util.ShouldBind(ctx, &req.Header, nil, nil, nil)
  2910. if err != nil {
  2911. logger.Error("func",
  2912. zap.String("call", "util.ShouldBind"),
  2913. zap.String("error", err.Error()))
  2914. return errors.ParamsError
  2915. }
  2916. return nil
  2917. }
  2918. // 业务处理
  2919. handleServiceTask := func() error {
  2920. tokenInfo, err := utils.GetSubjectValue(ctx)
  2921. if err != nil {
  2922. return err
  2923. }
  2924. // 响应数据
  2925. resp := param_v1.ChargeUrgeInfoResponse{}
  2926. rpcReq := &v1.ChargeUrgeInfoRequest{
  2927. GardenId:tokenInfo.GardenId,
  2928. }
  2929. rpcRsp, err := pb.Garden.ChargeUrgeInfo(ctx, rpcReq)
  2930. if err != nil {
  2931. s, _ := json.MarshalToString(req)
  2932. logger.Error("func",
  2933. zap.String("call", "pb.Garden.ChargeUrgeInfo"),
  2934. zap.String("params", s),
  2935. zap.String("error", err.Error()))
  2936. return errors.ErrorTransForm(err)
  2937. }
  2938. resp.Data = *rpcRsp
  2939. ctx.JSON(http.StatusOK, resp)
  2940. return nil
  2941. }
  2942. // 执行任务
  2943. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  2944. }
  2945. //
  2946. // @Summary 二维码收款
  2947. // @Description 二维码收款
  2948. // @Tags 收银台
  2949. // @Accept json
  2950. // @Produce json
  2951. // @Param token header string true "token"
  2952. // @Param body body v1.ChargeBillPayByHouseholdBody true " "
  2953. // @Success 200 {object} v1.ChargeBillPayByHouseholdResponse
  2954. // @Failure 500 {object} base.HTTPError
  2955. // @Router /api/v1/charge/native_pay [put]
  2956. func (c *Controller) ChargeBillPayByHousehold(ctx *gin.Context) {
  2957. // 解析参数
  2958. req := &param_v1.ChargeBillPayByHouseholdRequest{}
  2959. parseParamTask := func() error {
  2960. err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.ChargeBillPayByHouseholdBody)
  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.ChargeBillPayByHouseholdResponse{}
  2977. rpcReq := &v1.ChargeBillPayByHouseholdRequest{
  2978. GardenId:tokenInfo.GardenId,
  2979. BindIds:req.BindIds,
  2980. ShouldPayAmount:req.ShouldPayAmount,
  2981. PayAmount:req.PayAmount,
  2982. PayType:10,
  2983. Comment:req.Comment,
  2984. InputIp:ctx.ClientIP(),
  2985. HouseholdUid:0,
  2986. OpenId:"",
  2987. Native:true,
  2988. }
  2989. rpcRsp, err := pb.Garden.ChargeBillPayByHousehold(ctx, rpcReq)
  2990. if err != nil {
  2991. s, _ := json.MarshalToString(req)
  2992. logger.Error("func",
  2993. zap.String("call", "pb.Garden.ChargeBillPayByHousehold"),
  2994. zap.String("params", s),
  2995. zap.String("error", err.Error()))
  2996. return errors.ErrorTransForm(err)
  2997. }
  2998. resp.Data = *rpcRsp
  2999. ctx.JSON(http.StatusOK, resp)
  3000. return nil
  3001. }
  3002. // 执行任务
  3003. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  3004. }