custom_api_controller.go 33KB

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