|
|
@@ -6,12 +6,10 @@ import (
|
|
|
"io"
|
|
|
"time"
|
|
|
|
|
|
- "github.com/astaxie/beego"
|
|
|
- "github.com/astaxie/beego/orm"
|
|
|
-
|
|
|
"fohow.com/apps/models/balance_model"
|
|
|
"fohow.com/apps/models/user_model"
|
|
|
"fohow.com/libs/wx_mp"
|
|
|
+ "github.com/astaxie/beego"
|
|
|
)
|
|
|
|
|
|
type SyncData struct {
|
|
|
@@ -28,34 +26,6 @@ func (self *SyncData) Sign() string {
|
|
|
return fmt.Sprintf("%x", h.Sum(nil))
|
|
|
}
|
|
|
|
|
|
-// 定期同步红包数据到第五创主数据库
|
|
|
-func syncBalance() {
|
|
|
- beego.BeeLogger.Warn("********** Cron task - handle syncBalance start at: %s********", time.Now())
|
|
|
- // 找出50条未同步的记录
|
|
|
- // 逐条同步,并标记成功记录
|
|
|
- o := orm.NewOrm()
|
|
|
-
|
|
|
- var rs []SyncData
|
|
|
-
|
|
|
- sql := "SELECT `chunjie_lucky_moneys`.`id` AS id, `wx_uid`, `receive_bonus`, `chunjie_lucky_moneys`.`created_at`, `unionid` FROM `chunjie_lucky_moneys` inner join `wx_users` on `chunjie_lucky_moneys`.`wx_uid`=`wx_users`.`id` WHERE `is_sync25`<>1 AND `wx_users`.`unionid`<>'' order by `is_sync25` ASC LIMIT 300 ;"
|
|
|
- num, err := o.Raw(sql).QueryRows(&rs)
|
|
|
- if err == nil {
|
|
|
- fmt.Println("user nums: ", num)
|
|
|
- }
|
|
|
- for _, syncData := range rs {
|
|
|
- beego.BeeLogger.Info("********** Cron task - handle syncBalance RecordID=[%d] ********", syncData)
|
|
|
- if result := syncOne(syncData); result {
|
|
|
- // update chunjie_lucky_moneys set is_sync25=1
|
|
|
- o.Raw("UPDATE `chunjie_lucky_moneys` SET `is_sync25` = 1 WHERE id=?", syncData.RecordID).Exec()
|
|
|
- beego.BeeLogger.Info("********** Cron task - handle syncBalance Success: ********", syncData)
|
|
|
- } else {
|
|
|
- o.Raw("UPDATE `chunjie_lucky_moneys` SET `is_sync25` = 2 WHERE id=?", syncData.RecordID).Exec()
|
|
|
- beego.BeeLogger.Error("********** Cron task - handle syncBalance Fail: ********", syncData)
|
|
|
- }
|
|
|
- }
|
|
|
- beego.BeeLogger.Warn("********** Cron task - handle syncBalance end at: %s********", time.Now())
|
|
|
-}
|
|
|
-
|
|
|
//提现打款的定时任务
|
|
|
func takeCash() {
|
|
|
//选择出已审批通过的提现中订单
|