diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 5f6513773..6c8339f1c 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1524,7 +1524,7 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vend } if vendorID == model.VendorIDDD { //抖店绑定店铺时 检查并补充创建 globals.SugarLogger.Debugf("vendorID ==============%d", vendorID) - if err2 := tiktok_store.CreateOrUpdateAll(vendorOrgCode, int64(storeMap.StoreID), utils.Str2Int64(storeMap.VendorStoreID)); err2 != nil { + if err2 := tiktok_store.CreateOrUpdateAll(vendorOrgCode, int64(storeMap.StoreID), utils.Str2Int64(storeMap.VendorStoreID), int64(storeMap.DeliveryFeeDeductionFee), utils.Str2Int64(storeMap.YbStorePrefix)); err2 != nil { errList.AddErr(err2) } } @@ -5950,3 +5950,8 @@ func GetVendorOrgCode(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID i } return storeMap, dao.GetEntitiesByKV(db, &storeMap, cond, false) } + +//批量绑定抖店平台门店 +func BatchBindVendorStore(ctx *jxcontext.Context) { + +} diff --git a/business/model/dao/store.go b/business/model/dao/store.go index afedda874..760520eae 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -61,7 +61,7 @@ type StoreDetail struct { YbAppID string `orm:"column(yb_app_id)" json:"ybAppID"` YbAppKey string `json:"ybAppKey"` - YbStorePrefix string `json:"ybStorePrefix"` + YbStorePrefix string `json:"ybStorePrefix"` //vendorID=14 暂存打包费 MtwmToken string `json:"mtwmToken"` // 当vendor为美团时存储美团token,为抖店时存储抖店token EbaiSupplierID string `json:"ebaiSupplierID"` diff --git a/business/partner/purchase/tiktok_store/store.go b/business/partner/purchase/tiktok_store/store.go index 3a9d65132..663d19764 100644 --- a/business/partner/purchase/tiktok_store/store.go +++ b/business/partner/purchase/tiktok_store/store.go @@ -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 { diff --git a/controllers/cms_store.go b/controllers/cms_store.go index 8b9d38c70..5f86c578f 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -1507,3 +1507,12 @@ func (c *StoreController) GetDDScope() { return retVal, "", nil }) } + +// @Title 批量绑定抖店与京西门店 +// @Description 批量绑定抖店与京西门店 +// @Param token header string true "认证token" +// @Param storeID formData int true "门店ID" +// @Param vendorStoreID formData string true "平台门店ID" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /BatchBindVendorStore [post]