sth
This commit is contained in:
parent
b00990ebe9
commit
e5df57d162
|
|
@ -3,10 +3,12 @@
|
||||||
namespace app\admin\controller\orders;
|
namespace app\admin\controller\orders;
|
||||||
|
|
||||||
use app\admin\model\Order;
|
use app\admin\model\Order;
|
||||||
|
use app\admin\model\OrderDispatch;
|
||||||
use app\common\controller\Backend;
|
use app\common\controller\Backend;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\db\exception\DataNotFoundException;
|
use think\db\exception\DataNotFoundException;
|
||||||
use think\db\exception\ModelNotFoundException;
|
use think\db\exception\ModelNotFoundException;
|
||||||
|
use think\Exception;
|
||||||
use think\exception\DbException;
|
use think\exception\DbException;
|
||||||
use think\exception\PDOException;
|
use think\exception\PDOException;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
|
|
@ -196,23 +198,31 @@ class Dispatch extends Backend
|
||||||
if (is_array($adminIds)) {
|
if (is_array($adminIds)) {
|
||||||
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
||||||
}
|
}
|
||||||
$list = $this->model->where($pk, 'in', $ids)->select();
|
$list = $this->model->where($pk, 'in', $ids)->whereIn('status',$this->model->deleteStatusList())->select();
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
$count += $item->delete();
|
//$count += $item->delete();
|
||||||
|
$order = Order::where('id',$item->order_id)->where('status',Order::STATUS_DISPATCHED)->find();
|
||||||
|
if(!$order){
|
||||||
|
$this->error('订单状态已变更,请刷新后操作');
|
||||||
|
}
|
||||||
|
//取消
|
||||||
|
$item->update(['status'=>OrderDispatch::STATUS_CANCEL]);
|
||||||
|
//回退订单状态
|
||||||
|
$order->update(['status'=>Order::STATUS_DISPATCHING]);
|
||||||
}
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (PDOException|Exception $e) {
|
} catch (PDOException|Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
$this->error($e->getMessage());
|
$this->error($e->getMessage());
|
||||||
}
|
}
|
||||||
if ($count) {
|
/* if ($count) {
|
||||||
$this->success();
|
$this->success();
|
||||||
}
|
}*/
|
||||||
$this->error(__('No rows were deleted'));
|
$this->error(__('取消成功'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class Order extends Model
|
||||||
const STATUS_DRAFT = 0; //草稿
|
const STATUS_DRAFT = 0; //草稿
|
||||||
const STATUS_DISPATCHING = 10; //待派单
|
const STATUS_DISPATCHING = 10; //待派单
|
||||||
const STATUS_DISPATCHED = 20; //已派单
|
const STATUS_DISPATCHED = 20; //已派单
|
||||||
const STATUS_ING = 30; //进行中
|
//const STATUS_ING = 30; //进行中
|
||||||
const STATUS_CHECKING = 40; //待派单
|
const STATUS_CHECKING = 40; //待派单
|
||||||
const STATUS_AUDITING = 50; //审核中
|
const STATUS_AUDITING = 50; //审核中
|
||||||
const STATUS_FINISHED = 60; //已完成
|
const STATUS_FINISHED = 60; //已完成
|
||||||
|
|
@ -55,7 +55,9 @@ class Order extends Model
|
||||||
|
|
||||||
public function getStatusList()
|
public function getStatusList()
|
||||||
{
|
{
|
||||||
return ['0' => __('Status 0'),'10' => __('Status 10'), '20' => __('Status 20'), '30' => __('Status 30'), '40' => __('Status 40'), '50' => __('Status 50'), '60' => __('Status 60'), '-10' => __('Status -10')];
|
return ['0' => __('Status 0'),'10' => __('Status 10'), '20' => __('Status 20'),
|
||||||
|
//'30' => __('Status 30'),
|
||||||
|
'40' => __('Status 40'), '50' => __('Status 50'), '60' => __('Status 60'), '-10' => __('Status -10')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -113,7 +115,7 @@ class Order extends Model
|
||||||
], //派单管理状态
|
], //派单管理状态
|
||||||
self::TAB_PENDING => [
|
self::TAB_PENDING => [
|
||||||
self::STATUS_DISPATCHED,
|
self::STATUS_DISPATCHED,
|
||||||
self::STATUS_ING,
|
//self::STATUS_ING,
|
||||||
self::STATUS_CHECKING,
|
self::STATUS_CHECKING,
|
||||||
], //订单跟进状态
|
], //订单跟进状态
|
||||||
self::TAB_AUDIT => [
|
self::TAB_AUDIT => [
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,22 @@ class OrderDispatch extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function deleteStatusList(){
|
||||||
|
return [
|
||||||
|
self::STATUS_TOGET,
|
||||||
|
self::STATUS_GOTIT,
|
||||||
|
self::STATUS_PLANIT,
|
||||||
|
self::STATUS_CLOCK,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkDelete($status){
|
||||||
|
|
||||||
|
if(in_array($status,$this->deleteStatusList())){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function order()
|
public function order()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user