110 lines
3.4 KiB
Go
110 lines
3.4 KiB
Go
package pdd
|
|
|
|
import (
|
|
"fmt"
|
|
"git.rosy.net.cn/baseapi/platformapi/pddapi"
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/business/jxstore/partner"
|
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
"git.rosy.net.cn/jx-callback/globals/api"
|
|
)
|
|
|
|
var (
|
|
sortTypeMap = map[int]int{
|
|
0: 0, //综合排序
|
|
partner.JxSortTypeYJ: 1, //按佣金比率升序;
|
|
-partner.JxSortTypeYJ: 2, //按佣金比例降序;
|
|
partner.JxSortTypeJG: 3, //按价格升序;
|
|
-partner.JxSortTypeJG: 4, //按价格降序;
|
|
partner.JxSortTypeXL: 5, //按销量升序;
|
|
-partner.JxSortTypeXL: 6, //按销量降序;
|
|
}
|
|
)
|
|
|
|
func (s *UnionHandler) ShareUnionLink(ctx *jxcontext.Context, linkType, unionActID int, sID, userID string, resourceType int) (link string, err error) {
|
|
if result, err := api.PddAPI.ResourceURLGen(sID, resourceType); err == nil {
|
|
switch linkType {
|
|
case partner.LinkTypeWeiXinMini:
|
|
return "", err
|
|
case partner.LinTypeH5:
|
|
return result.SingleURLList.URL, err
|
|
case partner.LinTypeWx:
|
|
return result.WeAppInfo.PagePath, err
|
|
default:
|
|
return link, fmt.Errorf("暂不支持此链接类型!")
|
|
}
|
|
}
|
|
return link, err
|
|
}
|
|
|
|
func (s *UnionHandler) GetUnionActList(ctx *jxcontext.Context, actType int) (actList []*partner.ActivityList, err error) {
|
|
if result, err2 := getAPI().ActivityOperationList(); err2 == nil {
|
|
for _, v := range result {
|
|
act := &partner.ActivityList{
|
|
ActID: v.ID,
|
|
ActName: v.Name,
|
|
ActDes: v.Description,
|
|
Ratio: "未知",
|
|
ActSrc: v.Fileurl,
|
|
Img: v.Bannerimage,
|
|
DateBegin: utils.Str2Time(v.Starttime),
|
|
DateEnd: utils.Str2Time(v.Endtime),
|
|
}
|
|
actList = append(actList, act)
|
|
}
|
|
}
|
|
return actList, err
|
|
}
|
|
|
|
func (s *UnionHandler) CreateUnionPosition(ctx *jxcontext.Context, userID string) (sID string, err error) {
|
|
if sID, err = api.PddAPI.GoodsOPidGenerate(userID); err != nil {
|
|
return "", err
|
|
}
|
|
return sID, err
|
|
}
|
|
|
|
func jxSortType2PddSortType(jxSortType int) (sortType int) {
|
|
return sortTypeMap[jxSortType]
|
|
}
|
|
|
|
func (s *UnionHandler) GetUnionMatterList(ctx *jxcontext.Context, vendorCatID, keyword string, page, pageSize, sortType int, listID string) (list *partner.MatterList, err error) {
|
|
var (
|
|
goodsList []*partner.GoodsList
|
|
)
|
|
list = &partner.MatterList{}
|
|
params := &pddapi.GoodsSearchParam{
|
|
CatID: utils.Str2Int(vendorCatID),
|
|
Keyword: keyword,
|
|
Page: page,
|
|
PageSize: pageSize,
|
|
SortType: jxSortType2PddSortType(sortType),
|
|
ListID: listID,
|
|
}
|
|
//-1表示是拼多多的精选
|
|
if vendorCatID == "-1" {
|
|
params.ActivityTags = []int{pddapi.GoodsActTagBYBT, pddapi.GoodsActTagJXBK, pddapi.GoodsActTagMS, pddapi.GoodsActTagPPGY, pddapi.GoodsActTagPPHB, pddapi.GoodsActTagQWBT, pddapi.GoodsActTagTZTJ}
|
|
}
|
|
if goods, err2 := api.PddAPI.GoodsSearch(params); err2 != nil {
|
|
return nil, err2
|
|
} else {
|
|
list.ListID = goods.ListID
|
|
list.TotalCount = goods.TotalCount
|
|
list.VendorID = model.VendorIDPDD
|
|
for _, v := range goods.GoodsList {
|
|
good := &partner.GoodsList{
|
|
GoodsID: v.GoodsSign,
|
|
GoodsName: v.GoodsName,
|
|
Img: v.GoodsThumbnailURL,
|
|
CouponDiscount: v.CouponDiscount,
|
|
CouponRemainQuantity: v.CouponRemainQuantity,
|
|
MinNormalPrice: v.MinNormalPrice,
|
|
SalesCount: v.SalesTip,
|
|
}
|
|
goodsList = append(goodsList, good)
|
|
}
|
|
list.GoodsList = goodsList
|
|
}
|
|
return nil, err
|
|
}
|