custom_api_controller.go 34KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  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.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) 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. custom_name := this.GetString("custom_name")
  591. start_time := this.GetString("start_time")
  592. end_time := this.GetString("end_time")
  593. signing_person := this.GetString("signing_person")
  594. wordFileURL := this.GetString("word_file_url")
  595. pdfFileURL := this.GetString("pdf_file_url")
  596. remark := this.GetString("remark")
  597. ctime := time.Now().Unix()
  598. mtime := time.Now().Unix()
  599. // 创建 KyyChargeContract 对象,并设置每个字段的值
  600. contract := models.KyyChargeContract{
  601. CustomId: customID,
  602. Code: code,
  603. Name: name,
  604. Sumamt: sumamt,
  605. StartTime: start_time,
  606. EndTime: end_time,
  607. SigningPerson: signing_person,
  608. WordFileUrl: wordFileURL,
  609. PdfFileUrl: pdfFileURL,
  610. CustomName: custom_name,
  611. Remark: remark,
  612. Ctime: ctime,
  613. Mtime: mtime,
  614. Status: 1,
  615. }
  616. err := service.SaveChargeContract(&contract)
  617. if err != nil {
  618. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  619. return
  620. }
  621. this.ServeSuccessJSON(map[string]interface{}{
  622. "msg": "创建成功",
  623. })
  624. }
  625. func (this *CustomAPIController) GetContractInfoList() {
  626. list, _ := service.GetAllChargeContracts()
  627. this.ServeSuccessJSON(map[string]interface{}{
  628. "list": list,
  629. })
  630. }
  631. func (this *CustomAPIController) GetContractInfo() {
  632. id, _ := this.GetInt64("id")
  633. cc, _ := service.FindChargeContractInfo(id)
  634. if cc.ID == 0 {
  635. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  636. return
  637. }
  638. this.ServeSuccessJSON(map[string]interface{}{
  639. "charge_contract": cc,
  640. })
  641. }
  642. func (this *CustomAPIController) EditContractInfo() {
  643. id, _ := this.GetInt64("id")
  644. code := this.GetString("code")
  645. name := this.GetString("name")
  646. customName := this.GetString("custom_name")
  647. sumamt := this.GetString("sumamt")
  648. startTime := this.GetString("start_time")
  649. endTime := this.GetString("end_time")
  650. signingPerson := this.GetString("signing_person")
  651. wordFileURL := this.GetString("word_file_url")
  652. pdfFileURL := this.GetString("pdf_file_url")
  653. remark := this.GetString("remark")
  654. mtime := time.Now().Unix()
  655. chargeContract, _ := service.FindChargeContractInfo(id)
  656. if chargeContract.ID == 0 {
  657. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  658. return
  659. }
  660. chargeContract.Code = code
  661. chargeContract.Name = name
  662. chargeContract.CustomName = customName
  663. chargeContract.Sumamt = sumamt
  664. chargeContract.StartTime = startTime
  665. chargeContract.EndTime = endTime
  666. chargeContract.SigningPerson = signingPerson
  667. chargeContract.WordFileUrl = wordFileURL
  668. chargeContract.PdfFileUrl = pdfFileURL
  669. chargeContract.Remark = remark
  670. chargeContract.Mtime = mtime
  671. err := service.SaveChargeContract(&chargeContract)
  672. if err != nil {
  673. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  674. return
  675. }
  676. this.ServeSuccessJSON(map[string]interface{}{
  677. "msg": "修改成功",
  678. })
  679. }
  680. func (this *CustomAPIController) DeleteContractInfo() {
  681. id, _ := this.GetInt64("id")
  682. cc, _ := service.FindChargeContractInfo(id)
  683. if cc.ID == 0 {
  684. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  685. return
  686. }
  687. cc.Status = 0
  688. err := service.SaveChargeContract(&cc)
  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) CheckContractInfo() {
  698. id, _ := this.GetInt64("id")
  699. chargeContract, _ := service.FindChargeContractInfo(id)
  700. if chargeContract.ID == 0 {
  701. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  702. return
  703. }
  704. chargeContract.IsCheck = 1
  705. err := service.SaveChargeContract(&chargeContract)
  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) CreateFollowInfo() {
  715. ctime := time.Now().Unix()
  716. mtime := time.Now().Unix()
  717. customID, _ := this.GetInt64("custom_id")
  718. desc := this.GetString("desc")
  719. // 创建 KyyChargeFollow 对象,并设置每个字段的值
  720. follow := models.KyyChargeFollow{
  721. Ctime: ctime,
  722. Mtime: mtime,
  723. Creator: this.GetAdminInfo().ID,
  724. CustomId: customID,
  725. Desc: desc,
  726. Status: 1,
  727. }
  728. err := service.SaveChargeFollow(&follow)
  729. if err != nil {
  730. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  731. return
  732. }
  733. this.ServeSuccessJSON(map[string]interface{}{
  734. "follow": follow,
  735. })
  736. }
  737. func (this *CustomAPIController) GetFollowInfoList() {
  738. list, _ := service.GetAllChargeFollow()
  739. this.ServeSuccessJSON(map[string]interface{}{
  740. "list": list,
  741. })
  742. }
  743. func (this *CustomAPIController) GetFollowInfo() {
  744. id, _ := this.GetInt64("id")
  745. follow, _ := service.FindChargeFollowInfo(id)
  746. if follow.ID == 0 {
  747. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  748. return
  749. }
  750. this.ServeSuccessJSON(map[string]interface{}{
  751. "follow": follow,
  752. })
  753. }
  754. func (this *CustomAPIController) EditFollowInfo() {
  755. id, _ := this.GetInt64("id")
  756. desc := this.GetString("desc")
  757. chargeFollow, _ := service.FindChargeFollowInfo(id)
  758. chargeFollow.Desc = desc
  759. chargeFollow.Mtime = time.Now().Unix()
  760. err := service.SaveChargeFollow(&chargeFollow)
  761. if err != nil {
  762. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  763. return
  764. }
  765. this.ServeSuccessJSON(map[string]interface{}{
  766. "follow": chargeFollow,
  767. })
  768. }
  769. func (this *CustomAPIController) DeleteFollowInfo() {
  770. id, _ := this.GetInt64("id")
  771. follow, _ := service.FindChargeFollowInfo(id)
  772. if follow.ID == 0 {
  773. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  774. return
  775. }
  776. follow.Status = 0
  777. err := service.SaveChargeFollow(&follow)
  778. if err != nil {
  779. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  780. return
  781. }
  782. this.ServeSuccessJSON(map[string]interface{}{
  783. "msg": "删除成功",
  784. })
  785. }
  786. func (this *CustomAPIController) CheckFollowInfo() {
  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.IsCheck = 1
  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) CreateDemandInfo() {
  804. demandType, _ := this.GetInt64("demand_type")
  805. demandDesc := this.GetString("demand_desc")
  806. demandStatus, _ := this.GetInt64("demand_status")
  807. demandCreator := this.GetString("demand_creator")
  808. demandCreateDate := this.GetString("demand_create_date")
  809. demandDirector := this.GetString("demand_director")
  810. ctime := time.Now().Unix()
  811. mtime := time.Now().Unix()
  812. customID, _ := this.GetInt64("custom_id")
  813. demandFinishDate := this.GetString("demand_finish_date")
  814. demandDetail := this.GetString("demand_detail")
  815. // 创建 KyyChargeDemand 对象,并设置每个字段的值
  816. demand := models.KyyChargeDemand{
  817. DemandType: demandType,
  818. DemandDesc: demandDesc,
  819. DemandStatus: demandStatus,
  820. DemandCreator: demandCreator,
  821. DemandCreateDate: demandCreateDate,
  822. DemandDirector: demandDirector,
  823. Ctime: ctime,
  824. Mtime: mtime,
  825. Status: 1,
  826. CustomId: customID,
  827. DemandFinishDate: demandFinishDate,
  828. DemandDetail: demandDetail,
  829. }
  830. err := service.SaveChargeDemand(&demand)
  831. if err != nil {
  832. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  833. return
  834. }
  835. this.ServeSuccessJSON(map[string]interface{}{
  836. "demand": demand,
  837. })
  838. }
  839. func (this *CustomAPIController) GetDemandInfoList() {
  840. list, _ := service.GetAllChargeDemand()
  841. this.ServeSuccessJSON(map[string]interface{}{
  842. "list": list,
  843. })
  844. }
  845. func (this *CustomAPIController) GetDemandInfo() {
  846. id, _ := this.GetInt64("id")
  847. cd, _ := service.FindChargeDemandInfo(id)
  848. if cd.ID == 0 {
  849. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  850. return
  851. }
  852. this.ServeSuccessJSON(map[string]interface{}{
  853. "charge_demand": cd,
  854. })
  855. }
  856. func (this *CustomAPIController) EditDemandInfo() {
  857. id, _ := this.GetInt64("id")
  858. demandType, _ := this.GetInt64("demand_type")
  859. demandDesc := this.GetString("demand_desc")
  860. demandStatus, _ := this.GetInt64("demand_status")
  861. demandCreator := this.GetString("demand_creator")
  862. demandCreateDate := this.GetString("demand_create_date")
  863. demandFinishDate := this.GetString("demand_finish_date")
  864. demandDetail := this.GetString("demand_detail")
  865. demandDirector := this.GetString("demand_director")
  866. cd, _ := service.FindChargeDemandInfo(id)
  867. cd.DemandType = demandType
  868. cd.DemandDesc = demandDesc
  869. cd.DemandStatus = demandStatus
  870. cd.DemandCreator = demandCreator
  871. cd.DemandCreateDate = demandCreateDate
  872. cd.DemandFinishDate = demandFinishDate
  873. cd.DemandDirector = demandDirector
  874. cd.DemandDetail = demandDetail
  875. cd.Mtime = time.Now().Unix()
  876. err := service.SaveChargeDemand(&cd)
  877. if err != nil {
  878. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  879. return
  880. }
  881. this.ServeSuccessJSON(map[string]interface{}{
  882. "demand": cd,
  883. })
  884. }
  885. func (this *CustomAPIController) DeleteDemandInfo() {
  886. id, _ := this.GetInt64("id")
  887. cd, _ := service.FindChargeDemandInfo(id)
  888. if cd.ID == 0 {
  889. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  890. return
  891. }
  892. cd.Status = 0
  893. err := service.SaveChargeDemand(&cd)
  894. if err != nil {
  895. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  896. return
  897. }
  898. this.ServeSuccessJSON(map[string]interface{}{
  899. "msg": "删除成功",
  900. })
  901. }
  902. func (this *CustomAPIController) CheckDemandInfo() {
  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.IsCheck = 1
  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) CreateRenewalInfo() {
  920. types, _ := this.GetInt64("type")
  921. startTime := this.GetString("start_time")
  922. endTime := this.GetString("end_time")
  923. signingPersonal := this.GetString("signing_personal")
  924. customID, _ := this.GetInt64("custom_id")
  925. signTime := this.GetString("sign_time")
  926. checkPersonal := this.GetString("check_personal")
  927. ctime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  928. mtime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  929. remark := this.GetString("remark")
  930. // 创建 KyyChargeRenewal 对象,并设置每个字段的值
  931. renewal := models.KyyChargeRenewal{
  932. Type: types,
  933. StartTime: startTime,
  934. EndTime: endTime,
  935. SigningPersonal: signingPersonal,
  936. CustomId: customID,
  937. SignTime: signTime,
  938. CheckPersonal: checkPersonal,
  939. Ctime: ctime,
  940. Mtime: mtime,
  941. Status: 1,
  942. Remark: remark,
  943. }
  944. err := service.SaveChargeRenewal(&renewal)
  945. if err != nil {
  946. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  947. return
  948. }
  949. this.ServeSuccessJSON(map[string]interface{}{
  950. "renewal": renewal,
  951. })
  952. }
  953. func (this *CustomAPIController) GetRenewalInfoList() {
  954. list, _ := service.GetAllChargeRenewal()
  955. this.ServeSuccessJSON(map[string]interface{}{
  956. "list": list,
  957. })
  958. }
  959. func (this *CustomAPIController) GetRenewalInfo() {
  960. id, _ := this.GetInt64("id")
  961. cr, _ := service.FindChargeRenewalInfo(id)
  962. if cr.ID == 0 {
  963. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  964. return
  965. }
  966. this.ServeSuccessJSON(map[string]interface{}{
  967. "charge_renewal": cr,
  968. })
  969. }
  970. func (this *CustomAPIController) EditRenewalInfo() {
  971. types, _ := this.GetInt64("type")
  972. id, _ := this.GetInt64("id")
  973. startTime := this.GetString("start_time")
  974. endTime := this.GetString("end_time")
  975. signingPersonal := this.GetString("signing_personal")
  976. customID, _ := this.GetInt64("custom_id")
  977. signTime := this.GetString("sign_time")
  978. remark := this.GetString("remark")
  979. checkPersonal := this.GetString("check_personal")
  980. mtime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  981. cr, _ := service.FindChargeRenewalInfo(id)
  982. if cr.ID == 0 {
  983. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  984. return
  985. }
  986. cr.Type = types
  987. cr.CustomId = customID
  988. cr.StartTime = startTime
  989. cr.EndTime = endTime
  990. cr.SigningPersonal = signingPersonal
  991. cr.SignTime = signTime
  992. cr.Mtime = mtime
  993. cr.Remark = remark
  994. cr.CheckPersonal = checkPersonal
  995. err := service.SaveChargeRenewal(&cr)
  996. if err != nil {
  997. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  998. return
  999. }
  1000. this.ServeSuccessJSON(map[string]interface{}{
  1001. "cr": cr,
  1002. })
  1003. }
  1004. func (this *CustomAPIController) DeleteRenewalInfo() {
  1005. id, _ := this.GetInt64("id")
  1006. cr, _ := service.FindChargeRenewalInfo(id)
  1007. if cr.ID == 0 {
  1008. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1009. return
  1010. }
  1011. cr.Status = 0
  1012. err := service.SaveChargeRenewal(&cr)
  1013. if err != nil {
  1014. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1015. return
  1016. }
  1017. this.ServeSuccessJSON(map[string]interface{}{
  1018. "msg": "删除成功",
  1019. })
  1020. }
  1021. func (this *CustomAPIController) CheckRenewalInfo() {
  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.IsCheck = 1
  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 (c *CustomAPIController) GetQNUpToken() {
  1039. redisClient := service.RedisClient()
  1040. defer redisClient.Close()
  1041. token, err := redisClient.Get("qn_token").Result()
  1042. if err != nil {
  1043. defer fmt.Println(err)
  1044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)
  1045. return
  1046. }
  1047. c.ServeSuccessJSON(map[string]interface{}{
  1048. "uptoken": token,
  1049. })
  1050. return
  1051. }