Merge branch 'feature-octTwo-daiyb' into dev
This commit is contained in:
commit
517ee67733
@ -1,11 +1,13 @@
|
|||||||
## 测试服后台
|
## 测试服后台
|
||||||
http://172.16.100.99:9028/
|
http://121.229.45.214:9028/
|
||||||
13580848136
|
13580848136
|
||||||
|
|
||||||
https://erp.fiee.com/older_list
|
https://erp.fiee.com/older_list
|
||||||
13580848136
|
13580848136
|
||||||
Aa.123456
|
Aa.123456
|
||||||
|
|
||||||
|
17315042007 测试-陆嘉骅2
|
||||||
|
|
||||||
测试h5
|
测试h5
|
||||||
## https://saas-test.szjixun.cn
|
## https://saas-test.szjixun.cn
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,8 @@ AppMode = "dev"
|
|||||||
HttpPort = ":8085"
|
HttpPort = ":8085"
|
||||||
Host = "https://common.szjixun.cn"
|
Host = "https://common.szjixun.cn"
|
||||||
RedirectUri = "/api/redirect/url"
|
RedirectUri = "/api/redirect/url"
|
||||||
ErpHost = "http://114.218.158.24:9020"
|
ErpHost = "http://erpapi.test.fontree.cn:8081"
|
||||||
FieeHost = "http://114.218.158.24:9020"
|
FieeHost = "http://erpapi.test.fontree.cn:8081"
|
||||||
AuthRedirectUrl = "http://121.229.45.214:9028/media_account"
|
AuthRedirectUrl = "http://121.229.45.214:9028/media_account"
|
||||||
CronOpen = false
|
CronOpen = false
|
||||||
[bos]
|
[bos]
|
||||||
|
|||||||
@ -4,8 +4,8 @@ AppMode = "test"
|
|||||||
HttpPort = ":8085"
|
HttpPort = ":8085"
|
||||||
Host = "https://common.szjixun.cn"
|
Host = "https://common.szjixun.cn"
|
||||||
RedirectUri = "/api/redirect/url"
|
RedirectUri = "/api/redirect/url"
|
||||||
ErpHost = "http://114.218.158.24:9020"
|
ErpHost = "http://erpapi.test.fontree.cn:8081"
|
||||||
FieeHost = "http://114.218.158.24:9020"
|
FieeHost = "http://erpapi.test.fontree.cn:8081"
|
||||||
FieeApiHost = "https://saas-test.szjixun.cn"
|
FieeApiHost = "https://saas-test.szjixun.cn"
|
||||||
AuthRedirectUrl = "http://121.229.45.214:9028/media_account"
|
AuthRedirectUrl = "http://121.229.45.214:9028/media_account"
|
||||||
CronOpen = true
|
CronOpen = true
|
||||||
|
|||||||
@ -2,16 +2,24 @@ package cron
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"fonchain-fiee/api/cast"
|
"fonchain-fiee/api/cast"
|
||||||
|
"fonchain-fiee/pkg/cache"
|
||||||
|
modelCast "fonchain-fiee/pkg/model/cast"
|
||||||
"fonchain-fiee/pkg/service"
|
"fonchain-fiee/pkg/service"
|
||||||
serverCast "fonchain-fiee/pkg/service/cast"
|
serverCast "fonchain-fiee/pkg/service/cast"
|
||||||
"log"
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InitTasks 初始化定时任务
|
// InitTasks 初始化定时任务
|
||||||
func InitTasks() error {
|
func InitTasks() error {
|
||||||
cm := GetCronManager()
|
cm := GetCronManager()
|
||||||
err := cm.AddTask("refreshWorkApprovalStatus", "0 */5 * * * *", RefreshWorkApprovalStatusTask)
|
err := cm.AddTask("refreshWorkApprovalStatus", "0 */1 * * * *", RefreshWorkApprovalStatusTask)
|
||||||
|
err = cm.AddTask("artistAutoConfirm", "0 */1 * * * *", ArtistAutoConfirmTask)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("添加测试任务失败: %v", err)
|
log.Printf("添加测试任务失败: %v", err)
|
||||||
}
|
}
|
||||||
@ -34,3 +42,24 @@ func RefreshWorkApprovalStatusTask() {
|
|||||||
}
|
}
|
||||||
serverCast.RefreshWorkApproval(nil, resp.Data)
|
serverCast.RefreshWorkApproval(nil, resp.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ArtistAutoConfirmTask() {
|
||||||
|
now := float64(time.Now().Unix())
|
||||||
|
opt := redis.ZRangeBy{
|
||||||
|
Min: fmt.Sprintf("%d", 0),
|
||||||
|
Max: fmt.Sprintf("%f", now),
|
||||||
|
}
|
||||||
|
workUuids, err := cache.RedisClient.ZRangeByScore(modelCast.AutoConfirmQueueKey, opt).Result()
|
||||||
|
if err != nil {
|
||||||
|
zap.L().Error("获取到期任务失败", zap.Error(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(workUuids) == 0 {
|
||||||
|
zap.L().Debug("没有到期的任务")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
zap.L().Info("发现到期任务", zap.Int("count", len(workUuids)))
|
||||||
|
for _, workUuid := range workUuids {
|
||||||
|
serverCast.ProcessTask(context.Background(), workUuid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -10,6 +10,11 @@ const (
|
|||||||
WorkStatusPublishFailed = 7 // 发布失败
|
WorkStatusPublishFailed = 7 // 发布失败
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
AutoConfirmQueueKey = "auto_confirm:queue"
|
||||||
|
AutoConfirmLockKey = "auto_confirm:lock:%s"
|
||||||
|
)
|
||||||
|
|
||||||
var WorkCategoryMM = map[int]string{
|
var WorkCategoryMM = map[int]string{
|
||||||
1: "图文",
|
1: "图文",
|
||||||
2: "视频",
|
2: "视频",
|
||||||
|
|||||||
@ -66,7 +66,6 @@ func UnbindManager(ctx *gin.Context) {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
service.Error(ctx, err)
|
service.Error(ctx, err)
|
||||||
//FIXME 进行回滚
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import (
|
|||||||
"fonchain-fiee/api/bundle"
|
"fonchain-fiee/api/bundle"
|
||||||
"fonchain-fiee/api/cast"
|
"fonchain-fiee/api/cast"
|
||||||
"fonchain-fiee/cmd/config"
|
"fonchain-fiee/cmd/config"
|
||||||
|
"fonchain-fiee/pkg/cache"
|
||||||
"fonchain-fiee/pkg/e"
|
"fonchain-fiee/pkg/e"
|
||||||
logicCast "fonchain-fiee/pkg/logic/cast"
|
logicCast "fonchain-fiee/pkg/logic/cast"
|
||||||
modelCast "fonchain-fiee/pkg/model/cast"
|
modelCast "fonchain-fiee/pkg/model/cast"
|
||||||
@ -16,6 +17,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"dubbo.apache.org/dubbo-go/v3/common/constant"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
@ -513,3 +515,107 @@ func WorkListExport(ctx *gin.Context) {
|
|||||||
ctx.Header("Access-Control-Expose-Headers", "File-Name")
|
ctx.Header("Access-Control-Expose-Headers", "File-Name")
|
||||||
_ = excelFile.Write(ctx.Writer)
|
_ = excelFile.Write(ctx.Writer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ProcessTask(ctx context.Context, workUuid string) {
|
||||||
|
lockKey := fmt.Sprintf(modelCast.AutoConfirmLockKey, workUuid)
|
||||||
|
reply := cache.RedisClient.SetNX(lockKey, "1", 5*time.Minute)
|
||||||
|
if !reply.Val() {
|
||||||
|
zap.L().Warn("任务正在被其他实例处理", zap.String("workUuid", workUuid))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
cache.RedisClient.Del(lockKey)
|
||||||
|
}()
|
||||||
|
err := autoConfirm(ctx, workUuid)
|
||||||
|
if err != nil {
|
||||||
|
zap.L().Error("自动确认失败",
|
||||||
|
zap.String("approvalId", workUuid),
|
||||||
|
zap.Error(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从队列中移除
|
||||||
|
args := make([]interface{}, len(workUuid))
|
||||||
|
for i, m := range workUuid {
|
||||||
|
args[i] = m
|
||||||
|
}
|
||||||
|
err = cache.RedisClient.ZRem(modelCast.AutoConfirmQueueKey, args...).Err()
|
||||||
|
if err != nil {
|
||||||
|
zap.L().Error("从队列移除任务失败",
|
||||||
|
zap.String("workUuid", workUuid),
|
||||||
|
zap.Error(err))
|
||||||
|
}
|
||||||
|
zap.L().Info("自动确认成功", zap.String("workUuid", workUuid))
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConfirm(ctx context.Context, workUuid string) (err error) {
|
||||||
|
infoResp, err := service.CastProvider.WorkInfo(context.Background(), &cast.WorkInfoReq{
|
||||||
|
WorkUuid: workUuid,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
zap.L().Error("autoConfirm WorkInfo", zap.Any("err", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println("autoConfirm WorkInfo", infoResp)
|
||||||
|
/*userID, _ := strconv.ParseInt(infoResp.ArtistUuid, 10, 64)
|
||||||
|
balanceInfoRes, err := service.BundleProvider.GetBundleBalanceByUserId(context.Background(), &bundle.GetBundleBalanceByUserIdReq{
|
||||||
|
UserId: int32(userID),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
zap.L().Error("autoConfirm GetBundleBalanceByUserId", zap.Any("err", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if infoResp.WorkStatus != 4 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var workCategory = infoResp.WorkCategory
|
||||||
|
var addBalanceReq bundle.AddBundleBalanceReq
|
||||||
|
addBalanceReq.UserId = int32(userID)
|
||||||
|
switch workCategory {
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
if balanceInfoRes.ImageConsumptionNumber >= balanceInfoRes.ImageNumber { // 图文余量不足
|
||||||
|
err = errors.New("图文余量不足")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
addBalanceReq.ImageConsumptionNumber = 1
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
if balanceInfoRes.VideoConsumptionNumber >= balanceInfoRes.VideoNumber { // 视频余量不足
|
||||||
|
err = errors.New("视频余量不足")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
addBalanceReq.VideoConsumptionNumber = 1
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
err = errors.New("不支持的类型")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
zap.L().Info("autoConfirm AddBundleBalanceReq", zap.Any("addBalanceReq", &addBalanceReq))
|
||||||
|
resp, err := service.BundleProvider.AddBundleBalance(context.Background(), &addBalanceReq)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}*/
|
||||||
|
resp := &bundle.AddBundleBalanceResp{
|
||||||
|
UsedType: 2,
|
||||||
|
}
|
||||||
|
zap.L().Info("autoConfirm AddBundleBalanceResp", zap.Any("resp", resp))
|
||||||
|
var mm = make(map[string]interface{}, 3)
|
||||||
|
mm["userid"] = 0
|
||||||
|
mm["name"] = "系统自动确定"
|
||||||
|
mm["phone"] = ""
|
||||||
|
newCtx := context.WithValue(context.Background(), constant.DubboCtxKey("attachment"), mm)
|
||||||
|
_, err = service.CastProvider.UpdateStatus(newCtx, &cast.UpdateStatusReq{
|
||||||
|
WorkAction: cast.WorkActionENUM_CONFIRM,
|
||||||
|
WorkUuid: workUuid,
|
||||||
|
ConfirmRemark: "系统自动确认",
|
||||||
|
CostType: resp.UsedType,
|
||||||
|
ConfirmStatus: 1,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user