123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950 |
- <?php
- namespace app\admin\controller\send\user;
- use app\admin\model\SendChannelMessage;
- use app\admin\model\SendUserGroup;
- use app\admin\model\SendUserGroupExtend;
- use app\admin\validate\SpecialRechargeUrl;
- use app\common\controller\Backend;
- use app\main\constants\AdminConstants;
- use app\main\service\AdminService;
- use think\Controller;
- use think\Request;
- /**
- * 群发消息-用户组管理
- *
- * @icon fa fa-circle-o
- */
- class Group extends Backend
- {
- protected $noNeedRight = ['detail', 'idimport'];
- /**
- * SendUserGroup模型对象
- */
- protected $model = null;
- /**
- * SendUserGroupExtend
- */
- protected $userGroupExtendModel = null;
- public function _initialize()
- {
- parent::_initialize();
- if($this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_AGENT)){
- $is_distributor = AdminService::instance()->checkAdminIsDistributor($this->auth->id);
- // 如果登录用户仅仅是代理商,不是配号代理商
- if (!$is_distributor) {
- $this->error('您没有访问权限');
- }
- }
- /**
- * @var SendUserGroup
- */
- $this->model = model('SendUserGroup');
- /**
- * @var SendUserGroupExtend
- */
- $this->userGroupExtendModel = model('SendUserGroupExtend');
- $this->view->assign('typeList', $this->model->getTypeList());
- $this->view->assign('userCate', $this->model->getUserCate());
- $this->view->assign('mobileSystem', $this->model->getMobileSystem());
- $this->view->assign('userSex', $this->model->getUserSex());
- $this->view->assign('baseType', $this->model->getBaseType());
- $this->view->assign('vipType', $this->model->getVipType());
- $this->view->assign('rechargeProperty', $this->model->getRechargeProperty());
- $this->view->assign('rechargeType', $this->model->getRechargeType());
- $this->view->assign('readProperty', $this->model->getReadProperty());
- $this->view->assign('consumerProperty', $this->model->getConsumerProperty());
- $this->view->assign('readType', $this->model->getReadType());
- $this->view->assign('readRecordType', $this->model->getReadRecordType());
- }
- /**
- * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法
- * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑
- * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
- */
- /**
- * 查看
- */
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax())
- {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('pkey_name'))
- {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $map = ['is_del' => 0, 'create_by' => $this->auth->id];
- $total = $this->model
- ->where($where)
- ->where($map)
- ->order($sort, $order)
- ->count();
- $list = $this->model
- ->where($where)
- ->where($map)
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * 添加
- */
- public function add()
- {
- $selcted_categories = [];
- $this->assign('selcted_categories', $selcted_categories);
- $selcted_consumer_categories = [];
- $this->assign('selcted_consumer_categories', $selcted_consumer_categories);
- if ($this->request->isPost())
- {
- $params = $this->request->post("row/a");
- if ($params)
- {
- /*
- * 已经弃用,如果为了兼容老版可取消注释
- foreach ($params as $k => &$v)
- {
- $v = is_array($v) ? implode(',', $v) : $v;
- }
- */
- if ($this->dataLimit)
- {
- $params[$this->dataLimitField] = $this->auth->id;
- }
- try
- {
- //是否采用模型验证
- if ($this->modelValidate)
- {
- $name = basename(str_replace('\\', '/', get_class($this->model)));
- $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate;
- $this->model->validate($validate);
- }
- if(empty($params['group_name'])){
- $this->error('用户集合名词不能为空');
- }
- $group_type = $params['group_type'];
- if($group_type == 0){
- //全部用户
- $data = [];
- $data['group_name'] = $params['group_name'];
- $data['group_type'] = $params['group_type'];
- $data['create_by'] = $this->auth->id;
- $data['edit_by'] = $this->auth->id;
- $result = $this->model->allowField(true)->save($data);
- }elseif ($group_type == 1){
- //自定义
- $data = [];
- $data['group_name'] = $params['group_name'];
- $data['group_type'] = $params['group_type'];
- $user_ids = $this->arr_uni_str($params['user_ids']);
- if (empty($user_ids)) {
- $this->error('用户ID不能为空');
- } elseif (count(explode(',', $user_ids)) < 2) {
- $this->error('用户ID最少填写两个');
- }
- $data['create_by'] = $this->auth->id;
- $data['edit_by'] = $this->auth->id;
- $rst = $this->model->allowField(true)->save($data);
- if ($rst) {
- $send_user_group_id = $this->model->id;
- $send_extend_data = [
- 'user_group_id' => $send_user_group_id,
- 'user_ids' => $user_ids,
- 'create_by' => $this->auth->id,
- 'edit_by' => $this->auth->id
- ];
- $result = $this->userGroupExtendModel->allowField(true)->save($send_extend_data);
- }else{
- $result = false;
- }
- }else{
- //条件筛选
- $data = [];
- $data['group_name'] = $params['group_name'];
- $data['group_type'] = $params['group_type'];
- unset($params['group_name']);
- unset($params['group_type']);
- unset($params['user_ids']);
- if(!isset($params['vipType'])){
- $params['vipType'] = '';
- }
- if(!isset($params['rechargeType'])){
- $params['rechargeType'] = '';
- }
- if(!isset($params['readType'])){
- $params['readType'] = '';
- }
- //重构 $params
- $this->restruct_params($params);
- //
- $this->filterFromParams($params);
- // 校验表单
- $this->validateForm($params);
- if($params['userSex'] == -1){
- $params['userSex'] = '';
- }
- $params['read_book_categories'] = implode(',', array_unique(array_filter(explode(',', $params['read_book_categories']))));
- //$params['consumer_book_categories'] = implode(',', array_unique(array_filter(explode(',', $params['consumer_book_categories']))));
- $user_json = json_encode($params);
- $data['user_json'] = $user_json;
- $data['create_by'] = $this->auth->id;
- $data['edit_by'] = $this->auth->id;
- $result = $this->model->allowField(true)->save($data);
- }
- if ($result !== false)
- {
- $this->success();
- }
- else
- {
- $this->error($this->model->getError());
- }
- }
- catch (\think\exception\PDOException $e)
- {
- $this->error($e->getMessage());
- }
- }
- $this->error(__('Parameter %s can not be empty', ''));
- }
- return $this->view->fetch();
- }
- /**
- * 编辑
- */
- public function edit($ids = NULL)
- {
- $row = $this->model->get($ids);
- if (!$row)
- $this->error(__('No Results were found'));
- $adminIds = $this->getDataLimitAdminIds();
- if (is_array($adminIds))
- {
- if (!in_array($row[$this->dataLimitField], $adminIds))
- {
- $this->error(__('You have no permission'));
- }
- }
- if ($this->request->isPost())
- {
- $params = $this->request->post("row/a");
- if ($params)
- {
- /*
- * 已经弃用,如果为了兼容老版可取消注释
- foreach ($params as $k => &$v)
- {
- $v = is_array($v) ? implode(',', $v) : $v;
- }
- */
- try
- {
- //是否采用模型验证
- if ($this->modelValidate)
- {
- $name = basename(str_replace('\\', '/', get_class($this->model)));
- $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate;
- $row->validate($validate);
- }
- if(empty($params['group_name'])){
- $this->error('用户集合名词不能为空');
- }
- $group_type = $params['group_type'];
- if($group_type == 0){
- //全部用户
- $data = [];
- $data['group_name'] = $params['group_name'];
- $data['group_type'] = $params['group_type'];
- $data['edit_by'] = $this->auth->id;
- $result = $this->model->allowField(true)->update($data, ['id'=>$ids]);
- }elseif ($group_type == 1){
- //自定义
- $data = [];
- $data['group_name'] = $params['group_name'];
- $data['group_type'] = $params['group_type'];
- $user_ids = trim($this->arr_uni_str($params['user_ids']));
- if (empty($user_ids)) {
- $this->error('用户ID不能为空');
- } elseif (count(explode(',', $user_ids)) < 2) {
- $this->error('用户ID最少填写两个');
- }
- $data['edit_by'] = $this->auth->id;
- $rst = $this->model->allowField(true)->update($data, ['id'=>$ids]);
- if ($rst) {
- $send_extend_data = [
- 'user_ids' => $user_ids,
- 'edit_by' => $this->auth->id
- ];
- $result = $this->userGroupExtendModel->where(['user_group_id' => $ids])->update($send_extend_data);
- }else{
- $result = false;
- }
- }else{
- //条件筛选
- $data = [];
- $data['group_name'] = $params['group_name'];
- $data['group_type'] = $params['group_type'];
- unset($params['group_name']);
- unset($params['group_type']);
- unset($params['user_ids']);
- if(!isset($params['vipType'])){
- $params['vipType'] = '';
- }
- if(!isset($params['rechargeType'])){
- $params['rechargeType'] = '';
- }
- if(!isset($params['readType'])){
- $params['readType'] = '';
- }
- $params['read_book_categories'] = implode(',', array_unique(array_filter(explode(',', $params['read_book_categories']))));
- //$params['consumer_book_categories'] = implode(',', array_unique(array_filter(explode(',', $params['consumer_book_categories']))));
- //
- $this->filterFromParams($params);
- // 校验表单
- $this->validateForm($params);
- if($params['userSex'] == -1){
- $params['userSex'] = '';
- }
- $user_json = json_encode($params);
- $data['user_json'] = $user_json;
- $data['edit_by'] = $this->auth->id;
- $result = $this->model->allowField(true)->update($data, ['id'=>$ids]);
- }
- //$result = $row->allowField(true)->save($params);
- if ($result !== false)
- {
- $this->success();
- }
- else
- {
- $this->error($row->getError());
- }
- }
- catch (\think\exception\PDOException $e)
- {
- $this->error($e->getMessage());
- }
- }
- $this->error(__('Parameter %s can not be empty', ''));
- }
- if($row['group_type'] == 2){
- $user_json = json_decode($row['user_json'], true);
- $this->restruct_params($user_json);
- }else{
- $user_json = $this->initUserJson();
- }
- if(!empty($user_json['read_book_categories'])){
- $read_book_categories = model('BookCategory')->where('id', 'in', $user_json['read_book_categories'])->select();
- }else{
- $read_book_categories = [];
- }
- if($row['group_type'] === 1){
- $extend_data = $this->userGroupExtendModel->where(['user_group_id' => $row['id']])->find();
- $row['user_ids'] = $extend_data->user_ids ?? '';
- }
- if(!isset($user_json['userSex']) || $user_json['userSex'] === ''){
- $user_json['userSex'] = -1;
- }
- $all_property = $this->initUserJson();
- $user_json = array_merge($all_property, $user_json);
- $this->view->assign('read_book_categories', $read_book_categories);
- $this->view->assign('user_json',$user_json);
- $this->view->assign("row", $row);
- return $this->view->fetch();
- }
- /**
- * 删除
- */
- public function del($ids = "")
- {
- if ($ids)
- {
- $pk = $this->model->getPk();
- $adminIds = $this->getDataLimitAdminIds();
- if (is_array($adminIds))
- {
- $count = $this->model->where($this->dataLimitField, 'in', $adminIds);
- }
- $list = $this->model->where($pk, 'in', $ids)->select();
- $count = 0;
- foreach ($list as $k => $v)
- {
- $count += $v->where(['id'=>$v->id])->update(['is_del'=>1]);
- //$count += $v->delete();
- }
- if ($count)
- {
- $this->success();
- }
- else
- {
- $this->error(__('No rows were deleted'));
- }
- }
- $this->error(__('Parameter %s can not be empty', 'ids'));
- }
- /**
- * 详情页面
- * @param $ids
- * @return string
- * @throws \think\Exception
- */
- public function detail($ids)
- {
- $row = $this->model->get($ids);
- if ($row['group_type'] == 2) {
- $user_json = json_decode($row['user_json'], true);
- $this->restruct_params($user_json);
- } else {
- $user_json = $this->initUserJson();
- }
- if(!empty($user_json['read_book_categories'])){
- $read_book_categories = model('BookCategory')->where('id', 'in', $user_json['read_book_categories'])->select();
- }else{
- $read_book_categories = [];
- }
- if(!isset($user_json['userSex']) || $user_json['userSex'] === ''){
- $user_json['userSex'] = -1;
- }
- if($row['group_type'] === 1){
- $extend_data = $this->userGroupExtendModel->where(['user_group_id' => $row['id']])->find();
- $row['user_ids'] = $extend_data->user_ids ?? '';
- }
- $all_property = $this->initUserJson();
- $user_json = array_merge($all_property, $user_json);
- $this->view->assign('read_book_categories', $read_book_categories);
- $this->view->assign('user_json',$user_json);
- $this->view->assign("row", $row);
- return $this->view->fetch();
- }
- /**
- * 导入用户id
- */
- public function idimport()
- {
- $file = $this->request->request('file');
- if (!$file)
- {
- $this->error(__('Parameter %s can not be empty', 'file'));
- }
- $filePath = ROOT_PATH . DS . 'public' . DS . $file;
- if (!is_file($filePath))
- {
- $this->error(__('No results were found'));
- }
- $PHPReader = new \PHPExcel_Reader_Excel2007();
- if (!$PHPReader->canRead($filePath))
- {
- $PHPReader = new \PHPExcel_Reader_Excel5();
- if (!$PHPReader->canRead($filePath))
- {
- $PHPReader = new \PHPExcel_Reader_CSV();
- if (!$PHPReader->canRead($filePath))
- {
- $this->error(__('Unknown data format'));
- }
- }
- }
- $fieldArr = ['id' =>'id'];
- $PHPExcel = $PHPReader->load($filePath); //加载文件
- $currentSheet = $PHPExcel->getSheet(0); //读取文件中的第一个工作表
- $allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号
- $allRow = $currentSheet->getHighestRow(); //取得一共有多少行
- $maxColumnNumber = \PHPExcel_Cell::columnIndexFromString($allColumn);
- for ($currentRow = 1; $currentRow <= 1; $currentRow++)
- {
- for ($currentColumn = 0; $currentColumn < $maxColumnNumber; $currentColumn++)
- {
- $val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
- $fields[] = $val;
- }
- }
- $insert = [];
- for ($currentRow = 2; $currentRow <= $allRow; $currentRow++)
- {
- $values = [];
- for ($currentColumn = 0; $currentColumn < $maxColumnNumber; $currentColumn++)
- {
- $val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
- $values[] = is_null($val) ? '' : $val;
- }
- $row = [];
- $temp = array_combine($fields, $values);
- foreach ($temp as $k => $v)
- {
- if (isset($fieldArr[$k]) && $k !== '')
- {
- $row[$fieldArr[$k]] = $v;
- }
- }
- if ($row)
- {
- $insert[] = $row;
- }
- }
- if (!$insert)
- {
- $this->error(__('上传文件有误,请核对数据'));
- }
- try
- {
- $str = implode(',', array_column($insert, 'id'));
- $this->success('Success', '', $str);
- }
- catch (\think\exception\PDOException $exception)
- {
- $this->error($exception->getMessage());
- }
- }
- /**
- * 选择书籍分类
- * @return string|\think\response\Json
- * @throws \think\Exception
- */
- public function ajaxcategoryslect()
- {
- $this->model = model('BookCategory');
- if ($this->request->isAjax()) {
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $total = $this->model
- ->where(['status' => 'normal'])
- ->where($where)
- ->count();
- $list = $this->model
- ->where(['status' => 'normal'])
- ->where($where)
- ->limit($offset, $limit)
- ->select();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * Ajax设置有效失效
- */
- public function ajaxValidate()
- {
- $id = $this->request->param("ids");
- $data = $this->model->where('id', $id)->find();
- $status = $data->status;
- $this->model->update(['status' => !$status], ['id' => $id]);
- $data = ['code' => 0, 'msg' => 'success'];
- echo json_encode($data);
- }
- /**
- * 批量生效 | 失效
- */
- public function validbatch()
- {
- $params = $this->request->param();
- $ids = $params['ids'];
- $status = $params['status'];
- if (is_array($ids)) {
- foreach ($ids as $id) {
- $result = $this->model->update(['status' => $status], ['id' => $id]);
- }
- } else {
- $result = $this->model->update(['status' => $status], ['id' => $ids]);
- }
- if($result){
- $this->success('设置成功');
- }else{
- $this->error('设置失败');
- }
- }
- // region 额外的方法
- /**
- * 过滤字符串中重复的ID
- * @param $str 字符串
- * @param string $delimiter 分隔符
- */
- private function arr_uni_str($str, $delimiter=',')
- {
- $str = str_replace(',', ',', $str);
- $arr = array_unique(explode($delimiter, $str));
- // 过滤掉字符串
- $arr = array_filter($arr, function ($v){
- if(is_numeric($v)){
- return true;
- }else{
- return false;
- }
- });
- return implode(",", $arr);
- }
- private function restruct_params(&$params)
- {
- if ($params) {
- foreach ($params as $key => $item) {
- if (is_array($params[$key])) {
- $params[$key] = $this->array_filter_group($item);
- }
- }
- }
- }
- private function array_filter_group(array $arr)
- {
- return array_filter($arr, function ($v) {
- if($v == ''){
- return false;
- }else{
- return true;
- }
- });
- }
- public function validateForm(&$params)
- {
- // region 基础属性
- if (in_array(0, $params['baseType']) && $params['baseType'][0] == '0') {
- if (empty($params['follow-etime'])) {
- $this->error('请完善关注时间');
- }else{
- if($params['follow-stime'] >= $params['follow-etime']){
- $this->error('关注结束时间应大于关注开始时间');
- }
- }
- }
- if (in_array(1, $params['baseType'])) {
- if (empty($params['interactive-etime'])) {
- $this->error('请完善互动时间');
- } else {
- if ($params['interactive-stime'] >= $params['interactive-etime']) {
- $this->error('互动结束时间应大于互动开始时间');
- }
- }
- }
- if (in_array(2, $params['baseType'])) {
- if ($params['vipType'] == '') {
- $this->error('请完善VIP用户');
- }
- }
- // endregion 基础属性
- // region 充值属性
- if (in_array(0, $params['rechargeProperty']) && $params['rechargeProperty'][0] == '0') {
- if (empty($params['amount-e'])) {
- $this->error('请完善充值金额');
- } else {
- if($params['amount-s'] >= $params['amount-e']){
- $this->error('充值结束金额应大于充值开始金额');
- }
- }
- }
- if (in_array(1, $params['rechargeProperty'])) {
- if (empty($params['recharge-times-e'])) {
- $this->error('请完善充值次数');
- } else {
- if ($params['recharge-times-s'] >= $params['recharge-times-e']) {
- $this->error('充值结束次数应大于充值开始次数');
- }
- }
- }
- if (in_array(2, $params['rechargeProperty'])) {
- if ($params['rechargeType'] == '') {
- $this->error('请完善充值用户');
- }
- }
- if (in_array(3, $params['rechargeProperty'])) {
- if (empty($params['kandian-e'])) {
- $this->error('请完善账户余额');
- } else {
- if ($params['kandian-s'] >= $params['kandian-e']) {
- $this->error('账户结束余额应大于账户开始余额');
- }
- }
- }
- if (in_array(4, $params['rechargeProperty'])) {
- if (empty($params['giftkandian-e'])) {
- $this->error('请完善赠送书币金额');
- } else {
- if ($params['giftkandian-s'] >= $params['giftkandian-e']) {
- $this->error('赠送书币结束金额应大于赠送书币开始金额');
- }
- }
- }
- // endregion 充值属性
- // region 阅读属性
- if (in_array(0, $params['readProperty']) && $params['readProperty'][0] == '0') {
- if ($params['readType'] === '' || empty($params['readnum-e'])) {
- $this->error('请完善阅读章节数属性');
- } else {
- if ($params['readnum-s'] >= $params['readnum-e']) {
- $this->error('阅读结束章节数应大于阅读开始章节数');
- }
- }
- }
- if (in_array(1, $params['readProperty'])) {
- if ($params['book_id'] == '') {
- $this->error('请完善阅读记录属性');
- }
- }
- if (in_array(2, $params['readProperty'])) {
- if (empty($params['read_book_categories'])) {
- $this->error('请完善阅读书籍分类');
- }
- }
- // endregion 阅读属性
- // region 消费属性
- if (in_array(0, $params['consumerProperty']) && $params['consumerProperty'][0] == '0') {
- if (empty($params['spendkandian-e'])) {
- $this->error('请完善消费赠送书币数量');
- } else {
- if ($params['spendkandian-s'] >= $params['spendkandian-e']) {
- $this->error('消费赠送书币结束数额应大于消费赠送书币开始数额');
- }
- }
- }
- if (in_array(1, $params['consumerProperty'])) {
- if (empty($params['spendrecharge-e'])) {
- $this->error('请完善消费充值金额');
- } else {
- if ($params['spendrecharge-s'] >= $params['spendrecharge-e']) {
- $this->error('消费充值结束金额应大于消费充值开始金额');
- }
- }
- }
- // endregion 消费属性
- }
- public function initUserJson(){
- $user_json = [
- 'baseType' => [],
- 'readRecordType' => [],
- 'read_book_categories' => '',
- 'vipType' => '',
- 'readType' => '',
- 'rechargeType' => '',
- 'follow-stime' => 0,
- 'follow-etime' => 0,
- 'interactive-stime' => 0,
- 'interactive-etime' => 0,
- 'amount-s' => 0,
- 'amount-e' => 0,
- 'recharge-times-s' => 0,
- 'recharge-times-e' => 0,
- 'giftkandian-s' => 0,
- 'giftkandian-e' => 0,
- 'kandian-s' => 0,
- 'kandian-e' => 0,
- 'readnum-s' => 0,
- 'readnum-e' => 0,
- 'book_id' => '',
- 'spendkandian-s' => 0,
- 'spendkandian-e' => 0,
- 'spendrecharge-s' => 0,
- 'spendrecharge-e' => 0,
- 'userCate' => 0,
- 'mobile_system' => 0,
- 'userSex' => '',
- 'consumerProperty' => [],
- 'rechargeProperty' =>[],
- 'readProperty' => [],
- ];
- return $user_json;
- }
- public function filterFromParams(&$params)
- {
- if (!in_array(0, $params['baseType'])) {
- $params['follow-stime'] = '';
- $params['follow-etime'] = '';
- }else{
- if(trim($params['follow-stime']) == '' && !empty($params['follow-etime'])){
- $params['follow-stime'] = 0;
- }
- }
- if (!in_array(1, $params['baseType'])) {
- $params['interactive-stime'] = '';
- $params['interactive-etime'] = '';
- }else{
- if(trim($params['interactive-stime']) == '' && !empty($params['interactive-etime'])){
- $params['interactive-stime'] = 0;
- }
- }
- if (!in_array(2, $params['baseType'])) {
- $params['vipType'] = '';
- }
- // rechargeProperty
- if (!in_array(0, $params['rechargeProperty'])) {
- $params['amount-s'] = '';
- $params['amount-e'] = '';
- }else{
- if(trim($params['amount-s']) == '' && !empty($params['amount-e'])){
- $params['amount-s'] = 0;
- }
- }
- if (!in_array(1, $params['rechargeProperty'])) {
- $params['recharge-times-s'] = '';
- $params['recharge-times-e'] = '';
- }else{
- if(trim($params['recharge-times-s']) == '' && !empty($params['recharge-times-e'])){
- $params['recharge-times-s'] = 0;
- }
- }
- if (!in_array(2, $params['rechargeProperty'])) {
- $params['rechargeType'] = '';
- }
- if (!in_array(3, $params['rechargeProperty'])) {
- $params['kandian-s'] = '';
- $params['kandian-e'] = '';
- }else{
- if(trim($params['kandian-s']) == '' && !empty($params['kandian-e'])){
- $params['kandian-s'] = 0;
- }
- }
- if (!in_array(4, $params['rechargeProperty'])) {
- $params['giftkandian-s'] = '';
- $params['giftkandian-e'] = '';
- }else{
- if(trim($params['giftkandian-s']) == '' && !empty($params['giftkandian-e'])){
- $params['giftkandian-s'] = 0;
- }
- }
- // readProperty
- if (!in_array(0, $params['readProperty'])) {
- $params['readType'] = '';
- $params['readnum-s'] = '';
- $params['readnum-e'] = '';
- }
- if (!in_array(1, $params['readProperty'])) {
- $params['readRecordType'] = '';
- $params['book_id'] = '';
- }
- if (!in_array(2, $params['readProperty'])) {
- $params['read_book_categories'] = '';
- }
- // consumerProperty
- if (!in_array(0, $params['consumerProperty'])) {
- $params['spendkandian-s'] = '';
- $params['spendkandian-e'] = '';
- }else{
- if(trim($params['spendkandian-s']) == '' && !empty($params['spendkandian-e'])){
- $params['spendkandian-s'] = 0;
- }
- }
- if (!in_array(1, $params['consumerProperty'])) {
- $params['spendrecharge-s'] = '';
- $params['spendrecharge-e'] = '';
- }else{
- if(trim($params['spendrecharge-s']) == '' && !empty($params['spendrecharge-e'])){
- $params['spendrecharge-s'] = 0;
- }
- }
- /*if (!in_array(2, $params['consumerProperty'])) {
- $params['consumer_book_categories'] = '';
- }*/
- }
- // endregion 额外的方法
- }
|