aa
This commit is contained in:
@@ -3,6 +3,7 @@ package act
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
@@ -1966,3 +1967,54 @@ func GetNewVendorPopActs(ctx *jxcontext.Context) (err error) {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func RrefreshMtwmVendorAct() (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
actTypeMap = map[int]int{
|
||||
mtwmapi.RetailActTypeSecKill: model.ActSkuSecKill,
|
||||
mtwmapi.RetailActTypeDirectDown: model.ActSkuDirectDown,
|
||||
}
|
||||
)
|
||||
//直接做删除,把新的加进来
|
||||
dao.ExecuteSQL(db, `TRUNCATE act_mtwm_vendor`, nil)
|
||||
storeMaps, _ := dao.GetStoresMapList(db, []int{model.VendorIDMTWM}, []int{668023}, []int{model.StoreStatusOpened, model.StoreStatusHaveRest, model.StoreStatusClosed},
|
||||
model.StoreStatusAll, model.StoreIsSyncAll, "", "", "")
|
||||
task := tasksch.NewParallelTask("刷新美团活动", tasksch.NewParallelConfig().SetIsContinueWhenError(true), jxcontext.AdminCtx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeMap := batchItemList[0].(*model.StoreMap)
|
||||
mtapi := mtwm.GetAPI(storeMap.VendorOrgCode, storeMap.StoreID, "")
|
||||
for k, v := range actTypeMap {
|
||||
if actList, _ := mtapi.RetailDiscountList(storeMap.VendorStoreID, k); len(actList) > 0 {
|
||||
for _, act := range actList {
|
||||
if act.Status > 0 {
|
||||
actVendor := &model.ActMtwmVendor{
|
||||
StoreID: storeMap.StoreID,
|
||||
SkuID: utils.Str2Int(act.AppFoodCode),
|
||||
VendorStoreID: storeMap.VendorStoreID,
|
||||
ActType: v,
|
||||
BeginAt: utils.Timestamp2Time(act.StartTime),
|
||||
EndAt: utils.Timestamp2Time(act.EndTime),
|
||||
SkuName: act.Name,
|
||||
OriginPrice: act.OriginalPrice,
|
||||
ActPrice: act.ActPrice,
|
||||
DiscountCoefficient: act.DiscountCoefficient,
|
||||
Status: act.Status,
|
||||
ItemID: utils.Int64ToStr(act.ItemID),
|
||||
OrderLimit: act.OrderLimit,
|
||||
Period: act.Period,
|
||||
WeeksTime: act.WeeksTime,
|
||||
SettingType: act.SettingType,
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(act, "jxadmin")
|
||||
dao.CreateEntity(db, actVendor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
}, storeMaps)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
task.GetID()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -267,6 +267,7 @@ type ActMtwmVendor struct {
|
||||
VendorStoreID string `orm:"column(vendor_store_id)" json:"vendorStoreID"`
|
||||
BeginAt time.Time `json:"beginAt"` //活动时间
|
||||
EndAt time.Time `json:"endAt"`
|
||||
ActType int `json:"actType"` //活动类型 (折扣,秒杀)
|
||||
SkuName string `json:"skuName"` //商品名
|
||||
OriginPrice float64 `json:"originPrice"`
|
||||
ActPrice float64 `json:"actPrice"`
|
||||
|
||||
@@ -226,14 +226,18 @@ func (p *PurchaseHandler) getUploadImgPoiCode() (poiCode string) {
|
||||
return poiCode
|
||||
}
|
||||
|
||||
func GetAPI(appOrgCode string, vendorStoreID string) (apiObj *mtwmapi.API) {
|
||||
func GetAPI(appOrgCode string, storeID int, vendorStoreID string) (apiObj *mtwmapi.API) {
|
||||
if appOrgCode == "" {
|
||||
globals.SugarLogger.Debugf("getAPI appOrgCode is empty")
|
||||
}
|
||||
apiObj = partner.CurAPIManager.GetAPI(model.VendorIDMTWM, appOrgCode).(*mtwmapi.API)
|
||||
if appOrgCode == globals.Mtwm2Code {
|
||||
var storeDetail *dao.StoreDetail
|
||||
storeDetail, _ = dao.GetStoreDetailByVendorStoreID(dao.GetDB(), vendorStoreID, model.VendorIDMTWM, appOrgCode)
|
||||
if storeID != 0 {
|
||||
storeDetail, _ = dao.GetStoreDetail(dao.GetDB(), storeID, model.VendorIDMTWM, appOrgCode)
|
||||
} else if vendorStoreID != "" {
|
||||
storeDetail, _ = dao.GetStoreDetailByVendorStoreID(dao.GetDB(), vendorStoreID, model.VendorIDMTWM, appOrgCode)
|
||||
}
|
||||
if storeDetail != nil {
|
||||
apiObj.SetToken(storeDetail.MtwmToken)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user