Merge remote-tracking branch 'origin/mark' into yonghui
This commit is contained in:
@@ -204,25 +204,25 @@ func QueryActs(db *DaoDB, actID int, offset, pageSize int, syncStatus int, keywo
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.id map_id, t2.vendor_id, t2.vendor_act_id, t2.sync_status, t2.remark map_remark
|
||||
FROM act t1
|
||||
LEFT JOIN act_map t2 ON t2.act_id = t1.id AND t2.deleted_at = ?`
|
||||
sqlParams = []interface{}{utils.DefaultTimeValue}
|
||||
if syncStatus >= 0 {
|
||||
sql += " AND (t2.sync_status = ? OR t2.sync_status & ? <> 0)"
|
||||
sqlParams = append(sqlParams, syncStatus, syncStatus)
|
||||
}
|
||||
} else if syncStatus >= 0 {
|
||||
sql += " JOIN act_map t2 ON t2.act_id = t1.id AND t2.deleted_at = ? AND (t2.sync_status = ? OR t2.sync_status & ? <> 0)"
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue, syncStatus, syncStatus)
|
||||
FROM act t1`
|
||||
}
|
||||
sql += " LEFT JOIN act_map t2 ON t2.act_id = t1.id AND t2.deleted_at = ?"
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||
if syncStatus >= 0 {
|
||||
sql += " AND (t2.sync_status = ? OR t2.sync_status & ? <> 0)"
|
||||
sqlParams = append(sqlParams, syncStatus, syncStatus)
|
||||
}
|
||||
sql += `
|
||||
WHERE t1.deleted_at = ?`
|
||||
if syncStatus >= 0 {
|
||||
sql += " AND t2.id IS NOT NULL"
|
||||
}
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||
keywordInt := int64(0)
|
||||
if keyword != "" {
|
||||
keywordLike := "%" + keyword + "%"
|
||||
sql += " AND ( t1.name LIKE ? OR t1.advertising LIKE ? OR t1.remark LIKE ?"
|
||||
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike)
|
||||
sql += " AND ( t1.name LIKE ? OR t1.advertising LIKE ? OR t1.remark LIKE ? OR t2.vendor_act_id LIKE ?"
|
||||
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike)
|
||||
keywordInt = utils.Str2Int64WithDefault(keyword, 0)
|
||||
if keywordInt > 0 {
|
||||
sql += `
|
||||
@@ -321,9 +321,12 @@ func QueryActs(db *DaoDB, actID int, offset, pageSize int, syncStatus int, keywo
|
||||
t2.id map_id, t2.vendor_id, t2.vendor_org_code, t2.vendor_act_id, t2.sync_status, t2.remark map_remark
|
||||
FROM act t1
|
||||
LEFT JOIN act_map t2 ON t2.act_id = t1.id AND t2.deleted_at = ?
|
||||
WHERE t1.id IN (` + GenQuestionMarks(len(idList)) + `)
|
||||
ORDER BY t1.id DESC, t2.vendor_id
|
||||
`
|
||||
WHERE t1.id IN (` + GenQuestionMarks(len(idList)) + `)`
|
||||
if syncStatus >= 0 {
|
||||
sql += " AND t2.id IS NOT NULL"
|
||||
}
|
||||
sql += `
|
||||
ORDER BY t1.id DESC, t2.vendor_id`
|
||||
sqlParams = []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
idList,
|
||||
|
||||
@@ -734,7 +734,7 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat
|
||||
IF(t3.jx_sku_id > 0, t3.jx_sku_id, t3.sku_id) sku_id,
|
||||
t3.count sku_count2,
|
||||
t3.shop_price sku_shop_price,
|
||||
t3.earning_price sku_earning_price,
|
||||
IF(t3.store_sub_id = 0, 0, t3.earning_price) sku_earning_price,
|
||||
t3.sale_price sku_sale_price,
|
||||
t3.sku_name`
|
||||
}
|
||||
|
||||
@@ -1318,8 +1318,11 @@ func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesI
|
||||
if actStoreSku := actStoreSkuMap4EarningPrice.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil {
|
||||
v.EarningPrice = int(actStoreSku.EarningPrice)
|
||||
v.EarningActID = actStoreSku.ActID
|
||||
} else if v.EarningPrice == 0 {
|
||||
v.EarningPrice = int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.BindPrice), skuName.PayPercentage))
|
||||
} else {
|
||||
earningPrice := int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.BindPrice), skuName.PayPercentage))
|
||||
if earningPrice < v.EbaiPrice {
|
||||
v.EarningPrice = earningPrice
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1328,3 +1331,18 @@ func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesI
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func GetDeletedStoreSkuBind(db *DaoDB, storeID, skuID int) (storeSkuBind *model.StoreSkuBind) {
|
||||
sql := `
|
||||
SELECT a.*
|
||||
FROM store_sku_bind a
|
||||
WHERE a.store_id = ? AND a.sku_id = ?
|
||||
ORDER BY a.deleted_at DESC`
|
||||
sqlParams := []interface{}{
|
||||
storeID, skuID,
|
||||
}
|
||||
if err := GetRow(db, &storeSkuBind, sql, sqlParams...); err != nil {
|
||||
storeSkuBind = nil
|
||||
}
|
||||
return storeSkuBind
|
||||
}
|
||||
|
||||
@@ -23,3 +23,8 @@ func TestGetStoreSkus(t *testing.T) {
|
||||
}
|
||||
globals.SugarLogger.Debug(utils.Format4Output(skuList, false))
|
||||
}
|
||||
|
||||
func TestGetDeletedStoreSkuBind(t *testing.T) {
|
||||
storeSkuBind := GetDeletedStoreSkuBind(GetDB(), 100123, 30648)
|
||||
globals.SugarLogger.Debug(utils.Format4Output(storeSkuBind, false))
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ type SkuName struct {
|
||||
ModelIDCULD
|
||||
|
||||
Prefix string `orm:"size(255)" json:"prefix"`
|
||||
Name string `orm:"size(255);index" json:"name"`
|
||||
Name string `orm:"size(255)" json:"name"`
|
||||
ExPrefix string `orm:"size(255)" json:"exPrefix"`
|
||||
|
||||
ExPrefixBegin *time.Time `orm:"null" json:"exPrefixBegin"`
|
||||
@@ -193,9 +193,9 @@ type SkuName struct {
|
||||
DescImg string `orm:"size(255)" json:"descImg"` // 商品详情图片描述
|
||||
// DescImgEbai string `orm:"size(255)" json:"descImgEbai"` // 饿百的商品详情图片描述RTF
|
||||
|
||||
Upc string `orm:"size(20);index"`
|
||||
Status int `orm:"default(1)" json:"status"` // skuname状态,取值同sku.Status
|
||||
IsSpu int8 `orm:"column(is_spu)" json:"isSpu"` // 用于指明是否SKUNAME当成SPU
|
||||
Upc *string `orm:"size(20)"`
|
||||
Status int `orm:"default(1)" json:"status"` // skuname状态,取值同sku.Status
|
||||
IsSpu int8 `orm:"column(is_spu)" json:"isSpu"` // 用于指明是否SKUNAME当成SPU
|
||||
|
||||
JdID int64 `orm:"column(jd_id);null;index" json:"jdID"`
|
||||
JdSyncStatus int8 `orm:"default(2)" json:"jdSyncStatus"`
|
||||
@@ -206,6 +206,7 @@ type SkuName struct {
|
||||
func (*SkuName) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"Name", "Prefix", "SpecQuality", "SpecUnit", "Unit", "IsSpu", "DeletedAt"},
|
||||
[]string{"Upc", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user