aa
This commit is contained in:
@@ -2087,3 +2087,11 @@ func RrefreshEbaiVendorAct() (err error) {
|
||||
task.GetResult(0)
|
||||
return err
|
||||
}
|
||||
|
||||
func GetActMtwmVendor(ctx *jxcontext.Context, storeIDs, skuIDs []int, keyword, beginAt, endAt string, actType, offset, pageSize int) (page *model.PagedInfo, err error) {
|
||||
return dao.GetActMtwmVendorPage(dao.GetDB(), storeIDs, skuIDs, keyword, utils.Str2Time(beginAt), utils.Str2Time(endAt), actType, offset, pageSize)
|
||||
}
|
||||
|
||||
func GetActMtwmVendorSku(ctx *jxcontext.Context, storeID int, keyword string, actType, offset, pageSize int) (page *model.PagedInfo, err error) {
|
||||
return dao.GetActMtwmVendorSkuPage(dao.GetDB(), storeID, keyword, actType, offset, pageSize)
|
||||
}
|
||||
|
||||
@@ -328,6 +328,8 @@ func Init() {
|
||||
ScheduleTimerFunc("RrefreshMtwmVendorAct", func() {
|
||||
//刷新美团平台活动
|
||||
act.RrefreshMtwmVendorAct()
|
||||
//刷新饿百平台活动
|
||||
act.RrefreshEbaiVendorAct()
|
||||
}, dailyWorkTimeList2)
|
||||
}
|
||||
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
||||
|
||||
@@ -279,6 +279,7 @@ type ActMtwmVendor struct {
|
||||
Period string `json:"period"` //生效时段
|
||||
WeeksTime string `json:"weeksTime"` //生效活动周期
|
||||
SettingType int `json:"settingType"` //活动开展类型,参考值:0-按折扣系数开展活动;1-按折扣价格开展活动。
|
||||
StoreName string `orm:"-" json:"storeName"`
|
||||
}
|
||||
|
||||
func (*ActMtwmVendor) TableIndex() [][]string {
|
||||
|
||||
@@ -710,3 +710,93 @@ func GetActEbaiVendorSkus(db *DaoDB, storeIDs, skuIDs []int) (actEbaiVendorSku [
|
||||
err = GetRows(db, &actEbaiVendorSku, sql, sqlParams)
|
||||
return actEbaiVendorSku, err
|
||||
}
|
||||
|
||||
func GetActMtwmVendorPage(db *DaoDB, storeIDs, skuIDs []int, keyword string, beginAt, endAt time.Time, actType, offset, pageSize int) (page *model.PagedInfo, err error) {
|
||||
var (
|
||||
acts []*model.ActMtwmVendor
|
||||
)
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS a.store_id, a.vendor_store_id, b.name store_name, a.act_type
|
||||
FROM act_mtwm_vendor a
|
||||
LEFT JOIN store b ON a.store_id = b.id
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND a.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
if len(skuIDs) > 0 {
|
||||
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||
sqlParams = append(sqlParams, skuIDs)
|
||||
}
|
||||
if keyword != "" {
|
||||
sql += " AND (a.store_id = ? OR a.sku_id = ? OR a.sku_name LIKE ? OR b.name LIKE ?)"
|
||||
sqlParams = append(sqlParams, keyword, keyword, "%"+keyword+"%", "%"+keyword+"%")
|
||||
}
|
||||
if !utils.IsTimeZero(beginAt) {
|
||||
sql += " AND a.begin_at <= ?"
|
||||
sqlParams = append(sqlParams, beginAt)
|
||||
}
|
||||
if !utils.IsTimeZero(endAt) {
|
||||
sql += " AND a.end_at >= ?"
|
||||
sqlParams = append(sqlParams, endAt)
|
||||
}
|
||||
if actType != 0 {
|
||||
sql += " AND a.act_type = ?"
|
||||
sqlParams = append(sqlParams, actType)
|
||||
}
|
||||
sql += `
|
||||
GROUP BY 1, 2, 3, 4
|
||||
LIMIT ? OFFSET ?
|
||||
`
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
txDB, _ := Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
Rollback(db, txDB)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if err = GetRowsTx(txDB, &acts, sql, sqlParams...); err == nil {
|
||||
page.TotalCount = GetLastTotalRowCount2(db, txDB)
|
||||
page.Data = acts
|
||||
}
|
||||
Commit(db, txDB)
|
||||
return page, err
|
||||
}
|
||||
|
||||
func GetActMtwmVendorSkuPage(db *DaoDB, storeID int, keyword string, actType, offset, pageSize int) (page *model.PagedInfo, err error) {
|
||||
var (
|
||||
acts []*model.ActMtwmVendor
|
||||
)
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS a.*
|
||||
FROM act_mtwm_vendor a WHERE store_id = ?
|
||||
`
|
||||
sqlParams := []interface{}{storeID}
|
||||
if keyword != "" {
|
||||
sql += " AND (a.store_id = ? OR a.sku_id = ? OR a.sku_name LIKE ?)"
|
||||
sqlParams = append(sqlParams, keyword, keyword, "%"+keyword+"%")
|
||||
}
|
||||
if actType != 0 {
|
||||
sql += " AND a.act_type = ?"
|
||||
sqlParams = append(sqlParams, actType)
|
||||
}
|
||||
sql += `
|
||||
LIMIT ? OFFSET ?
|
||||
`
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
txDB, _ := Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
Rollback(db, txDB)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if err = GetRowsTx(txDB, &acts, sql, sqlParams...); err == nil {
|
||||
page.TotalCount = GetLastTotalRowCount2(db, txDB)
|
||||
page.Data = acts
|
||||
}
|
||||
Commit(db, txDB)
|
||||
return page, err
|
||||
}
|
||||
|
||||
@@ -447,14 +447,38 @@ func (c *ActController) GetVendorPopActDetail() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs query string false "门店IDs"
|
||||
// @Param skuIDs query string false "skuIDs"
|
||||
// @Param keyword query string false "关键字"
|
||||
// @Param beginAt query string false "活动开始日期"
|
||||
// @Param endAt query string false "活动结束日期"
|
||||
// @Param actType query int false "折扣或者秒杀"
|
||||
// @Param offset query int false "起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int false "表页大小(缺省全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetActMtwmVendor [get]
|
||||
func (c *ActController) GetActMtwmVendor() {
|
||||
c.callGetActMtwmVendor(func(params *tActGetActMtwmVendorParams) (retVal interface{}, errCode string, err error) {
|
||||
var storeIDs, skuIDs []int
|
||||
err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs)
|
||||
retVal, err = act.GetActMtwmVendor(params.Ctx, storeIDs, skuIDs, params.Keyword, params.BeginAt, params.EndAt, params.ActType, params.Offset, params.PageSize)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 查询美团平台活动sku
|
||||
// @Description 查询美团平台活动sku
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeID query int true "门店ID"
|
||||
// @Param keyword query string false "关键字"
|
||||
// @Param actType query int false "折扣或者秒杀"
|
||||
// @Param offset query int false "起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int false "表页大小(缺省全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetActMtwmVendorSku [get]
|
||||
func (c *ActController) GetActMtwmVendorSku() {
|
||||
c.callGetActMtwmVendorSku(func(params *tActGetActMtwmVendorSkuParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = act.GetActMtwmVendorSku(params.Ctx, params.StoreID, params.Keyword, params.ActType, params.Offset, params.PageSize)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user