CustomerProduct.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. namespace app\admin\controller\qingdongams\customer;
  3. use app\admin\controller\qingdongams\Base;
  4. use addons\qingdongams\model\CustomerProduct as CustomerProductModel;
  5. /**
  6. * 客户产品
  7. * @icon fa fa-user
  8. */
  9. class CustomerProduct extends Base {
  10. protected $relationSearch = true;
  11. /**
  12. * @var \addons\qingdongams\model\CustomerProduct
  13. */
  14. protected $model = null;
  15. public function _initialize() {
  16. parent::_initialize();
  17. $this->model = new CustomerProductModel();
  18. }
  19. /**
  20. * 查看
  21. */
  22. public function index() {
  23. //设置过滤方法
  24. $this->request->filter(['strip_tags', 'trim']);
  25. if ($this->request->isAjax()) {
  26. //如果发送的来源是Selectpage,则转发到Selectpage
  27. if ($this->request->request('keyField')) {
  28. return $this->selectpage();
  29. }
  30. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  31. $list = $this->model->where($where)->with([
  32. 'customer',
  33. 'createStaff',
  34. 'product',
  35. 'contracts'
  36. ])->order($sort, $order)->paginate($limit);
  37. $result = array("total" => $list->total(), "rows" => $list->items());
  38. return json($result);
  39. }
  40. return $this->view->fetch();
  41. }
  42. /**获取附件记录
  43. */
  44. public function get_file($ids = null) {
  45. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  46. $list = \addons\qingdongams\model\ContractFile::where(['contract_id' => $ids])->with(['file'])->field('file_id')->paginate($limit);
  47. $result = array("total" => $list->total(), "rows" => $list->items());
  48. return json($result);
  49. }
  50. public function detail($ids = null) {
  51. $row = $this->model->where(['id' => $ids])->with([
  52. 'customer',
  53. 'product',
  54. 'contracts',
  55. 'equipment'
  56. ])->find();
  57. if(empty($row)){
  58. $this->error('参数不存在');
  59. }
  60. if(isset($row['equipment']) && isset($row['equipment']['logo'])){
  61. $row['equipment']['logo'] = cdnurl($row['equipment']['logo'],true);
  62. }
  63. //跟进记录
  64. $this->assign('row', $row);
  65. $this->assign('ids', $ids);
  66. return $this->view->fetch();
  67. }
  68. /**获取客户工单
  69. */
  70. public function get_workorder($ids = null) {
  71. $ids=intval($ids);
  72. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  73. $condition ="FIND_IN_SET($ids, customer_product_id)";
  74. $list = \addons\qingdongams\model\Workorder::where($condition)->paginate($limit);
  75. $result = array("total" => $list->total(), "rows" => $list->items());
  76. return json($result);
  77. }
  78. /**获取回款计划
  79. */
  80. public function get_receivables_plan($ids = null) {
  81. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  82. $list = \addons\qingdongams\model\ReceivablesPlan::where([
  83. 'contract_id' => $ids,
  84. ])->with(['customer'])->paginate($limit);
  85. $result = array("total" => $list->total(), "rows" => $list->items());
  86. return json($result);
  87. }
  88. /**获取回款记录
  89. */
  90. public function get_receivables($ids = null) {
  91. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  92. $list = \addons\qingdongams\model\Receivables::where([
  93. 'contract_id' => $ids,
  94. ])->with(['customer'])->paginate($limit);
  95. $result = array("total" => $list->total(), "rows" => $list->items());
  96. return json($result);
  97. }
  98. }