contract_paid_api.go 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * @description: 合同已支付相关
  3. * @Author: CP
  4. * @Date: 2020-12-22 11:45:22
  5. * @FilePath: \construction_management\web\api\contract_paid_api.go
  6. */
  7. package api
  8. import (
  9. "fmt"
  10. "github.com/kataras/iris/v12"
  11. "go.mod/models"
  12. "go.mod/web/utils"
  13. )
  14. // @Summary 获得已支付列表
  15. // @Tags 合同管理-支出合同
  16. // @Description 获得已支付列表
  17. // @Accept json
  18. // @Produce json
  19. // @Security ApiKeyAuth
  20. // @Param contractsId path string true "合同ID"
  21. // @Param bidsectionId path string true "标段ID"
  22. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
  23. // @Router /api/contract/paid/list [get]
  24. func (c *ContractApi) GetPaidList() {
  25. returnData, err := c.ServiceContract.ValidRuleContractPaid(c.Ctx)
  26. // 项目ID
  27. projectId, err := utils.GetProjectId(c.Ctx)
  28. if err != nil {
  29. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  30. return
  31. }
  32. // 标段ID
  33. bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
  34. if err != nil {
  35. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  36. return
  37. }
  38. // 合同ID
  39. contractsId, err := utils.GetDecryptId(returnData.ContractsId)
  40. if err != nil {
  41. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  42. return
  43. }
  44. returnList := c.ServiceContract.PaidAll(projectId, bidsectionId, contractsId, returnData.Page)
  45. c.Ctx.JSON(iris.Map{
  46. "code": 0,
  47. "msg": "",
  48. "data": returnList,
  49. })
  50. }
  51. // @Summary 新增已支付
  52. // @Tags 合同管理-支出合同
  53. // @Description 新增已支付
  54. // @Accept json
  55. // @Produce json
  56. // @Security ApiKeyAuth
  57. // @Param contractsId path string true "合同ID"
  58. // @Param bidsectionId path string true "标段ID"
  59. // @Param time path string true "已支付时间"
  60. // @Param Price path string true "已支付金额"
  61. // @Param Way path string true "已支付方式"
  62. // @Param remarks path string true "备注"
  63. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
  64. // @Router /api/contract/paid/create [post]
  65. func (c *ContractApi) PostPaidCreate() {
  66. // 验证参数
  67. returnData, err := c.ServiceContract.ValidRuleContractPaidAdd(c.Ctx)
  68. if err != nil {
  69. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  70. return
  71. }
  72. // 项目ID
  73. projectId, err := utils.GetProjectId(c.Ctx)
  74. if err != nil {
  75. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  76. return
  77. }
  78. // 标段ID
  79. bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
  80. if err != nil {
  81. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  82. return
  83. }
  84. // 合同ID
  85. contractsId, err := utils.GetDecryptId(returnData.ContractsId)
  86. if err != nil {
  87. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  88. return
  89. }
  90. // 获得项目账号ID
  91. projectAccountId, err := utils.GetProjectAccountId(c.Ctx)
  92. if err != nil {
  93. c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  94. return
  95. }
  96. account := c.Ctx.Values().Get("account").(*models.CmProjectAccount)
  97. returnData.CreateUser = account.Name
  98. err = c.ServiceContract.PaidCreate(returnData, projectId, bidsectionId, contractsId, projectAccountId)
  99. contractData := c.ServiceContract.GetContract(contractsId)
  100. if err != nil {
  101. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  102. return
  103. }
  104. c.Ctx.JSON(iris.Map{"code": 0, "msg": "新增成功", "contract": contractData})
  105. }
  106. // @Summary 更新已支付
  107. // @Tags 合同管理-支出合同
  108. // @Description 更新已支付
  109. // @Accept json
  110. // @Produce json
  111. // @Security ApiKeyAuth
  112. // @Param id path string true "已支付ID"
  113. // @Param contractsId path string true "合同ID"
  114. // @Param bidsectionId path string true "标段ID"
  115. // @Param time path string true "已支付时间"
  116. // @Param Price path string true "已支付金额"
  117. // @Param Way path string true "已支付方式"
  118. // @Param remarks path string true "备注"
  119. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
  120. // @Router /api/contract/paid/update [post]
  121. func (c *ContractApi) PostPaidUpdate() {
  122. // 验证参数
  123. returnData, err := c.ServiceContract.ValidRuleContractPaidAdd(c.Ctx)
  124. if err != nil {
  125. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  126. return
  127. }
  128. // 项目ID
  129. projectId, err := utils.GetProjectId(c.Ctx)
  130. if err != nil {
  131. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  132. return
  133. }
  134. // 标段ID
  135. bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
  136. if err != nil {
  137. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  138. return
  139. }
  140. // 合同ID
  141. contractsId, err := utils.GetDecryptId(returnData.ContractsId)
  142. if err != nil {
  143. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  144. return
  145. }
  146. if returnData.Id == "" {
  147. c.Ctx.JSON(iris.Map{"code": -1, "msg": "已支付ID不能为空"})
  148. return
  149. }
  150. // 已支付ID
  151. id, err := utils.GetDecryptId(returnData.Id)
  152. if err != nil {
  153. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  154. return
  155. }
  156. err = c.ServiceContract.PaidUpdate(returnData, projectId, bidsectionId, contractsId, id)
  157. if err != nil {
  158. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  159. return
  160. }
  161. c.Ctx.JSON(iris.Map{"code": 0, "msg": "编辑成功"})
  162. }
  163. // @Summary 删除已支付
  164. // @Tags 合同管理-支出合同
  165. // @Description 删除已支付
  166. // @Accept json
  167. // @Produce json
  168. // @Security ApiKeyAuth
  169. // @Param id path string true "已支付ID"
  170. // @Param contractsId path string true "合同ID"
  171. // @Param bidsectionId path string true "标段ID"
  172. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
  173. // @Router /api/contract/piad/delete [delete]
  174. func (c *ContractApi) DeletePaidDelete() {
  175. // 验证参数
  176. returnData, err := c.ServiceContract.ValidRuleContractPaidDel(c.Ctx)
  177. if err != nil {
  178. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  179. return
  180. }
  181. // 项目ID
  182. projectId, err := utils.GetProjectId(c.Ctx)
  183. if err != nil {
  184. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  185. return
  186. }
  187. // 标段ID
  188. bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
  189. if err != nil {
  190. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  191. return
  192. }
  193. // 合同ID
  194. contractsId, err := utils.GetDecryptId(returnData.ContractsId)
  195. if err != nil {
  196. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  197. return
  198. }
  199. // 回款ID
  200. id, err := utils.GetDecryptId(returnData.Id)
  201. if err != nil {
  202. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  203. return
  204. }
  205. err = c.ServiceContract.PaidDelete(projectId, bidsectionId, contractsId, id)
  206. if err != nil {
  207. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  208. return
  209. }
  210. c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功"})
  211. }