|
@@ -0,0 +1,155 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\api\controller;
|
|
|
+
|
|
|
+use app\common\controller\Api;
|
|
|
+use think\Db;
|
|
|
+/**
|
|
|
+ * 保修
|
|
|
+ */
|
|
|
+class Maintain extends Api
|
|
|
+{
|
|
|
+ protected $noNeedLogin = ['*'];
|
|
|
+ protected $noNeedRight = ['*'];
|
|
|
+
|
|
|
+ public function addone()
|
|
|
+ {
|
|
|
+ $info = input('info','');
|
|
|
+ $filedata = input('filedata','','htmlspecialchars_decode');
|
|
|
+ $mobile = input('mobile','');
|
|
|
+ $address = input('address','');
|
|
|
+
|
|
|
+ //视频类型追加缩略图
|
|
|
+ $filedata = json_decode($filedata,true);
|
|
|
+ foreach($filedata as $key => $file){
|
|
|
+ if($file['type'] == 'video'){
|
|
|
+ $file_url = explode('.', $file['url']);
|
|
|
+ unset($file_url[count($file_url) - 1]);
|
|
|
+ $file['images_thumb'] = implode('.', $file_url) . '_0.jpg';
|
|
|
+ }else{
|
|
|
+ $file['images_thumb'] = $file['url'];
|
|
|
+ }
|
|
|
+ $filedata[$key] = $file;
|
|
|
+ }
|
|
|
+ $filedata = json_encode($filedata);
|
|
|
+
|
|
|
+ //写入
|
|
|
+ $data = [
|
|
|
+ 'orderno' => createUniqueNo('',''),
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'company_id' => $this->auth->company_id,
|
|
|
+ 'createtime' => time(),
|
|
|
+ 'updatetime' => time(),
|
|
|
+ 'info' => $info,
|
|
|
+ 'filedata' => $filedata,
|
|
|
+ 'mobile' => $mobile,
|
|
|
+ 'address' => $address,
|
|
|
+ 'status' => 0,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $order_id = Db::name('maintain')->insertGetId($data);
|
|
|
+ $this->success('保修成功请等待审核', $order_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function lists(){
|
|
|
+ $status = input('status',0); //默认待审核
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'status' => $status,
|
|
|
+ ];
|
|
|
+ $list = Db::name('maintain')->field('id,orderno,createtime,info,filedata,status')
|
|
|
+ ->where($map)->order('id desc')
|
|
|
+ ->autopage()->select();
|
|
|
+ if(!empty($list)){
|
|
|
+ $header_mobile = Db::name('user_company')->where('user_id',$this->auth->id)->value('header_mobile');//负责人的电话
|
|
|
+
|
|
|
+ foreach($list as $key => $val){
|
|
|
+ $list[$key]['header_mobile'] = $header_mobile;
|
|
|
+ $list[$key]['status_text'] = $this->status_data($val['status']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function info(){
|
|
|
+ $id = input('id',0);
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'id' => $id,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $info = Db::name('maintain')
|
|
|
+ ->where($map)
|
|
|
+ ->find();
|
|
|
+ $info['status_text'] = $this->status_data($info['status']);
|
|
|
+
|
|
|
+ $this->success(1, $info);
|
|
|
+ }
|
|
|
+
|
|
|
+ //报价单里列表
|
|
|
+ public function baojia_info(){
|
|
|
+ $order_id = input('order_id',0);
|
|
|
+ $lists = Db::name('maintain_baojia')
|
|
|
+ ->field('id,name,price,number,price_total')
|
|
|
+ ->where('order_id',$order_id)->order('id asc')->select();
|
|
|
+
|
|
|
+ $baojia_sum = Db::name('maintain')
|
|
|
+ ->where('id',$order_id)
|
|
|
+ ->value('baojia_sum');
|
|
|
+
|
|
|
+ $rs = [
|
|
|
+ 'list' => $lists,
|
|
|
+ 'baojia_sum' => $baojia_sum
|
|
|
+ ];
|
|
|
+
|
|
|
+ $this->success(1,$rs);
|
|
|
+ }
|
|
|
+
|
|
|
+ //取消上报
|
|
|
+ public function cancel(){
|
|
|
+ $id = input('id',0);
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'id' => $id,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $info = Db::name('maintain')
|
|
|
+ ->where($map)
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ if($info['status'] != 0){
|
|
|
+ $this->error('现在已经不能取消了');
|
|
|
+ }
|
|
|
+
|
|
|
+ $nowtime = time();
|
|
|
+ $update = [
|
|
|
+ 'status' => 3,
|
|
|
+ 'canceltime' => $nowtime,
|
|
|
+ 'finishtime' => $nowtime,
|
|
|
+ 'updatetime' => $nowtime,
|
|
|
+ ];
|
|
|
+ $rs = Db::name('maintain')
|
|
|
+ ->where($map)->update($update);
|
|
|
+
|
|
|
+ $this->success('取消成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ //状态枚举
|
|
|
+ private function status_data($status){
|
|
|
+ $data = [
|
|
|
+ 0 => '待审核',
|
|
|
+ 3 => '已取消',
|
|
|
+ 10 => '待报价',
|
|
|
+ 20 => '报价审核',
|
|
|
+ 30 => '待维修',
|
|
|
+ 40 => '已完成',
|
|
|
+ ];
|
|
|
+ return $data[$status];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|