关于饿鲜达商品关注,查询改动
This commit is contained in:
@@ -415,6 +415,14 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku bool, params ma
|
|||||||
sqlParams = append(sqlParams, nameIDs)
|
sqlParams = append(sqlParams, nameIDs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if params["isExd"] != nil {
|
||||||
|
var idExd = params["isExd"].(bool)
|
||||||
|
if idExd {
|
||||||
|
sql += " AND t2.exd_sku_id <> ''"
|
||||||
|
} else {
|
||||||
|
sql += " AND t2.exd_sku_id == ''"
|
||||||
|
}
|
||||||
|
}
|
||||||
if params["categoryID"] != nil {
|
if params["categoryID"] != nil {
|
||||||
cat := &model.SkuCategory{}
|
cat := &model.SkuCategory{}
|
||||||
cat.ID = params["categoryID"].(int)
|
cat.ID = params["categoryID"].(int)
|
||||||
|
|||||||
@@ -82,15 +82,16 @@ type StoreSkuBindInfo struct {
|
|||||||
|
|
||||||
type tStoreSkuBindAndSpec struct {
|
type tStoreSkuBindAndSpec struct {
|
||||||
model.StoreSkuBind
|
model.StoreSkuBind
|
||||||
SkuStatus int
|
SkuStatus int
|
||||||
SkuNameStatus int
|
SkuNameStatus int
|
||||||
Name string
|
Name string
|
||||||
SpecQuality float32
|
SpecQuality float32
|
||||||
SpecUnit string
|
SpecUnit string
|
||||||
SkuNamePrice int
|
SkuNamePrice int
|
||||||
SkuNameUnit string
|
SkuNameUnit string
|
||||||
RealSkuID int `orm:"column(real_sku_id)"`
|
RealSkuID int `orm:"column(real_sku_id)"`
|
||||||
|
ExdSkuID string `orm:"column(exd_sku_id)"`
|
||||||
|
StoreName string
|
||||||
ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核
|
ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,13 +977,13 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
sql := `
|
sql := `
|
||||||
SELECT
|
SELECT
|
||||||
t2.*,
|
t2.*,
|
||||||
t1.id real_sku_id, t1.status sku_status, t1.spec_quality, t1.spec_unit,`
|
t1.id real_sku_id, t1.status sku_status, t1.spec_quality, t1.spec_unit, t1.exd_sku_id,`
|
||||||
if needGetExistingUnitPrice {
|
if needGetExistingUnitPrice {
|
||||||
sql += " IF(t5.unit_price > 0, t5.unit_price, t3.price) sku_name_price,"
|
sql += " IF(t5.unit_price > 0, t5.unit_price, t3.price) sku_name_price,"
|
||||||
}
|
}
|
||||||
sql += `
|
sql += `
|
||||||
t3.unit sku_name_unit, t3.name, t3.status sku_name_status,
|
t3.unit sku_name_unit, t3.name, t3.status sku_name_status,
|
||||||
ts.change_price_type
|
ts.change_price_type, ts.name store_name
|
||||||
FROM sku t1
|
FROM sku t1
|
||||||
JOIN store ts ON ts.id = ? AND ts.deleted_at = ?
|
JOIN store ts ON ts.id = ? AND ts.deleted_at = ?
|
||||||
LEFT JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND t2.store_id = ts.id AND t2.deleted_at = ?
|
LEFT JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND t2.store_id = ts.id AND t2.deleted_at = ?
|
||||||
@@ -1037,41 +1038,43 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
// globals.SugarLogger.Debug(utils.Format4Output(inSkuBind, false))
|
// globals.SugarLogger.Debug(utils.Format4Output(inSkuBind, false))
|
||||||
var skuBind *model.StoreSkuBind
|
var skuBind *model.StoreSkuBind
|
||||||
if v.ID == 0 {
|
if v.ID == 0 {
|
||||||
if skuBindInfo.IsFocus == 1 && v.SkuNameStatus == model.SkuStatusNormal && v.SkuStatus == model.SkuStatusNormal && isCanChangePrice {
|
if !(strings.Contains(v.StoreName, model.ExdStoreName) && v.ExdSkuID == "") {
|
||||||
skuBind = &model.StoreSkuBind{
|
if skuBindInfo.IsFocus == 1 && v.SkuNameStatus == model.SkuStatusNormal && v.SkuStatus == model.SkuStatusNormal && isCanChangePrice {
|
||||||
StoreID: storeID,
|
skuBind = &model.StoreSkuBind{
|
||||||
SkuID: v.RealSkuID,
|
StoreID: storeID,
|
||||||
SubStoreID: skuBindInfo.SubStoreID, // todo 这个应该从用户信息中自动获得
|
SkuID: v.RealSkuID,
|
||||||
UnitPrice: unitPrice,
|
SubStoreID: skuBindInfo.SubStoreID, // todo 这个应该从用户信息中自动获得
|
||||||
Price: jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit),
|
UnitPrice: unitPrice,
|
||||||
Status: model.StoreSkuBindStatusDontSale, // 缺省不可售?
|
Price: jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit),
|
||||||
}
|
Status: model.StoreSkuBindStatusDontSale, // 缺省不可售?
|
||||||
skuBind.JxPrice = jxutils.CaculatePriceByPricePack(storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage), skuBind.Price)
|
|
||||||
if tmpStatus := getSkuSaleStatus(inSkuBind, skuBindInfo); tmpStatus != model.StoreSkuBindStatusNA {
|
|
||||||
skuBind.Status = tmpStatus
|
|
||||||
}
|
|
||||||
if globals.IsAddEvent {
|
|
||||||
err = AddEventDetail(db, ctx, model.OperateAdd, v.RealSkuID, model.ThingTypeSku, storeID, "", "")
|
|
||||||
}
|
|
||||||
setStoreSkuBindStatus(skuBind, model.SyncFlagNewMask)
|
|
||||||
dao.WrapAddIDCULDEntity(skuBind, userName)
|
|
||||||
// globals.SugarLogger.Debug(utils.Format4Output(skuBind, false))
|
|
||||||
if deletedSku := dao.GetDeletedStoreSkuBind(db, skuBind.StoreID, skuBind.SkuID); deletedSku == nil {
|
|
||||||
if err = dao.CreateEntity(db, skuBind); err != nil {
|
|
||||||
dao.Rollback(db)
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
num = 1
|
skuBind.JxPrice = jxutils.CaculatePriceByPricePack(storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage), skuBind.Price)
|
||||||
} else {
|
if tmpStatus := getSkuSaleStatus(inSkuBind, skuBindInfo); tmpStatus != model.StoreSkuBindStatusNA {
|
||||||
// 需要处理,在删除某个门店商品,同步失败的情况下,又把商品重新关注。
|
skuBind.Status = tmpStatus
|
||||||
// 所以统一处理成恢复删除的记录,这样避免问题
|
}
|
||||||
skuBind.ID = deletedSku.ID
|
if globals.IsAddEvent {
|
||||||
// vendorSkuID的赋值意义不大
|
err = AddEventDetail(db, ctx, model.OperateAdd, v.RealSkuID, model.ThingTypeSku, storeID, "", "")
|
||||||
skuBind.MtwmID = deletedSku.MtwmID
|
}
|
||||||
skuBind.EbaiID = deletedSku.EbaiID
|
setStoreSkuBindStatus(skuBind, model.SyncFlagNewMask)
|
||||||
if num, err = dao.UpdateEntity(db, skuBind); err != nil {
|
dao.WrapAddIDCULDEntity(skuBind, userName)
|
||||||
dao.Rollback(db)
|
// globals.SugarLogger.Debug(utils.Format4Output(skuBind, false))
|
||||||
return nil, err
|
if deletedSku := dao.GetDeletedStoreSkuBind(db, skuBind.StoreID, skuBind.SkuID); deletedSku == nil {
|
||||||
|
if err = dao.CreateEntity(db, skuBind); err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
num = 1
|
||||||
|
} else {
|
||||||
|
// 需要处理,在删除某个门店商品,同步失败的情况下,又把商品重新关注。
|
||||||
|
// 所以统一处理成恢复删除的记录,这样避免问题
|
||||||
|
skuBind.ID = deletedSku.ID
|
||||||
|
// vendorSkuID的赋值意义不大
|
||||||
|
skuBind.MtwmID = deletedSku.MtwmID
|
||||||
|
skuBind.EbaiID = deletedSku.EbaiID
|
||||||
|
if num, err = dao.UpdateEntity(db, skuBind); err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ var (
|
|||||||
}
|
}
|
||||||
checkCookieList = []string{
|
checkCookieList = []string{
|
||||||
"08:00:00",
|
"08:00:00",
|
||||||
|
"12:00:00",
|
||||||
"18:00:00",
|
"18:00:00",
|
||||||
}
|
}
|
||||||
createStorePriceTimeList = []string{
|
createStorePriceTimeList = []string{
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ func (c *SkuController) SyncCategory() {
|
|||||||
// @Param skuCategoryID query int false "商品所属类别ID"
|
// @Param skuCategoryID query int false "商品所属类别ID"
|
||||||
// @Param unit query string false "商品单位"
|
// @Param unit query string false "商品单位"
|
||||||
// @Param isSpu query bool false "是否是SPU"
|
// @Param isSpu query bool false "是否是SPU"
|
||||||
|
// @Param isExd query bool false "是否是饿鲜达商品"
|
||||||
// @Param fromStatus query int false "查询起始状态(0:下架,1:正常)"
|
// @Param fromStatus query int false "查询起始状态(0:下架,1:正常)"
|
||||||
// @Param toStatus query int false "查询起始状态(0:下架,1:正常)"
|
// @Param toStatus query int false "查询起始状态(0:下架,1:正常)"
|
||||||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||||||
|
|||||||
Reference in New Issue
Block a user