/**
  * 修改保存 update
  */
 public function update()
 {
     $name = 'User';
     $model = D($name);
     $result = $model->do_update_head_auth();
     /* 返回信息 */
     if ($result) {
         if ($_POST['upfile_head_auth_type'] == 1) {
             /* 发送IM 信息 */
             import('Api.ORG.EasemobIMSDK');
             $rest = new \Hxcall();
             $sender = C('EASEMOB.EASEMOB_PREFIX') . '1';
             $receiver = C('EASEMOB.EASEMOB_PREFIX') . $_POST['id'];
             $msg = L('TS_user_authentication_upfile_head');
             $ext = array('type' => 5);
             $rest->hx_send($sender, $receiver, $msg, $ext);
         }
         $this->ajaxReturn(array('msg' => L('YZ_operation_success'), 'result' => 1, 'href' => U('index')));
     } else {
         $result = $model->getError();
         if (is_array($result) && count($result)) {
             /* 验证错误 */
             $errorMsg = validate_error($result);
             $this->ajaxReturn(array('formError' => $errorMsg, 'result' => -1));
         }
         /* 数据库操作错误 */
         $this->ajaxReturn(array('msg' => L('YZ_operation_fail'), 'result' => 1));
     }
 }
 /**
  * 保存修改密码 updatePassword
  */
 public function updatePassword()
 {
     $model = D('Member');
     $result = $model->do_update_password();
     /* 返回信息 */
     if ($result) {
         $this->ajaxReturn(array('msg' => L('YZ_operation_success'), 'result' => 1, 'href' => U('password')));
     } else {
         $result = $model->getError();
         if (is_array($result) && count($result)) {
             /* 验证错误 */
             $errorMsg = validate_error($result);
             $this->ajaxReturn(array('formError' => $errorMsg, 'result' => -1));
         } else {
             /* 数据库操作错误 */
             $this->ajaxReturn(array('msg' => L('YZ_operation_fail'), 'result' => 1));
         }
     }
 }
 public function do_consume()
 {
     $name = CONTROLLER_NAME;
     $model = D($name);
     $result = $model->do_consume();
     /* 返回信息 */
     if ($result) {
         /* ShopUserWent 添加去向 */
         $where['trade_no'] = array('EQ', I('post.verify'));
         $where['trade_state'] = array('EQ', 1);
         $where['shop_account_id'] = array('EQ', UID);
         $where['display'] = array('EQ', 1);
         $shopUserWent = $model->field('id,user_id,shop_id,shop_coupon_info')->where($where)->find();
         $shopUserWentInfo = json_decode($shopUserWent['shop_coupon_info'], true);
         $content = '使用了"' . $shopUserWentInfo['title'] . '"';
         $dataUserWent['shop_id'] = $shopUserWent['shop_id'];
         $dataUserWent['user_id'] = $shopUserWent['user_id'];
         $dataUserWent['content'] = $content;
         $dataUserWent['pay_order_id'] = $shopUserWent['id'];
         $dataUserWent['create_time'] = NOW_TIME;
         M('ShopUserWent')->add($dataUserWent);
         /* 关注的人收到通知 */
         // 获取关注你的人
         $where_attention['user_attention.to_user_id'] = array('EQ', $shopUserWent['user_id']);
         $where_attention['user.push_id'] = array('NEQ', '');
         $where_attention['user.status'] = array('EQ', 1);
         $where_attention['user.display'] = array('EQ', 1);
         $where_attention['user.trace_notify'] = array('EQ', 1);
         $attention_user_id = M('UserAttention')->alias('user_attention')->field('user.push_id')->where($where_attention)->join('__USER__ user on user_attention.user_id = user.id')->select();
         // 获取去向资料
         $data_shop_user_went = get_shop_user_went($shopUserWent['user_id'], $shopUserWent['shop_id']);
         if ($data_shop_user_went) {
             foreach ($attention_user_id as $k => $v) {
                 $push_id[] = $v['push_id'];
             }
             $push_id = array_filter(array_unique(array_slice($push_id, 0, 1000)));
             R('Api/Api/push_one', array($push_id, $data_shop_user_went));
         }
         $this->ajaxReturn(array('msg' => L('YZ_operation_success'), 'result' => 1, 'href' => U('consume')));
     } else {
         $result = $model->getError();
         if (is_array($result) && count($result)) {
             /* 验证错误 */
             $errorMsg = validate_error($result);
             $this->ajaxReturn(array('formError' => $errorMsg, 'result' => -1));
         }
         /* 数据库操作错误 */
         $this->ajaxReturn(array('msg' => L('YZ_operation_fail'), 'result' => 1));
     }
 }
 /**
  * 保存提交 do_save
  * @param null $name
  * @param array $data_array
  * @param string $href
  */
 protected function do_save($name = NULL, $data_array = array(), $href = 'index')
 {
     if (!$name) {
         $name = CONTROLLER_NAME;
     }
     $model = D($name);
     $postId = I('post.id');
     if ($postId > 0) {
         $result = $model->do_update($data_array['condition'], $data_array['data_array']);
     } else {
         $result = $model->do_insert($data_array['data_array']);
     }
     /* 返回信息 */
     if ($result) {
         /* 成功回调执行函数 */
         if ($postId > 0) {
             $this->_after_do_update();
         } else {
             $this->_after_do_insert();
         }
         $this->ajaxReturn(array('msg' => L('YZ_operation_success'), 'result' => 1, 'href' => U($href)));
     } else {
         $result = $model->getError();
         if (is_array($result) && count($result)) {
             /* 验证错误 */
             $errorMsg = validate_error($result);
             $this->ajaxReturn(array('formError' => $errorMsg, 'result' => -1));
         }
         /* 数据库操作错误 */
         $this->ajaxReturn(array('msg' => L('YZ_operation_fail'), 'result' => 1));
     }
 }