提交 dd40b0f1 authored 作者: 屈传平's avatar 屈传平

ikucun

package ikucun
import (
"context"
"crypto/sha1"
"encoding/hex"
"fmt"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
"math/rand"
"net/url"
"sort"
"strings"
"time"
)
var server *Config
func New(req *Config) {
server = req
return
}
const pkgName = "ikucun"
type Config struct {
AppId string
AppSecret string
ApiUrl string
AccessToken string
}
// 生成随机 nonce 字符串 (等效 JS 的 makeNonceStr)
func makeNonceStr() string {
// 原始有效字符集(排除易混淆字符)
const baseStr = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789"
// 打乱字符顺序(Go 的稳定洗牌算法)
shuffled := []rune(baseStr)
rand.Seed(time.Now().UnixNano())
rand.Shuffle(len(shuffled), func(i, j int) {
shuffled[i], shuffled[j] = shuffled[j], shuffled[i]
})
// 随机截取 10 位字符
start := rand.Intn(len(shuffled) - 10)
return string(shuffled[start : start+10])
}
// 构建签名前字符串 (等效 JS 的 beforeSignBuild)
func beforeSignBuild(nonceStr, interfaceName string, queryParams map[string]string, body string) string {
// 处理空参数
if queryParams == nil {
queryParams = make(map[string]string)
}
// 准备 POST 参数
postParams := make(map[string]string)
if body != "" {
postParams["body"] = body
}
// 获取公共参数
appSecret := server.AppSecret
timestamp := time.Now().Unix() // 直接获取秒级时间戳
commonParams := map[string]string{
"appid": queryParams["appid"],
"noncestr": nonceStr,
"timestamp": fmt.Sprintf("%d", timestamp),
"version": queryParams["version"],
"appsecret": appSecret,
"format": queryParams["json"],
"interfaceName": interfaceName,
}
// 合并参数(注意合并顺序)
allParams := make(map[string]string)
for k, v := range commonParams {
allParams[k] = v
}
for k, v := range queryParams {
allParams[k] = v
}
for k, v := range postParams {
allParams[k] = v
}
// 按键名排序
keys := make([]string, 0, len(allParams))
for k := range allParams {
keys = append(keys, k)
}
sort.Strings(keys)
// 构建签名字符串
var builder strings.Builder
for i, k := range keys {
if i > 0 {
builder.WriteString("&")
}
builder.WriteString(fmt.Sprintf("%s=%s", k, allParams[k]))
}
return builder.String()
}
func getQueryParams(interfaceName, body string) map[string]string {
// 生成 nonce 并添加到查询参数
nonceStr := makeNonceStr()
timestamp := time.Now().Unix() // 直接获取秒级时间戳
queryParams := map[string]string{
"appid": server.AppId,
"version": "1.0",
"format": "json",
"timestamp": fmt.Sprintf("%d", timestamp),
"interfaceName": interfaceName,
"accessToken": server.AccessToken,
// 其他查询参数...
}
queryParams["noncestr"] = nonceStr
// 构建签名前字符串
signStr := beforeSignBuild(
nonceStr,
interfaceName,
queryParams,
body,
)
// 计算 SHA1 签名
hasher := sha1.New()
hasher.Write([]byte(signStr))
sign := hex.EncodeToString(hasher.Sum(nil))
// 添加签名到查询参数
queryParams["sign"] = sign
//res := gsha1.Encrypt(req)
return queryParams
}
// 处理 interface{} 类型的值
func mapToSortedQuery(params map[string]string) string {
if len(params) == 0 {
return ""
}
keys := make([]string, 0, len(params))
for k := range params {
keys = append(keys, k)
}
sort.Strings(keys)
var builder strings.Builder
for i, k := range keys {
if i > 0 {
builder.WriteByte('&')
}
builder.WriteString(url.QueryEscape(k))
builder.WriteByte('=')
builder.WriteString(url.QueryEscape(params[k]))
}
return builder.String()
}
func post(ctx context.Context, method string, req interface{}) (res string, err error) {
Start := gtime.TimestampMilli()
param := gjson.New(req)
queryParam := getQueryParams(method, param.MustToJsonString())
Url := server.ApiUrl + "?" + mapToSortedQuery(queryParam)
Request := g.Client()
Request.SetHeader("Content-Type", "application/json")
resp, err := Request.Timeout(time.Second*5).Post(Url, param.MustToJsonString())
defer func() {
_ = resp.Close()
ctx = context.WithValue(ctx, "Method", "POST")
ctx = context.WithValue(ctx, "URI", Url)
if err != nil {
g.Log().Ctx(ctx).Cat(pkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v ms】", param.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
} else {
g.Log().Ctx(ctx).Cat(pkgName).Infof("参数【%v】响应【%v】响应时间【%v ms】", param.MustToJsonString(), res, gtime.TimestampMilli()-Start)
}
}()
res = resp.ReadAllString()
return
}
package ikucun
import (
"context"
"github.com/gogf/gf/encoding/gjson"
)
type activityIkc struct {
}
//Activity 活动
var Activity = activityIkc{}
type ActivityListReq struct {
PageIndex string `json:"pageIndex"`
PageSize string `json:"pageSize"`
}
type ActivityListRes struct {
Code string `json:"code"`
Success bool `json:"success"`
Message string `json:"message"`
Data struct {
ActivityList []struct {
ActivityId string `json:"activityId"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
ActiveType int `json:"activeType"`
UpDownStatus int `json:"upDownStatus"`
} `json:"activityList"`
} `json:"data"`
}
//List 列表
func (*activityIkc) List(ctx context.Context, req *ActivityListReq) (res *ActivityListRes, err error) {
method := "mengxiang.supply.consignment.activity.search"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
package ikucun
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type address struct {
}
var Address = address{}
type AddressProvinceRes struct {
Code int `json:"code"`
Message string `json:"message"`
Success bool `json:"success"`
Data []struct {
Id string `json:"id"`
Name string `json:"name"`
LevelType int `json:"levelType"`
ParentId interface{} `json:"parentId"`
MergerName string `json:"mergerName"`
} `json:"data"`
}
func (s *msg) Province(ctx context.Context) (res *AddressProvinceRes, err error) {
method := "aikucun.base.address.province.list"
result, err := post(ctx, method, g.Map{})
_ = gjson.New(result).Scan(&res)
return
}
type AddressCityReq struct {
ProvinceId string `json:"provinceId"`
}
type AddressCityRes struct {
Code int `json:"code"`
Message string `json:"message"`
Success bool `json:"success"`
Data []struct {
Id string `json:"id"`
Name string `json:"name"`
LevelType int `json:"levelType"`
ParentId string `json:"parentId"`
MergerName string `json:"mergerName"`
} `json:"data"`
}
func (s *msg) City(ctx context.Context, req *AddressCityReq) (res *AddressCityRes, err error) {
method := "aikucun.base.address.city.list"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type AddressAreaReq struct {
CityId string `json:"cityId"`
}
type AddressAreaRes struct {
Code int `json:"code"`
Message string `json:"message"`
Success bool `json:"success"`
Data []struct {
Id string `json:"id"`
Name string `json:"name"`
LevelType int `json:"levelType"`
ParentId string `json:"parentId"`
MergerName string `json:"mergerName"`
} `json:"data"`
}
func (s *msg) Area(ctx context.Context, req *AddressAreaReq) (res *AddressAreaRes, err error) {
method := "aikucun.base.address.district.list"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type AddressStreetReq struct {
DistrictId string `json:"districtId"`
}
type AddressStreetRes struct {
Code int `json:"code"`
Message string `json:"message"`
Success bool `json:"success"`
Data []struct {
Id string `json:"id"`
Name string `json:"name"`
LevelType int `json:"levelType"`
ParentId string `json:"parentId"`
MergerName string `json:"mergerName"`
CityCode string `json:"cityCode"`
ZipCode string `json:"zipCode"`
Lng interface{} `json:"lng"`
Lat interface{} `json:"lat"`
Pinyin string `json:"pinyin"`
ShortName string `json:"shortName"`
DeleteFlag int `json:"deleteFlag"`
AreaId interface{} `json:"areaId"`
AreaName interface{} `json:"areaName"`
} `json:"data"`
}
func (s *msg) Street(ctx context.Context, req *AddressStreetReq) (res *AddressStreetRes, err error) {
method := "aikucun.base.address.villages.list"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
package ikucun
import (
"context"
"github.com/gogf/gf/encoding/gjson"
)
type goods struct {
}
var Goods = goods{}
type GoodsListReq struct {
PageIndex string `json:"pageIndex"`
PageSize string `json:"pageSize"`
}
type GoodsListRes struct {
Code string `json:"code"`
Success bool `json:"success"`
Message string `json:"message"`
Data struct {
GoodsList []struct {
ActivityId string `json:"activityId"`
ActivitySpuId string `json:"activitySpuId"`
ProductNum string `json:"productNum"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
SpuId string `json:"spuId"`
SpuType string `json:"spuType"`
SpuName string `json:"spuName"`
SpuImage []string `json:"spuImage"`
Status int `json:"status"`
SoldOut bool `json:"soldOut"`
CategoryCode string `json:"categoryCode"`
CategoryName string `json:"categoryName"`
SecondCategoryCode string `json:"secondCategoryCode"`
SecondCategoryName string `json:"secondCategoryName"`
FirstCategoryCode string `json:"firstCategoryCode"`
FirstCategoryName string `json:"firstCategoryName"`
BrandId string `json:"brandId"`
BrandName string `json:"brandName"`
BrandLogo string `json:"brandLogo"`
SpuDetailImage []string `json:"spuDetailImage"`
SizeImage string `json:"sizeImage,omitempty"`
SalesAttributeInfoList []struct {
AttributeCode string `json:"attributeCode"`
AttributeName string `json:"attributeName"`
AttributeValue string `json:"attributeValue"`
Priority int `json:"priority"`
AttributeImage []string `json:"attributeImage"`
} `json:"salesAttributeInfoList"`
BaseAttributeInfoList []struct {
AttributeCode string `json:"attributeCode"`
AttributeName string `json:"attributeName"`
AttributeValue string `json:"attributeValue"`
} `json:"baseAttributeInfoList"`
SkuList []struct {
SkuId string `json:"skuId"`
SoldOut bool `json:"soldOut"`
SalesAttributeInfoList []struct {
AttributeName string `json:"attributeName"`
AttributeValue string `json:"attributeValue"`
Priority int `json:"priority"`
} `json:"salesAttributeInfoList"`
BaseAttributeInfoList []struct {
AttributeCode string `json:"attributeCode"`
AttributeName string `json:"attributeName"`
AttributeValue string `json:"attributeValue"`
} `json:"baseAttributeInfoList"`
CurrentPriceInfo struct {
ActivitySpuId string `json:"activitySpuId"`
MarketingPrice int `json:"marketingPrice"`
Commission float64 `json:"commission"`
CommissionAddition int `json:"commissionAddition"`
SupplyPrice float64 `json:"supplyPrice"`
TagPrice int `json:"tagPrice"`
SowingPrice int `json:"sowingPrice"`
PromotionDetailInfoList []struct {
PromotionId string `json:"promotionId"`
PromotionType string `json:"promotionType"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
PromoPrice int `json:"promoPrice"`
SupplyPrice float64 `json:"supplyPrice"`
} `json:"promotionDetailInfoList,omitempty"`
} `json:"currentPriceInfo"`
AdvancePriceInfo struct {
} `json:"advancePriceInfo"`
} `json:"skuList"`
} `json:"goodsList"`
} `json:"data"`
}
//List 列表
func (s *goods) List(ctx context.Context, req *GoodsListReq) (res *GoodsListRes, err error) {
method := "mengxiang.supply.consignment.goods.search"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type GoodsDetailReq struct {
ThirdUserId string `json:"thirdUserId"`
SpuId string `json:"spuId"`
}
type GoodsDetailRes struct {
Code string `json:"code"`
Success bool `json:"success"`
Message string `json:"message"`
Data struct {
ActivityId string `json:"activityId"`
ActivitySpuId string `json:"activitySpuId"`
ProductNum string `json:"productNum"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
SpuId string `json:"spuId"`
SpuType string `json:"spuType"`
SpuName string `json:"spuName"`
SpuImage []string `json:"spuImage"`
Status int `json:"status"`
SoldOut bool `json:"soldOut"`
CategoryCode string `json:"categoryCode"`
CategoryName string `json:"categoryName"`
SecondCategoryCode string `json:"secondCategoryCode"`
SecondCategoryName string `json:"secondCategoryName"`
FirstCategoryCode string `json:"firstCategoryCode"`
FirstCategoryName string `json:"firstCategoryName"`
BrandId string `json:"brandId"`
BrandName string `json:"brandName"`
BrandLogo string `json:"brandLogo"`
SpuDetailImage []string `json:"spuDetailImage"`
SizeImage string `json:"sizeImage"`
SalesAttributeInfoList []struct {
AttributeCode string `json:"attributeCode"`
AttributeName string `json:"attributeName"`
AttributeValue string `json:"attributeValue"`
Priority int `json:"priority"`
AttributeImage []string `json:"attributeImage"`
} `json:"salesAttributeInfoList"`
BaseAttributeInfoList []struct {
AttributeCode string `json:"attributeCode"`
AttributeName string `json:"attributeName"`
AttributeValue string `json:"attributeValue"`
} `json:"baseAttributeInfoList"`
SkuList []struct {
SkuId string `json:"skuId"`
SoldOut bool `json:"soldOut"`
SalesAttributeInfoList []struct {
AttributeName string `json:"attributeName"`
AttributeValue string `json:"attributeValue"`
Priority int `json:"priority"`
} `json:"salesAttributeInfoList"`
BaseAttributeInfoList []struct {
AttributeCode string `json:"attributeCode"`
AttributeName string `json:"attributeName"`
AttributeValue string `json:"attributeValue"`
} `json:"baseAttributeInfoList"`
CurrentPriceInfo struct {
ActivitySpuId string `json:"activitySpuId"`
MarketingPrice int `json:"marketingPrice"`
Commission int `json:"commission"`
CommissionAddition int `json:"commissionAddition"`
SupplyPrice int `json:"supplyPrice"`
TagPrice int `json:"tagPrice"`
SowingPrice int `json:"sowingPrice"`
} `json:"currentPriceInfo"`
AdvancePriceInfo struct {
} `json:"advancePriceInfo"`
} `json:"skuList"`
} `json:"data"`
}
//List 商品列表
func (s *goods) Detail(ctx context.Context, req *GoodsDetailReq) (res *GoodsDetailRes, err error) {
method := "mengxiang.supply.consignment.goods.detail"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
package ikucun
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type msg struct {
}
var Msg = msg{}
type MsgRes struct {
}
/**
商品变更消息通知
*/
func (s *msg) GoodsChange(ctx context.Context) (res *MsgRes, err error) {
method := "mengxiang.supply.goods.change.notify"
result, err := post(ctx, method, g.Map{})
_ = gjson.New(result).Scan(&res)
return
}
/**
规则内商品增量通知
*/
func (s *msg) RuleGoodsChange(ctx context.Context) (res *MsgRes, err error) {
method := "mengxiang.supply.rule.goods.change"
result, err := post(ctx, method, g.Map{})
_ = gjson.New(result).Scan(&res)
return
}
/**
自助选品推送通知
*/
func (s *msg) GoodsPush(ctx context.Context) (res *MsgRes, err error) {
method := "mengxiang.supply.self.goods.push"
result, err := post(ctx, method, g.Map{})
_ = gjson.New(result).Scan(&res)
return
}
/**
发货通知、修改通知
*/
func (s *msg) OrderDelivery(ctx context.Context) (res *MsgRes, err error) {
method := "mengxiang.supply.order.delivery.notify"
result, err := post(ctx, method, g.Map{})
_ = gjson.New(result).Scan(&res)
return
}
type MsgPickUpReq struct {
PickUpNo string `json:"pickUpNo"`
ThirdUserId string `json:"thirdUserId"`
PickUpStatus int `json:"pickUpStatus"`
MsgStatus int `json:"msgStatus"`
}
type MsgPickUpRes struct {
}
/**
上门取件消息通知
*/
func (s *msg) PickUp(ctx context.Context, req *MsgPickUpReq) (res *MsgPickUpRes, err error) {
method := "mengxiang.aftersale.notfiy.pick.up.changes"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type MsgAfterChangeReq struct {
GenerationTime string `json:"generationTime"`
AfterSalesNo string `json:"afterSalesNo"`
NotificationType int `json:"notificationType"`
OrderStatus int `json:"orderStatus"`
}
type MsgAfterChangeRes struct {
}
/**
售后状态变更推送
*/
func (s *msg) AftersaleChange(ctx context.Context, req *MsgAfterChangeReq) (res *MsgAfterChangeRes, err error) {
method := "mengxiang.aftersale.notify.order.changes"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
/**
订单状态通知
*/
func (s *msg) OrderNotify(ctx context.Context) (res *MsgAfterChangeRes, err error) {
method := "mengxiang.supply.order.event.notify"
result, err := post(ctx, method, g.Map{})
_ = gjson.New(result).Scan(&res)
return
}
package ikucun
import (
"context"
"github.com/gogf/gf/encoding/gjson"
)
type order struct {
}
var Order = order{}
type OrderCreateReq struct {
ThirdUserId string `json:"thirdUserId"`
ThirdOrderNo string `json:"thirdOrderNo"`
Receiver struct {
TownName string `json:"townName"`
DistrictCode string `json:"districtCode"`
CityName string `json:"cityName"`
DistrictName string `json:"districtName"`
TownCode string `json:"townCode"`
ProvinceCode string `json:"provinceCode"`
CityCode string `json:"cityCode"`
IdCardNo string `json:"idCardNo"`
Mobile string `json:"mobile"`
RecipientName string `json:"recipientName"`
ProvinceName string `json:"provinceName"`
Address string `json:"address"`
} `json:"receiver"`
SpuList []*OrderSpuList `json:"spuList"`
}
type OrderSpuList struct {
Quantity string `json:"quantity"`
MarketingSalePrice string `json:"marketingSalePrice"`
ExtSubOrderNo string `json:"extSubOrderNo"`
SpuId string `json:"spuId"`
SkuId string `json:"skuId"`
}
type OrderCreateRes struct {
Code string `json:"code"`
Success bool `json:"success"`
Message string `json:"message"`
Data struct {
OrderGroupNo string `json:"orderGroupNo"`
OrderList []struct {
OrderNo string `json:"orderNo"`
PayOverTime string `json:"payOverTime"`
Quantity int `json:"quantity"`
TotalProductAmount int `json:"totalProductAmount"`
TotalDiscountAmount int `json:"totalDiscountAmount"`
TotalCommission int `json:"totalCommission"`
TotalCommissionAddition int `json:"totalCommissionAddition"`
Freight int `json:"freight"`
TotalTax int `json:"totalTax"`
PaymentAmount int `json:"paymentAmount"`
TotalProduct2CAmount int `json:"totalProduct2CAmount"`
TotalDiscount2CAmount int `json:"totalDiscount2CAmount"`
Payment2CAmount int `json:"payment2CAmount"`
OrderSkuList []struct {
OrderSkuNo string `json:"orderSkuNo"`
SpuId string `json:"spuId"`
SkuId string `json:"skuId"`
Quantity int `json:"quantity"`
UnitPrice int `json:"unitPrice"`
SpuAmount int `json:"spuAmount"`
DiscountAmount int `json:"discountAmount"`
SkuTax int `json:"skuTax"`
SettlementAmount int `json:"settlementAmount"`
Commission int `json:"commission"`
CommissionAddition int `json:"commissionAddition"`
Spu2CAmount int `json:"spu2CAmount"`
Discount2CAmount int `json:"discount2CAmount"`
Settlement2CAmount int `json:"settlement2CAmount"`
OrderPromotionList []interface{} `json:"orderPromotionList"`
} `json:"orderSkuList"`
} `json:"orderList"`
} `json:"data"`
}
func (s *order) Create(ctx context.Context, req *OrderCreateReq) (res *OrderCreateRes, err error) {
method := "mengxiang.supply.order.create"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type OrderDetailReq struct {
OrderNo string `json:"orderNo"`
}
type OrderDetailRes struct {
Code string `json:"code"`
Success bool `json:"success"`
Message string `json:"message"`
Data struct {
OrderNo string `json:"orderNo"`
OrderType int `json:"orderType"`
OrderStatus int `json:"orderStatus"`
OrderTime string `json:"orderTime"`
TotalProductAmount int `json:"totalProductAmount"`
TotalDiscountAmount int `json:"totalDiscountAmount"`
TotalCommission int `json:"totalCommission"`
TotalIntegratedTax int `json:"totalIntegratedTax"`
Freight int `json:"freight"`
OrderGroupNo string `json:"orderGroupNo"`
PaymentAmount int `json:"paymentAmount"`
TotalProduct2CAmount int `json:"totalProduct2CAmount"`
TotalDiscount2CAmount int `json:"totalDiscount2CAmount"`
Payment2CAmount int `json:"payment2CAmount"`
PayOverTime string `json:"payOverTime"`
BrandId string `json:"brandId"`
BrandName string `json:"brandName"`
BrandLogo string `json:"brandLogo"`
ThirdUserId string `json:"thirdUserId"`
SignType int `json:"signType"`
ThirdOrderNo string `json:"thirdOrderNo"`
OrderSkuList []struct {
OrderSkuNo string `json:"orderSkuNo"`
OrderSkuStatus int `json:"orderSkuStatus"`
SpuId string `json:"spuId"`
SkuId string `json:"skuId"`
UnitPrice int `json:"unitPrice"`
ProductAmount int `json:"productAmount"`
Product2CAmount int `json:"product2CAmount"`
Discount2CAmount int `json:"discount2CAmount"`
Settlement2CAmount int `json:"settlement2CAmount"`
Commission int `json:"commission"`
DiscountAmount int `json:"discountAmount"`
SkuTax int `json:"skuTax"`
SettlementAmount int `json:"settlementAmount"`
Quantity int `json:"quantity"`
CancelQuantity int `json:"cancelQuantity"`
DeliveryQuantity int `json:"deliveryQuantity"`
UnDeliveryQuantity int `json:"unDeliveryQuantity"`
SpuName string `json:"spuName"`
SpuImage string `json:"spuImage"`
BrandName string `json:"brandName"`
BrandLogo string `json:"brandLogo"`
} `json:"orderSkuList"`
Recipient struct {
RecipientName string `json:"recipientName"`
Mobile string `json:"mobile"`
Address string `json:"address"`
ProvinceCode string `json:"provinceCode"`
CityCode string `json:"cityCode"`
DistrictCode string `json:"districtCode"`
TownCode string `json:"townCode"`
} `json:"recipient"`
} `json:"data"`
}
/*
*获取订单详情
*/
func (s *order) Detail(ctx context.Context, req *OrderDetailReq) (res *OrderDetailRes, err error) {
method := "mengxiang.supply.order.detail"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type OderLogisticsReq struct {
LogisticsNo string `json:"logisticsNo"`
LogisticsCode string `json:"logisticsCode"`
}
type OderLogisticsRes struct {
}
/*
*物流轨迹查询
*/
func (s *order) Logistics(ctx context.Context, req *OderLogisticsReq) (res *OderLogisticsRes, err error) {
method := "mengxiang.supply.logistics.trace.get"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
package ikucun
import (
"context"
"github.com/gogf/gf/encoding/gjson"
)
type orderRefund struct {
}
var OrderRefund = orderRefund{}
type OrderRefundReq struct {
ThirdUserId string `json:"thirdUserId"`
OrderNo string `json:"orderNo"`
AfterSaleApplyAmount string `json:"afterSaleApplyAmount"`
IsReceived string `json:"isReceived"`
ReturnName string `json:"returnName"`
CityId string `json:"cityId"`
AfterSaleReason string `json:"afterSaleReason"`
ProvinceId string `json:"provinceId"`
AsType string `json:"asType"`
ReturnPhone string `json:"returnPhone"`
Spec string `json:"spec"`
ReturnAddress string `json:"returnAddress"`
DistrictId string `json:"districtId"`
ProofImageUrls []string `json:"proofImageUrls"`
ApplyRemark string `json:"applyRemark"`
SkuOrderNo string `json:"skuOrderNo"`
AfterSaleApplyCount string `json:"afterSaleApplyCount"`
ExSkuId string `json:"exSkuId"`
AsReason string `json:"asReason"`
}
type OrderRefundRes struct {
}
func (s *orderRefund) Apply(ctx context.Context, req *OrderRefundReq) (res *OrderRefundRes, err error) {
method := "mengxiang.aftersale.apply.order"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type OrefundRefundCancelReq struct {
ThirdUserId string `json:"thirdUserId"`
AfterSalesNo string `json:"afterSalesNo"`
}
type OrefundRefundCancelRes struct {
}
func (s *orderRefund) Cancel(ctx context.Context, req *OrefundRefundCancelReq) (res *OrefundRefundCancelRes, err error) {
method := "mengxiang.aftersale.cancel.order"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type OrefundRefundDetailReq struct {
ThirdUserId string `json:"thirdUserId"`
AfterSalesNo string `json:"afterSalesNo"`
}
type OrefundRefundDetailRes struct {
}
func (s *orderRefund) Detail(ctx context.Context, req *OrefundRefundDetailReq) (res *OrefundRefundDetailRes, err error) {
method := "mengxiang.aftersale.order.detail"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type OrderfundRefundDetailReq struct {
OrderNo string `json:"orderNo"`
SkuOrderNo string `json:"skuOrderNo"`
ThirdUserId string `json:"thirdUserId"`
}
type OrderfundRefundDetailRes struct {
}
func (s *orderRefund) Check(ctx context.Context, req *OrderfundRefundDetailReq) (res *OrderfundRefundDetailRes, err error) {
method := "mengxiang.aftersale.order.support.exchange"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
package ikucun
import (
"context"
"github.com/gogf/gf/encoding/gjson"
)
type user struct {
}
var User = user{}
type UserInfoReq struct {
ThirdUserId string `json:"thirdUserId"`
Mobile string `json:"mobile"`
Name string `json:"name"`
}
type UserAddRes struct {
Code string `json:"code"`
Success bool `json:"success"`
Message string `json:"message"`
Data bool `json:"data"`
}
func (s *user) Add(ctx context.Context, req *UserInfoReq) (res *UserAddRes, err error) {
method := "mengxiang.supply.user.create"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
type UserDetailReq struct {
ThirdUserId string `json:"thirdUserId"`
}
type UserInfoRes struct {
Code string `json:"code"`
Success bool `json:"success"`
Message string `json:"message"`
Data struct {
ThirdUserId string `json:"thirdUserId"`
Name string `json:"name"`
} `json:"data"`
}
func (s *user) Detail(ctx context.Context, req *UserDetailReq) (res *UserInfoRes, err error) {
method := "mengxiang.supply.user.detail"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
......@@ -23,6 +23,7 @@ const (
Tmv3 = 20 //天猫优选
Suning = 21 //苏宁有货
Yonghui = 22 //永辉
Ikucun = 23 //爱库存
Wangdian = 24 //旺店通
)
......@@ -117,6 +118,10 @@ func GetUpstreamList() (res interface{}, err error) {
"key": Yonghui,
"name": GetUpstreamName(Yonghui),
},
g.Map{
"key": Ikucun,
"name": GetUpstreamName(Ikucun),
},
g.Map{
"key": Wangdian,
"name": GetUpstreamName(Wangdian),
......@@ -163,6 +168,8 @@ func GetUpstreamName(source int) string {
return "苏宁易购"
case Yonghui:
return "永辉"
case Ikucun:
return "爱库存"
case Wangdian:
return "旺店通"
default:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论