This commit is contained in:
邹宗楠
2024-04-28 10:39:32 +08:00
parent 8b701bfbed
commit 49a3d1d5d3

View File

@@ -1,7 +1,6 @@
package cms package cms
import ( import (
"encoding/json"
"fmt" "fmt"
"git.rosy.net.cn/baseapi/platformapi/ebaiapi" "git.rosy.net.cn/baseapi/platformapi/ebaiapi"
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch" "git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
@@ -11,7 +10,6 @@ import (
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api" "git.rosy.net.cn/jx-callback/globals/api"
beego "github.com/astaxie/beego/server/web" beego "github.com/astaxie/beego/server/web"
"strings"
"time" "time"
"git.rosy.net.cn/baseapi/platformapi/mtwmapi" "git.rosy.net.cn/baseapi/platformapi/mtwmapi"
@@ -382,363 +380,363 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
//#endregion //#endregion
//#region 同步活动 ////#region 同步活动
//
func CopyMtActToMt(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail) { //func CopyMtActToMt(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail) {
var fromApi, toApi *mtwmapi.API // var fromApi, toApi *mtwmapi.API
var errData = make([]error, 0, 0) // var errData = make([]error, 0, 0)
//
if fromStore.VendorOrgCode == globals.Mtwm2Code { // if fromStore.VendorOrgCode == globals.Mtwm2Code {
fromApi = mtwmapi.New(beego.AppConfig.DefaultString("mtwmAppID2", ""), beego.AppConfig.DefaultString("mtwmSecret2", ""), beego.AppConfig.DefaultString("mtwmCallbackURL2", ""), "") // fromApi = mtwmapi.New(beego.AppConfig.DefaultString("mtwmAppID2", ""), beego.AppConfig.DefaultString("mtwmSecret2", ""), beego.AppConfig.DefaultString("mtwmCallbackURL2", ""), "")
fromApi.SetToken(fromStore.MtwmToken) // fromApi.SetToken(fromStore.MtwmToken)
} else { // } else {
fromApi = partner.CurAPIManager.GetAPI(model.VendorIDMTWM, fromStore.VendorOrgCode).(*mtwmapi.API) // fromApi = partner.CurAPIManager.GetAPI(model.VendorIDMTWM, fromStore.VendorOrgCode).(*mtwmapi.API)
} // }
//
if toStore.VendorOrgCode == globals.Mtwm2Code { // if toStore.VendorOrgCode == globals.Mtwm2Code {
toApi = mtwmapi.New(beego.AppConfig.DefaultString("mtwmAppID2", ""), beego.AppConfig.DefaultString("mtwmSecret2", ""), beego.AppConfig.DefaultString("mtwmCallbackURL2", ""), "") // toApi = mtwmapi.New(beego.AppConfig.DefaultString("mtwmAppID2", ""), beego.AppConfig.DefaultString("mtwmSecret2", ""), beego.AppConfig.DefaultString("mtwmCallbackURL2", ""), "")
toApi.SetToken(toStore.MtwmToken) // toApi.SetToken(toStore.MtwmToken)
} else { // } else {
toApi = partner.CurAPIManager.GetAPI(model.VendorIDMTWM, toStore.VendorOrgCode).(*mtwmapi.API) // toApi = partner.CurAPIManager.GetAPI(model.VendorIDMTWM, toStore.VendorOrgCode).(*mtwmapi.API)
} // }
//
// 买赠活动 // // 买赠活动
buyGiftList, err := fromApi.BatchQueryBuyGiftsAll(fromStore.VendorStoreID) // buyGiftList, err := fromApi.BatchQueryBuyGiftsAll(fromStore.VendorStoreID)
if err != nil { // if err != nil {
errData = append(errData, fmt.Errorf("买赠活动异常:%v", errData)) // errData = append(errData, fmt.Errorf("买赠活动异常:%v", errData))
} // }
if len(buyGiftList) == model.NO { // if len(buyGiftList) == model.NO {
errData = append(errData, fmt.Errorf("门店暂无买赠活动")) // errData = append(errData, fmt.Errorf("门店暂无买赠活动"))
} // }
//
param := make([]*mtwmapi.BatchCreateBuyGiftsParam, 0, 0) // param := make([]*mtwmapi.BatchCreateBuyGiftsParam, 0, 0)
for _, v := range buyGiftList { // for _, v := range buyGiftList {
buyGift := &mtwmapi.BatchCreateBuyGiftsParam{ // buyGift := &mtwmapi.BatchCreateBuyGiftsParam{
AppSpuCode: v.AppSpuCode, // AppSpuCode: v.AppSpuCode,
StartTime: v.StartTime, // StartTime: v.StartTime,
EndTime: v.EndTime, // EndTime: v.EndTime,
GiftsType: v.GiftsType, // GiftsType: v.GiftsType,
GiftsName: v.GiftsName, // GiftsName: v.GiftsName,
GiftsAppSpuCode: v.GiftsAppSpuCode, // GiftsAppSpuCode: v.GiftsAppSpuCode,
BuyNum: v.BuyNum, // BuyNum: v.BuyNum,
GiftsNum: v.GiftsNum, // GiftsNum: v.GiftsNum,
GiftsCharge: v.GiftsCharge, // GiftsCharge: v.GiftsCharge,
GiftsDayLimit: v.GiftsDayLimit, // GiftsDayLimit: v.GiftsDayLimit,
} // }
//
// 赠品成本 // // 赠品成本
giftsCharge := &mtwmapi.GiftsChargeObj{} // giftsCharge := &mtwmapi.GiftsChargeObj{}
if err := json.Unmarshal([]byte(v.Charge), giftsCharge); err != nil { // if err := json.Unmarshal([]byte(v.Charge), giftsCharge); err != nil {
return // return
} // }
//
buyGift.GiftsCharge = utils.Str2Float64(fmt.Sprintf("%.2f", utils.Str2Float64(giftsCharge.GiftsCharge))) // buyGift.GiftsCharge = utils.Str2Float64(fmt.Sprintf("%.2f", utils.Str2Float64(giftsCharge.GiftsCharge)))
param = append(param, buyGift) // param = append(param, buyGift)
} // }
toApi.BatchCreateBuyGifts(toStore.VendorStoreID, param) // toApi.BatchCreateBuyGifts(toStore.VendorStoreID, param)
//
} //}
//
// SyncStoreFullReduction 同步门店满减活动 //// SyncStoreFullReduction 同步门店满减活动
func SyncStoreFullReduction(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error { //func SyncStoreFullReduction(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error {
data, err := fromStoreApi.BatchGetDiscountList(fromStoreId, 0) // data, err := fromStoreApi.BatchGetDiscountList(fromStoreId, 0)
if err != nil { // if err != nil {
return err // return err
} // }
//
errList := make([]string, 0.0) // errList := make([]string, 0.0)
for k, v := range data { // for k, v := range data {
param := &mtwmapi.CreateDiscountList{ // param := &mtwmapi.CreateDiscountList{
AppPoiCode: toStoreId, // AppPoiCode: toStoreId,
ActInfo: "", // ActInfo: "",
ActDetails: "", // ActDetails: "",
AppFoods: "", // AppFoods: "",
} // }
actInfo := &mtwmapi.CreateDisCountActInfo{ // actInfo := &mtwmapi.CreateDisCountActInfo{
StartTime: v.ActInfo.StartTime, // StartTime: v.ActInfo.StartTime,
EndTime: v.ActInfo.EndTime, // EndTime: v.ActInfo.EndTime,
ActType: 0, // 0 不传app_food // ActType: 0, // 0 不传app_food
AutoDelay: 1, // AutoDelay: 1,
} // }
if v.ActInfo.ActName != "" { // if v.ActInfo.ActName != "" {
actInfo.ActName = v.ActInfo.ActName // actInfo.ActName = v.ActInfo.ActName
} else { // } else {
actInfo.ActName = "全店满减" + utils.Int2Str(k) // actInfo.ActName = "全店满减" + utils.Int2Str(k)
} // }
//
actInfoByte, err := json.Marshal(actInfo) // actInfoByte, err := json.Marshal(actInfo)
if err != nil { // if err != nil {
return err // return err
} // }
param.ActInfo = string(actInfoByte) // param.ActInfo = string(actInfoByte)
//
actDetails := make([]mtwmapi.CreateDiscountActDetails, 0, 0) // actDetails := make([]mtwmapi.CreateDiscountActDetails, 0, 0)
for _, ads := range v.ActDetails { // for _, ads := range v.ActDetails {
actDetails = append(actDetails, mtwmapi.CreateDiscountActDetails{ // actDetails = append(actDetails, mtwmapi.CreateDiscountActDetails{
OriginPrice: utils.Float64TwoInt(ads.OriginPrice), // OriginPrice: utils.Float64TwoInt(ads.OriginPrice),
ActPrice: utils.Float64TwoInt(ads.ActPrice), // ActPrice: utils.Float64TwoInt(ads.ActPrice),
}) // })
} // }
actDetailsByte, err := json.Marshal(actDetails) // actDetailsByte, err := json.Marshal(actDetails)
if err != nil { // if err != nil {
return err // return err
} // }
param.ActDetails = string(actDetailsByte) // param.ActDetails = string(actDetailsByte)
_, err = toStoreApi.BatchCreateDiscountList(param) // _, err = toStoreApi.BatchCreateDiscountList(param)
if err != nil { // if err != nil {
errList = append(errList, actInfo.ActName+":"+err.Error()) // errList = append(errList, actInfo.ActName+":"+err.Error())
} // }
} // }
//
return fmt.Errorf(strings.Join(errList, ",")) // return fmt.Errorf(strings.Join(errList, ","))
} //}
//
// SyncStoreShippingFee 同步门店运费满减活动 //// SyncStoreShippingFee 同步门店运费满减活动
func SyncStoreShippingFee(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error { //func SyncStoreShippingFee(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error {
data, err := fromStoreApi.BatchGetShippingFee(fromStoreId) // data, err := fromStoreApi.BatchGetShippingFee(fromStoreId)
if err != nil { // if err != nil {
return err // return err
} // }
//
if data.SuccessList != nil && len(data.SuccessList) != 0 { // if data.SuccessList != nil && len(data.SuccessList) != 0 {
param := make([]*mtwmapi.ShippingFeeBatchCreateActData, 0, 0) // param := make([]*mtwmapi.ShippingFeeBatchCreateActData, 0, 0)
for _, v := range data.SuccessList { // for _, v := range data.SuccessList {
shippingFee := &mtwmapi.ShippingFeeBatchCreateActData{ // shippingFee := &mtwmapi.ShippingFeeBatchCreateActData{
StartTime: v.StartTime, // StartTime: v.StartTime,
EndTime: v.EndTime, // EndTime: v.EndTime,
WeeksTime: v.WeeksTime, // WeeksTime: v.WeeksTime,
Period: v.Period, // Period: v.Period,
MaxPrice: v.MaxPrice, // MaxPrice: v.MaxPrice,
} // }
actDetail := make([]mtwmapi.ShippingFeeBatchCreateActDataActDetail, 0, 0) // actDetail := make([]mtwmapi.ShippingFeeBatchCreateActDataActDetail, 0, 0)
for _, ad := range v.ActDetail { // for _, ad := range v.ActDetail {
actDetail = append(actDetail, mtwmapi.ShippingFeeBatchCreateActDataActDetail{ // actDetail = append(actDetail, mtwmapi.ShippingFeeBatchCreateActDataActDetail{
LimitPrice: ad.LimitPrice, // LimitPrice: ad.LimitPrice,
DiscountPrice: ad.DiscountPrice, // DiscountPrice: ad.DiscountPrice,
}) // })
} // }
shippingFee.ActDetail = actDetail // shippingFee.ActDetail = actDetail
//
param = append(param, shippingFee) // param = append(param, shippingFee)
} // }
//
resultData, err := toStoreApi.BatchCreateShippingFee(toStoreId, param) // resultData, err := toStoreApi.BatchCreateShippingFee(toStoreId, param)
if err != nil { // if err != nil {
return err // return err
} // }
if resultData.Data != "ok" { // if resultData.Data != "ok" {
return fmt.Errorf(resultData.Msg) // return fmt.Errorf(resultData.Msg)
} // }
} // }
return nil // return nil
} //}
//
// SyncStoreProducts 同步门店折扣爆品活动 //// SyncStoreProducts 同步门店折扣爆品活动
func SyncStoreProducts(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error { //func SyncStoreProducts(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error {
secKillALL, err := fromStoreApi.QueryProductsAll(fromStoreId, mtwmapi.RetailActTypeSecKill) // secKillALL, err := fromStoreApi.QueryProductsAll(fromStoreId, mtwmapi.RetailActTypeSecKill)
if err != nil { // if err != nil {
return err // return err
} // }
//
killAct := make([]*mtwmapi.RetailDiscountActData, 0, 0) // killAct := make([]*mtwmapi.RetailDiscountActData, 0, 0)
for _, v := range secKillALL { // for _, v := range secKillALL {
kill := &mtwmapi.RetailDiscountActData{ // kill := &mtwmapi.RetailDiscountActData{
AppFoodCode: v.AppFoodCode, // AppFoodCode: v.AppFoodCode,
UserType: v.UserType, // UserType: v.UserType,
StartTime: v.StartTime, // StartTime: v.StartTime,
EndTime: v.EndTime, // EndTime: v.EndTime,
OrderLimit: v.OrderLimit, // OrderLimit: v.OrderLimit,
DayLimit: v.DayLimit, // DayLimit: v.DayLimit,
Period: v.Period, // Period: v.Period,
WeeksTime: v.WeeksTime, // WeeksTime: v.WeeksTime,
SettingType: v.SettingType, // SettingType: v.SettingType,
ActPrice: v.ActPrice, // ActPrice: v.ActPrice,
DiscountCoefficient: v.DiscountCoefficient, // DiscountCoefficient: v.DiscountCoefficient,
Sequence: v.Sequence, // Sequence: v.Sequence,
ItemID: v.ItemID, // ItemID: v.ItemID,
OriginalPrice: v.OriginalPrice, // OriginalPrice: v.OriginalPrice,
Stock: v.Stock, // Stock: v.Stock,
Status: v.Status, // Status: v.Status,
Name: v.Name, // Name: v.Name,
} // }
killAct = append(killAct, kill) // killAct = append(killAct, kill)
} // }
//
//todo 折扣活动查询出来一万多条,暂时工单处理 // //todo 折扣活动查询出来一万多条,暂时工单处理
directDownALL, err := fromStoreApi.QueryProductsAll(fromStoreId, mtwmapi.RetailActTypeDirectDown) // directDownALL, err := fromStoreApi.QueryProductsAll(fromStoreId, mtwmapi.RetailActTypeDirectDown)
for _, v := range directDownALL { // for _, v := range directDownALL {
kill := &mtwmapi.RetailDiscountActData{ // kill := &mtwmapi.RetailDiscountActData{
AppFoodCode: v.AppFoodCode, // AppFoodCode: v.AppFoodCode,
UserType: v.UserType, // UserType: v.UserType,
StartTime: v.StartTime, // StartTime: v.StartTime,
EndTime: v.EndTime, // EndTime: v.EndTime,
OrderLimit: v.OrderLimit, // OrderLimit: v.OrderLimit,
DayLimit: v.DayLimit, // DayLimit: v.DayLimit,
Period: v.Period, // Period: v.Period,
WeeksTime: v.WeeksTime, // WeeksTime: v.WeeksTime,
SettingType: v.SettingType, // SettingType: v.SettingType,
ActPrice: v.ActPrice, // ActPrice: v.ActPrice,
DiscountCoefficient: v.DiscountCoefficient, // DiscountCoefficient: v.DiscountCoefficient,
Sequence: v.Sequence, // Sequence: v.Sequence,
ItemID: v.ItemID, // ItemID: v.ItemID,
OriginalPrice: v.OriginalPrice, // OriginalPrice: v.OriginalPrice,
Stock: v.Stock, // Stock: v.Stock,
Status: v.Status, // Status: v.Status,
Name: v.Name, // Name: v.Name,
} // }
killAct = append(killAct, kill) // killAct = append(killAct, kill)
} // }
if len(killAct) != 0 { // if len(killAct) != 0 {
_, _, err := toStoreApi.CreateProductsAct(toStoreId, mtwmapi.RetailActTypeSecKill, killAct) // _, _, err := toStoreApi.CreateProductsAct(toStoreId, mtwmapi.RetailActTypeSecKill, killAct)
if err != nil { // if err != nil {
return err // return err
} // }
} // }
//
return nil // return nil
} //}
//
// SyncStoreCoupon 同步门店商家券(单店店内商家券) //// SyncStoreCoupon 同步门店商家券(单店店内商家券)
func SyncStoreCoupon(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error { //func SyncStoreCoupon(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error {
couponList, err := fromStoreApi.QueryStoreCoupon(fromStoreId) // couponList, err := fromStoreApi.QueryStoreCoupon(fromStoreId)
if err != nil { // if err != nil {
return err // return err
} // }
//
errList := make([]string, 0, 0) // errList := make([]string, 0, 0)
if len(couponList) != 0 { // if len(couponList) != 0 {
for _, v := range couponList { // for _, v := range couponList {
couponInfoList := make([]*mtwmapi.CouponInfo, 0, 0) // couponInfoList := make([]*mtwmapi.CouponInfo, 0, 0)
for _, ad := range v.ActData { // for _, ad := range v.ActData {
couponInfoList = append(couponInfoList, &mtwmapi.CouponInfo{ // couponInfoList = append(couponInfoList, &mtwmapi.CouponInfo{
LimitPrice: ad.LimitPrice, // LimitPrice: ad.LimitPrice,
CouponPrice: ad.CouponPrice, // CouponPrice: ad.CouponPrice,
UserType: ad.UserType, // UserType: ad.UserType,
ValidityDays: ad.ValidityDays, // ValidityDays: ad.ValidityDays,
Stock: ad.Stock, // Stock: ad.Stock,
}) // })
} // }
//
limitTime := &mtwmapi.LimitTime{ // limitTime := &mtwmapi.LimitTime{
StartTime: v.StartTime, // StartTime: v.StartTime,
EndTime: v.EndTime, // EndTime: v.EndTime,
} // }
//
if _, err := toStoreApi.CreateStoreCouponBatch(toStoreId, limitTime, couponInfoList); err != nil { // if _, err := toStoreApi.CreateStoreCouponBatch(toStoreId, limitTime, couponInfoList); err != nil {
errList = append(errList, err.Error()) // errList = append(errList, err.Error())
} // }
} // }
} // }
//
if len(errList) != 0 { // if len(errList) != 0 {
return fmt.Errorf(strings.Join(errList, ",")) // return fmt.Errorf(strings.Join(errList, ","))
} // }
return nil // return nil
} //}
//
// SyncStoreXDiscount 同步门店X件优惠活动(x件m元/X件m折/X件减m元)目前只有x件m元,其他两个查询不出来,美团创建成功也查询不出来 //// SyncStoreXDiscount 同步门店X件优惠活动(x件m元/X件m折/X件减m元)目前只有x件m元,其他两个查询不出来,美团创建成功也查询不出来
// 暂时不能创建,无法获取商品的活动价格和活动库存 //// 暂时不能创建,无法获取商品的活动价格和活动库存
func SyncStoreXDiscount(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error { //func SyncStoreXDiscount(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error {
//result := make([]*mtwmapi.BundlesSuccessListDetail, 0, 0) // //result := make([]*mtwmapi.BundlesSuccessListDetail, 0, 0)
//// X件M元 // //// X件M元
//bundlesXM, _ := fromStoreApi.QueryBundlesAct(fromStoreId, 0) // //bundlesXM, _ := fromStoreApi.QueryBundlesAct(fromStoreId, 0)
//if bundlesXM != nil { // //if bundlesXM != nil {
// result = append(result, bundlesXM...) // // result = append(result, bundlesXM...)
//} // //}
//// X件Y折 // //// X件Y折
//bundlesXY, _ := fromStoreApi.QueryBundlesAct(fromStoreId, 2) // //bundlesXY, _ := fromStoreApi.QueryBundlesAct(fromStoreId, 2)
//if bundlesXY != nil { // //if bundlesXY != nil {
// result = append(result, bundlesXY...) // // result = append(result, bundlesXY...)
//} // //}
// // //
//errList := make([]error, 0, 0) // //errList := make([]error, 0, 0)
//for _, v := range result { // //for _, v := range result {
// actSku, err := fromStoreApi.QueryBundlesSku(fromStoreId, utils.Int64ToStr(v.ActId)) // // actSku, err := fromStoreApi.QueryBundlesSku(fromStoreId, utils.Int64ToStr(v.ActId))
// if err != nil { // // if err != nil {
// errList = append(errList, err) // // errList = append(errList, err)
// continue // // continue
// } // // }
// // //
//} // //}
//
return nil // return nil
} //}
//
// SyncRepurchaseSku 加价购[无法获取活动商品的价格和库存暂不创建] //// SyncRepurchaseSku 加价购[无法获取活动商品的价格和库存暂不创建]
func SyncRepurchaseSku() { //func SyncRepurchaseSku() {
return // return
} //}
//
// SyncStoreCouponAct 门店商品券活动 //// SyncStoreCouponAct 门店商品券活动
func SyncStoreCouponAct(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error { //func SyncStoreCouponAct(fromStoreApi, toStoreApi *mtwmapi.API, fromStoreId, toStoreId string) error {
couponInfoAll := make([]*mtwmapi.GetStoreCouponActSuccessList, 0, 0) // couponInfoAll := make([]*mtwmapi.GetStoreCouponActSuccessList, 0, 0)
pageNumber := 1 // pageNumber := 1
pageSize := 100 // pageSize := 100
for { // for {
param := &mtwmapi.GetStoreCouponActParam{ // param := &mtwmapi.GetStoreCouponActParam{
AppPoiCode: fromStoreId, // AppPoiCode: fromStoreId,
ActStatus: 1, // ActStatus: 1,
StartTime: time.Now().AddDate(-1, 0, 0).Unix(), // StartTime: time.Now().AddDate(-1, 0, 0).Unix(),
EndTime: time.Now().AddDate(1, 0, 0).Unix(), // EndTime: time.Now().AddDate(1, 0, 0).Unix(),
PageNum: pageNumber, // PageNum: pageNumber,
PageSize: pageSize, // PageSize: pageSize,
} // }
//
couponList, err := fromStoreApi.GetStoreCouponAct(param) // couponList, err := fromStoreApi.GetStoreCouponAct(param)
if err != nil { // if err != nil {
return err // return err
} // }
couponInfoAll = append(couponInfoAll, couponList...) // couponInfoAll = append(couponInfoAll, couponList...)
if len(couponList) < pageSize { // if len(couponList) < pageSize {
break // break
} // }
pageNumber++ // pageNumber++
} // }
//
for _, v := range couponInfoAll { // for _, v := range couponInfoAll {
couponSkuList, err := fromStoreApi.GetCouponActSkuList(fromStoreId, utils.Int64ToStr(v.ActId)) // couponSkuList, err := fromStoreApi.GetCouponActSkuList(fromStoreId, utils.Int64ToStr(v.ActId))
if err != nil { // if err != nil {
return err // return err
} // }
//
for _, csl := range couponSkuList { // for _, csl := range couponSkuList {
param := &mtwmapi.CreateCouponAct{ // param := &mtwmapi.CreateCouponAct{
AppPoiCodes: csl.AppPoiCodes, // AppPoiCodes: csl.AppPoiCodes,
CouponName: csl.CouponName, // CouponName: csl.CouponName,
IsSinglePoi: csl.IsSinglePoi, // IsSinglePoi: csl.IsSinglePoi,
AppSpuCodes: csl.AppSpuCodes, // AppSpuCodes: csl.AppSpuCodes,
TakeCouponStartTime: csl.TakeCouponStartTime, // TakeCouponStartTime: csl.TakeCouponStartTime,
TakeCouponEndTime: csl.TakeCouponEndTime, // TakeCouponEndTime: csl.TakeCouponEndTime,
UseCouponStartTime: csl.UseCouponStartTime, // UseCouponStartTime: csl.UseCouponStartTime,
CouponLimitCount: csl.CouponLimitCount, // CouponLimitCount: csl.CouponLimitCount,
Type: csl.Type, // Type: csl.Type,
} // }
//
if csl.SpuData != nil && len(csl.SpuData) != 0 { // if csl.SpuData != nil && len(csl.SpuData) != 0 {
for _, sd := range csl.SpuData { // for _, sd := range csl.SpuData {
param.SpuData = append(param.SpuData, mtwmapi.CreateCouponActSpuData{ // param.SpuData = append(param.SpuData, mtwmapi.CreateCouponActSpuData{
AppSpuCode: sd.AppSpuCode, // AppSpuCode: sd.AppSpuCode,
SkuId: sd.SkuId, // SkuId: sd.SkuId,
Upc: sd.Upc, // Upc: sd.Upc,
}) // })
} // }
} // }
//
if csl.ActPriceCouponInfo != nil && len(csl.ActPriceCouponInfo) != 0 { // if csl.ActPriceCouponInfo != nil && len(csl.ActPriceCouponInfo) != 0 {
param.ActPriceCouponInfo = csl.ActPriceCouponInfo // param.ActPriceCouponInfo = csl.ActPriceCouponInfo
} // }
if csl.DiscountCouponInfo != nil && len(csl.DiscountCouponInfo) != 0 { // if csl.DiscountCouponInfo != nil && len(csl.DiscountCouponInfo) != 0 {
param.DiscountCouponInfo = csl.DiscountCouponInfo // param.DiscountCouponInfo = csl.DiscountCouponInfo
} // }
//
_, err = toStoreApi.CreateCouponAct(param) // _, err = toStoreApi.CreateCouponAct(param)
if err != nil { // if err != nil {
return err // return err
} // }
} // }
} // }
//
return nil // return nil
} //}
//
//#endregion ////#endregion