...
|
...
|
@@ -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
|
|
|
} |
...
|
...
|
|