1
This commit is contained in:
@@ -3,10 +3,8 @@ package dadaapi
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"go.uber.org/zap"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -196,58 +194,3 @@ func Test222222(t *testing.T) {
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
func Test111(t *testing.T) {
|
||||
SplitUniversalOrderID("313943552673")
|
||||
}
|
||||
|
||||
func SplitUniversalOrderID(universalOrderID string) (orderID string, vendorID int) {
|
||||
index := strings.Index(universalOrderID, "|")
|
||||
if index != -1 {
|
||||
orderID = universalOrderID[:index]
|
||||
vendorID = int(utils.Str2Int64(universalOrderID[index+1:]))
|
||||
} else {
|
||||
if vendorID = GetPossibleVendorIDFromVendorOrderID(universalOrderID); vendorID == -1 {
|
||||
panic(fmt.Sprintf("unkown order type, orderID:%s", universalOrderID))
|
||||
}
|
||||
orderID = universalOrderID
|
||||
}
|
||||
return orderID, vendorID
|
||||
}
|
||||
|
||||
func GetPossibleVendorIDFromVendorOrderID(vendorOrderID string) (vendorID int) {
|
||||
vendorID = -1
|
||||
//if vendorOrderIDInt64 := utils.Str2Int64WithDefault(vendorOrderID, 0); vendorOrderIDInt64 > 0 {
|
||||
orderIDLen := len(vendorOrderID)
|
||||
// 5287873015048 13 wsc
|
||||
// 15380342248732 14 old ebai order
|
||||
// 800402581000221 15,16 jd order
|
||||
// 33437032333978492 17 mtwm order
|
||||
// 3022716176275221584 19 elm order, new ebai order
|
||||
|
||||
// 京东到家从2020年开始订单号的长度都会在现有基础上加一位,订单号的前两位取的是当年的最后两位数(如:2020取的20),以适应业务的发展。
|
||||
// 改造点:
|
||||
// 1、订单号位数变化,由原有15位数增加1位数调整为16位数,对接商家需检查是否有对订单号位数做长度校验。
|
||||
// 2、第一位数字发生变化,由原来9开头调整为当年年份后两位数如:2020年订单开头为20;
|
||||
if orderIDLen == len("925265130002541") || orderIDLen == len("1925265130002541") {
|
||||
vendorID = 0
|
||||
} else if orderIDLen == len("3022716176275221584") {
|
||||
// vendorID = model.VendorIDELM
|
||||
vendorID = 3 // 饿百零售开放平台订单接口中订单ID“order_id”字段长度将调整为19位,和饿了么订单ID“eleme_order_id”字段格式保持一致。
|
||||
} else if orderIDLen == len("15380342248732") {
|
||||
if vendorOrderID[:2] == "88" {
|
||||
vendorID = 9
|
||||
} else {
|
||||
vendorID = 3
|
||||
}
|
||||
} else if orderIDLen == len("33437032333978492") || orderIDLen == len("116379390766579767") {
|
||||
vendorID = 1
|
||||
} else if orderIDLen == len("5287873015048") {
|
||||
vendorID = 11
|
||||
} else if orderIDLen == len("1000004390") {
|
||||
vendorID = 9
|
||||
} else if orderIDLen == len("18100216009800000001") || orderIDLen == len("191075245758000000039") {
|
||||
vendorID = 5
|
||||
}
|
||||
return vendorID
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// 京西速食(蔬菜)
|
||||
var token1 = `{"access_token":"inj8cpkpri1j7t4nq1hehos0000yhugi-11","expires_in":1742841858,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市","refresh_token":"u4qcjoscrj1j7t4nq1hehos0000yhugi-12","authority_id":""}`
|
||||
var token1 = `{"access_token":"ntx7g036841j7t4nq1hehos0000yhugi-11","expires_in":1745854497,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市","refresh_token":"u2d0v1sjz11j7t4nq1hehos0000yhugi-12","authority_id":""}`
|
||||
|
||||
// 美好菜市
|
||||
//var token1 = `{"access_token":"9a315a03-c737-4a82-ae52-c9a6ce827007","expires_in":1699490747,"scope":"SCOPE","shop_id":68032645,"shop_name":"美好菜市","refresh_token":"8334c006-5301-4d25-911b-4d8cc7b70ebb","authority_id":""}`
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestN2ame(t *testing.T) {
|
||||
polay := make(map[string]interface{}, 0)
|
||||
polay["a"] = ""
|
||||
polay["b"] = "1"
|
||||
|
||||
fmt.Println(polay["a"].(string))
|
||||
fmt.Println(polay["b"].(string))
|
||||
fmt.Println(polay["c"].(string))
|
||||
a.GetProductUpdateRule(32241)
|
||||
}
|
||||
|
||||
func TestGetRecommendCategory(t *testing.T) {
|
||||
|
||||
@@ -82,27 +82,82 @@ func TestEiduPrice(t *testing.T) {
|
||||
// s上架1
|
||||
func TestEditStoreCommodity(t *testing.T) {
|
||||
err := a.EditStoreCommodity(&product_editV2_request.ProductEditV2Param{
|
||||
CategoryLeafId: 22428,
|
||||
Name: "净芹菜约350g/份(净菜芹菜摘叶洗净,保鲜膜包装)",
|
||||
Pic: "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/PTWpUjYg_m_78dbc86c51be55406cd2f51bc863b2e0_sx_32178_www800-800",
|
||||
Description: "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/PTWpUjYg_m_4fdaab3dd1df6ed4aa8d0990b0e99ee7_sx_456574_www750-3527",
|
||||
PayType: 1,
|
||||
ReduceType: 2,
|
||||
Weight: 350,
|
||||
WeightUnit: 1,
|
||||
DeliveryDelayDay: 9999,
|
||||
Mobile: "18048531223",
|
||||
Commit: true,
|
||||
Specs: "重量|350g",
|
||||
SpecPrices: "[{\"spec_detail_name1\":\"350g\",\"spec_detail_name2\":\"\",\"spec_detail_name3\":\"\",\"stock_num\":9999,\"price\":850,\"code\":\"23010\",\"step_stock_num\":0,\"supplier_id\":\"\",\"outer_sku_id\":\"23010\",\"sku_type\":1,\"stock_num_map\":{\"79226307\":9999},\"delivery_infos\":[{\"info_type\":\"weight\",\"info_value\":\"350\",\"info_unit\":\"g\"}]}]",
|
||||
ProductFormatNew: "{\n\t\"1687\": [\n\t\t{\n\t\t\t\"diy_type\": 0,\n\t\t\t\"name\": \"品牌\",\n\t\t\t\"value\": 789194134\n\t\t}\n\t]\n}",
|
||||
StandardBrandId: 789194134,
|
||||
NeedCheckOut: false,
|
||||
ForceUseQualityList: false,
|
||||
NeedRechargeMode: false})
|
||||
ProductId: 3605562143317059130,
|
||||
ProductType: 0,
|
||||
CategoryLeafId: 32241,
|
||||
ProductFormat: "",
|
||||
Name: "三线肉约500g/份【同城配送】",
|
||||
RecommendRemark: "",
|
||||
Pic: "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/VqGYBUaL_m_4bf295c4d3b6466138c5650a4d433935_sx_504060_www800-800",
|
||||
Description: "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/VqGYBUaL_m_2e3b9a6bbf7649895bff131393b42b4c_sx_463917_www750-3527",
|
||||
PayType: 1,
|
||||
DeliveryMethod: 0,
|
||||
CdfCategory: "",
|
||||
ReduceType: 2,
|
||||
AssocIds: "",
|
||||
FreightId: 0,
|
||||
Weight: 500,
|
||||
WeightUnit: 1,
|
||||
DeliveryDelayDay: 9999,
|
||||
PresellType: 0,
|
||||
PresellDelay: 0,
|
||||
PresellEndTime: "",
|
||||
Supply7dayReturn: 0,
|
||||
Mobile: "18598908808",
|
||||
Commit: true,
|
||||
BrandId: 0,
|
||||
Remark: "",
|
||||
OutProductId: 0,
|
||||
QualityList: nil,
|
||||
SpecName: "",
|
||||
Specs: "重量|500g",
|
||||
SpecPrices: "[{\"spec_detail_name1\":\"500g\",\"spec_detail_name2\":\"\",\"spec_detail_name3\":\"\",\"stock_num\":999999,\"price\":3500,\"code\":\"22700\",\"step_stock_num\":0,\"supplier_id\":\"\",\"outer_sku_id\":\"22700\",\"sku_type\":1,\"stock_num_map\":{\"173965249\":999999},\"delivery_infos\":[{\"info_type\":\"weight\",\"info_value\":\"500\",\"info_unit\":\"g\"}]}]",
|
||||
SpecPic: "",
|
||||
MaximumPerOrder: 0,
|
||||
LimitPerBuyer: 0,
|
||||
MinimumPerOrder: 0,
|
||||
ProductFormatNew: "{\n\t\"1687\": [\n\t\t{\n\t\t\t\"diy_type\": 0,\n\t\t\t\"name\": \"品牌\",\n\t\t\t\"value\": 596120136\n\t\t}\n\t],\n\t\"1758\": [\n\t\t{\n\t\t\t\"diy_type\": 1,\n\t\t\t\"name\": \"包装方式\",\n\t\t\t\"value\": 8197\n\t\t}\n\t],\n\t\"1880\": [\n\t\t{\n\t\t\t\"diy_type\": 0,\n\t\t\t\"name\": \"产地\",\n\t\t\t\"value\": 13850\n\t\t}\n\t],\n\t\"2130\": [\n\t\t{\n\t\t\t\"diy_type\": 0,\n\t\t\t\"name\": \"生鲜储存温度\",\n\t\t\t\"value\": 2808\n\t\t}\n\t]\n}",
|
||||
SpuId: 0,
|
||||
AppointDeliveryDay: 0,
|
||||
ThirdUrl: "",
|
||||
Extra: "",
|
||||
Src: "",
|
||||
OuterProductId: "",
|
||||
StandardBrandId: 596120136,
|
||||
NeedCheckOut: false,
|
||||
PoiResource: nil,
|
||||
ForceUseQualityList: false,
|
||||
CarVinCode: "",
|
||||
PresellConfigLevel: 0,
|
||||
NeedRechargeMode: false,
|
||||
PresellDeliveryType: 0,
|
||||
WhiteBackGroundPicUrl: "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/VqGYBUaL_m_4bf295c4d3b6466138c5650a4d433935_sx_504060_www800-800",
|
||||
LongPicUrl: "",
|
||||
AfterSaleService: map[string]string{
|
||||
"supply_day_return_selector": "7",
|
||||
},
|
||||
SellChannel: []int64{0},
|
||||
DelayRule: nil,
|
||||
MaterialVideoId: "",
|
||||
PickupMethod: "0",
|
||||
SizeInfoTemplateId: 0,
|
||||
SubstituteGoodsUrl: "",
|
||||
SaleChannelType: "",
|
||||
NamePrefix: "",
|
||||
StoreId: 0,
|
||||
MainProductId: 0,
|
||||
SaleLimitId: 0,
|
||||
})
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
func TestStoreName(t *testing.T) {
|
||||
address := `闵庄南路京泉馨苑便民市场卖菜的第二家`
|
||||
subStr := "海淀区"
|
||||
index := strings.LastIndex(address, subStr)
|
||||
fmt.Println(address[index+len(subStr):])
|
||||
}
|
||||
|
||||
// 上架2
|
||||
func TestEditStoreCommodity2(t *testing.T) {
|
||||
a.EditStoreCommodityCommit(&product_editV2_commit_request.ProductEditV2Param2{
|
||||
|
||||
@@ -35,10 +35,14 @@ const (
|
||||
OnlinePayUrl = `https://vsp.allinpay.com/apiweb/unitorder/scanqrpay` // 扫码支付
|
||||
OnLineTransactionQuery = `https://vsp.allinpay.com/apiweb/tranx/query` // 交易查询,查询订单的支付状态
|
||||
OnLineRefund = `https://vsp.allinpay.com/apiweb/tranx/refund` // 同一退款接口
|
||||
OnLineAddterm = `https://vsp.allinpay.com/cusapi/merchantapi/addterm` // 添加设备终端
|
||||
)
|
||||
|
||||
const (
|
||||
EncryptionRsa = "RSA" // 加密方式
|
||||
EncryptionRsa = "RSA" // 加密方式
|
||||
ScannerOperrationStart = "00" // 扫码枪本次操作类型-新增
|
||||
ScannerOperrationLogOff = "02" // 扫码枪本次操作类型-注销
|
||||
ScannerOperrationUpdate = "01" // 扫码枪本次操作类型-修改
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -120,6 +124,35 @@ func (a *API) OrderRefund(param *OnLineOrderRefundParam) (statusCode, errRemake
|
||||
return payInfo.Trxstatus, payInfo.Errmsg, nil
|
||||
}
|
||||
|
||||
// TLAddTerm 采集门店终端设备信息
|
||||
func (a *API) TLAddTerm(param *AddTermReq) error {
|
||||
onlineReq := utils.Struct2Map(param, "", false)
|
||||
result, err := a.AccessAPI2(OnLineAddterm, onlineReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result["retcode"].(string) != "SUCCESS" {
|
||||
return fmt.Errorf(result["retmsg"].(string))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type AddTermReq struct {
|
||||
Orgid string `json:"orgid"` // 集团/代理商商户号 是 共享集团号/代理商参数时必填
|
||||
Cusid string `json:"cusid"` // 商户号实际交易的商户号 否
|
||||
Appid string `json:"appid"` // 应用ID平台分配的APPID 否
|
||||
Version string `json:"version"` // 版本号接口版本号 可
|
||||
|
||||
Termno string `json:"termno"` // 8位数字,商户下唯一 否
|
||||
Devicetype string `json:"devicetype"` // 设备类型 否
|
||||
Termsn string `json:"termsn"` // 终端序列号 终端类型(device_type)填写为 02、03、04、05、06、08、09 或 10时,必须填写终端序列号。
|
||||
Operation string `json:"operation"` // 本次操作标识,取值范围:00:新增;01:修改;02:注销;(注销时,仅需上送termno字段)
|
||||
Termstate string `json:"termstate"` // 取值范围:00:启用;01:注销;注:终端注销时非必填
|
||||
Termaddress string `json:"termaddress"` // 终端地址
|
||||
Signtype string `json:"signtype"`
|
||||
Sign string `json:"sign"`
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI2(action string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
params := make(map[string]interface{})
|
||||
params["appid"] = a.appID
|
||||
|
||||
Reference in New Issue
Block a user