paylimit2
This commit is contained in:
parent
9b27891ab2
commit
b720a9ccf0
|
@ -3,6 +3,7 @@ package dao
|
||||||
import (
|
import (
|
||||||
"enterprise/common/model"
|
"enterprise/common/model"
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
|
"gorm.io/gorm"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,6 +24,21 @@ func (d *StaffPayLogDao) Create(o *model.StaffPayLog) (int64, error) {
|
||||||
return o.Id, res.Error
|
return o.Id, res.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *StaffPayLogDao) GetByOutTradeNo(outTradeNo string) (*model.StaffPayLog, error) {
|
||||||
|
var u model.StaffPayLog
|
||||||
|
tx := GetDB().Table(d.TableName())
|
||||||
|
tx = tx.Where("out_trade_no = ?", outTradeNo)
|
||||||
|
res := tx.First(&u)
|
||||||
|
if res.Error == gorm.ErrRecordNotFound {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if res.Error != nil {
|
||||||
|
return nil, res.Error
|
||||||
|
}
|
||||||
|
return &u, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (d *StaffPayLogDao) QueryAdmin(page, size int, corpId int64, staffId string) ([]*model.StaffPayLog, int64, error) {
|
func (d *StaffPayLogDao) QueryAdmin(page, size int, corpId int64, staffId string) ([]*model.StaffPayLog, int64, error) {
|
||||||
var u []*model.StaffPayLog
|
var u []*model.StaffPayLog
|
||||||
tx := GetDB().Table(d.TableName())
|
tx := GetDB().Table(d.TableName())
|
||||||
|
|
|
@ -27,7 +27,17 @@ func (p *Pay) Pay(corp *model.Corp, user *model.StaffUser, title, payType string
|
||||||
if outTradeNo == "" {
|
if outTradeNo == "" {
|
||||||
outTradeNo = fmt.Sprintf("%d_%s_%s", corp.Id, time.Now().Format("200601020304"), user.Id)
|
outTradeNo = fmt.Sprintf("%d_%s_%s", corp.Id, time.Now().Format("200601020304"), user.Id)
|
||||||
}
|
}
|
||||||
var err error
|
|
||||||
|
plog, err := dao.NewStaffPayLogDao().GetByOutTradeNo(outTradeNo)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("db error :%s", err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if plog != nil {
|
||||||
|
log.Errorf("ouTradeNo[%s] paylog[%s] exist!", outTradeNo, goutil.EncodeJSON(plog))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
realPayType := ""
|
realPayType := ""
|
||||||
payee := user.GetPayee()
|
payee := user.GetPayee()
|
||||||
if payType == "alipay" {
|
if payType == "alipay" {
|
||||||
|
@ -54,7 +64,8 @@ func (p *Pay) Pay(corp *model.Corp, user *model.StaffUser, title, payType string
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
plog := new(model.StaffPayLog)
|
plog = new(model.StaffPayLog)
|
||||||
|
plog.OutTradeNo = outTradeNo
|
||||||
plog.Title = title
|
plog.Title = title
|
||||||
plog.PayType = realPayType
|
plog.PayType = realPayType
|
||||||
plog.StaffId = user.Id
|
plog.StaffId = user.Id
|
||||||
|
|
Loading…
Reference in New Issue