username billno
This commit is contained in:
parent
bd04e1b9f0
commit
f0c53b3716
|
@ -15,3 +15,11 @@ func RandomStr(length int) string {
|
|||
}
|
||||
return string(result)
|
||||
}
|
||||
|
||||
func CutTail(str string, length int) string {
|
||||
if len(str) <= length {
|
||||
return str
|
||||
}
|
||||
|
||||
return str[0:length]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCutTail(t *testing.T) {
|
||||
fmt.Println(CutTail("jiangyong", 4))
|
||||
fmt.Println(CutTail("jiangyong", 41))
|
||||
}
|
|
@ -133,7 +133,7 @@ func (p *QyPay) PayRedMoney(req *RedMoneyReq) error {
|
|||
return err
|
||||
}
|
||||
if req.BillNo == "" {
|
||||
req.BillNo = fmt.Sprintf("QY%s%s", time.Now().Format("20060102150405"), butil.RandomStr(6))
|
||||
req.BillNo = fmt.Sprintf("QY%s%s", time.Now().Format("20060102150405"), butil.CutTail(req.Userid, 12))
|
||||
}
|
||||
param.Set("nonce_str", butil.RandomStr(32))
|
||||
param.Set("mch_billno", req.BillNo)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
butil "enterprise/base/util"
|
||||
"enterprise/base/wechat/message"
|
||||
"enterprise/common/config"
|
||||
"enterprise/common/dao"
|
||||
|
@ -126,7 +127,7 @@ func (a *Approve) handleRefund(spNo string) {
|
|||
|
||||
// 支付费用
|
||||
var req weixin.RedMoneyReq
|
||||
req.BillNo = fmt.Sprintf("BX%s", refund.SpNo)
|
||||
req.BillNo = fmt.Sprintf("BX%s%s", refund.SpNo, butil.CutTail(refund.Username, 12))
|
||||
req.Title = fmt.Sprintf("【%s】报销", refund.RefundType)
|
||||
req.Userid = refund.Username
|
||||
req.TotalAmount = int64(100 * refund.RefundAmount)
|
||||
|
|
|
@ -113,7 +113,7 @@ func autoPayMoney(checkin *model.Checkin, checkinType string, payMoney int64) er
|
|||
req.TotalAmount = payMoney
|
||||
req.Title = checkinType
|
||||
|
||||
req.BillNo = fmt.Sprintf("DK%s%s", time.Now().Format("20060102150405"), butil.RandomStr(6))
|
||||
req.BillNo = fmt.Sprintf("DK%s%s", time.Now().Format("20060102150405"), butil.CutTail(checkin.Username, 12))
|
||||
req.Userid = checkin.Username
|
||||
if err := weixin.NewQyPay().PayRedMoney(&req); err != nil {
|
||||
log.Errorf("pay red money error :%s", err.Error())
|
||||
|
|
Loading…
Reference in New Issue