修复号码数量列的数据统计方式
This commit is contained in:
@@ -7,6 +7,7 @@ namespace app\admin\controller\split;
|
||||
use app\admin\model\split\Link as LinkModel;
|
||||
use app\admin\model\split\Number as NumberModel;
|
||||
use app\common\controller\Backend;
|
||||
use app\common\service\SplitTicketActiveNumberCountService;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\exception\DbException;
|
||||
@@ -225,6 +226,7 @@ class Number extends Backend
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($count > 0) {
|
||||
(new SplitTicketActiveNumberCountService())->refreshForNumberIds(explode(',', (string) $ids));
|
||||
$this->success();
|
||||
}
|
||||
$this->error(__('No rows were updated'));
|
||||
@@ -331,6 +333,12 @@ class Number extends Backend
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
|
||||
(new SplitTicketActiveNumberCountService())->refreshForTicketKeys(
|
||||
(int) ($baseRow['admin_id'] ?? $adminId),
|
||||
$splitLinkId,
|
||||
(string) ($baseRow['ticket_name'] ?? '')
|
||||
);
|
||||
|
||||
$msg = __('Inserted %d number(s)', $inserted);
|
||||
if ($skipped > 0) {
|
||||
$msg .= ',' . __('Skipped %d duplicate(s)', $skipped);
|
||||
@@ -378,6 +386,7 @@ class Number extends Backend
|
||||
}
|
||||
|
||||
$result = false;
|
||||
$before = $row->getData();
|
||||
Db::startTrans();
|
||||
try {
|
||||
if ($this->modelValidate) {
|
||||
@@ -397,9 +406,50 @@ class Number extends Backend
|
||||
if ($result === false) {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
(new SplitTicketActiveNumberCountService())->refreshAfterNumberEdit($before, $row->getData());
|
||||
$this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除号码后回写工单本地开启号码数
|
||||
*
|
||||
* @param string|null $ids
|
||||
*/
|
||||
public function del($ids = null)
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
$ids = $ids ?: $this->request->post('ids');
|
||||
if (empty($ids)) {
|
||||
$this->error(__('Parameter %s can not be empty', 'ids'));
|
||||
}
|
||||
$pk = $this->model->getPk();
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
||||
}
|
||||
$list = $this->model->where($pk, 'in', $ids)->select();
|
||||
|
||||
$count = 0;
|
||||
$countService = new SplitTicketActiveNumberCountService();
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($list as $item) {
|
||||
$count += $item->delete();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (PDOException|Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($count) {
|
||||
$countService->refreshFromNumberRows($list);
|
||||
$this->success();
|
||||
}
|
||||
$this->error(__('No rows were deleted'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新号码状态与手动管理
|
||||
*/
|
||||
@@ -444,6 +494,7 @@ class Number extends Backend
|
||||
if ($count === false || $count === 0) {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
(new SplitTicketActiveNumberCountService())->refreshForNumberIds($ids);
|
||||
$this->success(__('Batch update success'));
|
||||
}
|
||||
|
||||
@@ -496,6 +547,8 @@ class Number extends Backend
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$countService = new SplitTicketActiveNumberCountService();
|
||||
$keyRows = (clone $query)->field('admin_id,split_link_id,ticket_name')->select();
|
||||
Db::startTrans();
|
||||
try {
|
||||
if ($action === 'delete') {
|
||||
@@ -523,6 +576,7 @@ class Number extends Backend
|
||||
$this->error(__('No matching numbers found'));
|
||||
}
|
||||
|
||||
$countService->refreshFromNumberRows($keyRows);
|
||||
$this->success(sprintf(__('Batch operate success'), $count));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user