智盟项目
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.

481 rivejä
18 KiB

  1. package platform
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. offical "applet/app/db/official"
  6. "applet/app/e"
  7. "applet/app/lib/mob"
  8. "applet/app/utils"
  9. "applet/app/utils/cache"
  10. "encoding/json"
  11. "fmt"
  12. "github.com/gin-gonic/gin"
  13. "time"
  14. )
  15. func WithdrawalIncome(c *gin.Context) {
  16. args, mid, err := commArg(c)
  17. if err != nil {
  18. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  19. return
  20. }
  21. fmt.Println(args)
  22. fmt.Println(mid)
  23. if args["type"] == "" {
  24. args["type"] = "playlet"
  25. }
  26. amountMap := masterAmount(mid, args["type"])
  27. monthAmountMap := masterMonthAmount(mid)
  28. isNeedBingAlipay := "1"
  29. if amountMap["alipay"] != "" {
  30. isNeedBingAlipay = "0"
  31. }
  32. var res = make([]map[string]string, 0)
  33. if amountMap["is_show_official_amount"] == "1" {
  34. var tmp = map[string]string{"name": "账户一余额", "value": amountMap["amount"], "type": "amount", "tip": "", "alipay": amountMap["alipay"], "alipay_name": amountMap["alipay_name"], "is_need_bing_alipay": isNeedBingAlipay, "is_show_withdrawal": "1"}
  35. res = append(res, tmp)
  36. if amountMap["is_show_agent_amount"] == "1" {
  37. var tmpAgent = map[string]string{"name": "账户二余额", "value": amountMap["agent_amount"], "type": "agent_amount", "tip": "", "alipay": amountMap["alipay"], "alipay_name": amountMap["alipay_name"], "is_need_bing_alipay": isNeedBingAlipay, "is_show_withdrawal": "1"}
  38. res = append(res, tmpAgent)
  39. }
  40. } else {
  41. var tmpAgent = map[string]string{"name": "账户二余额", "value": amountMap["agent_amount"], "type": "agent_amount", "tip": "", "alipay": amountMap["alipay"], "alipay_name": amountMap["alipay_name"], "is_need_bing_alipay": isNeedBingAlipay, "is_show_withdrawal": "1"}
  42. res = append(res, tmpAgent)
  43. }
  44. res = append(res, map[string]string{"name": "未结算收益", "value": monthAmountMap["waitSum"], "type": "waitSum", "tip": "", "is_need_bing_alipay": "0", "is_show_withdrawal": "0"})
  45. res = append(res, map[string]string{"name": "上月预估收益", "value": monthAmountMap["last_month_amount"], "type": "last_month_amount", "tip": "", "is_need_bing_alipay": "0", "is_show_withdrawal": "0"})
  46. res = append(res, map[string]string{"name": "上月预估结算收益", "value": amountMap["last_month_settle_amount"], "type": "last_month_settle_amount", "tip": "", "is_need_bing_alipay": "0", "is_show_withdrawal": "0"})
  47. res = append(res, map[string]string{"name": "本月预估收益", "value": monthAmountMap["month_amount"], "type": "month_amount", "tip": "", "is_need_bing_alipay": "0", "is_show_withdrawal": "0"})
  48. res = append(res, map[string]string{"name": "本月预估结算收益", "value": monthAmountMap["month_settle_amount"], "type": "month_settle_amount", "tip": "", "is_need_bing_alipay": "0", "is_show_withdrawal": "0"})
  49. e.OutSuc(c, res, nil)
  50. return
  51. }
  52. func WithdrawalList(c *gin.Context) {
  53. args, mid, err := commArg(c)
  54. if err != nil {
  55. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  56. return
  57. }
  58. amountMap := masterAmount(mid, args["type"])
  59. masterWithdrawalFlowDb := db.MasterWithdrawalFlowDb{}
  60. masterWithdrawalFlowDb.Set()
  61. list, total := masterWithdrawalFlowDb.GetWithdrawalFlowListWithTotal(amountMap["id"], args)
  62. data := make([]map[string]string, 0)
  63. if list != nil {
  64. for _, v := range *list {
  65. var tmp = map[string]string{
  66. "id": utils.IntToStr(v.Id),
  67. "alipay": v.Alipay,
  68. "alipay_name": v.AlipayName,
  69. "amount": v.Amount,
  70. "real_amount": v.RealAmount,
  71. "fee": v.Fee,
  72. "time": v.Time.Format("2006-01-02 15:04:05"),
  73. "check_time": "",
  74. "status": v.Status,
  75. "remark": v.Remark,
  76. "reason": v.Reason,
  77. "img": v.Img,
  78. "is_need_upload_invoice": utils.IntToStr(v.HasInvoice),
  79. }
  80. if v.Img != "" {
  81. tmp["is_need_upload_invoice"] = "0"
  82. }
  83. if v.CheckTime.IsZero() == false {
  84. tmp["check_time"] = v.CheckTime.Format("2006-01-02 15:04:05")
  85. }
  86. data = append(data, tmp)
  87. }
  88. }
  89. statusList := []map[string]string{
  90. {"name": "提现审核", "value": "提现审核"},
  91. {"name": "提现成功", "value": "提现成功"},
  92. {"name": "提现失败", "value": "提现失败"},
  93. }
  94. var res = map[string]interface{}{
  95. "list": data, "total": total, "status_list": statusList,
  96. }
  97. e.OutSuc(c, res, nil)
  98. return
  99. }
  100. func WithdrawalDoing(c *gin.Context) {
  101. args, mid, err := commArg(c)
  102. if err != nil {
  103. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  104. return
  105. }
  106. if utils.StrToFloat64(args["amount"]) <= 0 {
  107. e.OutErr(c, 400, e.NewErr(400, "金额不正确"))
  108. return
  109. }
  110. masterdb := db.MasterDb{}
  111. masterdb.Set()
  112. master := masterdb.GetMaster(mid)
  113. if master == nil {
  114. e.OutErr(c, 400, e.NewErr(400, "用户不存在"))
  115. return
  116. }
  117. amountMap := masterAmount(mid, args["type"])
  118. puid := "0"
  119. if args["amount_type"] == "agent_amount" {
  120. amountMap["amount"] = amountMap["agent_amount"]
  121. amountMap["list_id"] = amountMap["agent_list_id"]
  122. puid = amountMap["puid"]
  123. }
  124. leaveAmount := utils.StrToFloat64(amountMap["amount"]) - utils.StrToFloat64(args["amount"])
  125. if leaveAmount < 0 {
  126. e.OutErr(c, 400, e.NewErr(400, "余额不足"))
  127. return
  128. }
  129. masterListCfgDb := db.MasterListCfgDb{}
  130. masterListCfgDb.Set()
  131. withdrawalBili := masterListCfgDb.MasterListCfgGetOneData(puid, "withdrawal_bili")
  132. invoiceBili := masterListCfgDb.MasterListCfgGetOneData(puid, "invoice_bili")
  133. //withdrawalDay := masterListCfgDb.MasterListCfgGetOneData(puid, "withdrawal_day")
  134. //if time.Now().Day() != utils.StrToInt(withdrawalDay) && utils.StrToInt(withdrawalDay) > 0 {
  135. // e.OutErr(c, 400, e.NewErr(400, "每月"+withdrawalDay+"号提现"))
  136. // return
  137. //}
  138. var fee float64 = 0
  139. if utils.StrToFloat64(withdrawalBili) > 0 {
  140. bili := utils.StrToFloat64(withdrawalBili) / 100
  141. var invoiceBiliMap = make([]string, 0)
  142. json.Unmarshal([]byte(invoiceBili), &invoiceBiliMap)
  143. if utils.InArr(args["invoice_bili"], invoiceBiliMap) == false && utils.StrToInt(args["has_invoice"]) == 1 {
  144. e.OutErr(c, 400, e.NewErr(400, "发票税率不正确"))
  145. return
  146. }
  147. //开了发票的话再扣掉对应的发票比例
  148. if utils.InArr(args["invoice_bili"], invoiceBiliMap) && utils.StrToInt(args["has_invoice"]) == 1 {
  149. bili -= utils.StrToFloat64(args["invoice_bili"]) / 100
  150. }
  151. fee = utils.StrToFloat64(args["amount"]) * bili
  152. }
  153. realAmount := utils.StrToFloat64(args["amount"]) - fee
  154. if amountMap["alipay"] == "" {
  155. e.OutErr(c, 400, e.NewErr(400, "未绑定支付宝"))
  156. return
  157. }
  158. mutexKey := fmt.Sprintf("withdrawal:%s", amountMap["id"])
  159. withdrawAvailable, err := cache.Do("SET", mutexKey, 1, "EX", 30, "NX")
  160. if err != nil {
  161. e.OutErr(c, e.ERR, err)
  162. return
  163. }
  164. if withdrawAvailable != "OK" {
  165. e.OutErr(c, e.ERR, e.NewErr(400000, "操作过于频繁,请稍后再试"))
  166. return
  167. }
  168. sess := db.ZhimengDb.NewSession()
  169. err = sess.Begin()
  170. if err != nil {
  171. sess.Rollback()
  172. e.OutErr(c, 400, e.NewErr(400000, "请重试"))
  173. return
  174. }
  175. defer sess.Close()
  176. //先扣钱
  177. amountData := db.GetMasterAmountByListIdWithSess(sess, amountMap["list_id"])
  178. if amountData == nil {
  179. sess.Rollback()
  180. e.OutErr(c, e.ERR, e.NewErr(400000, "提现失败"))
  181. return
  182. }
  183. oldAmount := amountData.Amount
  184. leaveAmount = utils.StrToFloat64(amountData.Amount) - utils.StrToFloat64(args["amount"])
  185. if leaveAmount < 0 {
  186. e.OutErr(c, 400, e.NewErr(400, "余额不足"))
  187. return
  188. }
  189. amountData.Amount = utils.Float64ToStr(leaveAmount)
  190. update := db.MasterAmountUpdateWithSess(sess, amountData.Id, amountData)
  191. if update == false {
  192. e.OutErr(c, e.ERR, e.NewErr(400000, "提现失败"))
  193. return
  194. }
  195. //再写入明细
  196. var tmpFlow = model.MasterAmountFlow{
  197. Uid: amountMap["id"],
  198. Time: time.Now(),
  199. BeforeAmount: oldAmount,
  200. Amount: args["amount"],
  201. AfterAmount: amountData.Amount,
  202. Platform: args["type"],
  203. Oid: "",
  204. Title: "提现",
  205. FlowType: "withdrawal",
  206. ExtendUid: puid,
  207. }
  208. flowInsert := db.MasterAmountFlowInsertWithSess(sess, &tmpFlow)
  209. if flowInsert == false {
  210. e.OutErr(c, e.ERR, e.NewErr(400000, "提现失败"))
  211. return
  212. }
  213. var tmp = model.MasterWithdrawalFlow{
  214. Uid: amountMap["id"],
  215. Time: time.Now(),
  216. UpdateTime: time.Now(),
  217. Remark: args["remark"],
  218. Alipay: amountMap["alipay"],
  219. AlipayName: amountMap["alipay_name"],
  220. Amount: args["amount"],
  221. RealAmount: utils.Float64ToStr(realAmount),
  222. Fee: utils.Float64ToStr(fee),
  223. Reason: "",
  224. Status: "提现审核",
  225. HasInvoice: utils.StrToInt(args["has_invoice"]),
  226. InvoiceBili: args["invoice_bili"],
  227. ExtendUid: puid,
  228. }
  229. insert := db.MasterWithdrawalFlowInsertWithSess(sess, &tmp)
  230. if insert == false {
  231. e.OutErr(c, e.ERR, e.NewErr(400000, "提现失败"))
  232. return
  233. }
  234. sess.Commit()
  235. e.OutSuc(c, "success", nil)
  236. return
  237. }
  238. func WithdrawalOutput(c *gin.Context) {
  239. args, mid, err := commArg(c)
  240. if err != nil {
  241. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  242. return
  243. }
  244. args["size"] = "3000"
  245. amountMap := masterAmount(mid, args["type"])
  246. masterWithdrawalFlowDb := db.MasterWithdrawalFlowDb{}
  247. masterWithdrawalFlowDb.Set()
  248. list := masterWithdrawalFlowDb.GetWithdrawalFlowList(amountMap["id"], args)
  249. name := "订单_" + args["p"]
  250. //写入数据
  251. data := map[string]string{
  252. "A1": "提现支付宝账号",
  253. "B1": "提现支付宝姓名",
  254. "C1": "提现金额",
  255. "D1": "实际金额",
  256. "E1": "手续费",
  257. "F1": "提现状态",
  258. "G1": "申请时间",
  259. "H1": "审核时间",
  260. "I1": "备注",
  261. "J1": "失败原因",
  262. }
  263. if list != nil {
  264. for k, v := range *list {
  265. checkTime := ""
  266. if v.CheckTime.IsZero() == false {
  267. checkTime = v.CheckTime.Format("2006-01-02 15:04:05")
  268. }
  269. i := utils.IntToStr(k + 2)
  270. data["A"+i] = v.Alipay
  271. data["B"+i] = v.AlipayName
  272. data["C"+i] = v.Amount
  273. data["D"+i] = v.RealAmount
  274. data["E"+i] = v.Fee
  275. data["F"+i] = v.Status
  276. data["G"+i] = v.Time.Format("2006-01-02 15:04:05")
  277. data["H"+i] = checkTime
  278. data["I"+i] = v.Remark
  279. data["J"+i] = v.Reason
  280. }
  281. }
  282. file := utils.Output(c, name, data)
  283. filename := name + ".xlsx"
  284. r := map[string]string{
  285. "file": file,
  286. "filename": filename,
  287. }
  288. e.OutSuc(c, r, nil)
  289. return
  290. }
  291. func WithdrawalInvoiceImg(c *gin.Context) {
  292. var args map[string]string
  293. if err := c.ShouldBindJSON(&args); err != nil {
  294. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  295. return
  296. }
  297. masterWithdrawalFlowDb := db.MasterWithdrawalFlowDb{}
  298. masterWithdrawalFlowDb.Set()
  299. flow := masterWithdrawalFlowDb.MasterWithdrawalFlowById(args["id"])
  300. flow.Img = args["img"]
  301. update := masterWithdrawalFlowDb.MasterWithdrawalFlowInsertUpdate(flow)
  302. if update == false {
  303. e.OutErr(c, 400, e.NewErr(400, "上传失败"))
  304. return
  305. }
  306. e.OutSuc(c, "success", nil)
  307. return
  308. }
  309. func WithdrawalBindAlipay(c *gin.Context) {
  310. var args map[string]string
  311. if err := c.ShouldBindJSON(&args); err != nil {
  312. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  313. return
  314. }
  315. if args["alipay"] == "" || args["alipay_name"] == "" {
  316. e.OutErr(c, 400, e.NewErr(400, "支付宝信息不能为空"))
  317. return
  318. }
  319. mob1, errr := mob.GetMobSDK(c.GetString("master_id"))
  320. if errr != nil {
  321. e.OutErr(c, e.ERR_MOB_CONFIG, errr)
  322. return
  323. }
  324. if c.GetString("is_system") == "" {
  325. e.OutErr(c, 400, e.NewErr(400, "请重新在后台进入聚合联盟"))
  326. return
  327. }
  328. if c.GetString("is_system") != "1" {
  329. e.OutErr(c, 400, e.NewErr(400, "请使用超管账号设置"))
  330. return
  331. }
  332. send := map[string]interface{}{
  333. "phone": c.GetString("phone"),
  334. "zone": "86",
  335. "code": args["captcha"],
  336. }
  337. ok, err := mob1.MobSMS(c, send)
  338. if err != nil {
  339. e.OutErr(c, 400, err.Error())
  340. return
  341. }
  342. ok = true
  343. if ok {
  344. masterId, _ := c.Get("master_id")
  345. mid := utils.AnyToString(masterId)
  346. masterDb := db.MasterDb{}
  347. masterDb.Set()
  348. master := masterDb.GetMaster(mid)
  349. master.AlipayName = args["alipay_name"]
  350. master.Alipay = args["alipay"]
  351. update := masterDb.MasterUpdate(master)
  352. if update == false {
  353. e.OutErr(c, 400, e.NewErr(400, "修改失败"))
  354. return
  355. }
  356. e.OutSuc(c, "success", nil)
  357. return
  358. }
  359. e.OutErr(c, 400, e.NewErr(400, "验证码错误"))
  360. return
  361. }
  362. func commArg(c *gin.Context) (map[string]string, string, error) {
  363. masterId, _ := c.Get("master_id")
  364. mid := utils.AnyToString(masterId)
  365. fmt.Println(mid)
  366. var args map[string]string
  367. if err := c.ShouldBindJSON(&args); err != nil {
  368. return args, mid, err
  369. }
  370. return args, mid, nil
  371. }
  372. func masterInfo(mid string) map[string]string {
  373. masterDb := db.MasterDb{}
  374. masterDb.Set()
  375. master := masterDb.GetMaster(mid)
  376. res := make(map[string]string)
  377. if master != nil {
  378. res["id"] = utils.IntToStr(master.Id)
  379. res["alipay"] = master.Alipay
  380. res["alipay_name"] = master.AlipayName
  381. }
  382. return res
  383. }
  384. func masterAmount(mid, types string) map[string]string {
  385. masterInfos := masterInfo(mid)
  386. res := map[string]string{
  387. "amount": "0.00",
  388. "last_month_settle_amount": "0.00",
  389. }
  390. if masterInfos["id"] == "" {
  391. return res
  392. }
  393. puid := AppUserListPuid(mid)
  394. hwOwnOpen := offical.MasterListCfgGetOneData(puid, "hw_own_open")
  395. masterAmountDb := db.MasterAmountDb{}
  396. masterAmountDb.Set()
  397. masterAmounts := masterAmountDb.GetMasterAmountByExtendUid(masterInfos["id"], "0", types)
  398. if masterAmounts == nil {
  399. return res
  400. }
  401. res["agent_amount"] = "0"
  402. res["is_show_official_amount"] = "1"
  403. res["puid"] = puid
  404. res["is_show_agent_amount"] = "0"
  405. if utils.StrToInt(puid) > 0 && hwOwnOpen == "1" {
  406. res["is_show_agent_amount"] = "1"
  407. agentMasterAmounts := masterAmountDb.GetMasterAmountByExtendUid(masterInfos["id"], puid, types)
  408. if agentMasterAmounts != nil {
  409. if agentMasterAmounts.Amount != "" {
  410. res["agent_amount"] = agentMasterAmounts.Amount
  411. }
  412. res["agent_list_id"] = utils.IntToStr(agentMasterAmounts.Id)
  413. masterAmounts.LastMonthAmount = utils.Float64ToStr(utils.StrToFloat64(masterAmounts.LastMonthAmount) + utils.StrToFloat64(agentMasterAmounts.LastMonthAmount))
  414. }
  415. if utils.StrToFloat64(masterAmounts.Amount) == 0 {
  416. res["is_show_official_amount"] = "0"
  417. }
  418. }
  419. res["amount"] = masterAmounts.Amount
  420. if res["amount"] == "" {
  421. res["amount"] = "0"
  422. }
  423. res["id"] = masterAmounts.Uid
  424. res["list_id"] = utils.IntToStr(masterAmounts.Id)
  425. res["alipay"] = masterInfos["alipay"]
  426. res["alipay_name"] = masterInfos["alipay_name"]
  427. res["last_month_settle_amount"] = masterAmounts.LastMonthAmount
  428. if res["last_month_settle_amount"] == "" {
  429. res["last_month_settle_amount"] = "0"
  430. }
  431. return res
  432. }
  433. func masterMonthAmount(mid string) map[string]string {
  434. playletSaleOrder := db.PlayletSaleOrderDb{}
  435. playletSaleOrder.Set()
  436. lastMonthSum := playletSaleOrder.PlayletVideoOrderSum(mid, "", "last_month")
  437. monthSum := playletSaleOrder.PlayletVideoOrderSum(mid, "", "current_month")
  438. monthSettleSum := playletSaleOrder.PlayletVideoOrderSum(mid, "订单结算", "current_month")
  439. lastMonthTimeRange := utils.GetTimeRange("last_month")
  440. currentMonthTimeRange := utils.GetTimeRange("current_month")
  441. hwSum, _ := db.ZhimengDb.NotIn("status", []string{"违规订单", "创建订单", "订单退款", "订单失效"}).Where("uid=? and create_time>=? and create_time<?", mid, lastMonthTimeRange["start"], lastMonthTimeRange["end"]).Sum(&model.HwOrder{}, "commission")
  442. guideSum, _ := db.ZhimengDb.NotIn("status", []string{"违规订单", "创建订单", "订单退款", "订单失效"}).Where("uid=? and create_time>=? and create_time<?", mid, lastMonthTimeRange["start"], lastMonthTimeRange["end"]).Sum(&model.GuideOrder{}, "commission")
  443. lifeSum, _ := db.ZhimengDb.NotIn("status", []string{"违规订单", "创建订单", "订单退款", "订单失效", "风控"}).Where("uid=? and create_time>=? and create_time<?", mid, lastMonthTimeRange["start"], lastMonthTimeRange["end"]).Sum(&model.LifeOrder{}, "commission")
  444. lastMonthSum += hwSum + guideSum + lifeSum
  445. hwMonthSum, _ := db.ZhimengDb.NotIn("status", []string{"违规订单", "创建订单", "订单退款", "订单失效"}).Where("uid=? and create_time>=? and create_time<?", mid, currentMonthTimeRange["start"], currentMonthTimeRange["end"]).Sum(&model.HwOrder{}, "commission")
  446. guideMonthSum, _ := db.ZhimengDb.NotIn("status", []string{"违规订单", "创建订单", "订单退款", "订单失效"}).Where("uid=? and create_time>=? and create_time<?", mid, currentMonthTimeRange["start"], currentMonthTimeRange["end"]).Sum(&model.GuideOrder{}, "commission")
  447. lifeMonthSum, _ := db.ZhimengDb.NotIn("status", []string{"违规订单", "创建订单", "订单退款", "订单失效", "风控"}).Where("uid=? and create_time>=? and create_time<?", mid, currentMonthTimeRange["start"], currentMonthTimeRange["end"]).Sum(&model.LifeOrder{}, "commission")
  448. monthSum += hwMonthSum + guideMonthSum + lifeMonthSum
  449. hwMonthSettleSum, _ := db.ZhimengDb.In("status", []string{"订单结算"}).Where("uid=? and create_time>=? and create_time<?", mid, currentMonthTimeRange["start"], currentMonthTimeRange["end"]).Sum(&model.HwOrder{}, "commission")
  450. guideMonthSettleSum, _ := db.ZhimengDb.In("status", []string{"订单结算"}).Where("uid=? and create_time>=? and create_time<?", mid, currentMonthTimeRange["start"], currentMonthTimeRange["end"]).Sum(&model.GuideOrder{}, "real_commission")
  451. lifeMonthSettleSum, _ := db.ZhimengDb.In("status", []string{"订单结算"}).Where("uid=? and create_time>=? and create_time<?", mid, currentMonthTimeRange["start"], currentMonthTimeRange["end"]).Sum(&model.LifeOrder{}, "real_commission")
  452. monthSettleSum += hwMonthSettleSum + guideMonthSettleSum + lifeMonthSettleSum
  453. waithwSum, _ := db.ZhimengDb.NotIn("status", []string{"违规订单", "创建订单", "订单退款", "订单失效"}).Where("uid=? and settle_time=0", mid).Sum(&model.HwOrder{}, "commission")
  454. waitguideSum, _ := db.ZhimengDb.NotIn("status", []string{"违规订单", "创建订单", "订单退款", "订单失效"}).Where("uid=? and settle_time=0", mid).Sum(&model.GuideOrder{}, "commission")
  455. waitlifeSum, _ := db.ZhimengDb.NotIn("status", []string{"违规订单", "创建订单", "订单退款", "订单失效", "风控"}).Where("uid=? and settle_time=0", mid).Sum(&model.LifeOrder{}, "commission")
  456. waitSum := waithwSum + waitguideSum + waitlifeSum
  457. res := map[string]string{
  458. "waitSum": utils.Float64ToStr(waitSum),
  459. "last_month_amount": utils.Float64ToStr(lastMonthSum),
  460. "month_amount": utils.Float64ToStr(monthSum),
  461. "month_settle_amount": utils.Float64ToStr(monthSettleSum),
  462. }
  463. return res
  464. }