This commit is contained in:
richboo111
2023-10-16 09:31:28 +08:00
parent 039a4050be
commit b4db103d2b
3 changed files with 109 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
package mtwm
import (
"errors"
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
@@ -263,3 +265,81 @@ func (c *PurchaseHandler) GetActAmple(ctx *jxcontext.Context, vendorStoreID, ven
}
return ample, err
}
const (
ActTypeBuy = 1 //买赠活动
ActTypeDeduction = 2 //商品满减
ActTypeDirectDown = 3 //折扣(爆品)
ActTypeXM = 4 //X元M件
ActTypeN = 5 //第N件优惠
ActTypeDeductionAll = 0 //全店满减
ActTypeDeductionOne = 1 //指定商品满减
)
func GetActByAppPoiCode(vendorStoreID, vendorOrgCode string, sTime, eTime int64, actType int) (map[int]interface{}, error) {
if len(vendorStoreID) == 0 || len(vendorOrgCode) == 0 || sTime == 0 || eTime == 0 {
return nil, errors.New("未选中门店或时间,请检查")
}
var (
temp []interface{}
resp = make(map[int]interface{})
a = getAPI(vendorOrgCode, 0, vendorStoreID)
)
switch actType {
case ActTypeDeduction:
actInfo, err := a.FullDiscountList(vendorStoreID, ActTypeDeductionAll)
if err != nil {
return nil, err
}
//获取活动商品
for _, v := range actInfo {
sku, err := a.FullDiscountFoodsList(vendorStoreID, v.ActInfo.ActIDs)
actID := utils.Str2Int(v.ActInfo.ActIDs)
if err != nil {
temp[actID] = nil
}
if CheckActTime(sTime, eTime, v.ActInfo.StartTime, v.ActInfo.EndTime) {
temp[actID] = sku
}
}
resp[ActTypeDeduction] = temp
return resp, nil
case ActTypeDirectDown:
killInfo, err := a.RetailDiscountList(vendorStoreID, mtwmapi.RetailActTypeSecKill)
if err != nil || killInfo == nil {
resp[mtwmapi.RetailActTypeSecKill] = ""
} else {
for _, v := range killInfo {
if CheckActTime(sTime, eTime, v.StartTime, v.EndTime) {
temp = append(temp, v)
}
}
resp[mtwmapi.RetailActTypeSecKill] = temp
}
downInfo, err1 := a.RetailDiscountList(vendorStoreID, mtwmapi.RetailActTypeDirectDown)
if err1 != nil || downInfo == nil {
resp[mtwmapi.RetailActTypeDirectDown] = ""
} else {
for _, k := range downInfo {
if CheckActTime(sTime, eTime, k.StartTime, k.EndTime) {
temp = append(temp, k)
}
}
resp[mtwmapi.RetailActTypeDirectDown] = temp
}
return resp, nil
}
return nil, nil
}
func CheckActTime(startTime, endTime, sTime, eTime int64) bool {
if sTime > endTime || eTime < startTime {
return false
}
return true
//if (startTime <= eTime && eTime <= endTime) || (startTime <= sTime && sTime <= endTime) {
// return true
//}
//return false
}

View File

@@ -3,6 +3,8 @@ package controllers
import (
"fmt"
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
"git.rosy.net.cn/jx-callback/business/jxstore/act"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
@@ -470,6 +472,24 @@ func (c *ActController) GetActMtwmVendor() {
})
}
// @Title 查询美团平台线上活动(会有不在我们本地创建的)
// @Description 查询美团平台线上活动
// @Param token header string true "认证token"
// @Param vendorStoreID query string true "美团门店ID"
// @Param vendorOrgCode query string true "美团appID"
// @Param beginAt query int true "活动开始日期 时间戳"
// @Param endAt query int true "活动结束日期"
// @Param actType query int true "折扣或者秒杀"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetMTOnlineAct [get]
func (c *ActController) GetMTOnlineAct() {
c.callGetMTOnlineAct(func(params *tActGetMTOnlineActParams) (interface{}, string, error) {
retVal, err := mtwm.GetActByAppPoiCode(params.VendorStoreID, params.VendorOrgCode, int64(params.BeginAt), int64(params.EndAt), params.ActType)
return retVal, "", err
})
}
// @Title 根据商品id查询未开展活动的门店信息
// @Description 查询美团平台活动
// @Param token header string true "认证token"

View File

@@ -96,6 +96,15 @@ func init() {
MethodParams: param.Make(),
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"],
web.ControllerComments{
Method: "GetMTOnlineAct",
Router: `/GetMTOnlineAct`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"],
web.ControllerComments{
Method: "GetNotHaveSkuActList",