|
@@ -4,6 +4,7 @@ namespace app\admin\controller;
|
|
|
|
|
|
use app\common\controller\Backend;
|
|
|
use think\Db;
|
|
|
+use app\common\service\UserService;
|
|
|
/**
|
|
|
* 用户订单
|
|
|
*
|
|
@@ -141,20 +142,20 @@ class Order extends Backend
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
- $reason = input('reason','');
|
|
|
+ $reason = input('cancel_reason','');
|
|
|
|
|
|
- $info = Db::name('order')->where('id',$id)->where('company_id',$this->auth->company_id)->find();
|
|
|
+ $info = Db::name('order')->where('id',$id)->find();
|
|
|
if($info['status'] == 4){
|
|
|
$this->error('当前订单已经取消');
|
|
|
}
|
|
|
- if($info['status'] != 0 && $info['status'] != 2){
|
|
|
+ if($info['status'] != 2){
|
|
|
$this->error('当前订单状态不能取消');
|
|
|
}
|
|
|
if($info['ordertype'] == 3){
|
|
|
$this->error('套餐订单不能取消');
|
|
|
}
|
|
|
$time = time();
|
|
|
- //同步到预约单
|
|
|
+ //同步到预约单,这一步不该有
|
|
|
if (!empty($info['pre_order_id'])) {
|
|
|
$preOrderWhere['id'] = $info['pre_order_id'];
|
|
|
$preOrder = Db::name('pre_order')->where($preOrderWhere)->find();
|
|
@@ -185,20 +186,38 @@ class Order extends Backend
|
|
|
*/
|
|
|
public function finish(){
|
|
|
$id = input('id',0);
|
|
|
+ if(!$this->request->ispost()){
|
|
|
+ $this->assign('id',$id);
|
|
|
+ $info = Db::name('order')->where('id',$id)->find();
|
|
|
+ $this->assign('info',$info);
|
|
|
+ $this->assign('staff_id',$this->auth->staff_id);
|
|
|
+
|
|
|
+ //是否弹出保养
|
|
|
+ $baoyang_switch = Db::name('servicetype')->where('id',$info['servicetype_id'])->value('baoyang_switch');
|
|
|
+ $this->assign('baoyang_switch',$baoyang_switch);
|
|
|
+
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
|
|
|
Db::startTrans();
|
|
|
- $info = Db::name('order')->where('id',$id)->where('company_id',$this->auth->company_id)->lock(true)->find();
|
|
|
+ $info = Db::name('order')->where('id',$id)->lock(true)->find();
|
|
|
if($info['status'] != 2){
|
|
|
Db::rollback();
|
|
|
$this->error('当前订单不能完成');
|
|
|
}
|
|
|
|
|
|
+ //保养更新
|
|
|
+ $next_date = input('next_date','');
|
|
|
+ $next_carlicheng = input('next_carlicheng','');
|
|
|
+ $baoyang_data = [
|
|
|
+ 'next_date' => $next_date,
|
|
|
+ 'next_carlicheng' => $next_carlicheng,
|
|
|
+ ];
|
|
|
+
|
|
|
//完成
|
|
|
$time = time();
|
|
|
- $updateData = ['status'=>3,'finish_time'=>time(),'staff_id'=>$this->auth->id];
|
|
|
- if (empty($info['hexiao_time'])) {
|
|
|
- $updateData['hexiao_time'] = $time;
|
|
|
- }
|
|
|
+ $updateData = ['status'=>3,'finish_time'=>time(),'staff_id'=>$this->auth->staff_id];
|
|
|
+ $updateData = array_merge($updateData,$baoyang_data);
|
|
|
$rs = Db::name('order')->where('id',$id)->update($updateData);
|
|
|
if($rs === false){
|
|
|
Db::rollback();
|
|
@@ -219,10 +238,9 @@ class Order extends Backend
|
|
|
$userService = new UserService();
|
|
|
$params['order_id'] = $id;
|
|
|
$userService->msgOrder($params);
|
|
|
- //是否弹出保养
|
|
|
- $baoyang_switch = Db::name('servicetype')->where('id',$info['servicetype_id'])->value('baoyang_switch');
|
|
|
|
|
|
- $this->success('操作成功',$baoyang_switch);
|
|
|
+
|
|
|
+ $this->success('操作成功');
|
|
|
}
|
|
|
|
|
|
}
|