1、自动续费
This commit is contained in:
@ -13,10 +13,11 @@ func InitJob() {
|
||||
"ExamplesOne": ExamplesOne{},
|
||||
"TrxPaymentJob": TrxPaymentJob{},
|
||||
"CliProxyTrafficsJob": CliProxyJob{},
|
||||
"RenewalJob": RenewalJob{},
|
||||
"ExpireProxyJob": ExpireProxyJob{},
|
||||
"CleanExpiredOrderJob": CleanExpiredOrderJob{},
|
||||
"SmsJob": SmsJob{},
|
||||
"RenewalJob": RenewalJob{}, //长效ip定时续期
|
||||
"ExpireProxyJob": ExpireProxyJob{}, //定时过期代理
|
||||
"CleanExpiredOrderJob": CleanExpiredOrderJob{}, //清理过期订单
|
||||
"SmsJob": SmsJob{}, //短信定时查询验证码
|
||||
"SmsRenewalJob": SmsRenewalJob{}, //短信定时自动续期
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type RenewalJob struct{}
|
||||
type SmsRenewalJob struct{}
|
||||
type ExpireProxyJob struct{}
|
||||
|
||||
// 定时续期任务
|
||||
@ -18,6 +19,15 @@ func (j RenewalJob) Exec(args interface{}) error {
|
||||
return memberRenewalService.AutoRenewal()
|
||||
}
|
||||
|
||||
// 定时短信续期任务
|
||||
func (j SmsRenewalJob) Exec(args interface{}) error {
|
||||
smsService := service.SmsServices{}
|
||||
smsService.Orm = GetDb()
|
||||
smsService.Log = logger.NewHelper(logger.DefaultLogger)
|
||||
|
||||
return smsService.AutoRenewal()
|
||||
}
|
||||
|
||||
// 过期任务
|
||||
func (j ExpireProxyJob) Exec(args interface{}) error {
|
||||
memberRenewalService := service.MemberRenewalLog{}
|
||||
|
||||
19
app/jobs/proxy_job_test.go
Normal file
19
app/jobs/proxy_job_test.go
Normal file
@ -0,0 +1,19 @@
|
||||
package jobs
|
||||
|
||||
import (
|
||||
"go-admin/config"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestProxyJob(t *testing.T) {
|
||||
initSetting()
|
||||
config.ExtConfig.CliproxyUrl = "https://f.cliproxy.com"
|
||||
config.ExtConfig.CliproxyApiUrl = "https://api.cliproxy.com"
|
||||
config.ExtConfig.DaisysmsUrl = "https://daisysms.com/stubs/handler_api.php"
|
||||
|
||||
renewJob := RenewalJob{}
|
||||
|
||||
if err := renewJob.Exec(nil); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
@ -14,3 +14,14 @@ func TestSendSMS(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
// 短信自动续期
|
||||
func TestSmsRenew(t *testing.T) {
|
||||
initSetting()
|
||||
config.ExtConfig.DaisysmsUrl = "https://daisysms.com/stubs/handler_api.php"
|
||||
job := SmsRenewalJob{}
|
||||
|
||||
if err := job.Exec(nil); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user