93 lines
1.8 KiB
Go
93 lines
1.8 KiB
Go
package cms
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"sync"
|
|
)
|
|
|
|
type SyncErrResult struct {
|
|
SkuID int `json:"商品ID"`
|
|
CategoryName string `json:"分类名"`
|
|
StoreID int `json:"门店ID"`
|
|
VendorName string `json:"平台名"`
|
|
VendorSkuID string `json:"平台商品ID"`
|
|
NameID int `json:"商品nameID"`
|
|
VendorPrice int64 `json:"平台价"`
|
|
SyncType string `json:"同步类型"`
|
|
ErrMsg string `json:"错误信息"`
|
|
}
|
|
|
|
type SyncErrResultLock struct {
|
|
syncErrResult []SyncErrResult
|
|
locker sync.RWMutex
|
|
}
|
|
|
|
type LoopStoreMapInfo struct {
|
|
VendorID int
|
|
// StoreMapList []*model.StoreMap
|
|
}
|
|
|
|
type VendorSync struct {
|
|
}
|
|
|
|
type SyncError struct {
|
|
Original error `json:"original"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
type SpecSyncError struct {
|
|
SpecErr error `json:"specErr"`
|
|
}
|
|
|
|
var (
|
|
CurVendorSync VendorSync
|
|
)
|
|
|
|
var (
|
|
ErrHaveNotImplementedYet = errors.New("还没有实现")
|
|
ErrEntityNotExist = errors.New("找不到相应实体")
|
|
SyncErrResultTitle = []string{
|
|
"商品ID",
|
|
"分类名",
|
|
"门店ID",
|
|
"平台名",
|
|
"平台商品ID",
|
|
"商品nameID",
|
|
"平台价",
|
|
"同步类型",
|
|
"错误信息",
|
|
}
|
|
syncErrResultLock SyncErrResultLock
|
|
)
|
|
|
|
func makeSyncError(err error) (newErr error) {
|
|
if err != nil {
|
|
if _, ok := err.(*SyncError); !ok {
|
|
return &SyncError{
|
|
Original: err,
|
|
}
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
func makeSpecSyncError(err error) (newErr error) {
|
|
if err != nil {
|
|
if _, ok := err.(*SpecSyncError); !ok {
|
|
return &SpecSyncError{
|
|
SpecErr: err,
|
|
}
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (e *SpecSyncError) Error() string {
|
|
return e.SpecErr.Error()
|
|
}
|
|
|
|
func (e *SyncError) Error() string {
|
|
return fmt.Sprintf("本地数据修改成功,但同步失败,请根据错误提示处理!,同步错误信息:%s", e.Original.Error())
|
|
}
|