作者 唐旭辉

错误修复

... ... @@ -44,6 +44,11 @@ func (srv BusinessBonusService) ListBusinessBonus(queryOption query.ListBusiness
if err != nil {
return 0, nil, err
}
cnt, err := bonusDaoao.CountBusinessBonus(queryOption.PartnerId, queryOption.PartnerNameMatch,
queryOption.CompanyId, queryOption.Limit, queryOption.Offset)
if err != nil {
return 0, nil, err
}
err = transactionContext.CommitTransaction()
returnData := []map[string]interface{}{}
... ... @@ -60,7 +65,7 @@ func (srv BusinessBonusService) ListBusinessBonus(queryOption query.ListBusiness
}
returnData = append(returnData, m)
}
return 0, returnData, nil
return cnt, returnData, nil
}
func (srv BusinessBonusService) UpdateBusinessBonus(cmd command.UpdateBusinessBonusCommand) error {
... ...
... ... @@ -40,7 +40,7 @@ func (dao BusinessBonusDao) SearchBusinessBonus(partnerId int64, partnerNameMatc
,partner_info.partner_name,business_bonus.bonus_has
FROM business_bonus
JOIN partner_info ON business_bonus.partner_info_id=partner_info.id
WHERE business_bonus.company_id = ? `
WHERE business_bonus.is_disable=0 AND business_bonus.company_id = ? `
partnerCondition := []string{}
allParam := []interface{}{companyId}
if partnerId > 0 {
... ... @@ -64,3 +64,30 @@ func (dao BusinessBonusDao) SearchBusinessBonus(partnerId int64, partnerNameMatc
_, err = tx.Query(&result, sql, allParam...)
return result, err
}
func (dao BusinessBonusDao) CountBusinessBonus(partnerId int64, partnerNameMatch string,
companyId int64, limit int, offset int) (int, error) {
sql := `SELECT count(*)
JOIN partner_info ON business_bonus.partner_info_id=partner_info.id
WHERE business_bonus.is_disable=0 AND business_bonus.company_id = ? `
partnerCondition := []string{}
allParam := []interface{}{companyId}
if partnerId > 0 {
partnerCondition = append(partnerCondition, ` business_bonus.partner_info_id=? `)
allParam = append(allParam, partnerId)
}
if len(partnerNameMatch) > 0 {
allParam = append(allParam, "%"+partnerNameMatch+"%")
partnerCondition = append(partnerCondition, ` partner_info.partner_name like ? `)
}
if len(partnerCondition) > 0 {
sql += fmt.Sprintf(" AND (%s)", strings.Join(partnerCondition, " OR "))
}
tx := dao.transactionContext.PgTx
var (
result int
err error
)
_, err = tx.Query(&result, sql, allParam...)
return result, err
}
... ...
... ... @@ -42,14 +42,14 @@ func (c *BusinessBonusController) ListBusinessBonus() {
}
companyId := c.GetUserCompany()
srv := businessService.NewBusinessBonusService(nil)
_, result, err := srv.ListBusinessBonus(businessQuery.ListBusinessBonusQuery{
cnt, result, err := srv.ListBusinessBonus(businessQuery.ListBusinessBonusQuery{
CompanyId: companyId,
})
if err != nil {
c.ResponseError(err)
return
}
c.ResponsePageList(result, 0, param.PageNumber)
c.ResponsePageList(result, cnt, param.PageNumber)
}
func (c *BusinessBonusController) UpdateBusinessBonus() {
... ...