diff --git a/cmd/server/enterprise-api.go b/cmd/server/enterprise-api.go
index de00819..9290363 100644
--- a/cmd/server/enterprise-api.go
+++ b/cmd/server/enterprise-api.go
@@ -2,7 +2,6 @@ package main
import (
"enterprise/common/config"
- "enterprise/common/global"
"enterprise/server"
_ "enterprise/service/salary_calculator"
)
@@ -11,7 +10,7 @@ func main() {
config.LoadServerConfig()
config.LoadAliPay()
config.LoadCorpConfig()
- global.InitGlobal()
+ //global.InitGlobal()
if err := server.Start(); err != nil {
panic(err)
diff --git a/conf/template/alipay.html b/conf/template/alipay.html
new file mode 100644
index 0000000..1e0009e
--- /dev/null
+++ b/conf/template/alipay.html
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+ 绑定结果页面
+
+
+
+
+
+
+
+
{{.title}}
+
{{.message}}
+
+
+
+
+
+
diff --git a/server/controller/payment.go b/server/controller/payment.go
index e160a3d..be901a8 100644
--- a/server/controller/payment.go
+++ b/server/controller/payment.go
@@ -6,7 +6,9 @@ import (
"enterprise/server/api"
"enterprise/server/service"
"enterprise/server/session"
+ "fmt"
"github.com/gin-gonic/gin"
+ "github.com/smbrave/goutil"
"net/http"
)
@@ -22,8 +24,13 @@ func (q *Payment) AlipayAuth(ctx *gin.Context) {
authCode := ctx.Query("auth_code")
state := ctx.Query("state")
- data := service.NewPay().AlipayAuth(sess, authCode, state)
- ctx.JSON(http.StatusOK, session.NewRsp(data))
+ userid, staffUser := service.NewPay().AlipayAuth(sess, authCode, state)
+ username := goutil.If(staffUser.Realname != "", staffUser.Realname, staffUser.Username)
+ ctx.HTML(http.StatusOK, "alipay.html", gin.H{
+ "title": "绑定成功",
+ "message": fmt.Sprintf("您支付宝【%s】已成功绑定到用户【%s】", userid, username),
+ "style": "payment-success",
+ })
}
func (q *Payment) Pay(ctx *gin.Context) {
diff --git a/server/service/pay.go b/server/service/pay.go
index 503f000..e2650fe 100644
--- a/server/service/pay.go
+++ b/server/service/pay.go
@@ -25,7 +25,7 @@ func NewPay() *Pay {
return &Pay{}
}
-func (p *Pay) AlipayAuth(sess *session.AdminSession, authCode, state string) interface{} {
+func (p *Pay) AlipayAuth(sess *session.AdminSession, authCode, state string) (string, *model.StaffUser) {
corp, err := dao.NewCorpDao().GetByHost(sess.GetHeader().Host)
session.CheckDBError(err)
@@ -45,22 +45,15 @@ func (p *Pay) AlipayAuth(sess *session.AdminSession, authCode, state string) int
panic(config.ErrInternal.New().Append(goutil.EncodeJSON(res)))
}
- if state != "" {
- staffUser, err := dao.NewStaffUserDao().Get(cast.ToInt64(state))
- session.CheckDBError(err)
- session.CheckNilError(staffUser)
- payee := staffUser.GetPayee()
- payee.AlipayUid = res.UserId
- staffUser.Payee = goutil.EncodeJSON(payee)
- err = dao.NewStaffUserDao().Update(staffUser)
- session.CheckDBError(err)
- }
-
- data := make(map[string]interface{})
- data["state"] = state
- data["userid"] = res.UserId
- log.Errorf("state=%s,userid=%s", state, res.UserId)
- return data
+ staffUser, err := dao.NewStaffUserDao().Get(cast.ToInt64(state))
+ session.CheckDBError(err)
+ session.CheckNilError(staffUser)
+ payee := staffUser.GetPayee()
+ payee.AlipayUid = res.UserId
+ staffUser.Payee = goutil.EncodeJSON(payee)
+ err = dao.NewStaffUserDao().Update(staffUser)
+ session.CheckDBError(err)
+ return res.UserId, staffUser
}
func (p *Pay) Pay(corp *model.Corp, req *api.PayReq) {