|
@@ -87,7 +87,7 @@ class Teac extends Api
|
|
|
$teacLogin::setCreateTrade($this->auth->id, $params['price'], $params['stock'], ProductTeac::Sell, $params['stock']);
|
|
$teacLogin::setCreateTrade($this->auth->id, $params['price'], $params['stock'], ProductTeac::Sell, $params['stock']);
|
|
|
|
|
|
|
|
//冻结Teac
|
|
//冻结Teac
|
|
|
- $ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::TEAC, -$params['stock'], LedgerTokenChangeModel::BuySellg, $this->auth->id);
|
|
|
|
|
|
|
+ $ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::TEAC, -$params['stock'], LedgerTeacChangeModel::Sell, $this->auth->id);
|
|
|
Db::commit();
|
|
Db::commit();
|
|
|
|
|
|
|
|
}catch(Exception $e){
|
|
}catch(Exception $e){
|
|
@@ -108,6 +108,7 @@ class Teac extends Api
|
|
|
if(!$validate->scene('sell_order')->check($params)) $this->error($validate->getError());
|
|
if(!$validate->scene('sell_order')->check($params)) $this->error($validate->getError());
|
|
|
$row = $productTeac::where(['type_id'=> ProductTeac::Sell, 'id' => $params['teac_id']])->find();
|
|
$row = $productTeac::where(['type_id'=> ProductTeac::Sell, 'id' => $params['teac_id']])->find();
|
|
|
if(empty($row) || $row['status'] != ProductTeac::Normal) $this->error('订单不存在');
|
|
if(empty($row) || $row['status'] != ProductTeac::Normal) $this->error('订单不存在');
|
|
|
|
|
+ if($this->auth->id == $row['user_id']) $this->error('不能购买自己的订单');
|
|
|
if($params['num'] > $row['stock'] - $row['num']) $this->error('库存不足');
|
|
if($params['num'] > $row['stock'] - $row['num']) $this->error('库存不足');
|
|
|
$chabao = $ledgerWalletModel->getWalletChaBao($this->auth->id);
|
|
$chabao = $ledgerWalletModel->getWalletChaBao($this->auth->id);
|
|
|
$tatal = bcmul($row['price'], $params['num'], 2);
|
|
$tatal = bcmul($row['price'], $params['num'], 2);
|
|
@@ -151,6 +152,7 @@ class Teac extends Api
|
|
|
if(!$validate->scene('sell_order')->check($params)) $this->error($validate->getError());
|
|
if(!$validate->scene('sell_order')->check($params)) $this->error($validate->getError());
|
|
|
$row = $productTeac::where(['type_id'=> ProductTeac::Buying, 'id' => $params['teac_id']])->find();
|
|
$row = $productTeac::where(['type_id'=> ProductTeac::Buying, 'id' => $params['teac_id']])->find();
|
|
|
if(empty($row) || $row['status'] != ProductTeac::Normal) $this->error('订单不存在');
|
|
if(empty($row) || $row['status'] != ProductTeac::Normal) $this->error('订单不存在');
|
|
|
|
|
+ if($this->auth->id == $row['user_id']) $this->error('不能购买自己的订单');
|
|
|
if($params['num'] > $row['stock'] - $row['num']) $this->error('库存不足');
|
|
if($params['num'] > $row['stock'] - $row['num']) $this->error('库存不足');
|
|
|
$chabao = $ledgerWalletModel->getWalletChaBao($this->auth->id);
|
|
$chabao = $ledgerWalletModel->getWalletChaBao($this->auth->id);
|
|
|
$tatal = bcmul($row['price'], $params['num'], 2);
|
|
$tatal = bcmul($row['price'], $params['num'], 2);
|