|
|
@ -104,7 +104,8 @@ class OrderService extends AdminBaseService |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => 0, 'list' => [], 'extent' => ['totalMoney' => 0]]); |
|
|
|
} |
|
|
|
if (!empty($where['user_id']) && is_numeric($where['user_id']) && $where['user_id'] == 0) { |
|
|
|
return $this->toData('1', 'SUCCESS', ['total' => 0, 'list' => [], 'extent' => ['totalMoney' => 0, |
|
|
|
return $this->toData('1', 'SUCCESS', ['total' => 0, 'list' => [], 'extent' => [ |
|
|
|
'totalMoney' => 0, |
|
|
|
]]); |
|
|
|
} |
|
|
|
|
|
|
@ -163,10 +164,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -174,7 +178,6 @@ class OrderService extends AdminBaseService |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 现货撤单 |
|
|
@ -260,10 +263,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -271,7 +277,6 @@ class OrderService extends AdminBaseService |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 现货订单 |
|
|
@ -357,10 +362,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -368,7 +376,6 @@ class OrderService extends AdminBaseService |
|
|
|
} catch (\Exception $exception) { |
|
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -463,10 +470,14 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, 'totalServiceCost' => $totalServiceCost, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
'totalServiceCost' => $totalServiceCost, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -559,10 +570,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -656,10 +670,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -737,10 +754,10 @@ class OrderService extends AdminBaseService |
|
|
|
foreach ($list as $item) { |
|
|
|
// 计算浮动盈亏 |
|
|
|
if ($item['trade_type'] == 1) { |
|
|
|
// $float = $item['closing_price'] - $item['deal_price']; |
|
|
|
// $float = $item['closing_price'] - $item['deal_price']; |
|
|
|
$float = bcsub($item['closing_price'], $item['deal_price'], 10); |
|
|
|
} else { |
|
|
|
// $float = $item['deal_price'] - $item['closing_price']; |
|
|
|
// $float = $item['deal_price'] - $item['closing_price']; |
|
|
|
$float = bcsub($item['deal_price'], $item['closing_price'], 10); |
|
|
|
} |
|
|
|
|
|
|
@ -771,12 +788,14 @@ class OrderService extends AdminBaseService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalClosingCost' => $totalClosingCost, |
|
|
|
'totalFloat' => $totalFloat['total'], |
|
|
|
]]); |
|
|
|
|
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -878,10 +897,14 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, 'totalServiceCost' => $totalServiceCost, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
'totalServiceCost' => $totalServiceCost, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -974,10 +997,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -1071,10 +1097,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -1184,12 +1213,14 @@ class OrderService extends AdminBaseService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalClosingCost' => $totalClosingCost, |
|
|
|
'totalFloat' => $totalFloat['total'], |
|
|
|
]]); |
|
|
|
|
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -1291,10 +1322,14 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, 'totalServiceCost' => $totalServiceCost, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
'totalServiceCost' => $totalServiceCost, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -1387,10 +1422,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -1484,10 +1522,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -1565,10 +1606,10 @@ class OrderService extends AdminBaseService |
|
|
|
foreach ($list as $item) { |
|
|
|
// 计算浮动盈亏 |
|
|
|
if ($item['trade_type'] == 1) { |
|
|
|
// $float = $item['closing_price'] - $item['deal_price']; |
|
|
|
// $float = $item['closing_price'] - $item['deal_price']; |
|
|
|
$float = bcsub($item['closing_price'], $item['deal_price'], 10); |
|
|
|
} else { |
|
|
|
// $float = $item['deal_price'] - $item['closing_price']; |
|
|
|
// $float = $item['deal_price'] - $item['closing_price']; |
|
|
|
$float = bcsub($item['deal_price'], $item['closing_price'], 10); |
|
|
|
} |
|
|
|
|
|
|
@ -1599,12 +1640,14 @@ class OrderService extends AdminBaseService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalClosingCost' => $totalClosingCost, |
|
|
|
'totalFloat' => $totalFloat['total'], |
|
|
|
]]); |
|
|
|
|
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -1720,11 +1763,14 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, 'totalServiceCost' => $totalServiceCost, |
|
|
|
]]); |
|
|
|
|
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
'totalServiceCost' => $totalServiceCost, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -1835,10 +1881,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -1948,10 +1997,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -2035,10 +2087,10 @@ class OrderService extends AdminBaseService |
|
|
|
foreach ($list as $item) { |
|
|
|
// 计算浮动盈亏 |
|
|
|
if ($item['trade_type'] == 1) { |
|
|
|
// $float = $item['closing_price'] - $item['deal_price']; |
|
|
|
// $float = $item['closing_price'] - $item['deal_price']; |
|
|
|
$float = bcsub($item['closing_price'], $item['deal_price'], 18); |
|
|
|
} else { |
|
|
|
// $float = $item['deal_price'] - $item['closing_price']; |
|
|
|
// $float = $item['deal_price'] - $item['closing_price']; |
|
|
|
$float = bcsub($item['deal_price'], $item['closing_price'], 18); |
|
|
|
} |
|
|
|
|
|
|
@ -2075,12 +2127,14 @@ class OrderService extends AdminBaseService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalClosingCost' => $totalClosingCost, |
|
|
|
'totalFloat' => $totalFloat['total'], |
|
|
|
]]); |
|
|
|
|
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -2134,7 +2188,7 @@ class OrderService extends AdminBaseService |
|
|
|
$total = Db::table($tableObj['order_table'])->where($where)->where($whereU)->count(); |
|
|
|
|
|
|
|
|
|
|
|
$stockTape=(new IPOService)->getStockTape($marketType); |
|
|
|
$stockTape = (new IPOService)->getStockTape($marketType); |
|
|
|
$tapeList = $stockTape['tape']; |
|
|
|
$stockTypeList = $stockTape['type']; |
|
|
|
$statusList = UserUsPreStockOrderModel::$statusList; |
|
|
@ -2171,9 +2225,7 @@ class OrderService extends AdminBaseService |
|
|
|
'stock_type_list' => $stockTypeList, |
|
|
|
'status_list' => $statusList |
|
|
|
]]); |
|
|
|
|
|
|
|
} catch |
|
|
|
(ValidateException $validateException) { |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
|
return $this->toData('1', $message); |
|
|
@ -2237,7 +2289,7 @@ class OrderService extends AdminBaseService |
|
|
|
} |
|
|
|
$tableObj = (new IPOService)->getStockModel($marketType); |
|
|
|
|
|
|
|
$order = Db::table($tableObj['order_table'])->where('id', $param['id'])->whereIn('status',[1,2,5,6])->find(); |
|
|
|
$order = Db::table($tableObj['order_table'])->where('id', $param['id'])->whereIn('status', [1, 2, 5, 6])->find(); |
|
|
|
if (empty($order)) return $this->toData('1', 'id参数错误'); |
|
|
|
|
|
|
|
|
|
|
@ -2246,56 +2298,56 @@ class OrderService extends AdminBaseService |
|
|
|
->where('id', $param['pre_id']) |
|
|
|
// 签名状态 |
|
|
|
->where('sign_status', 1) |
|
|
|
->where('open_status', 1) ->find(); |
|
|
|
if(empty($preStock)){ |
|
|
|
->where('open_status', 1)->find(); |
|
|
|
if (empty($preStock)) { |
|
|
|
return $this->toData('1', 'IPO未签名或已上市不可退款'); |
|
|
|
} |
|
|
|
|
|
|
|
$now = date('Y-m-d H:i:s'); |
|
|
|
$total_num=$order['amount']+$order['fee']; |
|
|
|
$total_num = $order['amount'] + $order['fee']; |
|
|
|
//查询订单有没有欠款 |
|
|
|
$user_arrears=UserArrearsModel::where('order_no', $order['order_no'])->where('status',0)->where('user_id', $order['user_id'])->find(); |
|
|
|
$user_arrears = UserArrearsModel::where('order_no', $order['order_no'])->where('status', 0)->where('user_id', $order['user_id'])->find(); |
|
|
|
|
|
|
|
Db::startTrans(); |
|
|
|
if($user_arrears){ |
|
|
|
$user_arrears=$user_arrears->toArray(); |
|
|
|
if($user_arrears['is_add']==1){ |
|
|
|
if ($user_arrears) { |
|
|
|
$user_arrears = $user_arrears->toArray(); |
|
|
|
if ($user_arrears['is_add'] == 1) { |
|
|
|
//扣除冻结,不加可用 |
|
|
|
$updateNum = Db::table($tableObj['user_table'])->where('stock_id', $tableObj['stock_id'])->where('user_id', $order['user_id']) |
|
|
|
->where('frozen_num', '>=', $total_num) |
|
|
|
->dec('frozen_num',$total_num) |
|
|
|
->dec('frozen_num', $total_num) |
|
|
|
->update(['update_time' => $now]); |
|
|
|
if(!$updateNum){ |
|
|
|
if (!$updateNum) { |
|
|
|
Db::rollback(); |
|
|
|
trace('IPO订单退款01-给用户ID:' . $order['user_id'] . "解冻资金异常" . $order['order_no'], 'error'); |
|
|
|
return $this->toData('1', '解冻资金异常'); |
|
|
|
} |
|
|
|
} |
|
|
|
$update_bool=UserArrearsModel::where('order_no', $order['order_no'])->where('user_id', $order['user_id']) |
|
|
|
$update_bool = UserArrearsModel::where('order_no', $order['order_no'])->where('user_id', $order['user_id']) |
|
|
|
->update([ |
|
|
|
'update_time'=>$now, |
|
|
|
'status'=>1 |
|
|
|
'update_time' => $now, |
|
|
|
'status' => 1 |
|
|
|
]); |
|
|
|
if(!$update_bool){ |
|
|
|
if (!$update_bool) { |
|
|
|
Db::rollback(); |
|
|
|
trace('IPO订单退款02-给用户ID:' . $order['user_id'] . "更新贷款订单异常" . $order['order_no'], 'error'); |
|
|
|
return $this->toData('1', '更新贷款订单异常'); |
|
|
|
} |
|
|
|
|
|
|
|
$status=8; |
|
|
|
}else{ |
|
|
|
$status = 8; |
|
|
|
} else { |
|
|
|
//扣除冻结 加可用 |
|
|
|
$updateNum = Db::table($tableObj['user_table'])->where('stock_id', $tableObj['stock_id'])->where('user_id', $order['user_id']) |
|
|
|
->where('frozen_num', '>=', $total_num) |
|
|
|
->inc('usable_num', $total_num) |
|
|
|
->dec('frozen_num',$total_num) |
|
|
|
->dec('frozen_num', $total_num) |
|
|
|
->update(['update_time' => $now]); |
|
|
|
if(!$updateNum){ |
|
|
|
if (!$updateNum) { |
|
|
|
Db::rollback(); |
|
|
|
trace('IPO订单退款03-给用户ID:' . $order['user_id'] . "解冻资金异常" . $order['order_no'], 'error'); |
|
|
|
return $this->toData('1', '解冻资金异常'); |
|
|
|
} |
|
|
|
$status=7; |
|
|
|
$status = 7; |
|
|
|
} |
|
|
|
|
|
|
|
//更新状态 |
|
|
@ -2398,7 +2450,6 @@ class OrderService extends AdminBaseService |
|
|
|
'stock_type_list' => PreFundStockModel::$stockTypeList, |
|
|
|
'cycle_type_list' => PreFundStockModel::$cycleTypeList |
|
|
|
]]); |
|
|
|
|
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -2602,10 +2653,14 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, 'totalServiceCost' => $totalServiceCost, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
'totalServiceCost' => $totalServiceCost, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -2706,9 +2761,11 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -2810,10 +2867,13 @@ class OrderService extends AdminBaseService |
|
|
|
if ($totalModel['total']) { |
|
|
|
$totalMoney = round($totalModel['total'], 4); |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
'extent' => ['totalMoney' => $totalMoney, |
|
|
|
]]); |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -2892,10 +2952,10 @@ class OrderService extends AdminBaseService |
|
|
|
foreach ($list as $item) { |
|
|
|
// 计算浮动盈亏 |
|
|
|
if ($item['trade_type'] == 1) { |
|
|
|
// $float = $item['closing_price'] - $item['deal_price']; |
|
|
|
// $float = $item['closing_price'] - $item['deal_price']; |
|
|
|
$float = bcsub($item['closing_price'], $item['deal_price'], 18); |
|
|
|
} else { |
|
|
|
// $float = $item['deal_price'] - $item['closing_price']; |
|
|
|
// $float = $item['deal_price'] - $item['closing_price']; |
|
|
|
$float = bcsub($item['deal_price'], $item['closing_price'], 18); |
|
|
|
} |
|
|
|
$float = bcmul($float, $item['order_number'], 18); |
|
|
@ -2925,12 +2985,14 @@ class OrderService extends AdminBaseService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, |
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalClosingCost' => $totalClosingCost, |
|
|
|
'totalFloat' => $totalFloat['total'], |
|
|
|
]]); |
|
|
|
|
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -2941,12 +3003,11 @@ class OrderService extends AdminBaseService |
|
|
|
} |
|
|
|
|
|
|
|
################################################# 大宗交易 |
|
|
|
//大宗交易订单 |
|
|
|
public function blockStock($param, $adminId) |
|
|
|
public function blockStockHold($param, $adminId) |
|
|
|
{ |
|
|
|
try { |
|
|
|
// 参数校验 |
|
|
|
validate(OrderValidate::class)->scene('fund_stock')->check($param); |
|
|
|
validate(OrderValidate::class)->scene('block_stockHold')->check($param); |
|
|
|
|
|
|
|
$where = []; |
|
|
|
$userId = 0; |
|
|
@ -2964,50 +3025,88 @@ class OrderService extends AdminBaseService |
|
|
|
if (!is_array($whereU)) { |
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => 0, 'list' => [], 'extent' => ['totalMoney' => 0]]); |
|
|
|
} |
|
|
|
$market_type = intval($param['market_type']); |
|
|
|
$table_obj = (new IPOService())->getStockModel($market_type); |
|
|
|
if (empty($table_obj)) { |
|
|
|
return $this->toData('1', '数据异常'); |
|
|
|
} |
|
|
|
|
|
|
|
if (!empty($param['type']) && is_numeric($param['type'])) { |
|
|
|
$where['type'] = $param['type']; |
|
|
|
// 订单号 |
|
|
|
if (!empty($param['order_id'])) { |
|
|
|
$where['order_id'] = $param['order_id']; |
|
|
|
} |
|
|
|
if (isset($param['status'])) { |
|
|
|
$where['status'] = $param['status']; |
|
|
|
} |
|
|
|
// 交易对 |
|
|
|
if (!empty($param['stock_id'])) { |
|
|
|
$where['stock_id'] = $param['contract_id']; |
|
|
|
} |
|
|
|
|
|
|
|
$list = UserStockBlockOrderModel::where($whereU)->where($where)->order('id', 'desc')->page($param['page'], $param['limit'])->select(); |
|
|
|
$total = UserStockBlockOrderModel::where($whereU)->where($where)->count(); |
|
|
|
if (!empty($param['start_time']) && !empty($param['end_time'])) { |
|
|
|
$where['open_time'] = ['between time', [$param['start_time'], $param['end_time']]]; |
|
|
|
} |
|
|
|
|
|
|
|
// 列表 |
|
|
|
$list = Db::table($table_obj['trade_table'])->where($whereU)->where($where)->order('trade_id', 'desc')->page($param['page'], $param['limit'])->select(); |
|
|
|
// 总数 |
|
|
|
$summary = Db::table($table_obj['trade_table']) |
|
|
|
->where($whereU) |
|
|
|
->where($where) |
|
|
|
->field('COUNT(*) as total,sum(order_money) as total_money,sum(service_cost) as total_service_cost') |
|
|
|
->find(); |
|
|
|
$rows = []; |
|
|
|
if (!$list->isEmpty()) { |
|
|
|
// 获取用户号 |
|
|
|
$userIdArr = []; |
|
|
|
// stock |
|
|
|
$preStockId = []; |
|
|
|
foreach ($list as $idItem) { |
|
|
|
$userIdArr[] = $idItem['user_id']; |
|
|
|
// $preStockId[] = $idItem['pre_stock_id']; |
|
|
|
} |
|
|
|
|
|
|
|
$userNoArr = UserModel::where('user_id', 'in', $userIdArr)->column('user_no', 'user_id'); |
|
|
|
// $stockArr = PreFundStockModel::where('id', 'in', $preStockId)->column('*', 'id'); |
|
|
|
|
|
|
|
$rows = $list->toArray(); |
|
|
|
foreach ($rows as $key => $item) { |
|
|
|
// $stock = $stockArr[$item['pre_stock_id']] ?? []; |
|
|
|
// if (empty($stock)) continue; |
|
|
|
$rows[$key]['user_no'] = $userNoArr[$item['user_id']] ?? '-'; // 用户号 |
|
|
|
$rows[$key]['stock_name'] = $item['stock_name'] ?? '-'; |
|
|
|
$rows[$key]['market_price'] = $item['market_price'] ?? '-'; |
|
|
|
$rows[$key]['deal_price'] = $item['deal_price'] ?? '-'; |
|
|
|
$rows[$key]['order_number'] = $item['order_number'] ?? '-'; |
|
|
|
$rows[$key]['market_money'] = $item['market_money'] ?? '-'; |
|
|
|
$rows[$key]['order_money'] = $item['order_money'] ?? '-'; |
|
|
|
$rows[$key]['status'] = UserStockBlockOrderModel::$statusList[$item['status']]; |
|
|
|
$rows[$key]['type'] = UserStockBlockOrderModel::$typeList[$item['type']]; |
|
|
|
$rows[$key]['create_time'] = $item['create_time'] ?? '-'; |
|
|
|
foreach ($list as $item) { |
|
|
|
$orderNumber = number_format($item['order_number'], '18', '.', ''); |
|
|
|
$orderPrice = number_format($item['deal_price'], '18', '.', ''); |
|
|
|
$orderAmount = bcmul($orderNumber, $orderPrice, 18); |
|
|
|
if (in_array($market_type, [21])) { // 一些市场类型字段不一样,比如黄金期货没有stock_id,而是用的contract_id |
|
|
|
$stockIdOrContractId = $item['contract_id']; |
|
|
|
} else { |
|
|
|
$stockIdOrContractId = $item['stock_id']; |
|
|
|
} |
|
|
|
$rows[] = [ |
|
|
|
'trade_id' => $item['trade_id'], // |
|
|
|
'user_no' => $userNoArr[$item['user_id']] ?? '-', // 用户号 |
|
|
|
'order_id' => $item['order_id'], // 用户号 |
|
|
|
'open_time' => $item['open_time'] ?? '-', // 挂单时间 |
|
|
|
'trade_type' => $item['trade_type'] == 1 ? '买涨' : '买跌', |
|
|
|
'order_money' => $orderAmount, // 订单金额 |
|
|
|
'stock_id' => $stockIdOrContractId, // 股票代码 |
|
|
|
'order_number' => $item['order_number'], // 数量 |
|
|
|
'service_cost' => $item['service_cost'], // 服务费 |
|
|
|
'float' => '-', // 浮动盈亏 |
|
|
|
'deal_price' => $item['deal_price'], // 开仓价 |
|
|
|
'now_price' => '-', // 当前价 |
|
|
|
'stop_loss_price' => $item['stop_loss_price'], // 止损价 |
|
|
|
'stop_win_price' => $item['stop_win_price'], // 止盈价 |
|
|
|
'pry_num' => $item['pry_num'], // 杠杆 |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, 'extend' => [ |
|
|
|
'status_list' => UserStockBlockOrderModel::$statusList, |
|
|
|
'type_list' => UserStockBlockOrderModel::$typeList |
|
|
|
]]); |
|
|
|
|
|
|
|
$totalMoney = $total = $totalServiceCost = 0; |
|
|
|
if ($summary) { |
|
|
|
$totalMoney = round($summary['total'] ?? 0, 4); |
|
|
|
$totalServiceCost = round($summary['total_service_cost'] ?? 0, 4); |
|
|
|
$total = $summary['total'] ?? 0; |
|
|
|
} |
|
|
|
return $this->toData('0', 'SUCCESS', [ |
|
|
|
'total' => $total, |
|
|
|
'list' => $rows, |
|
|
|
'extent' => [ |
|
|
|
'totalMoney' => $totalMoney, |
|
|
|
'totalServiceCost' => $totalServiceCost, |
|
|
|
] |
|
|
|
]); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
// 参数校验失败 |
|
|
|
$message = $validateException->getError(); |
|
|
@ -3016,4 +3115,4 @@ class OrderService extends AdminBaseService |
|
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|