Browse Source

判断茶宝锁定

afa 6 months ago
parent
commit
f220085d42

+ 1 - 1
application/api/controller/Ledger.php

@@ -47,7 +47,7 @@ class Ledger extends Api
                 'frozen_amount'=> $wallet->buying //冻结金额
             ],[
                 'coin_name' => 'Teac',
-                'coin_key'  => 'teac', 
+                'coin_key'  => 'Teac', 
                 'amount'    => $wallet->teac,
                 'frozen_amount'=> 0 //冻结金额
             ],[

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

@@ -45,14 +45,19 @@ class MarketLogic
       public static function setTransferLock(object $productTransfer, int $endTime, int $uid, string $transferId)
       {
             $time = time();
+            $total = 0;
             $lockList = $productTransfer->whereIn('id', $transferId)->select();
+
             foreach ($lockList as &$item) {
                   if($item->user_id == $uid)  throw new Exception(__("不能锁自己的寄售单"));
                   if($item->lock_uid  != $uid &&  $item->lock_time + $endTime > $time) throw new Exception(__("茶权已被他人锁定,无法操作"));
+                  $total += $item->price;
                   $item->lock_uid  = $uid;
                   $item->lock_time = $time;
                   $item->save();
-            }            
+            }
+            //余额足够
+            if($total > Loader::model('LedgerWalletModel')::getWalletChaBao($uid))  throw new Exception(__("茶宝余额不足"));
             return true;
       }
 

+ 2 - 2
application/api/logic/TeacLogin.php

@@ -29,8 +29,8 @@ class TeacLogin
     */
     public static  function setCreateTrade(int $uid, float $price, int $stock, int $typeId, float $frozen):object
     {
-        $rows = ProductTeac::where('user_id', $uid)->where('type_id', $typeId)->where('status', ProductTeac::Normal)->find();
-        if($rows)  throw new Exception(__("你有未完成的求购订单、不能重复发布"));
+        // $rows = ProductTeac::where('user_id', $uid)->where('type_id', $typeId)->where('status', ProductTeac::Normal)->find();
+        // if($rows)  throw new Exception(__("你有未完成的求购订单、不能重复发布"));
 
         //添加订单信息
         return ProductTeac::setUserCreateOrder($uid, $typeId, $price, $stock, config('teac_trade.'. self::$feeList[$typeId]), $frozen);