正在显示
3 个修改的文件
包含
68 行增加
和
5 行删除
@@ -444,7 +444,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -444,7 +444,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
444 | } else { | 444 | } else { |
445 | dividendsEstimate = &domain.DividendsEstimate{ | 445 | dividendsEstimate = &domain.DividendsEstimate{ |
446 | DividendsEstimateId: 0, | 446 | DividendsEstimateId: 0, |
447 | - DividendsAccountStatus: 0, | 447 | + DividendsAccountStatus: 1, |
448 | DividendsAmount: dividendsAmount, | 448 | DividendsAmount: dividendsAmount, |
449 | DividendsEstimateOrderNumber: "", | 449 | DividendsEstimateOrderNumber: "", |
450 | DividendsEstimateTime: time.Time{}, | 450 | DividendsEstimateTime: time.Time{}, |
@@ -491,9 +491,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -491,9 +491,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
491 | Org: nil, | 491 | Org: nil, |
492 | Company: nil, | 492 | Company: nil, |
493 | Operator: nil, | 493 | Operator: nil, |
494 | - OperateTime: time.Time{}, | 494 | + OperateTime: time.Now(), |
495 | IsCanceled: false, | 495 | IsCanceled: false, |
496 | - CreatedAt: time.Time{}, | 496 | + CreatedAt: time.Now(), |
497 | DeletedAt: time.Time{}, | 497 | DeletedAt: time.Time{}, |
498 | UpdatedAt: time.Time{}, | 498 | UpdatedAt: time.Time{}, |
499 | } | 499 | } |
@@ -509,7 +509,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -509,7 +509,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
509 | dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimateSaved) | 509 | dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimateSaved) |
510 | } | 510 | } |
511 | } | 511 | } |
512 | - | ||
513 | if err := transactionContext.CommitTransaction(); err != nil { | 512 | if err := transactionContext.CommitTransaction(); err != nil { |
514 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 513 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
515 | } | 514 | } |
1 | +package dao | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | ||
8 | + "time" | ||
9 | +) | ||
10 | + | ||
11 | +type DividendsEstimateDao struct { | ||
12 | + transactionContext *pgTransaction.TransactionContext | ||
13 | +} | ||
14 | + | ||
15 | +// GenerateDividendsEstimateNumber 生成分红预算单号 | ||
16 | +func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber() (string, error) { | ||
17 | + tx := dao.transactionContext.PgTx | ||
18 | + var dividendsEstimateModels []*models.DividendsEstimate | ||
19 | + query := tx.Model(÷ndsEstimateModels) | ||
20 | + currentTime := time.Now() | ||
21 | + todayZeroTime := utils.GetZeroTime(currentTime) | ||
22 | + nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) | ||
23 | + query.Where("dividends_estimate.created_at >= ?", todayZeroTime) | ||
24 | + query.Where("dividends_estimate.created_at < ?", nextDayZeroTime) | ||
25 | + if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { | ||
26 | + return "", err | ||
27 | + } else { | ||
28 | + countStr := fmt.Sprintf("%03d", count+1) | ||
29 | + timestamp := currentTime.Unix() | ||
30 | + timeNow := time.Unix(timestamp, 0) | ||
31 | + timeString := timeNow.Format("20060102") | ||
32 | + timeString = timeString[2:len(timeString)] | ||
33 | + dividendsOrderNumber := "FH" + timeString + "#" + countStr | ||
34 | + return dividendsOrderNumber, nil | ||
35 | + } | ||
36 | +} | ||
37 | + | ||
38 | +// CheckDividendsEstimateOrderNumberAvailable 校验分红预算单号是否唯一 | ||
39 | +func (dao *DividendsEstimateDao) CheckDividendsEstimateOrderNumberAvailable(queryOptions map[string]interface{}) (bool, error) { | ||
40 | + tx := dao.transactionContext.PgTx | ||
41 | + var dividendsEstimateModels []*models.DividendsEstimate | ||
42 | + query := tx.Model(÷ndsEstimateModels) | ||
43 | + if dividendsEstimateOrderNumber, ok := queryOptions["dividendsEstimateOrderNumber"]; ok && dividendsEstimateOrderNumber != "" { | ||
44 | + query = query.Where("dividends_estimate_order_number = ?", dividendsEstimateOrderNumber) | ||
45 | + } | ||
46 | + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | ||
47 | + query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId) | ||
48 | + } | ||
49 | + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { | ||
50 | + query = query.Where(`dividends_estimate.org @> '{"orgId":"?"}'`, orgId) | ||
51 | + } | ||
52 | + ok, err := query.Exists() | ||
53 | + return !ok, err | ||
54 | +} | ||
55 | + | ||
56 | +func NewDividendsEstimateDao(transactionContext *pgTransaction.TransactionContext) (*DividendsEstimateDao, error) { | ||
57 | + if transactionContext == nil { | ||
58 | + return nil, fmt.Errorf("transactionContext参数不能为空") | ||
59 | + } else { | ||
60 | + return &DividendsEstimateDao{ | ||
61 | + transactionContext: transactionContext, | ||
62 | + }, nil | ||
63 | + } | ||
64 | +} |
@@ -60,7 +60,7 @@ func (dao *DividendsOrderDao) CalculateDividendsOrderAmount(queryOptions map[str | @@ -60,7 +60,7 @@ func (dao *DividendsOrderDao) CalculateDividendsOrderAmount(queryOptions map[str | ||
60 | 60 | ||
61 | func NewDividendsOrderDao(transactionContext *pgTransaction.TransactionContext) (*DividendsOrderDao, error) { | 61 | func NewDividendsOrderDao(transactionContext *pgTransaction.TransactionContext) (*DividendsOrderDao, error) { |
62 | if transactionContext == nil { | 62 | if transactionContext == nil { |
63 | - return nil, fmt.Errorf("transactionContext参数不能未") | 63 | + return nil, fmt.Errorf("transactionContext参数不能为空") |
64 | } else { | 64 | } else { |
65 | return &DividendsOrderDao{ | 65 | return &DividendsOrderDao{ |
66 | transactionContext: transactionContext, | 66 | transactionContext: transactionContext, |
-
请 注册 或 登录 后发表评论