力荐
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user