CustomerService.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Service;
  3. use App\Model\Customer;
  4. class CustomerService extends Service
  5. {
  6. public function customerEdit($data,$user){
  7. list($status,$msg) = $this->customerRule($data,false);
  8. if(!$status) return [$status,$msg];
  9. return [true,''];
  10. }
  11. public function customerAdd($data,$user){
  12. list($status,$msg) = $this->customerRule($data);
  13. if(!$status) return [$status,$msg];
  14. return [true,''];
  15. }
  16. public function customerDel($data){
  17. if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
  18. Customer::whereIn('id',$data['id'])->update([
  19. 'del_time'=>time()
  20. ]);
  21. return [true,''];
  22. }
  23. public function customerDetail($data){
  24. if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
  25. return [true,''];
  26. }
  27. public function customerList($data){
  28. $model = Customer::where('del_time',0)
  29. ->select('title','id','type')
  30. ->orderby('id', 'asc')
  31. ->where('type',$data['type']);
  32. if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
  33. $list = $this->limit($model,'',$data);
  34. $list = $this->fillData($list);
  35. return [true, $list];
  36. }
  37. public function customerRule($data, $is_add = true){
  38. if($this->isEmpty($data,'type')) return [false,'客户模板类型不能为空'];
  39. return [true, $data];
  40. }
  41. public function fillData($data){
  42. if(empty($data['data'])) return $data;
  43. return $data;
  44. }
  45. }