优化和平小店兑换记录查询

This commit is contained in:
yml2213
2026-08-09 12:54:37 +08:00
parent 8919d020c5
commit 1cd94c0179
7 changed files with 396 additions and 842 deletions
+12 -5
View File
@@ -307,10 +307,13 @@ type xiaodianOrderList struct {
}
type xiaodianOrder struct {
BuyTime string `json:"dtBuyTime"`
PayTime string `json:"dtPayTime"`
Status string `json:"iStatus"`
GoodsRaw string `json:"sGoodsInfo"`
BuyTime string `json:"dtBuyTime"`
PayTime string `json:"dtPayTime"`
Status string `json:"iStatus"`
Price xiaodianFlexibleString `json:"iPrice"`
PayAmount xiaodianFlexibleString `json:"iPayAmount"`
RoleName string `json:"sRoleName"`
GoodsRaw string `json:"sGoodsInfo"`
}
type xiaodianOrderGoods struct {
@@ -896,10 +899,14 @@ func (c *DouyuClient) XiaodianExchangeList(cookie string) ([]types.XiaodianExcha
}
}
for _, item := range goods.List {
price := parseXiaodianInt(string(order.PayAmount))
if strings.TrimSpace(string(order.PayAmount)) == "" {
price = parseXiaodianInt(string(order.Price))
}
all = append(all, types.XiaodianExchangeRecord{
CommodityID: item.GoodsID, CommodityName: item.GoodsName,
Quantity: parseXiaodianInt(string(item.Quantity)), BuyTime: order.BuyTime,
PayTime: order.PayTime, Status: order.Status,
PayTime: order.PayTime, Price: price, RoleName: order.RoleName, Status: order.Status,
})
}
}
+4 -1
View File
@@ -331,7 +331,7 @@ func TestXiaodianExchangeListUsesOrderListAndParsesGoods(t *testing.T) {
if got := r.URL.Query().Get("_sid"); got != "8" {
t.Errorf("_sid = %q", got)
}
_, _ = w.Write([]byte(`var info={"data":{"cnt":1,"list":[{"dtBuyTime":"2026-08-08 01:00:42","dtPayTime":"2026-08-08 01:00:55","iStatus":"3","sGoodsInfo":"{\"list\":[{\"iGoodsId\":\"1565395\",\"sGoodsName\":\"改名卡\",\"iQuantity\":\"2\"}]}"}]}};`))
_, _ = w.Write([]byte(`var info={"data":{"cnt":1,"list":[{"dtBuyTime":"2026-08-08 01:00:42","dtPayTime":"2026-08-08 01:00:55","iStatus":"3","iPrice":"200","iPayAmount":"180","sRoleName":"测试角色","sGoodsInfo":"{\"list\":[{\"iGoodsId\":\"1565395\",\"sGoodsName\":\"改名卡\",\"iQuantity\":\"2\"}]}"}]}};`))
default:
http.NotFound(w, r)
}
@@ -356,6 +356,9 @@ func TestXiaodianExchangeListUsesOrderListAndParsesGoods(t *testing.T) {
if got.CommodityID != "1565395" || got.CommodityName != "改名卡" || got.Quantity != 2 || got.Status != "3" {
t.Fatalf("记录解析异常: %#v", got)
}
if got.Price != 180 || got.RoleName != "测试角色" {
t.Fatalf("订单扩展字段异常: %#v", got)
}
}
func testCTNClient(t *testing.T, ctnURL string) *DouyuClient {