yonghuiexcel
This commit is contained in:
@@ -215,7 +215,11 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
||||
isCompare, err = UpdateClassifyAndGetLastClassify()
|
||||
case 1:
|
||||
//获取微盟所有商品
|
||||
goodsList, err = GetWeiMobGoodsList()
|
||||
param := &weimobapi.QueryGoodsListParam{
|
||||
PageNum: 1,
|
||||
PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds,
|
||||
}
|
||||
goodsList, err = GetWeiMobGoodsList(param)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("GetWeiMobGoodsList error:%v", err)
|
||||
}
|
||||
@@ -490,11 +494,7 @@ func updateWeiMobGoods(costPrice, salePrice float64, unit string, isCompare bool
|
||||
return goodsID, skuMap, err
|
||||
}
|
||||
|
||||
func GetWeiMobGoodsList() (goodsList []*weimobapi.GoodsInfo, err error) {
|
||||
param := &weimobapi.QueryGoodsListParam{
|
||||
PageNum: 1,
|
||||
PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds,
|
||||
}
|
||||
func GetWeiMobGoodsList(param *weimobapi.QueryGoodsListParam) (goodsList []*weimobapi.GoodsInfo, err error) {
|
||||
for {
|
||||
goodsInfoList, _, err := api.WeimobAPI.QueryGoodsList(param)
|
||||
if err != nil {
|
||||
@@ -694,7 +694,7 @@ func WriteToExcel(task *tasksch.SeqTask, dataSuccess []DataSuccess, dataFailed [
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("WriteToExcel:upload %s , %s failed error:%v", fileName1, fileName2, err)
|
||||
} else {
|
||||
noticeMsg := fmt.Sprintf("[详情点我]%s/billshow/?normal=true&path1=%s, path2=%s \n", globals.BackstageHost, downloadURL1, downloadURL2)
|
||||
noticeMsg := fmt.Sprintf("[详情点我]path1=%s, path2=%s \n", globals.BackstageHost, downloadURL1, downloadURL2)
|
||||
task.SetNoticeMsg(noticeMsg)
|
||||
baseapi.SugarLogger.Debugf("WriteToExcel:upload %s ,%s success, downloadURL1:%s ,downloadURL2:%s", fileName1, fileName2, downloadURL1, downloadURL2)
|
||||
}
|
||||
@@ -709,3 +709,48 @@ func UploadExeclAndPushMsg(sheetList []*excel.Obj2ExcelSheetConfig, name string)
|
||||
downloadURL, err = jxutils.UploadExportContent(excelBin, fileName)
|
||||
return downloadURL, fileName, err
|
||||
}
|
||||
|
||||
func UpdateJxPriceByWeimob(ctx *jxcontext.Context, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
//获取微盟所有商品
|
||||
// param := &weimobapi.QueryGoodsListParam{
|
||||
// GoodsStatus: 0,
|
||||
// PageNum: 1,
|
||||
// PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds,
|
||||
// }
|
||||
// goodsList, err := GetWeiMobGoodsList(param)
|
||||
// if err != nil {
|
||||
// baseapi.SugarLogger.Errorf("GetWeiMobGoodsList error:%v", err)
|
||||
// }
|
||||
// taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
// switch step {
|
||||
// case 0:
|
||||
// taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
// v := batchItemList[0].(*weimobapi.GoodsInfo)
|
||||
// goodsDetail, err := api.WeimobAPI.QueryGoodsDetail(v.GoodsID)
|
||||
// if err != nil {
|
||||
// baseapi.SugarLogger.Errorf("QueryGoodsDetail error:%v", err)
|
||||
// }
|
||||
// storeSkuBindInfo := &cms.StoreSkuBindInfo{
|
||||
// NameID: goodsDetail.SkuMap.SingleSku.OuterSkuCode,
|
||||
// UnitPrice: goodsDetail.SkuMap.SingleSku.CostPrice,
|
||||
// }
|
||||
// retVal =
|
||||
// return retVal, err
|
||||
// }
|
||||
// taskParallel := tasksch.NewParallelTask("获取微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount), ctx, taskFunc, goodsList)
|
||||
// tasksch.HandleTask(taskParallel, task, true).Run()
|
||||
// _, err = taskParallel.GetResult(0)
|
||||
// case 1:
|
||||
// cms.UpdateStoresSkus(ctx, storeIDs, skuBindInfos, isAsync, isContinueWhenError)
|
||||
// }
|
||||
// }
|
||||
// taskSeq := tasksch.NewSeqTask2("根据微盟商品更新京西价", ctx, isContinueWhenError, taskSeqFunc, 2)
|
||||
// tasksch.HandleTask(taskSeq, nil, true).Run()
|
||||
// if !isAsync {
|
||||
// _, err = taskSeq.GetResult(0)
|
||||
// hint = "1"
|
||||
// } else {
|
||||
// hint = taskSeq.GetID()
|
||||
// }
|
||||
return hint, err
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"io"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/yonghui"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
@@ -46,17 +47,18 @@ func (c *YongHuiController) LoadExcelByYongHui() {
|
||||
// @Title 根据微盟商品更新京西价格
|
||||
// @Description 根据微盟商品更新京西价格
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs formData string false "门店ID列表"
|
||||
// @Param storeIDs formData string true "门店ID列表"
|
||||
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
||||
// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UpdateJxPriceByWeimob [post]
|
||||
func (c *YongHuiController) UpdateJxPriceByWeimob() {
|
||||
// c.callLoadExcelByYongHui(func(params *tYonghuiLoadExcelByYongHuiParams) (retVal interface{}, errCode string, err error) {
|
||||
// r := c.Ctx.Request
|
||||
// files := r.MultipartForm.File["userfiles"]
|
||||
// retVal, err = yonghui.LoadExcelByYongHui(params.Ctx, files, params.IsAsync, params.IsContinueWhenError)
|
||||
// return retVal, "", err
|
||||
// })
|
||||
c.callUpdateJxPriceByWeimob(func(params *tYonghuiUpdateJxPriceByWeimobParams) (retVal interface{}, errCode string, err error) {
|
||||
var storeIDList []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
|
||||
retVal, err = yonghui.UpdateJxPriceByWeimob(params.Ctx, storeIDList, isAsync, isContinueWhenError)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user