Przeglądaj źródła

recharge record add by people

abiao 4 lat temu
rodzic
commit
05af65d99d

+ 1 - 11
go/gopath/src/fohow.com/apps/controllers/pay_controller/after_pay_controller.go

@@ -107,19 +107,9 @@ func (self *PayController) wxPayBalanceAsync() {
 		self.Ctx.WriteString(wx_mp.MapToXmlString(notifyResponse))
 		return
 	}
-	order.PaiedPrice = totalFee
-	order.State = 1
-	order.TradeNo = params.TransactionId
-	order.PayWay = balance_model.PAY_WAY_TYPE_SERVICE_WXPAY
-	order.PaiedAt = time.Now().Unix()
-	if err := order.Save(); err != nil {
-		beego.BeeLogger.Error("weixinpay async return. save oId=%s fail", order.OrderId)
-		self.Ctx.WriteString(wx_mp.MapToXmlString(notifyResponse))
-		return
-	}
 
 	// 发放充值佣金
-	go helpers.PatchRechargeBalance(order.Id, totalFee)
+	go helpers.PatchRechargeBalance(order.Id, totalFee, params.TransactionId)
 
 	notifyResponse["return_code"] = wx_mp.PAY_SUCCESS
 	//beego.BeeLogger.Warn("小程序购买提货券微信支付回调通知,订单编号=%s  订单状态=%d", order.OrderId, order.State)

+ 25 - 0
go/gopath/src/fohow.com/apps/controllers/railsadmin_controller/balance_order_controller.go

@@ -0,0 +1,25 @@
+package railsadmin_controller
+
+import (
+	"fohow.com/apps"
+	"fohow.com/apps/helpers"
+	"fohow.com/apps/models/balance_model"
+	"github.com/astaxie/beego"
+	"strconv"
+)
+
+//充值订单审核
+func (self *RailsadminController) ConfirmBalanceOrder() {
+
+	_id := self.Ctx.Input.Param(":id")
+	id, _ := strconv.ParseInt(_id, 10, 64)
+	beego.BeeLogger.Warn("BalanceOrder id:(%d)", id)
+
+	order := balance_model.GetBalanceOrderById(id, true)
+	if order == nil {
+		self.ReturnError(404, apps.NoExist, "", nil)
+	}
+
+	go helpers.PatchRechargeBalance(id, order.PaiedPrice, "")
+	self.ServeJSON()
+}

+ 15 - 2
go/gopath/src/fohow.com/apps/helpers/recharge_helper.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"fohow.com/apps/models/base_config"
 	"github.com/astaxie/beego"
+	"time"
 
 	"fohow.com/apps/models/balance_model"
 	"fohow.com/apps/models/user_model"
@@ -11,16 +12,28 @@ import (
 )
 
 //充值成功发放佣金
-func PatchRechargeBalance(oId, totalFee int64) {
+func PatchRechargeBalance(oId, totalFee int64, transactionId string) {
 
 	beego.BeeLogger.Warn("*******PatchRechargeBalance Begin oId:%d", oId)
 
 	order := balance_model.GetBalanceOrderById(oId, true)
-
 	if order == nil || order.State == int64(1) {
 		beego.BeeLogger.Error("充值订单状态错误或者不存在%d", oId)
 		return
 	}
+	payWay := ""
+	if len(transactionId) > 0 {
+		payWay = balance_model.PAY_WAY_TYPE_SERVICE_WXPAY
+	}
+	order.PaiedPrice = totalFee
+	order.State = 1
+	order.TradeNo = transactionId
+	order.PayWay = payWay
+	order.PaiedAt = time.Now().Unix()
+	if err := order.Save(); err != nil {
+		beego.BeeLogger.Error("weixinpay async return. save oId=%s fail", order.OrderId)
+		return
+	}
 	recharge(order.WxUserId, order.UserId, order.TotalPrice, order.OrderId)
 	wxUser := user_model.GetWxUserById(order.WxUserId, false)
 	if wxUser != nil {

+ 1 - 0
go/gopath/src/fohow.com/routers/routes.go

@@ -226,6 +226,7 @@ func init() {
 	beego.Router("/railsadmin/order/refund/:id([0-9]+)", &railsadmin_controller.RailsadminController{}, "get:OrderRefund")
 	beego.Router("/railsadmin/user/perfomance/:id([0-9]+)", &railsadmin_controller.RailsadminController{}, "get:UserPerfomance")
 	beego.Router("/railsadmin/live/award/:id([0-9]+)", &railsadmin_controller.RailsadminController{}, "get:LiveAward")
+	beego.Router("/railsadmin/balance_order/confirm/:id([0-9]+)", &railsadmin_controller.RailsadminController{}, "get:ConfirmBalanceOrder")
 
 	//设置群主
 	beego.Router("/railsadmin/update/intro/:id([0-9]+)", &railsadmin_controller.RailsadminController{}, "get:UpdateIntroUser")