diff --git a/api/bundle/bundle.pb.go b/api/bundle/bundle.pb.go index edc3bf5..5efbcc3 100644 --- a/api/bundle/bundle.pb.go +++ b/api/bundle/bundle.pb.go @@ -8763,9 +8763,9 @@ type GetBundleBalanceByUserIdResp struct { unknownFields protoimpl.UnknownFields OrderUUID string `protobuf:"bytes,1,opt,name=orderUUID,proto3" json:"orderUUID"` - BundleUuid string `protobuf:"bytes,2,opt,name=bundleUuid,proto3" json:"bundleUuid"` // 套餐ID uuid - BundleName string `protobuf:"bytes,3,opt,name=bundleName,proto3" json:"bundleName"` // 套餐名称 - BundleStatus string `protobuf:"bytes,4,opt,name=bundleStatus,proto3" json:"bundleStatus"` // 套餐名称 + BundleUuid string `protobuf:"bytes,2,opt,name=bundleUuid,proto3" json:"bundleUuid"` // 套餐ID uuid + BundleName string `protobuf:"bytes,3,opt,name=bundleName,proto3" json:"bundleName"` // 套餐名称 + BundleStatus int32 `protobuf:"varint,4,opt,name=bundleStatus,proto3" json:"bundleStatus"` // 套餐状态是否过期 1 是 0 否 PayTime int64 `protobuf:"varint,5,opt,name=payTime,proto3" json:"payTime"` ExpiredTime int64 `protobuf:"varint,6,opt,name=expiredTime,proto3" json:"expiredTime"` PaymentAmount string `protobuf:"bytes,7,opt,name=paymentAmount,proto3" json:"paymentAmount"` @@ -8845,11 +8845,11 @@ func (x *GetBundleBalanceByUserIdResp) GetBundleName() string { return "" } -func (x *GetBundleBalanceByUserIdResp) GetBundleStatus() string { +func (x *GetBundleBalanceByUserIdResp) GetBundleStatus() int32 { if x != nil { return x.BundleStatus } - return "" + return 0 } func (x *GetBundleBalanceByUserIdResp) GetPayTime() int64 { @@ -16917,7 +16917,7 @@ var file_pb_bundle_proto_rawDesc = []byte{ 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x55, 0x75, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x75, 0x6e, - 0x64, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x64, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x70, 0x61, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x78, 0x70, 0x69, 0x72, diff --git a/pkg/cron/task.go b/pkg/cron/task.go index f443391..dc591b4 100644 --- a/pkg/cron/task.go +++ b/pkg/cron/task.go @@ -11,6 +11,7 @@ import ( bundleModel "fonchain-fiee/pkg/model/bundle" modelCast "fonchain-fiee/pkg/model/cast" "fonchain-fiee/pkg/service" + "fonchain-fiee/pkg/service/bundle/common" serverCast "fonchain-fiee/pkg/service/cast" "log" "math/rand" @@ -135,6 +136,17 @@ func AutoManuallyConfirmWorkTask() { continue } + if balanceInfoRes.BundleStatus == common.BundleExpired { + _, err = service.CastProvider.UpdateStatus(context.Background(), &cast.UpdateStatusReq{ + WorkAction: cast.WorkActionENUM_CONFIRM, + WorkUuid: req.WorkUuid, + ConfirmRemark: req.ConfirmRemark, + ConfirmStatus: 3, + }) + log.Printf("套餐已过期,作品uuid:"+req.WorkUuid, zap.Error(err)) + continue + } + wordInfoRes, err := service.CastProvider.WorkDetail(context.Background(), &cast.WorkDetailReq{ WorkUuid: req.WorkUuid, }) diff --git a/pkg/service/bundle/bundleBalance.go b/pkg/service/bundle/bundleBalance.go index f64e7f9..a9fef08 100644 --- a/pkg/service/bundle/bundleBalance.go +++ b/pkg/service/bundle/bundleBalance.go @@ -190,6 +190,21 @@ func WorkConfirm(c *gin.Context) { // 确认作品并扣除余量 service.Error(c, errors.New(common.GetUserBalanceFailed)) return } + //判断套餐是否过期 + if balanceInfoRes.BundleStatus == common.BundleExpired { + _, err = service.CastProvider.UpdateStatus(c, &cast.UpdateStatusReq{ + WorkAction: cast.WorkActionENUM_CONFIRM, + WorkUuid: req.WorkUuid, + ConfirmRemark: req.ConfirmRemark, + ConfirmStatus: 3, + }) + if err != nil { + service.Error(c, errors.New(common.UpdateWorkStatusFailed)) + return + } + service.Error(c, errors.New("套餐已过期")) + return + } wordInfoRes, err := service.CastProvider.WorkDetail(c, &cast.WorkDetailReq{ WorkUuid: req.WorkUuid, @@ -210,6 +225,16 @@ func WorkConfirm(c *gin.Context) { // 确认作品并扣除余量 case 1: { if balanceInfoRes.ImageExtendConsumptionNumber >= balanceInfoRes.ImageExtendNumber { // 图文余量不足 + _, err = service.CastProvider.UpdateStatus(context.Background(), &cast.UpdateStatusReq{ + WorkAction: cast.WorkActionENUM_CONFIRM, + WorkUuid: req.WorkUuid, + ConfirmRemark: req.ConfirmRemark, + ConfirmStatus: 3, + }) + if err != nil { + service.Error(c, errors.New(common.UpdateWorkStatusFailed)) + return + } service.Error(c, errors.New("图文余量不足")) return } @@ -218,6 +243,16 @@ func WorkConfirm(c *gin.Context) { // 确认作品并扣除余量 case 2: { if balanceInfoRes.VideoExtendConsumptionNumber >= balanceInfoRes.VideoExtendNumber { // 视频余量不足 + _, err = service.CastProvider.UpdateStatus(context.Background(), &cast.UpdateStatusReq{ + WorkAction: cast.WorkActionENUM_CONFIRM, + WorkUuid: req.WorkUuid, + ConfirmRemark: req.ConfirmRemark, + ConfirmStatus: 3, + }) + if err != nil { + service.Error(c, errors.New(common.UpdateWorkStatusFailed)) + return + } service.Error(c, errors.New("视频余量不足")) return } diff --git a/pkg/service/bundle/common/msg.go b/pkg/service/bundle/common/msg.go index 2bc6eea..f29e84b 100644 --- a/pkg/service/bundle/common/msg.go +++ b/pkg/service/bundle/common/msg.go @@ -122,6 +122,11 @@ const ( InsufficientBalance = "余量不足" ) +const ( + BundleExpired = 1 + BundleNotExpired = 0 +) + //数据指标 const ( MetricsBusinessFailed = "业务概览查询失败"