纯文件级移动,无行为变更: - delivery.go 常量、DeliveryService 结构、构造与依赖注入 - delivery_types.go 对外 DTO 与 deliveryHTTPError - delivery_provider.go 渠道取消/同步与 result_data 维护 - delivery_query.go 订单查询与发货状态构建 - delivery_bind.go 绑定与绑定结果查询 - delivery_submit.go 提交发货与提交阶段状态机 - deliveryGoodID 并入 delivery_helpers.go,链接管理并入 delivery_link.go 校验:拆分前后 55 个 func/type/const 声明完全一致(无缺失、无多出、无重复)。
119 lines
3.4 KiB
Go
119 lines
3.4 KiB
Go
package service
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func buildDeliveryProduct(openProduct *OpenOrderProduct, good map[string]interface{}) *DeliveryProduct {
|
|
if openProduct == nil {
|
|
return nil
|
|
}
|
|
product := &DeliveryProduct{
|
|
Name: openProduct.Name,
|
|
SKU: openProduct.SKU,
|
|
Game: openProduct.Game,
|
|
}
|
|
if title := stringFromMap(good, "title"); title != "" {
|
|
product.Name = title
|
|
}
|
|
product.Image = stringFromMap(good, "image")
|
|
return product
|
|
}
|
|
|
|
func isZeroCode(code interface{}) bool {
|
|
switch v := code.(type) {
|
|
case nil:
|
|
return true
|
|
case float64:
|
|
return v == 0
|
|
case string:
|
|
return v == "0"
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func stringFromMap(m map[string]interface{}, key string) string {
|
|
if m == nil {
|
|
return ""
|
|
}
|
|
switch v := m[key].(type) {
|
|
case string:
|
|
return v
|
|
case float64:
|
|
return fmt.Sprintf("%.0f", v)
|
|
default:
|
|
if v != nil {
|
|
return fmt.Sprint(v)
|
|
}
|
|
return ""
|
|
}
|
|
}
|
|
|
|
func firstNonEmpty(values ...string) string {
|
|
for _, value := range values {
|
|
if strings.TrimSpace(value) != "" {
|
|
return strings.TrimSpace(value)
|
|
}
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func gameChannelText(account map[string]interface{}) string {
|
|
area := stringFromMap(account, "game_account_area")
|
|
plat := stringFromMap(account, "game_account_plat")
|
|
if area == "" && plat == "" {
|
|
return ""
|
|
}
|
|
return strings.Trim(strings.Join([]string{area, plat}, "-"), "-")
|
|
}
|
|
|
|
func truncateDeliveryText(value string) string {
|
|
if len(value) <= 300 {
|
|
return value
|
|
}
|
|
return value[:300]
|
|
}
|
|
|
|
func deliveryGoodID(channel, sku string) string {
|
|
if channel != "dlc" {
|
|
return ""
|
|
}
|
|
return map[string]string{
|
|
"suit_alan_walker": "682ef3c5a8f40c4234c59f47",
|
|
"suit_shadow_gothic": "682ef39ca8f40c4234c59f36",
|
|
"top_black_elite_trainer": "682ef39ca8f40c4234c59f37",
|
|
"m416_hamster_gray": "682ef3c5a8f40c4234c59f52",
|
|
"bag_cute_bear": "682ef3c5a8f40c4234c59f4a",
|
|
"suit_dual_fluffy": "682ef3c5a8f40c4234c59f49",
|
|
"suit_pink_sheep": "682ef3c5a8f40c4234c59f4d",
|
|
"suit_first_peach": "682ef3c5a8f40c4234c59f48",
|
|
"suit_romantic_destiny": "682ef39ca8f40c4234c59f38",
|
|
"pack_western_cowboy": "682ef3c5a8f40c4234c59f4c",
|
|
"smoke_pink_sheep": "682ef3c5a8f40c4234c59f50",
|
|
"frag_pink_sheep": "682ef3c5a8f40c4234c59f51",
|
|
"suit_hamster_gray": "682ef3c5a8f40c4234c59f53",
|
|
"suit_cute_bear": "682ef3c5a8f40c4234c59f4b",
|
|
"bag_pink_sheep": "682ef3c5a8f40c4234c59f4f",
|
|
"helmet_pink_sheep": "682ef3c5a8f40c4234c59f4e",
|
|
"bag_hamster_gray": "682ef3c5a8f40c4234c59f55",
|
|
"helmet_hamster_gray": "682ef3c5a8f40c4234c59f54",
|
|
"suit_western_mystery": "682ef39ca8f40c4234c59f35",
|
|
"helmet_panda_treasure": "682ef39ca8f40c4234c59f39",
|
|
"suit_panda_round": "682ef39ca8f40c4234c59f3a",
|
|
"suit_panda_tuan": "682ef39ca8f40c4234c59f3b",
|
|
"pack_lava_ranger": "682ef39ca8f40c4234c59f3c",
|
|
"suit_sand_dancer": "682ef39ca8f40c4234c59f3d",
|
|
"pack_star_roam_outfit": "682ef39ca8f40c4234c59f3e",
|
|
"pack_star_roam_weapon": "682ef39ca8f40c4234c59f3f",
|
|
"suit_cloud_bear": "682ef39ca8f40c4234c59f40",
|
|
"honor_medal_x2": "682ef39ca8f40c4234c59f45",
|
|
"honor_medal_x30": "682ef39ca8f40c4234c59f43",
|
|
"honor_medal_x90": "682ef39ca8f40c4234c59f41",
|
|
"lucky_coin_x2": "682ef39ca8f40c4234c59f46",
|
|
"lucky_coin_x30": "682ef39ca8f40c4234c59f44",
|
|
"lucky_coin_x90": "682ef39ca8f40c4234c59f42",
|
|
}[sku]
|
|
}
|