蛋蛋星球 后台端
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.

hdl_withdraw.go 7.8 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. package financial_center
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. md "applet/app/md/financial_center"
  6. svc "applet/app/svc/financial_center"
  7. "applet/app/utils"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  9. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  10. md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
  11. "github.com/gin-gonic/gin"
  12. "time"
  13. )
  14. // GetWithdrawSetting
  15. // @Summary 财务中心-提现-基础设置(获取)
  16. // @Tags 提现
  17. // @Description 基础设置(获取)
  18. // @Accept json
  19. // @Produce json
  20. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  21. // @Success 200 {object} md.GetWithdrawSettingResp "具体数据"
  22. // @Failure 400 {object} md.Response "具体错误"
  23. // @Router /api/financialCenter/withdraw/setting [get]
  24. func GetWithdrawSetting(c *gin.Context) {
  25. settingDb := implement.NewFinWithdrawSettingDb(db.Db)
  26. setting, err := settingDb.FinWithdrawSettingGetOne()
  27. if err != nil {
  28. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  29. return
  30. }
  31. // 不存在则初始化
  32. var emptyNum []string
  33. if setting == nil {
  34. now := time.Now()
  35. frequency := md2.WithdrawFrequencySettingStruct{
  36. Duration: 0,
  37. Num: emptyNum,
  38. }
  39. withdrawFeeSet := md2.WithdrawFeeSetStruct{
  40. Kind: 0,
  41. Value: 0,
  42. }
  43. frequencyStr := utils.SerializeStr(frequency)
  44. withdrawFeeSetStr := utils.SerializeStr(withdrawFeeSet)
  45. m := model.FinWithdrawSetting{
  46. FrequencySet: frequencyStr,
  47. WithdrawType: 0,
  48. VipLevelLimit: 0,
  49. IsRealName: 0,
  50. WithdrawNumsLimit: 0,
  51. WithdrawAmountLimit: "",
  52. WithdrawMultipleLimit: "",
  53. IsSupportDecimalPoint: 0,
  54. IsAuto: 0,
  55. WithdrawTimeInterval: "",
  56. WithdrawFeeSet: withdrawFeeSetStr,
  57. CreateAt: now.Format("2006-01-02 15:04:05"),
  58. UpdateAt: "",
  59. }
  60. _, err2 := settingDb.FinWithdrawSettingInsert(&m)
  61. if err2 != nil {
  62. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  63. return
  64. }
  65. setting, err = settingDb.FinWithdrawSettingGetOne()
  66. if err != nil {
  67. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  68. return
  69. }
  70. }
  71. var frequency md2.WithdrawFrequencySettingStruct
  72. var withdrawFeeSet md2.WithdrawFeeSetStruct
  73. utils.Unserialize([]byte(setting.FrequencySet), &frequency)
  74. utils.Unserialize([]byte(setting.WithdrawFeeSet), &withdrawFeeSet)
  75. resp := md.GetWithdrawSettingResp{
  76. Id: setting.Id,
  77. FrequencySet: frequency,
  78. WithdrawType: setting.WithdrawType,
  79. VipLevelLimit: setting.VipLevelLimit,
  80. IsRealName: setting.IsRealName,
  81. WithdrawNumsLimit: setting.WithdrawNumsLimit,
  82. WithdrawAmountLimit: setting.WithdrawAmountLimit,
  83. WithdrawMultipleLimit: setting.WithdrawMultipleLimit,
  84. IsSupportDecimalPoint: setting.IsSupportDecimalPoint,
  85. IsAuto: setting.IsAuto,
  86. WithdrawTimeInterval: setting.WithdrawTimeInterval,
  87. WithdrawFeeSet: withdrawFeeSet,
  88. CreateAt: setting.CreateAt,
  89. UpdateAt: setting.UpdateAt,
  90. }
  91. e.OutSuc(c, resp, nil)
  92. }
  93. // UpdateWithdrawSetting
  94. // @Summary 财务中心-提现-基础设置(更新)
  95. // @Tags 提现
  96. // @Description 基础设置(更新)
  97. // @Accept json
  98. // @Produce json
  99. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  100. // @Param req body md.UpdateWithdrawSettingReq true "id 必填"
  101. // @Success 200 {int} "修改数据条数"
  102. // @Failure 400 {object} md.Response "具体错误"
  103. // @Router /api/financialCenter/withdraw/updateWithdrawSetting [POST]
  104. func UpdateWithdrawSetting(c *gin.Context) {
  105. var req *md.UpdateWithdrawSettingReq
  106. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  107. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  108. return
  109. }
  110. frequencyStr := utils.SerializeStr(req.FrequencySet)
  111. withdrawFeeSetStr := utils.SerializeStr(req.WithdrawFeeSet)
  112. m := model.FinWithdrawSetting{
  113. Id: req.Id,
  114. FrequencySet: frequencyStr,
  115. WithdrawType: req.WithdrawType,
  116. VipLevelLimit: req.VipLevelLimit,
  117. IsRealName: req.IsRealName,
  118. WithdrawNumsLimit: req.WithdrawNumsLimit,
  119. WithdrawAmountLimit: req.WithdrawAmountLimit,
  120. WithdrawMultipleLimit: req.WithdrawMultipleLimit,
  121. IsSupportDecimalPoint: req.IsSupportDecimalPoint,
  122. IsAuto: req.IsAuto,
  123. WithdrawTimeInterval: req.WithdrawTimeInterval,
  124. WithdrawFeeSet: withdrawFeeSetStr,
  125. }
  126. forceColumns := []string{"withdraw_type", "is_real_name", "withdraw_nums_limit", "withdraw_amount_limit", "withdraw_multiple_limit", "is_support_decimal_point", "is_auto"}
  127. settingDb := implement.NewFinWithdrawSettingDb(db.Db)
  128. affected, err := settingDb.FinWithdrawSettingUpdate(req.Id, &m, forceColumns...)
  129. if err != nil {
  130. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  131. return
  132. }
  133. e.OutSuc(c, affected, nil)
  134. }
  135. // GetWithdrawApplyList
  136. // @Summary 财务中心-提现-提现申请列表(获取)
  137. // @Tags 提现
  138. // @Description 提现申请列表(获取)
  139. // @Accept json
  140. // @Produce json
  141. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  142. // @Param req body md.GetWithdrawApplyListReq false "筛选条件"
  143. // @Success 200 {object} md.GetWithdrawApplyListResp "具体数据"
  144. // @Failure 400 {object} md.Response "具体错误"
  145. // @Router /api/financialCenter/withdraw/applyList [POST]
  146. func GetWithdrawApplyList(c *gin.Context) {
  147. var req *md.GetWithdrawApplyListReq
  148. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  149. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  150. return
  151. }
  152. levelDb := implement.NewUserLevelDb(db.Db)
  153. levels, err1 := levelDb.UserLevelAllByAsc()
  154. if err1 != nil {
  155. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  156. return
  157. }
  158. levelsList := make([]map[string]interface{}, 0)
  159. levelsMap := make(map[int]string)
  160. for _, level := range levels {
  161. levelsList = append(levelsList, map[string]interface{}{
  162. "id": level.Id,
  163. "name": level.LevelName,
  164. })
  165. levelsMap[level.Id] = level.LevelName
  166. }
  167. tagDb := implement.NewUserTagDb(db.Db)
  168. tags, err2 := tagDb.UserTagAllByAsc()
  169. if err2 != nil {
  170. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  171. return
  172. }
  173. tagsList := make([]map[string]interface{}, 0)
  174. tagsMap := make(map[int]string)
  175. for _, tag := range tags {
  176. tagsList = append(tagsList, map[string]interface{}{
  177. "id": tag.Id,
  178. "name": tag.TagName,
  179. })
  180. tagsMap[tag.Id] = tag.TagName
  181. }
  182. applies, total, err3 := svc.WithDrawManagementGetApply(db.Db, req)
  183. if err3 != nil {
  184. e.OutErr(c, e.ERR_DB_ORM, err3.Error())
  185. return
  186. }
  187. list := make([]md.GetWithdrawApplyListNode, len(*applies))
  188. for i, apply := range *applies {
  189. list[i] = md.GetWithdrawApplyListNode{
  190. UserID: apply.UserID,
  191. Nickname: apply.Nickname,
  192. ParentID: apply.ParentID,
  193. ParentPhone: apply.ParentPhone,
  194. WithdrawType: apply.WithdrawType,
  195. InviteCode: apply.InviteCode,
  196. Amount: apply.Amount,
  197. ActualReceipt: "",
  198. SysFee: apply.SysFee,
  199. State: apply.State,
  200. ApplyAt: apply.ApplyAt,
  201. PayAt: apply.PayAt,
  202. Memo: apply.Memo,
  203. }
  204. if apply.Amount != "" && apply.SysFee != "" {
  205. actualReceipt := utils.StrToFloat64(apply.Amount) - utils.StrToFloat64(apply.SysFee)
  206. list[i].ActualReceipt = utils.Float64ToStr(actualReceipt)
  207. }
  208. switch apply.WithdrawType {
  209. case 1:
  210. list[i].AliPayName = apply.PayName
  211. list[i].AliPayAccount = apply.PayAccount
  212. case 2:
  213. list[i].WechatPayName = apply.PayName
  214. list[i].WechatPayAccount = apply.PayAccount
  215. }
  216. tag, ok := tagsMap[apply.Tag]
  217. if ok {
  218. list[i].Tag = tag
  219. }
  220. }
  221. resp := md.GetWithdrawApplyListResp{
  222. LevelsList: levelsList,
  223. TagsList: tagsList,
  224. List: list,
  225. Paginate: md.Paginate{
  226. Limit: req.Limit,
  227. Page: req.Page,
  228. Total: total,
  229. },
  230. }
  231. e.OutSuc(c, resp, nil)
  232. }