1
This commit is contained in:
@@ -1564,11 +1564,17 @@ func GetStoreBrandInfos(storeID int) (date *BrandInfos, err error) {
|
||||
return detail, err
|
||||
}
|
||||
|
||||
var FreightTemplateMap = make(map[int]*model.FreightTemplate)
|
||||
|
||||
// 查询FreightTemplate
|
||||
func QueryStoreBindInfo(storeID int) (*model.FreightTemplate, error) {
|
||||
if storeID == model.NO {
|
||||
return nil, errors.New("storeId 不能为0")
|
||||
}
|
||||
if _, ok := FreightTemplateMap[storeID]; ok {
|
||||
return FreightTemplateMap[storeID], nil
|
||||
}
|
||||
|
||||
var (
|
||||
sqlParams []interface{}
|
||||
bindInfo *model.FreightTemplate
|
||||
@@ -1579,6 +1585,13 @@ func QueryStoreBindInfo(storeID int) (*model.FreightTemplate, error) {
|
||||
if err := GetRow(GetDB(), &bindInfo, sql, sqlParams...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
FreightTemplateMap[storeID] = bindInfo
|
||||
|
||||
defer func() {
|
||||
if time.Now().Unix()%20*60 == 0 {
|
||||
FreightTemplateMap = nil
|
||||
}
|
||||
}()
|
||||
return bindInfo, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -229,8 +229,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
|
||||
// 创建子商品
|
||||
temp, err := dao.QueryStoreBindInfo(storeDetail.Store.ID)
|
||||
globals.SugarLogger.Debugf("================temp:= %s", utils.Format4Output(temp, false))
|
||||
globals.SugarLogger.Debugf("================storeDetail:= %s", utils.Format4Output(storeDetail, false))
|
||||
if err != nil || temp == nil || temp.ID == 0 {
|
||||
// 运费模板
|
||||
param.FreightId, err = GetDeliveryTemp(api, vendorStoreID, storeDetail)
|
||||
@@ -259,13 +257,10 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
// 运费模板
|
||||
param.FreightId, err = GetDeliveryTemp(api, vendorStoreID, storeDetail)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("=========FreightId=======err:= %s", utils.Format4Output(err, false))
|
||||
return nil, err
|
||||
}
|
||||
temp.TemplateID = param.FreightId
|
||||
globals.SugarLogger.Debugf("================temp:= %s", utils.Format4Output(temp, false))
|
||||
_, err = dao.UpdateEntity(db, temp, "TemplateID")
|
||||
globals.SugarLogger.Debugf("================err:= %s", utils.Format4Output(err, false))
|
||||
}
|
||||
if temp.TradeLimitID != 0 {
|
||||
param.SaleLimitId = temp.TradeLimitID
|
||||
@@ -277,7 +272,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
}
|
||||
temp.TradeLimitID = param.SaleLimitId
|
||||
_, err = dao.UpdateEntity(db, temp, "TradeLimitID")
|
||||
globals.SugarLogger.Debugf("================2err:= %s", utils.Format4Output(err, false))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user