- 调整dao中的函数分布,将门店相关的都移到store中
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/refutil"
|
"git.rosy.net.cn/jx-callback/globals/refutil"
|
||||||
"github.com/astaxie/beego/orm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type KVUpdateItem struct {
|
type KVUpdateItem struct {
|
||||||
@@ -137,106 +136,3 @@ func DeleteEntityLogically(db *DaoDB, item interface{}, kvs map[string]interface
|
|||||||
model.FieldDeletedAt: time.Now(),
|
model.FieldDeletedAt: time.Now(),
|
||||||
}), userName, conditions)
|
}), userName, conditions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddStoreCategoryMap(db *DaoDB, storeID, categoryID int, vendorID int, vendorCategoryID string, status int8, userName string) (err error) {
|
|
||||||
storeCat := &model.StoreSkuCategoryMap{
|
|
||||||
StoreID: storeID,
|
|
||||||
CategoryID: categoryID,
|
|
||||||
MtwmSyncStatus: model.SyncFlagNewMask,
|
|
||||||
EbaiSyncStatus: model.SyncFlagNewMask,
|
|
||||||
WscSyncStatus: model.SyncFlagNewMask,
|
|
||||||
}
|
|
||||||
storeCat.DeletedAt = utils.DefaultTimeValue
|
|
||||||
if err = GetEntity(db, storeCat, model.FieldStoreID, model.FieldCategoryID, model.FieldDeletedAt); err != nil && err != orm.ErrNoRows {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if vendorID == model.VendorIDMTWM {
|
|
||||||
storeCat.MtwmID = vendorCategoryID
|
|
||||||
storeCat.MtwmSyncStatus = status
|
|
||||||
} else if vendorID == model.VendorIDEBAI || vendorID == model.VendorIDWSC {
|
|
||||||
intVendorCategoryID := utils.Str2Int64WithDefault(vendorCategoryID, 0)
|
|
||||||
if vendorID == model.VendorIDEBAI {
|
|
||||||
storeCat.EbaiID = intVendorCategoryID
|
|
||||||
storeCat.EbaiSyncStatus = status
|
|
||||||
} else {
|
|
||||||
storeCat.WscID = intVendorCategoryID
|
|
||||||
storeCat.WscSyncStatus = status
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
panic("unsupported vendor")
|
|
||||||
}
|
|
||||||
if storeCat.ID == 0 {
|
|
||||||
WrapAddIDCULDEntity(storeCat, userName)
|
|
||||||
err = CreateEntity(db, storeCat)
|
|
||||||
} else {
|
|
||||||
WrapUpdateULEntity(storeCat, userName)
|
|
||||||
_, err = UpdateEntity(db, storeCat)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetStoreMapByStoreID(db *DaoDB, storeID, vendorID int) (storeMap *model.StoreMap, err error) {
|
|
||||||
if db == nil {
|
|
||||||
db = GetDB()
|
|
||||||
}
|
|
||||||
storeMap = &model.StoreMap{
|
|
||||||
StoreID: storeID,
|
|
||||||
VendorID: vendorID,
|
|
||||||
}
|
|
||||||
storeMap.DeletedAt = utils.DefaultTimeValue
|
|
||||||
if err = GetEntity(db, storeMap, model.FieldStoreID, model.FieldVendorID, model.FieldDeletedAt); err != nil {
|
|
||||||
if err != orm.ErrNoRows {
|
|
||||||
globals.SugarLogger.Warnf("GetStoreMapByStoreID storeID:%d, vendorID:%d read storeMap failed with error:%v", storeID, vendorID, err)
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return storeMap, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func FakeGetStoreMapByStoreID(db *DaoDB, storeID, vendorID int) (storeMap *model.StoreMap, err error) {
|
|
||||||
vendorID2 := vendorID
|
|
||||||
if vendorID == model.VendorIDWSC {
|
|
||||||
vendorID2 = model.VendorIDJD // 微商城的属性以京东属性为准(以免再绑定)
|
|
||||||
}
|
|
||||||
if storeMap, err = GetStoreMapByStoreID(db, storeID, vendorID2); vendorID == model.VendorIDWSC && IsNoRowsError(err) {
|
|
||||||
err = nil
|
|
||||||
storeMap = &model.StoreMap{
|
|
||||||
StoreID: storeID,
|
|
||||||
VendorID: vendorID2,
|
|
||||||
Status: model.StoreStatusOpened,
|
|
||||||
PricePercentage: 100,
|
|
||||||
AutoPickup: 1,
|
|
||||||
DeliveryType: model.StoreDeliveryTypeByStore,
|
|
||||||
// DeliveryFee
|
|
||||||
DeliveryCompetition: 1,
|
|
||||||
IsSync: 1,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return storeMap, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetOpenedStoreCouriersByStoreID(db *DaoDB, storeID, vendorID int) (storeMaps []*model.StoreCourierMap, err error) {
|
|
||||||
if db == nil {
|
|
||||||
db = GetDB()
|
|
||||||
}
|
|
||||||
if err = utils.CallFuncLogError(func() error {
|
|
||||||
sql := `
|
|
||||||
SELECT *
|
|
||||||
FROM store_courier_map
|
|
||||||
WHERE store_id = ? AND status = ? AND deleted_at = ?
|
|
||||||
`
|
|
||||||
sqlParams := []interface{}{
|
|
||||||
storeID,
|
|
||||||
model.StoreStatusOpened,
|
|
||||||
utils.DefaultTimeValue,
|
|
||||||
}
|
|
||||||
if vendorID != -1 {
|
|
||||||
sql += " AND vendor_id = ?"
|
|
||||||
sqlParams = append(sqlParams, vendorID)
|
|
||||||
}
|
|
||||||
return GetRows(db, &storeMaps, sql, sqlParams...)
|
|
||||||
}, "GetStoreCouriersByStoreID storeID:%d, vendorID:%d", storeID, vendorID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return storeMaps, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import (
|
|||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"github.com/astaxie/beego/orm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 带购物平台信息的
|
// 带购物平台信息的
|
||||||
@@ -39,6 +41,7 @@ type StoreDetail2 struct {
|
|||||||
VendorStoreID string `orm:"column(vendor_store_id)" json:"vendorStoreID"`
|
VendorStoreID string `orm:"column(vendor_store_id)" json:"vendorStoreID"`
|
||||||
DistrictName string `json:"districtName"`
|
DistrictName string `json:"districtName"`
|
||||||
CityName string `json:"cityName"`
|
CityName string `json:"cityName"`
|
||||||
|
AuditStatus int `json:"auditStatus"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StoreDetail) GetPricePerentage(price int) (pricePercentage int) {
|
func (s *StoreDetail) GetPricePerentage(price int) (pricePercentage int) {
|
||||||
@@ -331,3 +334,106 @@ func PricePercentagePack2Obj(packStr string) (obj model.PricePercentagePack) {
|
|||||||
}
|
}
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AddStoreCategoryMap(db *DaoDB, storeID, categoryID int, vendorID int, vendorCategoryID string, status int8, userName string) (err error) {
|
||||||
|
storeCat := &model.StoreSkuCategoryMap{
|
||||||
|
StoreID: storeID,
|
||||||
|
CategoryID: categoryID,
|
||||||
|
MtwmSyncStatus: model.SyncFlagNewMask,
|
||||||
|
EbaiSyncStatus: model.SyncFlagNewMask,
|
||||||
|
WscSyncStatus: model.SyncFlagNewMask,
|
||||||
|
}
|
||||||
|
storeCat.DeletedAt = utils.DefaultTimeValue
|
||||||
|
if err = GetEntity(db, storeCat, model.FieldStoreID, model.FieldCategoryID, model.FieldDeletedAt); err != nil && err != orm.ErrNoRows {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if vendorID == model.VendorIDMTWM {
|
||||||
|
storeCat.MtwmID = vendorCategoryID
|
||||||
|
storeCat.MtwmSyncStatus = status
|
||||||
|
} else if vendorID == model.VendorIDEBAI || vendorID == model.VendorIDWSC {
|
||||||
|
intVendorCategoryID := utils.Str2Int64WithDefault(vendorCategoryID, 0)
|
||||||
|
if vendorID == model.VendorIDEBAI {
|
||||||
|
storeCat.EbaiID = intVendorCategoryID
|
||||||
|
storeCat.EbaiSyncStatus = status
|
||||||
|
} else {
|
||||||
|
storeCat.WscID = intVendorCategoryID
|
||||||
|
storeCat.WscSyncStatus = status
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
panic("unsupported vendor")
|
||||||
|
}
|
||||||
|
if storeCat.ID == 0 {
|
||||||
|
WrapAddIDCULDEntity(storeCat, userName)
|
||||||
|
err = CreateEntity(db, storeCat)
|
||||||
|
} else {
|
||||||
|
WrapUpdateULEntity(storeCat, userName)
|
||||||
|
_, err = UpdateEntity(db, storeCat)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStoreMapByStoreID(db *DaoDB, storeID, vendorID int) (storeMap *model.StoreMap, err error) {
|
||||||
|
if db == nil {
|
||||||
|
db = GetDB()
|
||||||
|
}
|
||||||
|
storeMap = &model.StoreMap{
|
||||||
|
StoreID: storeID,
|
||||||
|
VendorID: vendorID,
|
||||||
|
}
|
||||||
|
storeMap.DeletedAt = utils.DefaultTimeValue
|
||||||
|
if err = GetEntity(db, storeMap, model.FieldStoreID, model.FieldVendorID, model.FieldDeletedAt); err != nil {
|
||||||
|
if err != orm.ErrNoRows {
|
||||||
|
globals.SugarLogger.Warnf("GetStoreMapByStoreID storeID:%d, vendorID:%d read storeMap failed with error:%v", storeID, vendorID, err)
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return storeMap, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func FakeGetStoreMapByStoreID(db *DaoDB, storeID, vendorID int) (storeMap *model.StoreMap, err error) {
|
||||||
|
vendorID2 := vendorID
|
||||||
|
if vendorID == model.VendorIDWSC {
|
||||||
|
vendorID2 = model.VendorIDJD // 微商城的属性以京东属性为准(以免再绑定)
|
||||||
|
}
|
||||||
|
if storeMap, err = GetStoreMapByStoreID(db, storeID, vendorID2); vendorID == model.VendorIDWSC && IsNoRowsError(err) {
|
||||||
|
err = nil
|
||||||
|
storeMap = &model.StoreMap{
|
||||||
|
StoreID: storeID,
|
||||||
|
VendorID: vendorID2,
|
||||||
|
Status: model.StoreStatusOpened,
|
||||||
|
PricePercentage: 100,
|
||||||
|
AutoPickup: 1,
|
||||||
|
DeliveryType: model.StoreDeliveryTypeByStore,
|
||||||
|
// DeliveryFee
|
||||||
|
DeliveryCompetition: 1,
|
||||||
|
IsSync: 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return storeMap, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOpenedStoreCouriersByStoreID(db *DaoDB, storeID, vendorID int) (storeMaps []*model.StoreCourierMap, err error) {
|
||||||
|
if db == nil {
|
||||||
|
db = GetDB()
|
||||||
|
}
|
||||||
|
if err = utils.CallFuncLogError(func() error {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM store_courier_map
|
||||||
|
WHERE store_id = ? AND status = ? AND deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
storeID,
|
||||||
|
model.StoreStatusOpened,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if vendorID != -1 {
|
||||||
|
sql += " AND vendor_id = ?"
|
||||||
|
sqlParams = append(sqlParams, vendorID)
|
||||||
|
}
|
||||||
|
return GetRows(db, &storeMaps, sql, sqlParams...)
|
||||||
|
}, "GetStoreCouriersByStoreID storeID:%d, vendorID:%d", storeID, vendorID); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return storeMaps, nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user