custom_api_controller.go 33KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  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) DeleteCustom() {
  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.FindCustomInfoByID(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.UpdateCustom(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.UpdateCustom(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.UpdateCustom(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.UpdateCustom(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.UpdateCustom(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.UpdateCustom(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.UpdateCustom(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) DeletePaymentCollection() {
  436. id, _ := this.GetInt64("id")
  437. cpc, _ := service.FindPaymentCollectionInfo(id)
  438. if cpc.ID == 0 {
  439. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  440. return
  441. }
  442. cpc.Status = 0
  443. err := service.SaveChargePaymentCollection(&cpc)
  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) CheckPaymentCollection() {
  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.IsCheck = 1
  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) CreateContactInfo() {
  470. customID, _ := this.GetInt64("custom_id")
  471. contactName := this.GetString("contact_name")
  472. contactPhone := this.GetString("contact_phone")
  473. contactDuties := this.GetString("contact_duties")
  474. isDecision := this.GetString("is_decision")
  475. remark := this.GetString("remark")
  476. contact_way := this.GetString("contact_way")
  477. ctime := time.Now().Unix()
  478. mtime := time.Now().Unix()
  479. // 创建 KyyChargeContact 对象,并设置每个字段的值
  480. contact := models.KyyChargeContact{
  481. ID: 0,
  482. CustomId: customID,
  483. ContactName: contactName,
  484. ContactPhone: contactPhone,
  485. ContactDuties: contactDuties,
  486. IsDecision: isDecision,
  487. Remark: remark,
  488. Ctime: ctime,
  489. Mtime: mtime,
  490. Status: 1,
  491. Creator: 0,
  492. Modifier: 0,
  493. IsCheck: 0,
  494. ContactWay: contact_way,
  495. }
  496. err := service.SaveChargeContact(&contact)
  497. if err != nil {
  498. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  499. return
  500. }
  501. this.ServeSuccessJSON(map[string]interface{}{
  502. "contact": contact,
  503. })
  504. }
  505. func (this *CustomAPIController) GetContactInfoList() {
  506. list, _ := service.GetAllChargeContacts()
  507. this.ServeSuccessJSON(map[string]interface{}{
  508. "list": list,
  509. })
  510. }
  511. func (this *CustomAPIController) GetContactInfo() {
  512. id, _ := this.GetInt64("id")
  513. cc, _ := service.FindChargeContactInfo(id)
  514. if cc.ID == 0 {
  515. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  516. return
  517. }
  518. this.ServeSuccessJSON(map[string]interface{}{
  519. "contact_info": cc,
  520. })
  521. }
  522. func (this *CustomAPIController) EditContactInfo() {
  523. id, _ := this.GetInt64("id")
  524. contactName := this.GetString("contact_name")
  525. contactPhone := this.GetString("contact_phone")
  526. contactDuties := this.GetString("contact_duties")
  527. isDecision := this.GetString("is_decision")
  528. remark := this.GetString("remark")
  529. mtime := time.Now().Unix()
  530. chargeContact, _ := service.FindChargeContactInfo(id)
  531. if chargeContact.ID == 0 {
  532. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  533. return
  534. }
  535. chargeContact.ContactName = contactName
  536. chargeContact.ContactPhone = contactPhone
  537. chargeContact.ContactDuties = contactDuties
  538. chargeContact.IsDecision = isDecision
  539. chargeContact.Remark = remark
  540. chargeContact.Remark = remark
  541. chargeContact.Mtime = mtime
  542. err := service.SaveChargeContact(&chargeContact)
  543. if err != nil {
  544. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  545. return
  546. }
  547. this.ServeSuccessJSON(map[string]interface{}{
  548. "contact": chargeContact,
  549. })
  550. }
  551. func (this *CustomAPIController) DeleteContactInfo() {
  552. id, _ := this.GetInt64("id")
  553. cc, _ := service.FindChargeContactInfo(id)
  554. if cc.ID == 0 {
  555. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  556. return
  557. }
  558. cc.Status = 0
  559. err := service.SaveChargeContact(&cc)
  560. if err != nil {
  561. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  562. return
  563. }
  564. this.ServeSuccessJSON(map[string]interface{}{
  565. "msg": "删除成功",
  566. })
  567. }
  568. func (this *CustomAPIController) CheckContactInfo() {
  569. id, _ := this.GetInt64("id")
  570. chargeContact, _ := service.FindChargeContactInfo(id)
  571. if chargeContact.ID == 0 {
  572. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  573. return
  574. }
  575. chargeContact.IsCheck = 1
  576. err := service.SaveChargeContact(&chargeContact)
  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) CreateContractInfo() {
  586. customID, _ := this.GetInt64("custom_id")
  587. code := this.GetString("code")
  588. name := this.GetString("name")
  589. sumamt := this.GetString("sumamt")
  590. start_time := this.GetString("start_time")
  591. end_time := this.GetString("end_time")
  592. signing_person := this.GetString("signing_person")
  593. wordFileURL := this.GetString("word_file_url")
  594. pdfFileURL := this.GetString("pdf_file_url")
  595. remark := this.GetString("remark")
  596. ctime := time.Now().Unix()
  597. mtime := time.Now().Unix()
  598. // 创建 KyyChargeContract 对象,并设置每个字段的值
  599. contract := models.KyyChargeContract{
  600. CustomId: customID,
  601. Code: code,
  602. Name: name,
  603. Sumamt: sumamt,
  604. StartTime: start_time,
  605. EndTime: end_time,
  606. SigningPerson: signing_person,
  607. WordFileUrl: wordFileURL,
  608. PdfFileUrl: pdfFileURL,
  609. Remark: remark,
  610. Ctime: ctime,
  611. Mtime: mtime,
  612. Status: 1,
  613. }
  614. err := service.SaveChargeContract(&contract)
  615. if err != nil {
  616. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  617. return
  618. }
  619. this.ServeSuccessJSON(map[string]interface{}{
  620. "msg": "创建成功",
  621. })
  622. }
  623. func (this *CustomAPIController) GetContractInfoList() {
  624. list, _ := service.GetAllChargeContracts()
  625. this.ServeSuccessJSON(map[string]interface{}{
  626. "list": list,
  627. })
  628. }
  629. func (this *CustomAPIController) GetContractInfo() {
  630. id, _ := this.GetInt64("id")
  631. cc, _ := service.FindChargeContractInfo(id)
  632. if cc.ID == 0 {
  633. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  634. return
  635. }
  636. this.ServeSuccessJSON(map[string]interface{}{
  637. "charge_contract": cc,
  638. })
  639. }
  640. func (this *CustomAPIController) EditContractInfo() {
  641. id, _ := this.GetInt64("id")
  642. code := this.GetString("code")
  643. name := this.GetString("name")
  644. customName := this.GetString("custom_name")
  645. sumamt := this.GetString("sumamt")
  646. startTime := this.GetString("start_time")
  647. endTime := this.GetString("end_time")
  648. signingPerson := this.GetString("signing_person")
  649. wordFileURL := this.GetString("word_file_url")
  650. pdfFileURL := this.GetString("pdf_file_url")
  651. remark := this.GetString("remark")
  652. mtime := time.Now().Unix()
  653. chargeContract, _ := service.FindChargeContractInfo(id)
  654. if chargeContract.ID == 0 {
  655. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  656. return
  657. }
  658. chargeContract.Code = code
  659. chargeContract.Name = name
  660. chargeContract.CustomName = customName
  661. chargeContract.Sumamt = sumamt
  662. chargeContract.StartTime = startTime
  663. chargeContract.EndTime = endTime
  664. chargeContract.SigningPerson = signingPerson
  665. chargeContract.WordFileUrl = wordFileURL
  666. chargeContract.PdfFileUrl = pdfFileURL
  667. chargeContract.Remark = remark
  668. chargeContract.Mtime = mtime
  669. err := service.SaveChargeContract(&chargeContract)
  670. if err != nil {
  671. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  672. return
  673. }
  674. this.ServeSuccessJSON(map[string]interface{}{
  675. "msg": "修改成功",
  676. })
  677. }
  678. func (this *CustomAPIController) DeleteContractInfo() {
  679. id, _ := this.GetInt64("id")
  680. cc, _ := service.FindChargeContractInfo(id)
  681. if cc.ID == 0 {
  682. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  683. return
  684. }
  685. cc.Status = 0
  686. err := service.SaveChargeContract(&cc)
  687. if err != nil {
  688. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  689. return
  690. }
  691. this.ServeSuccessJSON(map[string]interface{}{
  692. "msg": "删除成功",
  693. })
  694. }
  695. func (this *CustomAPIController) CheckContractInfo() {
  696. id, _ := this.GetInt64("id")
  697. chargeContract, _ := service.FindChargeContractInfo(id)
  698. if chargeContract.ID == 0 {
  699. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  700. return
  701. }
  702. chargeContract.IsCheck = 1
  703. err := service.SaveChargeContract(&chargeContract)
  704. if err != nil {
  705. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  706. return
  707. }
  708. this.ServeSuccessJSON(map[string]interface{}{
  709. "msg": "审核成功",
  710. })
  711. }
  712. func (this *CustomAPIController) CreateFollowInfo() {
  713. ctime := time.Now().Unix()
  714. mtime := time.Now().Unix()
  715. customID, _ := this.GetInt64("custom_id")
  716. desc := this.GetString("desc")
  717. // 创建 KyyChargeFollow 对象,并设置每个字段的值
  718. follow := models.KyyChargeFollow{
  719. Ctime: ctime,
  720. Mtime: mtime,
  721. Creator: this.GetAdminInfo().ID,
  722. CustomId: customID,
  723. Desc: desc,
  724. Status: 1,
  725. }
  726. err := service.SaveChargeFollow(&follow)
  727. if err != nil {
  728. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  729. return
  730. }
  731. this.ServeSuccessJSON(map[string]interface{}{
  732. "follow": follow,
  733. })
  734. }
  735. func (this *CustomAPIController) GetFollowInfoList() {
  736. list, _ := service.GetAllChargeFollow()
  737. this.ServeSuccessJSON(map[string]interface{}{
  738. "list": list,
  739. })
  740. }
  741. func (this *CustomAPIController) GetFollowInfo() {
  742. id, _ := this.GetInt64("id")
  743. follow, _ := service.FindChargeFollowInfo(id)
  744. if follow.ID == 0 {
  745. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  746. return
  747. }
  748. this.ServeSuccessJSON(map[string]interface{}{
  749. "follow": follow,
  750. })
  751. }
  752. func (this *CustomAPIController) EditFollowInfo() {
  753. id, _ := this.GetInt64("id")
  754. desc := this.GetString("desc")
  755. chargeFollow, _ := service.FindChargeFollowInfo(id)
  756. chargeFollow.Desc = desc
  757. chargeFollow.Mtime = time.Now().Unix()
  758. err := service.SaveChargeFollow(&chargeFollow)
  759. if err != nil {
  760. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  761. return
  762. }
  763. this.ServeSuccessJSON(map[string]interface{}{
  764. "follow": chargeFollow,
  765. })
  766. }
  767. func (this *CustomAPIController) DeleteFollowInfo() {
  768. id, _ := this.GetInt64("id")
  769. follow, _ := service.FindChargeFollowInfo(id)
  770. if follow.ID == 0 {
  771. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  772. return
  773. }
  774. follow.Status = 0
  775. err := service.SaveChargeFollow(&follow)
  776. if err != nil {
  777. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  778. return
  779. }
  780. this.ServeSuccessJSON(map[string]interface{}{
  781. "msg": "删除成功",
  782. })
  783. }
  784. func (this *CustomAPIController) CheckFollowInfo() {
  785. id, _ := this.GetInt64("id")
  786. follow, _ := service.FindChargeFollowInfo(id)
  787. if follow.ID == 0 {
  788. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  789. return
  790. }
  791. follow.IsCheck = 1
  792. err := service.SaveChargeFollow(&follow)
  793. if err != nil {
  794. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  795. return
  796. }
  797. this.ServeSuccessJSON(map[string]interface{}{
  798. "msg": "审核成功",
  799. })
  800. }
  801. func (this *CustomAPIController) CreateDemandInfo() {
  802. demandType, _ := this.GetInt64("demand_type")
  803. demandDesc := this.GetString("demand_desc")
  804. demandStatus, _ := this.GetInt64("demand_status")
  805. demandCreator := this.GetString("demand_creator")
  806. demandCreateDate := this.GetString("demand_create_date")
  807. demandDirector := this.GetString("demand_director")
  808. ctime := time.Now().Unix()
  809. mtime := time.Now().Unix()
  810. customID, _ := this.GetInt64("custom_id")
  811. demandFinishDate := this.GetString("demand_finish_date")
  812. demandDetail := this.GetString("demand_detail")
  813. // 创建 KyyChargeDemand 对象,并设置每个字段的值
  814. demand := models.KyyChargeDemand{
  815. DemandType: demandType,
  816. DemandDesc: demandDesc,
  817. DemandStatus: demandStatus,
  818. DemandCreator: demandCreator,
  819. DemandCreateDate: demandCreateDate,
  820. DemandDirector: demandDirector,
  821. Ctime: ctime,
  822. Mtime: mtime,
  823. Status: 1,
  824. CustomId: customID,
  825. DemandFinishDate: demandFinishDate,
  826. DemandDetail: demandDetail,
  827. }
  828. err := service.SaveChargeDemand(&demand)
  829. if err != nil {
  830. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  831. return
  832. }
  833. this.ServeSuccessJSON(map[string]interface{}{
  834. "demand": demand,
  835. })
  836. }
  837. func (this *CustomAPIController) GetDemandInfoList() {
  838. list, _ := service.GetAllChargeDemand()
  839. this.ServeSuccessJSON(map[string]interface{}{
  840. "list": list,
  841. })
  842. }
  843. func (this *CustomAPIController) GetDemandInfo() {
  844. id, _ := this.GetInt64("id")
  845. cd, _ := service.FindChargeDemandInfo(id)
  846. if cd.ID == 0 {
  847. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  848. return
  849. }
  850. this.ServeSuccessJSON(map[string]interface{}{
  851. "charge_demand": cd,
  852. })
  853. }
  854. func (this *CustomAPIController) EditDemandInfo() {
  855. id, _ := this.GetInt64("id")
  856. demandType, _ := this.GetInt64("demand_type")
  857. demandDesc := this.GetString("demand_desc")
  858. demandStatus, _ := this.GetInt64("demand_status")
  859. demandCreator := this.GetString("demand_creator")
  860. demandCreateDate := this.GetString("demand_create_date")
  861. demandDirector := this.GetString("demand_director")
  862. cd, _ := service.FindChargeDemandInfo(id)
  863. cd.DemandType = demandType
  864. cd.DemandDesc = demandDesc
  865. cd.DemandStatus = demandStatus
  866. cd.DemandCreator = demandCreator
  867. cd.DemandCreateDate = demandCreateDate
  868. cd.DemandDirector = demandDirector
  869. cd.Mtime = time.Now().Unix()
  870. err := service.SaveChargeDemand(&cd)
  871. if err != nil {
  872. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  873. return
  874. }
  875. this.ServeSuccessJSON(map[string]interface{}{
  876. "demand": cd,
  877. })
  878. }
  879. func (this *CustomAPIController) DeleteDemandInfo() {
  880. id, _ := this.GetInt64("id")
  881. cd, _ := service.FindChargeDemandInfo(id)
  882. if cd.ID == 0 {
  883. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  884. return
  885. }
  886. cd.Status = 0
  887. err := service.SaveChargeDemand(&cd)
  888. if err != nil {
  889. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  890. return
  891. }
  892. this.ServeSuccessJSON(map[string]interface{}{
  893. "msg": "删除成功",
  894. })
  895. }
  896. func (this *CustomAPIController) CheckDemandInfo() {
  897. id, _ := this.GetInt64("id")
  898. cd, _ := service.FindChargeDemandInfo(id)
  899. if cd.ID == 0 {
  900. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  901. return
  902. }
  903. cd.IsCheck = 1
  904. err := service.SaveChargeDemand(&cd)
  905. if err != nil {
  906. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  907. return
  908. }
  909. this.ServeSuccessJSON(map[string]interface{}{
  910. "msg": "审核成功",
  911. })
  912. }
  913. func (this *CustomAPIController) CreateRenewalInfo() {
  914. types, _ := this.GetInt64("type")
  915. startTime := this.GetString("start_time")
  916. endTime := this.GetString("end_time")
  917. signingPersonal := this.GetString("signing_personal")
  918. customID, _ := this.GetInt64("custom_id")
  919. signTime := this.GetString("sign_time")
  920. checkPersonal := this.GetString("check_personal")
  921. ctime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  922. mtime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  923. remark := this.GetString("remark")
  924. // 创建 KyyChargeRenewal 对象,并设置每个字段的值
  925. renewal := models.KyyChargeRenewal{
  926. Type: types,
  927. StartTime: startTime,
  928. EndTime: endTime,
  929. SigningPersonal: signingPersonal,
  930. CustomId: customID,
  931. SignTime: signTime,
  932. CheckPersonal: checkPersonal,
  933. Ctime: ctime,
  934. Mtime: mtime,
  935. Status: 1,
  936. Remark: remark,
  937. }
  938. err := service.SaveChargeRenewal(&renewal)
  939. if err != nil {
  940. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  941. return
  942. }
  943. this.ServeSuccessJSON(map[string]interface{}{
  944. "renewal": renewal,
  945. })
  946. }
  947. func (this *CustomAPIController) GetRenewalInfoList() {
  948. list, _ := service.GetAllChargeRenewal()
  949. this.ServeSuccessJSON(map[string]interface{}{
  950. "list": list,
  951. })
  952. }
  953. func (this *CustomAPIController) GetRenewalInfo() {
  954. id, _ := this.GetInt64("id")
  955. cr, _ := service.FindChargeRenewalInfo(id)
  956. if cr.ID == 0 {
  957. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  958. return
  959. }
  960. this.ServeSuccessJSON(map[string]interface{}{
  961. "charge_renewal": cr,
  962. })
  963. }
  964. func (this *CustomAPIController) EditRenewalInfo() {
  965. types, _ := this.GetInt64("type")
  966. id, _ := this.GetInt64("id")
  967. startTime := this.GetString("start_time")
  968. endTime := this.GetString("end_time")
  969. signingPersonal := this.GetString("signing_personal")
  970. customID, _ := this.GetInt64("custom_id")
  971. signTime := this.GetString("sign_time")
  972. remark := this.GetString("remark")
  973. checkPersonal := this.GetString("check_personal")
  974. mtime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  975. cr, _ := service.FindChargeRenewalInfo(id)
  976. if cr.ID == 0 {
  977. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  978. return
  979. }
  980. cr.Type = types
  981. cr.CustomId = customID
  982. cr.StartTime = startTime
  983. cr.EndTime = endTime
  984. cr.SigningPersonal = signingPersonal
  985. cr.SignTime = signTime
  986. cr.Mtime = mtime
  987. cr.Remark = remark
  988. cr.CheckPersonal = checkPersonal
  989. err := service.SaveChargeRenewal(&cr)
  990. if err != nil {
  991. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  992. return
  993. }
  994. this.ServeSuccessJSON(map[string]interface{}{
  995. "cr": cr,
  996. })
  997. }
  998. func (this *CustomAPIController) DeleteRenewalInfo() {
  999. id, _ := this.GetInt64("id")
  1000. cr, _ := service.FindChargeRenewalInfo(id)
  1001. if cr.ID == 0 {
  1002. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1003. return
  1004. }
  1005. cr.Status = 0
  1006. err := service.SaveChargeRenewal(&cr)
  1007. if err != nil {
  1008. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1009. return
  1010. }
  1011. this.ServeSuccessJSON(map[string]interface{}{
  1012. "msg": "删除成功",
  1013. })
  1014. }
  1015. func (this *CustomAPIController) CheckRenewalInfo() {
  1016. id, _ := this.GetInt64("id")
  1017. cr, _ := service.FindChargeRenewalInfo(id)
  1018. if cr.ID == 0 {
  1019. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1020. return
  1021. }
  1022. cr.IsCheck = 1
  1023. err := service.SaveChargeRenewal(&cr)
  1024. if err != nil {
  1025. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1026. return
  1027. }
  1028. this.ServeSuccessJSON(map[string]interface{}{
  1029. "msg": "审核成功",
  1030. })
  1031. }
  1032. func (c *CustomAPIController) GetQNUpToken() {
  1033. redisClient := service.RedisClient()
  1034. defer redisClient.Close()
  1035. token, err := redisClient.Get("qn_token").Result()
  1036. if err != nil {
  1037. defer fmt.Println(err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)
  1039. return
  1040. }
  1041. c.ServeSuccessJSON(map[string]interface{}{
  1042. "uptoken": token,
  1043. })
  1044. return
  1045. }