1
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||
"io"
|
||||
"math"
|
||||
"mime/multipart"
|
||||
@@ -3042,6 +3043,89 @@ func UpdateSkuExinfoMap(ctx *jxcontext.Context, nameIDs []int, imgWaterMark stri
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func UpdateVendorImg(ctx *jxcontext.Context, storeId int, imgWaterMark string, vendorID int, exPrefix string, fromTime, toTime string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
var (
|
||||
fromTimeP time.Time
|
||||
toTimeP time.Time
|
||||
db = dao.GetDB()
|
||||
i = 0
|
||||
// skuIDs []int
|
||||
)
|
||||
if fromTime != "" {
|
||||
fromTimeP = utils.Time2Date(utils.Str2Time(fromTime))
|
||||
}
|
||||
if toTime != "" {
|
||||
toTimeP = utils.Time2Date(utils.Str2Time(toTime))
|
||||
}
|
||||
if toTimeP.Before(fromTimeP) {
|
||||
return "", fmt.Errorf("结束时间不可以小于开始时间!开始时间:[%v],结束时间:[%v]", fromTimeP, toTimeP)
|
||||
}
|
||||
|
||||
task := tasksch.NewParallelTask("刷新商品前缀水印图", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
switch vendorID {
|
||||
case model.VendorIDMTWM:
|
||||
storeDetail, err := dao.GetStoreDetail(db, storeId, vendorID, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
api := mtwm.GetAPI(storeDetail.VendorOrgCode, storeId, storeDetail.VendorStoreID)
|
||||
for {
|
||||
foodList, _ := api.RetailListAll(storeDetail.VendorStoreID, i)
|
||||
for _, v := range foodList {
|
||||
if v.AppFoodCode == "mtcode_2005129131042222122" { // 测试
|
||||
skuEx := &model.SkuExinfoMap{
|
||||
NameID: 0,
|
||||
ImgWatermark: v.PictureList[0], // 原图
|
||||
ImgWatermarkMix: v.AppFoodCode, // 商品ID
|
||||
ExPrefix: exPrefix,
|
||||
VendorID: vendorID,
|
||||
BeginAt: fromTimeP,
|
||||
EndAt: toTimeP,
|
||||
BrandID: 0,
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(skuEx, ctx.GetUserName())
|
||||
dao.CreateEntity(db, skuEx)
|
||||
|
||||
param := map[string]interface{}{}
|
||||
if imgWaterMark != "" {
|
||||
if ImgMix := jxutils.MixWatermarkImg(imgWaterMark, v.PictureList[0], &fromTimeP, &toTimeP); ImgMix != "" {
|
||||
picture := make([]string, 0, len(v.PictureList))
|
||||
picture = append(picture, ImgMix)
|
||||
if len(v.PictureList) > 1 {
|
||||
picture = append(picture, v.PictureList[1:]...)
|
||||
}
|
||||
param["picture"] = strings.Join(picture, ",")
|
||||
}
|
||||
}
|
||||
if exPrefix != "" {
|
||||
param["name"] = fmt.Sprintf("%s %s", exPrefix, v.Name)
|
||||
}
|
||||
api.RetailInitData(utils.GetUUID(), storeDetail.VendorStoreID, v.AppFoodCode, param)
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
}
|
||||
if len(foodList) < 100 {
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
return retVal, err
|
||||
}, nil)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if isAsync {
|
||||
hint = task.GetID()
|
||||
} else {
|
||||
_, err = task.GetResult(0)
|
||||
hint = "1"
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func GetVendorCategoryMap(ctx *jxcontext.Context, parentID, level, vendorID int, vendorOrgCode string) (vendorMaps []*model.VendorCategoryMap, err error) {
|
||||
db := dao.GetDB()
|
||||
vendorMaps, err = dao.GetVendorCategoryMap(db, parentID, level, vendorID, vendorOrgCode, 0)
|
||||
|
||||
Reference in New Issue
Block a user