|
|
|
|
@@ -129,6 +129,14 @@ type JxBadCommentsExt struct {
|
|
|
|
|
VendorOrderID2 string `orm:"column(vendor_order_id2);size(48);index" json:"vendorOrderID2"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type VendorStoreExcel struct {
|
|
|
|
|
StoreID int `json:"门店ID"`
|
|
|
|
|
VendorStoreName string `json:"门店名"`
|
|
|
|
|
Status string `json:"营业状态"`
|
|
|
|
|
Tel1 string `json:"电话1"`
|
|
|
|
|
Tel2 string `json:"电话2"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
ErrMissingInput = errors.New("没有有效的输入参数")
|
|
|
|
|
ErrCanNotFindVendor = errors.New("vendorID参数不合法")
|
|
|
|
|
@@ -160,6 +168,13 @@ var (
|
|
|
|
|
"15:00:00",
|
|
|
|
|
"20:00:00",
|
|
|
|
|
}
|
|
|
|
|
titleListStore = []string{
|
|
|
|
|
"门店ID",
|
|
|
|
|
"门店名",
|
|
|
|
|
"营业状态",
|
|
|
|
|
"电话1",
|
|
|
|
|
"电话2",
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]interface{}, orderTimeFrom, orderTimeTo time.Time) (sql string, sqlParams []interface{}, sqlFrom string, sqlFromParams []interface{}, err error) {
|
|
|
|
|
@@ -2269,3 +2284,131 @@ func ExecuteFileName(filename string) (name string) {
|
|
|
|
|
name = fileRealName + utils.Int64ToStr(time.Now().Unix()) + filePrefix
|
|
|
|
|
return name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetVendorStoreInfo(ctx *jxcontext.Context, vendorIDList []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
|
|
|
|
var (
|
|
|
|
|
storeListJD []VendorStoreExcel
|
|
|
|
|
storeListMT []VendorStoreExcel
|
|
|
|
|
storeListEB []VendorStoreExcel
|
|
|
|
|
)
|
|
|
|
|
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
|
|
|
|
switch step {
|
|
|
|
|
case 0:
|
|
|
|
|
for _, vendorID := range vendorIDList {
|
|
|
|
|
iStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IStoreHandler)
|
|
|
|
|
storeIDs, err := iStoreHandler.GetAllStoresVendorID(ctx)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
|
|
|
|
var storeDetail *dao.StoreDetail
|
|
|
|
|
storeID := batchItemList[0].(string)
|
|
|
|
|
if partner.IsMultiStore(vendorID) {
|
|
|
|
|
multiHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler)
|
|
|
|
|
storeDetail, err = multiHandler.ReadStore(ctx, storeID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return retVal, err
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
singleHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreHandler)
|
|
|
|
|
storeDetail, err = singleHandler.ReadStore(ctx, storeID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return retVal, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if storeDetail.Status != model.StoreStatusOpened {
|
|
|
|
|
var storeExcel = VendorStoreExcel{
|
|
|
|
|
StoreID: storeDetail.ID,
|
|
|
|
|
VendorStoreName: storeDetail.Name,
|
|
|
|
|
Tel1: storeDetail.Tel1,
|
|
|
|
|
Tel2: storeDetail.Tel2,
|
|
|
|
|
Status: StoreStatus2Chinese(storeDetail.Status),
|
|
|
|
|
}
|
|
|
|
|
retVal = []VendorStoreExcel{storeExcel}
|
|
|
|
|
}
|
|
|
|
|
return retVal, err
|
|
|
|
|
}
|
|
|
|
|
taskParallel := tasksch.NewParallelTask("获取各平台未营业门店", tasksch.NewParallelConfig(), ctx, taskFunc, storeIDs)
|
|
|
|
|
tasksch.HandleTask(taskParallel, task, true).Run()
|
|
|
|
|
storeList, err := taskParallel.GetResult(0)
|
|
|
|
|
for _, v := range storeList {
|
|
|
|
|
if vendorID == model.VendorIDJD {
|
|
|
|
|
storeListJD = append(storeListJD, v.(VendorStoreExcel))
|
|
|
|
|
}
|
|
|
|
|
if vendorID == model.VendorIDEBAI {
|
|
|
|
|
storeListEB = append(storeListEB, v.(VendorStoreExcel))
|
|
|
|
|
}
|
|
|
|
|
if vendorID == model.VendorIDMTWM {
|
|
|
|
|
storeListMT = append(storeListMT, v.(VendorStoreExcel))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case 1:
|
|
|
|
|
WriteToExcelStore(task, storeListJD, storeListMT, storeListEB)
|
|
|
|
|
}
|
|
|
|
|
return result, err
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func WriteToExcelStore(task *tasksch.SeqTask, storeListJD, storeListMT, storeListEB []VendorStoreExcel) (err error) {
|
|
|
|
|
var sheetList []*excel.Obj2ExcelSheetConfig
|
|
|
|
|
var downloadURL, fileName string
|
|
|
|
|
if len(storeListJD) > 0 {
|
|
|
|
|
excelConf := &excel.Obj2ExcelSheetConfig{
|
|
|
|
|
Title: "京东平台",
|
|
|
|
|
Data: storeListJD,
|
|
|
|
|
CaptionList: titleListStore,
|
|
|
|
|
}
|
|
|
|
|
sheetList = append(sheetList, excelConf)
|
|
|
|
|
}
|
|
|
|
|
if len(storeListMT) > 0 {
|
|
|
|
|
excelConf := &excel.Obj2ExcelSheetConfig{
|
|
|
|
|
Title: "饿百平台",
|
|
|
|
|
Data: storeListMT,
|
|
|
|
|
CaptionList: titleListStore,
|
|
|
|
|
}
|
|
|
|
|
sheetList = append(sheetList, excelConf)
|
|
|
|
|
}
|
|
|
|
|
if len(storeListEB) > 0 {
|
|
|
|
|
excelConf := &excel.Obj2ExcelSheetConfig{
|
|
|
|
|
Title: "美团平台",
|
|
|
|
|
Data: storeListEB,
|
|
|
|
|
CaptionList: titleListStore,
|
|
|
|
|
}
|
|
|
|
|
sheetList = append(sheetList, excelConf)
|
|
|
|
|
}
|
|
|
|
|
if len(sheetList) == 0 {
|
|
|
|
|
return errors.New("所选平台没有未营业的门店!")
|
|
|
|
|
} else {
|
|
|
|
|
downloadURL, fileName, err = jxutils.UploadExeclAndPushMsg(sheetList, "各平台未营业门店统计")
|
|
|
|
|
if err != nil {
|
|
|
|
|
baseapi.SugarLogger.Errorf("WriteToExcel:upload %s failed error:%v", fileName, err)
|
|
|
|
|
} else {
|
|
|
|
|
noticeMsg := fmt.Sprintf("[详情点我]path=%s \n", downloadURL)
|
|
|
|
|
task.SetNoticeMsg(noticeMsg)
|
|
|
|
|
baseapi.SugarLogger.Debugf("WriteToExcel:upload %s success, downloadURL:%s", fileName, downloadURL)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func StoreStatus2Chinese(status int) (str string) {
|
|
|
|
|
if status == model.StoreStatusOpened {
|
|
|
|
|
return "正常营业"
|
|
|
|
|
} else if status == model.StoreStatusDisabled {
|
|
|
|
|
return "暂停营业"
|
|
|
|
|
} else if status == model.StoreStatusClosed {
|
|
|
|
|
return "休息中"
|
|
|
|
|
} else {
|
|
|
|
|
return "未知的营业状态"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|