|
|
@@ -33,8 +33,8 @@ class Order extends Api
|
|
|
if(!$validate->scene('add')->check($params)) $this->error($validate->getError());
|
|
|
|
|
|
$order_info = $productPopular->where('id', $params['order_id'])->find();
|
|
|
- if($order_info->num == $order_info->stock) $this->error(__("库存不足"));
|
|
|
- if(empty($order_info)) $this->error(__("参数有误,无可用产品"));
|
|
|
+ // if($order_info->num == $order_info->stock) $this->error(__("库存不足"));
|
|
|
+ // if(empty($order_info)) $this->error(__("参数有误,无可用产品"));
|
|
|
$order_data['order_id'] = $params['order_id'];
|
|
|
$order_data['product_id']= $params['product_id'];
|
|
|
$order_data['price'] = $order_info['price'];
|
|
|
@@ -49,11 +49,10 @@ class Order extends Api
|
|
|
try {
|
|
|
|
|
|
$amount = $ledgerWalletModel::getWalletChaBao($this->auth->id);
|
|
|
- if(bccomp($order_info['price'], $amount, 2) > 0) throw new Exception(__("余额不足请前往充值"));
|
|
|
+ if(bccomp($order_info['price'], $amount, 2) < 0) throw new Exception(__("余额不足请前往充值"), 300);
|
|
|
if($order_info->stock == 0 || time() >= $order_info->end_time) throw new Exception(__("抢购已结束"));
|
|
|
// 生成订单
|
|
|
$productOrder->create($order_data);
|
|
|
-
|
|
|
//修改区域状态
|
|
|
$productArea->where('id', $order_data['area_id'])->setField('status', ProductLists::STOP);
|
|
|
|
|
|
@@ -74,7 +73,7 @@ class Order extends Api
|
|
|
} catch (Exception $e) {
|
|
|
// 回滚事务
|
|
|
Db::rollback();
|
|
|
- $this->error( $e->getMessage());
|
|
|
+ $this->error($e->getMessage(), null, $e->getCode());
|
|
|
}
|
|
|
$this->success('ok');
|
|
|
}
|
|
|
@@ -166,7 +165,7 @@ class Order extends Api
|
|
|
$order_info = $productTransfer->where('id', $params['order_id'])->where('status', $productTransfer::NORMAL)->find();
|
|
|
if(empty($order_info)) throw new Exception(__("订单不存在"));
|
|
|
$chabao = $ledgerWalletModel::getWalletChaBao($this->auth->id);
|
|
|
- if(bccomp($order_info['price'], $chabao, 2) > 0) throw new Exception(__("余额不足请前往充值"));
|
|
|
+ if(bccomp($order_info['price'], $chabao, 2) > 0) throw new Exception(__("余额不足请前往充值"), 300);
|
|
|
|
|
|
$order_data['order_id'] = $params['order_id'];
|
|
|
$order_data['product_id']= $order_info['product_id'];
|
|
|
@@ -198,7 +197,7 @@ class Order extends Api
|
|
|
Db::commit();
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
- $this->error($e->getMessage());
|
|
|
+ $this->error($e->getMessage(), null, $e->getCode());
|
|
|
}
|
|
|
$this->success('ok');
|
|
|
}
|
|
|
@@ -222,7 +221,7 @@ class Order extends Api
|
|
|
|
|
|
$chabao = $ledgerWalletModel::getWalletChaBao($this->auth->id);
|
|
|
$fees = bcmul($order_info['price'], getConfig('giveaway'), 2);
|
|
|
- if(bccomp($fees, $chabao, 2) > 0) throw new Exception(__("余额不足请前往充值"));
|
|
|
+ if(bccomp($fees, $chabao, 2) > 0) throw new Exception(__("余额不足请前往充值"), 300);
|
|
|
|
|
|
//添加记录
|
|
|
$order_data['order_id'] = $params['order_id'];
|
|
|
@@ -250,7 +249,7 @@ class Order extends Api
|
|
|
} catch (Exception $e) {
|
|
|
// 回滚事务
|
|
|
Db::rollback();
|
|
|
- $this->error( $e->getMessage());
|
|
|
+ $this->error( $e->getMessage(), null, $e->getCode());
|
|
|
}
|
|
|
$this->success('ok');
|
|
|
}
|