蛋蛋星球 后台端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

131 lines
4.5 KiB

  1. package financial_center
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. md "applet/app/md/financial_center"
  6. "applet/app/utils"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  9. md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
  10. "github.com/gin-gonic/gin"
  11. "time"
  12. )
  13. // GetWithdrawSetting
  14. // @Summary 财务中心-提现-基础设置(获取)
  15. // @Tags 提现
  16. // @Description 基础设置(获取)
  17. // @Accept json
  18. // @Produce json
  19. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  20. // @Success 200 {object} md.GetWithdrawSettingResp "具体数据"
  21. // @Failure 400 {object} md.Response "具体错误"
  22. // @Router /api/financialCenter/withdraw/setting [get]
  23. func GetWithdrawSetting(c *gin.Context) {
  24. settingDb := implement.NewFinWithdrawSettingDb(db.Db)
  25. setting, err := settingDb.FinWithdrawSettingGetOne()
  26. if err != nil {
  27. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  28. return
  29. }
  30. // 不存在则初始化
  31. if setting == nil {
  32. now := time.Now()
  33. frequency := md2.WithdrawFrequencySettingStruct{
  34. Duration: 0,
  35. Num: 0,
  36. }
  37. frequencyStr := utils.SerializeStr(frequency)
  38. m := model.FinWithdrawSetting{
  39. FrequencySet: frequencyStr,
  40. WithdrawType: 0,
  41. VipLevelLimit: 0,
  42. IsRealName: 0,
  43. WithdrawNumsLimit: 0,
  44. WithdrawAmountLimit: "",
  45. WithdrawMultipleLimit: "",
  46. IsSupportDecimalPoint: 0,
  47. IsAuto: 0,
  48. WithdrawTimeInterval: "",
  49. WithdrawFeeSet: "",
  50. CreateAt: now.Format("2006-01-02 15:04:05"),
  51. UpdateAt: "",
  52. }
  53. _, err2 := settingDb.FinWithdrawSettingInsert(&m)
  54. if err2 != nil {
  55. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  56. return
  57. }
  58. setting, err = settingDb.FinWithdrawSettingGetOne()
  59. if err != nil {
  60. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  61. return
  62. }
  63. }
  64. var frequency md2.WithdrawFrequencySettingStruct
  65. utils.Unserialize([]byte(setting.FrequencySet), &frequency)
  66. resp := md.GetWithdrawSettingResp{
  67. Id: setting.Id,
  68. FrequencySet: frequency,
  69. WithdrawType: setting.WithdrawType,
  70. VipLevelLimit: setting.VipLevelLimit,
  71. IsRealName: setting.IsRealName,
  72. WithdrawNumsLimit: setting.WithdrawNumsLimit,
  73. WithdrawAmountLimit: setting.WithdrawAmountLimit,
  74. WithdrawMultipleLimit: setting.WithdrawMultipleLimit,
  75. IsSupportDecimalPoint: setting.IsSupportDecimalPoint,
  76. IsAuto: setting.IsAuto,
  77. WithdrawTimeInterval: setting.WithdrawTimeInterval,
  78. WithdrawFeeSet: setting.WithdrawFeeSet,
  79. CreateAt: setting.CreateAt,
  80. UpdateAt: setting.UpdateAt,
  81. }
  82. e.OutSuc(c, resp, nil)
  83. }
  84. // UpdateWithdrawSetting
  85. // @Summary 财务中心-提现-基础设置(更新)
  86. // @Tags 提现
  87. // @Description 基础设置(更新)
  88. // @Accept json
  89. // @Produce json
  90. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  91. // @Param req body md.UpdateWithdrawSettingReq true "id 必填"
  92. // @Success 200 {int} "修改数据条数"
  93. // @Failure 400 {object} md.Response "具体错误"
  94. // @Router /api/financialCenter/withdraw/updateWithdrawSetting [POST]
  95. func UpdateWithdrawSetting(c *gin.Context) {
  96. var req *md.UpdateWithdrawSettingReq
  97. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  98. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  99. return
  100. }
  101. frequencyStr := utils.SerializeStr(req.FrequencySet)
  102. m := model.FinWithdrawSetting{
  103. Id: req.Id,
  104. FrequencySet: frequencyStr,
  105. WithdrawType: req.WithdrawType,
  106. VipLevelLimit: req.VipLevelLimit,
  107. IsRealName: req.IsRealName,
  108. WithdrawNumsLimit: req.WithdrawNumsLimit,
  109. WithdrawAmountLimit: req.WithdrawAmountLimit,
  110. WithdrawMultipleLimit: req.WithdrawMultipleLimit,
  111. IsSupportDecimalPoint: req.IsSupportDecimalPoint,
  112. IsAuto: req.IsAuto,
  113. WithdrawTimeInterval: req.WithdrawTimeInterval,
  114. WithdrawFeeSet: req.WithdrawFeeSet,
  115. }
  116. forceColumns := []string{"withdraw_type", "is_real_name", "withdraw_nums_limit", "withdraw_amount_limit", "withdraw_multiple_limit", "is_support_decimal_point", "is_auto"}
  117. settingDb := implement.NewFinWithdrawSettingDb(db.Db)
  118. affected, err := settingDb.FinWithdrawSettingUpdate(req.Id, &m, forceColumns...)
  119. if err != nil {
  120. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  121. return
  122. }
  123. e.OutSuc(c, affected, nil)
  124. }