where($condition)->count(); $list = Db::name('seller_base_info')->field("*")->where($condition)->order($order)->page($p, $other['page_size'])->select()->toArray(); $other['count'] = $count; if (!$list) { $list = []; } else{ foreach ($list as &$item){ $item['main_area'] = $item['main_area'] ? array_map('intval', explode(',', $item['main_area'])) : []; $item['main_dis_platform'] = $item['main_dis_platform'] ? array_map('intval', explode(',', $item['main_dis_platform'])) : []; $item['cate_code'] = [$item['country_id'], $item['province_id'], $item['city_id']]; } } $result['code'] = 200; $result['list'] = $list; $result['other'] = $other; return $this->successResponse($result); } catch (\Exception $exc) { return $this->errorResponse($exc->getMessage()); } } } /* * 获取国家-省份-城市列表 */ public function getCountryCodeList() { if (!Request::isPost()) { throw new Exception(lang('request_method_incorrect')); } try { $result['list'] = $this->getCountrychildrenids(0); return $this->successResponse($result); } catch (\Exception $exc) { return $this->errorResponse($exc->getMessage()); } } protected function getCountrychildrenids($id) { $where['father_id'] = $id; $result = Db::name('country_code')->field('id as value,cate_name as label')->where($where)->cacheAlways(TRUE, 0, 'country_code')->order('order_id asc,id asc')->select()->toArray(); if ($result) { foreach ($result as &$val) { $val['children'] = $this->getCountrychildrenids($val['value']); //// } return $result; } } /** * 分销商实名认证审核 * @return array|int[] */ public function reviewBaseInfo() { // 开始数据库事务 Db::startTrans(); try { if (!Request::isPost()) { throw new Exception(lang('request_method_incorrect')); } $base_info_id = input('post.base_info_id'); if (is_numeric($base_info_id)) { $status = input('post.status'); //更新数据 $info = Db::name('seller_base_info')->field('id,status')->where('id', $base_info_id)->find(); if (!$info) { throw new Exception(lang('no_data_found')); } if ($info['status'] == 1) { throw new Exception('该申请已审核通过,不能重复审核'); } if ($status == 1) { Db::name('seller_base_info')->where('id', $base_info_id)->update(['status' => 1]); $message = '操作成功,审核通过'; } else { Db::name('seller_base_info')->where('id', $base_info_id)->update(['status' => 3]); $message = '操作成功,审核不通过'; } // 提交事务 Db::commit(); return $this->successResponse($message); } else { return $this->errorResponse(lang('request_method_incorrect')); } } catch (Exception $exc) { // 回滚事务 Db::rollback(); return $this->errorResponse($exc->getMessage()); } } }