Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yhwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
李大见
yhwx
Commits
7cc197f1
提交
7cc197f1
authored
4月 29, 2026
作者:
窦斌
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
edit
上级
1ee9372b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
949 行增加
和
921 行删除
+949
-921
AdminService.php
app/Services/BasicManagement/AdminService.php
+949
-921
没有找到文件。
app/Services/BasicManagement/AdminService.php
浏览文件 @
7cc197f1
<?php
<?php
namespace
App\Services\BasicManagement
;
namespace
App\Services\BasicManagement
;
use
App\Services\CommonService
;
use
App\Http\Models\Services\PublicSearch
;
use
Illuminate\Database\Eloquent\Model
;
use
App\Services\CommonService
;
use
App\Models\BasicManagement\Admin
;
use
Illuminate\Database\Eloquent\Model
;
use
BlueCity\Core\Service\Service
;
use
App\Models\BasicManagement\Admin
;
use
Illuminate\Support\Facades\Cache
;
use
BlueCity\Core\Service\Service
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Cache
;
use
Illuminate\Support\Facades\Redis
;
use
Illuminate\Support\Facades\Log
;
use
App\Models\Common
;
use
Illuminate\Support\Facades\Redis
;
use
Illuminate\Support\Facades\DB
;
use
App\Models\Common
;
use
App\Http\Requests\Validators\BasicManagement\AdminValidator
;
use
Illuminate\Support\Facades\DB
;
use
BlueCity\Core\Inc\ErrorInc
;
use
App\Http\Requests\Validators\BasicManagement\AdminValidator
;
use
Pinyin
;
use
BlueCity\Core\Inc\ErrorInc
;
use
Pinyin
;
class
AdminService
extends
Service
{
class
AdminService
extends
Service
public
static
$instance
;
{
public
$modelMain
=
null
;
public
static
$instance
;
public
$mainValidator
=
null
;
public
$modelMain
=
null
;
public
$mainValidator
=
null
;
public
function
__construct
()
{
public
function
__construct
()
$this
->
modelMain
=
new
Admin
();
{
$this
->
mainValidator
=
new
AdminValidator
();
$this
->
modelMain
=
new
Admin
();
}
$this
->
mainValidator
=
new
AdminValidator
();
}
/**
* @return mixed
/**
*/
* @return mixed
public
static
function
getInstance
()
*/
{
public
static
function
getInstance
()
if
(
is_null
(
static
::
$instance
))
{
{
static
::
$instance
=
new
static
;
if
(
is_null
(
static
::
$instance
))
{
}
static
::
$instance
=
new
static
;
return
static
::
$instance
;
}
}
return
static
::
$instance
;
}
/**
* 根据条件搜索数据内容
/**
*
* 根据条件搜索数据内容
* @param array $param 条件
*
* @param array $columns 内容
* @param array $param 条件
* @param int $page 页码
* @param array $columns 内容
* @param int $pageSize 页容量
* @param int $page 页码
* @return mixed
* @param int $pageSize 页容量
*/
* @return mixed
public
function
searchPage
(
$user_info
,
$search_data
,
$show_count
=
10
)
*/
{
public
function
searchPage
(
$user_info
,
$search_data
,
$show_count
=
10
)
$list_data
=
DB
::
table
(
'wash_Admin_list as a'
)
{
->
leftJoin
(
'wash_Admin_client as b'
,
'a.reli_id'
,
'='
,
'b.recl_reli_id'
)
$list_data
=
DB
::
table
(
'wash_Admin_list as a'
)
->
where
(
'reli_cid'
,
$user_info
->
adm_cid
)
->
leftJoin
(
'wash_Admin_client as b'
,
'a.reli_id'
,
'='
,
'b.recl_reli_id'
)
->
where
(
'reli_shop_id'
,
$user_info
->
adm_shop_id
)
->
where
(
'reli_cid'
,
$user_info
->
adm_cid
)
->
where
(
'reli_state'
,
'<>'
,
2
)
//预约单状态:1待结单2已接单3取消订单4已撤回
->
where
(
'reli_shop_id'
,
$user_info
->
adm_shop_id
)
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//业务员搜索
->
where
(
'reli_state'
,
'<>'
,
2
)
//预约单状态:1待结单2已接单3取消订单4已撤回
if
(
!
empty
(
$search_data
[
'chun_adm_id'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//业务员搜索
$query
->
where
(
'chun_adm_id'
,
$search_data
[
'chun_adm_id'
])
if
(
!
empty
(
$search_data
[
'chun_adm_id'
]))
{
->
where
(
'reli_type'
,
2
);
$query
->
where
(
'chun_adm_id'
,
$search_data
[
'chun_adm_id'
])
}
->
where
(
'reli_type'
,
2
);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
})
if
(
!
empty
(
$search_data
[
'reli_number'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
$query
->
where
(
'reli_number'
,
'like'
,
'%'
.
$search_data
[
'reli_number'
]
.
'%'
);
if
(
!
empty
(
$search_data
[
'reli_number'
]))
{
}
$query
->
where
(
'reli_number'
,
'like'
,
'%'
.
$search_data
[
'reli_number'
]
.
'%'
);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
})
if
(
!
empty
(
$search_data
[
'recl_name'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
$query
->
where
(
'recl_name'
,
'like'
,
'%'
.
$search_data
[
'recl_name'
]
.
'%'
);
if
(
!
empty
(
$search_data
[
'recl_name'
]))
{
}
$query
->
where
(
'recl_name'
,
'like'
,
'%'
.
$search_data
[
'recl_name'
]
.
'%'
);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
})
if
(
!
empty
(
$search_data
[
'recl_phone'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
$query
->
where
(
'recl_phone'
,
'like'
,
'%'
.
$search_data
[
'recl_phone'
]
.
'%'
);
if
(
!
empty
(
$search_data
[
'recl_phone'
]))
{
}
$query
->
where
(
'recl_phone'
,
'like'
,
'%'
.
$search_data
[
'recl_phone'
]
.
'%'
);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
})
if
(
!
empty
(
$search_data
[
'recl_car_num'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
$query
->
where
(
'recl_car_num'
,
'like'
,
'%'
.
$search_data
[
'recl_car_num'
]
.
'%'
);
if
(
!
empty
(
$search_data
[
'recl_car_num'
]))
{
}
$query
->
where
(
'recl_car_num'
,
'like'
,
'%'
.
$search_data
[
'recl_car_num'
]
.
'%'
);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//车型
})
if
(
!
empty
(
$search_data
[
'recl_car_vehicle_type'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//车型
$query
->
where
(
'recl_car_vehicle_type'
,
'like'
,
'%'
.
$search_data
[
'recl_car_vehicle_type'
]
.
'%'
);
if
(
!
empty
(
$search_data
[
'recl_car_vehicle_type'
]))
{
}
$query
->
where
(
'recl_car_vehicle_type'
,
'like'
,
'%'
.
$search_data
[
'recl_car_vehicle_type'
]
.
'%'
);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//买家类型:1会员零售2客户单位3速电派单4第三方派单5运营中心给门店派单
})
if
(
!
empty
(
$search_data
[
'reli_type'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//买家类型:1会员零售2客户单位3速电派单4第三方派单5运营中心给门店派单
$query
->
where
(
'reli_type'
,
$search_data
[
'reli_type'
]);
if
(
!
empty
(
$search_data
[
'reli_type'
]))
{
}
$query
->
where
(
'reli_type'
,
$search_data
[
'reli_type'
]);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
})
if
(
!
empty
(
$search_data
[
'reli_service_type'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
$query
->
where
(
'reli_service_type'
,
$search_data
[
'reli_service_type'
]);
if
(
!
empty
(
$search_data
[
'reli_service_type'
]))
{
}
$query
->
where
(
'reli_service_type'
,
$search_data
[
'reli_service_type'
]);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
})
if
(
!
empty
(
$search_data
[
'reli_create_id'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
$query
->
where
(
'reli_create_id'
,
$search_data
[
'reli_create_id'
]);
if
(
!
empty
(
$search_data
[
'reli_create_id'
]))
{
}
$query
->
where
(
'reli_create_id'
,
$search_data
[
'reli_create_id'
]);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
})
if
(
!
empty
(
$search_data
[
'reli_state'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
$query
->
where
(
'reli_state'
,
$search_data
[
'reli_state'
]);
if
(
!
empty
(
$search_data
[
'reli_state'
]))
{
}
$query
->
where
(
'reli_state'
,
$search_data
[
'reli_state'
]);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//备注
})
if
(
!
empty
(
$search_data
[
'reli_remark'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//备注
$query
->
where
(
'reli_remark'
,
'like'
,
'%'
.
$search_data
[
'reli_remark'
]
.
'%'
);
if
(
!
empty
(
$search_data
[
'reli_remark'
]))
{
}
$query
->
where
(
'reli_remark'
,
'like'
,
'%'
.
$search_data
[
'reli_remark'
]
.
'%'
);
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//创建时间
})
// 如果选择开始时间并且选择结束时间
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//创建时间
if
(
!
empty
(
$search_data
[
'create_time_start'
])
&&
!
empty
(
$search_data
[
'create_time_end'
]))
{
// 如果选择开始时间并且选择结束时间
$query
->
whereBetween
(
'reli_create_time'
,
[
$search_data
[
'create_time_start'
],
$search_data
[
'create_time_end'
]
.
' 23:59:59'
]);
if
(
!
empty
(
$search_data
[
'create_time_start'
])
&&
!
empty
(
$search_data
[
'create_time_end'
]))
{
}
else
{
$query
->
whereBetween
(
'reli_create_time'
,
[
$search_data
[
'create_time_start'
],
$search_data
[
'create_time_end'
]
.
' 23:59:59'
]);
// 如果选择开始时间
}
else
{
if
(
!
empty
(
$search_data
[
'create_time_start'
]))
{
// 如果选择开始时间
$query
->
where
(
'reli_create_time'
,
'>='
,
$search_data
[
'create_time_start'
]);
if
(
!
empty
(
$search_data
[
'create_time_start'
]))
{
}
else
{
$query
->
where
(
'reli_create_time'
,
'>='
,
$search_data
[
'create_time_start'
]);
// 如果选择结束时间
}
else
{
if
(
!
empty
(
$search_data
[
'create_time_end'
]))
{
// 如果选择结束时间
$query
->
where
(
'reli_create_time'
,
'<='
,
$search_data
[
'create_time_end'
]
.
' 23:59:59'
);
if
(
!
empty
(
$search_data
[
'create_time_end'
]))
{
}
$query
->
where
(
'reli_create_time'
,
'<='
,
$search_data
[
'create_time_end'
]
.
' 23:59:59'
);
}
}
}
}
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
})
if
(
!
empty
(
$search_data
[
'reli_client_id'
]))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
$query
->
where
(
'reli_client_id'
,
$search_data
[
'reli_client_id'
]);
if
(
!
empty
(
$search_data
[
'reli_client_id'
]))
{
}
$query
->
where
(
'reli_client_id'
,
$search_data
[
'reli_client_id'
]);
})
}
->
select
(
'reli_id'
,
'reli_create_id'
,
'reli_order_number'
,
'reli_number'
,
'reli_actual_price'
,
'reli_client_type'
,
'reli_state'
,
'reli_appoint_time'
,
'reli_appoint_remark'
,
'reli_remark'
,
'reli_order_price'
,
'reli_client_id'
,
'recl_channel_unit'
,
'recl_name'
,
'recl_phone'
,
'recl_car_num'
,
'recl_province'
,
'recl_city'
,
'recl_county'
,
'recl_address'
,
'recl_car_vehicle_type'
,
'recl_car_vin'
,
'recl_car_brand_series'
)
})
->
orderBy
(
'reli_id'
,
'desc'
)
->
select
(
'reli_id'
,
'reli_create_id'
,
'reli_order_number'
,
'reli_number'
,
'reli_actual_price'
,
'reli_client_type'
,
'reli_state'
,
'reli_appoint_time'
,
'reli_appoint_remark'
,
'reli_remark'
,
'reli_order_price'
,
'reli_client_id'
,
'recl_channel_unit'
,
'recl_name'
,
'recl_phone'
,
'recl_car_num'
,
'recl_province'
,
'recl_city'
,
'recl_county'
,
'recl_address'
,
'recl_car_vehicle_type'
,
'recl_car_vin'
,
'recl_car_brand_series'
)
->
paginate
(
$show_count
);
->
orderBy
(
'reli_id'
,
'desc'
)
$list_items
=
$list_data
->
items
();
->
paginate
(
$show_count
);
$list_items
=
$list_data
->
items
();
if
(
$list_items
)
{
$reli_id
=
array_column
(
$list_items
,
'reli_id'
);
//预约单id
if
(
$list_items
)
{
$reli_id
=
array_column
(
$list_items
,
'reli_id'
);
//预约单id
// 查询商品、项目信息
$order_goods
=
DB
::
table
(
'wash_Admin_items'
)
// 查询商品、项目信息
->
whereIn
(
'reit_reli_id'
,
$reli_id
)
$order_goods
=
DB
::
table
(
'wash_Admin_items'
)
->
select
(
'reit_id'
,
'reit_reli_id'
,
'reit_sepr_id'
,
'reit_goo_name'
,
'reit_goo_goods_encode'
,
'reit_sepr_id'
,
'reit_sepr_name'
,
'reit_part_state'
)
->
whereIn
(
'reit_reli_id'
,
$reli_id
)
->
get
()
->
toArray
();
->
select
(
'reit_id'
,
'reit_reli_id'
,
'reit_sepr_id'
,
'reit_goo_name'
,
'reit_goo_goods_encode'
,
'reit_sepr_id'
,
'reit_sepr_name'
,
'reit_part_state'
)
->
get
()
->
toArray
();
// 账号id
$adm_id
=
array_column
(
$list_items
,
'reli_create_id'
);
//id
// 账号id
$adm_id
=
array_filter
(
array_unique
(
$adm_id
));
$adm_id
=
array_column
(
$list_items
,
'reli_create_id'
);
//id
// 查询账号id对应姓名
$adm_id
=
array_filter
(
array_unique
(
$adm_id
));
$adm_name
=
DB
::
table
(
'admin'
)
// 查询账号id对应姓名
->
whereIn
(
'adm_id'
,
$adm_id
)
$adm_name
=
DB
::
table
(
'admin'
)
->
pluck
(
'adm_name'
,
'adm_id'
)
->
whereIn
(
'adm_id'
,
$adm_id
)
->
toArray
();
->
pluck
(
'adm_name'
,
'adm_id'
)
foreach
(
$list_items
as
$key
=>
$value
)
{
->
toArray
();
// 创建人
foreach
(
$list_items
as
$key
=>
$value
)
{
if
(
$value
->
reli_create_id
)
{
// 创建人
$list_items
[
$key
]
->
create_name
=
$adm_name
[
$value
->
reli_create_id
];
if
(
$value
->
reli_create_id
)
{
}
else
{
$list_items
[
$key
]
->
create_name
=
$adm_name
[
$value
->
reli_create_id
];
$list_items
[
$key
]
->
create_name
=
''
;
}
else
{
}
$list_items
[
$key
]
->
create_name
=
''
;
}
}
}
// 查询备注信息
$order_reamrks
=
DB
::
table
(
'wash_order_remarks'
)
// 查询备注信息
->
whereIn
(
'orre_primary_id'
,
$reli_id
)
$order_reamrks
=
DB
::
table
(
'wash_order_remarks'
)
->
where
(
'orre_type'
,
1
)
->
whereIn
(
'orre_primary_id'
,
$reli_id
)
->
select
(
'orre_create_adm_name'
,
'orre_content'
,
'orre_time'
,
'orre_primary_id'
,
'orre_module'
)
->
where
(
'orre_type'
,
1
)
->
orderby
(
'orre_id'
,
'desc'
)
->
select
(
'orre_create_adm_name'
,
'orre_content'
,
'orre_time'
,
'orre_primary_id'
,
'orre_module'
)
->
get
();
->
orderby
(
'orre_id'
,
'desc'
)
->
get
();
// 查找操作记录
$order_log
=
DB
::
table
(
'wash_order_log'
)
// 查找操作记录
->
whereIn
(
'orre_primary_id'
,
$reli_id
)
$order_log
=
DB
::
table
(
'wash_order_log'
)
->
where
(
'orre_type'
,
1
)
->
whereIn
(
'orre_primary_id'
,
$reli_id
)
->
orderBy
(
'orlo_id'
,
'desc'
)
->
where
(
'orre_type'
,
1
)
->
select
(
'orre_primary_id'
,
'orlo_time'
,
'orlo_create_adm_name'
,
'orlo_content'
)
->
orderBy
(
'orlo_id'
,
'desc'
)
->
get
();
->
select
(
'orre_primary_id'
,
'orlo_time'
,
'orlo_create_adm_name'
,
'orlo_content'
)
}
else
{
->
get
();
$order_goods
=
[];
}
else
{
$order_log
=
[];
$order_goods
=
[];
$order_reamrks
=
[];
$order_log
=
[];
}
$order_reamrks
=
[];
// 查询预约单状态对应的预约单数量
}
$state_count
=
DB
::
table
(
'wash_Admin_list'
)
// 查询预约单状态对应的预约单数量
->
where
(
'reli_cid'
,
$user_info
->
adm_cid
)
$state_count
=
DB
::
table
(
'wash_Admin_list'
)
->
where
(
'reli_shop_id'
,
$user_info
->
adm_shop_id
)
->
where
(
'reli_cid'
,
$user_info
->
adm_cid
)
->
where
(
'reli_state'
,
'<>'
,
1
)
->
where
(
'reli_shop_id'
,
$user_info
->
adm_shop_id
)
->
select
(
DB
::
raw
(
'count(*) as count, reli_state'
))
->
where
(
'reli_state'
,
'<>'
,
1
)
->
groupBy
(
'reli_state'
)
->
select
(
DB
::
raw
(
'count(*) as count, reli_state'
))
->
get
();
->
groupBy
(
'reli_state'
)
$data
[
'current_page'
]
=
$list_data
->
currentPage
();
//当前页面页码
->
get
();
$data
[
'last_page'
]
=
$list_data
->
lastPage
();
//表示最后一页的页码
$data
[
'current_page'
]
=
$list_data
->
currentPage
();
//当前页面页码
$data
[
'total'
]
=
$list_data
->
total
();
//总数据个数
$data
[
'last_page'
]
=
$list_data
->
lastPage
();
//表示最后一页的页码
$data
[
'current_number'
]
=
$show_count
;
//一页显示多少个
$data
[
'total'
]
=
$list_data
->
total
();
//总数据个数
$data
[
'data'
]
=
$list_items
;
//返回数据
$data
[
'current_number'
]
=
$show_count
;
//一页显示多少个
$data
[
'order_goods'
]
=
$order_goods
;
//预约单商品数据
$data
[
'data'
]
=
$list_items
;
//返回数据
$data
[
'state_count'
]
=
$state_count
;
$data
[
'order_goods'
]
=
$order_goods
;
//预约单商品数据
$data
[
'order_log'
]
=
$order_log
;
//操作记录
$data
[
'state_count'
]
=
$state_count
;
$data
[
'order_reamrks'
]
=
$order_reamrks
;
//预约单备注
$data
[
'order_log'
]
=
$order_log
;
//操作记录
$data
[
'now_time'
]
=
date
(
'Y-m-d H:i:s'
);
//当前时间
$data
[
'order_reamrks'
]
=
$order_reamrks
;
//预约单备注
return
$data
;
$data
[
'now_time'
]
=
date
(
'Y-m-d H:i:s'
);
//当前时间
}
return
$data
;
}
// 个人中心
public
static
function
personal
(
$user_info
,
$request
)
// 个人中心
{
public
static
function
personal
(
$user_info
,
$request
)
$info
=
DB
::
table
(
'admin as a'
)
{
->
leftjoin
(
'admin_set as adms'
,
'adms.adms_adm_id'
,
'='
,
'a.adm_id'
)
$info
=
DB
::
table
(
'admin as a'
)
->
where
(
'a.adm_id'
,
$user_info
->
adm_id
)
->
leftjoin
(
'admin_set as adms'
,
'adms.adms_adm_id'
,
'='
,
'a.adm_id'
)
->
where
(
'adms_shop_id'
,
$user_info
->
adm_shop_id
)
->
where
(
'a.adm_id'
,
$user_info
->
adm_id
)
->
first
([
'a.adm_account'
,
'a.adm_name'
,
'a.adm_phone'
,
'adms_province'
,
'adms_city'
,
'adms_county'
,
'adms_address'
]);
->
where
(
'adms_shop_id'
,
$user_info
->
adm_shop_id
)
if
(
!
$info
)
{
->
first
([
'a.adm_account'
,
'a.adm_name'
,
'a.adm_phone'
,
'adms_province'
,
'adms_city'
,
'adms_county'
,
'adms_address'
]);
$info
=
DB
::
table
(
'admin as a'
)
if
(
!
$info
)
{
->
leftjoin
(
'admin_set as adms'
,
'adms.adms_adm_id'
,
'='
,
'a.adm_id'
)
$info
=
DB
::
table
(
'admin as a'
)
->
where
(
'a.adm_id'
,
$user_info
->
adm_id
)
->
leftjoin
(
'admin_set as adms'
,
'adms.adms_adm_id'
,
'='
,
'a.adm_id'
)
->
first
([
'a.adm_account'
,
'a.adm_name'
,
'a.adm_phone'
,
'adms_province'
,
'adms_city'
,
'adms_county'
,
'adms_address'
]);
->
where
(
'a.adm_id'
,
$user_info
->
adm_id
)
}
->
first
([
'a.adm_account'
,
'a.adm_name'
,
'a.adm_phone'
,
'adms_province'
,
'adms_city'
,
'adms_county'
,
'adms_address'
]);
if
(
$info
)
{
}
$info
->
adm_name
=
$info
->
adm_name
??
''
;
if
(
$info
)
{
$info
->
adm_phone
=
$info
->
adm_phone
??
''
;
$info
->
adm_name
=
$info
->
adm_name
??
''
;
$info
->
adms_address
=
$info
->
adms_address
??
''
;
$info
->
adm_phone
=
$info
->
adm_phone
??
''
;
$data
[
'info'
]
=
$info
;
$info
->
adms_address
=
$info
->
adms_address
??
''
;
$data
[
'info'
]
=
$info
;
// 查询当前年月的技师的单量和绩效金额
$now_year_month
=
date
(
'Y-m'
);
// 查询当前年月的技师的单量和绩效金额
$find_data
=
DB
::
table
(
'wash_performance_work'
)
$now_year_month
=
date
(
'Y-m'
);
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
$find_data
=
DB
::
table
(
'wash_performance_work'
)
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
->
where
(
'pewo_create_time'
,
'like'
,
$now_year_month
.
'%'
)
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
->
select
(
DB
::
raw
(
'count(*) as count,sum(pewo_performance_total_price) as service_price'
))
->
where
(
'pewo_create_time'
,
'like'
,
$now_year_month
.
'%'
)
->
first
();
->
select
(
DB
::
raw
(
'count(*) as count,sum(pewo_performance_total_price) as service_price'
))
$punishment_count1
=
DB
::
table
(
'violation_ticket_detail'
)
->
first
();
->
leftJoin
(
'violation_ticket'
,
'viti_id'
,
'='
,
'vtde_viti_id'
)
$punishment_count1
=
DB
::
table
(
'violation_ticket_detail'
)
->
where
(
'vtde_adm_id'
,
$user_info
->
adm_id
)
->
leftJoin
(
'violation_ticket'
,
'viti_id'
,
'='
,
'vtde_viti_id'
)
->
where
(
'viti_bind_work'
,
1
)
->
where
(
'vtde_adm_id'
,
$user_info
->
adm_id
)
->
where
(
'viti_create_time'
,
'like'
,
$now_year_month
.
'%'
)
->
where
(
'viti_bind_work'
,
1
)
->
select
(
DB
::
raw
(
'sum(vtde_punish_money) as punishment_count1'
))
->
where
(
'viti_create_time'
,
'like'
,
$now_year_month
.
'%'
)
->
first
();
->
select
(
DB
::
raw
(
'sum(vtde_punish_money) as punishment_count1'
))
$punishment_count2
=
DB
::
table
(
'violation_ticket_detail'
)
->
first
();
->
leftJoin
(
'violation_ticket'
,
'viti_id'
,
'='
,
'vtde_viti_id'
)
$punishment_count2
=
DB
::
table
(
'violation_ticket_detail'
)
->
where
(
'vtde_adm_id'
,
$user_info
->
adm_id
)
->
leftJoin
(
'violation_ticket'
,
'viti_id'
,
'='
,
'vtde_viti_id'
)
->
where
(
'viti_state'
,
1
)
->
where
(
'vtde_adm_id'
,
$user_info
->
adm_id
)
->
where
(
'viti_bind_work'
,
2
)
->
where
(
'viti_state'
,
1
)
->
where
(
'viti_create_time'
,
'like'
,
$now_year_month
.
'%'
)
->
where
(
'viti_bind_work'
,
2
)
->
select
(
DB
::
raw
(
'sum(vtde_punish_money) as punishment_count2'
))
->
where
(
'viti_create_time'
,
'like'
,
$now_year_month
.
'%'
)
->
first
();
->
select
(
DB
::
raw
(
'sum(vtde_punish_money) as punishment_count2'
))
if
(
$find_data
->
service_price
)
{
->
first
();
$count_show
[
'service_price'
]
=
$find_data
->
service_price
/
100
;
//当月的服务绩效金额
if
(
$find_data
->
service_price
)
{
}
else
{
$count_show
[
'service_price'
]
=
$find_data
->
service_price
/
100
;
//当月的服务绩效金额
$count_show
[
'service_price'
]
=
0
;
//当月的服务绩效金额
}
else
{
}
$count_show
[
'service_price'
]
=
0
;
//当月的服务绩效金额
if
(
$punishment_count1
)
{
}
$punishment_count1_money
=
$punishment_count1
->
punishment_count1
;
if
(
$punishment_count1
)
{
$count_show
[
'service_price'
]
+=
$punishment_count1_money
/
100
;
$punishment_count1_money
=
$punishment_count1
->
punishment_count1
;
}
else
{
$count_show
[
'service_price'
]
+=
$punishment_count1_money
/
100
;
$punishment_count1_money
=
0
;
}
else
{
}
$punishment_count1_money
=
0
;
if
(
$punishment_count2
)
{
}
$punishment_count2_money
=
$punishment_count2
->
punishment_count2
;
if
(
$punishment_count2
)
{
}
else
{
$punishment_count2_money
=
$punishment_count2
->
punishment_count2
;
$punishment_count2_money
=
0
;
}
else
{
}
$punishment_count2_money
=
0
;
$punishment_count_money
=
$punishment_count1_money
+
$punishment_count2_money
;
}
$order_num
=
DB
::
table
(
'wash_performance_work'
)
$punishment_count_money
=
$punishment_count1_money
+
$punishment_count2_money
;
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
$order_num
=
DB
::
table
(
'wash_performance_work'
)
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
->
where
(
'pewo_create_time'
,
'like'
,
$now_year_month
.
'%'
)
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
->
groupBy
(
'pewo_wor_id'
)
->
where
(
'pewo_create_time'
,
'like'
,
$now_year_month
.
'%'
)
->
get
();
->
groupBy
(
'pewo_wor_id'
)
$count_show
[
'order_num'
]
=
count
(
$order_num
);
//当月完成的工单量
->
get
();
$count_show
[
'punishment_count_money'
]
=
$punishment_count_money
/
100
;
//当月完成的工单量
$count_show
[
'order_num'
]
=
count
(
$order_num
);
//当月完成的工单量
$data
[
'count_show'
]
=
$count_show
;
$count_show
[
'punishment_count_money'
]
=
$punishment_count_money
/
100
;
//当月完成的工单量
$data
[
'count_show'
]
=
$count_show
;
$data
[
'count_show'
]
=
$count_show
;
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
$data
[
'count_show'
]
=
$count_show
;
}
else
{
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
return
[
'code'
=>
500
,
'msg'
=>
'暂无数据'
,
'data'
=>
''
];
}
else
{
}
return
[
'code'
=>
500
,
'msg'
=>
'暂无数据'
,
'data'
=>
''
];
}
}
}
// 获取个人所有门店信息
public
static
function
getPersonalShops
(
$user_info
)
// 获取个人所有门店信息
{
public
static
function
getPersonalShops
(
$user_info
)
$list_data
=
DB
::
table
(
'admin_shop_role as asr'
)
{
->
leftJoin
(
'shop'
,
'shop.shop_id'
,
'='
,
'asr.shop_id'
)
$list_data
=
DB
::
table
(
'admin_shop_role as asr'
)
->
leftjoin
(
'role'
,
'role.rol_id'
,
'='
,
'asr.role_id'
)
->
leftJoin
(
'shop'
,
'shop.shop_id'
,
'='
,
'asr.shop_id'
)
->
where
(
'asr.adm_id'
,
$user_info
->
adm_id
)
->
leftjoin
(
'role'
,
'role.rol_id'
,
'='
,
'asr.role_id'
)
->
where
(
'asr.adm_state'
,
1
)
->
where
(
'asr.adm_id'
,
$user_info
->
adm_id
)
->
where
(
'asr.create_source'
,
1
)
->
where
(
'asr.adm_state'
,
1
)
->
where
(
'role.rol_state'
,
1
)
->
where
(
'asr.create_source'
,
1
)
->
where
(
'shop.shop_state'
,
1
)
->
where
(
'role.rol_state'
,
1
)
->
select
(
'shop_store_name'
,
'asr.shop_id'
,
'asr.login_shop_wechat as login_shop'
)
->
where
(
'shop.shop_state'
,
1
)
->
orderBy
(
'asr.login_shop_wechat'
,
'asc'
)
->
select
(
'shop_store_name'
,
'asr.shop_id'
,
'asr.login_shop_wechat as login_shop'
)
->
get
();
->
orderBy
(
'asr.login_shop_wechat'
,
'asc'
)
if
(
!
empty
(
$list_data
))
{
->
get
();
$data
=
[
if
(
!
empty
(
$list_data
))
{
'info'
=>
$list_data
$data
=
[
];
'info'
=>
$list_data
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
];
}
else
{
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
return
[
'code'
=>
500
,
'msg'
=>
'暂无数据'
,
'data'
=>
[]];
}
else
{
}
return
[
'code'
=>
500
,
'msg'
=>
'暂无数据'
,
'data'
=>
[]];
}
}
}
// 个人中心
public
static
function
BusPersonal
(
$user_info
,
$request
)
// 个人中心
{
public
static
function
BusPersonal
(
$user_info
,
$request
)
$info
=
DB
::
table
(
'business_account as ba'
)
{
->
leftjoin
(
'business_client as bc'
,
'bc.bucl_id'
,
'='
,
'ba.buac_bucl_id'
)
$info
=
DB
::
table
(
'business_account as ba'
)
->
leftjoin
(
'shop as s'
,
's.shop_id'
,
'='
,
'ba.buac_shop_id'
)
->
leftjoin
(
'business_client as bc'
,
'bc.bucl_id'
,
'='
,
'ba.buac_bucl_id'
)
->
where
(
'buac_id'
,
$user_info
->
buac_id
)
->
leftjoin
(
'shop as s'
,
's.shop_id'
,
'='
,
'ba.buac_shop_id'
)
->
first
([
'bucl_name'
,
'buac_name'
,
'buac_phone'
,
'buac_id'
,
'shop_store_name'
]);
->
where
(
'buac_id'
,
$user_info
->
buac_id
)
if
(
$info
)
{
->
first
([
'bucl_name'
,
'buac_name'
,
'buac_phone'
,
'buac_id'
,
'shop_store_name'
]);
$data
[
'info'
]
=
$info
;
if
(
$info
)
{
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
$data
[
'info'
]
=
$info
;
}
else
{
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
return
[
'code'
=>
500
,
'msg'
=>
'暂无数据'
,
'data'
=>
''
];
}
else
{
}
return
[
'code'
=>
500
,
'msg'
=>
'暂无数据'
,
'data'
=>
''
];
}
}
}
// 工单统计
public
static
function
getOrderNumList
(
$user_info
,
$request
,
$show_count
=
10
)
// 工单统计
{
public
static
function
getOrderNumList
(
$user_info
,
$request
,
$show_count
=
10
)
$list_data
=
DB
::
table
(
'wash_performance_work'
)
{
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
$typecount
=
[];
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
if
(
!
isset
(
$request
[
'page'
])
||
$request
[
'page'
]
==
1
)
{
->
where
(
'pewo_create_time'
,
'like'
,
$request
[
'time'
]
.
'%'
)
$results
=
DB
::
table
(
'wash_performance_work'
)
->
select
(
'pewo_create_time'
,
'pewo_wor_number'
,
'pewo_wor_id'
,
'pewo_id'
,
'pewo_sepr_name'
,
'pewo_performance_total_price'
)
->
leftjoin
(
'work_order'
,
'work_order.wor_id'
,
'='
,
'wash_performance_work.pewo_wor_id'
)
->
orderby
(
'pewo_create_time'
,
'desc'
)
// ->where('pewo_shop_id', $user_info->adm_shop_id)
->
groupBy
(
'pewo_wor_id'
)
// ->where('pewo_service_adm_id', $user_info->adm_id)
->
paginate
(
$show_count
);
// ->where('pewo_create_time', 'like', $request['time']. '%')
$find_data
=
DB
::
table
(
'wash_performance_work'
)
->
select
(
'wor_service_standard'
,
DB
::
raw
(
'COUNT(DISTINCT pewo_wor_id) as count'
))
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
->
groupBy
(
'wor_service_standard'
)
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
->
get
()
->
where
(
'pewo_create_time'
,
'like'
,
$request
[
'time'
]
.
'%'
)
->
mapWithKeys
(
function
(
$item
)
{
->
select
(
DB
::
raw
(
'sum(pewo_performance_total_price) as service_price'
))
return
[
$item
->
wor_service_standard
=>
$item
->
count
];
->
first
();
})
if
(
$find_data
->
service_price
)
{
->
toArray
();
$count_show
[
'service_price'
]
=
$find_data
->
service_price
/
100
;
//当月的服务绩效金额
if
(
!
empty
(
$results
)){
}
else
{
$services
=
new
PublicSearch
();
$count_show
[
'service_price'
]
=
0
;
//当月的服务绩效金额
$serviceStandard
=
$services
->
getServiceStandard
(
true
);
}
$num
=
0
;
$order_num
=
DB
::
table
(
'wash_performance_work'
)
foreach
(
$results
as
$k
=>
$v
){
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
$typecount
[
$num
][
'name'
]
=
$serviceStandard
[
$k
];
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
$typecount
[
$num
][
'value'
]
=
$v
;
->
where
(
'pewo_create_time'
,
'like'
,
$request
[
'time'
]
.
'%'
)
$num
++
;
->
groupBy
(
'pewo_wor_id'
)
->
get
();
}
$count_show
[
'order_num'
]
=
count
(
$order_num
);
}
$data
[
'count_show'
]
=
$count_show
;
}
$list_items
=
$list_data
->
items
();
$list_data
=
DB
::
table
(
'wash_performance_work'
)
foreach
(
$list_items
as
$key
=>
$value
)
{
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
$list_items
[
$key
]
->
pewo_performance_total_price
=
DB
::
table
(
'wash_performance_work'
)
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
->
where
(
'pewo_create_time'
,
'like'
,
$request
[
'time'
]
.
'%'
)
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
->
select
(
'pewo_create_time'
,
'pewo_wor_number'
,
'pewo_wor_id'
,
'pewo_id'
,
'pewo_sepr_name'
,
'pewo_performance_total_price'
)
->
where
(
'pewo_create_time'
,
'like'
,
$request
[
'time'
]
.
'%'
)
->
orderby
(
'pewo_create_time'
,
'desc'
)
->
where
(
'pewo_wor_id'
,
$value
->
pewo_wor_id
)
->
groupBy
(
'pewo_wor_id'
)
->
sum
(
'pewo_performance_total_price'
);
->
paginate
(
$show_count
);
$list_items
[
$key
]
->
pewo_create_time
=
date
(
"Y-m-d"
,
strtotime
(
$value
->
pewo_create_time
));
$find_data
=
DB
::
table
(
'wash_performance_work'
)
}
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
$data
[
'current_page'
]
=
$list_data
->
currentPage
();
//当前页面页码
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
$data
[
'last_page'
]
=
$list_data
->
lastPage
();
//表示最后一页的页码
->
where
(
'pewo_create_time'
,
'like'
,
$request
[
'time'
]
.
'%'
)
$data
[
'total'
]
=
$list_data
->
total
();
//总数据个数
->
select
(
DB
::
raw
(
'sum(pewo_performance_total_price) as service_price'
))
$data
[
'current_number'
]
=
$show_count
;
//一页显示多少个
->
first
();
$data
[
'data'
]
=
$list_items
;
//返回数据
if
(
$find_data
->
service_price
)
{
return
$data
;
$count_show
[
'service_price'
]
=
$find_data
->
service_price
/
100
;
//当月的服务绩效金额
}
}
else
{
$count_show
[
'service_price'
]
=
0
;
//当月的服务绩效金额
// 个人中心-编辑
}
public
static
function
edit
(
$user_info
,
$request
)
$order_num
=
DB
::
table
(
'wash_performance_work'
)
{
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
$find_admin
=
DB
::
table
(
'admin'
)
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
->
where
(
'adm_id'
,
'!='
,
$user_info
->
adm_id
)
->
where
(
'pewo_create_time'
,
'like'
,
$request
[
'time'
]
.
'%'
)
->
where
(
'adm_phone'
,
$request
[
'adm_phone'
])
->
groupBy
(
'pewo_wor_id'
)
->
first
();
->
get
();
if
(
$find_admin
)
{
$count_show
[
'order_num'
]
=
count
(
$order_num
);
return
[
'code'
=>
500
,
'msg'
=>
'手机号已存在'
,
'data'
=>
''
];
$data
[
'count_show'
]
=
$count_show
;
}
$list_items
=
$list_data
->
items
();
$data
[
'adm_name'
]
=
$request
[
'adm_name'
];
foreach
(
$list_items
as
$key
=>
$value
)
{
$data
[
'adm_phone'
]
=
$request
[
'adm_phone'
];
$list_items
[
$key
]
->
pewo_performance_total_price
=
DB
::
table
(
'wash_performance_work'
)
$data
[
'adm_update_time'
]
=
date
(
'Y-m-d H:i:s'
);
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
$res
=
DB
::
table
(
'admin'
)
->
where
(
'pewo_service_adm_id'
,
$user_info
->
adm_id
)
->
where
(
'adm_id'
,
$user_info
->
adm_id
)
->
where
(
'pewo_create_time'
,
'like'
,
$request
[
'time'
]
.
'%'
)
->
update
(
$data
);
->
where
(
'pewo_wor_id'
,
$value
->
pewo_wor_id
)
$update_data
[
'phone'
]
=
$request
[
'adm_phone'
];
->
sum
(
'pewo_performance_total_price'
);
$update_data
[
'update_time'
]
=
date
(
'Y-m-d H:i:s'
);
$list_items
[
$key
]
->
pewo_create_time
=
date
(
"Y-m-d"
,
strtotime
(
$value
->
pewo_create_time
));
$update_res
=
DB
::
table
(
'admin_shop_role'
)
}
->
where
(
'adm_id'
,
$user_info
->
adm_id
)
$data
[
'current_page'
]
=
$list_data
->
currentPage
();
//当前页面页码
->
update
(
$update_data
);
$data
[
'last_page'
]
=
$list_data
->
lastPage
();
//表示最后一页的页码
if
(
$res
)
{
$data
[
'total'
]
=
$list_data
->
total
();
//总数据个数
return
[
'code'
=>
200
,
'msg'
=>
'编辑成功'
,
'data'
=>
''
];
$data
[
'current_number'
]
=
$show_count
;
//一页显示多少个
}
else
{
$data
[
'data'
]
=
$list_items
;
//返回数据
return
[
'code'
=>
500
,
'msg'
=>
'编辑失败'
,
'data'
=>
''
];
$data
[
'typecount'
]
=
$typecount
;
//返回数据
}
return
$data
;
}
}
// 收藏技师
// 个人中心-编辑
public
static
function
collectionTh
(
$user_info
,
$request
)
public
static
function
edit
(
$user_info
,
$request
)
{
{
$data
[
'coth_shop_id'
]
=
$user_info
->
adm_shop_id
;
$find_admin
=
DB
::
table
(
'admin'
)
$data
[
'coth_adm_id'
]
=
$request
[
'adm_id'
];
//技师id
->
where
(
'adm_id'
,
'!='
,
$user_info
->
adm_id
)
$data
[
'coth_create_adm_id'
]
=
$user_info
->
adm_id
;
//收藏人id
->
where
(
'adm_phone'
,
$request
[
'adm_phone'
])
$data
[
'coth_create_time'
]
=
date
(
'Y-m-d H:i:s'
);
->
first
();
$find_coth_data
=
DB
::
table
(
'collection_technician'
)
if
(
$find_admin
)
{
->
where
(
'coth_adm_id'
,
$request
[
'adm_id'
])
return
[
'code'
=>
500
,
'msg'
=>
'手机号已存在'
,
'data'
=>
''
];
->
where
(
'coth_create_adm_id'
,
$user_info
->
adm_id
)
}
->
select
(
'coth_id'
)
$data
[
'adm_name'
]
=
$request
[
'adm_name'
];
->
first
();
$data
[
'adm_phone'
]
=
$request
[
'adm_phone'
];
if
(
$find_coth_data
)
{
$data
[
'adm_update_time'
]
=
date
(
'Y-m-d H:i:s'
);
return
[
'code'
=>
500
,
'msg'
=>
'此技师已收藏'
,
'data'
=>
'此技师已收藏'
];
$res
=
DB
::
table
(
'admin'
)
}
->
where
(
'adm_id'
,
$user_info
->
adm_id
)
$res
=
DB
::
table
(
'collection_technician'
)
->
update
(
$data
);
->
insertGetId
(
$data
);
$update_data
[
'phone'
]
=
$request
[
'adm_phone'
];
if
(
$res
)
{
$update_data
[
'update_time'
]
=
date
(
'Y-m-d H:i:s'
);
return
[
'code'
=>
200
,
'msg'
=>
'收藏成功'
,
'data'
=>
'收藏成功'
];
$update_res
=
DB
::
table
(
'admin_shop_role'
)
}
else
{
->
where
(
'adm_id'
,
$user_info
->
adm_id
)
return
[
'code'
=>
500
,
'msg'
=>
'收藏失败'
,
'data'
=>
'收藏失败'
];
->
update
(
$update_data
);
}
if
(
$res
)
{
}
return
[
'code'
=>
200
,
'msg'
=>
'编辑成功'
,
'data'
=>
''
];
}
else
{
// 取消收藏技师
return
[
'code'
=>
500
,
'msg'
=>
'编辑失败'
,
'data'
=>
''
];
public
static
function
cancelCoTh
(
$user_info
,
$request
)
}
{
}
$res
=
DB
::
table
(
'collection_technician'
)
->
where
(
'coth_create_adm_id'
,
$user_info
->
adm_id
)
// 收藏技师
->
where
(
'coth_adm_id'
,
$request
[
'adm_id'
])
public
static
function
collectionTh
(
$user_info
,
$request
)
->
delete
();
{
if
(
$res
)
{
$data
[
'coth_shop_id'
]
=
$user_info
->
adm_shop_id
;
return
[
'code'
=>
200
,
'msg'
=>
'取消收藏成功'
,
'data'
=>
'取消收藏成功'
];
$data
[
'coth_adm_id'
]
=
$request
[
'adm_id'
];
//技师id
}
else
{
$data
[
'coth_create_adm_id'
]
=
$user_info
->
adm_id
;
//收藏人id
return
[
'code'
=>
500
,
'msg'
=>
'取消收藏失败'
,
'data'
=>
'取消收藏失败'
];
$data
[
'coth_create_time'
]
=
date
(
'Y-m-d H:i:s'
);
}
$find_coth_data
=
DB
::
table
(
'collection_technician'
)
}
->
where
(
'coth_adm_id'
,
$request
[
'adm_id'
])
->
where
(
'coth_create_adm_id'
,
$user_info
->
adm_id
)
// 我的收藏技师
->
select
(
'coth_id'
)
public
static
function
myCoTh
(
$user_info
,
$search_data
)
->
first
();
{
if
(
$find_coth_data
)
{
$res
=
DB
::
table
(
'collection_technician as coth'
)
return
[
'code'
=>
500
,
'msg'
=>
'此技师已收藏'
,
'data'
=>
'此技师已收藏'
];
->
leftJoin
(
'admin as a'
,
'a.adm_id'
,
'='
,
'coth.coth_adm_id'
)
}
->
leftJoin
(
'wash_grade_level as b'
,
'b.grle_id'
,
'='
,
'a.adm_grle_id'
)
$res
=
DB
::
table
(
'collection_technician'
)
->
leftJoin
(
'wash_grade_professional as c'
,
'c.grpr_id'
,
'='
,
'b.grle_grpr_id'
)
->
insertGetId
(
$data
);
->
where
(
'coth_create_adm_id'
,
$user_info
->
adm_id
)
if
(
$res
)
{
->
where
(
'adm_state'
,
1
)
return
[
'code'
=>
200
,
'msg'
=>
'收藏成功'
,
'data'
=>
'收藏成功'
];
->
where
(
function
(
$query
)
use
(
$search_data
)
{
}
else
{
if
(
!
empty
(
$search_data
[
'keywords'
]))
{
return
[
'code'
=>
500
,
'msg'
=>
'收藏失败'
,
'data'
=>
'收藏失败'
];
$query
->
where
(
'adm_name'
,
'like'
,
'%'
.
$search_data
[
'keywords'
]
.
'%'
);
}
}
}
})
->
select
(
'adm_id'
,
'adm_name'
,
'adm_phone'
,
'grpr_name'
,
'grle_name'
)
// 取消收藏技师
->
get
()
->
toArray
();
public
static
function
cancelCoTh
(
$user_info
,
$request
)
foreach
(
$res
as
$key
=>
$value
)
{
{
$res
[
$key
]
->
adm_coth_state
=
1
;
$res
=
DB
::
table
(
'collection_technician'
)
$rest
=
mb_substr
(
$value
->
adm_name
,
0
,
1
,
'utf-8'
);
->
where
(
'coth_create_adm_id'
,
$user_info
->
adm_id
)
if
(
$rest
)
{
->
where
(
'coth_adm_id'
,
$request
[
'adm_id'
])
$mb
=
mb_strlen
(
$rest
,
'utf-8'
);
->
delete
();
$st
=
strlen
(
$rest
);
if
(
$res
)
{
if
(
$st
==
$mb
)
{
//英文
return
[
'code'
=>
200
,
'msg'
=>
'取消收藏成功'
,
'data'
=>
'取消收藏成功'
];
$res
[
$key
]
->
firstLetter
=
strtoupper
(
$rest
);
}
else
{
}
else
{
//汉字
return
[
'code'
=>
500
,
'msg'
=>
'取消收藏失败'
,
'data'
=>
'取消收藏失败'
];
$res
[
$key
]
->
firstLetter
=
substr
(
strtoupper
(
Pinyin
::
abbr
(
$value
->
adm_name
)),
0
,
1
);
}
}
}
}
else
{
$res
[
$key
]
->
firstLetter
=
''
;
// 我的收藏技师
}
public
static
function
myCoTh
(
$user_info
,
$search_data
)
}
{
return
$res
;
$res
=
DB
::
table
(
'collection_technician as coth'
)
}
->
leftJoin
(
'admin as a'
,
'a.adm_id'
,
'='
,
'coth.coth_adm_id'
)
->
leftJoin
(
'wash_grade_level as b'
,
'b.grle_id'
,
'='
,
'a.adm_grle_id'
)
// 技师动态
->
leftJoin
(
'wash_grade_professional as c'
,
'c.grpr_id'
,
'='
,
'b.grle_grpr_id'
)
public
static
function
technicianDynamics
(
$user_info
,
$search_data
)
->
where
(
'coth_create_adm_id'
,
$user_info
->
adm_id
)
{
->
where
(
'adm_state'
,
1
)
$now_year_month
=
date
(
'Y-m'
);
->
where
(
function
(
$query
)
use
(
$search_data
)
{
$admin
=
DB
::
table
(
'admin as a'
)
if
(
!
empty
(
$search_data
[
'keywords'
]))
{
->
leftJoin
(
'admin_shop_role as d'
,
'd.adm_id'
,
'='
,
'a.adm_id'
)
$query
->
where
(
'adm_name'
,
'like'
,
'%'
.
$search_data
[
'keywords'
]
.
'%'
);
->
leftJoin
(
'wash_grade_level as b'
,
'b.grle_id'
,
'='
,
'a.adm_grle_id'
)
}
->
leftJoin
(
'wash_grade_professional as c'
,
'c.grpr_id'
,
'='
,
'b.grle_grpr_id'
)
})
->
where
(
'd.shop_cid'
,
$user_info
->
adm_cid
)
->
select
(
'adm_id'
,
'adm_name'
,
'adm_phone'
,
'grpr_name'
,
'grle_name'
)
->
where
(
'd.shop_id'
,
$user_info
->
adm_shop_id
)
->
get
()
->
toArray
();
->
where
(
'd.adm_state'
,
1
)
foreach
(
$res
as
$key
=>
$value
)
{
// ->whereIn('adm_leave', [3, 5])
$res
[
$key
]
->
adm_coth_state
=
1
;
->
where
(
'adm_type'
,
'!='
,
2
)
//不等于虚拟加盟店
$rest
=
mb_substr
(
$value
->
adm_name
,
0
,
1
,
'utf-8'
);
->
where
(
function
(
$query
)
use
(
$search_data
)
{
if
(
$rest
)
{
if
(
!
empty
(
$search_data
[
'search_data'
]))
{
$mb
=
mb_strlen
(
$rest
,
'utf-8'
);
$query
->
where
(
'adm_name'
,
'like'
,
'%'
.
$search_data
[
'search_data'
]
.
'%'
)
$st
=
strlen
(
$rest
);
->
orwhere
(
'adm_phone'
,
'like'
,
'%'
.
$search_data
[
'search_data'
]
.
'%'
);
if
(
$st
==
$mb
)
{
//英文
}
$res
[
$key
]
->
firstLetter
=
strtoupper
(
$rest
);
})
}
else
{
//汉字
->
select
(
'a.adm_id'
,
'adm_name'
,
'adm_phone'
,
'grpr_name'
,
'grle_name'
,
'adm_account'
)
$res
[
$key
]
->
firstLetter
=
substr
(
strtoupper
(
Pinyin
::
abbr
(
$value
->
adm_name
)),
0
,
1
);
->
orderBy
(
'adm_id'
,
'desc'
)
}
->
get
()
->
toArray
();
}
else
{
foreach
(
$admin
as
$key
=>
$value
)
{
$res
[
$key
]
->
firstLetter
=
''
;
$work_order
=
DB
::
table
(
'wash_work_technician_part as wotp'
)
}
->
leftJoin
(
'work_order as w'
,
'w.wor_id'
,
'='
,
'wotp.wotp_wor_id'
)
}
->
where
(
'wotp_service_adm_id'
,
$value
->
adm_id
)
return
$res
;
->
where
(
'wor_create_time'
,
'like'
,
$now_year_month
.
'%'
)
}
->
select
(
'wor_id'
,
'wor_state'
,
'wor_appoint_time'
,
'wor_achieve_time'
,
'wor_create_time'
)
->
groupBy
(
'wor_id'
)
// 技师动态
->
get
()
->
toArray
();
public
static
function
technicianDynamics
(
$user_info
,
$search_data
)
$number
=
0
;
{
$number1
=
0
;
$now_year_month
=
date
(
'Y-m'
);
$number2
=
0
;
$admin
=
DB
::
table
(
'admin as a'
)
foreach
(
$work_order
as
$key1
=>
$value1
)
{
->
leftJoin
(
'admin_shop_role as d'
,
'd.adm_id'
,
'='
,
'a.adm_id'
)
$number
++
;
//总工单
->
leftJoin
(
'wash_grade_level as b'
,
'b.grle_id'
,
'='
,
'a.adm_grle_id'
)
// if (in_array($value1->wor_state, [5,6,7])) {
->
leftJoin
(
'wash_grade_professional as c'
,
'c.grpr_id'
,
'='
,
'b.grle_grpr_id'
)
// }
->
where
(
'd.shop_cid'
,
$user_info
->
adm_cid
)
$endDay
=
date
(
'Y-m-'
)
.
date
(
't'
,
strtotime
(
date
(
'Y-m-d'
)))
.
' 23:59:59'
;
->
where
(
'd.shop_id'
,
$user_info
->
adm_shop_id
)
if
(
in_array
(
$value1
->
wor_state
,
[
5
,
6
,
7
,
8
,
9
])
&&
strtotime
(
$value1
->
wor_create_time
)
>=
strtotime
(
date
(
'Y-m'
))
&&
strtotime
(
$value1
->
wor_create_time
)
<=
strtotime
(
$endDay
))
{
->
where
(
'd.adm_state'
,
1
)
$number1
++
;
// ->whereIn('adm_leave', [3, 5])
}
->
where
(
'adm_type'
,
'!='
,
2
)
//不等于虚拟加盟店
if
(
in_array
(
$value1
->
wor_state
,
[
10
,
12
])
&&
strtotime
(
$value1
->
wor_achieve_time
)
>=
strtotime
(
date
(
'Y-m-d'
))
&&
strtotime
(
$value1
->
wor_achieve_time
)
<=
strtotime
(
$endDay
))
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
$number2
++
;
if
(
!
empty
(
$search_data
[
'search_data'
]))
{
}
$query
->
where
(
'adm_name'
,
'like'
,
'%'
.
$search_data
[
'search_data'
]
.
'%'
)
}
->
orwhere
(
'adm_phone'
,
'like'
,
'%'
.
$search_data
[
'search_data'
]
.
'%'
);
// 查询当前年月的技师的单量和绩效金额
}
$find_data
=
DB
::
table
(
'wash_performance_work'
)
})
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
->
select
(
'a.adm_id'
,
'adm_name'
,
'adm_phone'
,
'grpr_name'
,
'grle_name'
,
'adm_account'
)
->
where
(
'pewo_service_adm_id'
,
$value
->
adm_id
)
->
orderBy
(
'adm_id'
,
'desc'
)
->
where
(
'pewo_create_time'
,
'like'
,
$now_year_month
.
'%'
)
->
get
()
->
toArray
();
->
select
(
DB
::
raw
(
'count(*) as count,sum(pewo_performance_total_price) as service_price'
))
foreach
(
$admin
as
$key
=>
$value
)
{
->
first
();
$work_order
=
DB
::
table
(
'wash_work_technician_part as wotp'
)
if
(
$find_data
->
service_price
)
{
->
leftJoin
(
'work_order as w'
,
'w.wor_id'
,
'='
,
'wotp.wotp_wor_id'
)
$service_price
=
$find_data
->
service_price
/
100
;
//当月的服务绩效金额
->
where
(
'wotp_service_adm_id'
,
$value
->
adm_id
)
}
else
{
->
where
(
'wor_create_time'
,
'like'
,
$now_year_month
.
'%'
)
$service_price
=
0
;
//当月的服务绩效金额
->
select
(
'wor_id'
,
'wor_state'
,
'wor_appoint_time'
,
'wor_achieve_time'
,
'wor_create_time'
)
}
->
groupBy
(
'wor_id'
)
$admin
[
$key
]
->
adm_name
=
$value
->
adm_name
??
''
;
->
get
()
->
toArray
();
$admin
[
$key
]
->
adm_phone
=
$value
->
adm_phone
??
''
;
$number
=
0
;
$admin
[
$key
]
->
adm_account
=
$value
->
adm_account
??
''
;
$number1
=
0
;
$admin
[
$key
]
->
service_price
=
$service_price
;
$number2
=
0
;
$admin
[
$key
]
->
totalWork
=
$number
;
//总工单
foreach
(
$work_order
as
$key1
=>
$value1
)
{
$admin
[
$key
]
->
unFinished
=
$number1
;
//未完成工单
$number
++
;
//总工单
}
// if (in_array($value1->wor_state, [5,6,7])) {
return
$admin
;
// }
}
$endDay
=
date
(
'Y-m-'
)
.
date
(
't'
,
strtotime
(
date
(
'Y-m-d'
)))
.
' 23:59:59'
;
if
(
in_array
(
$value1
->
wor_state
,
[
5
,
6
,
7
,
8
,
9
])
&&
strtotime
(
$value1
->
wor_create_time
)
>=
strtotime
(
date
(
'Y-m'
))
&&
strtotime
(
$value1
->
wor_create_time
)
<=
strtotime
(
$endDay
))
{
// 技师工单列表
$number1
++
;
public
static
function
workOrderTh
(
$user_info
,
$request
,
$show_count
=
10
)
}
{
if
(
in_array
(
$value1
->
wor_state
,
[
10
,
12
])
&&
strtotime
(
$value1
->
wor_achieve_time
)
>=
strtotime
(
date
(
'Y-m-d'
))
&&
strtotime
(
$value1
->
wor_achieve_time
)
<=
strtotime
(
$endDay
))
{
$today_start
=
date
(
'Y-m-d'
,
time
())
.
' 00:00:00'
;
$number2
++
;
$today_end
=
date
(
'Y-m-d'
,
time
())
.
' 23:59:59'
;
}
$list_data
=
DB
::
table
(
'wash_work_technician_part as wotp'
)
}
->
leftJoin
(
'work_order as w'
,
'w.wor_id'
,
'='
,
'wotp.wotp_wor_id'
)
// 查询当前年月的技师的单量和绩效金额
->
leftJoin
(
'work_client as wocl'
,
'wocl.wocl_wor_id'
,
'='
,
'wotp.wotp_wor_id'
)
$find_data
=
DB
::
table
(
'wash_performance_work'
)
->
where
(
'wotp_service_adm_id'
,
$request
[
'adm_id'
])
->
where
(
'pewo_shop_id'
,
$user_info
->
adm_shop_id
)
->
where
(
function
(
$query
)
use
(
$today_start
,
$today_end
){
->
where
(
'pewo_service_adm_id'
,
$value
->
adm_id
)
$query
->
whereIn
(
'wor_state'
,
[
5
,
6
,
7
])
->
where
(
'pewo_create_time'
,
'like'
,
$now_year_month
.
'%'
)
->
orWhere
(
function
(
$query
)
use
(
$today_start
,
$today_end
){
->
select
(
DB
::
raw
(
'count(*) as count,sum(pewo_performance_total_price) as service_price'
))
$query
->
whereIn
(
'wor_state'
,
[
8
,
10
])
->
first
();
->
whereBetween
(
'wor_achieve_time'
,
[
$today_start
,
$today_end
]);
if
(
$find_data
->
service_price
)
{
});
$service_price
=
$find_data
->
service_price
/
100
;
//当月的服务绩效金额
})
}
else
{
->
select
(
'wor_id'
,
'wor_state'
,
'wor_appoint_time'
,
'wor_number'
,
'wor_address'
,
'wor_explain'
,
'wor_type'
,
'wor_delete'
,
'wocl_client_id'
,
'wocl_carowner_name'
,
'wocl_carowner_phone'
,
'wocl_bus_name'
,
'wor_create_id'
,
'wor_address_type'
,
'wor_shop_id'
,
'wor_address_id'
,
'wocl_car_num'
,
'wor_service_adm_id'
)
$service_price
=
0
;
//当月的服务绩效金额
->
orderBy
(
'wor_appoint_time'
,
'ASC'
)
}
->
paginate
(
$show_count
);
$admin
[
$key
]
->
adm_name
=
$value
->
adm_name
??
''
;
$list_items2
=
$list_data
->
items
();
$admin
[
$key
]
->
adm_phone
=
$value
->
adm_phone
??
''
;
if
(
$list_items2
)
{
$admin
[
$key
]
->
adm_account
=
$value
->
adm_account
??
''
;
$wor_id
=
array_column
(
$list_items2
,
'wor_id'
);
//工单id
$admin
[
$key
]
->
service_price
=
$service_price
;
$wor_create_id
=
array_unique
(
array_column
(
$list_items2
,
'wor_create_id'
));
//录单人id
$admin
[
$key
]
->
totalWork
=
$number
;
//总工单
$admin
[
$key
]
->
unFinished
=
$number1
;
//未完成工单
// 查询商品、项目信息
}
$work_goods
=
DB
::
table
(
'work_good as wg'
)
return
$admin
;
->
leftjoin
(
'goods as g'
,
'g.goo_id'
,
'='
,
'wg.wogo_goo_id'
)
}
->
whereIn
(
'wogo_wor_id'
,
$wor_id
)
->
select
(
'wogo_id'
,
'wogo_wor_id'
,
'wogo_goo_id'
,
'wogo_goo_name'
,
'wogo_goo_goods_encode'
,
'wogo_goo_amount'
,
'wogo_goo_price'
,
'wogo_goo_guarantee'
,
'wogo_goo_type'
,
'wogo_state'
,
'wogo_goo_unit'
,
'wogo_goo_unta_id'
,
'goo_unit_conversion'
)
// 技师工单列表
->
get
()
->
toArray
();
public
static
function
workOrderTh
(
$user_info
,
$request
,
$show_count
=
10
)
$service_adm_id
=
array_filter
(
array_unique
(
array_column
(
$list_items2
,
'wor_service_adm_id'
)));
//选的技师id
{
$adm_id_merge
=
array_merge
(
$wor_create_id
,
$service_adm_id
);
$today_start
=
date
(
'Y-m-d'
,
time
())
.
' 00:00:00'
;
// 查询录单人信息
$today_end
=
date
(
'Y-m-d'
,
time
())
.
' 23:59:59'
;
$find_adm
=
DB
::
table
(
'admin'
)
$list_data
=
DB
::
table
(
'wash_work_technician_part as wotp'
)
->
whereIn
(
'adm_id'
,
$adm_id_merge
)
->
leftJoin
(
'work_order as w'
,
'w.wor_id'
,
'='
,
'wotp.wotp_wor_id'
)
->
pluck
(
'adm_name'
,
'adm_id'
)
->
toArray
();
->
leftJoin
(
'work_client as wocl'
,
'wocl.wocl_wor_id'
,
'='
,
'wotp.wotp_wor_id'
)
->
where
(
'wotp_service_adm_id'
,
$request
[
'adm_id'
])
foreach
(
$work_goods
as
$key
=>
$value
)
{
->
where
(
function
(
$query
)
use
(
$today_start
,
$today_end
){
$work_goods
[
$key
]
->
wogo_goo_amount
=
$value
->
wogo_goo_amount
.
$value
->
wogo_goo_unit
;
$query
->
whereIn
(
'wor_state'
,
[
5
,
6
,
7
])
}
->
orWhere
(
function
(
$query
)
use
(
$today_start
,
$today_end
){
$query
->
whereIn
(
'wor_state'
,
[
8
,
10
])
$find_dis
=
DB
::
table
(
'dispatch_bill'
)
->
whereBetween
(
'wor_achieve_time'
,
[
$today_start
,
$today_end
]);
->
where
(
'dego_shop_id'
,
$user_info
->
adm_shop_id
)
});
->
whereIn
(
'dego_wor_id'
,
$wor_id
)
})
->
where
(
'dego_order_type'
,
2
)
->
select
(
'wor_id'
,
'wor_state'
,
'wor_appoint_time'
,
'wor_number'
,
'wor_address'
,
'wor_explain'
,
'wor_type'
,
'wor_delete'
,
'wocl_client_id'
,
'wocl_carowner_name'
,
'wocl_carowner_phone'
,
'wocl_bus_name'
,
'wor_create_id'
,
'wor_address_type'
,
'wor_shop_id'
,
'wor_address_id'
,
'wocl_car_num'
,
'wor_service_adm_id'
)
->
pluck
(
'dego_type'
,
'dego_wor_id'
)
->
toArray
();
->
orderBy
(
'wor_appoint_time'
,
'ASC'
)
$find_dis_pic
=
DB
::
table
(
'dispatch_bill'
)
->
paginate
(
$show_count
);
->
where
(
'dego_shop_id'
,
$user_info
->
adm_shop_id
)
$list_items2
=
$list_data
->
items
();
->
whereIn
(
'dego_wor_id'
,
$wor_id
)
if
(
$list_items2
)
{
->
where
(
'dego_order_type'
,
2
)
$wor_id
=
array_column
(
$list_items2
,
'wor_id'
);
//工单id
->
pluck
(
'dego_pic'
,
'dego_wor_id'
)
->
toArray
();
$wor_create_id
=
array_unique
(
array_column
(
$list_items2
,
'wor_create_id'
));
//录单人id
foreach
(
$list_items2
as
$key
=>
$value
)
{
// 组长
// 查询商品、项目信息
if
(
$value
->
wor_service_adm_id
)
{
$work_goods
=
DB
::
table
(
'work_good as wg'
)
$list_items2
[
$key
]
->
wor_service_adm_name
=
$find_adm
[
$value
->
wor_service_adm_id
];
->
leftjoin
(
'goods as g'
,
'g.goo_id'
,
'='
,
'wg.wogo_goo_id'
)
}
else
{
->
whereIn
(
'wogo_wor_id'
,
$wor_id
)
$list_items2
[
$key
]
->
wor_service_adm_name
=
''
;
->
select
(
'wogo_id'
,
'wogo_wor_id'
,
'wogo_goo_id'
,
'wogo_goo_name'
,
'wogo_goo_goods_encode'
,
'wogo_goo_amount'
,
'wogo_goo_price'
,
'wogo_goo_guarantee'
,
'wogo_goo_type'
,
'wogo_state'
,
'wogo_goo_unit'
,
'wogo_goo_unta_id'
,
'goo_unit_conversion'
)
}
->
get
()
->
toArray
();
// 组员
$service_adm_id
=
array_filter
(
array_unique
(
array_column
(
$list_items2
,
'wor_service_adm_id'
)));
//选的技师id
$find_wotp_data
=
DB
::
table
(
'wash_work_technician_part'
)
$adm_id_merge
=
array_merge
(
$wor_create_id
,
$service_adm_id
);
->
where
(
'wotp_wor_id'
,
$value
->
wor_id
)
// 查询录单人信息
->
where
(
'wotp_service_adm_id'
,
'<>'
,
$value
->
wor_service_adm_id
)
$find_adm
=
DB
::
table
(
'admin'
)
->
select
(
'wotp_service_adm_id'
,
'wotp_service_adm_name'
)
->
whereIn
(
'adm_id'
,
$adm_id_merge
)
->
get
()
->
toArray
();
->
pluck
(
'adm_name'
,
'adm_id'
)
->
toArray
();
if
(
$find_wotp_data
)
{
$team_members
=
''
;
foreach
(
$work_goods
as
$key
=>
$value
)
{
foreach
(
$find_wotp_data
as
$m_key
=>
$m_value
)
{
$work_goods
[
$key
]
->
wogo_goo_amount
=
$value
->
wogo_goo_amount
.
$value
->
wogo_goo_unit
;
if
(
$team_members
)
{
}
$team_members
=
$m_value
->
wotp_service_adm_name
.
'、'
.
$team_members
;
}
else
{
$find_dis
=
DB
::
table
(
'dispatch_bill'
)
$team_members
=
$m_value
->
wotp_service_adm_name
;
->
where
(
'dego_shop_id'
,
$user_info
->
adm_shop_id
)
}
->
whereIn
(
'dego_wor_id'
,
$wor_id
)
}
->
where
(
'dego_order_type'
,
2
)
$list_items2
[
$key
]
->
team_members
=
$team_members
;
->
pluck
(
'dego_type'
,
'dego_wor_id'
)
->
toArray
();
}
$find_dis_pic
=
DB
::
table
(
'dispatch_bill'
)
// 创建人
->
where
(
'dego_shop_id'
,
$user_info
->
adm_shop_id
)
if
(
$value
->
wor_create_id
)
{
->
whereIn
(
'dego_wor_id'
,
$wor_id
)
$list_items2
[
$key
]
->
adm_name
=
$find_adm
[
$value
->
wor_create_id
];
->
where
(
'dego_order_type'
,
2
)
}
else
{
->
pluck
(
'dego_pic'
,
'dego_wor_id'
)
->
toArray
();
$list_items2
[
$key
]
->
adm_name
=
''
;
foreach
(
$list_items2
as
$key
=>
$value
)
{
}
// 组长
// 发货状态
if
(
$value
->
wor_service_adm_id
)
{
if
(
isset
(
$find_dis
[
$value
->
wor_id
]))
{
$list_items2
[
$key
]
->
wor_service_adm_name
=
$find_adm
[
$value
->
wor_service_adm_id
];
$list_items2
[
$key
]
->
dego_type
=
$find_dis
[
$value
->
wor_id
];
}
else
{
}
else
{
$list_items2
[
$key
]
->
wor_service_adm_name
=
''
;
$list_items2
[
$key
]
->
dego_type
=
0
;
}
}
// 组员
if
(
strtotime
(
$value
->
wor_appoint_time
)
>=
strtotime
(
date
(
'Y-m-d'
,
time
()))
&&
strtotime
(
$value
->
wor_appoint_time
)
<=
strtotime
(
date
(
'Y-m-d'
,
time
())
.
'23:59:59'
))
{
$find_wotp_data
=
DB
::
table
(
'wash_work_technician_part'
)
$list_items2
[
$key
]
->
wor_time
=
'今日工单'
;
->
where
(
'wotp_wor_id'
,
$value
->
wor_id
)
}
else
{
->
where
(
'wotp_service_adm_id'
,
'<>'
,
$value
->
wor_service_adm_id
)
$list_items2
[
$key
]
->
wor_time
=
''
;
->
select
(
'wotp_service_adm_id'
,
'wotp_service_adm_name'
)
}
->
get
()
->
toArray
();
// 施工地址
if
(
$find_wotp_data
)
{
if
(
$value
->
wor_address_type
==
1
)
{
//门店
$team_members
=
''
;
$find_address
=
DB
::
table
(
'shop'
)
foreach
(
$find_wotp_data
as
$m_key
=>
$m_value
)
{
->
where
(
'shop_id'
,
$value
->
wor_address_id
)
if
(
$team_members
)
{
->
select
(
'shop_id'
,
'shop_store_name'
,
'shop_province'
,
'shop_city'
,
'shop_address'
,
'shop_county'
)
$team_members
=
$m_value
->
wotp_service_adm_name
.
'、'
.
$team_members
;
->
first
();
}
else
{
$list_items2
[
$key
]
->
shop_store_name
=
$find_address
->
shop_store_name
;
$team_members
=
$m_value
->
wotp_service_adm_name
;
$list_items2
[
$key
]
->
wor_address
=
$find_address
->
shop_province
.
$find_address
->
shop_city
.
$find_address
->
shop_county
.
$find_address
->
shop_address
;
}
}
elseif
(
$value
->
wor_address_type
==
2
)
{
}
$find_address
=
DB
::
table
(
'business_client'
)
$list_items2
[
$key
]
->
team_members
=
$team_members
;
->
where
(
'bucl_id'
,
$value
->
wor_address_id
)
}
->
select
(
'bucl_id'
,
'bucl_name'
,
'bucl_province'
,
'bucl_city'
,
'bucl_address'
,
'bucl_county'
)
// 创建人
->
first
();
if
(
$value
->
wor_create_id
)
{
$list_items2
[
$key
]
->
shop_store_name
=
$find_address
->
bucl_name
;
$list_items2
[
$key
]
->
adm_name
=
$find_adm
[
$value
->
wor_create_id
];
$list_items2
[
$key
]
->
wor_address
=
$find_address
->
bucl_province
.
$find_address
->
bucl_city
.
$find_address
->
bucl_county
.
$find_address
->
bucl_address
;
}
else
{
}
else
{
$list_items2
[
$key
]
->
adm_name
=
''
;
$find_address
=
DB
::
table
(
'shop'
)
}
->
where
(
'shop_id'
,
$value
->
wor_shop_id
)
// 发货状态
->
select
(
'shop_id'
,
'shop_store_name'
,
'shop_province'
,
'shop_city'
,
'shop_address'
,
'shop_county'
)
if
(
isset
(
$find_dis
[
$value
->
wor_id
]))
{
->
first
();
$list_items2
[
$key
]
->
dego_type
=
$find_dis
[
$value
->
wor_id
];
$list_items2
[
$key
]
->
shop_store_name
=
$find_address
->
shop_store_name
;
}
else
{
$list_items2
[
$key
]
->
wor_address
=
$find_address
->
shop_province
.
$find_address
->
shop_city
.
$find_address
->
shop_county
.
$find_address
->
shop_address
;
$list_items2
[
$key
]
->
dego_type
=
0
;
}
}
}
if
(
strtotime
(
$value
->
wor_appoint_time
)
>=
strtotime
(
date
(
'Y-m-d'
,
time
()))
&&
strtotime
(
$value
->
wor_appoint_time
)
<=
strtotime
(
date
(
'Y-m-d'
,
time
())
.
'23:59:59'
))
{
// 查询备注信息
$list_items2
[
$key
]
->
wor_time
=
'今日工单'
;
$order_reamrks
=
DB
::
table
(
'order_remarks'
)
}
else
{
->
whereIn
(
'orre_wor_id'
,
$wor_id
)
$list_items2
[
$key
]
->
wor_time
=
''
;
->
select
(
'orre_create_adm_name'
,
'orre_content'
,
'orre_time'
,
'orre_wor_id'
,
'orre_module'
)
}
->
orderby
(
'orre_id'
,
'desc'
)
// 施工地址
->
get
();
if
(
$value
->
wor_address_type
==
1
)
{
//门店
$find_address
=
DB
::
table
(
'shop'
)
// 查找操作记录
->
where
(
'shop_id'
,
$value
->
wor_address_id
)
$order_log
=
DB
::
table
(
'order_log'
)
->
select
(
'shop_id'
,
'shop_store_name'
,
'shop_province'
,
'shop_city'
,
'shop_address'
,
'shop_county'
)
->
whereIn
(
'orlo_wor_id'
,
$wor_id
)
->
first
();
->
orderBy
(
'orlo_id'
,
'desc'
)
$list_items2
[
$key
]
->
shop_store_name
=
$find_address
->
shop_store_name
;
->
select
(
'orlo_wor_id'
,
'orlo_time'
,
'orlo_create_adm_name'
,
'orlo_content'
)
$list_items2
[
$key
]
->
wor_address
=
$find_address
->
shop_province
.
$find_address
->
shop_city
.
$find_address
->
shop_county
.
$find_address
->
shop_address
;
->
get
();
}
elseif
(
$value
->
wor_address_type
==
2
)
{
}
else
{
$find_address
=
DB
::
table
(
'business_client'
)
$work_goods
=
[];
->
where
(
'bucl_id'
,
$value
->
wor_address_id
)
$order_log
=
[];
->
select
(
'bucl_id'
,
'bucl_name'
,
'bucl_province'
,
'bucl_city'
,
'bucl_address'
,
'bucl_county'
)
$order_reamrks
=
[];
->
first
();
}
$list_items2
[
$key
]
->
shop_store_name
=
$find_address
->
bucl_name
;
$data
[
'current_page'
]
=
$list_data
->
currentPage
();
//当前页面页码
$list_items2
[
$key
]
->
wor_address
=
$find_address
->
bucl_province
.
$find_address
->
bucl_city
.
$find_address
->
bucl_county
.
$find_address
->
bucl_address
;
$data
[
'last_page'
]
=
$list_data
->
lastPage
();
//表示最后一页的页码
}
else
{
$data
[
'total'
]
=
$list_data
->
total
();
//总数据个数
$find_address
=
DB
::
table
(
'shop'
)
$data
[
'current_number'
]
=
$show_count
;
//一页显示多少个
->
where
(
'shop_id'
,
$value
->
wor_shop_id
)
$data
[
'data'
]
=
$list_items2
;
//返回数据
->
select
(
'shop_id'
,
'shop_store_name'
,
'shop_province'
,
'shop_city'
,
'shop_address'
,
'shop_county'
)
$data
[
'work_goods'
]
=
$work_goods
;
//工单商品数据
->
first
();
return
$data
;
$list_items2
[
$key
]
->
shop_store_name
=
$find_address
->
shop_store_name
;
}
$list_items2
[
$key
]
->
wor_address
=
$find_address
->
shop_province
.
$find_address
->
shop_city
.
$find_address
->
shop_county
.
$find_address
->
shop_address
;
}
// 审核列表
}
public
static
function
index
(
$user_info
,
$search_data
,
$show_count
=
10
)
// 查询备注信息
{
$order_reamrks
=
DB
::
table
(
'order_remarks'
)
$list_data
=
DB
::
table
(
'admin_process'
)
->
whereIn
(
'orre_wor_id'
,
$wor_id
)
->
leftJoin
(
'role'
,
'rol_id'
,
'='
,
'adp_adm_rol_id'
)
->
select
(
'orre_create_adm_name'
,
'orre_content'
,
'orre_time'
,
'orre_wor_id'
,
'orre_module'
)
->
where
(
'adp_shop_id'
,
$user_info
->
adm_shop_id
)
->
orderby
(
'orre_id'
,
'desc'
)
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//状态搜索
->
get
();
if
(
!
empty
(
$search_data
[
'adp_state'
]))
{
$query
->
where
(
'adp_state'
,
$search_data
[
'adp_state'
]);
// 查找操作记录
}
$order_log
=
DB
::
table
(
'order_log'
)
})
->
whereIn
(
'orlo_wor_id'
,
$wor_id
)
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//业务员搜索
->
orderBy
(
'orlo_id'
,
'desc'
)
if
(
!
empty
(
$search_data
[
'keywords'
]))
{
->
select
(
'orlo_wor_id'
,
'orlo_time'
,
'orlo_create_adm_name'
,
'orlo_content'
)
$query
->
where
(
'adp_adm_phone'
,
'like'
,
'%'
.
$search_data
[
'keywords'
]
.
'%'
)
->
get
();
->
orWhere
(
'adp_adm_name'
,
'like'
,
'%'
.
$search_data
[
'keywords'
]
.
'%'
);
}
else
{
}
$work_goods
=
[];
})
$order_log
=
[];
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//姓名搜索
$order_reamrks
=
[];
if
(
!
empty
(
$search_data
[
'adp_adm_name'
]))
{
}
$data
[
'current_page'
]
=
$list_data
->
currentPage
();
//当前页面页码
$query
->
Where
(
'adp_adm_name'
,
$search_data
[
'adp_adm_name'
]);
$data
[
'last_page'
]
=
$list_data
->
lastPage
();
//表示最后一页的页码
}
$data
[
'total'
]
=
$list_data
->
total
();
//总数据个数
})
$data
[
'current_number'
]
=
$show_count
;
//一页显示多少个
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//电话搜索
$data
[
'data'
]
=
$list_items2
;
//返回数据
if
(
!
empty
(
$search_data
[
'adp_adm_phone'
]))
{
$data
[
'work_goods'
]
=
$work_goods
;
//工单商品数据
$query
->
where
(
'adp_adm_phone'
,
$search_data
[
'adp_adm_phone'
]);
return
$data
;
}
}
})
->
select
(
'adp_id'
,
'adp_adm_name'
,
'adp_adm_phone'
,
'adp_adm_rol_id'
,
'rol_name'
,
'adp_state'
,
'adp_create_time'
)
// 审核列表
->
orderBy
(
'adp_id'
,
'desc'
)
public
static
function
index
(
$user_info
,
$search_data
,
$show_count
=
10
)
->
paginate
(
$show_count
);
{
$list_items
=
$list_data
->
items
();
$list_data
=
DB
::
table
(
'admin_process'
)
$data
[
'current_page'
]
=
$list_data
->
currentPage
();
//当前页面页码
->
leftJoin
(
'role'
,
'rol_id'
,
'='
,
'adp_adm_rol_id'
)
$data
[
'last_page'
]
=
$list_data
->
lastPage
();
//表示最后一页的页码
->
where
(
'adp_shop_id'
,
$user_info
->
adm_shop_id
)
$data
[
'total'
]
=
$list_data
->
total
();
//总数据个数
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//状态搜索
$data
[
'current_number'
]
=
$show_count
;
//一页显示多少个
if
(
!
empty
(
$search_data
[
'adp_state'
]))
{
$data
[
'data'
]
=
$list_items
;
//返回数据
$query
->
where
(
'adp_state'
,
$search_data
[
'adp_state'
]);
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
}
}
})
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//业务员搜索
// 驳回原因
if
(
!
empty
(
$search_data
[
'keywords'
]))
{
public
static
function
getReason
(
$user_info
,
$search_data
,
$show_count
=
10
)
$query
->
where
(
'adp_adm_phone'
,
'like'
,
'%'
.
$search_data
[
'keywords'
]
.
'%'
)
{
->
orWhere
(
'adp_adm_name'
,
'like'
,
'%'
.
$search_data
[
'keywords'
]
.
'%'
);
$list_data
=
DB
::
table
(
'admin_reason'
)
}
->
leftJoin
(
'admin_process'
,
'adp_id'
,
'='
,
'adr_adp_id'
)
})
->
where
(
'adr_adm_phone'
,
$search_data
[
'phone'
])
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//姓名搜索
->
where
(
'admin_process.adp_shop_id'
,
$user_info
->
adm_shop_id
)
if
(
!
empty
(
$search_data
[
'adp_adm_name'
]))
{
->
select
(
'adr_reason'
,
'adr_create_name'
,
'adr_create_time'
,
'adr_rol_name'
)
->
orderBy
(
'adr_id'
,
'desc'
)
$query
->
Where
(
'adp_adm_name'
,
$search_data
[
'adp_adm_name'
]);
->
get
()
->
toArray
();
}
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$list_data
];
})
}
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//电话搜索
if
(
!
empty
(
$search_data
[
'adp_adm_phone'
]))
{
// 门店经营驾驶舱
$query
->
where
(
'adp_adm_phone'
,
$search_data
[
'adp_adm_phone'
]);
public
static
function
dataCount
(
$user_info
,
$search_data
)
}
{
})
if
(
empty
(
$search_data
[
'create_time_start'
]))
{
->
select
(
'adp_id'
,
'adp_adm_name'
,
'adp_adm_phone'
,
'adp_adm_rol_id'
,
'rol_name'
,
'adp_state'
,
'adp_create_time'
)
$search_data
[
'create_time_start'
]
=
date
(
'Y-m-d'
);
->
orderBy
(
'adp_id'
,
'desc'
)
}
->
paginate
(
$show_count
);
if
(
empty
(
$search_data
[
'create_time_end'
]))
{
$list_items
=
$list_data
->
items
();
$search_data
[
'create_time_end'
]
=
date
(
'Y-m-d'
);
$data
[
'current_page'
]
=
$list_data
->
currentPage
();
//当前页面页码
}
$data
[
'last_page'
]
=
$list_data
->
lastPage
();
//表示最后一页的页码
$list_data
=
DB
::
table
(
'order'
)
$data
[
'total'
]
=
$list_data
->
total
();
//总数据个数
->
where
(
'ord_shop_id'
,
$user_info
->
adm_shop_id
)
$data
[
'current_number'
]
=
$show_count
;
//一页显示多少个
->
where
(
'ord_wor_state'
,
'<>'
,
11
)
$data
[
'data'
]
=
$list_items
;
//返回数据
->
whereIn
(
'ord_service_type'
,
[
1
,
2
,
3
])
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//创建时间
}
// 如果选择开始时间并且选择结束时间
if
(
!
empty
(
$search_data
[
'create_time_start'
])
&&
!
empty
(
$search_data
[
'create_time_end'
]))
{
// 驳回原因
$query
->
whereBetween
(
'ord_create_time'
,
[
$search_data
[
'create_time_start'
],
$search_data
[
'create_time_end'
]
.
' 23:59:59'
]);
public
static
function
getReason
(
$user_info
,
$search_data
,
$show_count
=
10
)
}
else
{
{
// 如果选择开始时间
$list_data
=
DB
::
table
(
'admin_reason'
)
if
(
!
empty
(
$search_data
[
'create_time_start'
]))
{
->
leftJoin
(
'admin_process'
,
'adp_id'
,
'='
,
'adr_adp_id'
)
$query
->
where
(
'ord_create_time'
,
'>='
,
$search_data
[
'create_time_start'
]);
->
where
(
'adr_adm_phone'
,
$search_data
[
'phone'
])
}
else
{
->
where
(
'admin_process.adp_shop_id'
,
$user_info
->
adm_shop_id
)
// 如果选择结束时间
->
select
(
'adr_reason'
,
'adr_create_name'
,
'adr_create_time'
,
'adr_rol_name'
)
if
(
!
empty
(
$search_data
[
'create_time_end'
]))
{
->
orderBy
(
'adr_id'
,
'desc'
)
$query
->
where
(
'ord_create_time'
,
'<='
,
$search_data
[
'create_time_end'
]
.
' 23:59:59'
);
->
get
()
->
toArray
();
}
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$list_data
];
}
}
}
})
// 门店经营驾驶舱
->
select
(
'ord_id'
,
'ord_actual_price'
,
'ord_zero_price'
,
'ord_order_price'
,
'ord_service_type'
,
'ord_payment_way'
)
public
static
function
dataCount
(
$user_info
,
$search_data
)
->
get
()
->
toArray
();
{
$ord_order_price
=
0
;
if
(
empty
(
$search_data
[
'create_time_start'
]))
{
$ord_actual_price
=
0
;
$search_data
[
'create_time_start'
]
=
date
(
'Y-m-d'
);
$ord_zero_price
=
0
;
}
$ord_num
=
0
;
if
(
empty
(
$search_data
[
'create_time_end'
]))
{
foreach
(
$list_data
as
$key
=>
$value
)
{
$search_data
[
'create_time_end'
]
=
date
(
'Y-m-d'
);
if
(
in_array
(
$value
->
ord_service_type
,[
1
,
2
,
3
]))
{
}
$ord_order_price
+=
$value
->
ord_order_price
;
$list_data
=
DB
::
table
(
'order'
)
}
->
where
(
'ord_shop_id'
,
$user_info
->
adm_shop_id
)
if
(
in_array
(
$value
->
ord_payment_way
,[
5
,
6
,
7
]))
{
->
where
(
'ord_wor_state'
,
'<>'
,
11
)
$ord_actual_price
+=
$value
->
ord_order_price
;
->
whereIn
(
'ord_service_type'
,
[
1
,
2
,
3
])
}
else
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//创建时间
$ord_actual_price
+=
$value
->
ord_actual_price
;
// 如果选择开始时间并且选择结束时间
}
if
(
!
empty
(
$search_data
[
'create_time_start'
])
&&
!
empty
(
$search_data
[
'create_time_end'
]))
{
$ord_zero_price
+=
$value
->
ord_zero_price
;
$query
->
whereBetween
(
'ord_create_time'
,
[
$search_data
[
'create_time_start'
],
$search_data
[
'create_time_end'
]
.
' 23:59:59'
]);
$ord_num
++
;
}
else
{
}
// 如果选择开始时间
$data
[
'ord_order_price'
]
=
$ord_order_price
;
if
(
!
empty
(
$search_data
[
'create_time_start'
]))
{
$data
[
'ord_actual_price'
]
=
$ord_actual_price
;
$query
->
where
(
'ord_create_time'
,
'>='
,
$search_data
[
'create_time_start'
]);
$data
[
'ord_num'
]
=
$ord_num
;
}
else
{
if
(
$ord_num
>
0
)
{
// 如果选择结束时间
$data
[
'avg_order_amount'
]
=
intval
(
$ord_order_price
/
$ord_num
);
if
(
!
empty
(
$search_data
[
'create_time_end'
]))
{
}
else
{
$query
->
where
(
'ord_create_time'
,
'<='
,
$search_data
[
'create_time_end'
]
.
' 23:59:59'
);
$data
[
'avg_order_amount'
]
=
0
;
}
}
}
$order_goods
=
DB
::
table
(
'order_goods'
)
}
->
leftJoin
(
'order'
,
'ord_id'
,
'='
,
'orgo_ord_id'
)
})
->
where
(
'ord_shop_id'
,
$user_info
->
adm_shop_id
)
->
select
(
'ord_id'
,
'ord_actual_price'
,
'ord_zero_price'
,
'ord_order_price'
,
'ord_service_type'
,
'ord_payment_way'
)
->
where
(
'ord_wor_state'
,
'<>'
,
11
)
->
get
()
->
toArray
();
->
whereIn
(
'orgo_goo_type'
,
[
1
,
2
])
$ord_order_price
=
0
;
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//创建时间
$ord_actual_price
=
0
;
// 如果选择开始时间并且选择结束时间
$ord_zero_price
=
0
;
if
(
!
empty
(
$search_data
[
'create_time_start'
])
&&
!
empty
(
$search_data
[
'create_time_end'
]))
{
$ord_num
=
0
;
$query
->
whereBetween
(
'ord_create_time'
,
[
$search_data
[
'create_time_start'
],
$search_data
[
'create_time_end'
]
.
' 23:59:59'
]);
foreach
(
$list_data
as
$key
=>
$value
)
{
}
else
{
if
(
in_array
(
$value
->
ord_service_type
,[
1
,
2
,
3
]))
{
// 如果选择开始时间
$ord_order_price
+=
$value
->
ord_order_price
;
if
(
!
empty
(
$search_data
[
'create_time_start'
]))
{
}
$query
->
where
(
'ord_create_time'
,
'>='
,
$search_data
[
'create_time_start'
]);
if
(
in_array
(
$value
->
ord_payment_way
,[
5
,
6
,
7
]))
{
}
else
{
$ord_actual_price
+=
$value
->
ord_order_price
;
// 如果选择结束时间
}
else
{
if
(
!
empty
(
$search_data
[
'create_time_end'
]))
{
$ord_actual_price
+=
$value
->
ord_actual_price
;
$query
->
where
(
'ord_create_time'
,
'<='
,
$search_data
[
'create_time_end'
]
.
' 23:59:59'
);
}
}
$ord_zero_price
+=
$value
->
ord_zero_price
;
}
$ord_num
++
;
}
}
})
$data
[
'ord_order_price'
]
=
$ord_order_price
;
->
select
(
DB
::
raw
(
'count(*) as count, orgo_goo_name, sum(orgo_goo_amount) as orgo_goo_amount'
))
$data
[
'ord_actual_price'
]
=
$ord_actual_price
;
->
groupBy
(
'orgo_goo_name'
)
$data
[
'ord_num'
]
=
$ord_num
;
->
orderBy
(
'count'
,
'desc'
)
if
(
$ord_num
>
0
)
{
->
get
()
->
toArray
();
$data
[
'avg_order_amount'
]
=
intval
(
$ord_order_price
/
$ord_num
);
$order_goods_price
=
DB
::
table
(
'order_goods'
)
}
else
{
->
leftJoin
(
'order'
,
'ord_id'
,
'='
,
'orgo_ord_id'
)
$data
[
'avg_order_amount'
]
=
0
;
->
where
(
'ord_shop_id'
,
$user_info
->
adm_shop_id
)
}
->
where
(
'ord_wor_state'
,
'<>'
,
11
)
$order_goods
=
DB
::
table
(
'order_goods'
)
->
whereIn
(
'orgo_goo_type'
,
[
1
,
2
])
->
leftJoin
(
'order'
,
'ord_id'
,
'='
,
'orgo_ord_id'
)
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//创建时间
->
where
(
'ord_shop_id'
,
$user_info
->
adm_shop_id
)
// 如果选择开始时间并且选择结束时间
->
where
(
'ord_wor_state'
,
'<>'
,
11
)
if
(
!
empty
(
$search_data
[
'create_time_start'
])
&&
!
empty
(
$search_data
[
'create_time_end'
]))
{
->
whereIn
(
'orgo_goo_type'
,
[
1
,
2
])
$query
->
whereBetween
(
'ord_create_time'
,
[
$search_data
[
'create_time_start'
],
$search_data
[
'create_time_end'
]
.
' 23:59:59'
]);
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//创建时间
}
else
{
// 如果选择开始时间并且选择结束时间
// 如果选择开始时间
if
(
!
empty
(
$search_data
[
'create_time_start'
])
&&
!
empty
(
$search_data
[
'create_time_end'
]))
{
if
(
!
empty
(
$search_data
[
'create_time_start'
]))
{
$query
->
whereBetween
(
'ord_create_time'
,
[
$search_data
[
'create_time_start'
],
$search_data
[
'create_time_end'
]
.
' 23:59:59'
]);
$query
->
where
(
'ord_create_time'
,
'>='
,
$search_data
[
'create_time_start'
]);
}
else
{
}
else
{
// 如果选择开始时间
// 如果选择结束时间
if
(
!
empty
(
$search_data
[
'create_time_start'
]))
{
if
(
!
empty
(
$search_data
[
'create_time_end'
]))
{
$query
->
where
(
'ord_create_time'
,
'>='
,
$search_data
[
'create_time_start'
]);
$query
->
where
(
'ord_create_time'
,
'<='
,
$search_data
[
'create_time_end'
]
.
' 23:59:59'
);
}
else
{
}
// 如果选择结束时间
}
if
(
!
empty
(
$search_data
[
'create_time_end'
]))
{
}
$query
->
where
(
'ord_create_time'
,
'<='
,
$search_data
[
'create_time_end'
]
.
' 23:59:59'
);
})
}
->
select
(
DB
::
raw
(
'orgo_goo_name, sum(orgo_goo_amount) as orgo_goo_amount'
))
}
->
groupBy
(
'orgo_goo_name'
)
}
->
orderBy
(
'orgo_goo_amount'
,
'desc'
)
})
->
orderBy
(
'orgo_goo_name'
,
'desc'
)
->
select
(
DB
::
raw
(
'count(*) as count, orgo_goo_name, sum(orgo_goo_amount) as orgo_goo_amount'
))
->
get
()
->
toArray
();
->
groupBy
(
'orgo_goo_name'
)
$other_count
=
0
;
->
orderBy
(
'count'
,
'desc'
)
$goo_num
=
0
;
->
get
()
->
toArray
();
$data
[
'order_goods_data'
]
=
[];
$order_goods_price
=
DB
::
table
(
'order_goods'
)
foreach
(
$order_goods
as
$key
=>
$value
)
{
->
leftJoin
(
'order'
,
'ord_id'
,
'='
,
'orgo_ord_id'
)
if
(
$key
>
3
)
{
->
where
(
'ord_shop_id'
,
$user_info
->
adm_shop_id
)
$other_count
+=
$value
->
count
;
->
where
(
'ord_wor_state'
,
'<>'
,
11
)
$goo_num
=
4
;
->
whereIn
(
'orgo_goo_type'
,
[
1
,
2
])
}
else
{
->
where
(
function
(
$query
)
use
(
$search_data
)
{
//创建时间
$data
[
'order_goods_data'
][
$key
][
'name'
]
=
$value
->
orgo_goo_name
;
// 如果选择开始时间并且选择结束时间
$data
[
'order_goods_data'
][
$key
][
'count'
]
=
$value
->
count
;
if
(
!
empty
(
$search_data
[
'create_time_start'
])
&&
!
empty
(
$search_data
[
'create_time_end'
]))
{
$goo_num
=
$key
+
1
;
$query
->
whereBetween
(
'ord_create_time'
,
[
$search_data
[
'create_time_start'
],
$search_data
[
'create_time_end'
]
.
' 23:59:59'
]);
}
}
else
{
}
// 如果选择开始时间
if
(
$other_count
>
0
)
{
if
(
!
empty
(
$search_data
[
'create_time_start'
]))
{
$data
[
'order_goods_data'
][
$goo_num
][
'name'
]
=
'其它'
;
$query
->
where
(
'ord_create_time'
,
'>='
,
$search_data
[
'create_time_start'
]);
$data
[
'order_goods_data'
][
$goo_num
][
'count'
]
=
$other_count
;
}
else
{
}
// 如果选择结束时间
$orgo_goo_amount
=
0
;
if
(
!
empty
(
$search_data
[
'create_time_end'
]))
{
$goo_num
=
0
;
$query
->
where
(
'ord_create_time'
,
'<='
,
$search_data
[
'create_time_end'
]
.
' 23:59:59'
);
$data
[
'order_goods_price'
]
=
[];
}
foreach
(
$order_goods_price
as
$key
=>
$value
)
{
}
if
(
$key
>
3
)
{
}
$orgo_goo_amount
+=
$value
->
orgo_goo_amount
;
})
$goo_num
=
4
;
->
select
(
DB
::
raw
(
'orgo_goo_name, sum(orgo_goo_amount) as orgo_goo_amount'
))
}
else
{
->
groupBy
(
'orgo_goo_name'
)
$data
[
'order_goods_price'
][
$key
][
'name'
]
=
$value
->
orgo_goo_name
;
->
orderBy
(
'orgo_goo_amount'
,
'desc'
)
$data
[
'order_goods_price'
][
$key
][
'count'
]
=
$value
->
orgo_goo_amount
;
->
orderBy
(
'orgo_goo_name'
,
'desc'
)
$goo_num
=
$key
+
1
;
->
get
()
->
toArray
();
}
$other_count
=
0
;
}
$goo_num
=
0
;
if
(
$orgo_goo_amount
>
0
)
{
$data
[
'order_goods_data'
]
=
[];
$data
[
'order_goods_price'
][
$goo_num
][
'name'
]
=
'其它'
;
foreach
(
$order_goods
as
$key
=>
$value
)
{
$data
[
'order_goods_price'
][
$goo_num
][
'count'
]
=
$orgo_goo_amount
;
if
(
$key
>
3
)
{
}
$other_count
+=
$value
->
count
;
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
$goo_num
=
4
;
}
}
else
{
$data
[
'order_goods_data'
][
$key
][
'name'
]
=
$value
->
orgo_goo_name
;
// 门店经营驾驶舱-销售额
$data
[
'order_goods_data'
][
$key
][
'count'
]
=
$value
->
count
;
public
static
function
salesVolume
(
$user_info
,
$request
)
$goo_num
=
$key
+
1
;
{
}
if
(
$request
[
'type'
]
==
1
)
{
//日销售
}
if
(
empty
(
$request
[
'time'
]))
{
if
(
$other_count
>
0
)
{
$request
[
'time'
]
=
date
(
'Y-m'
);
$data
[
'order_goods_data'
][
$goo_num
][
'name'
]
=
'其它'
;
}
$data
[
'order_goods_data'
][
$goo_num
][
'count'
]
=
$other_count
;
$days
=
date
(
"t"
,
strtotime
(
$request
[
'time'
]));
}
$data
=
[];
$orgo_goo_amount
=
0
;
$date
=
$request
[
'time'
]
.
'-01'
;
$goo_num
=
0
;
for
(
$i
=
0
;
$i
<
$days
;
$i
++
)
{
$data
[
'order_goods_price'
]
=
[];
if
(
$i
>
0
)
{
foreach
(
$order_goods_price
as
$key
=>
$value
)
{
$date
=
date
(
'Y-m-d'
,
strtotime
(
$date
)
+
60
*
60
*
24
);
if
(
$key
>
3
)
{
}
$orgo_goo_amount
+=
$value
->
orgo_goo_amount
;
$data
[
$i
][
'date'
]
=
$date
;
$goo_num
=
4
;
$data
[
$i
][
'ord_order_price'
]
=
DB
::
table
(
'order'
)
}
else
{
->
where
(
'ord_shop_id'
,
$user_info
->
adm_shop_id
)
$data
[
'order_goods_price'
][
$key
][
'name'
]
=
$value
->
orgo_goo_name
;
->
where
(
'ord_wor_state'
,
'<>'
,
11
)
$data
[
'order_goods_price'
][
$key
][
'count'
]
=
$value
->
orgo_goo_amount
;
->
whereIn
(
'ord_service_type'
,
[
1
,
2
,
3
])
$goo_num
=
$key
+
1
;
->
where
(
'ord_create_time'
,
'>='
,
$date
)
}
->
where
(
'ord_create_time'
,
'<='
,
$date
.
' 23:59:59'
)
}
->
sum
(
'ord_order_price'
);
if
(
$orgo_goo_amount
>
0
)
{
}
$data
[
'order_goods_price'
][
$goo_num
][
'name'
]
=
'其它'
;
}
$data
[
'order_goods_price'
][
$goo_num
][
'count'
]
=
$orgo_goo_amount
;
}
if
(
$request
[
'type'
]
==
2
)
{
//月销售
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
if
(
empty
(
$request
[
'time'
]))
{
}
$request
[
'time'
]
=
date
(
'Y'
);
}
// 门店经营驾驶舱-销售额
$date
=
$request
[
'time'
]
.
'-01-01'
;
public
static
function
salesVolume
(
$user_info
,
$request
)
for
(
$i
=
0
;
$i
<
12
;
$i
++
)
{
{
$next_date
=
date
(
'Y-m-d'
,
strtotime
(
'+1 month'
,
strtotime
(
$date
)));
if
(
$request
[
'type'
]
==
1
)
{
//日销售
$data
[
$i
][
'date'
]
=
date
(
'Y-m'
,
strtotime
(
$date
));
if
(
empty
(
$request
[
'time'
]))
{
$data
[
$i
][
'ord_order_price'
]
=
DB
::
table
(
'order'
)
$request
[
'time'
]
=
date
(
'Y-m'
);
->
where
(
'ord_shop_id'
,
$user_info
->
adm_shop_id
)
}
->
where
(
'ord_wor_state'
,
'<>'
,
11
)
$days
=
date
(
"t"
,
strtotime
(
$request
[
'time'
]));
->
whereIn
(
'ord_service_type'
,
[
1
,
2
,
3
])
$data
=
[];
->
where
(
'ord_create_time'
,
'>='
,
$date
)
$date
=
$request
[
'time'
]
.
'-01'
;
->
where
(
'ord_create_time'
,
'<'
,
$next_date
)
for
(
$i
=
0
;
$i
<
$days
;
$i
++
)
{
->
sum
(
'ord_order_price'
);
if
(
$i
>
0
)
{
$date
=
$next_date
;
$date
=
date
(
'Y-m-d'
,
strtotime
(
$date
)
+
60
*
60
*
24
);
}
}
}
$data
[
$i
][
'date'
]
=
$date
;
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
$data
[
$i
][
'ord_order_price'
]
=
DB
::
table
(
'order'
)
}
->
where
(
'ord_shop_id'
,
$user_info
->
adm_shop_id
)
}
->
where
(
'ord_wor_state'
,
'<>'
,
11
)
->
whereIn
(
'ord_service_type'
,
[
1
,
2
,
3
])
->
where
(
'ord_create_time'
,
'>='
,
$date
)
->
where
(
'ord_create_time'
,
'<='
,
$date
.
' 23:59:59'
)
->
sum
(
'ord_order_price'
);
}
}
if
(
$request
[
'type'
]
==
2
)
{
//月销售
if
(
empty
(
$request
[
'time'
]))
{
$request
[
'time'
]
=
date
(
'Y'
);
}
$date
=
$request
[
'time'
]
.
'-01-01'
;
for
(
$i
=
0
;
$i
<
12
;
$i
++
)
{
$next_date
=
date
(
'Y-m-d'
,
strtotime
(
'+1 month'
,
strtotime
(
$date
)));
$data
[
$i
][
'date'
]
=
date
(
'Y-m'
,
strtotime
(
$date
));
$data
[
$i
][
'ord_order_price'
]
=
DB
::
table
(
'order'
)
->
where
(
'ord_shop_id'
,
$user_info
->
adm_shop_id
)
->
where
(
'ord_wor_state'
,
'<>'
,
11
)
->
whereIn
(
'ord_service_type'
,
[
1
,
2
,
3
])
->
where
(
'ord_create_time'
,
'>='
,
$date
)
->
where
(
'ord_create_time'
,
'<'
,
$next_date
)
->
sum
(
'ord_order_price'
);
$date
=
$next_date
;
}
}
return
[
'code'
=>
200
,
'msg'
=>
'success'
,
'data'
=>
$data
];
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论