|
@@ -3,6 +3,7 @@ package roadshow
|
|
|
import (
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "hongze/hz_crm_api/utils"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -19,6 +20,10 @@ type AddActivitySellerReq struct {
|
|
|
EnglishCompany int `description:"是否为英文客户"`
|
|
|
}
|
|
|
|
|
|
+type RsActivityIdReq struct {
|
|
|
+ RsActivityId int `description:"活动id"`
|
|
|
+}
|
|
|
+
|
|
|
type ActivitySellerReq struct {
|
|
|
SellerId int `description:"销售id"`
|
|
|
SellerName string `description:"销售名称"`
|
|
@@ -77,16 +82,18 @@ func AddRsActivitySeller(item *RsActivitySeller) (lastId int64, err error) {
|
|
|
|
|
|
type RsActivitySellerResp struct {
|
|
|
RsActivitySellerId int `orm:"column(rs_activity_seller_id);pk"`
|
|
|
+ CompanyId int `description:"客户id"`
|
|
|
+ CompanyName string `description:"客户名称"`
|
|
|
RsActivityId int `description:"活动id"`
|
|
|
- SellerId int `description:"销售id"`
|
|
|
- SellerName string `description:"销售id"`
|
|
|
+ SellerName string `description:"销售姓名"`
|
|
|
StartDate string `description:"开始日期"`
|
|
|
EndDate string `description:"结束日期"`
|
|
|
StartTime string `description:"开始时间"`
|
|
|
EndTime string `description:"结束时间"`
|
|
|
StartWeek string `description:"开始日期对应周"`
|
|
|
EndWeek string `description:"结束日期对应周"`
|
|
|
- CreateTime string
|
|
|
+ Theme string `description:"会议主题"`
|
|
|
+ CreateTime string `description:"创建时间"`
|
|
|
}
|
|
|
|
|
|
type RsActivitySellerListResp struct {
|
|
@@ -109,24 +116,57 @@ func GetRsActivitySellerList(condition string, pars []interface{}, startSize, pa
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- sql += ` ORDER BY b.create_time ASC LIMIT ?,? `
|
|
|
+ sql += ` GROUP BY a.rs_activity_id ORDER BY b.create_time DESC LIMIT ?,? `
|
|
|
o := orm.NewOrm()
|
|
|
_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetRsActivitySellerListCount(condition string, pars []interface{}) (count int, err error) {
|
|
|
+// 根据活动ID获取销售列表
|
|
|
+func GetRsActivitySellerListByActivityIds(rsActivityIds []int) (items []*RsActivitySeller, err error) {
|
|
|
+ lenArr := len(rsActivityIds)
|
|
|
+ if lenArr == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT
|
|
|
- COUNT(1) AS count
|
|
|
+ *
|
|
|
FROM
|
|
|
rs_activity_seller AS a
|
|
|
- INNER JOIN rs_activity AS b ON a.rs_activity_id = b.rs_activity_id
|
|
|
WHERE
|
|
|
- 1 = 1 `
|
|
|
- if condition != "" {
|
|
|
- sql += condition
|
|
|
- }
|
|
|
+ 1 = 1 AND rs_activity_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
|
|
|
+ _, err = o.Raw(sql, rsActivityIds).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func GetRsActivitySellerListCount(condition string, pars []interface{}) (count int, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `SELECT
|
|
|
+ COUNT( * ) as count
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ COUNT( * )
|
|
|
+ FROM
|
|
|
+ rs_activity AS b
|
|
|
+ INNER JOIN rs_activity_seller AS a ON a.rs_activity_id = b.rs_activity_id
|
|
|
+ WHERE
|
|
|
+ 1 = 1 ` + condition + ` GROUP BY a.rs_activity_id ) b `
|
|
|
err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// 删除
|
|
|
+func DeleteRsActivitySeller(rsActivityId int) (err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := ` UPDATE rs_activity_seller SET status=4 WHERE rs_activity_id = ? `
|
|
|
+ _, err = o.Raw(sql, rsActivityId).Exec()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func GetRsActivityByRsActivityId(rsActivityId int) (item *RsActivity, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `SELECT * FROM rs_activity WHERE rs_activity_id=? `
|
|
|
+ err = o.Raw(sql, rsActivityId).QueryRow(&item)
|
|
|
+ return
|
|
|
+}
|