Skip to content

Commit

Permalink
Merge branch 'main' into main-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ixre committed Mar 26, 2023
2 parents f8b8336 + dc3e464 commit 04082fc
Show file tree
Hide file tree
Showing 38 changed files with 1,796 additions and 1,263 deletions.
60 changes: 30 additions & 30 deletions app/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ func (d *defaultService) PaymentOrderObs(order *proto.SPaymentOrder) bool {

// 测试是否为子订单,并返回编号
func (d *defaultService) testSubId(o *proto.SSingleOrder) (string, bool) {
if o.ParentOrderId <= 0 {
return o.OrderNo, true
}
// if o.ParentOrderId <= 0 {
// return o.OrderNo, true
// }
return o.OrderNo, false
}

Expand All @@ -291,20 +291,20 @@ func (d *defaultService) batchDelKeys(conn redis.Conn, key string) {

// 设置订单过期时间
func (d *defaultService) updateOrderExpires(conn redis.Conn, o *proto.SSingleOrder) {
//订单刚创建时,设置过期时间
if o.Status == order.StatAwaitingPayment {
trans, cli, _ := service.FoundationServiceClient()
defer trans.Close()
ss, _ := cli.GetGlobMchSaleConf_(context.TODO(), &proto.Empty{})
unix := o.UpdateTime + int64(ss.OrderTimeOutMinute)*60
t := time.Unix(unix, 0)
tk := getTick(t)
orderNo, sub := d.testSubId(o)
prefix := types.StringCond(sub, "sub!", "")
key := fmt.Sprintf("%s:%s%s:%s", variable.KvOrderExpiresTime, prefix, orderNo, tk)
//log.Println(" [Daemon][Exprire][ Key]:", key)
conn.Do("SET", key, unix)
}
// //订单刚创建时,设置过期时间
// if o.Status == order.StatAwaitingPayment {
// trans, cli, _ := service.FoundationServiceClient()
// defer trans.Close()
// ss, _ := cli.GetGlobMchSaleConf_(context.TODO(), &proto.Empty{})
// unix := o.UpdateTime + int64(ss.OrderTimeOutMinute)*60
// t := time.Unix(unix, 0)
// tk := getTick(t)
// orderNo, sub := d.testSubId(o)
// prefix := types.StringCond(sub, "sub!", "")
// key := fmt.Sprintf("%s:%s%s:%s", variable.KvOrderExpiresTime, prefix, orderNo, tk)
// //log.Println(" [Daemon][Exprire][ Key]:", key)
// conn.Do("SET", key, unix)
// }
}

// 取消订单过期时间
Expand Down Expand Up @@ -332,19 +332,19 @@ func (d *defaultService) orderAutoConfirm(conn redis.Conn, o *proto.SSingleOrder

// 订单自动收货
func (d *defaultService) orderAutoReceive(conn redis.Conn, o *proto.SSingleOrder) {
if o.Status == order.StatShipped {
trans, cli, _ := service.FoundationServiceClient()
defer trans.Close()
ss, _ := cli.GetGlobMchSaleConf_(context.TODO(), &proto.Empty{})
unix := o.UpdateTime + int64(ss.OrderTimeOutReceiveHour)*60*60
t := time.Unix(unix, 0)
tk := getTick(t)
orderNo, sub := d.testSubId(o)
prefix := types.StringCond(sub, "sub!", "")
key := fmt.Sprintf("%s:%s%s:%s", variable.KvOrderAutoReceive, prefix, orderNo, tk)
//log.Println(" [Daemon][AutoReceive][ Key]:", key)
conn.Do("SET", key, unix)
}
// if o.Status == order.StatShipped {
// trans, cli, _ := service.FoundationServiceClient()
// defer trans.Close()
// ss, _ := cli.GetGlobMchSaleConf_(context.TODO(), &proto.Empty{})
// unix := o.UpdateTime + int64(ss.OrderTimeOutReceiveHour)*60*60
// t := time.Unix(unix, 0)
// tk := getTick(t)
// orderNo, sub := d.testSubId(o)
// prefix := types.StringCond(sub, "sub!", "")
// key := fmt.Sprintf("%s:%s%s:%s", variable.KvOrderAutoReceive, prefix, orderNo, tk)
// //log.Println(" [Daemon][AutoReceive][ Key]:", key)
// conn.Do("SET", key, unix)
// }
}

// 完成订单自动收货
Expand Down
4 changes: 2 additions & 2 deletions app/daemon/supervise.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func superviseOrder(ss []Service) {
// OrderNo: orderNo,
// SubOrder: sub,
//})
o, _ := cli.GetOrder(context.TODO(), &proto.OrderNoV2{
Value: orderNo,
o, _ := cli.GetOrder(context.TODO(), &proto.OrderRequest{
OrderNo: orderNo,
})
trans.Close()
if o != nil {
Expand Down
2 changes: 2 additions & 0 deletions core/domain/interface/order/complex_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type (
OrderNo string
// 购买人编号
BuyerId int64
// 卖家编号-
SellerId int64
// 买家用户名
BuyerUser string
// 订单标题
Expand Down
5 changes: 5 additions & 0 deletions core/domain/interface/order/normal_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package order

import (
"github.com/ixre/go2o/core/domain/interface/cart"
"github.com/ixre/go2o/core/domain/interface/payment"
"github.com/ixre/go2o/core/domain/interface/promotion"
)

Expand All @@ -16,6 +17,8 @@ type (
OnlinePaymentTradeFinish() error
// Submit 提交订单。如遇拆单,需均摊优惠抵扣金额到商品
Submit() error
// BreakPaymentOrder 拆分支付单
BreakPaymentOrder() ([]payment.IPaymentOrder, error)
// Cancel 取消订单
Cancel(buyerCancel bool, reason string) error

Expand Down Expand Up @@ -49,6 +52,8 @@ type (
Complex() *ComplexOrder
// ParentOrder 获取父订单
ParentOrder() IOrder
// GetPaymentOrder 获取支付单
GetPaymentOrder() payment.IPaymentOrder
// Items 获取商品项
Items() []*SubOrderItem
// 更改收货人信息
Expand Down
6 changes: 3 additions & 3 deletions core/domain/interface/order/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,14 @@ type (
SubmitReturnData struct {
// 订单号,多个订单号,用","分割
OrderNo string
// 交易号
TradeNo string
// 交易金额
TradeAmount int64
// 合并支付
MergePay bool
IsMergePay bool
// 支付单号
PaymentOrderNo string
// 支付状态
PaymentState int
}

// Order 订单
Expand Down
44 changes: 9 additions & 35 deletions core/domain/interface/payment/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ type (
IPaymentRepo interface {
// GetPaymentOrderById 根据编号获取支付单
GetPaymentOrderById(id int) IPaymentOrder
// DeletePaymentOrder 拆分后删除父支付单
DeletePaymentOrder(id int) error
// DeletePaymentTradeData 删除支付单的支付数据
DeletePaymentTradeData(orderId int) error
// GetPaymentOrder 根据支付单号获取支付单
GetPaymentOrder(paymenOrderNo string) IPaymentOrder
// GetPaymentBySalesOrderId 根据订单号获取支付单
Expand Down Expand Up @@ -195,16 +199,6 @@ type (
GetAwaitCloseOrders(lastId int, size int) []IPaymentOrder
}

// RequestPayData 请求支付数据
RequestPayData struct {
// 支付方式
method int
// 支付方式代码
code string
// 支付金额
amount int
}

// Order 支付单
Order struct {
// 编号
Expand All @@ -227,10 +221,8 @@ type (
BuyerId int64 `db:"buyer_id"`
// 支付用户编号
PayerId int64 `db:"payer_id"`
// 商品金额
ItemAmount int64 `db:"item_amount"`
// 优惠金额
DiscountAmount int64 `db:"discount_amount"`
// 优惠金额,todo: 删除但目前依赖于优惠券
DiscountAmount int64 `db:"-"`
// 调整金额
AdjustAmount int64 `db:"adjust_amount"`
// 共计金额,包含抵扣金额
Expand Down Expand Up @@ -272,7 +264,9 @@ type (
// TradeMethodData 支付单项
TradeMethodData struct {
// 编号
ID int `db:"id" pk:"yes" auto:"yes"`
Id int `db:"id" pk:"yes" auto:"yes"`
// 支付订单号Id
OrderId int `db:"order_id"`
// 交易单号
TradeNo string `db:"trade_no"`
// 支付途径
Expand Down Expand Up @@ -301,26 +295,6 @@ type (
SubmitTime int64 `db:"submit_time"`
}

// PaySpTrade SP支付交易
PaySpTrade struct {
// 编号
ID int `db:"id"`
// 交易SP
TradeSp string `db:"trade_sp"`
// 交易号
TradeNo string `db:"trade_no"`
// 合并的订单号,交易号用"|"分割
TradeOrders string `db:"trade_orders"`
// 交易状态
TradeState int `db:"trade_state"`
// 交易结果
TradeResult int `db:"trade_result"`
// 交易备注
TradeRemark string `db:"trade_remark"`
// 交易时间
TradeTime int `db:"trade_time"`
}

// IntegrateApp 集成支付应用
IntegrateApp struct {
// 编号
Expand Down
Loading

0 comments on commit 04082fc

Please sign in to comment.