|
|
@@ -36,7 +36,7 @@ class Order extends Api
|
|
|
$areaArr = ($params['type'] == 1)? explode(',', $params['area_id']): '';
|
|
|
$areaNum = ($params['type'] == 1)? count($areaArr): $params['num'];
|
|
|
if(($order_info->num +$order_info->init_num+ $areaNum) > $order_info->stock) $this->error(__("库存不足"));
|
|
|
- // 启动事务
|
|
|
+ $result = false;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
|
|
|
@@ -48,9 +48,9 @@ class Order extends Api
|
|
|
|
|
|
//批量地区添加 1选择地区 2未选择地区
|
|
|
if($params['type'] == 1)
|
|
|
- $productOrder::setPopularAreaOrder($areaArr, $params['order_id'], $order_info->price, $params['product_id'], $this->auth->id);
|
|
|
+ $result = $productOrder::setPopularAreaOrder($areaArr, $params['order_id'], $order_info->price, $params['product_id'], $this->auth->id);
|
|
|
else
|
|
|
- $productOrder::setPopularNoAreaOrder($areaNum, $params['order_id'], $order_info->price, $params['product_id'], $this->auth->id);
|
|
|
+ $result =$productOrder::setPopularNoAreaOrder($areaNum, $params['order_id'], $order_info->price, $params['product_id'], $this->auth->id);
|
|
|
|
|
|
//余额记录
|
|
|
$ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::TOKEN, -$totalPrice, $ledgerWalletModel::Popular, $this->auth->id);
|
|
|
@@ -70,7 +70,7 @@ class Order extends Api
|
|
|
if(($order_info->stock - $areaNum) == 0 || time() >= $order_info->end_time) $order_info->status= $productPopular::STOP;
|
|
|
$order_info->num += $areaNum;
|
|
|
$order_info->save();
|
|
|
-
|
|
|
+ if (false === $result) $this->error(__('No rows were updated'));
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
} catch (Exception $e) {
|