1
This commit is contained in:
commit
a508cdfa30
@ -1,3 +1,8 @@
|
||||
# 本地host文件修改
|
||||
192.144.140.87 mysql-test.kingsome.cn
|
||||
192.144.140.87 redis-test.kingsome.cn
|
||||
192.144.200.110 polyservice-test.kingsome.cn
|
||||
|
||||
# 数据库规范
|
||||
|
||||
所有的表都必须有一下字段
|
||||
|
@ -1,9 +1,11 @@
|
||||
{
|
||||
"api": [
|
||||
"*",
|
||||
"api/v1/mail/add",
|
||||
"api/v1/mail/edit",
|
||||
"api/v1/mail/list"
|
||||
],
|
||||
"ui": [
|
||||
"*"
|
||||
]
|
||||
}
|
||||
|
@ -9,5 +9,17 @@
|
||||
"api": ["xxx", "-xxx"],
|
||||
"ui": ["addannouncement", "editannouncement", "addaudit", "editaudit"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"account_address": "0xAd2DeA1977055Db01C66e6E53309C4604AB869b8",
|
||||
"__doc__": "az",
|
||||
"roles": [
|
||||
"admin",
|
||||
"customer_service"
|
||||
],
|
||||
"special": {
|
||||
"api": ["xxx", "-xxx"],
|
||||
"ui": ["addannouncement", "editannouncement", "addaudit", "editaudit"]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
[
|
||||
{
|
||||
"url": "http://192.144.200.110:7682"
|
||||
"url": "http://polyservice-test.kingsome.cn:7682"
|
||||
}
|
||||
]
|
||||
|
@ -1,24 +1,63 @@
|
||||
-- MySQL dump 10.14 Distrib 5.5.41-MariaDB, for Linux (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: admindb
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 5.5.41-MariaDB
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `version`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `version`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `version` (
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`version` int(11) NOT NULL DEFAULT '0' COMMENT '版本号',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `version` (`version`)
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`version` int(11) NOT NULL DEFAULT '0' COMMENT '版本号',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `version` (`version`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_op_log`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_user`;
|
||||
DROP TABLE IF EXISTS `t_op_log`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_user` (
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`username` varchar(32) NOT NULL DEFAULT '0' COMMENT '用户名',
|
||||
`nickname` varchar(32) NOT NULL DEFAULT '0' COMMENT '别名',
|
||||
`password` varchar(64) NOT NULL DEFAULT '0' COMMENT '密码',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `username` (`username`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
CREATE TABLE `t_op_log` (
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_address` varchar(60) NOT NULL COMMENT '钱包地址',
|
||||
`http_method` varchar(10) NOT NULL COMMENT 'http method<10byte',
|
||||
`url` text NOT NULL DEFAULT '' COMMENT 'url<64kb',
|
||||
`params` text NOT NULL DEFAULT '' COMMENT 'params<64kb',
|
||||
`postdata` mediumtext NOT NULL DEFAULT '' COMMENT 'postdata<16mb',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
KEY `idx_account_address` (`account_address`),
|
||||
PRIMARY KEY (`idx`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2015-08-19 18:52:06
|
||||
|
@ -15,8 +15,29 @@ type MailApi struct {
|
||||
}
|
||||
|
||||
func (this *MailApi) ListMail(c *gin.Context) {
|
||||
mails := []system.Mail{}
|
||||
f5.GetApp().GetOrmDb(constant.MAIL_DB).Find(&mails)
|
||||
var pageSize int32 = 100
|
||||
var cursor int64 = 0
|
||||
orderBy := ""
|
||||
sql := "SELECT * FROM t_mail"
|
||||
subFilters := []f5.DbQueryFilter{}
|
||||
mails := []*system.Mail{}
|
||||
f5.GetGoStyleDb().StreamPageQuery(
|
||||
constant.MAIL_DB,
|
||||
pageSize,
|
||||
cursor,
|
||||
sql,
|
||||
[]string{
|
||||
},
|
||||
f5.GetDbFilter().Comp(subFilters...),
|
||||
orderBy,
|
||||
func (err error, pagination *f5.StreamPagination) {
|
||||
//rspObj.Page.FillPage(pagination)
|
||||
},
|
||||
func (ds *f5.DataSet) {
|
||||
p := new(system.Mail)
|
||||
f5.UnmarshalModel(ds, p)
|
||||
q5.AppendSlice(&mails, p)
|
||||
})
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "",
|
||||
@ -26,6 +47,7 @@ func (this *MailApi) ListMail(c *gin.Context) {
|
||||
|
||||
func (this *MailApi) AddMail(c *gin.Context) {
|
||||
reqJson := struct {
|
||||
UniKey string `json:"unikey"`
|
||||
MailType int32 `binding:"required" json:"mailtype"`
|
||||
SendTime int32 `json:"sendtime"`
|
||||
ExpireTime int32 `json:"expiretime"`
|
||||
@ -62,9 +84,13 @@ func (this *MailApi) AddMail(c *gin.Context) {
|
||||
mail.Content = reqJson.Content
|
||||
mail.Attachments = reqJson.Attachments
|
||||
mail.Recipients = reqJson.Recipients
|
||||
mail.Tag1 = jccommon.MAIL_TAG1_CUSTOM
|
||||
mail.Tag2 = jccommon.MAIL_TAG2_CUSTOM_NORMAL
|
||||
mail.CreateTime = nowDaySeconds
|
||||
mail.ModifyTime = nowDaySeconds
|
||||
f5.GetApp().GetOrmDb(constant.MAIL_DB).Create(mail)
|
||||
if f5.GetApp().GetOrmDb(constant.MAIL_DB).Create(mail).Error == nil {
|
||||
|
||||
}
|
||||
{
|
||||
e := new(jccommon.MailEvent)
|
||||
e.EventName = jccommon.EVENT_MAIL_UPDATE
|
||||
|
@ -47,26 +47,6 @@ func (this *app) Update() {
|
||||
}
|
||||
|
||||
func (this *app) registerDataSources() {
|
||||
f5.GetJsStyleDb().RegisterDataSource(
|
||||
constant.GAME_DB,
|
||||
mt.Table.GameDb.GetById(0).GetHost(),
|
||||
mt.Table.GameDb.GetById(0).GetPort(),
|
||||
mt.Table.GameDb.GetById(0).GetUser(),
|
||||
mt.Table.GameDb.GetById(0).GetPasswd(),
|
||||
mt.Table.GameDb.GetById(0).GetDatabase(),
|
||||
1,
|
||||
mt.Table.GameDb.GetById(0).GetMaxOpenConns(),
|
||||
mt.Table.GameDb.GetById(0).GetMaxIdleConns())
|
||||
f5.GetJsStyleDb().RegisterDataSource(
|
||||
constant.FRIEND_DB,
|
||||
mt.Table.FriendDb.GetById(0).GetHost(),
|
||||
mt.Table.FriendDb.GetById(0).GetPort(),
|
||||
mt.Table.FriendDb.GetById(0).GetUser(),
|
||||
mt.Table.FriendDb.GetById(0).GetPasswd(),
|
||||
mt.Table.FriendDb.GetById(0).GetDatabase(),
|
||||
1,
|
||||
mt.Table.FriendDb.GetById(0).GetMaxOpenConns(),
|
||||
mt.Table.FriendDb.GetById(0).GetMaxIdleConns())
|
||||
f5.GetApp().RegisterOrmDb(
|
||||
constant.ADMIN_DB,
|
||||
mt.Table.AdminDb.GetById(0).GetHost(),
|
||||
@ -141,23 +121,6 @@ func (this *app) registerDataSources() {
|
||||
mt.Table.ConfDb.GetById(0).GetMaxIdleConns())
|
||||
}
|
||||
|
||||
func (this *app) AddSession(accountId string) string {
|
||||
/*
|
||||
this.sessionLock.Lock()
|
||||
defer this.sessionLock.Unlock()
|
||||
uuid := f5.GetApp().NewGlobalUuid()
|
||||
str := fmt.Sprintf("%s%d%s%d", accountId, uuid, randStringBytes(12), time.Now().Unix())
|
||||
md5New := md5.New()
|
||||
strByte := []byte(str)
|
||||
md5New.Write(strByte)
|
||||
md5String := hex.EncodeToString(md5New.Sum(nil))
|
||||
token := accountId + "|" + md5String
|
||||
this.sessionHash[accountId] = token
|
||||
return token
|
||||
*/
|
||||
return ""
|
||||
}
|
||||
|
||||
func (this *app) HasTask() bool {
|
||||
return false
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ type Mail struct {
|
||||
SendTime int32 `gorm:"column:sendtime" json:"sendtime"`
|
||||
UserRegStartTime int32 `gorm:"column:user_reg_start_time" json:"user_reg_start_time"`
|
||||
UserRegEndTime int32 `gorm:"column:user_reg_end_time" json:"user_reg_end_time"`
|
||||
Tag1 int32 `gorm:"column:tag1" json:"tag1"`
|
||||
Tag2 int32 `gorm:"column:tag2;" json:"tag2"`
|
||||
ExpireTime int32 `gorm:"column:expiretime" json:"expiretime"`
|
||||
CreateTime int32 `gorm:"column:createtime;<-:create" json:"createtime"`
|
||||
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
|
||||
|
@ -128,7 +128,7 @@ func AddGameLog(accountId string, logType string, subType string,
|
||||
})
|
||||
}
|
||||
|
||||
func UserAddDiamond(accountId string, diamondNum int32, netId int32, tokenId string, reason int32) bool {
|
||||
func UserAddDiamond(accountId string, diamondNum int64, netId int32, orderId string) bool {
|
||||
var oldDiamond float64
|
||||
{
|
||||
f5.GetGoStyleDb().OrmSelectOne(
|
||||
@ -144,8 +144,8 @@ func UserAddDiamond(accountId string, diamondNum int32, netId int32, tokenId str
|
||||
if ds.Next() {
|
||||
oldDiamond = q5.ToFloat64(ds.GetByName("diamond"))
|
||||
AddGameLog(accountId, jccommon.GAME_LOG_TYPE_BACKTASK_USER_ADD_DIAMOND_START,
|
||||
q5.ToString(reason),
|
||||
q5.ToString(netId), tokenId, q5.ToString(oldDiamond), q5.ToString(diamondNum))
|
||||
"",
|
||||
q5.ToString(netId), orderId, q5.ToString(oldDiamond), q5.ToString(diamondNum))
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -181,8 +181,8 @@ func UserAddDiamond(accountId string, diamondNum int32, netId int32, tokenId str
|
||||
if ds.Next() {
|
||||
newDiamond := q5.ToFloat64(ds.GetByName("diamond"))
|
||||
AddGameLog(accountId, jccommon.GAME_LOG_TYPE_BACKTASK_USER_ADD_DIAMOND_END,
|
||||
q5.ToString(reason),
|
||||
q5.ToString(netId), tokenId, q5.ToString(oldDiamond), q5.ToString(newDiamond))
|
||||
"",
|
||||
q5.ToString(netId), orderId, q5.ToString(oldDiamond), q5.ToString(newDiamond))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ import (
|
||||
"q5"
|
||||
"f5"
|
||||
"main/constant"
|
||||
"main/service"
|
||||
"fmt"
|
||||
//"main/mt"
|
||||
//"strings"
|
||||
"jccommon"
|
||||
)
|
||||
|
||||
@ -22,19 +21,20 @@ func (this *recharge) unInit() {
|
||||
|
||||
func (this *recharge) process() {
|
||||
f5.GetGoStyleDb().LoopLoadNew(
|
||||
constant.BCEVENT_DB,
|
||||
"recharge",
|
||||
"t_recharge",
|
||||
constant.BCNFT_DB,
|
||||
"recharge_order",
|
||||
"t_recharge_order",
|
||||
0,
|
||||
func (lastIdx int64, maxIdx int64) (string, []string) {
|
||||
sql := fmt.Sprintf(`
|
||||
SELECT * FROM t_recharge
|
||||
WHERE idx > %d AND idx <= %d AND status = %d
|
||||
SELECT * FROM t_recharge_order
|
||||
WHERE idx > %d AND idx <= %d AND pay_status = %d AND delivery_status = %d
|
||||
ORDER BY idx LIMIT 1000
|
||||
`,
|
||||
lastIdx,
|
||||
maxIdx,
|
||||
jccommon.RECHARGE_STATUS_PENDING)
|
||||
jccommon.RECHARGE_ORDER_PAY_STATUS_OK,
|
||||
jccommon.RECHARGE_ORDER_DELIVERY_STATUS_PENDING)
|
||||
params := []string{
|
||||
}
|
||||
return sql, params
|
||||
@ -43,40 +43,34 @@ ORDER BY idx LIMIT 1000
|
||||
}
|
||||
|
||||
func (this *recharge) deliverGoods(ds *f5.DataSet) bool {
|
||||
var result = false
|
||||
idx := q5.ToInt64(ds.GetByName("idx"))
|
||||
orderId := ds.GetByName("order_id")
|
||||
f5.GetGoStyleDb().OrmSelectOne(
|
||||
constant.GAME_DB,
|
||||
"t_recharge_order",
|
||||
[][]string{
|
||||
{"order_id", orderId},
|
||||
},
|
||||
func (err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
result = false
|
||||
return
|
||||
}
|
||||
idx := q5.ToInt64(ds.GetByName("idx"))
|
||||
status := q5.ToInt32(ds.GetByName("stauts"))
|
||||
if status != 0 {
|
||||
result = this.markStatus(idx, jccommon.RECHARGE_STATUS_SENT) == nil
|
||||
return
|
||||
}
|
||||
result = this.markStatus(idx, jccommon.RECHARGE_STATUS_SENT) == nil
|
||||
})
|
||||
return result
|
||||
passportAddress := ds.GetByName("passport_address")
|
||||
diamond := q5.ToInt64(ds.GetByName("diamond"))
|
||||
netId := q5.ToInt32(ds.GetByName("net_id"))
|
||||
accountId := service.GetAccountIdByAddress(passportAddress)
|
||||
if accountId == "" {
|
||||
return true
|
||||
}
|
||||
if this.markOk(idx, accountId) != nil {
|
||||
return true
|
||||
}
|
||||
service.UserAddDiamond(accountId, diamond, netId, orderId)
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *recharge) markStatus(idx int64, status int32) error {
|
||||
func (this *recharge) markOk(idx int64, deliveryAccountId string) error {
|
||||
var resultErr error
|
||||
f5.GetGoStyleDb().Update(
|
||||
constant.BCEVENT_DB,
|
||||
"t_recharge",
|
||||
constant.BCNFT_DB,
|
||||
"t_recharge_order",
|
||||
[][]string{
|
||||
{"idx", q5.ToString(idx)},
|
||||
},
|
||||
[][]string{
|
||||
{"status", q5.ToString(status)},
|
||||
{"delivery_status", q5.ToString(jccommon.RECHARGE_ORDER_DELIVERY_STATUS_OK)},
|
||||
{"delivery_time", q5.ToString(f5.GetApp().GetRealSeconds())},
|
||||
{"receiver_account_id", deliveryAccountId},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
resultErr = err
|
||||
|
@ -37,11 +37,14 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
MAIL_TAG1_CUSTOM = 1
|
||||
MAIL_TAG1_HERO = 100
|
||||
MAIL_TAG1_GOLD_BULLION = 101
|
||||
)
|
||||
|
||||
const (
|
||||
MAIL_TAG2_CUSTOM_NORMAL = 1
|
||||
|
||||
MAIL_TAG2_HERO_MINT = 1
|
||||
MAIL_TAG2_HERO_LOCK = 2
|
||||
MAIL_TAG2_HERO_UNLOCK = 3
|
||||
@ -105,13 +108,16 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
RECHARGE_ORDER_STATUS_PENDING = 0
|
||||
RECHARGE_ORDER_STATUS_SENT =1
|
||||
RECHARGE_ORDER_PAY_STATUS_PENDING = 0
|
||||
RECHARGE_ORDER_PAY_STATUS_OK = 1
|
||||
|
||||
RECHARGE_ORDER_DELIVERY_STATUS_PENDING =0
|
||||
RECHARGE_ORDER_DELIVERY_STATUS_OK = 1
|
||||
)
|
||||
|
||||
const (
|
||||
RECHARGE_STATUS_PENDING = 0
|
||||
RECHARGE_STATUS_SENT =1
|
||||
RECHARGE_STATUS_SENT = 1
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -84,6 +84,14 @@ func (this *recharge) saveToDb(ds *f5.DataSet) bool {
|
||||
p := new(itemSoldOut)
|
||||
if q5.DecodeJson(returnValues, p) == nil {
|
||||
decodeJsonOk = true
|
||||
orderExists := false
|
||||
if this.updateOrderStatus(txhash, p.OrderId, q5.ToInt32(createTime), &orderExists) != nil {
|
||||
return false
|
||||
}
|
||||
status := 0
|
||||
if orderExists {
|
||||
status = 1
|
||||
}
|
||||
var dbErr error
|
||||
f5.GetGoStyleDb().Upsert(
|
||||
constant.BCEVENT_DB,
|
||||
@ -106,6 +114,7 @@ func (this *recharge) saveToDb(ds *f5.DataSet) bool {
|
||||
{"order_id", p.OrderId},
|
||||
{"currency", p.Currency},
|
||||
{"amount", p.Amount},
|
||||
{"status", q5.ToString(status)},
|
||||
{"createtime", createTime},
|
||||
{"modifytime", modifyTime},
|
||||
},
|
||||
@ -128,3 +137,38 @@ func (this *recharge) saveToDb(ds *f5.DataSet) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *recharge) updateOrderStatus(txhash string, orderId string, payTime int32, orderExists *bool) error {
|
||||
*orderExists = false
|
||||
var resultErr error
|
||||
f5.GetGoStyleDb().OrmSelectOne(
|
||||
constant.BCNFT_DB,
|
||||
"t_recharge_order",
|
||||
[][]string{
|
||||
{"order_id", orderId},
|
||||
},
|
||||
func (err error, ds *f5.DataSet) {
|
||||
resultErr = err
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
*orderExists = ds.Next()
|
||||
})
|
||||
if resultErr == nil && *orderExists {
|
||||
f5.GetGoStyleDb().Update(
|
||||
constant.BCNFT_DB,
|
||||
"t_recharge_order",
|
||||
[][]string{
|
||||
{"order_id", orderId},
|
||||
},
|
||||
[][]string{
|
||||
{"txhash", txhash},
|
||||
{"pay_status", q5.ToString(1)},
|
||||
{"pay_time", q5.ToString(payTime)},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
resultErr = err
|
||||
})
|
||||
}
|
||||
return resultErr
|
||||
}
|
||||
|
@ -128,10 +128,15 @@ func (sa *StackingApi) ContributionQuery(c *gin.Context) {
|
||||
|
||||
func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) {
|
||||
accountAddress := strings.ToLower(c.Param("account_address"))
|
||||
type Record struct {
|
||||
Date int32 `json:"date"`
|
||||
Amount string `json:"amount"`
|
||||
Type int32 `json:"type"`
|
||||
}
|
||||
rspObj := struct {
|
||||
ErrCode int32 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
Rows []interface{} `json:"rows"`
|
||||
ErrCode int32 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
Rows []*Record `json:"rows"`
|
||||
}{}
|
||||
|
||||
{
|
||||
@ -150,20 +155,46 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
obj := struct {
|
||||
Date int32 `json:"date"`
|
||||
Amount string `json:"amount"`
|
||||
Type int32 `json:"type"`
|
||||
}{}
|
||||
|
||||
for ds.Next() {
|
||||
obj := new(Record)
|
||||
|
||||
obj.Date = q5.SafeToInt32(ds.GetByName("createtime"))
|
||||
obj.Amount = ds.GetByName("amount")
|
||||
obj.Type = q5.SafeToInt32(ds.GetByName("type"))
|
||||
obj.Type = 1
|
||||
rspObj.Rows = append(rspObj.Rows, obj)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
sql := `SELECT * FROM t_recharge_order WHERE passport_address = ? AND pay_status = 1 ORDER BY createtime DESC`
|
||||
params := []string{
|
||||
accountAddress,
|
||||
}
|
||||
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.BCNFT_DB,
|
||||
sql,
|
||||
params,
|
||||
func(err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for ds.Next() {
|
||||
obj := new(Record)
|
||||
|
||||
obj.Date = q5.SafeToInt32(ds.GetByName("pay_time"))
|
||||
obj.Amount = ds.GetByName("diamond")
|
||||
obj.Type = 0
|
||||
rspObj.Rows = append(rspObj.Rows, obj)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
q5.Sort(rspObj.Rows, func(a *Record, b *Record) bool {
|
||||
return a.Date > b.Date
|
||||
})
|
||||
|
||||
c.JSON(200, rspObj)
|
||||
}
|
||||
|
@ -42,11 +42,11 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
accountId := c.MustGet("open_id").(string)
|
||||
passportAddress := c.MustGet("account_address").(string)
|
||||
reqJson := struct {
|
||||
NetId int32 `json:"net_id"`
|
||||
GoodsId int32 `json:"goods_id"`
|
||||
Num int32 `json:"num"`
|
||||
AccountAddress string `json:"account_address"`
|
||||
}{}
|
||||
if err := c.ShouldBindJSON(&reqJson); err != nil {
|
||||
@ -104,6 +104,8 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
ErrMsg string `json:"errmsg"`
|
||||
Calls []jccommon.ContractCall `json:"calls"`
|
||||
}{}
|
||||
var itemNum int32 = 1
|
||||
var diamond int64 = 1
|
||||
url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Web3SignCluster.RandElement().GetUrl())
|
||||
f5.GetHttpCliMgr().SendGoStyleRequest(
|
||||
url,
|
||||
@ -122,16 +124,17 @@ func (this *RechargeApi) Buy(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if !service.AddRechargeOrder(
|
||||
accountId,
|
||||
orderId,
|
||||
q5.ToString(shortOrderId),
|
||||
reqJson.NetId,
|
||||
reqJson.AccountAddress,
|
||||
passportAddress,
|
||||
currencyMeta.GetName(),
|
||||
currencyMeta.GetAddress(),
|
||||
goodsMeta.GetId(),
|
||||
1,
|
||||
price) {
|
||||
itemNum,
|
||||
price,
|
||||
diamond) {
|
||||
f5.RspErr(c, 500, "server internal error")
|
||||
return
|
||||
}
|
||||
@ -163,8 +166,8 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
|
||||
cursor := q5.SafeToInt64(reqJson.Cursor)
|
||||
|
||||
sql := fmt.Sprintf(`
|
||||
SELECT * FROM t_recharge
|
||||
WHERE idx > %d AND net_id = %d AND passport = ?`,
|
||||
SELECT * FROM t_recharge_order
|
||||
WHERE idx > %d AND net_id = %d AND passport_address = ? AND pay_status = 1`,
|
||||
cursor, netId)
|
||||
|
||||
params := []string{account}
|
||||
@ -177,19 +180,21 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
|
||||
ErrMsg string `json:"errmsg"`
|
||||
Page common.StreamPagination `json:"page"`
|
||||
Rows []struct {
|
||||
OrderID string `json:"order_id"`
|
||||
TxHash string `json:"txhash"`
|
||||
NetID int64 `json:"net_id"`
|
||||
Currency string `json:"currency"`
|
||||
Amount string `json:"amount"`
|
||||
Diamond string `json:"diamond"`
|
||||
Date int32 `json:"createtime"`
|
||||
OrderID string `json:"order_id"`
|
||||
ShortOrderID string `json:"short_order_id"`
|
||||
TxHash string `json:"txhash"`
|
||||
NetID int64 `json:"net_id"`
|
||||
Currency string `json:"currency"`
|
||||
CurrencyName string `json:"currency_name"`
|
||||
Amount string `json:"amount"`
|
||||
Diamond string `json:"diamond"`
|
||||
Date int32 `json:"createtime"`
|
||||
} `json:"rows"`
|
||||
}{}
|
||||
q5.NewSlice(&rspObj.Rows, 0, 10)
|
||||
|
||||
f5.GetGoStyleDb().StreamPageQuery(
|
||||
constant.BCEVENT_DB,
|
||||
constant.BCNFT_DB,
|
||||
pageSize,
|
||||
cursor,
|
||||
sql,
|
||||
@ -203,10 +208,12 @@ func (ea *RechargeApi) RechargeQuery(c *gin.Context) {
|
||||
p := q5.NewSliceElement(&rspObj.Rows)
|
||||
|
||||
p.TxHash = ds.GetByName("txhash")
|
||||
p.NetID = q5.SafeToInt64(ds.GetByName("net_id"))
|
||||
p.NetID = netId
|
||||
p.OrderID = ds.GetByName("order_id")
|
||||
p.Currency = ds.GetByName("currency")
|
||||
p.Amount = ds.GetByName("amount")
|
||||
p.ShortOrderID = ds.GetByName("short_order_id")
|
||||
p.Currency = ds.GetByName("currency_address")
|
||||
p.CurrencyName = ds.GetByName("currency_name")
|
||||
p.Amount = ds.GetByName("price")
|
||||
p.Diamond = ds.GetByName("diamond")
|
||||
p.Date = q5.SafeToInt32(ds.GetByName("createtime"))
|
||||
})
|
||||
|
@ -98,12 +98,12 @@ func (this *UserApi) Info(c *gin.Context) {
|
||||
}
|
||||
{
|
||||
var dbErr error
|
||||
sql := "SELECT SUM(diamond) FROM t_recharge WHERE passport = ? AND status = 0"
|
||||
sql := "SELECT SUM(diamond) FROM t_recharge_order WHERE passport_address = ? AND pay_status = 1 AND delivery_status = 0;"
|
||||
params := []string{
|
||||
accountAddress,
|
||||
}
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.BCEVENT_DB,
|
||||
constant.BCNFT_DB,
|
||||
sql,
|
||||
params,
|
||||
func(err error, ds *f5.DataSet) {
|
||||
|
@ -6,10 +6,10 @@ import (
|
||||
"main/constant"
|
||||
)
|
||||
|
||||
func AddRechargeOrder(accountId string, orderId string, shortOrderId string,
|
||||
accountAddress string, passportAddress string,
|
||||
currencyAddress string, currencyName string, itemId int32, itemNum int64,
|
||||
price string) bool {
|
||||
func AddRechargeOrder(orderId string, shortOrderId string,
|
||||
netId int32, accountAddress string, passportAddress string,
|
||||
currencyAddress string, currencyName string, itemId int32, itemNum int32,
|
||||
price string, diamond int64) bool {
|
||||
ok := false
|
||||
nowTime := f5.GetApp().GetRealSeconds()
|
||||
f5.GetGoStyleDb().UpsertEx(
|
||||
@ -21,9 +21,9 @@ func AddRechargeOrder(accountId string, orderId string, shortOrderId string,
|
||||
[][]string{
|
||||
},
|
||||
[][]string{
|
||||
{"account_id", accountId},
|
||||
{"order_id", orderId},
|
||||
{"short_order_id", shortOrderId},
|
||||
{"net_id", q5.ToString(netId)},
|
||||
{"account_address", accountAddress},
|
||||
{"passport_address", passportAddress},
|
||||
{"currency_name", currencyName},
|
||||
@ -31,6 +31,7 @@ func AddRechargeOrder(accountId string, orderId string, shortOrderId string,
|
||||
{"item_id", q5.ToString(itemId)},
|
||||
{"item_num", q5.ToString(itemNum)},
|
||||
{"price", price},
|
||||
{"diamond", q5.ToString(diamond)},
|
||||
{"createtime", q5.ToString(nowTime)},
|
||||
{"modifytime", q5.ToString(nowTime)},
|
||||
},
|
||||
|
2
third_party/f5
vendored
2
third_party/f5
vendored
@ -1 +1 @@
|
||||
Subproject commit c3814ee3afc6ef21c0e7683192044571f561009f
|
||||
Subproject commit 26d8a01994efda115ee81d570075f00ebd05eb21
|
Loading…
x
Reference in New Issue
Block a user