custom_api_controller.go 34KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. package admin_api_controllers
  2. import (
  3. "XT_Admin_Api/enums"
  4. "XT_Admin_Api/models"
  5. "XT_Admin_Api/service"
  6. "fmt"
  7. "time"
  8. )
  9. type CustomAPIController struct {
  10. AdminBaseAPIAuthController
  11. }
  12. func (this *CustomAPIController) CheckCustom() {
  13. id, _ := this.GetInt64("id")
  14. ci, _ := service.FindCustomInfoByID(id)
  15. if ci.ID == 0 {
  16. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17. return
  18. }
  19. ci.IsCheck = 1
  20. ci.CheckPerson = this.GetAdminInfo().Name
  21. err := service.SaveCustom(&ci)
  22. if err != nil {
  23. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  24. return
  25. }
  26. this.ServeSuccessJSON(map[string]interface{}{
  27. "msg": "审核成功",
  28. })
  29. }
  30. func (this *CustomAPIController) CreateCustom() {
  31. name := this.GetString("name")
  32. //xtOrgID := this.GetString("xt_org_id")
  33. customType, _ := this.GetInt64("custom_type")
  34. salesperson := this.GetString("salesperson")
  35. signTime := this.GetString("sign_time")
  36. contractPrice := this.GetString("contract_price")
  37. softwarePrice := this.GetString("software_price")
  38. hardwarePrice := this.GetString("hardware_price")
  39. yearCostPrice := this.GetString("year_cost_price")
  40. address := this.GetString("address")
  41. isImplement, _ := this.GetInt64("is_implement")
  42. lisStatus, _ := this.GetInt64("lis_status")
  43. lisContact := this.GetString("lis_contact")
  44. lisTime := this.GetString("lis_time")
  45. lisRemark := this.GetString("lis_remark")
  46. qcStatus, _ := this.GetInt64("qc_status")
  47. ybStatus, _ := this.GetInt64("yb_status")
  48. remark := this.GetString("remark")
  49. weightScaleStatus, _ := this.GetInt64("weight_scale_status")
  50. weightScaleBrand := this.GetString("weight_scale_brand")
  51. weightScaleRemark := this.GetString("weight_scale_remark")
  52. sphygmomanometerStatus, _ := this.GetInt64("sphygmomanometer_status")
  53. sphygmomanometerBrand := this.GetString("sphygmomanometer_brand")
  54. sphygmomanometerRemark := this.GetString("sphygmomanometer_remark")
  55. scannerStatus, _ := this.GetInt64("scanner_status")
  56. scannerBrand := this.GetString("scanner_brand")
  57. scannerRemark := this.GetString("scanner_remark")
  58. facialRecognitionDeviceStatus, _ := this.GetInt64("facial_recognition_device_status")
  59. facialRecognitionDeviceBrand := this.GetString("facial_recognition_device_brand")
  60. facialRecognitionDeviceRemark := this.GetString("facial_recognition_device_remark")
  61. printerStatus, _ := this.GetInt64("printer_status")
  62. printerBrand := this.GetString("printer_brand")
  63. printerRemark := this.GetString("printer_remark")
  64. hardwareRemark := this.GetString("hardware_remark")
  65. implement_time := this.GetString("implement_time")
  66. implement_person := this.GetString("implement_person")
  67. implement_remark := this.GetString("implement_remark")
  68. yb_time := this.GetString("yb_time")
  69. yb_person := this.GetString("yb_person")
  70. yb_remark := this.GetString("yb_remark")
  71. qc_time := this.GetString("qc_time")
  72. qc_person := this.GetString("qc_person")
  73. qc_remark := this.GetString("qc_remark")
  74. client_remark := this.GetString("client_remark")
  75. topline_time := this.GetString("topline_time")
  76. kyyChargeCustom := &models.KyyChargeCustom{
  77. ImplementTime: implement_time,
  78. ImplementPerson: implement_person,
  79. ImplementRemark: implement_remark,
  80. YbTime: yb_time,
  81. YbRemark: yb_remark,
  82. YbPerson: yb_person,
  83. QcTime: qc_time,
  84. QcPerson: qc_person,
  85. QcRemark: qc_remark,
  86. Name: name,
  87. Status: 1,
  88. Ctime: time.Now().Unix(),
  89. Mtime: time.Now().Unix(),
  90. Creator: 0,
  91. Modifier: 0,
  92. CustomType: customType,
  93. Salesperson: salesperson,
  94. SignTime: signTime,
  95. ContractPrice: contractPrice,
  96. SoftwarePrice: softwarePrice,
  97. HardwarePrice: hardwarePrice,
  98. YearCostPrice: yearCostPrice,
  99. Address: address,
  100. IsImplement: isImplement,
  101. LisStatus: lisStatus,
  102. LisContact: lisContact,
  103. LisTime: lisTime,
  104. LisRemark: lisRemark,
  105. QcStatus: qcStatus,
  106. YbStatus: ybStatus,
  107. Remark: remark,
  108. WeightScaleStatus: weightScaleStatus,
  109. WeightScaleBrand: weightScaleBrand,
  110. WeightScaleRemark: weightScaleRemark,
  111. SphygmomanometerStatus: sphygmomanometerStatus,
  112. SphygmomanometerBrand: sphygmomanometerBrand,
  113. SphygmomanometerRemark: sphygmomanometerRemark,
  114. ScannerStatus: scannerStatus,
  115. ScannerBrand: scannerBrand,
  116. ScannerRemark: scannerRemark,
  117. FacialRecognitionDeviceStatus: facialRecognitionDeviceStatus,
  118. FacialRecognitionDeviceBrand: facialRecognitionDeviceBrand,
  119. FacialRecognitionDeviceRemark: facialRecognitionDeviceRemark,
  120. PrinterStatus: printerStatus,
  121. PrinterBrand: printerBrand,
  122. PrinterRemark: printerRemark,
  123. HardwareRemark: hardwareRemark,
  124. ClientRemark: client_remark,
  125. ToplineTime: topline_time,
  126. }
  127. //custom, _ := service.FindCustomInfo(xtOrgID)
  128. //if custom.ID > 0 {
  129. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNameException)
  130. // return
  131. //}
  132. err := service.CreateCustom(kyyChargeCustom)
  133. if err == nil {
  134. this.ServeSuccessJSON(map[string]interface{}{
  135. "custom": kyyChargeCustom,
  136. })
  137. }
  138. }
  139. func (this *CustomAPIController) GetCustomList() {
  140. list, _ := service.GetAllCustoms()
  141. this.ServeSuccessJSON(map[string]interface{}{
  142. "list": list,
  143. })
  144. }
  145. // func (this *CustomAPIController) DeleteAdmin() {
  146. // id, _ := this.GetInt64("id")
  147. // err := service.DeleteAdmin(id)
  148. // if err == nil {
  149. // this.ServeSuccessJSON(map[string]interface{}{
  150. // "msg": "删除成功",
  151. // })
  152. // }
  153. // }
  154. func (this *CustomAPIController) ModifyCustom() {
  155. id, _ := this.GetInt64("id")
  156. module, _ := this.GetInt64("module")
  157. custom, _ := service.FindCustomInfoByIDTwo(id)
  158. switch module {
  159. case 1: //编辑基本信息
  160. name := this.GetString("name")
  161. customType, _ := this.GetInt64("custom_type")
  162. salesperson := this.GetString("salesperson")
  163. signTime := this.GetString("sign_time")
  164. contractPrice := this.GetString("contract_price")
  165. softwarePrice := this.GetString("software_price")
  166. hardwarePrice := this.GetString("hardware_price")
  167. yearCostPrice := this.GetString("year_cost_price")
  168. address := this.GetString("address")
  169. client_remark := this.GetString("client_remark")
  170. topline_time := this.GetString("topline_time")
  171. custom.CustomType = customType
  172. custom.Salesperson = salesperson
  173. custom.SignTime = signTime
  174. custom.ContractPrice = contractPrice
  175. custom.SoftwarePrice = softwarePrice
  176. custom.HardwarePrice = hardwarePrice
  177. custom.YearCostPrice = yearCostPrice
  178. custom.Address = address
  179. custom.Name = name
  180. custom.ID = id
  181. custom.Mtime = time.Now().Unix()
  182. custom.ClientRemark = client_remark
  183. custom.ToplineTime = topline_time
  184. err := service.UpdateCustomTwo(custom)
  185. if err != nil {
  186. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  187. return
  188. }
  189. this.ServeSuccessJSON(map[string]interface{}{
  190. "msg": "修改成功",
  191. })
  192. break
  193. case 2: //编辑实施信息
  194. isImplement, _ := this.GetInt64("is_implement")
  195. implementTime := this.GetString("implement_time")
  196. implementPerson := this.GetString("implement_person")
  197. implementRemark := this.GetString("implement_remark")
  198. custom.IsImplement = isImplement
  199. custom.ImplementTime = implementTime
  200. custom.ImplementPerson = implementPerson
  201. custom.ImplementRemark = implementRemark
  202. custom.ID = id
  203. custom.Mtime = time.Now().Unix()
  204. err := service.UpdateCustomTwo(custom)
  205. if err != nil {
  206. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  207. return
  208. }
  209. this.ServeSuccessJSON(map[string]interface{}{
  210. "msg": "修改成功",
  211. })
  212. break
  213. case 3: //编辑LIS对接
  214. lisStatus, _ := this.GetInt64("lis_status")
  215. lisContact := this.GetString("lis_contact")
  216. lisTime := this.GetString("lis_time")
  217. lisRemark := this.GetString("lis_remark")
  218. custom.LisStatus = lisStatus
  219. custom.LisTime = lisTime
  220. custom.LisRemark = lisRemark
  221. custom.LisContact = lisContact
  222. custom.ID = id
  223. custom.Mtime = time.Now().Unix()
  224. err := service.UpdateCustomTwo(custom)
  225. if err != nil {
  226. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  227. return
  228. }
  229. this.ServeSuccessJSON(map[string]interface{}{
  230. "msg": "修改成功",
  231. })
  232. break
  233. case 4: //编辑医保对接
  234. ybStatus, _ := this.GetInt64("yb_status")
  235. ybPerson := this.GetString("yb_person")
  236. ybTime := this.GetString("yb_time")
  237. ybRemark := this.GetString("yb_remark")
  238. custom.YbStatus = ybStatus
  239. custom.YbPerson = ybPerson
  240. custom.YbTime = ybTime
  241. custom.YbRemark = ybRemark
  242. custom.ID = id
  243. custom.Mtime = time.Now().Unix()
  244. err := service.UpdateCustomTwo(custom)
  245. if err != nil {
  246. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  247. return
  248. }
  249. this.ServeSuccessJSON(map[string]interface{}{
  250. "msg": "修改成功",
  251. })
  252. break
  253. case 5: //编辑质控对接
  254. qcStatus, _ := this.GetInt64("qc_status")
  255. qcPerson := this.GetString("qc_person")
  256. qcTime := this.GetString("qc_time")
  257. qcRemark := this.GetString("qc_remark")
  258. custom.QcStatus = qcStatus
  259. custom.QcPerson = qcPerson
  260. custom.QcTime = qcTime
  261. custom.QcRemark = qcRemark
  262. custom.ID = id
  263. custom.Mtime = time.Now().Unix()
  264. err := service.UpdateCustomTwo(custom)
  265. if err != nil {
  266. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  267. return
  268. }
  269. this.ServeSuccessJSON(map[string]interface{}{
  270. "msg": "修改成功",
  271. })
  272. break
  273. case 6: //编辑备注
  274. remark := this.GetString("remark")
  275. custom.Remark = remark
  276. custom.ID = id
  277. custom.Mtime = time.Now().Unix()
  278. err := service.UpdateCustomTwo(custom)
  279. if err != nil {
  280. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  281. return
  282. }
  283. this.ServeSuccessJSON(map[string]interface{}{
  284. "msg": "修改成功",
  285. })
  286. break
  287. case 7: //编辑硬件信息
  288. weightScaleStatus, _ := this.GetInt64("weight_scale_status")
  289. weightScaleBrand := this.GetString("weight_scale_brand")
  290. weightScaleRemark := this.GetString("weight_scale_remark")
  291. sphygmomanometerStatus, _ := this.GetInt64("sphygmomanometer_status")
  292. sphygmomanometerBrand := this.GetString("sphygmomanometer_brand")
  293. sphygmomanometerRemark := this.GetString("sphygmomanometer_remark")
  294. scannerStatus, _ := this.GetInt64("scanner_status")
  295. scannerBrand := this.GetString("scanner_brand")
  296. scannerRemark := this.GetString("scanner_remark")
  297. facialRecognitionDeviceStatus, _ := this.GetInt64("facial_recognition_device_status")
  298. facialRecognitionDeviceBrand := this.GetString("facial_recognition_device_brand")
  299. facialRecognitionDeviceRemark := this.GetString("facial_recognition_device_remark")
  300. printerStatus, _ := this.GetInt64("printer_status")
  301. printerBrand := this.GetString("printer_brand")
  302. printerRemark := this.GetString("printer_remark")
  303. hardwareRemark := this.GetString("hardware_remark")
  304. custom.WeightScaleStatus = weightScaleStatus
  305. custom.WeightScaleBrand = weightScaleBrand
  306. custom.WeightScaleRemark = weightScaleRemark
  307. custom.SphygmomanometerStatus = sphygmomanometerStatus
  308. custom.SphygmomanometerBrand = sphygmomanometerBrand
  309. custom.SphygmomanometerRemark = sphygmomanometerRemark
  310. custom.ScannerStatus = scannerStatus
  311. custom.ScannerBrand = scannerBrand
  312. custom.ScannerRemark = scannerRemark
  313. custom.FacialRecognitionDeviceStatus = facialRecognitionDeviceStatus
  314. custom.FacialRecognitionDeviceBrand = facialRecognitionDeviceBrand
  315. custom.FacialRecognitionDeviceRemark = facialRecognitionDeviceRemark
  316. custom.PrinterStatus = printerStatus
  317. custom.PrinterBrand = printerBrand
  318. custom.PrinterRemark = printerRemark
  319. custom.HardwareRemark = hardwareRemark
  320. custom.ID = id
  321. custom.Mtime = time.Now().Unix()
  322. err := service.UpdateCustomTwo(custom)
  323. if err != nil {
  324. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  325. return
  326. }
  327. this.ServeSuccessJSON(map[string]interface{}{
  328. "msg": "修改成功",
  329. })
  330. break
  331. }
  332. }
  333. func (this *CustomAPIController) GetCustom() {
  334. id, _ := this.GetInt64("id")
  335. custom, _ := service.FindCustomInfoByID(id)
  336. if custom.ID == 0 {
  337. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  338. return
  339. }
  340. this.ServeSuccessJSON(map[string]interface{}{
  341. "custom": custom,
  342. })
  343. }
  344. func (this *CustomAPIController) CreatePaymentCollection() {
  345. customID, _ := this.GetInt64("custom_id")
  346. customName := this.GetString("custom_name")
  347. paymentCollectionType, _ := this.GetInt64("payment_collection_type")
  348. paymentCollectionSumAmt := this.GetString("payment_collection_sumamt")
  349. softwareSumAmt := this.GetString("software_sumamt")
  350. hardwareSumAmt := this.GetString("hardware_sumamt")
  351. paymentCollectionDate := this.GetString("payment_collection_date")
  352. paymentCollectionRole := this.GetString("payment_collection_role")
  353. url := this.GetString("url")
  354. remark := this.GetString("remark")
  355. ctime := time.Now().Unix()
  356. mtime := time.Now().Unix()
  357. // 创建 KyyChargePaymentCollection 对象,并设置每个字段的值
  358. paymentCollection := models.KyyChargePaymentCollection{
  359. CustomId: customID,
  360. CustomName: customName,
  361. PaymentCollectionType: paymentCollectionType,
  362. PaymentCollectionSumamt: paymentCollectionSumAmt,
  363. SoftwareSumamt: softwareSumAmt,
  364. HardwareSumamt: hardwareSumAmt,
  365. PaymentCollectionDate: paymentCollectionDate,
  366. PaymentCollectionRole: paymentCollectionRole,
  367. Url: url,
  368. Remark: remark,
  369. Ctime: ctime,
  370. Mtime: mtime,
  371. Creator: 0,
  372. Modifier: 0,
  373. Status: 1,
  374. }
  375. err := service.CreateChargePaymentCollection(&paymentCollection)
  376. if err != nil {
  377. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  378. return
  379. }
  380. this.ServeSuccessJSON(map[string]interface{}{
  381. "paymentCollection": paymentCollection,
  382. })
  383. }
  384. func (this *CustomAPIController) GetPaymentCollectionList() {
  385. list, _ := service.GetAllPaymentCollections()
  386. this.ServeSuccessJSON(map[string]interface{}{
  387. "list": list,
  388. })
  389. }
  390. func (this *CustomAPIController) GetPaymentCollection() {
  391. id, _ := this.GetInt64("id")
  392. pc, _ := service.FindPaymentCollectionInfo(id)
  393. if pc.ID == 0 {
  394. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  395. return
  396. }
  397. this.ServeSuccessJSON(map[string]interface{}{
  398. "pc": pc,
  399. })
  400. }
  401. func (this *CustomAPIController) EditPaymentCollection() {
  402. id, _ := this.GetInt64("id")
  403. paymentCollectionType, _ := this.GetInt64("payment_collection_type")
  404. paymentCollectionSumAmt := this.GetString("payment_collection_sumamt")
  405. softwareSumAmt := this.GetString("software_sumamt")
  406. hardwareSumAmt := this.GetString("hardware_sumamt")
  407. paymentCollectionDate := this.GetString("payment_collection_date")
  408. paymentCollectionRole := this.GetString("payment_collection_role")
  409. url := this.GetString("url")
  410. remark := this.GetString("remark")
  411. mtime := time.Now().Unix()
  412. cpc, _ := service.FindPaymentCollectionInfo(id)
  413. if cpc.ID == 0 {
  414. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  415. return
  416. }
  417. cpc.PaymentCollectionType = paymentCollectionType
  418. cpc.PaymentCollectionSumamt = paymentCollectionSumAmt
  419. cpc.SoftwareSumamt = softwareSumAmt
  420. cpc.HardwareSumamt = hardwareSumAmt
  421. cpc.PaymentCollectionDate = paymentCollectionDate
  422. cpc.PaymentCollectionRole = paymentCollectionRole
  423. cpc.Url = url
  424. cpc.Remark = remark
  425. cpc.Mtime = mtime
  426. err := service.CreateChargePaymentCollection(&cpc)
  427. if err != nil {
  428. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  429. return
  430. }
  431. this.ServeSuccessJSON(map[string]interface{}{
  432. "cpc": cpc,
  433. })
  434. }
  435. func (this *CustomAPIController) DeleteCustom() {
  436. id, _ := this.GetInt64("id")
  437. ct, _ := service.FindCustomInfoByIDTwo(id)
  438. if ct.ID == 0 {
  439. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  440. return
  441. }
  442. ct.Status = 0
  443. err := service.SaveCustomTwo(ct)
  444. if err != nil {
  445. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  446. return
  447. }
  448. this.ServeSuccessJSON(map[string]interface{}{
  449. "msg": "删除成功",
  450. })
  451. }
  452. func (this *CustomAPIController) DeletePaymentCollection() {
  453. id, _ := this.GetInt64("id")
  454. cpc, _ := service.FindPaymentCollectionInfo(id)
  455. if cpc.ID == 0 {
  456. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  457. return
  458. }
  459. cpc.Status = 0
  460. err := service.SaveChargePaymentCollection(&cpc)
  461. if err != nil {
  462. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  463. return
  464. }
  465. this.ServeSuccessJSON(map[string]interface{}{
  466. "msg": "删除成功",
  467. })
  468. }
  469. func (this *CustomAPIController) CheckPaymentCollection() {
  470. id, _ := this.GetInt64("id")
  471. cpc, _ := service.FindPaymentCollectionInfo(id)
  472. if cpc.ID == 0 {
  473. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  474. return
  475. }
  476. cpc.IsCheck = 1
  477. err := service.SaveChargePaymentCollection(&cpc)
  478. if err != nil {
  479. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  480. return
  481. }
  482. this.ServeSuccessJSON(map[string]interface{}{
  483. "msg": "审核成功",
  484. })
  485. }
  486. func (this *CustomAPIController) CreateContactInfo() {
  487. customID, _ := this.GetInt64("custom_id")
  488. contactName := this.GetString("contact_name")
  489. contactPhone := this.GetString("contact_phone")
  490. contactDuties := this.GetString("contact_duties")
  491. isDecision := this.GetString("is_decision")
  492. remark := this.GetString("remark")
  493. contact_way := this.GetString("contact_way")
  494. ctime := time.Now().Unix()
  495. mtime := time.Now().Unix()
  496. // 创建 KyyChargeContact 对象,并设置每个字段的值
  497. contact := models.KyyChargeContact{
  498. ID: 0,
  499. CustomId: customID,
  500. ContactName: contactName,
  501. ContactPhone: contactPhone,
  502. ContactDuties: contactDuties,
  503. IsDecision: isDecision,
  504. Remark: remark,
  505. Ctime: ctime,
  506. Mtime: mtime,
  507. Status: 1,
  508. Creator: 0,
  509. Modifier: 0,
  510. IsCheck: 0,
  511. ContactWay: contact_way,
  512. }
  513. err := service.SaveChargeContact(&contact)
  514. if err != nil {
  515. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  516. return
  517. }
  518. this.ServeSuccessJSON(map[string]interface{}{
  519. "contact": contact,
  520. })
  521. }
  522. func (this *CustomAPIController) GetContactInfoList() {
  523. list, _ := service.GetAllChargeContacts()
  524. this.ServeSuccessJSON(map[string]interface{}{
  525. "list": list,
  526. })
  527. }
  528. func (this *CustomAPIController) GetContactInfo() {
  529. id, _ := this.GetInt64("id")
  530. cc, _ := service.FindChargeContactInfo(id)
  531. if cc.ID == 0 {
  532. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  533. return
  534. }
  535. this.ServeSuccessJSON(map[string]interface{}{
  536. "contact_info": cc,
  537. })
  538. }
  539. func (this *CustomAPIController) EditContactInfo() {
  540. id, _ := this.GetInt64("id")
  541. contactName := this.GetString("contact_name")
  542. contactPhone := this.GetString("contact_phone")
  543. contactDuties := this.GetString("contact_duties")
  544. isDecision := this.GetString("is_decision")
  545. remark := this.GetString("remark")
  546. mtime := time.Now().Unix()
  547. chargeContact, _ := service.FindChargeContactInfo(id)
  548. if chargeContact.ID == 0 {
  549. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  550. return
  551. }
  552. chargeContact.ContactName = contactName
  553. chargeContact.ContactPhone = contactPhone
  554. chargeContact.ContactDuties = contactDuties
  555. chargeContact.IsDecision = isDecision
  556. chargeContact.Remark = remark
  557. chargeContact.Remark = remark
  558. chargeContact.Mtime = mtime
  559. err := service.SaveChargeContact(&chargeContact)
  560. if err != nil {
  561. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  562. return
  563. }
  564. this.ServeSuccessJSON(map[string]interface{}{
  565. "contact": chargeContact,
  566. })
  567. }
  568. func (this *CustomAPIController) DeleteContactInfo() {
  569. id, _ := this.GetInt64("id")
  570. cc, _ := service.FindChargeContactInfo(id)
  571. if cc.ID == 0 {
  572. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  573. return
  574. }
  575. cc.Status = 0
  576. err := service.SaveChargeContact(&cc)
  577. if err != nil {
  578. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  579. return
  580. }
  581. this.ServeSuccessJSON(map[string]interface{}{
  582. "msg": "删除成功",
  583. })
  584. }
  585. func (this *CustomAPIController) CheckContactInfo() {
  586. id, _ := this.GetInt64("id")
  587. chargeContact, _ := service.FindChargeContactInfo(id)
  588. if chargeContact.ID == 0 {
  589. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  590. return
  591. }
  592. chargeContact.IsCheck = 1
  593. err := service.SaveChargeContact(&chargeContact)
  594. if err != nil {
  595. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  596. return
  597. }
  598. this.ServeSuccessJSON(map[string]interface{}{
  599. "msg": "审核成功",
  600. })
  601. }
  602. func (this *CustomAPIController) CreateContractInfo() {
  603. customID, _ := this.GetInt64("custom_id")
  604. code := this.GetString("code")
  605. name := this.GetString("name")
  606. sumamt := this.GetString("sumamt")
  607. custom_name := this.GetString("custom_name")
  608. start_time := this.GetString("start_time")
  609. end_time := this.GetString("end_time")
  610. signing_person := this.GetString("signing_person")
  611. wordFileURL := this.GetString("word_file_url")
  612. pdfFileURL := this.GetString("pdf_file_url")
  613. remark := this.GetString("remark")
  614. ctime := time.Now().Unix()
  615. mtime := time.Now().Unix()
  616. // 创建 KyyChargeContract 对象,并设置每个字段的值
  617. contract := models.KyyChargeContract{
  618. CustomId: customID,
  619. Code: code,
  620. Name: name,
  621. Sumamt: sumamt,
  622. StartTime: start_time,
  623. EndTime: end_time,
  624. SigningPerson: signing_person,
  625. WordFileUrl: wordFileURL,
  626. PdfFileUrl: pdfFileURL,
  627. CustomName: custom_name,
  628. Remark: remark,
  629. Ctime: ctime,
  630. Mtime: mtime,
  631. Status: 1,
  632. }
  633. err := service.SaveChargeContract(&contract)
  634. if err != nil {
  635. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  636. return
  637. }
  638. this.ServeSuccessJSON(map[string]interface{}{
  639. "msg": "创建成功",
  640. })
  641. }
  642. func (this *CustomAPIController) GetContractInfoList() {
  643. list, _ := service.GetAllChargeContracts()
  644. this.ServeSuccessJSON(map[string]interface{}{
  645. "list": list,
  646. })
  647. }
  648. func (this *CustomAPIController) GetContractInfo() {
  649. id, _ := this.GetInt64("id")
  650. cc, _ := service.FindChargeContractInfo(id)
  651. if cc.ID == 0 {
  652. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  653. return
  654. }
  655. this.ServeSuccessJSON(map[string]interface{}{
  656. "charge_contract": cc,
  657. })
  658. }
  659. func (this *CustomAPIController) EditContractInfo() {
  660. id, _ := this.GetInt64("id")
  661. code := this.GetString("code")
  662. name := this.GetString("name")
  663. customName := this.GetString("custom_name")
  664. sumamt := this.GetString("sumamt")
  665. startTime := this.GetString("start_time")
  666. endTime := this.GetString("end_time")
  667. signingPerson := this.GetString("signing_person")
  668. wordFileURL := this.GetString("word_file_url")
  669. pdfFileURL := this.GetString("pdf_file_url")
  670. remark := this.GetString("remark")
  671. mtime := time.Now().Unix()
  672. chargeContract, _ := service.FindChargeContractInfo(id)
  673. if chargeContract.ID == 0 {
  674. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  675. return
  676. }
  677. chargeContract.Code = code
  678. chargeContract.Name = name
  679. chargeContract.CustomName = customName
  680. chargeContract.Sumamt = sumamt
  681. chargeContract.StartTime = startTime
  682. chargeContract.EndTime = endTime
  683. chargeContract.SigningPerson = signingPerson
  684. chargeContract.WordFileUrl = wordFileURL
  685. chargeContract.PdfFileUrl = pdfFileURL
  686. chargeContract.Remark = remark
  687. chargeContract.Mtime = mtime
  688. err := service.SaveChargeContract(&chargeContract)
  689. if err != nil {
  690. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  691. return
  692. }
  693. this.ServeSuccessJSON(map[string]interface{}{
  694. "msg": "修改成功",
  695. })
  696. }
  697. func (this *CustomAPIController) DeleteContractInfo() {
  698. id, _ := this.GetInt64("id")
  699. cc, _ := service.FindChargeContractInfo(id)
  700. if cc.ID == 0 {
  701. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  702. return
  703. }
  704. cc.Status = 0
  705. err := service.SaveChargeContract(&cc)
  706. if err != nil {
  707. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  708. return
  709. }
  710. this.ServeSuccessJSON(map[string]interface{}{
  711. "msg": "删除成功",
  712. })
  713. }
  714. func (this *CustomAPIController) CheckContractInfo() {
  715. id, _ := this.GetInt64("id")
  716. chargeContract, _ := service.FindChargeContractInfo(id)
  717. if chargeContract.ID == 0 {
  718. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  719. return
  720. }
  721. chargeContract.IsCheck = 1
  722. err := service.SaveChargeContract(&chargeContract)
  723. if err != nil {
  724. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  725. return
  726. }
  727. this.ServeSuccessJSON(map[string]interface{}{
  728. "msg": "审核成功",
  729. })
  730. }
  731. func (this *CustomAPIController) CreateFollowInfo() {
  732. ctime := time.Now().Unix()
  733. mtime := time.Now().Unix()
  734. customID, _ := this.GetInt64("custom_id")
  735. desc := this.GetString("desc")
  736. // 创建 KyyChargeFollow 对象,并设置每个字段的值
  737. follow := models.KyyChargeFollow{
  738. Ctime: ctime,
  739. Mtime: mtime,
  740. Creator: this.GetAdminInfo().ID,
  741. CustomId: customID,
  742. Desc: desc,
  743. Status: 1,
  744. }
  745. err := service.SaveChargeFollow(&follow)
  746. if err != nil {
  747. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  748. return
  749. }
  750. this.ServeSuccessJSON(map[string]interface{}{
  751. "follow": follow,
  752. })
  753. }
  754. func (this *CustomAPIController) GetFollowInfoList() {
  755. list, _ := service.GetAllChargeFollow()
  756. this.ServeSuccessJSON(map[string]interface{}{
  757. "list": list,
  758. })
  759. }
  760. func (this *CustomAPIController) GetFollowInfo() {
  761. id, _ := this.GetInt64("id")
  762. follow, _ := service.FindChargeFollowInfo(id)
  763. if follow.ID == 0 {
  764. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  765. return
  766. }
  767. this.ServeSuccessJSON(map[string]interface{}{
  768. "follow": follow,
  769. })
  770. }
  771. func (this *CustomAPIController) EditFollowInfo() {
  772. id, _ := this.GetInt64("id")
  773. desc := this.GetString("desc")
  774. chargeFollow, _ := service.FindChargeFollowInfo(id)
  775. chargeFollow.Desc = desc
  776. chargeFollow.Mtime = time.Now().Unix()
  777. err := service.SaveChargeFollow(&chargeFollow)
  778. if err != nil {
  779. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  780. return
  781. }
  782. this.ServeSuccessJSON(map[string]interface{}{
  783. "follow": chargeFollow,
  784. })
  785. }
  786. func (this *CustomAPIController) DeleteFollowInfo() {
  787. id, _ := this.GetInt64("id")
  788. follow, _ := service.FindChargeFollowInfo(id)
  789. if follow.ID == 0 {
  790. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  791. return
  792. }
  793. follow.Status = 0
  794. err := service.SaveChargeFollow(&follow)
  795. if err != nil {
  796. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  797. return
  798. }
  799. this.ServeSuccessJSON(map[string]interface{}{
  800. "msg": "删除成功",
  801. })
  802. }
  803. func (this *CustomAPIController) CheckFollowInfo() {
  804. id, _ := this.GetInt64("id")
  805. follow, _ := service.FindChargeFollowInfo(id)
  806. if follow.ID == 0 {
  807. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  808. return
  809. }
  810. follow.IsCheck = 1
  811. err := service.SaveChargeFollow(&follow)
  812. if err != nil {
  813. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  814. return
  815. }
  816. this.ServeSuccessJSON(map[string]interface{}{
  817. "msg": "审核成功",
  818. })
  819. }
  820. func (this *CustomAPIController) CreateDemandInfo() {
  821. demandType, _ := this.GetInt64("demand_type")
  822. demandDesc := this.GetString("demand_desc")
  823. demandStatus, _ := this.GetInt64("demand_status")
  824. demandCreator := this.GetString("demand_creator")
  825. demandCreateDate := this.GetString("demand_create_date")
  826. demandDirector := this.GetString("demand_director")
  827. ctime := time.Now().Unix()
  828. mtime := time.Now().Unix()
  829. customID, _ := this.GetInt64("custom_id")
  830. demandFinishDate := this.GetString("demand_finish_date")
  831. demandDetail := this.GetString("demand_detail")
  832. // 创建 KyyChargeDemand 对象,并设置每个字段的值
  833. demand := models.KyyChargeDemand{
  834. DemandType: demandType,
  835. DemandDesc: demandDesc,
  836. DemandStatus: demandStatus,
  837. DemandCreator: demandCreator,
  838. DemandCreateDate: demandCreateDate,
  839. DemandDirector: demandDirector,
  840. Ctime: ctime,
  841. Mtime: mtime,
  842. Status: 1,
  843. CustomId: customID,
  844. DemandFinishDate: demandFinishDate,
  845. DemandDetail: demandDetail,
  846. }
  847. err := service.SaveChargeDemand(&demand)
  848. if err != nil {
  849. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  850. return
  851. }
  852. this.ServeSuccessJSON(map[string]interface{}{
  853. "demand": demand,
  854. })
  855. }
  856. func (this *CustomAPIController) GetDemandInfoList() {
  857. list, _ := service.GetAllChargeDemand()
  858. this.ServeSuccessJSON(map[string]interface{}{
  859. "list": list,
  860. })
  861. }
  862. func (this *CustomAPIController) GetDemandInfo() {
  863. id, _ := this.GetInt64("id")
  864. cd, _ := service.FindChargeDemandInfo(id)
  865. if cd.ID == 0 {
  866. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  867. return
  868. }
  869. this.ServeSuccessJSON(map[string]interface{}{
  870. "charge_demand": cd,
  871. })
  872. }
  873. func (this *CustomAPIController) EditDemandInfo() {
  874. id, _ := this.GetInt64("id")
  875. demandType, _ := this.GetInt64("demand_type")
  876. demandDesc := this.GetString("demand_desc")
  877. demandStatus, _ := this.GetInt64("demand_status")
  878. demandCreator := this.GetString("demand_creator")
  879. demandCreateDate := this.GetString("demand_create_date")
  880. demandFinishDate := this.GetString("demand_finish_date")
  881. demandDetail := this.GetString("demand_detail")
  882. demandDirector := this.GetString("demand_director")
  883. cd, _ := service.FindChargeDemandInfo(id)
  884. cd.DemandType = demandType
  885. cd.DemandDesc = demandDesc
  886. cd.DemandStatus = demandStatus
  887. cd.DemandCreator = demandCreator
  888. cd.DemandCreateDate = demandCreateDate
  889. cd.DemandFinishDate = demandFinishDate
  890. cd.DemandDirector = demandDirector
  891. cd.DemandDetail = demandDetail
  892. cd.Mtime = time.Now().Unix()
  893. err := service.SaveChargeDemand(&cd)
  894. if err != nil {
  895. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  896. return
  897. }
  898. this.ServeSuccessJSON(map[string]interface{}{
  899. "demand": cd,
  900. })
  901. }
  902. func (this *CustomAPIController) DeleteDemandInfo() {
  903. id, _ := this.GetInt64("id")
  904. cd, _ := service.FindChargeDemandInfo(id)
  905. if cd.ID == 0 {
  906. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  907. return
  908. }
  909. cd.Status = 0
  910. err := service.SaveChargeDemand(&cd)
  911. if err != nil {
  912. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  913. return
  914. }
  915. this.ServeSuccessJSON(map[string]interface{}{
  916. "msg": "删除成功",
  917. })
  918. }
  919. func (this *CustomAPIController) CheckDemandInfo() {
  920. id, _ := this.GetInt64("id")
  921. cd, _ := service.FindChargeDemandInfo(id)
  922. if cd.ID == 0 {
  923. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  924. return
  925. }
  926. cd.IsCheck = 1
  927. err := service.SaveChargeDemand(&cd)
  928. if err != nil {
  929. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  930. return
  931. }
  932. this.ServeSuccessJSON(map[string]interface{}{
  933. "msg": "审核成功",
  934. })
  935. }
  936. func (this *CustomAPIController) CreateRenewalInfo() {
  937. types, _ := this.GetInt64("type")
  938. startTime := this.GetString("start_time")
  939. endTime := this.GetString("end_time")
  940. signingPersonal := this.GetString("signing_personal")
  941. customID, _ := this.GetInt64("custom_id")
  942. signTime := this.GetString("sign_time")
  943. checkPersonal := this.GetString("check_personal")
  944. ctime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  945. mtime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  946. remark := this.GetString("remark")
  947. // 创建 KyyChargeRenewal 对象,并设置每个字段的值
  948. renewal := models.KyyChargeRenewal{
  949. Type: types,
  950. StartTime: startTime,
  951. EndTime: endTime,
  952. SigningPersonal: signingPersonal,
  953. CustomId: customID,
  954. SignTime: signTime,
  955. CheckPersonal: checkPersonal,
  956. Ctime: ctime,
  957. Mtime: mtime,
  958. Status: 1,
  959. Remark: remark,
  960. }
  961. err := service.SaveChargeRenewal(&renewal)
  962. if err != nil {
  963. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  964. return
  965. }
  966. this.ServeSuccessJSON(map[string]interface{}{
  967. "renewal": renewal,
  968. })
  969. }
  970. func (this *CustomAPIController) GetRenewalInfoList() {
  971. list, _ := service.GetAllChargeRenewal()
  972. this.ServeSuccessJSON(map[string]interface{}{
  973. "list": list,
  974. })
  975. }
  976. func (this *CustomAPIController) GetRenewalInfo() {
  977. id, _ := this.GetInt64("id")
  978. cr, _ := service.FindChargeRenewalInfo(id)
  979. if cr.ID == 0 {
  980. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  981. return
  982. }
  983. this.ServeSuccessJSON(map[string]interface{}{
  984. "charge_renewal": cr,
  985. })
  986. }
  987. func (this *CustomAPIController) EditRenewalInfo() {
  988. types, _ := this.GetInt64("type")
  989. id, _ := this.GetInt64("id")
  990. startTime := this.GetString("start_time")
  991. endTime := this.GetString("end_time")
  992. signingPersonal := this.GetString("signing_personal")
  993. customID, _ := this.GetInt64("custom_id")
  994. signTime := this.GetString("sign_time")
  995. remark := this.GetString("remark")
  996. checkPersonal := this.GetString("check_personal")
  997. mtime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  998. cr, _ := service.FindChargeRenewalInfo(id)
  999. if cr.ID == 0 {
  1000. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1001. return
  1002. }
  1003. cr.Type = types
  1004. cr.CustomId = customID
  1005. cr.StartTime = startTime
  1006. cr.EndTime = endTime
  1007. cr.SigningPersonal = signingPersonal
  1008. cr.SignTime = signTime
  1009. cr.Mtime = mtime
  1010. cr.Remark = remark
  1011. cr.CheckPersonal = checkPersonal
  1012. err := service.SaveChargeRenewal(&cr)
  1013. if err != nil {
  1014. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1015. return
  1016. }
  1017. this.ServeSuccessJSON(map[string]interface{}{
  1018. "cr": cr,
  1019. })
  1020. }
  1021. func (this *CustomAPIController) DeleteRenewalInfo() {
  1022. id, _ := this.GetInt64("id")
  1023. cr, _ := service.FindChargeRenewalInfo(id)
  1024. if cr.ID == 0 {
  1025. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1026. return
  1027. }
  1028. cr.Status = 0
  1029. err := service.SaveChargeRenewal(&cr)
  1030. if err != nil {
  1031. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1032. return
  1033. }
  1034. this.ServeSuccessJSON(map[string]interface{}{
  1035. "msg": "删除成功",
  1036. })
  1037. }
  1038. func (this *CustomAPIController) CheckRenewalInfo() {
  1039. id, _ := this.GetInt64("id")
  1040. cr, _ := service.FindChargeRenewalInfo(id)
  1041. if cr.ID == 0 {
  1042. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1043. return
  1044. }
  1045. cr.IsCheck = 1
  1046. err := service.SaveChargeRenewal(&cr)
  1047. if err != nil {
  1048. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1049. return
  1050. }
  1051. this.ServeSuccessJSON(map[string]interface{}{
  1052. "msg": "审核成功",
  1053. })
  1054. }
  1055. func (c *CustomAPIController) GetQNUpToken() {
  1056. redisClient := service.RedisClient()
  1057. defer redisClient.Close()
  1058. token, err := redisClient.Get("qn_token").Result()
  1059. if err != nil {
  1060. defer fmt.Println(err)
  1061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)
  1062. return
  1063. }
  1064. c.ServeSuccessJSON(map[string]interface{}{
  1065. "uptoken": token,
  1066. })
  1067. return
  1068. }