|
|
@@ -37,7 +37,7 @@ class Order extends Api
|
|
|
$areaArr = explode(',', $params['area_id']);
|
|
|
$areaNum = count($areaArr);
|
|
|
if(($order_info->num + $areaNum) > $order_info->stock) $this->error(__("库存不足"));
|
|
|
-
|
|
|
+
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
@@ -50,12 +50,14 @@ class Order extends Api
|
|
|
//批量地区添加
|
|
|
foreach ($areaArr as $item) {
|
|
|
// 生成订单
|
|
|
- $order_info['product_id']= $params['product_id'];
|
|
|
- $productOrder::setCreateOrder($params['order_id'], $order_info, $productOrder::Popular, $this->auth->id, 0, getOrderSN('R'), 0);
|
|
|
-
|
|
|
+ $order_arr['price'] = $order_info->price;
|
|
|
+ $order_arr['product_id']= $params['product_id'];
|
|
|
+ $order_arr['area_id'] = $item;
|
|
|
+ $productOrder::setCreateOrder($params['order_id'], $order_arr, $productOrder::Popular, $this->auth->id, 0, getOrderSN('R'), 0);
|
|
|
//修改区域状态
|
|
|
$productArea->where('id', $item)->setField('status', ProductLists::STOP);
|
|
|
}
|
|
|
+
|
|
|
//余额记录
|
|
|
$ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::TOKEN, -$totalPrice, $ledgerWalletModel::Popular, $this->auth->id);
|
|
|
|
|
|
@@ -67,13 +69,14 @@ class Order extends Api
|
|
|
$pvs = bcmul(($order_info['pv'] * $areaNum), config('community_ratio'), 2);
|
|
|
$userModel::setCommunityRewards($this->auth->id, $pvs, Asset::TOKEN);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//更新Rwa持有数量
|
|
|
$userModel->updateForRwaNum($this->auth->id, $areaNum, '+');
|
|
|
//扣除库存
|
|
|
if(($order_info->stock - $areaNum) == 0 || time() >= $order_info->end_time) $order_info->status= $productPopular::STOP;
|
|
|
$order_info->num += $areaNum;
|
|
|
$order_info->save();
|
|
|
+
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
} catch (Exception $e) {
|
|
|
@@ -203,7 +206,6 @@ class Order extends Api
|
|
|
$params = $this->request->post();
|
|
|
$validate = \think\Loader::validate('Order');
|
|
|
if(!$validate->scene('giv')->check($params)) $this->error($validate->getError());
|
|
|
-
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
@@ -217,7 +219,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(__("余额不足请前往充值"), 15001);
|
|
|
-
|
|
|
+
|
|
|
//添加记录
|
|
|
$productOrder::setCreateOrder($params['order_id'], $order_info, $productOrder::Giveaway, $user['id'], $this->auth->id, getOrderSN('G'), $fees);
|
|
|
|
|
|
@@ -260,8 +262,6 @@ class Order extends Api
|
|
|
//转让列表取消
|
|
|
$productTransfer::where('order_id',$params['order_id'])->setField('status', $productTransfer::STOP);
|
|
|
|
|
|
- //增加Rwa有效
|
|
|
- $userModel->updateForRwaNum($order_info['user_id'], 1, '+');
|
|
|
$order_info->status= $productOrder::Paid;
|
|
|
$order_info->save();
|
|
|
// 提交事务
|