Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
cf05fd0060
app/middleapi/controller
97
app/middleapi/controller/AccountLogController.php
Normal file
97
app/middleapi/controller/AccountLogController.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace app\middleapi\controller;
|
||||
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use app\common\model\user\UserRole;
|
||||
use app\common\service\FileService;
|
||||
use app\common\controller\BaseLikeAdminController;
|
||||
|
||||
/***
|
||||
* 账户流水控制器
|
||||
* Class AccountLogController
|
||||
* @package app\adminapi\controller
|
||||
*/
|
||||
class AccountLogController extends BaseLikeAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 账户流水明细
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 15:25
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['page_no','page_size', 'start_time', 'end_time', 'type','company_id']);
|
||||
$where = [];
|
||||
if (isset($params['type']) && $params['type'] == 'um') {
|
||||
$where[] = ['change_type', 'in', AccountLogEnum::getUserMoneyChangeType()];
|
||||
}
|
||||
if (!empty($params['company_id'])) {
|
||||
$where[] = ['company_id', '=', $params['company_id']];
|
||||
}
|
||||
if (!empty($params['start_time'])) {
|
||||
$where[] = ['create_time', '>=', strtotime($params['start_time'])];
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$where[] = ['create_time', '<=', strtotime($params['end_time'])];
|
||||
}
|
||||
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
|
||||
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
|
||||
$lists = UserAccountLog::where($where)
|
||||
->with(['company_info','user_info'])
|
||||
->order('id', 'desc')
|
||||
->page($pageNo, $pageSize)
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($lists as &$item) {
|
||||
$item['user_info']['avatar'] = FileService::getFileUrl($item['user_info']['avatar']);
|
||||
$item['user_info']['group_name']=UserRole::where('id',$item['user_info']['group_id'])->value('name');
|
||||
$item['change_type_desc'] = AccountLogEnum::getChangeTypeDesc($item['change_type']);
|
||||
$symbol = $item['action'] == AccountLogEnum::INC ? '+' : '-';
|
||||
$item['change_amount'] = $symbol . $item['change_amount'];
|
||||
// 用于导出
|
||||
$item['user_info_sn'] = $item['user_info']['sn'];
|
||||
$item['company_info_company_name'] = $item['company_info']['company_name'];
|
||||
$item['user_info_nickname'] = $item['user_info']['nickname'];
|
||||
$item['user_info_group_name'] = $item['user_info']['group_name'];
|
||||
$item['user_info_mobile'] = $item['user_info']['mobile'];
|
||||
}
|
||||
$count = UserAccountLog::where($where)->count();
|
||||
$result = [
|
||||
'lists' => $lists,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
];
|
||||
return $this->success('请求成功',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 用户余额变动类型
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2023/2/24 15:25
|
||||
*/
|
||||
public function getUmChangeType()
|
||||
{
|
||||
return $this->data(AccountLogEnum::getUserMoneyChangeTypeDesc());
|
||||
}
|
||||
|
||||
public function getCompanyUserList()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$companyId = $param['company_id'] ?? 0;
|
||||
$userList = User::where(['company_id' => $companyId])->field('id,nickname,avatar,sn,mobile,group_id,deposit,income')->select()->toArray();
|
||||
return $this->success('成功', $userList);
|
||||
}
|
||||
|
||||
}
|
@ -272,4 +272,59 @@
|
||||
->toArray();
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
public function responsibleArea(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['key','value','company_type']);
|
||||
if (empty($params['key']) || empty($params['value']) || empty($params['company_type'])) {
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
if ($params['key'] == 'city') {
|
||||
$where[] = ['area', '=', 0];
|
||||
}
|
||||
if ($params['value'] == '') {
|
||||
return $this->fail('参数不能为空');
|
||||
}
|
||||
$where[] = [$params['key'], '=', $params['value']];
|
||||
$where[] = ['company_type', '=', $params['company_type']];
|
||||
switch ($params['key']) {
|
||||
case 'city':
|
||||
// $geo_area=Db::name('geo_area')->where('city_code', '=', $parmas['value'])->column('area_code');
|
||||
// $where[] = ['area', 'in', $geo_area];
|
||||
break;
|
||||
case 'area':
|
||||
$street_code = Db::name('geo_street')->where('area_code', '=', $params['value'])->column('street_code');
|
||||
$where[] = ['street', 'in', $street_code];
|
||||
$where[] = ['village', '=', 0];
|
||||
break;
|
||||
case 'street':
|
||||
$street_code = Db::name('geo_village')->where('street_code', '=', $params['value'])->column('village_code');
|
||||
$where[] = ['village', 'in', $street_code];
|
||||
$where[] = ['brigade', '=', 0];
|
||||
break;
|
||||
case 'village':
|
||||
// $street_code = Db::name('geo_brigade')->where('street_code', '=', $parmas['value'])->column('village_code');
|
||||
$where[] = ['village', '=', $params['value']];
|
||||
// $where[] = ['brigade', '=', 0];
|
||||
break;
|
||||
}
|
||||
|
||||
$res = Company::where($where)->column('responsible_area');
|
||||
|
||||
foreach ($res as $k => $v) {
|
||||
$res[$k] = explode(',', $v);
|
||||
}
|
||||
$data = [];
|
||||
foreach ($res as $k => $v) {
|
||||
foreach ($v as $kk => $vv) {
|
||||
if ($vv != '') {
|
||||
$data[] = $vv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success('success', array_unique($data));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user