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

520 lines
19 KiB

  1. package egg_energy
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. md "applet/app/md/institutional_management/egg_energy"
  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. "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/enum"
  10. md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
  11. "errors"
  12. "fmt"
  13. "github.com/gin-gonic/gin"
  14. "time"
  15. )
  16. // GetVirtualCoinList
  17. // @Summary 制度中心-蛋蛋能量-查询所有币种(获取)
  18. // @Tags 蛋蛋能量
  19. // @Description 查询所有币种(获取)
  20. // @Accept json
  21. // @Produce json
  22. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  23. // @Success 200 {object} []md.VirtualCoin "成功返回"
  24. // @Failure 400 {object} md.Response "具体错误"
  25. // @Router /api/institutionalManagement/eggEnergy/availableEnergy/list [post]
  26. func GetVirtualCoinList(c *gin.Context) {
  27. virtualCoinDb := implement.NewVirtualCoinDb(db.Db)
  28. coins, err := virtualCoinDb.VirtualCoinFindAll()
  29. if err != nil {
  30. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  31. return
  32. }
  33. list := make([]md.VirtualCoin, len(coins))
  34. for i, coin := range coins {
  35. list[i] = md.VirtualCoin{
  36. Id: coin.Id,
  37. Name: coin.Name,
  38. ExchangeRatio: coin.ExchangeRatio,
  39. IsUse: coin.IsUse,
  40. CreateAt: coin.CreateAt,
  41. UpdateAt: coin.UpdateAt,
  42. }
  43. }
  44. e.OutSuc(c, list, nil)
  45. }
  46. // GetEggEnergyBasic
  47. // @Summary 制度中心-蛋蛋能量-基础设置(获取)
  48. // @Tags 蛋蛋能量
  49. // @Description 基础设置(获取)
  50. // @Accept json
  51. // @Produce json
  52. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  53. // @Success 200 {object} md.GetEggEnergyBasicResp "具体数据"
  54. // @Failure 400 {object} md.Response "具体错误"
  55. // @Router /api/institutionalManagement/eggEnergy/getBasic [get]
  56. func GetEggEnergyBasic(c *gin.Context) {
  57. basicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
  58. basicSettings, err1 := basicSettingDb.EggEnergyBasicSettingGetOne()
  59. if err1 != nil {
  60. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  61. return
  62. }
  63. if basicSettings == nil {
  64. e.OutErr(c, e.ERR_NO_DATA, errors.New("未能获取基础设置"))
  65. return
  66. }
  67. var videoRewardSystem md2.VideoRewardSystemStruct
  68. utils.Unserialize([]byte(basicSettings.VideoRewardSystem), videoRewardSystem)
  69. var destructionSetting md2.DestructionSettingStruct
  70. utils.Unserialize([]byte(basicSettings.DestructionSetting), destructionSetting)
  71. var priceSetting md2.PriceSettingStruct
  72. utils.Unserialize([]byte(basicSettings.PriceSetting), priceSetting)
  73. var exchangeRules md2.ExchangeRulesStruct
  74. utils.Unserialize([]byte(basicSettings.ExchangeRules), exchangeRules)
  75. var rewardSystem md2.RewardSystemStruct
  76. utils.Unserialize([]byte(basicSettings.RewardSystem), rewardSystem)
  77. var newUserRewardRules md2.NewUserRewardRules
  78. utils.Unserialize([]byte(basicSettings.NewUserIncentiveRules), newUserRewardRules)
  79. var directPushReward md2.TeamRewardSettingStruct
  80. utils.Unserialize([]byte(basicSettings.DirectPushReward), directPushReward)
  81. resp := md.GetEggEnergyBasicResp{
  82. BasicSetting: md.BasicSetting{
  83. IsOpen: basicSettings.IsOpen,
  84. PersonEggEnergyCoinId: basicSettings.PersonEggEnergyCoinId,
  85. TeamEggEnergyCoinId: basicSettings.TeamEggEnergyCoinId,
  86. PersonEggPointsCoinId: basicSettings.PersonEggPointsCoinId,
  87. TeamEggPointsCoinId: basicSettings.TeamEggPointsCoinId,
  88. DirectPushReward: md2.TeamRewardSettingStruct{
  89. RewardDecrementValue: directPushReward.RewardDecrementValue,
  90. RewardEndValue: directPushReward.RewardEndValue,
  91. MemberSelfIsOpenGetTeamReward: directPushReward.MemberSelfIsOpenGetTeamReward,
  92. OneRoundDuration: directPushReward.OneRoundDuration,
  93. },
  94. },
  95. VideoRewardSetting: md.VideoRewardSetting{
  96. VideoRewardIsOpen: basicSettings.VideoRewardIsOpen,
  97. VideoRewardSystem: md2.VideoRewardSystemStruct{
  98. RewardValue: videoRewardSystem.RewardValue,
  99. RewardTotalNum: videoRewardSystem.RewardTotalNum,
  100. IntervalMinutes: videoRewardSystem.IntervalMinutes,
  101. EachRoundHour: videoRewardSystem.EachRoundHour,
  102. },
  103. },
  104. DataSetting: md.DataSetting{
  105. TotalIssuanceAmount: basicSettings.TotalIssuanceAmount,
  106. TotalTechnologyTeam: basicSettings.TotalTechnologyTeam,
  107. TotalAngelInvestor: basicSettings.TotalAngelInvestor,
  108. TotalOperateFund: basicSettings.TotalOperateFund,
  109. TotalEcologicalDevelopment: basicSettings.TotalEcologicalDevelopment,
  110. TotalUserForPerson: basicSettings.TotalUserForPerson,
  111. TotalUserForTeam: basicSettings.TotalUserForTeam,
  112. },
  113. DestructionSetting: md2.DestructionSettingStruct{
  114. DestructionQuantity: destructionSetting.DestructionQuantity,
  115. PublicWelfareAndCharity: destructionSetting.PublicWelfareAndCharity,
  116. DevelopmentCommittee: destructionSetting.DevelopmentCommittee,
  117. StarLevelDividends: destructionSetting.StarLevelDividends,
  118. MarketplaceMerchant: destructionSetting.MarketplaceMerchant,
  119. CommunityDividends: destructionSetting.CommunityDividends,
  120. },
  121. PriceSetting: md2.PriceSettingStruct{
  122. PriceHigherThanValue: priceSetting.PriceHigherThanValue,
  123. MarketplaceMerchantsNumsExchangeMarketplaceMerchantsFundValue: priceSetting.MarketplaceMerchantsNumsExchangeMarketplaceMerchantsFundValue,
  124. PriceBelowValue: priceSetting.PriceBelowValue,
  125. MarketplaceMerchantsFundExchangeMarketplaceMerchantsNumsValue: priceSetting.MarketplaceMerchantsFundExchangeMarketplaceMerchantsNumsValue,
  126. },
  127. ExchangeRules: md2.ExchangeRulesStruct{
  128. AutoExchangeNumsByPerson: exchangeRules.AutoExchangeNumsByPerson,
  129. AutoExchangeRateByPerson: exchangeRules.AutoExchangeRateByPerson,
  130. AutoExchangeNumsByTeam: exchangeRules.AutoExchangeNumsByTeam,
  131. AutoExchangeRateByTeam: exchangeRules.AutoExchangeRateByTeam,
  132. },
  133. RewardSystem: md2.RewardSystemStruct{
  134. Level: rewardSystem.Level,
  135. RewardCondition: rewardSystem.RewardCondition,
  136. RewardValue: rewardSystem.RewardValue,
  137. },
  138. NewUserIncentiveRules: md2.NewUserRewardRules{
  139. InviteUserRewardValue: newUserRewardRules.InviteUserRewardValue,
  140. RewardCoefficient: newUserRewardRules.RewardCoefficient,
  141. ContinueDays: newUserRewardRules.ContinueDays,
  142. },
  143. SystemID: basicSettings.Id,
  144. }
  145. e.OutSuc(c, resp, nil)
  146. }
  147. // UpdateEggEnergyBasic
  148. // @Summary 制度中心-蛋蛋能量-基础设置(更新)
  149. // @Tags 蛋蛋能量
  150. // @Description 基础设置(更新)
  151. // @Accept json
  152. // @Produce json
  153. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  154. // @Param req body md.UpdateEggEnergyBasicReq true "system_id 必填"
  155. // @Success 200 {int} "修改数据条数"
  156. // @Failure 400 {object} md.Response "具体错误"
  157. // @Router /api/institutionalManagement/eggEnergy/updateBasic [post]
  158. func UpdateEggEnergyBasic(c *gin.Context) {
  159. var req *md.UpdateEggEnergyBasicReq
  160. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  161. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  162. return
  163. }
  164. destructionSettingStr := utils.SerializeStr(req.DestructionSetting)
  165. priceSettingStr := utils.SerializeStr(req.PriceSetting)
  166. videoRewardSystemStr := utils.SerializeStr(req.VideoRewardSetting.VideoRewardSystem)
  167. exchangeRulesStr := utils.SerializeStr(req.ExchangeRules)
  168. rewardSystemStr := utils.SerializeStr(req.RewardSystem)
  169. newUserIncentiveRulesStr := utils.SerializeStr(req.NewUserIncentiveRules)
  170. directPushRewardStr := utils.SerializeStr(req.BasicSetting.DirectPushReward)
  171. m := model.EggEnergyBasicSetting{
  172. Id: req.SystemID,
  173. IsOpen: req.BasicSetting.IsOpen,
  174. PersonEggEnergyCoinId: req.BasicSetting.PersonEggEnergyCoinId,
  175. TeamEggEnergyCoinId: req.BasicSetting.TeamEggEnergyCoinId,
  176. PersonEggPointsCoinId: req.BasicSetting.PersonEggPointsCoinId,
  177. TeamEggPointsCoinId: req.BasicSetting.TeamEggPointsCoinId,
  178. TotalIssuanceAmount: req.DataSetting.TotalIssuanceAmount,
  179. TotalTechnologyTeam: req.DataSetting.TotalTechnologyTeam,
  180. TotalAngelInvestor: req.DataSetting.TotalAngelInvestor,
  181. TotalOperateFund: req.DataSetting.TotalOperateFund,
  182. TotalEcologicalDevelopment: req.DataSetting.TotalEcologicalDevelopment,
  183. TotalUserForPerson: req.DataSetting.TotalUserForPerson,
  184. TotalUserForTeam: req.DataSetting.TotalUserForTeam,
  185. DestructionSetting: destructionSettingStr,
  186. DirectPushReward: directPushRewardStr,
  187. PriceSetting: priceSettingStr,
  188. VideoRewardIsOpen: req.VideoRewardSetting.VideoRewardIsOpen,
  189. VideoRewardSystem: videoRewardSystemStr,
  190. ExchangeRules: exchangeRulesStr,
  191. RewardSystem: rewardSystemStr,
  192. NewUserIncentiveRules: newUserIncentiveRulesStr,
  193. }
  194. energyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
  195. session := db.Db.NewSession()
  196. affected, err := energyBasicSettingDb.EggEnergyBasicSettingUpdate(session, req.SystemID, &m)
  197. if err != nil {
  198. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  199. return
  200. }
  201. e.OutSuc(c, affected, nil)
  202. }
  203. // GetEggCoreDataList
  204. // @Summary 制度中心-蛋蛋能量-数据概览(获取)
  205. // @Tags 蛋蛋能量
  206. // @Description 数据概览(获取)
  207. // @Accept json
  208. // @Produce json
  209. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  210. // @Success 200 {object} md.GetEggCoreDataListResp "具体数据"
  211. // @Failure 400 {object} md.Response "具体错误"
  212. // @Router /api/institutionalManagement/eggEnergy/globalData/coreDataList [get]
  213. func GetEggCoreDataList(c *gin.Context) {
  214. coreDataDb := implement.NewEggEnergyCoreDataDb(db.Db)
  215. coreData, err := coreDataDb.EggEnergyCoreDataGet()
  216. if err != nil {
  217. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  218. return
  219. }
  220. if coreData == nil {
  221. e.OutErr(c, e.ERR_NO_DATA, errors.New("数据不存在"))
  222. return
  223. }
  224. sql := "SELECT SUM(amount) AS total, coin_id FORM `user_virtual_amount` GROUP BY (coin_id)"
  225. results, err := db.Db.QueryString(sql)
  226. if err != nil {
  227. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  228. return
  229. }
  230. coinsHoldMap := make(map[int]string)
  231. for _, result := range results {
  232. coinsHoldMap[utils.StrToInt(result["coin_id"])] = result["total"]
  233. }
  234. basicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
  235. basicSetting, err := basicSettingDb.EggEnergyBasicSettingGetOne()
  236. if err != nil {
  237. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  238. return
  239. }
  240. userHoldTotalNumsMap := map[string]string{
  241. "PersonEggEnergyUserHoldTotal": coinsHoldMap[basicSetting.PersonEggEnergyCoinId],
  242. "TeamEggEnergyUserHoldTotal": coinsHoldMap[basicSetting.TeamEggEnergyCoinId],
  243. "PersonEggPointsUserHoldTotal": coinsHoldMap[basicSetting.PersonEggPointsCoinId],
  244. "TeamEggPointsUserHoldTotal": coinsHoldMap[basicSetting.TeamEggPointsCoinId],
  245. "ContributionUserHoldTotal": coinsHoldMap[basicSetting.ContributionCoinId],
  246. }
  247. resp := md.GetEggCoreDataListResp{
  248. PlanetTotalValue: coreData.PlanetTotalValue,
  249. NowPrice: coreData.NowPrice,
  250. NowEnergyTotalNums: coreData.NowEnergyTotalNums,
  251. UserHoldTotalNums: userHoldTotalNumsMap,
  252. }
  253. e.OutSuc(c, resp, nil)
  254. }
  255. // GetPriceCurve
  256. // @Summary 制度中心-蛋蛋能量-价格趋势(获取)
  257. // @Tags 蛋蛋能量
  258. // @Description 价格趋势(获取)
  259. // @Accept json
  260. // @Produce json
  261. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  262. // @Param kind query string false "1:按天 2:按小时 3:按周"
  263. // @Success 200 {object} md.GetPriceCurveResp "具体数据"
  264. // @Failure 400 {object} md.Response "具体错误"
  265. // @Router /api/institutionalManagement/eggEnergy/globalData/pointsCenterPriceCurve [get]
  266. func GetPriceCurve(c *gin.Context) {
  267. kind := c.DefaultQuery("kind", "1")
  268. now := time.Now()
  269. priceDb := implement.NewEggEnergyPriceDb(db.Db)
  270. m, has, err := priceDb.EggEnergyPriceGetLastOne()
  271. if err != nil {
  272. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  273. return
  274. }
  275. if has == false {
  276. e.OutErr(c, e.ERR_NO_DATA, "未查询到数据")
  277. return
  278. }
  279. var yData []interface{}
  280. var xData []interface{}
  281. switch kind {
  282. case "1":
  283. var date = now.AddDate(0, 0, -30).Format("2006-01-02")
  284. var sql = fmt.Sprintf("SELECT price,date FROM `egg_energy_price` WHERE HOUR = 23 AND DATE >= \"%s\" AND DATE != \"%s\" ORDER BY DATE ASC ", date, now.Format("2006-01-02"))
  285. results, _ := db.Db.QueryString(sql)
  286. for _, v := range results {
  287. tmpDate := utils.TimeParseStd(v["date"])
  288. yData = append(yData, v["price"])
  289. xData = append(xData, tmpDate.Format("01-02"))
  290. }
  291. yData = append(yData, m.Price)
  292. tmpDate := utils.TimeParseStd(m.Date)
  293. xData = append(xData, tmpDate.Format("01-02"))
  294. break
  295. case "2":
  296. for i := 29; i >= 1; i-- {
  297. date := now.Add(-time.Hour * 4 * time.Duration(i)).Format("2006-01-02")
  298. hour := now.Add(-time.Hour * 4 * time.Duration(i)).Hour()
  299. var sql = "SELECT price,date,hour FROM `egg_energy_price` WHERE HOUR = %d AND DATE = \"%s\" "
  300. sql = fmt.Sprintf(sql, hour, date)
  301. results, _ := db.Db.QueryString(sql)
  302. if results != nil {
  303. //if results[0]["date"] != now.Format("2006-01-02") {
  304. // continue
  305. //}
  306. yData = append(yData, results[0]["price"])
  307. xData = append(xData, results[0]["hour"]+":00")
  308. }
  309. }
  310. yData = append(yData, m.Price)
  311. xData = append(xData, m.Hour+":00")
  312. break
  313. case "3":
  314. var nums = 29
  315. for i := nums; i >= 1; i-- {
  316. var date = now.AddDate(0, 0, -7*i).Format("2006-01-02")
  317. var sql = "SELECT price,date FROM `egg_energy_price` WHERE HOUR = 23 AND DATE = \"%s\" "
  318. sql = fmt.Sprintf(sql, date)
  319. results, _ := db.Db.QueryString(sql)
  320. if results != nil {
  321. tmpDate := utils.TimeParseStd(results[0]["date"])
  322. yData = append(yData, results[0]["price"])
  323. xData = append(xData, tmpDate.Format("01-02"))
  324. }
  325. }
  326. yData = append(yData, m.Price)
  327. tmpDate := utils.TimeParseStd(m.Date)
  328. xData = append(xData, tmpDate.Format("01-02"))
  329. break
  330. }
  331. e.OutSuc(c, md.GetPriceCurveResp{
  332. YData: yData,
  333. XData: xData,
  334. }, nil)
  335. return
  336. }
  337. // GetFundDataList
  338. // @Summary 制度中心-蛋蛋能量-新增数据列表(获取)
  339. // @Tags 蛋蛋能量
  340. // @Description 新增数据列表(获取)
  341. // @Accept json
  342. // @Produce json
  343. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  344. // @Param req body md.GetFundDataListReq true "分页信息必填"
  345. // @Success 200 {object} md.GetFundDataListResp "具体数据"
  346. // @Failure 400 {object} md.Response "具体错误"
  347. // @Router /api/institutionalManagement/eggEnergy/globalData/fundDataList [post]
  348. func GetFundDataList(c *gin.Context) {
  349. var req *md.GetFundDataListReq
  350. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  351. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  352. return
  353. }
  354. var kindList = []map[string]interface{}{
  355. {
  356. "name": enum.EggEnergyFundDataKind.String(enum.CompanySubsidies),
  357. "value": enum.CompanySubsidies,
  358. },
  359. {
  360. "name": enum.EggEnergyFundDataKind.String(enum.InvestmentByInvestors),
  361. "value": enum.InvestmentByInvestors,
  362. },
  363. {
  364. "name": enum.EggEnergyFundDataKind.String(enum.MarketExpectations),
  365. "value": enum.MarketExpectations,
  366. },
  367. }
  368. fundDataDb := implement.NewEggEnergyFundDataDb(db.Db)
  369. fundDataList, total, err := fundDataDb.EggEnergyFundDataFindAndCount(req.Page, req.Limit, req.Limit, req.StartAt, req.EndAt)
  370. if err != nil {
  371. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  372. return
  373. }
  374. list := make([]md.FundDataNode, len(fundDataList))
  375. for i, fundData := range fundDataList {
  376. list[i].Kind = fundData.Kind
  377. list[i].TotalAmount = fundData.TotalAmount
  378. list[i].Hours = fundData.Hours
  379. list[i].Memo = fundData.Memo
  380. list[i].BalanceTimes = fundData.BalanceTimes
  381. list[i].BalanceAmount = fundData.BalanceAmount
  382. list[i].CreateAt = fundData.CreateAt
  383. list[i].SystemID = fundData.Id
  384. }
  385. resp := md.GetFundDataListResp{
  386. KindList: kindList,
  387. Paginate: md.Paginate{
  388. Limit: req.Limit,
  389. Page: req.Page,
  390. Total: total,
  391. },
  392. List: list,
  393. }
  394. e.OutSuc(c, resp, nil)
  395. }
  396. // GetFundDataRecordList
  397. // @Summary 制度中心-蛋蛋能量-新增数据列表详情(查询)
  398. // @Tags 蛋蛋能量
  399. // @Description 新增数据列表详情(查询)
  400. // @Accept json
  401. // @Produce json
  402. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  403. // @Param req body md.GetFundDataRecordListReq true "获取到的 system_id 以及分页信息"
  404. // @Success 200 {object} md.GetFundDataRecordListResp "具体数据"
  405. // @Failure 400 {object} md.Response "具体错误"
  406. // @Router /api/institutionalManagement/eggEnergy/globalData/fundDataRecordList [post]
  407. func GetFundDataRecordList(c *gin.Context) {
  408. var req *md.GetFundDataRecordListReq
  409. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  410. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  411. return
  412. }
  413. recordsDb := implement.NewEggEnergyFundDataRecordsDb(db.Db)
  414. records, total, err := recordsDb.EggEnergyFundDataRecordsFindAndCount(req.Page, req.Limit, req.SystemID)
  415. if err != nil {
  416. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  417. return
  418. }
  419. var list []md.FundDataRecordNode
  420. for i, record := range records {
  421. list[i].TotalAmount = record.TotalAmount
  422. list[i].BalanceAmount = record.BalanceAmount
  423. list[i].BalanceTimes = record.BalanceTimes
  424. list[i].BeforePrice = record.BeforePrice
  425. list[i].AfterPrice = record.AfterPrice
  426. list[i].BeforePlanetTotalValue = record.BeforePlanetTotalValue
  427. list[i].AfterPlanetTotalValue = record.AfterPlanetTotalValue
  428. list[i].CreateAt = record.CreateAt
  429. }
  430. resp := md.GetFundDataRecordListResp{
  431. Paginate: md.Paginate{
  432. Limit: req.Limit,
  433. Page: req.Page,
  434. Total: total,
  435. },
  436. List: list,
  437. }
  438. e.OutSuc(c, resp, nil)
  439. }
  440. // AddFundData
  441. // @Summary 制度中心-蛋蛋能量-价值明细数据(新增)
  442. // @Tags 蛋蛋能量
  443. // @Description 价值明细数据(新增)
  444. // @Accept json
  445. // @Produce json
  446. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  447. // @Param req body md.AddFundDataReq true "数据种类、金额、时长(最长24h)、执行次数必填,备注选填"
  448. // @Success 200 {int} "插入数据 id"
  449. // @Failure 400 {object} md.Response "具体错误"
  450. // @Router /api/institutionalManagement/eggEnergy/globalData/fundDataAdd [post]
  451. func AddFundData(c *gin.Context) {
  452. var req *md.AddFundDataReq
  453. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  454. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  455. return
  456. }
  457. fundDataDb := implement.NewEggEnergyFundDataDb(db.Db)
  458. now := time.Now()
  459. hour := now.Hour()
  460. if req.Hours > 24 {
  461. hour = 24
  462. }
  463. m := model.EggEnergyFundData{
  464. Kind: req.Kind,
  465. TotalAmount: req.TotalAmount,
  466. BalanceAmount: req.TotalAmount,
  467. Hours: hour,
  468. BalanceTimes: req.Times,
  469. Memo: req.Memo,
  470. CreateAt: now.Format("2006-01-02 15:04:05"),
  471. UpdateAt: now.Format("2006-01-02 15:04:05"),
  472. }
  473. id, err := fundDataDb.EggEnergyFundDataInsert(&m)
  474. if err != nil {
  475. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  476. return
  477. }
  478. e.OutSuc(c, id, nil)
  479. }