bidprice2

This commit is contained in:
jiangyong27 2023-04-09 15:59:56 +08:00
parent f08d04f3df
commit 63c4dd7b25
2 changed files with 62 additions and 2 deletions

View File

@ -88,7 +88,43 @@ func (p *Processor) queryBid(params map[string]interface{}) ([]*BidOrder, error)
return result, nil return result, nil
} }
func (p *Processor) QueryBidding() error { func (p *Processor) QueryBidding() ([]*BidOrder, error) {
bidOrder, err := p.queryBid(map[string]interface{}{
"tab": 1,
"type": 1,
})
return nil if err != nil {
return nil, err
}
return bidOrder, nil
}
func (p *Processor) QueryBidWin() ([]*BidOrder, error) {
bidOrder, err := p.queryBid(map[string]interface{}{
"pageSize": 10,
"current": 1,
"total": 0,
"tab": 0,
"type": 1,
"mold": 1,
})
if err != nil {
return nil, err
}
return bidOrder, nil
}
func (p *Processor) QueryBidComplete() ([]*BidOrder, error) {
bidOrder, err := p.queryBid(map[string]interface{}{
"tab": 0,
"type": 2,
"form": 1,
})
if err != nil {
return nil, err
}
return bidOrder, nil
} }

View File

@ -104,6 +104,26 @@ func (w *Worker) processorDadi(order *model.Order) {
} }
} }
func (w *Worker) processBidWin() {
bidOrders, err := w.hahaProcessor.QueryBidWin()
if err != nil {
return
}
for _, o := range bidOrders {
order, err := model.GetOrder(o.OrderId)
if err != nil {
log.Errorf("get order error : %s", err.Error())
continue
}
message := w.getOrderMesasge(order)
message = append(message, "\n")
message = append(message, "【竞价成功】")
message = append(message, fmt.Sprintf("出价:%s", util.MoneyFen(o.BidPrice)))
message = append(message, fmt.Sprintf("时间:%s", goutil.TimeToDateTime(o.BidTime)))
w.qyClient.SendText(config.GetConfig().Weixin.Receiver, strings.Join(message, "\n"))
}
}
func (w *Worker) Run() { func (w *Worker) Run() {
w.initQyWeixin() w.initQyWeixin()
newOrderChan := make(chan *model.Order, 100000) newOrderChan := make(chan *model.Order, 100000)
@ -129,6 +149,7 @@ func (w *Worker) Run() {
w.dadiProcessor = dadiProcessor w.dadiProcessor = dadiProcessor
} }
bidUploadTimer := time.NewTicker(10 * time.Second)
for { for {
select { select {
case order := <-newOrderChan: case order := <-newOrderChan:
@ -141,6 +162,9 @@ func (w *Worker) Run() {
case updateOrder := <-updateOrderChan: case updateOrder := <-updateOrderChan:
log.Tracef("%s update", updateOrder.String()) log.Tracef("%s update", updateOrder.String())
case <-bidUploadTimer.C:
w.processBidWin()
} }
} }