增加逻辑

This commit is contained in:
richboo111
2022-11-07 14:55:47 +08:00
parent 829eb9328b
commit b5a065b0e3
4 changed files with 38 additions and 20 deletions

View File

@@ -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) {
}

View File

@@ -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"`

View File

@@ -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 {

View File

@@ -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]