/**
  * @param array $data 存储数据 
  * @param int $db_no 操作数据库no.  ex:0
  * @param varchar $action 操作方法  ex: save
  * @param array $org  ex:array('member','id') 数据来源
  * @param int $mark  标识更新主键  
  * @return bool
  */
 static function addData($data, $db_no, $action, $org, $mark)
 {
     $db = M('Auth');
     $status = AuthController::checkDbConfig($db_no);
     if ($status) {
         $save['check_data'] = json_encode($data);
         $save['db_no'] = $db_no;
         $save['check_action'] = $action;
         $save['data_org'] = json_encode($org);
         $save['addtime'] = time();
         $save['status'] = 0;
         //未审核
         $save['mark_id'] = $mark;
         $auth_id = $db->where(array('db_no' => $db_no, 'mark_id' => $mark))->getField('id');
         if ($auth_id) {
             unset($save['db_no']);
             unset($save['mark_id']);
             $rel = $db->where(array('id' => $auth_id))->save($save);
         } else {
             $rel = $db->add($save);
         }
         return $rel;
     } else {
         return 0;
     }
 }
 /**
  * 提交商家详情
  */
 function editMerchantInfo()
 {
     $id = isset($_POST['id']) ? htmlspecialchars($_POST['id']) : '';
     // 商家id
     $salesman_session_id = isset($_POST['salesman_session_id']) ? htmlspecialchars($_POST['salesman_session_id']) : '';
     $salesman_id = $this->session_handle->getsession_userid($salesman_session_id);
     // dump($salesman_id);
     if (empty($salesman_id)) {
         $this->jsonUtils->echo_json_msg(4, '会话id不能为空');
         exit;
     }
     $merchant_name = isset($_POST['merchant_name']) ? htmlspecialchars($_POST['merchant_name']) : '';
     $area_id = isset($_POST['area_id']) ? htmlspecialchars($_POST['area_id']) : '';
     $address = isset($_POST['address']) ? htmlspecialchars($_POST['address']) : '';
     $manager = isset($_POST['manager']) ? htmlspecialchars($_POST['manager']) : '';
     $tel = isset($_POST['tel']) ? htmlspecialchars($_POST['tel']) : '';
     $business_time = isset($_POST['business_time']) ? htmlspecialchars($_POST['business_time']) : '';
     $longitude = isset($_POST['longitude']) ? htmlspecialchars($_POST['longitude']) : '';
     $latitude = isset($_POST['latitude']) ? htmlspecialchars($_POST['latitude']) : '';
     // $auth =
     // $this->merchant->where(array('id'=>$id))->getField('check_by');
     // if($auth==0) {
     // $this->jsonUtils->echo_json_msg(4, '数据异常');exit();
     // }
     // if($auth==$salesman_id){
     if (empty($id)) {
         $this->jsonUtils->echo_json_msg(4, '商家id不能为空');
         exit;
     }
     if (empty($merchant_name)) {
         $this->jsonUtils->echo_json_msg(4, '商家名不能为空');
         exit;
     }
     if (empty($address)) {
         $this->jsonUtils->echo_json_msg(4, '商家地址不能为空');
         exit;
     }
     if (empty($manager)) {
         $this->jsonUtils->echo_json_msg(4, '负责人名字不能为空');
         exit;
     }
     if (empty($business_time)) {
         $this->jsonUtils->echo_json_msg(4, '营业时间为空');
         exit;
     }
     if (empty($longitude)) {
         $this->jsonUtils->echo_json_msg(4, '精度不能为空');
         exit;
     }
     if (empty($latitude)) {
         $this->jsonUtils->echo_json_msg(4, '维度不能空');
         exit;
     }
     if (empty($area_id)) {
         $this->jsonUtils->echo_json_msg(4, '区域id不能空');
         exit;
     }
     if ($_FILES) {
         $result = mul_upload('/Header/', 3);
         if ($result) {
             $save['header'] = $result[0];
         }
     }
     $area = CityController::getAreaIdPreId($area_id);
     $save['province_id'] = $area['province'];
     $save['city_id'] = $area['city'];
     $save['area_id'] = $area_id;
     $save['business_time'] = $business_time;
     $save['merchant_name'] = $merchant_name;
     $save['address'] = $address;
     $save['manager'] = $manager;
     $save['tel'] = $tel;
     $save['longitude'] = $longitude;
     $save['latitude'] = $latitude;
     $check = AuthController::addData($save, 0, 'save', array('salesman' => $salesman_id), $id);
     if ($check) {
         $this->jsonUtils->echo_json_msg(0, '已提交审核');
         exit;
     } else {
         $this->jsonUtils->echo_json_msg(4, '修改失败');
         exit;
     }
     // }else{
     // $this->jsonUtils->echo_json_msg(4, '无权限操作');exit();
     // }
 }
 public function testLogoutAction()
 {
     $result = $this->controller->logoutAction();
     $expected = '/index/index';
     $this->assertEquals($expected, $result);
 }