From ee962053dfbf0f9c21979bf8760dc46d54e61731 Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Sun, 9 Apr 2023 10:40:20 +0800 Subject: [PATCH] price --- model/orders.go | 51 +++++++++++++++++----------------- worker/common/processor.go | 8 ++++-- worker/dadi/processor.go | 18 ++++++------ worker/dadi/type.go | 6 ++-- worker/haha/haha_sync_order.go | 1 + worker/worker.go | 15 ++++++---- 6 files changed, 56 insertions(+), 43 deletions(-) diff --git a/model/orders.go b/model/orders.go index 5e76aab..e3145db 100644 --- a/model/orders.go +++ b/model/orders.go @@ -10,31 +10,32 @@ var ( ) type Order struct { - Id int64 - OrderId string - StartTime string - StartDate string - TotalPrice int64 - PayPrice int64 - MinPrice int64 - MaxPrice int64 - MaoyanPrice int64 - SeatNum int - Seats string - ShowTime int64 - PayTime int64 - CityName string - ProvinceName string - Ting string - CinemaName string - MovieName string - Address string - Count int - IsSeat int - LoverSeat int - CreateDate string - CreateTime int64 - UpdateTime int64 + Id int64 + OrderId string + StartTime string + StartDate string + TotalPrice int64 + PayPrice int64 + MinPrice int64 + MaxPrice int64 + MaoyanPrice int64 + SeatNum int + Seats string + ShowTime int64 + PayTime int64 + OrderCreateTime int64 + CityName string + ProvinceName string + Ting string + CinemaName string + MovieName string + Address string + Count int + IsSeat int + LoverSeat int + CreateDate string + CreateTime int64 + UpdateTime int64 } func AddOrder(o *Order) (int64, error) { diff --git a/worker/common/processor.go b/worker/common/processor.go index d1fa7eb..cea65fe 100644 --- a/worker/common/processor.go +++ b/worker/common/processor.go @@ -3,9 +3,11 @@ package common import "film/model" type CheckInfo struct { - TotalPrice int64 - UnitPrice int64 - BillCode string + TotalOriginPrice int64 + TotalRealPrice int64 + TotalCouponPrice int64 + UnitPrice int64 + BillCode string } type OrderInfo struct { diff --git a/worker/dadi/processor.go b/worker/dadi/processor.go index 4a6c12e..fe23ee8 100644 --- a/worker/dadi/processor.go +++ b/worker/dadi/processor.go @@ -3,7 +3,6 @@ package dadi import ( "encoding/json" "film/base/httputil" - "film/base/util" "film/model" "film/worker/common" "fmt" @@ -268,10 +267,11 @@ func (p *Processor) prevOrderInfo(cinema *Cinema, seatGoods []*SeatGoods) (*Prev } log.Debugf("[newPriceCalculate] response : %s", goutil.EncodeJSON(data)) - totalRealPrice := cast.ToFloat64(cast.ToStringMap(data)["totalRealPrice"]) - + realData := cast.ToStringMap(data) previewOrder := new(PreviewOrder) - previewOrder.TotalPrice = int64(totalRealPrice * 100) + previewOrder.TotalOriginPrice = int64(cast.ToFloat64(realData["ticketOriginPrice"]) * 100) + previewOrder.TotalRealPrice = int64(cast.ToFloat64(realData["ticketRealPrice"]) * 100) + previewOrder.TotalCouponPrice = int64(cast.ToFloat64(realData["ticketCouponPrice"]) * 100) previewOrder.BillCode = billCode return previewOrder, nil @@ -296,11 +296,13 @@ func (p *Processor) CheckOrder(order *model.Order) (*common.CheckInfo, error) { } result := new(common.CheckInfo) - result.UnitPrice = previewOrder.TotalPrice / int64(order.SeatNum) - result.TotalPrice = previewOrder.TotalPrice + result.TotalRealPrice = previewOrder.TotalRealPrice + result.TotalRealPrice = previewOrder.TotalOriginPrice + result.TotalRealPrice = previewOrder.TotalCouponPrice + result.UnitPrice = previewOrder.TotalRealPrice / int64(order.SeatNum) result.BillCode = previewOrder.BillCode - log.Infof("check order[%s][%s] totalPrice[%s] [%s][%s][%s] success", - order.OrderId, result.BillCode, util.MoneyFen(previewOrder.TotalPrice), + log.Infof("check order[%s][%s] previewOrder[%s] [%s][%s][%s] success", + order.OrderId, result.BillCode, goutil.EncodeJSON(previewOrder), order.CityName, order.CinemaName, order.MovieName) return result, nil } diff --git a/worker/dadi/type.go b/worker/dadi/type.go index e822691..6f64810 100644 --- a/worker/dadi/type.go +++ b/worker/dadi/type.go @@ -1,8 +1,10 @@ package dadi type PreviewOrder struct { - BillCode string - TotalPrice int64 + TotalOriginPrice int64 + TotalRealPrice int64 + TotalCouponPrice int64 + BillCode string } type SeatGoods struct { diff --git a/worker/haha/haha_sync_order.go b/worker/haha/haha_sync_order.go index ec6cdc7..41dea70 100644 --- a/worker/haha/haha_sync_order.go +++ b/worker/haha/haha_sync_order.go @@ -88,6 +88,7 @@ func (s *SyncOrder) run() { order.Seats = cast.ToString(data["seats"]) order.ShowTime = cast.ToInt64(data["show_time"]) order.PayTime = cast.ToInt64(data["pay_time"]) + order.OrderCreateTime = cast.ToInt64(data["create_time"]) order.CityName = cast.ToString(data["cityName"]) order.ProvinceName = cast.ToString(data["provinceName"]) order.MovieName = cast.ToString(data["movieName"]) diff --git a/worker/worker.go b/worker/worker.go index a2ee3dc..7ffef8a 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -75,8 +75,9 @@ func (w *Worker) Run() { message = append(message, "【哈哈票订单信息】") message = append(message, fmt.Sprintf("城市:%s", order.CityName)) message = append(message, fmt.Sprintf("影院:%s", order.CinemaName)) - message = append(message, fmt.Sprintf("影厅:%s", order.Ting)) message = append(message, fmt.Sprintf("影片:%s", order.MovieName)) + message = append(message, fmt.Sprintf("影厅:%s", order.Ting)) + message = append(message, fmt.Sprintf("时间:%s", time.Unix(order.ShowTime, 0).Format("2006-01-02 15:04"))) message = append(message, fmt.Sprintf("座位:%s,%s,%s", order.Seats, goutil.If(order.IsSeat == 3, "可以调座", "不可调座"), goutil.If(order.LoverSeat == 1, "情侣座", "普通座"))) @@ -84,12 +85,16 @@ func (w *Worker) Run() { message = append(message, fmt.Sprintf("编号:%s", order.OrderId)) message = append(message, fmt.Sprintf("总金额:%.2f(%d)", float64(order.TotalPrice)/100, order.SeatNum)) message = append(message, fmt.Sprintf("报价范围:%.2f~%.2f", float64(order.MinPrice)/100, float64(order.MaxPrice)/100)) - message = append(message, fmt.Sprintf("订单时间:%s", time.Unix(order.PayTime, 0).Format("2006-01-02 15:04"))) - message = append(message, fmt.Sprintf("放映时间:%s", time.Unix(order.ShowTime, 0).Format("2006-01-02 15:04"))) + message = append(message, fmt.Sprintf("支付时间:%s", time.Unix(order.PayTime, 0).Format("2006-01-02 15:04"))) + message = append(message, fmt.Sprintf("创建时间:%s", time.Unix(order.OrderCreateTime, 0).Format("2006-01-02 15:04"))) + message = append(message, fmt.Sprintf("入库时间:%s", time.Unix(order.CreateTime, 0).Format("2006-01-02 15:04"))) + message = append(message, "\n") message = append(message, "【大地订单信息】") - message = append(message, fmt.Sprintf("单价:%s", util.MoneyFen(checkInfo.UnitPrice))) - message = append(message, fmt.Sprintf("总价:%s", util.MoneyFen(checkInfo.TotalPrice))) + message = append(message, fmt.Sprintf("订单原价:%s", util.MoneyFen(checkInfo.TotalOriginPrice))) + message = append(message, fmt.Sprintf("优惠金额:%s", util.MoneyFen(checkInfo.TotalCouponPrice))) + message = append(message, fmt.Sprintf("实际总价:%s", util.MoneyFen(checkInfo.TotalRealPrice))) + message = append(message, fmt.Sprintf("实际单价:%s", util.MoneyFen(checkInfo.UnitPrice))) if err := w.qyClient.SendText([]string{"jiangyong"}, strings.Join(message, "\n")); err != nil { log.Errorf("send message error : %s", err.Error()) }