topup.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. package controller
  2. import (
  3. "fmt"
  4. "net/http"
  5. "net/url"
  6. "strconv"
  7. "sync"
  8. "time"
  9. "github.com/QuantumNous/new-api/common"
  10. "github.com/QuantumNous/new-api/logger"
  11. "github.com/QuantumNous/new-api/model"
  12. "github.com/QuantumNous/new-api/service"
  13. "github.com/QuantumNous/new-api/setting"
  14. "github.com/QuantumNous/new-api/setting/operation_setting"
  15. "github.com/QuantumNous/new-api/setting/system_setting"
  16. "github.com/Calcium-Ion/go-epay/epay"
  17. "github.com/gin-gonic/gin"
  18. "github.com/samber/lo"
  19. "github.com/shopspring/decimal"
  20. )
  21. func GetTopUpInfo(c *gin.Context) {
  22. // 获取支付方式
  23. payMethods := operation_setting.PayMethods
  24. // 如果启用了 Stripe 支付,添加到支付方法列表
  25. if isStripeTopUpEnabled() {
  26. // 检查是否已经包含 Stripe
  27. hasStripe := false
  28. for _, method := range payMethods {
  29. if method["type"] == "stripe" {
  30. hasStripe = true
  31. break
  32. }
  33. }
  34. if !hasStripe {
  35. stripeMethod := map[string]string{
  36. "name": "Stripe",
  37. "type": "stripe",
  38. "color": "rgba(var(--semi-purple-5), 1)",
  39. "min_topup": strconv.Itoa(setting.StripeMinTopUp),
  40. }
  41. payMethods = append(payMethods, stripeMethod)
  42. }
  43. }
  44. // 如果启用了 Waffo 支付,添加到支付方法列表
  45. enableWaffo := isWaffoTopUpEnabled()
  46. if enableWaffo {
  47. hasWaffo := false
  48. for _, method := range payMethods {
  49. if method["type"] == model.PaymentMethodWaffo {
  50. hasWaffo = true
  51. break
  52. }
  53. }
  54. if !hasWaffo {
  55. waffoMethod := map[string]string{
  56. "name": "Waffo (Global Payment)",
  57. "type": model.PaymentMethodWaffo,
  58. "color": "rgba(var(--semi-blue-5), 1)",
  59. "min_topup": strconv.Itoa(setting.WaffoMinTopUp),
  60. }
  61. payMethods = append(payMethods, waffoMethod)
  62. }
  63. }
  64. enableWaffoPancake := isWaffoPancakeTopUpEnabled()
  65. if enableWaffoPancake {
  66. hasWaffoPancake := false
  67. for _, method := range payMethods {
  68. if method["type"] == model.PaymentMethodWaffoPancake {
  69. hasWaffoPancake = true
  70. break
  71. }
  72. }
  73. if !hasWaffoPancake {
  74. payMethods = append(payMethods, map[string]string{
  75. "name": "Waffo Pancake",
  76. "type": model.PaymentMethodWaffoPancake,
  77. "color": "rgba(var(--semi-orange-5), 1)",
  78. "min_topup": strconv.Itoa(setting.WaffoPancakeMinTopUp),
  79. })
  80. }
  81. }
  82. data := gin.H{
  83. "enable_online_topup": isEpayTopUpEnabled(),
  84. "enable_stripe_topup": isStripeTopUpEnabled(),
  85. "enable_creem_topup": isCreemTopUpEnabled(),
  86. "enable_waffo_topup": enableWaffo,
  87. "enable_waffo_pancake_topup": enableWaffoPancake,
  88. "waffo_pay_methods": func() interface{} {
  89. if enableWaffo {
  90. return setting.GetWaffoPayMethods()
  91. }
  92. return nil
  93. }(),
  94. "creem_products": setting.CreemProducts,
  95. "pay_methods": payMethods,
  96. "min_topup": operation_setting.MinTopUp,
  97. "stripe_min_topup": setting.StripeMinTopUp,
  98. "waffo_min_topup": setting.WaffoMinTopUp,
  99. "waffo_pancake_min_topup": setting.WaffoPancakeMinTopUp,
  100. "amount_options": operation_setting.GetPaymentSetting().AmountOptions,
  101. "discount": operation_setting.GetPaymentSetting().AmountDiscount,
  102. }
  103. common.ApiSuccess(c, data)
  104. }
  105. type EpayRequest struct {
  106. Amount int64 `json:"amount"`
  107. PaymentMethod string `json:"payment_method"`
  108. }
  109. type AmountRequest struct {
  110. Amount int64 `json:"amount"`
  111. }
  112. func GetEpayClient() *epay.Client {
  113. if operation_setting.PayAddress == "" || operation_setting.EpayId == "" || operation_setting.EpayKey == "" {
  114. return nil
  115. }
  116. withUrl, err := epay.NewClient(&epay.Config{
  117. PartnerID: operation_setting.EpayId,
  118. Key: operation_setting.EpayKey,
  119. }, operation_setting.PayAddress)
  120. if err != nil {
  121. return nil
  122. }
  123. return withUrl
  124. }
  125. func getPayMoney(amount int64, group string) float64 {
  126. dAmount := decimal.NewFromInt(amount)
  127. // 充值金额以“展示类型”为准:
  128. // - USD/CNY: 前端传 amount 为金额单位;TOKENS: 前端传 tokens,需要换成 USD 金额
  129. if operation_setting.GetQuotaDisplayType() == operation_setting.QuotaDisplayTypeTokens {
  130. dQuotaPerUnit := decimal.NewFromFloat(common.QuotaPerUnit)
  131. dAmount = dAmount.Div(dQuotaPerUnit)
  132. }
  133. topupGroupRatio := common.GetTopupGroupRatio(group)
  134. if topupGroupRatio == 0 {
  135. topupGroupRatio = 1
  136. }
  137. dTopupGroupRatio := decimal.NewFromFloat(topupGroupRatio)
  138. dPrice := decimal.NewFromFloat(operation_setting.Price)
  139. // apply optional preset discount by the original request amount (if configured), default 1.0
  140. discount := 1.0
  141. if ds, ok := operation_setting.GetPaymentSetting().AmountDiscount[int(amount)]; ok {
  142. if ds > 0 {
  143. discount = ds
  144. }
  145. }
  146. dDiscount := decimal.NewFromFloat(discount)
  147. payMoney := dAmount.Mul(dPrice).Mul(dTopupGroupRatio).Mul(dDiscount)
  148. return payMoney.InexactFloat64()
  149. }
  150. func getMinTopup() int64 {
  151. minTopup := operation_setting.MinTopUp
  152. if operation_setting.GetQuotaDisplayType() == operation_setting.QuotaDisplayTypeTokens {
  153. dMinTopup := decimal.NewFromInt(int64(minTopup))
  154. dQuotaPerUnit := decimal.NewFromFloat(common.QuotaPerUnit)
  155. minTopup = int(dMinTopup.Mul(dQuotaPerUnit).IntPart())
  156. }
  157. return int64(minTopup)
  158. }
  159. func RequestEpay(c *gin.Context) {
  160. var req EpayRequest
  161. err := c.ShouldBindJSON(&req)
  162. if err != nil {
  163. c.JSON(http.StatusOK, gin.H{"message": "error", "data": "参数错误"})
  164. return
  165. }
  166. if req.Amount < getMinTopup() {
  167. c.JSON(http.StatusOK, gin.H{"message": "error", "data": fmt.Sprintf("充值数量不能小于 %d", getMinTopup())})
  168. return
  169. }
  170. id := c.GetInt("id")
  171. group, err := model.GetUserGroup(id, true)
  172. if err != nil {
  173. c.JSON(http.StatusOK, gin.H{"message": "error", "data": "获取用户分组失败"})
  174. return
  175. }
  176. payMoney := getPayMoney(req.Amount, group)
  177. if payMoney < 0.01 {
  178. c.JSON(http.StatusOK, gin.H{"message": "error", "data": "充值金额过低"})
  179. return
  180. }
  181. if !operation_setting.ContainsPayMethod(req.PaymentMethod) {
  182. c.JSON(http.StatusOK, gin.H{"message": "error", "data": "支付方式不存在"})
  183. return
  184. }
  185. callBackAddress := service.GetCallbackAddress()
  186. returnUrl, _ := url.Parse(system_setting.ServerAddress + "/console/log")
  187. notifyUrl, _ := url.Parse(callBackAddress + "/api/user/epay/notify")
  188. tradeNo := fmt.Sprintf("%s%d", common.GetRandomString(6), time.Now().Unix())
  189. tradeNo = fmt.Sprintf("USR%dNO%s", id, tradeNo)
  190. client := GetEpayClient()
  191. if client == nil {
  192. c.JSON(http.StatusOK, gin.H{"message": "error", "data": "当前管理员未配置支付信息"})
  193. return
  194. }
  195. uri, params, err := client.Purchase(&epay.PurchaseArgs{
  196. Type: req.PaymentMethod,
  197. ServiceTradeNo: tradeNo,
  198. Name: fmt.Sprintf("TUC%d", req.Amount),
  199. Money: strconv.FormatFloat(payMoney, 'f', 2, 64),
  200. Device: epay.PC,
  201. NotifyUrl: notifyUrl,
  202. ReturnUrl: returnUrl,
  203. })
  204. if err != nil {
  205. logger.LogError(c.Request.Context(), fmt.Sprintf("易支付 拉起支付失败 user_id=%d trade_no=%s payment_method=%s amount=%d error=%q", id, tradeNo, req.PaymentMethod, req.Amount, err.Error()))
  206. c.JSON(http.StatusOK, gin.H{"message": "error", "data": "拉起支付失败"})
  207. return
  208. }
  209. amount := req.Amount
  210. if operation_setting.GetQuotaDisplayType() == operation_setting.QuotaDisplayTypeTokens {
  211. dAmount := decimal.NewFromInt(int64(amount))
  212. dQuotaPerUnit := decimal.NewFromFloat(common.QuotaPerUnit)
  213. amount = dAmount.Div(dQuotaPerUnit).IntPart()
  214. }
  215. topUp := &model.TopUp{
  216. UserId: id,
  217. Amount: amount,
  218. Money: payMoney,
  219. TradeNo: tradeNo,
  220. PaymentMethod: req.PaymentMethod,
  221. PaymentProvider: model.PaymentProviderEpay,
  222. CreateTime: time.Now().Unix(),
  223. Status: common.TopUpStatusPending,
  224. }
  225. err = topUp.Insert()
  226. if err != nil {
  227. logger.LogError(c.Request.Context(), fmt.Sprintf("易支付 创建充值订单失败 user_id=%d trade_no=%s payment_method=%s amount=%d error=%q", id, tradeNo, req.PaymentMethod, req.Amount, err.Error()))
  228. c.JSON(http.StatusOK, gin.H{"message": "error", "data": "创建订单失败"})
  229. return
  230. }
  231. logger.LogInfo(c.Request.Context(), fmt.Sprintf("易支付 充值订单创建成功 user_id=%d trade_no=%s payment_method=%s amount=%d money=%.2f uri=%q params=%q", id, tradeNo, req.PaymentMethod, req.Amount, payMoney, uri, common.GetJsonString(params)))
  232. c.JSON(http.StatusOK, gin.H{"message": "success", "data": params, "url": uri})
  233. }
  234. // tradeNo lock
  235. var orderLocks sync.Map
  236. var createLock sync.Mutex
  237. // refCountedMutex 带引用计数的互斥锁,确保最后一个使用者才从 map 中删除
  238. type refCountedMutex struct {
  239. mu sync.Mutex
  240. refCount int
  241. }
  242. // LockOrder 尝试对给定订单号加锁
  243. func LockOrder(tradeNo string) {
  244. createLock.Lock()
  245. var rcm *refCountedMutex
  246. if v, ok := orderLocks.Load(tradeNo); ok {
  247. rcm = v.(*refCountedMutex)
  248. } else {
  249. rcm = &refCountedMutex{}
  250. orderLocks.Store(tradeNo, rcm)
  251. }
  252. rcm.refCount++
  253. createLock.Unlock()
  254. rcm.mu.Lock()
  255. }
  256. // UnlockOrder 释放给定订单号的锁
  257. func UnlockOrder(tradeNo string) {
  258. v, ok := orderLocks.Load(tradeNo)
  259. if !ok {
  260. return
  261. }
  262. rcm := v.(*refCountedMutex)
  263. rcm.mu.Unlock()
  264. createLock.Lock()
  265. rcm.refCount--
  266. if rcm.refCount == 0 {
  267. orderLocks.Delete(tradeNo)
  268. }
  269. createLock.Unlock()
  270. }
  271. func EpayNotify(c *gin.Context) {
  272. if !isEpayWebhookEnabled() {
  273. logger.LogWarn(c.Request.Context(), fmt.Sprintf("易支付 webhook 被拒绝 reason=webhook_disabled path=%q client_ip=%s", c.Request.RequestURI, c.ClientIP()))
  274. _, _ = c.Writer.Write([]byte("fail"))
  275. return
  276. }
  277. var params map[string]string
  278. if c.Request.Method == "POST" {
  279. // POST 请求:从 POST body 解析参数
  280. if err := c.Request.ParseForm(); err != nil {
  281. logger.LogError(c.Request.Context(), fmt.Sprintf("易支付 webhook POST 表单解析失败 path=%q client_ip=%s error=%q", c.Request.RequestURI, c.ClientIP(), err.Error()))
  282. _, _ = c.Writer.Write([]byte("fail"))
  283. return
  284. }
  285. params = lo.Reduce(lo.Keys(c.Request.PostForm), func(r map[string]string, t string, i int) map[string]string {
  286. r[t] = c.Request.PostForm.Get(t)
  287. return r
  288. }, map[string]string{})
  289. } else {
  290. // GET 请求:从 URL Query 解析参数
  291. params = lo.Reduce(lo.Keys(c.Request.URL.Query()), func(r map[string]string, t string, i int) map[string]string {
  292. r[t] = c.Request.URL.Query().Get(t)
  293. return r
  294. }, map[string]string{})
  295. }
  296. logger.LogInfo(c.Request.Context(), fmt.Sprintf("易支付 webhook 收到请求 path=%q client_ip=%s method=%s params=%q", c.Request.RequestURI, c.ClientIP(), c.Request.Method, common.GetJsonString(params)))
  297. if len(params) == 0 {
  298. logger.LogWarn(c.Request.Context(), fmt.Sprintf("易支付 webhook 参数为空 path=%q client_ip=%s", c.Request.RequestURI, c.ClientIP()))
  299. _, _ = c.Writer.Write([]byte("fail"))
  300. return
  301. }
  302. client := GetEpayClient()
  303. if client == nil {
  304. logger.LogError(c.Request.Context(), fmt.Sprintf("易支付 client 未初始化 path=%q client_ip=%s", c.Request.RequestURI, c.ClientIP()))
  305. _, err := c.Writer.Write([]byte("fail"))
  306. if err != nil {
  307. logger.LogError(c.Request.Context(), fmt.Sprintf("易支付 webhook 响应写入失败 path=%q client_ip=%s error=%q", c.Request.RequestURI, c.ClientIP(), err.Error()))
  308. }
  309. return
  310. }
  311. verifyInfo, err := client.Verify(params)
  312. if err == nil && verifyInfo.VerifyStatus {
  313. logger.LogInfo(c.Request.Context(), fmt.Sprintf("易支付 webhook 验签成功 trade_no=%s callback_type=%s trade_status=%s client_ip=%s verify_info=%q", verifyInfo.ServiceTradeNo, verifyInfo.Type, verifyInfo.TradeStatus, c.ClientIP(), common.GetJsonString(verifyInfo)))
  314. _, err := c.Writer.Write([]byte("success"))
  315. if err != nil {
  316. logger.LogError(c.Request.Context(), fmt.Sprintf("易支付 webhook 响应写入失败 trade_no=%s client_ip=%s error=%q", verifyInfo.ServiceTradeNo, c.ClientIP(), err.Error()))
  317. }
  318. } else {
  319. _, err := c.Writer.Write([]byte("fail"))
  320. if err != nil {
  321. logger.LogError(c.Request.Context(), fmt.Sprintf("易支付 webhook 响应写入失败 path=%q client_ip=%s error=%q", c.Request.RequestURI, c.ClientIP(), err.Error()))
  322. }
  323. if err != nil {
  324. logger.LogWarn(c.Request.Context(), fmt.Sprintf("易支付 webhook 验签失败 path=%q client_ip=%s verify_error=%q", c.Request.RequestURI, c.ClientIP(), err.Error()))
  325. } else {
  326. logger.LogWarn(c.Request.Context(), fmt.Sprintf("易支付 webhook 验签失败 path=%q client_ip=%s verify_status=false", c.Request.RequestURI, c.ClientIP()))
  327. }
  328. return
  329. }
  330. if verifyInfo.TradeStatus == epay.StatusTradeSuccess {
  331. LockOrder(verifyInfo.ServiceTradeNo)
  332. defer UnlockOrder(verifyInfo.ServiceTradeNo)
  333. topUp := model.GetTopUpByTradeNo(verifyInfo.ServiceTradeNo)
  334. if topUp == nil {
  335. logger.LogWarn(c.Request.Context(), fmt.Sprintf("易支付 回调订单不存在 trade_no=%s callback_type=%s client_ip=%s verify_info=%q", verifyInfo.ServiceTradeNo, verifyInfo.Type, c.ClientIP(), common.GetJsonString(verifyInfo)))
  336. return
  337. }
  338. if topUp.PaymentProvider != model.PaymentProviderEpay {
  339. logger.LogWarn(c.Request.Context(), fmt.Sprintf("易支付 订单支付网关不匹配 trade_no=%s order_provider=%s callback_type=%s client_ip=%s", verifyInfo.ServiceTradeNo, topUp.PaymentProvider, verifyInfo.Type, c.ClientIP()))
  340. return
  341. }
  342. if topUp.Status == common.TopUpStatusPending {
  343. if topUp.PaymentMethod != verifyInfo.Type {
  344. logger.LogInfo(c.Request.Context(), fmt.Sprintf("易支付 实际支付方式与订单不同 trade_no=%s order_payment_method=%s actual_type=%s client_ip=%s", verifyInfo.ServiceTradeNo, topUp.PaymentMethod, verifyInfo.Type, c.ClientIP()))
  345. topUp.PaymentMethod = verifyInfo.Type
  346. }
  347. topUp.Status = common.TopUpStatusSuccess
  348. err := topUp.Update()
  349. if err != nil {
  350. logger.LogError(c.Request.Context(), fmt.Sprintf("易支付 更新充值订单失败 trade_no=%s user_id=%d client_ip=%s error=%q topup=%q", topUp.TradeNo, topUp.UserId, c.ClientIP(), err.Error(), common.GetJsonString(topUp)))
  351. return
  352. }
  353. //user, _ := model.GetUserById(topUp.UserId, false)
  354. //user.Quota += topUp.Amount * 500000
  355. dAmount := decimal.NewFromInt(int64(topUp.Amount))
  356. dQuotaPerUnit := decimal.NewFromFloat(common.QuotaPerUnit)
  357. quotaToAdd := int(dAmount.Mul(dQuotaPerUnit).IntPart())
  358. err = model.IncreaseUserQuota(topUp.UserId, quotaToAdd, true)
  359. if err != nil {
  360. logger.LogError(c.Request.Context(), fmt.Sprintf("易支付 更新用户额度失败 trade_no=%s user_id=%d client_ip=%s quota_to_add=%d error=%q topup=%q", topUp.TradeNo, topUp.UserId, c.ClientIP(), quotaToAdd, err.Error(), common.GetJsonString(topUp)))
  361. return
  362. }
  363. logger.LogInfo(c.Request.Context(), fmt.Sprintf("易支付 充值成功 trade_no=%s user_id=%d client_ip=%s quota_to_add=%d money=%.2f topup=%q", topUp.TradeNo, topUp.UserId, c.ClientIP(), quotaToAdd, topUp.Money, common.GetJsonString(topUp)))
  364. model.RecordTopupLog(topUp.UserId, fmt.Sprintf("使用在线充值成功,充值金额: %v,支付金额:%f", logger.LogQuota(quotaToAdd), topUp.Money), c.ClientIP(), topUp.PaymentMethod, "epay")
  365. }
  366. } else {
  367. logger.LogInfo(c.Request.Context(), fmt.Sprintf("易支付 webhook 忽略事件 trade_no=%s callback_type=%s trade_status=%s client_ip=%s verify_info=%q", verifyInfo.ServiceTradeNo, verifyInfo.Type, verifyInfo.TradeStatus, c.ClientIP(), common.GetJsonString(verifyInfo)))
  368. }
  369. }
  370. func RequestAmount(c *gin.Context) {
  371. var req AmountRequest
  372. err := c.ShouldBindJSON(&req)
  373. if err != nil {
  374. c.JSON(http.StatusOK, gin.H{"message": "error", "data": "参数错误"})
  375. return
  376. }
  377. if req.Amount < getMinTopup() {
  378. c.JSON(http.StatusOK, gin.H{"message": "error", "data": fmt.Sprintf("充值数量不能小于 %d", getMinTopup())})
  379. return
  380. }
  381. id := c.GetInt("id")
  382. group, err := model.GetUserGroup(id, true)
  383. if err != nil {
  384. c.JSON(http.StatusOK, gin.H{"message": "error", "data": "获取用户分组失败"})
  385. return
  386. }
  387. payMoney := getPayMoney(req.Amount, group)
  388. if payMoney <= 0.01 {
  389. c.JSON(http.StatusOK, gin.H{"message": "error", "data": "充值金额过低"})
  390. return
  391. }
  392. c.JSON(http.StatusOK, gin.H{"message": "success", "data": strconv.FormatFloat(payMoney, 'f', 2, 64)})
  393. }
  394. func GetUserTopUps(c *gin.Context) {
  395. userId := c.GetInt("id")
  396. pageInfo := common.GetPageQuery(c)
  397. keyword := c.Query("keyword")
  398. var (
  399. topups []*model.TopUp
  400. total int64
  401. err error
  402. )
  403. if keyword != "" {
  404. topups, total, err = model.SearchUserTopUps(userId, keyword, pageInfo)
  405. } else {
  406. topups, total, err = model.GetUserTopUps(userId, pageInfo)
  407. }
  408. if err != nil {
  409. common.ApiError(c, err)
  410. return
  411. }
  412. pageInfo.SetTotal(int(total))
  413. pageInfo.SetItems(topups)
  414. common.ApiSuccess(c, pageInfo)
  415. }
  416. // GetAllTopUps 管理员获取全平台充值记录
  417. func GetAllTopUps(c *gin.Context) {
  418. pageInfo := common.GetPageQuery(c)
  419. keyword := c.Query("keyword")
  420. var (
  421. topups []*model.TopUp
  422. total int64
  423. err error
  424. )
  425. if keyword != "" {
  426. topups, total, err = model.SearchAllTopUps(keyword, pageInfo)
  427. } else {
  428. topups, total, err = model.GetAllTopUps(pageInfo)
  429. }
  430. if err != nil {
  431. common.ApiError(c, err)
  432. return
  433. }
  434. pageInfo.SetTotal(int(total))
  435. pageInfo.SetItems(topups)
  436. common.ApiSuccess(c, pageInfo)
  437. }
  438. type AdminCompleteTopupRequest struct {
  439. TradeNo string `json:"trade_no"`
  440. }
  441. // AdminCompleteTopUp 管理员补单接口
  442. func AdminCompleteTopUp(c *gin.Context) {
  443. var req AdminCompleteTopupRequest
  444. if err := c.ShouldBindJSON(&req); err != nil || req.TradeNo == "" {
  445. common.ApiErrorMsg(c, "参数错误")
  446. return
  447. }
  448. // 订单级互斥,防止并发补单
  449. LockOrder(req.TradeNo)
  450. defer UnlockOrder(req.TradeNo)
  451. if err := model.ManualCompleteTopUp(req.TradeNo, c.ClientIP()); err != nil {
  452. common.ApiError(c, err)
  453. return
  454. }
  455. common.ApiSuccess(c, nil)
  456. }