Example #1
0
 /**
  * 获取税务信息
  * @return mixed
  * @param Request $request
  * @author AndyLee <*****@*****.**>
  */
 public function getTaxList(Request $request)
 {
     $company = Company::find($request->session()->get('customer_id'));
     $start = new \DateTime($company->created_at);
     $end = new DateTime();
     $interval = DateInterval::createFromDateString('1 month');
     $period = new DatePeriod($start, $interval, $end);
     $card = [];
     foreach ($period as $dt) {
         $map = ['user_id' => $request->session()->get('company_id'), 'company_id' => $request->session()->get('customer_id'), 'flag' => $dt->format("Ym")];
         $tax = Tax::where($map)->first();
         if (empty($tax)) {
             $record = new Tax();
             $record->user_id = $request->session()->get('company_id');
             $record->company_id = $request->session()->get('customer_id');
             $record->operator_id = Auth::user()->id;
             $record->card_name = $dt->format("Ym") . '税务申报单';
             $record->finish_time = strtotime($dt->format('Y-m') . '-15');
             $record->uuid = Uuid::uuid1();
             $record->guoshui_status = 0;
             $record->dishui_status = 0;
             $record->flag = $dt->format("Ym");
             $record->save();
             $card[] = $record->toArray();
         } else {
             $card[] = $tax->toArray();
         }
     }
     $card = array_reverse($card);
     return view('customer.tax.index')->with('cards', $card);
 }
 /**
  * 上传证件
  * @param Request $request
  * @return mixed
  * @author AndyLee <*****@*****.**>
  */
 public function postUploadCertificate(Request $request)
 {
     $input = $request->file('file');
     $param = $request->only('name', 'id');
     $rules = array('file' => 'image|max:3000');
     $validation = \Validator::make(['file' => $input], $rules);
     if ($validation->fails()) {
         return \Response::make($validation->errors->first(), 400);
     }
     $extension = $input->getClientOriginalExtension();
     /**
      * 获取公司信息
      */
     $customer = CustomerCompany::find(Session::get('customer_id'));
     /**
      * 设置存储目录
      * 存储目录结构 =  uploads / sha1加密的公司id /客户公司uuid
      */
     $directory = public_path('uploads') . '/' . sha1(Session::get('company_id')) . '/' . $customer->uuid;
     $filename = sha1(time() . time()) . ".{$extension}";
     $upload_success = $input->move($directory, $filename);
     $message = ['file_path' => asset('uploads/' . sha1(Session::get('company_id')) . '/' . $customer->uuid) . '/' . $filename];
     /**
      * 用户相关证件一键上传
      */
     if (!empty($param['name']) and !empty($param['id'])) {
         $param['company_id'] = Session::get('customer_id');
         try {
             $certificate = Certificate::where($param)->firstOrFail();
         } catch (ModelNotFoundException $e) {
             return \Response::json(['state' => 'denied'], 200);
         }
         $certificate->certificate_path = serialize([$message['file_path']]);
         $certificate->save();
     }
     if ($upload_success) {
         $message['status'] = 'success';
         return \Response::json($message, 200);
     } else {
         $message['status'] = 'error';
         return \Response::json($message, 400);
     }
 }
Example #3
0
 /**
  * 列出客户公司信息
  * @param integer $id
  * @return mixed
  * @author AndyLee <*****@*****.**>
  */
 public function getCustomerCompanyInfo($id)
 {
     //       dd( action('PartnerController@getPartner' , 12));
     $contact = Contact::where(['company_id' => Session::get('customer_id'), 'is_default' => 1])->first();
     $type = Config::get('customer.certificate');
     $result = [];
     /**
      * 查询不同的证件上传情况
      */
     foreach ($type as $k => $v) {
         $record = Certificate::where(['company_id' => Session::get('customer_id'), 'certificate_type' => $k])->first();
         if ($record) {
             $result[$k] = 'exist';
         } else {
             $result[$k] = 'empty';
         }
     }
     /**
      * 获取代办事项
      */
     $todo = App\Task::where(['company_id' => Session::get('customer_id'), 'is_finish' => 0])->take(10)->get();
     $company = Company::find(Session::get('customer_id'));
     return view('customer.index.detail')->with('contact', $contact)->with('result', $result)->with('todo', $todo)->with('company', $company);
 }