|
@@ -113,7 +113,93 @@ func DailySettlementIntegralRelease(engine *xorm.Engine, mid string, isTask bool |
|
|
|
|
|
|
|
|
//cache.Del(PessimismLockKeyForIntegralRelease) |
|
|
//cache.Del(PessimismLockKeyForIntegralRelease) |
|
|
|
|
|
|
|
|
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>绿色积分结束<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") |
|
|
|
|
|
|
|
|
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>积分释放结束<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// DailySettlementIntegralReleaseForInterposition 每日结算“服务收益” |
|
|
|
|
|
func DailySettlementIntegralReleaseForInterposition(engine *xorm.Engine, mid string, isTask bool) (err error) { |
|
|
|
|
|
session := engine.NewSession() |
|
|
|
|
|
defer func() { |
|
|
|
|
|
session.Close() |
|
|
|
|
|
if err := recover(); err != nil { |
|
|
|
|
|
_ = zhios_order_relate_logx.Error(err) |
|
|
|
|
|
} |
|
|
|
|
|
}() |
|
|
|
|
|
session.Begin() |
|
|
|
|
|
now := time.Now() |
|
|
|
|
|
today := now.Format("2006-01-02") |
|
|
|
|
|
|
|
|
|
|
|
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", now.Hour()) |
|
|
|
|
|
if isTask && (now.Hour() > 8) { |
|
|
|
|
|
//TODO::只在凌晨一点 ~ 凌晨 8 点运行 |
|
|
|
|
|
return errors.New("非运行时间") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//1、查找 `integral_release` 基础设置 |
|
|
|
|
|
integralRelease, err := db.IntegralReleaseGetOneByParams(session, map[string]interface{}{ |
|
|
|
|
|
"key": "is_use", |
|
|
|
|
|
"value": 1, |
|
|
|
|
|
}) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
if integralRelease.ReleaseDate != today { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return errors.New("今日“积分释放”未结算") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//2、查询所有 `integral_release_interposition_user_amount` 记录 |
|
|
|
|
|
var users []model.IntegralReleaseInterpositionUserAmount |
|
|
|
|
|
err = session.Where("waite_amount > 0").Find(&users) |
|
|
|
|
|
if integralRelease.ReleaseDate != today { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
for _, user := range users { |
|
|
|
|
|
//查询当前用户今日的积分释放值 |
|
|
|
|
|
var integralReleaseUserWithOrdFlow model.IntegralReleaseUserWithOrdFlow |
|
|
|
|
|
has, err := session.Where("uid =? and release_date =?", user.Uid, today).And("release_green_coin_num > 0").Get(&integralReleaseUserWithOrdFlow) |
|
|
|
|
|
if has == false { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
zhios_order_relate_utils.FilePutContents("find_integral_release_user_with_ord_flow_err", zhios_order_relate_utils.SerializeStr(map[string]interface{}{ |
|
|
|
|
|
"uid": user.Uid, |
|
|
|
|
|
"date": today, |
|
|
|
|
|
"err": err, |
|
|
|
|
|
})) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//发放服务收益 |
|
|
|
|
|
err = DealIntegralReleaseInterpositionUserAmount(session, md.DealIntegralReleaseInterpositionUserAmountReq{ |
|
|
|
|
|
Kind: "sub", |
|
|
|
|
|
Mid: mid, |
|
|
|
|
|
OrdId: "", |
|
|
|
|
|
CoinId: integralRelease.Coin2, |
|
|
|
|
|
Uid: user.Uid, |
|
|
|
|
|
Amount: zhios_order_relate_utils.StrToFloat64(integralReleaseUserWithOrdFlow.ReleaseGreenCoinNum), |
|
|
|
|
|
}) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//3、提交事务 |
|
|
|
|
|
err = session.Commit() |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
_ = session.Rollback() |
|
|
|
|
|
return errors.New("事务提交失败") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
zhios_order_relate_utils.CurlPost("http://zhios-app:5000/api/v1/check_app_over_time", map[string]string{ |
|
|
|
|
|
"mid": mid, |
|
|
|
|
|
"is_close": "0", |
|
|
|
|
|
}, map[string]string{}) |
|
|
|
|
|
|
|
|
|
|
|
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>每日结算-服务收益-结束<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|