afa 7 miesięcy temu
rodzic
commit
2f96c47e8a

+ 7 - 4
application/api/controller/Market.php

@@ -23,11 +23,10 @@ use think\Exception;
 class Market extends Api
 {
 
-    const LockTime = 180; // 锁定时间 3分钟
+   
     //用户收藏
     public function collect(UserCollect $userCollect)
     {
-
         $params = $this->request->post();
         $validate = \think\Loader::validate('Market');
         if(!$validate->scene('collect')->check($params)) $this->error($validate->getError());
@@ -70,11 +69,10 @@ class Market extends Api
         $params = $this->request->post();
         $validate = \think\Loader::validate('Market');
         if(!$validate->scene('transferlock')->check($params)) $this->error($validate->getError());
-  
         Db::startTrans();
         try {
 
-            $marketLogic->setTransferLock($productTransfer, time() + self::LockTime, $params);
+            $marketLogic::setTransferLock($productTransfer, config('market_transfer.lock_time'), $params['transfer_id']);
           
             // 提交事务
             Db::commit();
@@ -170,6 +168,11 @@ class Market extends Api
         }
     }
 
+    //获取配置信息
+    public function getMarketConfig()
+    {
+        $this->success('ok', config('market_transfer'));
+    }
  
 
 

+ 3 - 6
application/api/logic/MarketLogic.php

@@ -62,7 +62,6 @@ class MarketLogic
             //是否全部取消
             $rows  = ProductTransfer::where('order_id', $orderId)->find();
             $count = ProductTransfer::where('product_id', $orderInfo['product_id'])->where('status', ProductTransfer::Normal)->count();
-
             if($count == 1){
                   $isUpdate = true;
                   $market->status = ProductMarket::Hidden;
@@ -73,7 +72,6 @@ class MarketLogic
                         $market->price = ProductTransfer::getTransferMinPriceByProduct($orderInfo['product_id'], $rows->price);
                   }
             }
-
             //市场状态
             if($isUpdate) $market->save();
 
@@ -87,18 +85,17 @@ class MarketLogic
 
 
       //判断是否锁定
-      public static function setTransferLock(object $productTransfer, int $endTime, array $params)
+      public static function setTransferLock(object $productTransfer, int $endTime, string $transferId)
       {
             $time = time();
             $lockCount = $productTransfer
-                        ->whereIn('id', $params['transfer_id'])
+                        ->whereIn('id', $transferId)
                         ->where('is_lock', $productTransfer::Lock)
                         ->whereTime('lock_time','>', - $endTime)
                         ->count();
-        
             if(!empty($lockCount)) throw new Exception(__("茶权已被他人锁定,无法操作"));
 
-            return $productTransfer->whereIn('id', $params['transfer_id'])
+            return $productTransfer->whereIn('id', $transferId)
                   ->update(['lock_time'=> $time, 'is_lock' => $productTransfer::Lock]);
 
 

+ 9 - 1
application/config.php

@@ -321,5 +321,13 @@ return [
     'min_rwa_price'   => 499, //Rwa最低价格统计数量,
     'withdraw_in_amount' => 600, //提现金额手续费
     'super_weal_end_time' => 168 * 3600, //168小时
-    'min_frozen'          => 9.9 //最小保留标记金额
+    'min_frozen'          => 9.9, //最小保留标记金额
+
+    //市场配置 
+    'market_transfer' => [
+        'lock_time'         => 300, //锁定时间秒
+        'min_buy_price'         => 10,  //最小求购价格
+        'serve_desc'        => "服务描述",
+        'serve_fee'         => 0.045, //服务费
+    ],
 ];