1
This commit is contained in:
@@ -6685,6 +6685,6 @@ func BatchSetRestockingPrice(ctx *jxcontext.Context, preData map[string][]mtwmap
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BatchSetMTBoxPrice 批量修改美团包装费为0
|
// BatchSetMTBoxPrice 批量修改美团包装费为0
|
||||||
func BatchSetMTBoxPrice(ctx *jxcontext.Context, skuList []*mtwm.SetBoxPrice) error {
|
func BatchSetMTBoxPrice(ctx *jxcontext.Context, storeList []int) error {
|
||||||
return mtwm.UpdateBoxPrice(ctx, dao.GetDB(), skuList)
|
return mtwm.UpdateBoxPrice(ctx, dao.GetDB(), storeList)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1699,18 +1699,19 @@ func GetDeletedStoreSkuBind(db *DaoDB, storeID, skuID int) (storeSkuBind *model.
|
|||||||
return storeSkuBind
|
return storeSkuBind
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStoreSkuBindList(db *DaoDB, storeId int64) []string {
|
func GetStoreSkuBindList(db *DaoDB, storeId int) ([]*model.StoreSkuBind, error) {
|
||||||
storeSkuBind := make([]*model.StoreSkuBind, 0, 0)
|
storeSkuBind := make([]*model.StoreSkuBind, 0, 0)
|
||||||
sql := `SELECT * FROM store_sku_bind WHERE store_id = ` + fmt.Sprintf("%d", storeId) + ` AND status = 1 `
|
sql := `SELECT * FROM store_sku_bind WHERE store_id = ? AND deleted_at = ? `
|
||||||
GetRows(db, &storeSkuBind, sql)
|
|
||||||
|
|
||||||
data := make([]string, 0)
|
sqlParams := []interface{}{
|
||||||
for _, v := range storeSkuBind {
|
storeId,
|
||||||
if v.TaoID != 0 {
|
utils.DefaultTimeValue,
|
||||||
data = append(data, utils.Int64ToStr(v.TaoID))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return data
|
err := GetRows(db, &storeSkuBind, sql, sqlParams...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return storeSkuBind, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStoreSkuBindByNameID(db *DaoDB, storeID, nameID, status int) (storeSkuBind []*model.StoreSkuBind, err error) {
|
func GetStoreSkuBindByNameID(db *DaoDB, storeID, nameID, status int) (storeSkuBind []*model.StoreSkuBind, err error) {
|
||||||
|
|||||||
@@ -906,39 +906,54 @@ type SetBoxPrice struct {
|
|||||||
BoxPrice float64 `json:"box_price"` // 打包价格
|
BoxPrice float64 `json:"box_price"` // 打包价格
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateBoxPrice(ctx *jxcontext.Context, db *dao.DaoDB, list []*SetBoxPrice) error {
|
func UpdateBoxPrice(ctx *jxcontext.Context, db *dao.DaoDB, list []int) error {
|
||||||
storeDetail, err := dao.GetStoreDetail(db, list[0].StoreId, model.VendorIDMTWM, "")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
//storeSkuList, err := dao.GetStoresSkusInfo(db, []int{list[0].StoreId}, nil)
|
|
||||||
//if err != nil {
|
|
||||||
// return err
|
|
||||||
//}
|
|
||||||
|
|
||||||
api := getAPI(storeDetail.VendorOrgCode, list[0].StoreId, storeDetail.VendorStoreID)
|
|
||||||
foodDataList := make([]map[string]interface{}, 0)
|
|
||||||
for _, v := range list {
|
for _, v := range list {
|
||||||
|
storeDetail, err := dao.GetStoreDetail(db, v, model.VendorIDMTWM, "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
foodDataList = append(foodDataList, map[string]interface{}{
|
skuList, err := dao.GetStoreSkuBindList(db, v)
|
||||||
"app_spu_code": utils.Int2Str(v.SkuId),
|
if err != nil {
|
||||||
"skus": []map[string]interface{}{
|
return err
|
||||||
{
|
}
|
||||||
"sku_id": utils.Int2Str(v.SkuId),
|
if len(skuList) == model.NO {
|
||||||
"ladder_box_num": "1",
|
continue
|
||||||
"ladder_box_price": utils.Float64ToStr(v.BoxPrice),
|
}
|
||||||
|
|
||||||
|
foodDataList := make([]map[string]interface{}, 0)
|
||||||
|
for _, sl := range skuList {
|
||||||
|
foodDataList = append(foodDataList, map[string]interface{}{
|
||||||
|
"app_spu_code": utils.Int2Str(sl.SkuID),
|
||||||
|
"skus": []map[string]interface{}{
|
||||||
|
{
|
||||||
|
"sku_id": utils.Int2Str(sl.SkuID),
|
||||||
|
"ladder_box_num": "0",
|
||||||
|
"ladder_box_price": "0",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
})
|
}
|
||||||
}
|
count := utils.Float64TwoInt(math.Ceil(float64(len(foodDataList)) / float64(200)))
|
||||||
|
api := getAPI(storeDetail.VendorOrgCode, v, storeDetail.VendorStoreID)
|
||||||
count := utils.Float64TwoInt(math.Ceil(float64(len(foodDataList)) / float64(50)))
|
for i := 1; i <= count; i++ {
|
||||||
for i := 1; i <= count; i++ {
|
if i == count {
|
||||||
if i == count {
|
result, err := api.RetailBatchInitData(ctx.GetTrackInfo(), storeDetail.VendorStoreID, foodDataList[(i-1)*200:])
|
||||||
_, _ = api.RetailBatchInitData(ctx.GetTrackInfo(), storeDetail.VendorStoreID, foodDataList[(i-1)*50:])
|
if err != nil {
|
||||||
} else {
|
globals.SugarLogger.Debugf("RetailBatchInitData1 err := %v", err)
|
||||||
_, _ = api.RetailBatchInitData(ctx.GetTrackInfo(), storeDetail.VendorStoreID, foodDataList[(i-1)*50:i*50])
|
}
|
||||||
|
if result != nil {
|
||||||
|
globals.SugarLogger.Debugf("RetailBatchInitData1 result := %s", utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result, err := api.RetailBatchInitData(ctx.GetTrackInfo(), storeDetail.VendorStoreID, foodDataList[(i-1)*200:i*200])
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Debugf("RetailBatchInitData2 err := %v", err)
|
||||||
|
}
|
||||||
|
if result != nil {
|
||||||
|
globals.SugarLogger.Debugf("RetailBatchInitData1 result := %s", utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -902,18 +902,16 @@ func (c *SkuController) BatchSetRestockingPrice() {
|
|||||||
|
|
||||||
// @Title 批量设置美团商品打包费为零
|
// @Title 批量设置美团商品打包费为零
|
||||||
// @Description 批量设置美团商品打包费为零
|
// @Description 批量设置美团商品打包费为零
|
||||||
// @Param token header string true "认证token"
|
// @Param storeIDs query string false "门店ID列表"
|
||||||
// @Param payload formData string true "json数据,SpuData对象()"
|
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /BatchSetBoxPrice [post]
|
// @router /BatchSetBoxPrice [post]
|
||||||
func (c *SkuController) BatchSetBoxPrice() {
|
func (c *SkuController) BatchSetBoxPrice() {
|
||||||
c.callBatchSetBoxPrice(func(params *tSkuBatchSetBoxPriceParams) (retVal interface{}, errCode string, err error) {
|
c.callBatchSetBoxPrice(func(params *tSkuBatchSetBoxPriceParams) (retVal interface{}, errCode string, err error) {
|
||||||
payload := make([]*mtwm.SetBoxPrice, 0, 0)
|
var storeIDs []int
|
||||||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err != nil {
|
err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs)
|
||||||
return nil, "", err
|
|
||||||
}
|
err = cms.BatchSetMTBoxPrice(params.Ctx, storeIDs)
|
||||||
err = cms.BatchSetMTBoxPrice(params.Ctx, payload)
|
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user