支付
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.rosy.net.cn/jx-print/globals"
|
||||||
"git.rosy.net.cn/jx-print/services"
|
"git.rosy.net.cn/jx-print/services"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CallbackController struct {
|
type CallbackController struct {
|
||||||
@@ -15,3 +17,8 @@ func (t *CallbackController) Msg(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *CallbackController) TlPayCallback(c *gin.Context) {
|
||||||
|
data, _ := ioutil.ReadAll(c.Request.Body)
|
||||||
|
globals.SugarLogger.Debugf("TlPayCallback msg: %v", string(data))
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/jx-print/globals"
|
"git.rosy.net.cn/jx-print/globals"
|
||||||
"git.rosy.net.cn/jx-print/model"
|
"git.rosy.net.cn/jx-print/model"
|
||||||
|
"git.rosy.net.cn/jx-print/putils"
|
||||||
"git.rosy.net.cn/jx-print/services"
|
"git.rosy.net.cn/jx-print/services"
|
||||||
"git.rosy.net.cn/jx-print/utils"
|
|
||||||
"github.com/dchest/captcha"
|
"github.com/dchest/captcha"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -44,7 +44,7 @@ func checkToken(c *gin.Context) (tokenInfo *model.TokenInfo) {
|
|||||||
tokenInfo.Token = cookie.Value
|
tokenInfo.Token = cookie.Value
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("checkToken token: %v", tokenInfo.Token)
|
globals.SugarLogger.Debugf("checkToken token: %v", tokenInfo.Token)
|
||||||
if tokenMap = utils.GetKey(tokenInfo.Token).(map[string]interface{}); tokenMap == nil {
|
if tokenMap = putils.GetKey(tokenInfo.Token).(map[string]interface{}); tokenMap == nil {
|
||||||
err = fmt.Errorf("token过期或无效,请重新登录!")
|
err = fmt.Errorf("token过期或无效,请重新登录!")
|
||||||
c.JSON(http.StatusOK, &CallBack{
|
c.JSON(http.StatusOK, &CallBack{
|
||||||
Desc: err.Error(),
|
Desc: err.Error(),
|
||||||
@@ -63,7 +63,7 @@ func checkToken(c *gin.Context) (tokenInfo *model.TokenInfo) {
|
|||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("checkToken user: %v", utils.Format4Output(user, true))
|
globals.SugarLogger.Debugf("checkToken user: %v", putils.Format4Output(user, true))
|
||||||
}
|
}
|
||||||
return tokenInfo
|
return tokenInfo
|
||||||
}
|
}
|
||||||
@@ -106,8 +106,8 @@ func callFunc(c *gin.Context, worker func() (retVal interface{}, errCode string,
|
|||||||
|
|
||||||
func captchaVerify(c *gin.Context, code string) bool {
|
func captchaVerify(c *gin.Context, code string) bool {
|
||||||
//session := sessions.Default(c)
|
//session := sessions.Default(c)
|
||||||
if captchaId := utils.GetKey(c.ClientIP() + model.SessionKey).(string); captchaId != "" {
|
if captchaId := putils.GetKey(c.ClientIP() + model.SessionKey).(string); captchaId != "" {
|
||||||
utils.DelKey(c.ClientIP() + model.SessionKey)
|
putils.DelKey(c.ClientIP() + model.SessionKey)
|
||||||
if captcha.VerifyString(captchaId, code) {
|
if captcha.VerifyString(captchaId, code) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/jx-print/model"
|
"git.rosy.net.cn/jx-print/model"
|
||||||
|
"git.rosy.net.cn/jx-print/services"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ func CreateOrder(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||||
|
retVal, err = services.CreateOrder(tokenInfo, param.OrderType, param.Origin, param.ThingID, param.TypeID)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
}) {
|
}) {
|
||||||
return
|
return
|
||||||
@@ -48,6 +50,7 @@ func Pay(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||||
|
retVal, err = services.Pay(tokenInfo, param.OrderID, param.PayType, param.VendorPayType)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
}) {
|
}) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/jx-print/model"
|
"git.rosy.net.cn/jx-print/model"
|
||||||
|
"git.rosy.net.cn/jx-print/putils"
|
||||||
"git.rosy.net.cn/jx-print/services"
|
"git.rosy.net.cn/jx-print/services"
|
||||||
"git.rosy.net.cn/jx-print/utils"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ func AddPrinters(c *gin.Context) {
|
|||||||
if tokenInfo = checkToken(c); tokenInfo == nil {
|
if tokenInfo = checkToken(c); tokenInfo == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = utils.UnmarshalUseNumber([]byte(param.Prints), &printInfos); err != nil {
|
if err = putils.UnmarshalUseNumber([]byte(param.Prints), &printInfos); err != nil {
|
||||||
buildErrJson(c, err)
|
buildErrJson(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ func DelPrinters(c *gin.Context) {
|
|||||||
if tokenInfo = checkToken(c); tokenInfo == nil {
|
if tokenInfo = checkToken(c); tokenInfo == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = utils.UnmarshalUseNumber([]byte(param.PrintNos), &printNos); err != nil {
|
if err = putils.UnmarshalUseNumber([]byte(param.PrintNos), &printNos); err != nil {
|
||||||
buildErrJson(c, err)
|
buildErrJson(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"git.rosy.net.cn/jx-print/globals"
|
"git.rosy.net.cn/jx-print/globals"
|
||||||
"git.rosy.net.cn/jx-print/model"
|
"git.rosy.net.cn/jx-print/model"
|
||||||
|
"git.rosy.net.cn/jx-print/putils"
|
||||||
"git.rosy.net.cn/jx-print/services"
|
"git.rosy.net.cn/jx-print/services"
|
||||||
"git.rosy.net.cn/jx-print/utils"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
//刷新验证码 POST
|
//刷新验证码 POST
|
||||||
func RefreshCode(c *gin.Context) {
|
func RefreshCode(c *gin.Context) {
|
||||||
utils.Captcha(c, 4)
|
putils.Captcha(c, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserParam struct {
|
type UserParam struct {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dao
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
putils "git.rosy.net.cn/jx-print/utils"
|
putils "git.rosy.net.cn/jx-print/putils"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|||||||
20
dao/order_dao.go
Normal file
20
dao/order_dao.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-print/model"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetOrder(db *sqlx.DB, orderID string) (order *model.PayOrder, err error) {
|
||||||
|
var (
|
||||||
|
orders []*model.PayOrder
|
||||||
|
)
|
||||||
|
sql := `
|
||||||
|
SELECT * FROM pay_order WHERE order_id = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{orderID}
|
||||||
|
if err = db.Select(&orders, sql, sqlParams...); err == nil && len(orders) > 0 {
|
||||||
|
return orders[0], err
|
||||||
|
}
|
||||||
|
return order, err
|
||||||
|
}
|
||||||
@@ -41,6 +41,14 @@ const (
|
|||||||
|
|
||||||
OrderOriginWxMini = "weixinmini"
|
OrderOriginWxMini = "weixinmini"
|
||||||
OrderOriginOpenAPI = "openAPI"
|
OrderOriginOpenAPI = "openAPI"
|
||||||
|
|
||||||
|
OrderStatusWaitPay = 0 //待支付
|
||||||
|
OrderStatusPaid = 1 //已支付
|
||||||
|
OrderStatusPayFail = 2
|
||||||
|
OrderStatusPayCancel = 3
|
||||||
|
OrderStatusRefund = 4
|
||||||
|
|
||||||
|
PayTypeTL = "tl" //通联支付
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -64,7 +72,7 @@ type TokenInfo struct {
|
|||||||
|
|
||||||
type FlowConfig struct {
|
type FlowConfig struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Price int `json:"price"`
|
Price int64 `json:"price"`
|
||||||
Flow float64 `json:"flow"`
|
Flow float64 `json:"flow"`
|
||||||
Unit string `json:"unit"`
|
Unit string `json:"unit"`
|
||||||
}
|
}
|
||||||
@@ -207,7 +215,7 @@ type PayOrder struct {
|
|||||||
OrderType string `json:"order_type" db:"order_type"` //订单类型,流量充值等
|
OrderType string `json:"order_type" db:"order_type"` //订单类型,流量充值等
|
||||||
Origin string `json:"origin"` //订单来源,小程序,开放后台
|
Origin string `json:"origin"` //订单来源,小程序,开放后台
|
||||||
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
||||||
PayPrice int `json:"pay_price" db:"pay_price"` //支付金额
|
PayPrice int64 `json:"pay_price" db:"pay_price"` //支付金额
|
||||||
TransactionID string `json:"transaction_id" db:"transaction_id"` // 支付成功后,支付方生成的事务ID
|
TransactionID string `json:"transaction_id" db:"transaction_id"` // 支付成功后,支付方生成的事务ID
|
||||||
PayFinishedAt *time.Time `json:"pay_finished_at" db:"pay_finished_at"`
|
PayFinishedAt *time.Time `json:"pay_finished_at" db:"pay_finished_at"`
|
||||||
PrepayID string `json:"prepay_id" db:"prepay_id"` // 下单后,支付前,支付方生成的事务ID
|
PrepayID string `json:"prepay_id" db:"prepay_id"` // 下单后,支付前,支付方生成的事务ID
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils
|
package putils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package utils
|
package putils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/md5"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
@@ -10,6 +11,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-print/model"
|
"git.rosy.net.cn/jx-print/model"
|
||||||
"github.com/dchest/captcha"
|
"github.com/dchest/captcha"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -40,6 +42,7 @@ var (
|
|||||||
"MB": struct{}{},
|
"MB": struct{}{},
|
||||||
"GB": struct{}{},
|
"GB": struct{}{},
|
||||||
}
|
}
|
||||||
|
orderNoBeginTimestamp = utils.Str2Time("2010-01-01 00:00:00").Unix()
|
||||||
)
|
)
|
||||||
|
|
||||||
func RandStringBytes(n int) string {
|
func RandStringBytes(n int) string {
|
||||||
@@ -251,3 +254,18 @@ func FlowKB2Other(flowKB float64) (flow float64, unit string) {
|
|||||||
}
|
}
|
||||||
return flow, unit
|
return flow, unit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenOrderNo() (orderNo int64) {
|
||||||
|
var prefix = utils.Str2Int64(time.Now().Format("20060102"))
|
||||||
|
const randPartNum = 1000
|
||||||
|
orderNo = time.Now().Unix() - orderNoBeginTimestamp
|
||||||
|
orderNo = orderNo * randPartNum
|
||||||
|
md5Bytes := md5.Sum([]byte(utils.GetUUID()))
|
||||||
|
randPart := 0
|
||||||
|
for k, v := range md5Bytes {
|
||||||
|
randPart += int(v) << ((k % 3) * 8)
|
||||||
|
}
|
||||||
|
orderNo += int64(randPart % randPartNum)
|
||||||
|
orderNo += int64(math.Pow10(int(math.Log10(float64(orderNo)))+1)) * prefix
|
||||||
|
return orderNo
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-print/dao"
|
"git.rosy.net.cn/jx-print/dao"
|
||||||
"git.rosy.net.cn/jx-print/globals"
|
"git.rosy.net.cn/jx-print/globals"
|
||||||
"git.rosy.net.cn/jx-print/model"
|
"git.rosy.net.cn/jx-print/model"
|
||||||
putils "git.rosy.net.cn/jx-print/utils"
|
putils "git.rosy.net.cn/jx-print/putils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package misc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
putils "git.rosy.net.cn/jx-print/putils"
|
||||||
"git.rosy.net.cn/jx-print/services"
|
"git.rosy.net.cn/jx-print/services"
|
||||||
putils "git.rosy.net.cn/jx-print/utils"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-print/globals"
|
"git.rosy.net.cn/jx-print/globals"
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -1,7 +1,93 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import "git.rosy.net.cn/jx-print/model"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/tonglianpayapi"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-print/dao"
|
||||||
|
"git.rosy.net.cn/jx-print/globals"
|
||||||
|
"git.rosy.net.cn/jx-print/model"
|
||||||
|
"git.rosy.net.cn/jx-print/putils"
|
||||||
|
"git.rosy.net.cn/jx-print/services/api"
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func CreateOrder(tokenInfo *model.TokenInfo) (err error) {
|
var (
|
||||||
return err
|
findOrderPayPriceMap = map[string]func(db *sqlx.DB, typeID string) (int64, error){
|
||||||
|
model.OrderTypeFlow: func(db *sqlx.DB, typeID string) (payPrice int64, err error) {
|
||||||
|
var flowCfg []*model.FlowConfig
|
||||||
|
if config, err2 := dao.GetConfig(db, model.ConfigTypeSys, model.OrderTypeFlow); err2 == nil && config != nil {
|
||||||
|
if err = json.Unmarshal([]byte(config.Value), &flowCfg); err == nil && len(flowCfg) > 0 {
|
||||||
|
for _, v := range flowCfg {
|
||||||
|
if v.ID == utils.Str2Int(typeID) {
|
||||||
|
payPrice = v.Price
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
err = err2
|
||||||
|
}
|
||||||
|
return payPrice, err
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
payFunc = map[string]func(db *sqlx.DB, order *model.PayOrder, vendorPayType string) (err error){
|
||||||
|
model.PayTypeTL: func(db *sqlx.DB, order *model.PayOrder, vendorPayType string) (err error) {
|
||||||
|
param := &tonglianpayapi.CreateUnitorderOrderParam{
|
||||||
|
Trxamt: int(order.PayPrice),
|
||||||
|
NotifyUrl: "http://print.jxc4.com/callback/tlPayCallback",
|
||||||
|
Reqsn: order.OrderID,
|
||||||
|
PayType: vendorPayType,
|
||||||
|
}
|
||||||
|
if vendorPayType != tonglianpayapi.PayTypeWxCode {
|
||||||
|
return fmt.Errorf("暂不支持的支付类型!vendorPayType :%s", vendorPayType)
|
||||||
|
}
|
||||||
|
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
|
||||||
|
if err == nil {
|
||||||
|
var result2 tonglianpayapi.PayInfo
|
||||||
|
json.Unmarshal([]byte(result.PayInfo), &result2)
|
||||||
|
order.PrepayID = result2.Package[strings.LastIndex(result2.Package, "=")+1 : len(result2.Package)]
|
||||||
|
order.TransactionID = result.TrxID
|
||||||
|
err = dao.Update(db, order, "prepay_id", "transaction_id")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func CreateOrder(tokenInfo *model.TokenInfo, orderType, origin, thingID, typeID string) (orderID string, err error) {
|
||||||
|
var (
|
||||||
|
db = globals.GetDB()
|
||||||
|
now = time.Now()
|
||||||
|
payPrice int64
|
||||||
|
)
|
||||||
|
if payPrice, err = findOrderPayPriceMap[orderType](db, typeID); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
orderID = utils.Int64ToStr(putils.GenOrderNo())
|
||||||
|
payOrder := &model.PayOrder{
|
||||||
|
CreatedAt: &now,
|
||||||
|
OrderID: orderID,
|
||||||
|
PayPrice: payPrice,
|
||||||
|
UserID: tokenInfo.User.UserID,
|
||||||
|
OrderType: orderType,
|
||||||
|
Origin: origin,
|
||||||
|
ThingID: thingID,
|
||||||
|
TypeID: typeID,
|
||||||
|
}
|
||||||
|
err = dao.Insert(db, payOrder)
|
||||||
|
return orderID, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pay(tokenInfo *model.TokenInfo, orderID, payType, vendorPayType string) (order *model.PayOrder, err error) {
|
||||||
|
var (
|
||||||
|
db = globals.GetDB()
|
||||||
|
)
|
||||||
|
order, _ = dao.GetOrder(db, orderID)
|
||||||
|
err = payFunc[payType](db, order, vendorPayType)
|
||||||
|
return order, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-print/dao"
|
"git.rosy.net.cn/jx-print/dao"
|
||||||
"git.rosy.net.cn/jx-print/globals"
|
"git.rosy.net.cn/jx-print/globals"
|
||||||
"git.rosy.net.cn/jx-print/model"
|
"git.rosy.net.cn/jx-print/model"
|
||||||
putils "git.rosy.net.cn/jx-print/utils"
|
putils "git.rosy.net.cn/jx-print/putils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"git.rosy.net.cn/jx-print/dao"
|
"git.rosy.net.cn/jx-print/dao"
|
||||||
"git.rosy.net.cn/jx-print/globals"
|
"git.rosy.net.cn/jx-print/globals"
|
||||||
"git.rosy.net.cn/jx-print/model"
|
"git.rosy.net.cn/jx-print/model"
|
||||||
|
putils "git.rosy.net.cn/jx-print/putils"
|
||||||
"git.rosy.net.cn/jx-print/services/api"
|
"git.rosy.net.cn/jx-print/services/api"
|
||||||
putils "git.rosy.net.cn/jx-print/utils"
|
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -68,7 +68,7 @@ func SimFlowDaySettle() (err error) {
|
|||||||
sumIncome, _ := dao.GetSimFlowIncomeSum(db, v.IccID, monthBegin, monthEnd)
|
sumIncome, _ := dao.GetSimFlowIncomeSum(db, v.IccID, monthBegin, monthEnd)
|
||||||
sumExpend, _ := dao.GetSimFlowExpendSum(db, v.IccID, monthBegin, monthEnd)
|
sumExpend, _ := dao.GetSimFlowExpendSum(db, v.IccID, monthBegin, monthEnd)
|
||||||
if sumIncome != nil && sumExpend != nil {
|
if sumIncome != nil && sumExpend != nil {
|
||||||
if sumExpend.Flow-sumIncome.Flow <= 0 {
|
if sumIncome.Flow-sumExpend.Flow <= 0 {
|
||||||
v.FlowFlag = 1
|
v.FlowFlag = 1
|
||||||
err = dao.Update(db, v, "flow_flag")
|
err = dao.Update(db, v, "flow_flag")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-print/dao"
|
"git.rosy.net.cn/jx-print/dao"
|
||||||
"git.rosy.net.cn/jx-print/globals"
|
"git.rosy.net.cn/jx-print/globals"
|
||||||
"git.rosy.net.cn/jx-print/model"
|
"git.rosy.net.cn/jx-print/model"
|
||||||
putils "git.rosy.net.cn/jx-print/utils"
|
putils "git.rosy.net.cn/jx-print/putils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"strings"
|
"strings"
|
||||||
|
|||||||
Reference in New Issue
Block a user