username billno

This commit is contained in:
jiangyong27 2023-08-15 12:47:20 +08:00
parent bd04e1b9f0
commit f0c53b3716
5 changed files with 23 additions and 3 deletions

View File

@ -15,3 +15,11 @@ func RandomStr(length int) string {
} }
return string(result) return string(result)
} }
func CutTail(str string, length int) string {
if len(str) <= length {
return str
}
return str[0:length]
}

11
base/util/util_test.go Normal file
View File

@ -0,0 +1,11 @@
package util
import (
"fmt"
"testing"
)
func TestCutTail(t *testing.T) {
fmt.Println(CutTail("jiangyong", 4))
fmt.Println(CutTail("jiangyong", 41))
}

View File

@ -133,7 +133,7 @@ func (p *QyPay) PayRedMoney(req *RedMoneyReq) error {
return err return err
} }
if req.BillNo == "" { 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("nonce_str", butil.RandomStr(32))
param.Set("mch_billno", req.BillNo) param.Set("mch_billno", req.BillNo)

View File

@ -1,6 +1,7 @@
package service package service
import ( import (
butil "enterprise/base/util"
"enterprise/base/wechat/message" "enterprise/base/wechat/message"
"enterprise/common/config" "enterprise/common/config"
"enterprise/common/dao" "enterprise/common/dao"
@ -126,7 +127,7 @@ func (a *Approve) handleRefund(spNo string) {
// 支付费用 // 支付费用
var req weixin.RedMoneyReq 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.Title = fmt.Sprintf("【%s】报销", refund.RefundType)
req.Userid = refund.Username req.Userid = refund.Username
req.TotalAmount = int64(100 * refund.RefundAmount) req.TotalAmount = int64(100 * refund.RefundAmount)

View File

@ -113,7 +113,7 @@ func autoPayMoney(checkin *model.Checkin, checkinType string, payMoney int64) er
req.TotalAmount = payMoney req.TotalAmount = payMoney
req.Title = checkinType 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 req.Userid = checkin.Username
if err := weixin.NewQyPay().PayRedMoney(&req); err != nil { if err := weixin.NewQyPay().PayRedMoney(&req); err != nil {
log.Errorf("pay red money error :%s", err.Error()) log.Errorf("pay red money error :%s", err.Error())