diff --git a/platformapi/tao_vegetable/order_test.go b/platformapi/tao_vegetable/order_test.go index 51c2c996..791482d9 100644 --- a/platformapi/tao_vegetable/order_test.go +++ b/platformapi/tao_vegetable/order_test.go @@ -1,6 +1,7 @@ package tao_vegetable import ( + "encoding/json" "fmt" domain3156 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/domain" request3156 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability3156/request" @@ -9,7 +10,7 @@ import ( "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/util" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/globals" - "strings" + "strconv" "testing" "time" ) @@ -151,9 +152,17 @@ func TestPickUp(t *testing.T) { } func TestString(t *testing.T) { - aa := `{\"income\":\"1\",\"sub_discount_merchant_item_fee\":\"0\",\"afterRefund\":\"false\",\"discount\":\"[]\",\"sub_refund_item_fee\":\"1800\",\"scenarioGroup\":\"TB\",\"saleUnit\":\"份\",\"refundPostFee\":\"0\",\"refundPlatformFee\":\"0\",\"skuName\":\"西兰花 500g/份\",\"wdkrfqr\":\"{\\\"operatorType\\\":1,\\\"operatorId\\\":3460808748,\\\"operatorName\\\":\\\"BUYER\\\"}\",\"skuBrandSubsidyFee\":\"0\",\"refundSaleQuantity\":\"3\",\"wdkrc\":\"{\\\"operatorType\\\":2,\\\"operatorId\\\":\\\"SYSTEM\\\",\\\"operatorName\\\":\\\"系统\\\"}\",\"price\":\"900\",\"orderClient\":\"2\",\"wdkdfqrrr\":\"补差退款\",\"refundTotalSubCount\":\"1\",\"discount_merchant_fee\":\"0\",\"skuMerchantOfflineSubsidyFee\":\"0\",\"barcode\":\"19930827\",\"refundExpectRefundQuantity\":\"0.0\",\"wdkRefundSource\":\"3\",\"tbBizOrderId\":\"1930666550864804887\",\"wdkrfqrmemo\":\"系统代发起补差退款\",\"gmtDisputeEndTime\":\"2023-07-10 14:14:53\",\"sub_discount_platform_brand_item_fee\":\"0\",\"discount_platform_fee\":\"0\",\"stockUnit\":\"份\",\"tbBizParentId\":\"1930666550863804887\",\"sub_refund_fee\":\"1800\",\"sub_discount_platform_channel_item_fee\":\"0\",\"sub_discount_platform_agent_item_fee\":\"0\",\"weightItem\":\"0\",\"sub_discount_platform_item_fee\":\"0\",\"skuMerchantOnlineSubsidyFee\":\"0\"}` - - a2 := strings.Index(aa, "skuName") - a3 := strings.Index(aa, "wdkrfqr") - fmt.Println(aa[a2+12 : a3-5]) + skuSt := `{\"income\":\"1\",\"sub_discount_merchant_item_fee\":\"0\",\"afterRefund\":\"false\",\"reverseCaseId\":\"1000010862920670044\",\"discount\":\"[]\",\"sub_refund_item_fee\":\"1800\",\"scenarioGroup\":\"TB\",\"saleUnit\":\"份\",\"refundPostFee\":\"0\",\"refundPlatformFee\":\"0\",\"skuName\":\"西兰花 500g/份\",\"wdkrfqr\":\"{\\\"operatorType\\\":1,\\\"operatorId\\\":3460808748,\\\"operatorName\\\":\\\"BUYER\\\"}\",\"skuBrandSubsidyFee\":\"0\",\"refundSaleQuantity\":\"3\",\"wdkrc\":\"{\\\"operatorType\\\":2,\\\"operatorId\\\":\\\"SYSTEM\\\",\\\"operatorName\\\":\\\"系统\\\"}\",\"price\":\"900\",\"orderClient\":\"2\",\"wdkdfqrrr\":\"补差退款\",\"refundTotalSubCount\":\"1\",\"discount_merchant_fee\":\"0\",\"skuMerchantOfflineSubsidyFee\":\"0\",\"barcode\":\"19930827\",\"refundExpectRefundQuantity\":\"0.0\",\"wdkRefundSource\":\"3\",\"tbBizOrderId\":\"1930802089555804887\",\"wdkrfqrmemo\":\"系统代发起补差退款\",\"gmtDisputeEndTime\":\"2023-07-10 15:53:07\",\"sub_discount_platform_brand_item_fee\":\"0\",\"discount_platform_fee\":\"0\",\"stockUnit\":\"份\",\"tbBizParentId\":\"1930802089553804887\",\"sub_refund_fee\":\"1800\",\"sub_discount_platform_channel_item_fee\":\"0\",\"sub_discount_platform_agent_item_fee\":\"0\",\"weightItem\":\"0\",\"sub_discount_platform_item_fee\":\"0\",\"skuMerchantOnlineSubsidyFee\":\"0\"}` + str2, err := strconv.Unquote("\"" + skuSt + "\"") + fmt.Println("err111", err) + data := &GoodsScarceRefund{} + if err := json.Unmarshal([]byte(str2), &data); err != nil { + fmt.Println("err = ", err) + return + } + fmt.Println("data = ", data) + //a2 := strings.Index(skuSt, "skuName") + //a3 := strings.Index(skuSt, "wdkrfqr") + //skuName := skuSt[a2+12 : a3-5] + //fmt.Println(skuName) }