12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php namespace App\Http\Controllers\Admin;
- use App\Facades\Servers\WechatMini\Mini;
- use App\Models\RecruitmentRecord as Model;
- use App\Models\Custom;
- use App\Models\RecruitmentActive;
- use function PHPUnit\Framework\isNull;
- /**
- * 拉新活动
- *
- * @author 刘相欣
- *
- */
- class RecruitmentRecord extends Auth{
-
- protected function _initialize(){
- parent::_initialize();
- $this->assign('breadcrumb1','拉新活动');
- $this->assign('breadcrumb2','活动数据列表');
- }
- /**
- * 列表页
- *
- * */
- public function index(Model $Model,Custom $Custom,RecruitmentActive $RecruitmentActive){
- // 接收参数
- $code = request('code','');
- $old_uid_code = request('old_uid_code','');
- $new_uid_code = request('new_uid_code','');
- $start_time = request('start_time','');
- $end_time = request('end_time','');
- // 查询条件
- $map = [];
- // 组合条件
- if( $code ) {
- $activeId = $RecruitmentActive->codeToId($code);
- $map[] = ['active_id','=',$activeId];
- }
- if( $old_uid_code ) {
- $old_uid = $Custom->codeToId($old_uid_code);
- $map[] = ['old_uid','=',$old_uid];
- }
- if( $new_uid_code ) {
- $new_uid = $Custom->codeToId($new_uid_code);
- $map[] = ['new_uid','=',$new_uid];
- }
- if( $start_time ) {
- $start_time = strtotime($start_time);
- $map[] = ['insert_time','>=',$start_time];
- }
- if( $end_time ) {
- $end_time = strtotime($end_time);
- $map[] = ['insert_time','<=',$end_time];
- }
- // 查询数据
- $list = $Model->query()->where($map)->orderByDesc('id')->paginate(config('page_num',10));
- // 循环处理数据
- foreach ($list as $key => $value) {
- if( $value['old_uid'] ) {
- $oldCustom = $Custom->getOne($value['old_uid']);
- if ($oldCustom){
- $value['old_name'] = $oldCustom['username'];
- $value['old_uid_code'] = $Custom->idToCode($oldCustom['uid']);
- }
- }
- if( $value['new_uid'] ) {
- $oldCustom = $Custom->getOne($value['new_uid']);
- if ($oldCustom){
- $value['new_name'] = $oldCustom['username'];
- $value['new_uid_code'] = $Custom->idToCode($oldCustom['uid']);
- }
- }
- if ($value['active_id']){
- $value['active_id_code'] = $RecruitmentActive->idToCode($value['active_id']);
- $value['active_name'] = $RecruitmentActive::query()->where('id','=',$value['active_id'])->value('name');
- }
- // 重组
- $list[$key] = $value;
- }
- // 分配数据
- $this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
- $this->assign('list',$list);
- // 加载模板
- return $this->fetch();
- }
- }
|