Compare commits

...

2 Commits

Author SHA1 Message Date
liyang 8087e69b41 fix: ipo 修复 2 months ago
liyang e17d58850e fix: ipo后支付 2 months ago
  1. 2
      app/admin/route/app.php
  2. 32
      app/admin/service/OrderService.php
  3. 44
      app/admin/service/setting/IPOService.php
  4. 8
      app/home/service/IPOService.php

2
app/admin/route/app.php

@ -189,7 +189,7 @@ Route::group('/', function () {
// 申购订单 // 申购订单
Route::post('/order/pre_stock_order', 'Order/preStock'); Route::post('/order/pre_stock_order', 'Order/preStock');
Route::post('/order/update_order_num', 'Order/updateGetNum')->middleware('admin_log'); // 修改中签数 Route::post('/order/update_order_num', 'Order/updateGetNum')->append(['market_type' => 18])->middleware('admin_log'); // 修改中签数
Route::post('/order/pre_refund', 'Order/preRefund')->middleware('admin_log'); // ipo订单退款 Route::post('/order/pre_refund', 'Order/preRefund')->middleware('admin_log'); // ipo订单退款
//基金订单 //基金订单

32
app/admin/service/OrderService.php

@ -2252,22 +2252,30 @@ class OrderService extends AdminBaseService
if (in_array($order['status'], [7, 8])) return $this->toData('1', '订单已退款,不可操作'); if (in_array($order['status'], [7, 8])) return $this->toData('1', '订单已退款,不可操作');
if ($param['get_num'] > $order['num']) { // if ($param['get_num'] > $order['num']) {
return $this->toData('1', '修改中签数不能大于订单申购数'); // return $this->toData('1', '修改中签数不能大于订单申购数');
} // }
// 1 2 5 状态才能修改数量
$getTime = Db::table($tableObj['stock_table'])->where('id', $order['pre_stock_id'])->value('get_time'); if (!in_array($order['status'], [1, 2, 5])) {
if (env('USER_ARREARS.HAS_USER_ARREARS') == 1 && $order['pay_type'] == 2 && in_array($order['status'], [5, 6])) { return $this->toData('1', 'IPO已上市,无法修改');
} else { }
if (strtotime($getTime) < time()) return $this->toData('1', 'IPO已中签,无法修改'); // $getTime = Db::table($tableObj['stock_table'])->where('id', $order['pre_stock_id'])->value('get_time');
} // if (env('USER_ARREARS.HAS_USER_ARREARS') == 1 && $order['pay_type'] == 2 && in_array($order['status'], [5, 6])) {
// } else {
$bool = Db::table($tableObj['order_table'])->where('id', $param['id'])->update([ // if (strtotime($getTime) < time()) return $this->toData('1', 'IPO已中签,无法修改');
// }
$updateArr = [
'get_num' => $param['get_num'], 'get_num' => $param['get_num'],
'get_amount' => $param['get_num'] * $order['price'], 'get_amount' => $param['get_num'] * $order['price'],
'get_fee' => $order['get_amount'] * $order['fee_rate'], 'get_fee' => $order['get_amount'] * $order['fee_rate'],
'update_time' => date('Y-m-d H:i:s') 'update_time' => date('Y-m-d H:i:s')
]); ];
if ($order['pay_type'] == 2) {
$updateArr['num'] = $param['get_num'];
$updateArr['amount'] = $param['get_num'] * $order['price'];
$updateArr['fee'] = $updateArr['amount'] * $order['fee_rate'];
}
$bool = Db::table($tableObj['order_table'])->where('id', $param['id'])->update($updateArr);
if (!$bool) return $this->toData('1', '修改失败'); if (!$bool) return $this->toData('1', '修改失败');
return $this->toData('0', 'SUCCESS', []); return $this->toData('0', 'SUCCESS', []);

44
app/admin/service/setting/IPOService.php

@ -36,6 +36,7 @@ use think\exception\ValidateException;
use think\facade\Db; use think\facade\Db;
use think\facade\Log; use think\facade\Log;
use think\facade\Queue; use think\facade\Queue;
use think\facade\Cache;
class IPOService extends AdminBaseService class IPOService extends AdminBaseService
{ {
@ -647,7 +648,6 @@ class IPOService extends AdminBaseService
return $this->toData('1', '无法操作'); return $this->toData('1', '无法操作');
} }
Db::startTrans(); Db::startTrans();
// 修改股票状态 // 修改股票状态
$num = Db::table($table_obj['stock_table'])->where('id', $preInStock['id'])->update([ $num = Db::table($table_obj['stock_table'])->where('id', $preInStock['id'])->update([
@ -662,10 +662,6 @@ class IPOService extends AdminBaseService
$tape_list = $this->getStockTape($market_type); $tape_list = $this->getStockTape($market_type);
if (Db::table($table_obj['list_table'])->where('stock_code', $preInStock['stock_code'])->find()) {
Db::rollback();
return $this->toData('1', '股票列表已存在该股票');
}
// 将新股加入股票 // 将新股加入股票
$inStock['stock_name'] = $preInStock['stock_name']; $inStock['stock_name'] = $preInStock['stock_name'];
$inStock['stock_code'] = $preInStock['stock_code']; $inStock['stock_code'] = $preInStock['stock_code'];
@ -676,14 +672,20 @@ class IPOService extends AdminBaseService
$inStock['forced_closure'] = 30; $inStock['forced_closure'] = 30;
$inStock['up_limit'] = 30; $inStock['up_limit'] = 30;
$inStock['down_limit'] = 30; $inStock['down_limit'] = 30;
$inStock['create_time'] = date('Y-m-d H:i:s');
$inStock['update_time'] = date('Y-m-d H:i:s'); $inStock['update_time'] = date('Y-m-d H:i:s');
if ($market_type == 5) $inStock['numeric_code'] = $preInStock['numeric_code']; if ($market_type == 5) $inStock['numeric_code'] = $preInStock['numeric_code'];
if (Db::table($table_obj['list_table'])->where('stock_code', $preInStock['stock_code'])->find()) {
$bool = Db::table($table_obj['list_table'])->where('stock_code', $preInStock['stock_code'])->update($inStock);
} else {
$inStock['create_time'] = date('Y-m-d H:i:s');
$bool = Db::table($table_obj['list_table'])->insert($inStock); $bool = Db::table($table_obj['list_table'])->insert($inStock);
if (!$bool) { if (!$bool) {
Db::rollback(); Db::rollback();
return $this->toData('1', '股票转移失败'); return $this->toData('1', '股票转移失败');
} }
}
// 加入缓存 // 加入缓存
$list_key = $table_obj['redis_key'] . $preInStock['stock_code']; $list_key = $table_obj['redis_key'] . $preInStock['stock_code'];
@ -790,19 +792,34 @@ class IPOService extends AdminBaseService
if (empty($param['type'])) { if (empty($param['type'])) {
return $this->toData('1', '缺少参数'); return $this->toData('1', '缺少参数');
} }
// ✅【防重复点击】锁键
$lockKey = "repeatNoteGo_lock_{$market_type}_{$param['id']}_{$param['type']}";
if (!Cache::store('redis')->setnx($lockKey, 1)) {
return $this->toData('1', '请勿重复操作');
}
// 锁自动过期时间 60 秒(你可以根据需求改为 2-10 秒)
Cache::store('redis')->expire($lockKey, 60);
try {
$tape_list = $this->getStockTape($market_type); $tape_list = $this->getStockTape($market_type);
$preInStock = Db::table($table_obj['stock_table'])->where('id', $param['id'])->where('open_status', 2)->where('is_delete', 1)->find(); $preInStock = Db::table($table_obj['stock_table'])
->where('id', $param['id'])
->where('open_status', 2)
->where('is_delete', 1)
->find();
if (empty($preInStock)) { if (empty($preInStock)) {
return $this->toData('1', '股票未上市'); return $this->toData('1', '股票未上市');
} }
if ($preInStock['hq_status'] == 2 && $param['type'] == 'hq') { if ($preInStock['hq_status'] == 2 && $param['type'] == 'hq') {
// 给行情发送数据
Queue::push('app\admin\job\SendGo', [ Queue::push('app\admin\job\SendGo', [
'type' => 'hq', 'type' => 'hq',
'stock_code' => $preInStock['stock_code'], 'stock_code' => $preInStock['stock_code'],
'stock_name' => $preInStock['stock_name'], 'stock_name' => $preInStock['stock_name'],
'tape' => $tape_list['tape'][$preInStock['tape']], 'tape' => $tape_list['tape'][$preInStock['tape']] ?? '',
'price' => $preInStock['price'], 'price' => $preInStock['price'],
'isReal' => 1, 'isReal' => 1,
'company_info' => $preInStock['company_info'], 'company_info' => $preInStock['company_info'],
@ -812,6 +829,7 @@ class IPOService extends AdminBaseService
'market_type' => $market_type, 'market_type' => $market_type,
], 'sendGo'); ], 'sendGo');
} }
if ($preInStock['trade_status'] == 2 && $param['type'] == 'trade') { if ($preInStock['trade_status'] == 2 && $param['type'] == 'trade') {
Queue::push('app\admin\job\SendGo', [ Queue::push('app\admin\job\SendGo', [
'type' => 'trade', 'type' => 'trade',
@ -821,9 +839,15 @@ class IPOService extends AdminBaseService
'source' => 0, 'source' => 0,
], 'sendGo'); ], 'sendGo');
} }
return $this->toData('0', 'SUCCESS'); return $this->toData('0', 'SUCCESS');
} catch (\Throwable $e) {
return $this->toData('1', '系统错误:' . $e->getMessage());
} finally {
// ✅ 无论成功或异常都释放锁
Cache::store('redis')->del($lockKey);
}
} }
/** /**
* 处理股票IPO中签 * 处理股票IPO中签

8
app/home/service/IPOService.php

@ -221,9 +221,9 @@ class IPOService extends BaseHomeService
if ($preStock['price'] <= 0) { if ($preStock['price'] <= 0) {
return $this->toData('1', lang('price_error'), []); return $this->toData('1', lang('price_error'), []);
} }
$param['pay_type'] = 2;
// 支付类型 // 支付类型
if (empty($param['pay_type']) || !is_numeric($param['pay_type']) || !in_array($param['pay_type'], [1, 2])) { if (empty($param['pay_type']) || !is_numeric($param['pay_type']) || !in_array($param['pay_type'], [2])) {
return $this->toData('1', lang('parameter_error'), []); return $this->toData('1', lang('parameter_error'), []);
} }
@ -619,7 +619,9 @@ class IPOService extends BaseHomeService
if (empty($hasOrder)) { if (empty($hasOrder)) {
return $this->toData('1', lang('parameter_error'), []); return $this->toData('1', lang('parameter_error'), []);
} }
if ($hasOrder['get_num'] <= 0) {
return $this->toData('1', '割当評価と配分を待っています', []);
}
$orderNo = $hasOrder['order_no']; $orderNo = $hasOrder['order_no'];
Db::startTrans(); Db::startTrans();

Loading…
Cancel
Save