Merge remote-tracking branch 'origin/mark' into yonghui
This commit is contained in:
@@ -160,6 +160,7 @@ func (s *WatchOrderInfo) updateOrderStoreFeature(order *model.GoodsOrder) (err e
|
|||||||
s.autoPickupTimeoutMinute = int(storeDetail.AutoPickup)
|
s.autoPickupTimeoutMinute = int(storeDetail.AutoPickup)
|
||||||
s.isDeliveryCompetition = storeDetail.DeliveryCompetition != 0
|
s.isDeliveryCompetition = storeDetail.DeliveryCompetition != 0
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debugf("updateOrderStoreFeature2 orderID:%s, isDeliveryCompetition:%t", order.VendorOrderID, s.isDeliveryCompetition)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -659,17 +659,19 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s
|
|||||||
if hasSensitiveWord, err := CheckHasSensitiveWord(skuNameExt.Name); hasSensitiveWord {
|
if hasSensitiveWord, err := CheckHasSensitiveWord(skuNameExt.Name); hasSensitiveWord {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if utils.Pointer2String(skuNameExt.Upc) == "" {
|
||||||
|
skuNameExt.Upc = nil
|
||||||
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if skuNameExt.Upc != "" {
|
// if skuNameExt.Upc != "" {
|
||||||
err = dao.GetEntity(db, &skuNameExt.SkuName, "Upc")
|
// err = dao.GetEntity(db, &skuNameExt.SkuName, "Upc")
|
||||||
if err == nil {
|
// if err == nil {
|
||||||
return nil, fmt.Errorf("UPC:%s重复", skuNameExt.Upc)
|
// return nil, fmt.Errorf("UPC:%s重复", skuNameExt.Upc)
|
||||||
} else if !dao.IsNoRowsError(err) {
|
// } else if !dao.IsNoRowsError(err) {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
err = nil
|
// err = nil
|
||||||
}
|
// }
|
||||||
skuNameExt.SkuName.Status = model.SkuStatusNormal
|
skuNameExt.SkuName.Status = model.SkuStatusNormal
|
||||||
if skuNameExt.IsSpu == 1 {
|
if skuNameExt.IsSpu == 1 {
|
||||||
return nil, fmt.Errorf("不允许创建多规格商品")
|
return nil, fmt.Errorf("不允许创建多规格商品")
|
||||||
@@ -789,19 +791,22 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
|||||||
valid = utils.RemoveGeneralMapKeys(valid, model.FieldSpecQuality, model.FieldSpecUnit)
|
valid = utils.RemoveGeneralMapKeys(valid, model.FieldSpecQuality, model.FieldSpecUnit)
|
||||||
_, hasPlaces := payload["places"]
|
_, hasPlaces := payload["places"]
|
||||||
if len(valid) > 0 || hasPlaces {
|
if len(valid) > 0 || hasPlaces {
|
||||||
|
if upc, _ := valid["Upc"].(string); upc == "" {
|
||||||
|
valid["Upc"] = nil
|
||||||
|
}
|
||||||
globals.SugarLogger.Debugf("UpdateSkuName valid:%s", utils.Format4Output(valid, false))
|
globals.SugarLogger.Debugf("UpdateSkuName valid:%s", utils.Format4Output(valid, false))
|
||||||
if upc, _ := valid["upc"].(string); upc != "" {
|
// if upc, _ := valid["Upc"].(string); upc != "" {
|
||||||
skuName := &model.SkuName{
|
// skuName := &model.SkuName{
|
||||||
Upc: upc,
|
// Upc: upc,
|
||||||
}
|
// }
|
||||||
err = dao.GetEntity(db, skuName, "Upc")
|
// err = dao.GetEntity(db, skuName, "Upc")
|
||||||
if err == nil {
|
// if err == nil {
|
||||||
return 0, fmt.Errorf("UPC:%s重复", upc)
|
// return 0, fmt.Errorf("UPC:%s重复", upc)
|
||||||
} else if !dao.IsNoRowsError(err) {
|
// } else if !dao.IsNoRowsError(err) {
|
||||||
return 0, err
|
// return 0, err
|
||||||
}
|
// }
|
||||||
err = nil
|
// err = nil
|
||||||
}
|
// }
|
||||||
for _, imgName := range []string{"img", "img2"} {
|
for _, imgName := range []string{"img", "img2"} {
|
||||||
if valid[imgName] != nil {
|
if valid[imgName] != nil {
|
||||||
if imgStr := utils.Interface2String(valid[imgName]); imgStr != "" {
|
if imgStr := utils.Interface2String(valid[imgName]); imgStr != "" {
|
||||||
|
|||||||
@@ -1021,11 +1021,24 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
setStoreSkuBindStatus(skuBind, model.SyncFlagNewMask)
|
setStoreSkuBindStatus(skuBind, model.SyncFlagNewMask)
|
||||||
dao.WrapAddIDCULDEntity(skuBind, userName)
|
dao.WrapAddIDCULDEntity(skuBind, userName)
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(skuBind, false))
|
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 {
|
if err = dao.CreateEntity(db, skuBind); err != nil {
|
||||||
dao.Rollback(db)
|
dao.Rollback(db)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
num = 1
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
skuBind = &v.StoreSkuBind
|
skuBind = &v.StoreSkuBind
|
||||||
|
|||||||
@@ -204,25 +204,25 @@ func QueryActs(db *DaoDB, actID int, offset, pageSize int, syncStatus int, keywo
|
|||||||
SELECT
|
SELECT
|
||||||
t1.*,
|
t1.*,
|
||||||
t2.id map_id, t2.vendor_id, t2.vendor_act_id, t2.sync_status, t2.remark map_remark
|
t2.id map_id, t2.vendor_id, t2.vendor_act_id, t2.sync_status, t2.remark map_remark
|
||||||
FROM act t1
|
FROM act t1`
|
||||||
LEFT JOIN act_map t2 ON t2.act_id = t1.id AND t2.deleted_at = ?`
|
}
|
||||||
sqlParams = []interface{}{utils.DefaultTimeValue}
|
sql += " LEFT JOIN act_map t2 ON t2.act_id = t1.id AND t2.deleted_at = ?"
|
||||||
|
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||||
if syncStatus >= 0 {
|
if syncStatus >= 0 {
|
||||||
sql += " AND (t2.sync_status = ? OR t2.sync_status & ? <> 0)"
|
sql += " AND (t2.sync_status = ? OR t2.sync_status & ? <> 0)"
|
||||||
sqlParams = append(sqlParams, syncStatus, syncStatus)
|
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)
|
|
||||||
}
|
|
||||||
sql += `
|
sql += `
|
||||||
WHERE t1.deleted_at = ?`
|
WHERE t1.deleted_at = ?`
|
||||||
|
if syncStatus >= 0 {
|
||||||
|
sql += " AND t2.id IS NOT NULL"
|
||||||
|
}
|
||||||
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||||
keywordInt := int64(0)
|
keywordInt := int64(0)
|
||||||
if keyword != "" {
|
if keyword != "" {
|
||||||
keywordLike := "%" + keyword + "%"
|
keywordLike := "%" + keyword + "%"
|
||||||
sql += " AND ( t1.name LIKE ? OR t1.advertising LIKE ? OR t1.remark LIKE ?"
|
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)
|
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike)
|
||||||
keywordInt = utils.Str2Int64WithDefault(keyword, 0)
|
keywordInt = utils.Str2Int64WithDefault(keyword, 0)
|
||||||
if keywordInt > 0 {
|
if keywordInt > 0 {
|
||||||
sql += `
|
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
|
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
|
FROM act t1
|
||||||
LEFT JOIN act_map t2 ON t2.act_id = t1.id AND t2.deleted_at = ?
|
LEFT JOIN act_map t2 ON t2.act_id = t1.id AND t2.deleted_at = ?
|
||||||
WHERE t1.id IN (` + GenQuestionMarks(len(idList)) + `)
|
WHERE t1.id IN (` + GenQuestionMarks(len(idList)) + `)`
|
||||||
ORDER BY t1.id DESC, t2.vendor_id
|
if syncStatus >= 0 {
|
||||||
`
|
sql += " AND t2.id IS NOT NULL"
|
||||||
|
}
|
||||||
|
sql += `
|
||||||
|
ORDER BY t1.id DESC, t2.vendor_id`
|
||||||
sqlParams = []interface{}{
|
sqlParams = []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
idList,
|
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,
|
IF(t3.jx_sku_id > 0, t3.jx_sku_id, t3.sku_id) sku_id,
|
||||||
t3.count sku_count2,
|
t3.count sku_count2,
|
||||||
t3.shop_price sku_shop_price,
|
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.sale_price sku_sale_price,
|
||||||
t3.sku_name`
|
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 {
|
if actStoreSku := actStoreSkuMap4EarningPrice.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil {
|
||||||
v.EarningPrice = int(actStoreSku.EarningPrice)
|
v.EarningPrice = int(actStoreSku.EarningPrice)
|
||||||
v.EarningActID = actStoreSku.ActID
|
v.EarningActID = actStoreSku.ActID
|
||||||
} else if v.EarningPrice == 0 {
|
} else {
|
||||||
v.EarningPrice = int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.BindPrice), skuName.PayPercentage))
|
earningPrice := int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.BindPrice), skuName.PayPercentage))
|
||||||
|
if earningPrice < v.EbaiPrice {
|
||||||
|
v.EarningPrice = earningPrice
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1328,3 +1331,18 @@ func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesI
|
|||||||
}
|
}
|
||||||
return err
|
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))
|
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
|
ModelIDCULD
|
||||||
|
|
||||||
Prefix string `orm:"size(255)" json:"prefix"`
|
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"`
|
ExPrefix string `orm:"size(255)" json:"exPrefix"`
|
||||||
|
|
||||||
ExPrefixBegin *time.Time `orm:"null" json:"exPrefixBegin"`
|
ExPrefixBegin *time.Time `orm:"null" json:"exPrefixBegin"`
|
||||||
@@ -193,7 +193,7 @@ type SkuName struct {
|
|||||||
DescImg string `orm:"size(255)" json:"descImg"` // 商品详情图片描述
|
DescImg string `orm:"size(255)" json:"descImg"` // 商品详情图片描述
|
||||||
// DescImgEbai string `orm:"size(255)" json:"descImgEbai"` // 饿百的商品详情图片描述RTF
|
// DescImgEbai string `orm:"size(255)" json:"descImgEbai"` // 饿百的商品详情图片描述RTF
|
||||||
|
|
||||||
Upc string `orm:"size(20);index"`
|
Upc *string `orm:"size(20)"`
|
||||||
Status int `orm:"default(1)" json:"status"` // skuname状态,取值同sku.Status
|
Status int `orm:"default(1)" json:"status"` // skuname状态,取值同sku.Status
|
||||||
IsSpu int8 `orm:"column(is_spu)" json:"isSpu"` // 用于指明是否SKUNAME当成SPU
|
IsSpu int8 `orm:"column(is_spu)" json:"isSpu"` // 用于指明是否SKUNAME当成SPU
|
||||||
|
|
||||||
@@ -206,6 +206,7 @@ type SkuName struct {
|
|||||||
func (*SkuName) TableUnique() [][]string {
|
func (*SkuName) TableUnique() [][]string {
|
||||||
return [][]string{
|
return [][]string{
|
||||||
[]string{"Name", "Prefix", "SpecQuality", "SpecUnit", "Unit", "IsSpu", "DeletedAt"},
|
[]string{"Name", "Prefix", "SpecQuality", "SpecUnit", "Unit", "IsSpu", "DeletedAt"},
|
||||||
|
[]string{"Upc", "DeletedAt"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
|||||||
OrderCreatedAt: getTimeFromInterface(orderMap["create_time"]),
|
OrderCreatedAt: getTimeFromInterface(orderMap["create_time"]),
|
||||||
OriginalData: string(utils.MustMarshal(result)),
|
OriginalData: string(utils.MustMarshal(result)),
|
||||||
ActualPayPrice: utils.ForceInterface2Int64(orderMap["user_fee"]),
|
ActualPayPrice: utils.ForceInterface2Int64(orderMap["user_fee"]),
|
||||||
BaseFreightMoney: utils.ForceInterface2Int64(result["send_fee"]),
|
BaseFreightMoney: utils.ForceInterface2Int64(orderMap["send_fee"]),
|
||||||
TotalShopMoney: utils.ForceInterface2Int64(orderMap["shop_fee"]),
|
TotalShopMoney: utils.ForceInterface2Int64(orderMap["shop_fee"]),
|
||||||
DeliveryType: mapDeliveryType(int(utils.ForceInterface2Int64(orderMap["delivery_party"]))),
|
DeliveryType: mapDeliveryType(int(utils.ForceInterface2Int64(orderMap["delivery_party"]))),
|
||||||
|
|
||||||
|
|||||||
@@ -92,5 +92,17 @@ func FilterMapByFieldList(mapData map[string]interface{}, fields []string) (vali
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsValueEqual(value1, value2 interface{}) bool {
|
func IsValueEqual(value1, value2 interface{}) bool {
|
||||||
return fmt.Sprint(value1) == fmt.Sprint(value2)
|
if value1 == nil || value2 == nil {
|
||||||
|
return value1 == value2
|
||||||
|
}
|
||||||
|
return Interface2String(value1) == Interface2String(value2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Interface2String(value interface{}) (str string) {
|
||||||
|
valueType := reflect.TypeOf(value)
|
||||||
|
if valueType.Kind() == reflect.Ptr {
|
||||||
|
value = reflect.ValueOf(value).Elem()
|
||||||
|
}
|
||||||
|
str = fmt.Sprint(value)
|
||||||
|
return str
|
||||||
}
|
}
|
||||||
|
|||||||
37
globals/refutil/refutil_test.go
Normal file
37
globals/refutil/refutil_test.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package refutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsValueEqual(t *testing.T) {
|
||||||
|
for _, v := range [][]interface{}{
|
||||||
|
[]interface{}{
|
||||||
|
false,
|
||||||
|
1,
|
||||||
|
"1.0",
|
||||||
|
},
|
||||||
|
[]interface{}{
|
||||||
|
true,
|
||||||
|
"1",
|
||||||
|
utils.String2Pointer("1"),
|
||||||
|
},
|
||||||
|
[]interface{}{
|
||||||
|
true,
|
||||||
|
"1",
|
||||||
|
1,
|
||||||
|
},
|
||||||
|
[]interface{}{
|
||||||
|
true,
|
||||||
|
int64(100),
|
||||||
|
int(100),
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
result := IsValueEqual(v[1], v[2])
|
||||||
|
if result != v[0].(bool) {
|
||||||
|
t.Fatalf("%v,%v, desired:%v, get:%v", v[1], v[2], v[0], result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user