正在显示
3 个修改的文件
包含
36 行增加
和
4 行删除
@@ -44,6 +44,11 @@ func (srv BusinessBonusService) ListBusinessBonus(queryOption query.ListBusiness | @@ -44,6 +44,11 @@ func (srv BusinessBonusService) ListBusinessBonus(queryOption query.ListBusiness | ||
44 | if err != nil { | 44 | if err != nil { |
45 | return 0, nil, err | 45 | return 0, nil, err |
46 | } | 46 | } |
47 | + cnt, err := bonusDaoao.CountBusinessBonus(queryOption.PartnerId, queryOption.PartnerNameMatch, | ||
48 | + queryOption.CompanyId, queryOption.Limit, queryOption.Offset) | ||
49 | + if err != nil { | ||
50 | + return 0, nil, err | ||
51 | + } | ||
47 | err = transactionContext.CommitTransaction() | 52 | err = transactionContext.CommitTransaction() |
48 | 53 | ||
49 | returnData := []map[string]interface{}{} | 54 | returnData := []map[string]interface{}{} |
@@ -60,7 +65,7 @@ func (srv BusinessBonusService) ListBusinessBonus(queryOption query.ListBusiness | @@ -60,7 +65,7 @@ func (srv BusinessBonusService) ListBusinessBonus(queryOption query.ListBusiness | ||
60 | } | 65 | } |
61 | returnData = append(returnData, m) | 66 | returnData = append(returnData, m) |
62 | } | 67 | } |
63 | - return 0, returnData, nil | 68 | + return cnt, returnData, nil |
64 | } | 69 | } |
65 | 70 | ||
66 | func (srv BusinessBonusService) UpdateBusinessBonus(cmd command.UpdateBusinessBonusCommand) error { | 71 | func (srv BusinessBonusService) UpdateBusinessBonus(cmd command.UpdateBusinessBonusCommand) error { |
@@ -40,7 +40,7 @@ func (dao BusinessBonusDao) SearchBusinessBonus(partnerId int64, partnerNameMatc | @@ -40,7 +40,7 @@ func (dao BusinessBonusDao) SearchBusinessBonus(partnerId int64, partnerNameMatc | ||
40 | ,partner_info.partner_name,business_bonus.bonus_has | 40 | ,partner_info.partner_name,business_bonus.bonus_has |
41 | FROM business_bonus | 41 | FROM business_bonus |
42 | JOIN partner_info ON business_bonus.partner_info_id=partner_info.id | 42 | JOIN partner_info ON business_bonus.partner_info_id=partner_info.id |
43 | - WHERE business_bonus.company_id = ? ` | 43 | + WHERE business_bonus.is_disable=0 AND business_bonus.company_id = ? ` |
44 | partnerCondition := []string{} | 44 | partnerCondition := []string{} |
45 | allParam := []interface{}{companyId} | 45 | allParam := []interface{}{companyId} |
46 | if partnerId > 0 { | 46 | if partnerId > 0 { |
@@ -64,3 +64,30 @@ func (dao BusinessBonusDao) SearchBusinessBonus(partnerId int64, partnerNameMatc | @@ -64,3 +64,30 @@ func (dao BusinessBonusDao) SearchBusinessBonus(partnerId int64, partnerNameMatc | ||
64 | _, err = tx.Query(&result, sql, allParam...) | 64 | _, err = tx.Query(&result, sql, allParam...) |
65 | return result, err | 65 | return result, err |
66 | } | 66 | } |
67 | + | ||
68 | +func (dao BusinessBonusDao) CountBusinessBonus(partnerId int64, partnerNameMatch string, | ||
69 | + companyId int64, limit int, offset int) (int, error) { | ||
70 | + sql := `SELECT count(*) | ||
71 | + JOIN partner_info ON business_bonus.partner_info_id=partner_info.id | ||
72 | + WHERE business_bonus.is_disable=0 AND business_bonus.company_id = ? ` | ||
73 | + partnerCondition := []string{} | ||
74 | + allParam := []interface{}{companyId} | ||
75 | + if partnerId > 0 { | ||
76 | + partnerCondition = append(partnerCondition, ` business_bonus.partner_info_id=? `) | ||
77 | + allParam = append(allParam, partnerId) | ||
78 | + } | ||
79 | + if len(partnerNameMatch) > 0 { | ||
80 | + allParam = append(allParam, "%"+partnerNameMatch+"%") | ||
81 | + partnerCondition = append(partnerCondition, ` partner_info.partner_name like ? `) | ||
82 | + } | ||
83 | + if len(partnerCondition) > 0 { | ||
84 | + sql += fmt.Sprintf(" AND (%s)", strings.Join(partnerCondition, " OR ")) | ||
85 | + } | ||
86 | + tx := dao.transactionContext.PgTx | ||
87 | + var ( | ||
88 | + result int | ||
89 | + err error | ||
90 | + ) | ||
91 | + _, err = tx.Query(&result, sql, allParam...) | ||
92 | + return result, err | ||
93 | +} |
@@ -42,14 +42,14 @@ func (c *BusinessBonusController) ListBusinessBonus() { | @@ -42,14 +42,14 @@ func (c *BusinessBonusController) ListBusinessBonus() { | ||
42 | } | 42 | } |
43 | companyId := c.GetUserCompany() | 43 | companyId := c.GetUserCompany() |
44 | srv := businessService.NewBusinessBonusService(nil) | 44 | srv := businessService.NewBusinessBonusService(nil) |
45 | - _, result, err := srv.ListBusinessBonus(businessQuery.ListBusinessBonusQuery{ | 45 | + cnt, result, err := srv.ListBusinessBonus(businessQuery.ListBusinessBonusQuery{ |
46 | CompanyId: companyId, | 46 | CompanyId: companyId, |
47 | }) | 47 | }) |
48 | if err != nil { | 48 | if err != nil { |
49 | c.ResponseError(err) | 49 | c.ResponseError(err) |
50 | return | 50 | return |
51 | } | 51 | } |
52 | - c.ResponsePageList(result, 0, param.PageNumber) | 52 | + c.ResponsePageList(result, cnt, param.PageNumber) |
53 | } | 53 | } |
54 | 54 | ||
55 | func (c *BusinessBonusController) UpdateBusinessBonus() { | 55 | func (c *BusinessBonusController) UpdateBusinessBonus() { |
-
请 注册 或 登录 后发表评论