- RefreshPromotionStatus
- call UpdatePromotionStatusFromRemote in LockPromotionSkus.
This commit is contained in:
@@ -461,7 +461,7 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync, isContinueW
|
|||||||
if _, err = dao.UpdateEntityLogically(db, promotion, map[string]interface{}{
|
if _, err = dao.UpdateEntityLogically(db, promotion, map[string]interface{}{
|
||||||
model.FieldStatus: model.PromotionStatusRemoteCreated,
|
model.FieldStatus: model.PromotionStatusRemoteCreated,
|
||||||
}, ctx.GetUserName(), nil); err == nil {
|
}, ctx.GetUserName(), nil); err == nil {
|
||||||
RefreshJdPromotionLockStatus(promotion.ID)
|
RefreshJdPromotionLockStatus(ctx, promotion.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -644,7 +644,7 @@ func CancelJdPromotion(ctx *jxcontext.Context, promotionID int) (err error) {
|
|||||||
if _, err = dao.UpdateEntityLogically(db, promotion, map[string]interface{}{
|
if _, err = dao.UpdateEntityLogically(db, promotion, map[string]interface{}{
|
||||||
"Status": model.PromotionStatusCanceled,
|
"Status": model.PromotionStatusCanceled,
|
||||||
}, ctx.GetUserName(), nil); err == nil {
|
}, ctx.GetUserName(), nil); err == nil {
|
||||||
RefreshJdPromotionLockStatus(promotionID)
|
RefreshJdPromotionLockStatus(ctx, promotionID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@@ -787,7 +787,7 @@ func RefreshJdPromotionItemListLockStatus(promotionItemList []*tPromotionItemInf
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func RefreshJdPromotionLockStatus(promotionID int) (err error) {
|
func RefreshJdPromotionLockStatus(ctx *jxcontext.Context, promotionID int) (err error) {
|
||||||
globals.SugarLogger.Debugf("RefreshJdPromotionLockStatus promotionID:%d", promotionID)
|
globals.SugarLogger.Debugf("RefreshJdPromotionLockStatus promotionID:%d", promotionID)
|
||||||
|
|
||||||
sql := `
|
sql := `
|
||||||
@@ -840,7 +840,12 @@ func LockPromotionSkus(ctx *jxcontext.Context, promotionID int, isLock int, skuI
|
|||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
num, err = dao.ExecuteSQL(db, sql, sqlParams...)
|
num, err = dao.ExecuteSQL(db, sql, sqlParams...)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
RefreshJdPromotionLockStatus(promotionID)
|
if isLock != 0 {
|
||||||
|
if err = UpdatePromotionStatusFromRemote(ctx, promotionID); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RefreshJdPromotionLockStatus(ctx, promotionID)
|
||||||
if isLock != 0 {
|
if isLock != 0 {
|
||||||
RefreshJdStoreSkuStock()
|
RefreshJdStoreSkuStock()
|
||||||
}
|
}
|
||||||
@@ -978,6 +983,26 @@ func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.Callba
|
|||||||
return jdapi.Err2CallbackResponse(nil, "")
|
return jdapi.Err2CallbackResponse(nil, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdatePromotionStatusFromRemote(ctx *jxcontext.Context, prommotionID int) (err error) {
|
||||||
|
db := dao.GetDB()
|
||||||
|
promotion := &model.Promotion{}
|
||||||
|
promotion.ID = prommotionID
|
||||||
|
if err = dao.GetEntity(db, promotion); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
result, err := api.JdAPI.QueryPromotionInfo(utils.Str2Int64(promotion.VendorPromotionID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
newStatus := jd2jxPromotionStatusMap[result.PromotionState]
|
||||||
|
if newStatus != promotion.Status {
|
||||||
|
_, err = dao.UpdateEntityLogically(db, promotion, map[string]interface{}{
|
||||||
|
model.FieldStatus: newStatus,
|
||||||
|
}, ctx.GetUserName(), nil)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func excelStr2Time(timeStr string) (tm time.Time, err error) {
|
func excelStr2Time(timeStr string) (tm time.Time, err error) {
|
||||||
return time.ParseInLocation("2006年1月2日15点4分5秒", timeStr, time.Local)
|
return time.ParseInLocation("2006年1月2日15点4分5秒", timeStr, time.Local)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,3 +175,17 @@ func (c *PromotionController) LockPromotionSkus() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 锁定解锁活动SKU
|
||||||
|
// @Description 锁定解锁活动SKU
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param promotionID formData int true "活动id"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /RefreshPromotionStatus [put]
|
||||||
|
func (c *PromotionController) RefreshPromotionStatus() {
|
||||||
|
c.callRefreshPromotionStatus(func(params *tPromotionRefreshPromotionStatusParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
err = promotion.UpdatePromotionStatusFromRemote(params.Ctx, params.PromotionID)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -247,6 +247,14 @@ func init() {
|
|||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "RefreshPromotionStatus",
|
||||||
|
Router: `/RefreshPromotionStatus`,
|
||||||
|
AllowHTTPMethods: []string{"put"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PromotionController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "SendAdvertingByGoodsOrder",
|
Method: "SendAdvertingByGoodsOrder",
|
||||||
|
|||||||
Reference in New Issue
Block a user