- make OnNewPromotionMsg asnyc
- set limit... in CreateJdPromotion - correct limitPint to limitPin
This commit is contained in:
@@ -262,6 +262,10 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync, isContinueW
|
||||
VendorID: model.VendorIDJD,
|
||||
Type: params.Type,
|
||||
Status: model.PromotionStatusLocalCreated,
|
||||
LimitDevice: int8(limitDevice),
|
||||
LimitPin: int8(limitPin),
|
||||
LimitCount: limitCount,
|
||||
LimitDaily: int8(limitDaily),
|
||||
BeginAt: params.BeginAt,
|
||||
EndAt: params.EndAt,
|
||||
CreateType: model.PromotionCreateTypeByJX,
|
||||
@@ -482,56 +486,6 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync, isContinueW
|
||||
return hint, err
|
||||
}
|
||||
|
||||
// func CreatePromotionByExcel(ctx *jxcontext.Context, isAsync bool, promotionType int, fileHeader *multipart.FileHeader, userName string) (hint string, err error) {
|
||||
// file, err := fileHeader.Open()
|
||||
// if err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
// contents := excel.Excel2Slice(file)
|
||||
// file.Close()
|
||||
// var promotionParams *PromotionParams
|
||||
// for _, v := range contents {
|
||||
// promotionParams = &PromotionParams{
|
||||
// Name: v[1][colNameIndex],
|
||||
// Type: promotionType,
|
||||
// }
|
||||
// if promotionParams.BeginAt, err = excelStr2Time(v[1][colBeginAtIndex]); err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
// if promotionParams.EndAt, err = excelStr2Time(v[1][colEndAtIndex]); err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
|
||||
// for rowIndex, row := range v {
|
||||
// if rowIndex > 0 {
|
||||
// isBreak := true
|
||||
// if row[colSkuIDIndex] != "" {
|
||||
// isBreak = false
|
||||
// jdSkuID := int(utils.Str2Int64(row[colSkuIDIndex]))
|
||||
// promotionParams.SkuPrices = append(promotionParams.SkuPrices, &SkuPrice{
|
||||
// SkuID: jdSkuID,
|
||||
// PriceType: PriceTypePrice,
|
||||
// Price: int(jxutils.StandardPrice2Int(utils.Str2Float64(row[colSkuPriceIndex]))),
|
||||
// })
|
||||
// }
|
||||
// if row[colStoreIDIndex] != "" {
|
||||
// isBreak = false
|
||||
// jdStoreID := int(utils.Str2Int64(row[colStoreIDIndex]))
|
||||
// promotionParams.StoreIDs = append(promotionParams.StoreIDs, jdStoreID)
|
||||
// }
|
||||
// if isBreak {
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// break
|
||||
// }
|
||||
// // globals.SugarLogger.Debug(utils.Format4Output(promotionParams, false))
|
||||
// // globals.SugarLogger.Debug(isAsync)
|
||||
// return CreateJdPromotion(ctx, true, isAsync, promotionParams, userName)
|
||||
// }
|
||||
|
||||
func GetJdPromotions(ctx *jxcontext.Context, keyword string, params map[string]interface{}, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS
|
||||
@@ -933,6 +887,7 @@ func OnNewPromotionMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackRespo
|
||||
}
|
||||
|
||||
func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.CallbackResponse) {
|
||||
go func() {
|
||||
result, err := api.JdAPI.QueryPromotionInfo(promotionInfoId)
|
||||
if err == nil {
|
||||
db := dao.GetDB()
|
||||
@@ -965,7 +920,8 @@ func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.Callba
|
||||
WHERE vendor_id = ? AND deleted_at = ? AND vendor_store_id IN (`+
|
||||
dao.GenQuestionMarks(len(jdStoreIDs))+")",
|
||||
model.VendorIDJD, utils.DefaultTimeValue, jdStoreIDs); err != nil {
|
||||
return jdapi.Err2CallbackResponse(err, "")
|
||||
globals.SugarLogger.Warnf("createLocalPromotionFromRemote get storeMapList failed with error:%v", err)
|
||||
return
|
||||
}
|
||||
if err = dao.GetRows(db, &skuList, `
|
||||
SELECT *
|
||||
@@ -973,7 +929,8 @@ func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.Callba
|
||||
WHERE jd_id IN (`+
|
||||
dao.GenQuestionMarks(len(jdSkuIDs))+")",
|
||||
jdSkuIDs); err != nil {
|
||||
return jdapi.Err2CallbackResponse(err, "")
|
||||
globals.SugarLogger.Warnf("createLocalPromotionFromRemote get skuList failed with error:%v", err)
|
||||
return
|
||||
}
|
||||
jxStoreIDs := make([]int, len(storeMapList))
|
||||
for k, v := range storeMapList {
|
||||
@@ -1017,7 +974,8 @@ func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.Callba
|
||||
}
|
||||
}
|
||||
}
|
||||
return jdapi.Err2CallbackResponse(err, "")
|
||||
}()
|
||||
return jdapi.Err2CallbackResponse(nil, "")
|
||||
}
|
||||
|
||||
func excelStr2Time(timeStr string) (tm time.Time, err error) {
|
||||
|
||||
@@ -30,7 +30,7 @@ type Promotion struct {
|
||||
Type int `json:"type"`
|
||||
Status int `json:"status"`
|
||||
LimitDevice int8 `json:"limitDevice"`
|
||||
LimitPint int8 `json:"limitPint"`
|
||||
LimitPin int8 `json:"limitPin"`
|
||||
LimitDaily int8 `json:"limitDaily"`
|
||||
LimitCount int `json:"limitCount"`
|
||||
Source string `orm:"size(255)" json:"source"`
|
||||
|
||||
Reference in New Issue
Block a user