paymentinfo.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/annualaudit"
  4. "dashoo.cn/backend/api/business/oilsupplier/paymentbankinfo"
  5. "dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
  6. "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
  7. "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
  8. "dashoo.cn/backend/api/business/register"
  9. "encoding/json"
  10. "strconv"
  11. "strings"
  12. "time"
  13. "dashoo.cn/backend/api/business/bankapi"
  14. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  15. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  16. "dashoo.cn/backend/api/business/paymentinfo"
  17. . "dashoo.cn/backend/api/controllers"
  18. "dashoo.cn/business2/permission"
  19. "dashoo.cn/utils"
  20. //"wayne-master/src/backend/util/integer"
  21. )
  22. type PaymentInfoController struct {
  23. BaseController
  24. }
  25. // @Title 获取列表
  26. // @Description get user by token
  27. // @Success 200 {object} []paymentinfo.PaymentinfoList
  28. // @router /list [get]
  29. func (this *PaymentInfoController) GetEntityList() {
  30. //获取分页信息
  31. page := this.GetPageInfoForm()
  32. orderby := "p.Id"
  33. where := " 1=1 "
  34. asc := " DESC"
  35. SupplierTypeCode := this.GetString("SupplierTypeCode")
  36. SupplierName := this.GetString("SupplierName")
  37. IsPay := this.GetString("IsPay")
  38. if IsPay != "" {
  39. if IsPay == "0" {
  40. where = where + " and (p.IsPay = '" + IsPay + "' or p.IsPay = '1') "
  41. } else {
  42. where = where + " and p.IsPay = '" + IsPay + "'"
  43. }
  44. }
  45. if SupplierTypeCode != "" {
  46. where = where + " and c.SupplierTypeCode like '%" + SupplierTypeCode + "%'"
  47. }
  48. if SupplierName != "" {
  49. where = where + " and s.SupplierName like '%" + SupplierName + "%'"
  50. }
  51. //svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  52. //var list []suppliercert.OilSupplierCert
  53. svcPerm := permission.GetPermissionService(utils.DBE)
  54. var registerUser register.OilCorporateInfo
  55. sql := " UserName='" + this.User.Username + "'"
  56. svcPerm.GetEntity(&registerUser, sql)
  57. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.PaymentInfo.AllRecord")
  58. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  59. where = where + " and (p.CreateUserId = '" + this.User.Id + "' or s.CommercialNo='" + registerUser.CommercialNo + "') "
  60. }
  61. var paylist []paymentinfo.PaymentinfoList
  62. svc := paymentinfo.GetPaymentService(utils.DBE)
  63. total := svc.GetPaymentinfoList(page.CurrentPage, page.Size, orderby, asc, &paylist, where)
  64. //total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  65. var datainfo DataInfo
  66. datainfo.Items = paylist
  67. datainfo.CurrentItemCount = total
  68. datainfo.PageIndex = page.CurrentPage
  69. datainfo.ItemsPerPage = page.Size
  70. this.Data["json"] = &datainfo
  71. this.ServeJSON()
  72. }
  73. // @Title 获取列表
  74. // @Description get user by token
  75. // @Success 200 {object} []paymentinfo.PaymentinfoList
  76. // @router /get-bill-list [post]
  77. func (this *PaymentInfoController) GetBillList() {
  78. var icbcBillQueryParam bankapi.ICBCBillQueryParam
  79. var jsonBlob = this.Ctx.Input.RequestBody
  80. json.Unmarshal(jsonBlob, &icbcBillQueryParam)
  81. var supplierEntity supplier.OilSupplier
  82. supplierSvc := supplier.GetOilSupplierService(utils.DBE)
  83. supplierWhere := "1=1 and CommercialNo='" + icbcBillQueryParam.CommercialNo + "'" // IsPay=1
  84. supplierSvc.DBE.Where(supplierWhere).Get(&supplierEntity)
  85. var billList []paymentinfo.OilPaymentInfo
  86. billWhere := "1=1 and IsPay='1' and SupplierId='" + strconv.Itoa(supplierEntity.Id) + "'"
  87. svc := paymentinfo.GetPaymentService(utils.DBE)
  88. svc.DBE.Where(billWhere).OrderBy("Id DESC").Find(&billList)
  89. //获取分页信息
  90. //page := this.GetPageInfoForm()
  91. var datainfo DataInfo
  92. datainfo.Items = billList
  93. //datainfo.CurrentItemCount = integer.Int2Int64(len(billList))
  94. // datainfo.CurrentItemCount = 10
  95. datainfo.CurrentItemCount = int64(len(billList))
  96. datainfo.PageIndex = 1
  97. datainfo.ItemsPerPage = 1000
  98. this.Data["json"] = &datainfo
  99. this.ServeJSON()
  100. }
  101. // @Title 获取实体
  102. // @Description 获取实体
  103. // @Success 200 {object} paymentinfo.PaymentinfoList
  104. // @router /get/:id [get]
  105. func (this *PaymentInfoController) GetEntity() {
  106. Id := this.Ctx.Input.Param(":id")
  107. var model []paymentinfo.PaymentinfoList
  108. svc := paymentinfo.GetPaymentService(utils.DBE)
  109. svc.GetPaymentinfoById(Id, &model)
  110. this.Data["json"] = &model[0]
  111. this.ServeJSON()
  112. }
  113. // @Title 修改实体
  114. // @Description 修改实体
  115. // @Param body body paymentinfo.Paymentinfo
  116. // @Success 200 {object} controllers.Request
  117. // @router /update/:id [post]
  118. func (this *PaymentInfoController) UpdateEntity() {
  119. id := this.Ctx.Input.Param(":id")
  120. var errinfo ErrorInfo
  121. if id == "" {
  122. errinfo.Message = "操作失败!请求信息不完整"
  123. errinfo.Code = -2
  124. this.Data["json"] = &errinfo
  125. this.ServeJSON()
  126. return
  127. }
  128. var model paymentinfo.OilPaymentInfo
  129. svc := paymentinfo.GetPaymentService(utils.DBE)
  130. var jsonBlob = this.Ctx.Input.RequestBody
  131. json.Unmarshal(jsonBlob, &model)
  132. model.ModifiedOn = time.Now()
  133. model.ModifiedBy = this.User.Realname
  134. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  135. cols := []string{
  136. "IsPay",
  137. "PayMode",
  138. "PayDate",
  139. "BankSerialNum",
  140. "BankName",
  141. "Remark",
  142. "ModifiedOn",
  143. "ModifiedUserId",
  144. "ModifiedBy",
  145. }
  146. _, err := svc.UpdateEntityByIdCols(id, &model, cols)
  147. if model.IsPay == "2" {
  148. var certentity suppliercert.OilSupplierCert
  149. certentity.Status = suppliercert.STOREING_STATUS
  150. certentity.Step = 5
  151. cols = []string{
  152. "Status",
  153. "Step",
  154. }
  155. _, err = svc.UpdateEntityByIdCols(strconv.Itoa(model.SupplierCertId), &certentity, cols)
  156. }
  157. if err == nil {
  158. errinfo.Message = "修改成功!"
  159. errinfo.Code = 0
  160. this.Data["json"] = &errinfo
  161. this.ServeJSON()
  162. } else {
  163. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  164. errinfo.Code = -1
  165. this.Data["json"] = &errinfo
  166. this.ServeJSON()
  167. }
  168. }
  169. // @Title 修改金额
  170. // @Description 修改实体
  171. // @Param body body paymentinfo.Paymentinfo
  172. // @Success 200 {object} controllers.Request
  173. // @router /updateAmount/:id [post]
  174. func (this *PaymentInfoController) UpdateAmount() {
  175. id := this.Ctx.Input.Param(":id")
  176. var errinfo ErrorInfo
  177. if id == "" {
  178. errinfo.Message = "操作失败!请求信息不完整"
  179. errinfo.Code = -2
  180. this.Data["json"] = &errinfo
  181. this.ServeJSON()
  182. return
  183. }
  184. var model paymentinfo.OilPaymentInfo
  185. svc := paymentinfo.GetPaymentService(utils.DBE)
  186. var jsonBlob = this.Ctx.Input.RequestBody
  187. json.Unmarshal(jsonBlob, &model)
  188. cols := []string{
  189. "Amount",
  190. }
  191. _, err := svc.UpdateEntityByIdCols(id, &model, cols)
  192. if err == nil {
  193. errinfo.Message = "修改成功!"
  194. errinfo.Code = 0
  195. this.Data["json"] = &errinfo
  196. this.ServeJSON()
  197. } else {
  198. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  199. errinfo.Code = -1
  200. this.Data["json"] = &errinfo
  201. this.ServeJSON()
  202. }
  203. }
  204. type BillInfoSure struct {
  205. SupplierEntity supplier.OilSupplier
  206. DataInfos [2]DataInfo
  207. AmountList [2]float64
  208. }
  209. // @Title 获取实体
  210. // @Description 获取实体
  211. // @Success 200 {object} BillInfoSure
  212. // @router /getbillinfo [get]
  213. func (this *PaymentInfoController) GetBillInfo() {
  214. regSvc := register.GetOilCorporateInfoService(utils.DBE)
  215. supplierSvc := supplier.GetOilSupplierService(utils.DBE)
  216. var corporateInfo register.OilCorporateInfo
  217. regSvc.GetEntity(&corporateInfo, "UserId='"+this.User.Id+"'")
  218. var supplierEntity supplier.OilSupplier
  219. supplierSvc.GetEntity(&supplierEntity, "CommercialNo='"+corporateInfo.CommercialNo+"'")
  220. billInfoSure := new(BillInfoSure)
  221. billInfoSure.SupplierEntity = supplierEntity
  222. page := this.GetPageInfoForm()
  223. orderby := "p.Id"
  224. where := "p.SupplierId='" + strconv.Itoa(supplierEntity.Id) + "' and p.IsPay='0' "
  225. var paylist []paymentinfo.PaymentinfoList
  226. svc := paymentinfo.GetPaymentService(utils.DBE)
  227. total := svc.GetPaymentinfoList(page.CurrentPage, page.Size, orderby, " ASC", &paylist, where)
  228. //total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  229. var datainfo DataInfo
  230. datainfo.Items = paylist
  231. datainfo.CurrentItemCount = total
  232. datainfo.PageIndex = page.CurrentPage
  233. datainfo.ItemsPerPage = page.Size
  234. amount1 := 0.0
  235. for _, payItem := range paylist {
  236. tmpAmount, _ := strconv.ParseFloat(payItem.Amount, 64)
  237. amount1 += tmpAmount
  238. }
  239. orderby2 := "p.Id"
  240. where2 := "p.SupplierId='" + strconv.Itoa(supplierEntity.Id) + "' and p.IsPay='1' "
  241. var paylist2 []paymentinfo.PaymentinfoList
  242. svc2 := paymentinfo.GetPaymentService(utils.DBE)
  243. total2 := svc2.GetPaymentinfoList(page.CurrentPage, page.Size, orderby2, " ASC", &paylist2, where2)
  244. //total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  245. var datainfo2 DataInfo
  246. datainfo2.Items = paylist2
  247. datainfo2.CurrentItemCount = total2
  248. datainfo2.PageIndex = page.CurrentPage
  249. datainfo2.ItemsPerPage = page.Size
  250. amount2 := 0.0
  251. for _, payItem := range paylist2 {
  252. tmpAmount, _ := strconv.ParseFloat(payItem.Amount, 64)
  253. amount2 += tmpAmount
  254. }
  255. billInfoSure.DataInfos[0] = datainfo
  256. billInfoSure.DataInfos[1] = datainfo2
  257. billInfoSure.AmountList[0] = amount1
  258. billInfoSure.AmountList[1] = amount2
  259. this.Data["json"] = &billInfoSure
  260. this.ServeJSON()
  261. }
  262. type BillSure struct {
  263. Ids string `json:"ids"`
  264. }
  265. // @Title 确认缴费单
  266. // @Description 确认缴费单
  267. // @Success 200 {object} controllers.Request
  268. // @router /bill-sure [post]
  269. func (this *PaymentInfoController) SureEntity() {
  270. svc := paymentinfo.GetPaymentService(utils.DBE)
  271. var billSure BillSure
  272. var jsonBlob = this.Ctx.Input.RequestBody
  273. json.Unmarshal(jsonBlob, &billSure)
  274. strIds := strings.Trim(billSure.Ids, ",")
  275. sql := "update OilPaymentInfo set IsPay = 1, "
  276. sql += "SureBatchNo='" + strconv.FormatInt(time.Now().UnixNano(), 10) + "', "
  277. sql += "ModifiedOn='" + time.Now().Format("2006-01-02 15:04:05") + "', "
  278. sql += "ModifiedBy='" + this.User.Realname + "', "
  279. sql += "ModifiedUserId='" + this.User.Id + "' "
  280. sql += " where id in (" + strIds + ") and IsPay = 0"
  281. svc.DBE.Query(sql)
  282. var errinfo ErrorInfo
  283. errinfo.Message = "修改成功!"
  284. errinfo.Code = 0
  285. this.Data["json"] = &errinfo
  286. this.ServeJSON()
  287. }
  288. // @Title 确认缴费单--回调
  289. // @Description 确认缴费单
  290. // @Success 200 {object} controllers.Request
  291. // @router /receive-money-bill-list [post]
  292. func (this *PaymentInfoController) ReceiveMoneyBillList() {
  293. var errinfo ErrorInfo
  294. svc := paymentinfo.GetPaymentService(utils.DBE)
  295. var billParams bankapi.BillReceiveMoneyParams
  296. var jsonBlob = this.Ctx.Input.RequestBody
  297. json.Unmarshal(jsonBlob, &billParams)
  298. //已有的银行流水号说明是重复调用,将被丢弃
  299. cntWhere := " 1= 1 and BankSerialNum = '" + billParams.BankSerialNum + "' "
  300. var paymentInfoCnt []paymentinfo.OilPaymentInfo
  301. svc.GetEntities(&paymentInfoCnt, cntWhere)
  302. if paymentInfoCnt != nil && len(paymentInfoCnt) > 0 {
  303. errinfo.Message = "重复调用"
  304. errinfo.Code = -1
  305. this.Data["json"] = &errinfo
  306. this.ServeJSON()
  307. return
  308. }
  309. strIds := strings.Trim(billParams.Ids, ",")
  310. sqlList := "id in (" + strIds + ") and IsPay = '1'"
  311. var paymentInfos []paymentinfo.OilPaymentInfo
  312. svc.GetEntities(&paymentInfos, sqlList)
  313. t := time.Now()
  314. sql := "update OilPaymentInfo set IsPay = '2', "
  315. sql += "BankName='" + billParams.BankName + "', "
  316. sql += "BankSerialNum='" + billParams.BankSerialNum + "', "
  317. sql += "PayDate='" + billParams.PayDate.Format("2006-01-02 15:04:05") + "', "
  318. sql += "PayMode='" + billParams.PayMode + "', "
  319. sql += "ModifiedOn='" + t.Format("2006-01-02 15:04:05") + "', "
  320. sql += "ModifiedBy='" + this.User.Realname + "', "
  321. sql += "ModifiedUserId='" + this.User.Id + "' "
  322. sql += " where Id in (" + strIds + ") and IsPay = '1'"
  323. svc.DBE.Query(sql)
  324. for _, payItem := range paymentInfos {
  325. if payItem.PayType == "1" { //准入
  326. var certentity suppliercert.OilSupplierCert
  327. certentity.Status = suppliercert.STOREING_STATUS
  328. certentity.Step = 5
  329. cols := []string{
  330. "Status",
  331. "Step",
  332. }
  333. svc.UpdateEntityByIdCols(strconv.Itoa(payItem.SupplierCertId), &certentity, cols)
  334. } else if payItem.PayType == "2" { //年审
  335. //TODO: 修改年审时间
  336. annuasvc := annualaudit.GetOilAnnualAuditService(utils.DBE)
  337. var annualentities []annualaudit.OilAnnualAudit
  338. annwhere := " SupplierId = " + utils.ToStr(payItem.SupplierId) + " and CerId = " + utils.ToStr(payItem.SupplierCertId) + " and Status = '6'"
  339. svc.GetEntitysByWhere(OilAnnualAuditName, annwhere, &annualentities)
  340. if len(annualentities) > 0 {
  341. //更新年审表时间
  342. var annmodel annualaudit.OilAnnualAudit
  343. annmodel.Status = suppliercert.ALL_PASE_STATUS
  344. annmodel.ApplyTime = annualentities[0].ApplyTime.AddDate(1, 0, 0)
  345. annuasvc.UpdateEntityBywheretbl(OilAnnualAuditName, &annmodel, []string{"ApplyTime", "Status"}, annwhere)
  346. //更新准入表时间
  347. var certmodel suppliercert.OilSupplierCert
  348. certmodel.ApplyTime = annualentities[0].ApplyTime.AddDate(1, 0, 0)
  349. svc.UpdateEntityByIdCols(strconv.Itoa(payItem.SupplierCertId), &certmodel, []string{"ApplyTime"})
  350. }
  351. } else if payItem.PayType == "3" { //增项
  352. appsvc := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
  353. //更新准入项表
  354. appendwhere := " SupplierId = " + utils.ToStr(payItem.SupplierId) + " and SupplierCertId = " + utils.ToStr(payItem.SupplierCertId) + " and Type = '2'"
  355. var appendsubmodel suppliercertsub.OilSupplierCertSub
  356. appendsubmodel.Type = "3"
  357. appsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &appendsubmodel, []string{"Type"}, appendwhere)
  358. //更新资质表
  359. appendfilewhere := " SupplierId = " + utils.ToStr(payItem.SupplierId) + " and SupType = 2"
  360. var appendsubfilemodel supplierfile.OilSupplierFile
  361. appendsubfilemodel.SupType = 3
  362. appsvc.UpdateEntityBywheretbl(OilSupplierCertSubName, &appendsubfilemodel, []string{"SupType"}, appendfilewhere)
  363. //更新增项表
  364. appdwhere := " SupplierId = " + utils.ToStr(payItem.SupplierId) + " and SupplierCertId = " + utils.ToStr(payItem.SupplierCertId) + " and Status = '6'"
  365. var appendmodel suppliercertappend.OilSupplierCertAppend
  366. appendmodel.Status = suppliercert.ALL_PASE_STATUS
  367. appsvc.UpdateEntityBywheretbl(OilSupplierCertAppendName, &appendmodel, []string{"Status"}, appdwhere)
  368. }
  369. }
  370. //记录对账日志
  371. paymentBankInfo := new(paymentbankinfo.OilPaymentBankInfo)
  372. paymentBankInfo.BillIds = billParams.Ids
  373. paymentBankInfo.PayMode = billParams.PayMode
  374. paymentBankInfo.PayDate = billParams.PayDate
  375. paymentBankInfo.BankSerialNum = billParams.BankSerialNum
  376. paymentBankInfo.ReceiveAmount = billParams.ReceiveAmount
  377. paymentBankInfo.BankName = billParams.BankName
  378. paymentBankInfo.CreateUserId = 0
  379. paymentBankInfo.CreateOn = time.Now()
  380. paymentBankInfo.ModifiedUserId = 0
  381. paymentBankInfo.ModifiedOn = time.Now()
  382. paymentBankInfo.WriteInType = "1" //初次回调
  383. payBankSvc := paymentbankinfo.GetPaymentSelectService(utils.DBE)
  384. payBankSvc.InsertEntity(paymentBankInfo)
  385. errinfo.Message = "修改成功!"
  386. errinfo.Code = 0
  387. this.Data["json"] = &errinfo
  388. this.ServeJSON()
  389. }
  390. // @Title 对账后有未更改状态的,再次确认缴费单--回调
  391. // @Description 确认缴费单
  392. // @Success 200 {object} controllers.Request
  393. // @router /receive-money-again-list [post]
  394. func (this *PaymentInfoController) ReceiveMoneyAgainList() {
  395. var errinfo ErrorInfo
  396. svc := paymentinfo.GetPaymentService(utils.DBE)
  397. var billParams []bankapi.BillReceiveMoneyAgainParams
  398. var jsonBlob = this.Ctx.Input.RequestBody
  399. json.Unmarshal(jsonBlob, &billParams)
  400. for _, billItem := range billParams {
  401. t := time.Now()
  402. sql := "update OilPaymentInfo set IsPay = 2, "
  403. sql += "BankName='" + billItem.BankName + "', "
  404. sql += "BankSerialNum='" + billItem.BankSerialNum + "', "
  405. sql += "PayDate='" + billItem.PayDate.Format("2006-01-02 15:04:05") + "', "
  406. sql += "PayMode='" + billItem.PayMode + "', "
  407. sql += "ModifiedOn='" + t.Format("2006-01-02 15:04:05") + "', "
  408. sql += "ModifiedBy='" + this.User.Realname + "', "
  409. sql += "ModifiedUserId='" + this.User.Id + "' "
  410. sql += " where id = " + billItem.BillId + " and IsPay = '1'"
  411. svc.DBE.Query(sql)
  412. strIds := strings.Trim(billItem.BillId, ",")
  413. sqlList := " 1=1 and Id in (" + strIds + ") and IsPay = '1'"
  414. var paymentInfo paymentinfo.OilPaymentInfo
  415. utils.DBE.Find(&paymentInfo, sqlList)
  416. if paymentInfo.PayType == "1" { //准入
  417. var certentity suppliercert.OilSupplierCert
  418. certentity.Status = suppliercert.STOREING_STATUS
  419. certentity.Step = 5
  420. cols := []string{
  421. "Status",
  422. "Step",
  423. }
  424. svc.UpdateEntityByIdCols(strconv.Itoa(paymentInfo.SupplierCertId), &certentity, cols)
  425. } else if paymentInfo.PayType == "2" { //年审
  426. //TODO: 修改年审时间
  427. } else if paymentInfo.PayType == "3" { //增项
  428. }
  429. //记录对账日志
  430. paymentBankInfo := new(paymentbankinfo.OilPaymentBankInfo)
  431. paymentBankInfo.BillIds = billItem.BillId
  432. paymentBankInfo.PayMode = billItem.PayMode
  433. paymentBankInfo.PayDate = billItem.PayDate
  434. paymentBankInfo.BankSerialNum = billItem.BankSerialNum
  435. paymentBankInfo.ReceiveAmount = billItem.ReceiveAmount
  436. paymentBankInfo.BankName = billItem.BankName
  437. paymentBankInfo.CreateUserId = 0
  438. paymentBankInfo.CreateOn = time.Now()
  439. paymentBankInfo.ModifiedUserId = 0
  440. paymentBankInfo.ModifiedOn = time.Now()
  441. paymentBankInfo.WriteInType = "2" //对账发现未修改成功时的回调
  442. payBankSvc := paymentbankinfo.GetPaymentSelectService(utils.DBE)
  443. payBankSvc.InsertEntity(paymentBankInfo)
  444. }
  445. errinfo.Message = "修改成功!"
  446. errinfo.Code = 0
  447. this.Data["json"] = &errinfo
  448. this.ServeJSON()
  449. }
  450. // @Title 对账
  451. // @Description 对账
  452. // @Success 200 {object} controllers.Request
  453. // @router /check-money-list [post]
  454. func (this *PaymentInfoController) CheckMoneyList() {
  455. svc := paymentinfo.GetPaymentService(utils.DBE)
  456. var checkMoneyParams bankapi.BillCheckMoneyParams
  457. var jsonBlob = this.Ctx.Input.RequestBody
  458. json.Unmarshal(jsonBlob, &checkMoneyParams)
  459. checkRet := new(bankapi.BillCheckMoneyRet)
  460. paymentWhere := "1=1 and IsPay='2' "
  461. paymentWhere += " and PayDate >= '" + checkMoneyParams.StartTime.Format("2006-01-02 15:04:05") + "'"
  462. paymentWhere += " and PayDate <= '" + checkMoneyParams.EndTime.Format("2006-01-02 15:04:05") + "'"
  463. svc.GetEntities(&(checkRet.PaymentInfos), paymentWhere)
  464. bankWhere := "1=1"
  465. bankWhere += " and PayDate >= '" + checkMoneyParams.StartTime.Format("2006-01-02 15:04:05") + "'"
  466. bankWhere += " and PayDate <= '" + checkMoneyParams.EndTime.Format("2006-01-02 15:04:05") + "'"
  467. svc.GetEntities(&(checkRet.PaymentBankInfos), bankWhere)
  468. var datainfo DataInfo
  469. datainfo.Items = checkRet
  470. this.Data["json"] = &datainfo
  471. this.ServeJSON()
  472. }
  473. // @Title 删除单条信息
  474. // @Description
  475. // @Success 200 {object} ErrorInfo
  476. // @Failure 403 :id 为空
  477. // @router /delete/:Id [delete]
  478. func (this *PaymentInfoController) DeleteEntity() {
  479. Id := this.Ctx.Input.Param(":Id")
  480. var errinfo ErrorInfo
  481. if Id == "" {
  482. errinfo.Message = "操作失败!请求信息不完整"
  483. errinfo.Code = -2
  484. this.Data["json"] = &errinfo
  485. this.ServeJSON()
  486. return
  487. }
  488. var emptyModel paymentinfo.OilPaymentInfo
  489. var model paymentinfo.OilPaymentInfo
  490. svc := paymentinfo.GetPaymentService(utils.DBE)
  491. svc.GetEntityById(Id, &model)
  492. // where := "Id=" + Id
  493. // err := svc.DeleteEntityBytbl(OilPaymentInfoName, where)
  494. err := svc.DeleteEntityAndBackup(Id, &model, &emptyModel, utils.ToStr(this.User.Id), this.User.Username)
  495. if err != nil {
  496. errinfo.Message = "删除失败!"
  497. errinfo.Code = -1
  498. this.Data["json"] = &errinfo
  499. this.ServeJSON()
  500. return
  501. }
  502. if err == nil {
  503. var cert suppliercert.OilSupplierCert
  504. cert.Status = suppliercert.STOREING_STATUS
  505. cols := []string{"Status"}
  506. where := "Id=" + strconv.Itoa(model.SupplierCertId)
  507. svc.UpdateEntityBywheretbl(OilSupplierCertName, &cert, cols, where)
  508. errinfo.Message = "删除成功"
  509. errinfo.Code = 0
  510. this.Data["json"] = &errinfo
  511. this.ServeJSON()
  512. } else {
  513. errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
  514. errinfo.Code = -1
  515. this.Data["json"] = &errinfo
  516. this.ServeJSON()
  517. }
  518. }
  519. // @Title 修改金额
  520. // @Description 修改实体
  521. // @Param body body paymentinfo.Paymentinfo
  522. // @Success 200 {object} controllers.Request
  523. // @router /addpayinfo [post]
  524. func (this *PaymentInfoController) AddPayInfo() {
  525. supplierId := this.GetString("SupplierId")
  526. payType := this.GetString("PayType")
  527. amount := this.GetString("Amount")
  528. supplierTypeCode := this.GetString("SupplierTypeCode")
  529. var supp supplier.OilSupplier
  530. svc := paymentinfo.GetPaymentService(utils.DBE)
  531. has := svc.GetEntityById(supplierId, &supp)
  532. var errinfo ErrorInfo
  533. if !has {
  534. errinfo.Message = "没有相关企业信息!"
  535. errinfo.Code = -2
  536. this.Data["json"] = &errinfo
  537. this.ServeJSON()
  538. return
  539. }
  540. var cert []suppliercert.OilSupplierCert
  541. wherec := "SupplierId=" + supplierId + " and SupplierTypeCode='" + supplierTypeCode + "'"
  542. svc.GetEntities(&cert, wherec)
  543. if cert == nil {
  544. errinfo.Message = "没有相关企业信息!"
  545. errinfo.Code = -2
  546. this.Data["json"] = &errinfo
  547. this.ServeJSON()
  548. return
  549. }
  550. where := "SupplierId=" + strconv.Itoa(supp.Id) + " and USCCode='" + supp.CommercialNo + "' and PayType='" + payType + "' and SupplierCertId=" + strconv.Itoa(cert[0].Id)
  551. var model1 paymentinfo.OilPaymentInfo
  552. has = svc.GetEntity(&model1, where)
  553. if has {
  554. errinfo.Message = "已经存在相关缴费记录,不能重复添加!"
  555. errinfo.Code = -2
  556. this.Data["json"] = &errinfo
  557. this.ServeJSON()
  558. return
  559. }
  560. var model paymentinfo.OilPaymentInfo
  561. model.SupplierId,_ = strconv.Atoi(supplierId)
  562. model.SupplierCertId = cert[0].Id
  563. model.SupplierName = supp.SupplierName
  564. model.USCCode = supp.CommercialNo
  565. model.PayType = payType
  566. model.IsPay = "0"
  567. model.Amount = amount
  568. model.CreateOn = time.Now()
  569. model.CreateBy = this.User.Realname
  570. model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
  571. _,err := svc.InsertEntity(&model)
  572. if err == nil {
  573. errinfo.Message = "添加成功!"
  574. errinfo.Code = 0
  575. this.Data["json"] = &errinfo
  576. this.ServeJSON()
  577. } else {
  578. errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
  579. errinfo.Code = -1
  580. this.Data["json"] = &errinfo
  581. this.ServeJSON()
  582. }
  583. }