Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cms
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/globals/api/apimanager"
|
||||
@@ -949,6 +950,7 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s
|
||||
}
|
||||
|
||||
func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interface{}, isExd bool) (num int64, err error) {
|
||||
globals.SugarLogger.Debugf("==========payload %s", utils.Format4Output(payload, false))
|
||||
userName := ctx.GetUserName()
|
||||
skuName := &model.SkuName{}
|
||||
skuName.ID = nameID
|
||||
@@ -1024,6 +1026,9 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
globals.SugarLogger.Debugf("UpdateEntityLogically 1 := %s", utils.Format4Output(skuName, false))
|
||||
globals.SugarLogger.Debugf("UpdateEntityLogically 2 := %s", utils.Format4Output(valid, false))
|
||||
globals.SugarLogger.Debugf("UpdateEntityLogically 3 := %s", userName)
|
||||
// valid[model.FieldJdSyncStatus] = model.SyncFlagModifiedMask | skuName.JdSyncStatus
|
||||
if num, err = dao.UpdateEntityLogically(db, skuName, valid, userName, nil); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -1035,6 +1040,7 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
if utils.Interface2Int64WithDefault(payload["isGlobal"], 0) == 0 && payload["places"] != nil {
|
||||
if places, ok := payload["places"].([]interface{}); ok {
|
||||
if _, err = dao.DeleteSkuNamePlace(db, nameID, nil); err != nil {
|
||||
@@ -1080,6 +1086,28 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
||||
return 0, err
|
||||
}
|
||||
if len(skuIDs) > 0 {
|
||||
// 判断是否改价
|
||||
nowPrice, _ := payload["price"].(json.Number).Int64()
|
||||
if skuName.Price != int(nowPrice) && nowPrice != 0 {
|
||||
|
||||
for _, v1 := range payload["skus"].([]interface{}) {
|
||||
v := v1.(map[string]interface{})
|
||||
skuInfo := &aa{}
|
||||
if err := utils.Map2StructByJson(v, skuInfo, false); err != nil {
|
||||
globals.SugarLogger.Debugf("errr %v", err)
|
||||
continue
|
||||
}
|
||||
var skuPrice int64 = 0
|
||||
if payload["unit"] == "份" { // 商品规格等于份的时候,标准重量保持为500g
|
||||
skuPrice = int64(float64(skuInfo.SpecQuality) / float64(500) * float64(nowPrice))
|
||||
} else {
|
||||
skuPrice = nowPrice
|
||||
}
|
||||
SetUpdateSkuPriceIfChange(db, skuPrice, nowPrice, skuInfo.Id)
|
||||
}
|
||||
}
|
||||
|
||||
// 更新skuIds对应在store_sku_bind中的价格体系,解决老版本改价之前关注的商品,在价格修改后,store_sku_bind中京西价未修改的问题
|
||||
if _, err = SetStoreSkuSyncStatus2(db, nil, partner.GetSingleStoreVendorIDs(), skuIDs, model.SyncFlagModifiedMask); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return 0, err
|
||||
@@ -1106,6 +1134,21 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
||||
return num, err
|
||||
}
|
||||
|
||||
type aa struct {
|
||||
Id int `json:"id"`
|
||||
SpecQuality int `json:"specQuality"`
|
||||
SpecUnit string `json:"specUnit"`
|
||||
Weight int `json:"weight"`
|
||||
Status string `json:"status"`
|
||||
Comment string `json:"comment"`
|
||||
MinOrderCount int `json:"minOrderCount"`
|
||||
LadderBoxNum int `json:"ladderBoxNum"`
|
||||
LadderBoxPrice int `json:"ladderBoxPrice"`
|
||||
EclpID string `json:"eclpID"`
|
||||
CategoryID []interface{} `json:"categoryID"`
|
||||
ExdSkuID string `json:"exdSkuID"`
|
||||
}
|
||||
|
||||
func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, nameID int, payload map[string]interface{}, skuNameExt *model.SkuNameExt, isDelete bool) (flag bool) {
|
||||
if isDelete {
|
||||
skuVendorCatMaps, _ := dao.GetSkuVendorCategoryMaps(db, []int{nameID}, nil, nil)
|
||||
@@ -1189,6 +1232,13 @@ func SetStoreSkuSyncStatus2(db *dao.DaoDB, storeIDs []int, vendorIDs, skuIDs []i
|
||||
return num, nil
|
||||
}
|
||||
|
||||
func SetUpdateSkuPriceIfChange(db *dao.DaoDB, skuPrice, nowPrice int64, skuId int) error {
|
||||
sql := ` UPDATE store_sku_bind s SET s.price = ?,s.unit_price = ? WHERE s.sku_id = ? AND s.deleted_at = ?`
|
||||
param := []interface{}{skuPrice, nowPrice, skuId, utils.DefaultTimeValue}
|
||||
_, err := dao.ExecuteSQL(db, sql, param...)
|
||||
return err
|
||||
}
|
||||
|
||||
func UpdateSkuImg(ctx *jxcontext.Context, skuID int, payload map[string]interface{}) (string, error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
|
||||
@@ -1628,9 +1628,11 @@ func DeleteStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
|
||||
}
|
||||
}
|
||||
//删除抖店映射
|
||||
if _, err1 := dao.ExecuteSQL(db, "DELETE FROM freight_template WHERE freight_template.store_id = ? ", storeID); err != nil {
|
||||
//if vendorID == model.VendorIDDD {
|
||||
if _, err1 := dao.ExecuteSQL(db, "DELETE FROM freight_template WHERE freight_template.store_id = ? ", storeID); err1 != nil {
|
||||
err = fmt.Errorf("%v,%v", err, err1)
|
||||
}
|
||||
//}
|
||||
return num, err
|
||||
}
|
||||
|
||||
@@ -4453,6 +4455,7 @@ func RefreshTiktokShopToken(ctx *jxcontext.Context) (err error) {
|
||||
v.UpdatedAt = time.Now()
|
||||
v.StoreBrandName = "定时任务更新"
|
||||
dao.UpdateEntity(db, v, "Token", "UpdatedAt", "StoreBrandName")
|
||||
tiktok_store.HttpToGuoYuan(utils.Struct2MapByJson(v), "token")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,11 +184,9 @@ func SyncStoreSkuNew2(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFla
|
||||
switch step {
|
||||
case 0:
|
||||
if singleStoreHandler != nil {
|
||||
globals.SugarLogger.Debugf("==SyncStoreCategories===")
|
||||
_, err = SyncStoreCategories(ctx, task, vendorID, storeID, vendorStoreID, nameIDs, skuIDs, false, isContinueWhenError)
|
||||
}
|
||||
case 1:
|
||||
globals.SugarLogger.Debugf("==syncStoreSkuNew===")
|
||||
err = syncStoreSkuNew(ctx, task, causeFlag, false, vendorID, storeID, vendorOrgCode, nameIDs, skuIDs, excludeSkuIDs, useVendorPriceDirectly, isContinueWhenError)
|
||||
}
|
||||
return result, err
|
||||
|
||||
Reference in New Issue
Block a user