From 14d85186de65c66e513b5391da8c6608c78b03d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 14 Aug 2020 15:35:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9B=E8=8D=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 71 +++++++++++++++++++++++++++ controllers/cms_store_sku.go | 21 ++++++++ routers/commentsRouter_controllers.go | 9 ++++ 3 files changed, 101 insertions(+) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index d97e0b375..33cdd96fa 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -4797,3 +4797,74 @@ func StoreSkuPriceAudit(ctx *jxcontext.Context, storeSkuAudits []*model.StoreSku } return nil, hint, err } + +func GetSpecialtyStoreSkus(ctx *jxcontext.Context, storeIDs, vendorIDs []int) (err error) { + type SpecialtyStoreSkus struct { + StoreID int `json:"门店ID"` + StoreName string `json:"门店名"` + SkuID int `json:"SkuID"` + SkuName string `json:"商品名"` + Price float64 `json:"平台价"` + VendorName string `json:"平台名"` + } + var ( + db = dao.GetDB() + specialtyStoreSkus []*SpecialtyStoreSkus + excelTitle = []string{ + "门店ID", + "门店名", + "SkuID", + "商品名", + "平台价", + "平台名", + } + sheetList []*excel.Obj2ExcelSheetConfig + downloadURL, fileName string + ) + for _, v := range vendorIDs { + for _, vv := range storeIDs { + storeDetail, err := dao.GetStoreDetail(db, vv, v) + if err != nil || storeDetail == nil { + continue + } + if partner.IsMultiStore(v) { + + } else { + handler := partner.GetPurchasePlatformFromVendorID(v).(partner.ISingleStoreStoreSkuHandler) + skuList, _ := handler.GetStoreSkusFullInfo(ctx, nil, vv, storeDetail.VendorStoreID, nil) + for _, sku := range skuList { + if sku.SkuList[0].IsSpecialty == model.YES { + specialtyStoreSku := &SpecialtyStoreSkus{ + StoreID: vv, + StoreName: storeDetail.Name, + SkuID: sku.SkuList[0].SkuID, + SkuName: sku.Name, + Price: float64(sku.SkuList[0].VendorPrice) / 100, + VendorName: model.VendorNames[v], + } + specialtyStoreSkus = append(specialtyStoreSkus, specialtyStoreSku) + } + } + } + } + } + excelConf := &excel.Obj2ExcelSheetConfig{ + Title: "sheet1", + Data: specialtyStoreSkus, + CaptionList: excelTitle, + } + sheetList = append(sheetList, excelConf) + if excelConf != nil { + downloadURL, fileName, err = jxutils.UploadExeclAndPushMsg(sheetList, "力荐或置顶商品") + } else { + baseapi.SugarLogger.Debug("WriteToExcel: dataSuccess is nil!") + } + if err != nil { + baseapi.SugarLogger.Errorf("WriteToExcel:upload %s , %s failed error:%v", fileName, err) + } else { + noticeMsg := fmt.Sprintf("[详情点我]%s/billshow/?normal=true&path=%s \n", globals.BackstageHost, downloadURL) + ddmsg.SendUserMessage(dingdingapi.MsgTyeText, ctx.GetUserID(), "异步任务完成", noticeMsg) + baseapi.SugarLogger.Debug("WriteToExcel: dataSuccess downloadURL: [%v]", downloadURL) + } + return err +} diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index 51f102cad..41b74b5a6 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -896,3 +896,24 @@ func (c *StoreSkuController) StoreSkuPriceAudit() { } }) } + +// @Title 查看美团力荐或京东置顶商品 +// @Description 查看美团力荐或京东置顶商品 +// @Param token header string true "认证token" +// @Param vendorIDs formData string true "平台ids" +// @Param storeIDs formData string true "门店IDs" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetSpecialtyStoreSkus [post] +func (c *StoreSkuController) GetSpecialtyStoreSkus() { + c.callGetSpecialtyStoreSkus(func(params *tStoreSkuGetSpecialtyStoreSkusParams) (retVal interface{}, errCode string, err error) { + var ( + storeIDs, vendorIDs []int + ) + if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil { + return retVal, "", err + } + err = cms.GetSpecialtyStoreSkus(params.Ctx, storeIDs, vendorIDs) + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 2a962a10e..0b48de2c5 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -2088,6 +2088,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"], + beego.ControllerComments{ + Method: "GetSpecialtyStoreSkus", + Router: `/GetSpecialtyStoreSkus`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"], beego.ControllerComments{ Method: "GetStoreAbnormalSkuCount",