|
|
@@ -32,9 +32,7 @@ class Teac extends Api
|
|
|
->where('product_teac.status', ProductTeac::Normal)->where('type_id', $type_id)
|
|
|
->order('create_time desc')
|
|
|
->paginate($this->pageSize);
|
|
|
- // foreach ($list as &$item) {
|
|
|
- // $item->users->avatar = !empty($item->users->avatar)? $item->users->avatar:$this->request->domain().'/assets/img/logo.png'; // 头像
|
|
|
- // }
|
|
|
+
|
|
|
$this->success('ok', $list);
|
|
|
}
|
|
|
|
|
|
@@ -49,7 +47,6 @@ class Teac extends Api
|
|
|
if(!$validate->scene('buying')->check($params)) $this->error($validate->getError());
|
|
|
if(config('teac_trade.buy_min_num') > $params['stock']) $this->error('数量不能低于'.config('teac_trade.buy_min_num'));
|
|
|
if(config('teac_trade.buy_min_price') > $params['price']) $this->error('价格不能低于'.config('teac_trade.buy_min_price'));
|
|
|
-
|
|
|
$chabao = bcmul($params['price'], $params['stock'], 2) ;
|
|
|
if($ledgerWalletModel->getWalletChaBao($this->auth->id) < $chabao) $this->error('您的钱包茶宝余额不足');
|
|
|
|
|
|
@@ -114,14 +111,14 @@ class Teac extends Api
|
|
|
if($params['num'] > $row['stock'] - $row['num']) $this->error('库存不足');
|
|
|
$chabao = $ledgerWalletModel->getWalletChaBao($this->auth->id);
|
|
|
$tatal = bcmul($row['price'], $params['num'], 2);
|
|
|
- if($chabao < bcmul($row['price'], $tatal, 2)) $this->error('您的钱包茶宝余额不足');
|
|
|
+ if($chabao < $tatal) $this->error('您的钱包茶宝余额不足');
|
|
|
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
|
|
|
- $fee = config('teac_trade.sell_fee');
|
|
|
-
|
|
|
+ $fee = config('teac_trade.sell_serve_fee');
|
|
|
+
|
|
|
// 出售购买
|
|
|
$userTeac::setUserCreateOrder($this->auth->id, $row['id'], ProductTeac::Sell, $params['num'], $row['price'], $fee);
|
|
|
|
|
|
@@ -157,13 +154,13 @@ class Teac extends Api
|
|
|
if($params['num'] > $row['stock'] - $row['num']) $this->error('库存不足');
|
|
|
$chabao = $ledgerWalletModel->getWalletChaBao($this->auth->id);
|
|
|
$tatal = bcmul($row['price'], $params['num'], 2);
|
|
|
- if($chabao < bcmul($row['price'], $tatal, 2)) $this->error('您的钱包茶宝余额不足');
|
|
|
+ if($chabao < $tatal) $this->error('您的钱包茶宝余额不足');
|
|
|
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
|
|
|
- $fee = config('teac_trade.sell_fee');
|
|
|
+ $fee = config('teac_trade.buy_serve_fee');
|
|
|
$chabao = bcmul($row['price'], $params['num'], 2);
|
|
|
// 出售购买
|
|
|
$userTeac::setUserCreateOrder($this->auth->id, $row['id'], ProductTeac::Buying, $params['num'], $row['price'], $fee);
|