浏览代码

订单统计功能

abiao 5 年之前
父节点
当前提交
b010d6ba8c

+ 27 - 21
go/gopath/src/fohow.com/apps/controllers/pay_controller/pay_exchange_controller.go

@@ -110,29 +110,35 @@ func (self *PayController) payExchange(oId, payWay, tradPwd, returnUrl, source s
 	}
 	//若账户有代金券则优先抵扣代金券
 	needWx := true
-	totalCoupon := int64(0)
-	userLeftBalanceCount := balance_model.GetUserTotalBalance(wxUId)
-	tp := order.TotalPrice
-	freight := order_model.FREIGHT
-	if tp >= order_model.FREIGHT_LIMIT || beego.AppConfig.String("RunMode") == "dev" {
-		freight = int64(0)
-	}
-	tp += freight
-	if order.OrderType != order_model.ORDER_TYPE_SEKILL && useCoupon {
-		if userLeftBalanceCount < tp {
-			totalCoupon = userLeftBalanceCount
-		} else {
-			needWx = false
-			totalCoupon = tp
+	//订单第一次支付
+	if len(order.PayWay) == 0 {
+		totalCoupon := int64(0)
+		userLeftBalanceCount := balance_model.GetUserTotalBalance(wxUId)
+		tp := order.TotalPrice
+		freight := order_model.FREIGHT
+		if tp >= order_model.FREIGHT_LIMIT || beego.AppConfig.String("RunMode") == "dev" {
+			freight = int64(0)
 		}
+		tp += freight
+		if order.OrderType != order_model.ORDER_TYPE_SEKILL && useCoupon {
+			if userLeftBalanceCount < tp {
+				totalCoupon = userLeftBalanceCount
+			} else {
+				needWx = false
+				totalCoupon = tp
+			}
+		}
+		//先扣减代金券
+		if totalCoupon > 0 {
+			source := balance_model.BALANCE_SOURCE_EXCHANGE_PRODUCT
+			remark := fmt.Sprintf("代金券兑换商品")
+			new(balance_model.Balance).Create(wxUId, uId, -totalCoupon, source, oId, remark)
+		}
+		order.CouponPrice = totalCoupon
+	} else {
+
 	}
-	//先扣减代金券
-	if totalCoupon > 0 {
-		source := balance_model.BALANCE_SOURCE_EXCHANGE_PRODUCT
-		remark := fmt.Sprintf("代金券兑换商品")
-		new(balance_model.Balance).Create(wxUId, uId, -totalCoupon, source, oId, remark)
-	}
-	order.CouponPrice = totalCoupon
+
 	switch needWx { // 1.true需要微信支付,2.false不需要微信支付
 	case false: // 代金券抵扣完毕
 		//更新订单状态

+ 0 - 1
go/gopath/src/fohow.com/apps/models/order_model/order.go

@@ -143,7 +143,6 @@ func (self *Order) CreateNew(wxUserId, uId, totalPrice, freight, orderType int64
 		Freight:    freight,
 		WxUserId:   wxUserId,
 		TotalPrice: totalPrice,
-		PayWay:     PAY_WAY_BALANCE,
 		Status:     STATUS_UNPAY,
 		Source:     source,
 		OrderType:  orderType,