Commit f2f7ae2f by 朱继来

调整db

parent aecbf32a
......@@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model;
class InvoiceComUserModel extends Model
{
protected $connection = 'order';
protected $connection = 'web';
protected $table = 'lie_invoice_com_user';
protected $guarded = ['id'];
protected $primaryKey = 'id';
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class UserAmountModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_user_amount';
protected $guarded = ['amount_id'];
protected $primaryKey = 'amount_id';
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
public function fromDateTime($value)
{
return strtotime(parent::fromDateTime($value));
}
// 获取排名前十的用户总额
public function getUserAmount()
{
return $this->select('amount_id', 'user_id', 'account', 'amount')->orderBy('amount', 'desc')->take(10)->get()->toArray();
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class UserAmountModel extends Model
{
protected $connection = 'web';
protected $table = 'lie_user_amount';
protected $guarded = ['amount_id'];
protected $primaryKey = 'amount_id';
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
public function fromDateTime($value)
{
return strtotime(parent::fromDateTime($value));
}
// 获取排名前十的用户总额
public function getUserAmount()
{
return $this->select('amount_id', 'user_id', 'account', 'amount')->orderBy('amount', 'desc')->take(10)->get()->toArray();
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
class UserGroupJoinModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_user_group_join';
protected $primaryKey = 'id';
public $timestamps = false;
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
class UserGroupJoinModel extends Model
{
protected $connection = 'web';
protected $table = 'lie_user_group_join';
protected $primaryKey = 'id';
public $timestamps = false;
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class UserGroupModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_user_group';
protected $primaryKey = 'id';
protected $guarded = ['id'];
public $timestamps = false;
// 获取客服
public function lists($request, $export='')
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$map['account'] = $request->input('account', ''); // 用户账号
$map['status'] = $request->input('status', ''); // 状态
$map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$list = $this->where(function($query) use ($map) {
// 客服名称
if ($map['account']) {
$query->where('account', 'like', $map['account'].'%');
}
})->where(function($query) use ($map) {
// 邮箱
if ($map['status']) {
$query->where('status', '=', $map['status']);
}
})->where(function($query) use ($map) {
// 创建时间
if(!empty($map['begin_time']) && !empty($map['end_time'])) {
$query->whereBetween('create_time', [$map['begin_time'], $map['end_time']]);
}
else if(!empty($map['begin_time'])) {
$query->where('create_time', '>=', $map['begin_time']);
}
else if(!empty($map['end_time'])) {
$query->where('create_time', '<=', $map['end_time']);
}
})
->orderBy('create_time', 'desc')
->orderBy('id', 'desc');
if ($export) {
$list = $list->get()->toArray();
if (empty($list)) {
echo '<script>alert("导出数据为空");history.go(-1);</script>';die;
}
return $list;
} else {
$list = $list->paginate($limit, ['*'], 'page', $page)->toArray();
$data = $this->handle($list['data']);
return [0, '获取成功', $data, $list['total']];
}
}
// 处理数据
public function handle($data)
{
if (!$data) return false;
$UserGroupJoinModel = new UserGroupJoinModel();
foreach ($data as &$v) {
// 若已参团,且非系统分配,则查询参团表
if ($v['status'] == 1) {
$join = $UserGroupJoinModel->where('group_id', $v['id'])->first();
$v['join_user_id'] = $join['user_id'];
$v['join_account'] = $join['account'];
$v['join_order_id'] = $join['order_id'];
$v['join_order_sn'] = $join['order_sn'];
$v['join_time'] = date('Y-m-d H:i:s', $join['join_time']);
} else {
$v['join_user_id'] = '';
$v['join_account'] = '';
$v['join_order_id'] = '';
$v['join_order_sn'] = '';
$v['join_time'] = '';
}
$v['limited_time'] = $v['limited_time'] ? date('Y-m-d H:i:s', $v['limited_time']) : '';
$v['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
}
return $data;
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class UserGroupModel extends Model
{
protected $connection = 'web';
protected $table = 'lie_user_group';
protected $primaryKey = 'id';
protected $guarded = ['id'];
public $timestamps = false;
// 获取客服
public function lists($request, $export='')
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$map['account'] = $request->input('account', ''); // 用户账号
$map['status'] = $request->input('status', ''); // 状态
$map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$list = $this->where(function($query) use ($map) {
// 客服名称
if ($map['account']) {
$query->where('account', 'like', $map['account'].'%');
}
})->where(function($query) use ($map) {
// 邮箱
if ($map['status']) {
$query->where('status', '=', $map['status']);
}
})->where(function($query) use ($map) {
// 创建时间
if(!empty($map['begin_time']) && !empty($map['end_time'])) {
$query->whereBetween('create_time', [$map['begin_time'], $map['end_time']]);
}
else if(!empty($map['begin_time'])) {
$query->where('create_time', '>=', $map['begin_time']);
}
else if(!empty($map['end_time'])) {
$query->where('create_time', '<=', $map['end_time']);
}
})
->orderBy('create_time', 'desc')
->orderBy('id', 'desc');
if ($export) {
$list = $list->get()->toArray();
if (empty($list)) {
echo '<script>alert("导出数据为空");history.go(-1);</script>';die;
}
return $list;
} else {
$list = $list->paginate($limit, ['*'], 'page', $page)->toArray();
$data = $this->handle($list['data']);
return [0, '获取成功', $data, $list['total']];
}
}
// 处理数据
public function handle($data)
{
if (!$data) return false;
$UserGroupJoinModel = new UserGroupJoinModel();
foreach ($data as &$v) {
// 若已参团,且非系统分配,则查询参团表
if ($v['status'] == 1) {
$join = $UserGroupJoinModel->where('group_id', $v['id'])->first();
$v['join_user_id'] = $join['user_id'];
$v['join_account'] = $join['account'];
$v['join_order_id'] = $join['order_id'];
$v['join_order_sn'] = $join['order_sn'];
$v['join_time'] = date('Y-m-d H:i:s', $join['join_time']);
} else {
$v['join_user_id'] = '';
$v['join_account'] = '';
$v['join_order_id'] = '';
$v['join_order_sn'] = '';
$v['join_time'] = '';
}
$v['limited_time'] = $v['limited_time'] ? date('Y-m-d H:i:s', $v['limited_time']) : '';
$v['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
}
return $data;
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class UserInfoModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_user_info';
protected $primaryKey = 'ui_id';
public $timestamps = false;
// 获取用户样片领取机会
public function getUserApplyCount($user_id)
{
$user_info = $this->where('user_id', $user_id)->select('apply_count')->first();
if (!$user_info) return 0;
return $user_info->apply_count;
}
// 获取用户职务
public function getWorkFunction($user_id)
{
$work_function = $this->where('user_id', $user_id)->value('work_function');
if (!$work_function) return '';
$work_function_val = Config('params.work_function');
return isset($work_function_val[$work_function]) ? $work_function_val[$work_function] : '';
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class UserInfoModel extends Model
{
protected $connection = 'web';
protected $table = 'lie_user_info';
protected $primaryKey = 'ui_id';
public $timestamps = false;
// 获取用户样片领取机会
public function getUserApplyCount($user_id)
{
$user_info = $this->where('user_id', $user_id)->select('apply_count')->first();
if (!$user_info) return 0;
return $user_info->apply_count;
}
// 获取用户职务
public function getWorkFunction($user_id)
{
$work_function = $this->where('user_id', $user_id)->value('work_function');
if (!$work_function) return '';
$work_function_val = Config('params.work_function');
return isset($work_function_val[$work_function]) ? $work_function_val[$work_function] : '';
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ use DB;
class UserSampleApplyModel extends Model
{
protected $connection = 'order';
protected $connection = 'web';
protected $table = 'lie_user_sample_apply';
protected $primaryKey = 'apply_id';
public $timestamps = true;
......
......@@ -8,7 +8,7 @@ use DB;
class UserSampleInviteModel extends Model
{
protected $connection = 'order';
protected $connection = 'web';
protected $table = 'lie_user_sample_invite';
protected $primaryKey = 'invite_id';
public $timestamps = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment