Equipment.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace addons\qingdongams\controller;
  3. use addons\qingdongams\model\Equipment as EquipmentModel;
  4. /**
  5. * @desc 操作文档:https://doc.fastadmin.net/qingdongams
  6. * @desc 软件介绍:https://www.fastadmin.net/store/qingdongams.html
  7. * @desc 售后微信:qingdong_crm
  8. */
  9. /**
  10. * 产品设备
  11. */
  12. class Equipment extends StaffApi {
  13. protected $noNeedLogin = [];
  14. protected $noNeedRight = [];
  15. //获取设备详情
  16. public function getEquipDetail(){
  17. $code = input('code','');
  18. if(!$code){
  19. $this->error('缺少参数设备码!');
  20. }
  21. // 设备详情
  22. $product = EquipmentModel::where(['number'=>$code])->with(['product','customerProduct'=>['customer']])->find();
  23. if(empty($product)){
  24. $this->error('产品信息不存在');
  25. }
  26. $workLogistic = [];
  27. // 工单维修记录
  28. if(isset($product['customer_product']['cid'])){
  29. $cid = intval($product['customer_product']['cid']);
  30. $where="FIND_IN_SET($cid, w.customer_product_id)";
  31. $workLogistic = \addons\qingdongams\model\Workorder::alias('w')
  32. ->where($where)->join('qingdongams_workorder_logistics','l.workorder_id=w.id','left')->order('w.id asc')->select();
  33. }
  34. $data = [
  35. 'info' => $product,
  36. 'logic' => $workLogistic
  37. ];
  38. $this->success('请求成功',$data);
  39. }
  40. }