ServiceWorkSpare.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\common\model\works;
  15. use app\common\model\BaseModel;
  16. /**
  17. * ServiceWorkSpare模型
  18. * Class ServiceWorkSpare
  19. * @package app\common\model
  20. */
  21. class ServiceWorkSpare extends BaseModel
  22. {
  23. protected $name = 'service_work_spare';
  24. protected $type = [
  25. 'spare_parts' => 'array'
  26. ];
  27. public static function getLists($service_work_id, $type = null) {
  28. $where = [];
  29. //商城工单配件
  30. if ($type == 1) {
  31. $where[] = ['spare_part_id','>', 0];
  32. } else if ($type == 2) {
  33. //自选工单配件
  34. $where[] = ['spare_part_id','=', 0];
  35. }
  36. $lists = self::where('service_work_id', $service_work_id)
  37. ->where($where)
  38. ->field("id,spare_part_id, spare_name, spare_image, company_price, original_price, offering_price, spare_number,spare_unit,brand")
  39. ->select()
  40. ->toArray();
  41. return $lists;
  42. }
  43. }