ServiceWorkMailLists.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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\adminapi\lists\works;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\goods_category\GoodsCategory;
  17. use app\common\model\master_worker\MasterWorker;
  18. use app\common\model\master_worker\MasterWorkerInfo;
  19. use app\common\model\master_worker_credential\MasterWorkerCredentialImages;
  20. use app\common\model\master_worker_register\MasterWorkerRegister;
  21. use app\common\model\property\PropertyOrder;
  22. use app\common\model\works\ServiceWork;
  23. use app\common\lists\ListsSearchInterface;
  24. use think\db\Query;
  25. use think\facade\Log;
  26. /**
  27. * 导出ServiceWork列表
  28. * Class ServiceWorkLists
  29. * @package app\adminapi\listsworks
  30. */
  31. class ServiceWorkMailLists extends BaseAdminDataLists implements ListsSearchInterface
  32. {
  33. /**
  34. * 设置搜索条件
  35. */
  36. public function setSearch(): array
  37. {
  38. return [
  39. '=' => ['id']
  40. ];
  41. }
  42. public function queryWhere(){
  43. $where = [];
  44. $time = [strtotime(date("Y-m-d")), strtotime(date("Y-m-d 22:59:59"))];
  45. $where[] = ['finished_time', 'between', $time];
  46. return $where;
  47. }
  48. /**
  49. * 获取列表
  50. */
  51. public function lists(): array
  52. {
  53. $lists = ServiceWork::with([
  54. 'worker'=>function(Query $query) {
  55. $query->field("id,worker_number,real_name,mobile");
  56. },
  57. 'goodsCategory' =>function (Query $query) {
  58. $query->field('id,name');
  59. }
  60. ])
  61. ->where($this->searchWhere)
  62. ->where($this->queryWhere())
  63. ->where('master_worker_id', '>', 0)
  64. ->field(['*'])
  65. ->append(['category_type_text'])
  66. ->order(['id' => 'desc'])
  67. ->select()
  68. ->toArray();
  69. $serialNumber = 1;
  70. array_walk($lists, function(&$item) use (&$serialNumber) {
  71. $item['serial_number'] = $serialNumber++;
  72. });
  73. return $lists;
  74. }
  75. /**
  76. * @notes 获取数量
  77. * @return int
  78. * @author likeadmin
  79. * @date 2024/07/10 15:06
  80. */
  81. public function count(): int
  82. {
  83. return 0;
  84. }
  85. public function setFileName(): string
  86. {
  87. return date('Ymd');
  88. }
  89. public function setExcelComplexFields(): array
  90. {
  91. $zh_cn_fields = [
  92. '序号','工单编号', '服务类别','维修家电类型','领单时间','预约上门时间','结单时间',
  93. '工程师','工程师身份证号','工程师手机号','资格证书号','获证日期','客户信息','客户手机号','客户地址'
  94. ];
  95. $data_fields = [
  96. 'serial_number','work_sn','category_type_text',function ($row) { return isset($row['goodsCategory']['name'])?$row['goodsCategory']['name']:''; },function ($row) { return $row['receive_time']?:''; },function ($row) { return isset($row['finally_door_time'])?date('Y-m-d H:i:s',$row['finally_door_time']):''; },function ($row) { return $row['finished_time']?:''; },
  97. function ($row) { return isset($row['worker']['real_name'])?$row['worker']['real_name']:''; },
  98. function ($row) { return isset($row['worker']['id'])?MasterWorkerInfo::where(['worker_id'=>$row['worker']['id']])->value('id_card'):''; },
  99. function ($row) { return isset($row['worker']['mobile'])?$row['worker']['mobile']:''; },
  100. function ($row) {
  101. if(isset($row['worker']['id'])){
  102. $worker_register_id = MasterWorkerRegister::where(['worker_id'=>$row['worker']['id']])->value('id')?:0;
  103. return MasterWorkerCredentialImages::where(['audit_state'=>1, 'worker_register_id'=>$worker_register_id])->value('number')?:'';
  104. }else{
  105. return '';
  106. }
  107. },
  108. function ($row) {
  109. if(isset($row['worker']['id'])){
  110. $worker_register_id = MasterWorkerRegister::where(['worker_id'=>$row['worker']['id']])->value('id')?:0;
  111. return MasterWorkerCredentialImages::where(['audit_state'=>1, 'worker_register_id'=>$worker_register_id])->value('start_time')?:'';
  112. }else{
  113. return '';
  114. }
  115. },
  116. 'real_name','mobile','address'
  117. ];
  118. return [
  119. 'zh_cn_fields' => $zh_cn_fields,
  120. 'data_fields' => $data_fields
  121. ];
  122. }
  123. }