|
|
@@ -102,15 +102,15 @@ class Market extends Api
|
|
|
$params = $this->request->post();
|
|
|
$validate = \think\Loader::validate('Market');
|
|
|
if(!$validate->scene('buying')->check($params)) $this->error($validate->getError());
|
|
|
- if($productBuying::getProductBuyingCount($this->auth->id, $params['product_id']) > config('market_transfer.max_buying_num')) $this->error('您的求购次数已达上限');
|
|
|
+ if($productBuying::getProductBuyingCount($this->auth->id, $params['product_id']) > config('market_transfer.max_buying_count')) $this->error('您的求购次数已达上限');
|
|
|
$chabao = $ledgerWalletModel::getWalletChaBao($this->auth->id);
|
|
|
- $total = bcmul($params['min_price'], $params['num'], 6); // 所需茶宝
|
|
|
+ $total = bcmul($params['min_price'], $params['stock'], 6); // 所需茶宝
|
|
|
if($chabao < $total) $this->error('您的茶币不足');
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
// 记录订单
|
|
|
- $productBuying::setCreateBuying($this->auth->id, $params['product_id'], $params['num'], $params['min_price'], $total);
|
|
|
+ $productBuying::setCreateBuying($this->auth->id, $params['product_id'], $params['stock'], $params['min_price'], $total);
|
|
|
|
|
|
// 扣除茶币
|
|
|
$ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::TOKEN, -$total, LedgerTokenChangeModel::Buying, $this->auth->id);
|
|
|
@@ -168,7 +168,7 @@ class Market extends Api
|
|
|
$productOrder::where('id', $params['order_id'])->where('user_id', $this->auth->id)->setField(['status' => ProductOrder::Closure]);
|
|
|
|
|
|
if($buying->num == 1) $buying->status = ProductBuying::SaleOut;
|
|
|
- $buying->num = $buying->num +1;
|
|
|
+ $buying->num += 1;
|
|
|
$buying->save();
|
|
|
// 提交事务
|
|
|
Db::commit();
|