1
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user