80 lines
1.8 KiB
Go
80 lines
1.8 KiB
Go
package task
|
|
|
|
import (
|
|
"q5"
|
|
"f5"
|
|
"main/constant"
|
|
"main/service"
|
|
"fmt"
|
|
"jccommon"
|
|
)
|
|
|
|
type recharge struct {
|
|
}
|
|
|
|
func (this *recharge) init() {
|
|
go this.process()
|
|
}
|
|
|
|
func (this *recharge) unInit() {
|
|
}
|
|
|
|
func (this *recharge) process() {
|
|
f5.GetGoStyleDb().LoopLoadNew(
|
|
constant.BCNFT_DB,
|
|
"recharge_order",
|
|
"t_recharge_order",
|
|
0,
|
|
func (lastIdx int64, maxIdx int64) (string, []string) {
|
|
sql := fmt.Sprintf(`
|
|
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_ORDER_PAY_STATUS_OK,
|
|
jccommon.RECHARGE_ORDER_DELIVERY_STATUS_PENDING)
|
|
params := []string{
|
|
}
|
|
return sql, params
|
|
},
|
|
this.deliverGoods)
|
|
}
|
|
|
|
func (this *recharge) deliverGoods(ds *f5.DataSet) bool {
|
|
idx := q5.ToInt64(ds.GetByName("idx"))
|
|
orderId := ds.GetByName("order_id")
|
|
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) markOk(idx int64, deliveryAccountId string) error {
|
|
var resultErr error
|
|
f5.GetGoStyleDb().Update(
|
|
constant.BCNFT_DB,
|
|
"t_recharge_order",
|
|
[][]string{
|
|
{"idx", q5.ToString(idx)},
|
|
},
|
|
[][]string{
|
|
{"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
|
|
})
|
|
return resultErr
|
|
}
|