浏览代码

增加系统配置接口

kobe6258 4 月之前
父节点
当前提交
77882a4a28
共有 4 个文件被更改,包括 10 次插入9 次删除
  1. 6 5
      controllers/order.go
  2. 2 2
      models/refund_deal_flow.go
  3. 1 1
      utils/distrubtLock.go
  4. 1 1
      utils/redis/cluster_redis.go

+ 6 - 5
controllers/order.go

@@ -7,13 +7,14 @@ import (
 	"eta/eta_mini_crm_ht/models/response"
 	"eta/eta_mini_crm_ht/utils"
 	"fmt"
-	uuid2 "github.com/google/uuid"
+	"github.com/google/uuid"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"github.com/xuri/excelize/v2"
 	"math/rand"
 	"net/http"
 	"net/url"
 	"strconv"
+	"strings"
 	"sync"
 	"time"
 )
@@ -779,12 +780,12 @@ func (this *OrderController) Refund() {
 		br.ErrMsg = "退款失败,原订单未完成支付"
 		return
 	}
-	uuid := uuid2.NewString()
+	uuidStr := strings.ReplaceAll(uuid.New().String(), "-", "")
 	key := fmt.Sprintf("refund_lock_%s", productOrder.OrderId)
 	defer func() {
-		utils.ReleaseLock(key, uuid)
+		utils.ReleaseLock(key, uuidStr)
 	}()
-	if utils.AcquireLock(key, 10, uuid) {
+	if utils.AcquireLock(key, 10, uuidStr) {
 		aa := GenerateProductOrderNo()
 		refundOrder := &models.TradeOrder{
 			TransactionId:    aa,
@@ -814,7 +815,7 @@ func (this *OrderController) Refund() {
 		refundflow := models.RefundDealFlow{
 			ProductOrderNo: productOrder.OrderId,
 			RefundOrderNo:  refundOrder.TransactionId,
-			OperatorUserID: this.SysUser.SysUserId,
+			OperatorUserId: this.SysUser.SysUserId,
 			CreatedTime:    time.Now(),
 		}
 		//增加一条退款流水

+ 2 - 2
models/refund_deal_flow.go

@@ -7,8 +7,8 @@ import (
 
 // RefundDealFlow 表示 refund_deal_flow 表的 ORM 结构体
 type RefundDealFlow struct {
-	ID             int       `gorm:"column:id;primaryKey;autoIncrement:false"`
-	OperatorUserID int       `gorm:"column:operator_user_id;default:null"`
+	Id             int       `gorm:"column:id;primaryKey;autoIncrement:false"`
+	OperatorUserId int       `gorm:"column:operator_user_id;default:null"`
 	ProductOrderNo string    `gorm:"column:product_order_no;default:null"`
 	RefundOrderNo  string    `gorm:"column:refund_order_no;default:null"`
 	CreatedTime    time.Time `gorm:"column:created_time;default:null"`

+ 1 - 1
utils/distrubtLock.go

@@ -25,7 +25,7 @@ func AcquireLock(key string, expiration int, holder string) bool {
 			end`
 
 	lockey := fmt.Sprintf("%s%s", lockName, key)
-	return Rc.RunLUA(script, ctx, []string{lockey}, expiration, holder)
+	return Rc.RunLUA(script, ctx, []string{lockey}, holder, expiration)
 }
 
 func ReleaseLock(key string, holder string) bool {

+ 1 - 1
utils/redis/cluster_redis.go

@@ -279,7 +279,7 @@ func (rc *ClusterRedisClient) Do(commandName string, args ...interface{}) (reply
 // @return err
 func (rc *ClusterRedisClient) RunLUA(command string, ctx context.Context, keys []string, args ...interface{}) bool {
 	script := redis.NewScript(command)
-	result, err := script.Run(ctx, rc.redisClient, keys, args).Int()
+	result, err := script.Run(ctx, rc.redisClient, keys, args...).Int()
 	if err != nil {
 		return false
 	}