|
|
|
|
@@ -128,7 +128,7 @@ func (P *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
|
|
|
|
//必须先存进数据库
|
|
|
|
|
|
|
|
|
|
vendorStoreIDs = utils.Int64ToStr(resp.ResultList[0].Store.StoreId)
|
|
|
|
|
if err := CreateOrUpdateAll(storeDetail.VendorOrgCode, int64(storeDetail.Store.ID), resp.ResultList[0].Store.StoreId); err != nil {
|
|
|
|
|
if err := CreateOrUpdateAll(storeDetail.VendorOrgCode, int64(storeDetail.Store.ID), resp.ResultList[0].Store.StoreId, int64(storeDetail.DeliveryFeeDeductionFee), utils.Str2Int64(storeDetail.YbStorePrefix)); err != nil {
|
|
|
|
|
errList.AddErr(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -136,8 +136,8 @@ func (P *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
|
|
|
|
return vendorStoreIDs, errors.New(fmt.Sprintf("创建抖店平台店铺相关错误信息:%v", endErr))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//电子围栏 仓库 运费模板 限售模板 更新与绑定
|
|
|
|
|
func CreateOrUpdateAll(vendorOrgCode string, storeID, vendorStoreID int64) error {
|
|
|
|
|
//电子围栏 仓库 运费模板 限售模板 打包费 更新与绑定
|
|
|
|
|
func CreateOrUpdateAll(vendorOrgCode string, storeID, vendorStoreID, deliveryFeeDeductionFee, minPrice int64) error {
|
|
|
|
|
var (
|
|
|
|
|
errList = errlist.New()
|
|
|
|
|
FreightTemplate = &model.FreightTemplate{}
|
|
|
|
|
@@ -218,32 +218,36 @@ func CreateOrUpdateAll(vendorOrgCode string, storeID, vendorStoreID int64) error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//3.平台获取限售模板
|
|
|
|
|
SaleLimitID, err := GetStoreSaleLimit(vendorOrgCode, vendorStoreID)
|
|
|
|
|
bindSaleLimitID, err := GetStoreSaleLimit(vendorOrgCode, vendorStoreID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
globals.SugarLogger.Debugf("获取门店(%d) 限售模板出错:%v", vendorStoreID, err)
|
|
|
|
|
errList.AddErr(fmt.Errorf("获取门店(%d) 限售模板出错:%v", vendorStoreID, err))
|
|
|
|
|
globals.SugarLogger.Debugf("获取门店(%d) 限售模板失败:%v", vendorStoreID, err)
|
|
|
|
|
errList.AddErr(fmt.Errorf("获取门店(%d) 限售模板失败:%v", vendorStoreID, err))
|
|
|
|
|
}
|
|
|
|
|
if SaleLimitID == 0 || utils.IsNil(SaleLimitID) { //未绑定限售模板
|
|
|
|
|
if tradeLimitID, err := CreateTradeLimitTemplate(vendorOrgCode, storeID); err != nil || tradeLimitID == 0 || utils.IsNil(tradeLimitID) {
|
|
|
|
|
globals.SugarLogger.Debugf("门店(%d) 创建限售模板失败:%v", storeID, err)
|
|
|
|
|
errList.AddErr(fmt.Errorf("门店(%d) 创建限售模板失败:%v", storeID, err))
|
|
|
|
|
if bindSaleLimitID == 0 || utils.IsNil(bindSaleLimitID) { //未绑定限售模板,目前默认创建起送价限售模板
|
|
|
|
|
if createSaleLimitID, err := CreateAndBindMinPriceTemplate(vendorOrgCode, vendorStoreID, minPrice); err != nil {
|
|
|
|
|
errList.AddErr(fmt.Errorf("设置门店起送价限售模板失败:%v", err))
|
|
|
|
|
} else {
|
|
|
|
|
if err := BindStoreSaleLimit(vendorOrgCode, vendorStoreID, tradeLimitID); err != nil {
|
|
|
|
|
globals.SugarLogger.Debugf("门店(%d) 创建限售模板失败:%v", storeID, err)
|
|
|
|
|
errList.AddErr(fmt.Errorf("门店(%d) 创建限售模板失败:%v", storeID, err))
|
|
|
|
|
} else {
|
|
|
|
|
FreightTemplate.TradeLimitID = tradeLimitID
|
|
|
|
|
}
|
|
|
|
|
FreightTemplate.TradeLimitID = createSaleLimitID
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if updateSaleLimitID, err := UpdateTradeLimitTemplate(vendorOrgCode, bindSaleLimitID, minPrice); err != nil {
|
|
|
|
|
errList.AddErr(fmt.Errorf("更新门店起送价限售模板失败:%v", err))
|
|
|
|
|
} else {
|
|
|
|
|
FreightTemplate.TradeLimitID = updateSaleLimitID
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//4.同步进数据库
|
|
|
|
|
//4. 设置门店打包费 默认为0
|
|
|
|
|
if err := SetStorePackageFee(vendorOrgCode, vendorStoreID, deliveryFeeDeductionFee); err != nil {
|
|
|
|
|
errList.AddErr(fmt.Errorf("设置门店打包费失败:%v", err))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//5.同步进数据库
|
|
|
|
|
FreightTemplate.DeletedAt = utils.DefaultTimeValue
|
|
|
|
|
FreightTemplate = &model.FreightTemplate{
|
|
|
|
|
StoreID: int(storeID),
|
|
|
|
|
VendorStoreID: utils.Int64ToStr(vendorStoreID),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err = dao.CreateEntity(db, FreightTemplate); err != nil {
|
|
|
|
|
_, err1 := dao.UpdateEntity(db, FreightTemplate, "TemplateID", "WarehouseID", "FenceID", "TradeLimitID")
|
|
|
|
|
if err1 == nil {
|
|
|
|
|
|