public function editAction() { $p = $_REQUEST; $pWeight = empty($p['weight']) ? Tool_Fnc::ajaxMsg('干体重不能为空') : floatval($p['weight']); $tTime = time(); $tDWLMO = new DryweightlogModel(); $tDWLRow = $tDWLMO->field('id')->where('uid = ' . $this->tUid . ' and date = \'' . date('Y-m-d', $tTime) . '\'')->fRow(); $tUMO = new UserModel(); $tURow = $tUMO->field('user_type')->where(' id = ' . $this->tUid)->fRow(); if ($tURow['user_type'] == 1) { Tool_Fnc::ajaxMsg('操作异常'); } $tData = array('weight' => $pWeight); if (empty($tDWLRow['id'])) { $tData = array_merge($tData, array('created' => $tTime, 'uid' => $this->tUid, 'date' => date('Y-m-d', $tTime), 'year' => date('Y', $tTime), 'month' => date('Y-m', $tTime))); } else { $tData = array_merge($tData, array('updated' => $tTime, 'id' => $tDWLRow['id'])); } $tUMO->begin(); if (!$tDWLMO->save($tData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 001'); } $tUData = array('id' => $this->tUid, 'dry_weight' => $pWeight, 'updated' => $tTime); if (!$tUMO->update($tUData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 002'); } $tUMO->commit(); Tool_Fnc::ajaxMsg('操作成功', 1); }
public function indexAction() { $p = $_REQUEST; if (!count($p)) { Tool_Fnc::ajaxMsg('参数错误'); } $pPhone = empty($p['phone']) ? '' : trim($p['phone']); if (!Tool_Validate::mo($pPhone)) { Tool_Fnc::ajaxMsg('手机号不正确'); } //判断手机号是否是白求恩 $tBUserInfo = Oci_User::isPhone($pPhone); if (empty($tBUserInfo)) { Tool_Fnc::ajaxMsg('非白求恩用户,下一步完善必须资料', 1, array('user_type' => 0)); } $pPassword = empty($p['ptxt']) ? '' : trim($p['ptxt']); #客户端发送的必须是md5的 密码 $pCode = empty($p['code']) ? '0' : trim($p['code']); $pDid = empty($p['did']) ? '' : trim($p['did']); $tTime = time(); if (empty($pPassword)) { Tool_Fnc::ajaxMsg('密码不能为空'); } if (empty($pCode)) { Tool_Fnc::ajaxMsg('验证码不能为空'); } if (!Tool_Validate::integer($pCode)) { Tool_Fnc::ajaxMsg('验证码格式错误'); } if (strlen($pPassword) != 32) { Tool_Fnc::ajaxMsg('接口发送的必须是密文密码'); } if (empty($pDid) || !Tool_Validate::az09($pDid)) { Tool_Fnc::ajaxMsg('did error'); } $tUMO = new UserModel(); $tUMO->begin(); $tRow = $tUMO->field('count(0) c')->where('phone = \'' . $pPhone . '\'')->fRow(); if (!empty($tRow['c'])) { Tool_Fnc::ajaxMsg('该手机已被他人使用,请重新输入'); } $tKey = Tool_Fnc::newrand(4); $tMd5str = Tool_Fnc::markmd5($pPassword, $tKey); $tCodeMO = new PhonecodeModel(); $tCodeCRow = $tCodeMO->check($pPhone, 1, $pCode); if ($tCodeCRow['status'] == 0) { Tool_Fnc::ajaxMsg($tCodeCRow['msg']); } $tData = array('phone' => $pPhone, 'reg_ip' => Tool_Fnc::realip(), "passwd" => $tMd5str, "reg_time" => $tTime, 'private_key' => $tKey, 'reg_did' => $pDid, 'user_type' => 1); if (!($tID = $tUMO->insert($tData))) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 001'); } //did入库 $tUDMO = new UserdidModel(); $tUDRow = $tUDMO->field('count(0) c')->where('uid = ' . $tID . ' and did = \'' . $pDid . '\'')->fRow(); if (empty($tUDRow['c'])) { $tData = array('uid' => $tID, 'did' => $pDid, 'created' => $tTime, 'ip' => Tool_Fnc::realip()); if (!$tUDMO->insert($tData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 002'); } } $tTokenarr = $this->creattoken($tID); //获取数据 $tSex = $tBUserInfo['SEX'] == '男' ? 1 : 0; $tPatientId = $tBUserInfo['PATIENT_ID']; //提取干体重 $tDryWeight = Oci_User::getDryWeight($tPatientId); $tDatas = array('id' => $tID, 'nickname' => $tBUserInfo['NAME'], 'sex' => $tSex, 'dry_weight' => $tDryWeight['BODY_WEIGHT'], 'date_of_birth' => $tBUserInfo['DATE_OF_BIRTH'], 'headimg' => $tBUserInfo['PHOTO']); if (!$tUMO->update($tDatas)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 003'); } //新建健康档案 $tUserAssessment = Oci_User::getAssessment($tPatientId); $tUserAssessment['uid'] = $tID; $tUserAssessment['name'] = $tBUserInfo['NAME']; //his系统数据更新 $tCMO = new CenterModel(); $tCRow = $tCMO->field('id,name')->where(' center_id = \'' . $tBUserInfo['CENTER_ID'] . '\'')->fRow(); if (!empty($tCRow['id'])) { $tUserAssessment['medical_id'] = $tCRow['id']; //用户透析中心字段更新 $tUMedicalData = array('id' => $tID, 'center_id' => $tCRow['id'], 'medical_addr' => $tCRow['name']); if (!$tUMO->update($tUMedicalData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 003'); } } else { $tCenterdict = Oci_User::getCenterdict($tBUserInfo['CENTER_ID']); $tCData = array('center_id' => $tCenterdict['CENTER_ID'], 'center_code' => $tCenterdict['CENTER_CODE'], 'name' => $tCenterdict['CENTER_NAME'], 'position' => $tCenterdict['POSITION'], 'created' => $tTime); if (!($tUserAssessment['medical_id'] = $tCMO->insert($tCData))) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 008'); } //用户透析中心字段更新 $tUMedicalData = array('id' => $tID, 'center_id' => $tUserAssessment['medical_id'], 'medical_addr' => $tCenterdict['CENTER_NAME']); if (!$tUMO->update($tUMedicalData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 003'); } } //健康档案 $tUA = new UserassessmentModel(); foreach ($tUserAssessment as $k => $v) { $tUserAssessmentData[strtolower($k)] = $v; } $tUserAssessmentData['created'] = $tTime; //添加透析方式默认值 $tUserAssessmentData['method'] = 1; if (!$tUA->insert($tUserAssessmentData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 004'); } //干重记录表数据更新 $tDWMO = new DryweightlogModel(); /*$tDryWeightLog = array( 'uid' => $tID, 'weight' => $tDryWeight['BODY_WEIGHT'], 'date' => $tDryWeight['TREATE_DATE'], 'month' => date('Y-m',strtotime($tDryWeight['TREATE_DATE'])), 'year' => date('Y',strtotime($tDryWeight['TREATE_DATE'])), 'patient_id' => $tPatientId, 'created' => time(), );*/ $tSql = 'update ' . $tDWMO->table . ' set uid=' . $tID . ' where patient_id = \'' . $tPatientId . '\''; if (!$tDWMO->exec($tSql)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 005'); } #更新白求恩排班表 $tSDMO = new BqeschedulingdetailModel(); $tSql = 'update ' . $tSDMO->table . ' set uid = ' . $tID . ' where patient_id = \'' . $tPatientId . '\''; if (!$tSDMO->exec($tSql)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 006'); } #透析 - 治疗单主记录 $tTRMO = new BqetreatmentrecordModel(); $tSql = 'update ' . $tTRMO->table . ' set uid = ' . $tID . ' where patient_id = \'' . $tPatientId . '\''; if (!$tTRMO->exec($tSql)) { $tUMO->back(); Tool_Fnc::ajaxMsg('错误异常 007'); } $tUMO->commit(); //匿名转实名 $tUMO->incognito_real($pDid, $tID); $tTokenarr = array_merge($tTokenarr, array('user_type' => 1)); Tool_Fnc::ajaxMsg("注册成功,白求恩用户", 1, $tTokenarr); //注册成功返回token }
public function moneysave() { if (!IS_POST) { $this->message2('非法操作!', __APP__ . '/Admin'); } $user_model = new UserModel(); $user_account = new Model('account_log'); $id = I('id', 0); if ($id <= 0) { $this->message('未指定会员信息!', __URL__ . '/index'); } $user = $user_model->where('id=' . $id)->find(); if (empty($user)) { $this->message('未找到指定会员信息!', __URL__ . '/index'); } $account_type = I('account_type', 1); $bg_type = I('bg_type', 1); $addmoney = I('addmoney', 0); $reason = I('reason', ''); if ($addmoney <= 0) { $this->message('请填写变动金额!', __URL__ . '/addmoney/id/' . $id); } if ($reason == '') { $this->message('请填写变更原因!', __URL__ . '/addmoney/id/' . $id); } if ($account_type == 1) { if ($bg_type == 1) { $money = $user['money'] + $addmoney; $content = '增加账户余额' . $addmoney; } else { $money = $user['money'] - $addmoney; $content = '减少账户余额' . $addmoney; $addmoney = 0 - $addmoney; } if ($money < 0) { $this->message('该人账户可用余额已不足以冲减!', __URL__ . '/addmoney/id/' . $id); } $data['money'] = $money; } else { if ($account_type == 2) { if ($bg_type == 1) { $money = $user['refer_money'] + $addmoney; $content = '增加可用佣金' . $addmoney; } else { $money = $user['refer_money'] - $addmoney; $content = '减少可用佣金' . $addmoney; $addmoney = 0 - $addmoney; } $data['refer_money'] = $money; if ($money < 0) { $this->message('该人账户可用佣金已不足以冲减!', __URL__ . '/addmoney/id/' . $id); } } } $user_model->startTrans(); if (false !== $user_model->where('id=\'' . $id . '\'')->data($data)->save()) { $account_log['user_id'] = $id; $account_log['stage'] = 'admin'; $account_log['money'] = $addmoney; $account_log['comm'] = $reason; $account_log['addtime'] = $this->getDate(); if ($account_type == 1) { $account_log['remain_money'] = $money; $account_log['remain_refer_money'] = $user['refer_money']; } else { if ($account_type == 2) { $account_log['remain_money'] = $user['money']; $account_log['remain_refer_money'] = $money; } } if (false !== $user_account->data($account_log)->add()) { $user_model->commit(); $content = '对会员' . $user['username'] . $content . ',若为本人操作,请忽略该条提醒!'; send_fetion($content); $this->message('操作成功', __URL__ . '/index'); } else { $user_model->rollback(); $this->message('操作失败1:' . $user_account->getError(), __URL__ . '/addmoney/id/' . $id); } } else { $user_model->rollback(); $this->message('操作失败2:' . $user_account->getDbError()); } }
public function editAction() { $p = $_REQUEST; $tUMO = new UserModel(); $tURow = $tUMO->field('user_type')->where(' id = ' . $this->tUid)->fRow(); if ($tURow['user_type'] == 1) { Tool_Fnc::ajaxMsg('操作异常'); } $tData = array(); if (isset($p['name'])) { $tData = array_merge($tData, array('nickname' => Tool_Fnc::safe_string($p['name']))); } if (isset($p['date_of_birth'])) { $tData = array_merge($tData, array('date_of_birth' => date('Y-m-d', strtotime($p['date_of_birth'])))); } if (isset($p['sex'])) { $tData = array_merge($tData, array('sex' => intval($p['sex']))); } $tTime = time(); //存在干体重修改,则更新干体重记录 $pDryWeight = !isset($p['dry_weight']) ? '' : floatval($p['dry_weight']); $tUMO->begin(); if (!empty($pDryWeight)) { $tData = array_merge($tData, array('dry_weight' => $pDryWeight)); $tDWLMO = new DryweightlogModel(); $tDWLRow = $tDWLMO->field('id')->where('uid = ' . $this->tUid . ' and date = \'' . date('Y-m-d', $tTime) . '\'')->fRow(); if (empty($tDWLRow['id'])) { $tDWLData = array('weight' => $pDryWeight, 'uid' => $this->tUid, 'created' => $tTime, 'date' => date('Y-m-d', $tTime), 'month' => date('Y-m', $tTime), 'year' => date('Y', $tTime)); } else { $tDWLData = array('weight' => $pDryWeight, 'updated' => $tTime, 'id' => $tDWLRow['id']); } if (!$tDWLMO->save($tDWLData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 001'); } } //存在名字修改,则更新健康档案中的名字字段 if (isset($p['name']) && !empty($p['name'])) { $tUAMO = new UserassessmentModel(); $tUARow = $tUAMO->field('id,name')->where('uid = ' . $this->tUid)->fRow(); if (!empty($tUARow['id'])) { $tUADatas = array('id' => $tUARow['id'], 'name' => Tool_Fnc::safe_string($p['name']), 'updated' => $tTime); if (!$tUAMO->update($tUADatas)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 002'); } } else { $tUADatas = array('uid' => $this->tUid, 'name' => Tool_Fnc::safe_string($p['name']), 'created' => $tTime); if (!$tUAMO->insert($tUADatas)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 002'); } } } $tData = array_merge($tData, array('id' => $this->tUid, 'updated' => $tTime)); if (!$tUMO->update($tData)) { $tUMO->back(); Tool_Fnc::ajaxMsg('修改失败 003'); } $tUMO->commit(); Tool_Fnc::ajaxMsg('操作成功', 1); }