/** * 认证仓库管理 * @param int $user_id * @param int $store_id */ public function certStoreApply($user_id, $store_id) { $certModel = new M($this->certTable['store']); $status = self::CERT_APPLY; $sql = 'INSERT INTO ' . $certModel->table() . ' (`user_id`,`status`,`apply_time`,`store_id`) VALUES (' . $user_id . ',' . $status . ',"' . Time::getDateTime() . '",:store_id) ON DUPLICATE KEY UPDATE status =' . $status . ' , store_id=:store_id,apply_time = "' . Time::getDateTime() . '"'; return $certModel->bind(array('store_id' => $store_id))->query($sql); }
/** * 企业用户信息更新 * @param array $userData 用户数据 * @param array $companyData 企业数据 */ public function companyUpdate($userData, $companyData) { $user = new M('user'); if ($user->data($userData)->validate($this->userRules, 2) && $user->validate($this->companyRules, $companyData, 2)) { $user_id = $userData['user_id']; if ($this->existUser(array('id' => array('neq', $user_id), 'username' => $userData['username']))) { return $this->getSuccInfo(0, '用户名已注册'); } $user->beginTrans(); unset($userData['user_id']); if (($res1 = $user->where(array('id' => $user_id))->data($userData)->update()) !== false) { $res2 = $user->table('company_info')->where(array('user_id' => $user_id))->data($companyData)->update(); } if (false !== $res1 && isset($res2) && false !== $res2) { //操作成功 if ($res1 === 0 && $res2 === 0) { //更新成功,但数据未改变 $user->commit(); $res = 2; } else { $res = 1; } //此时事务不提交,后续还要更新认证状态 } else { $res = '系统繁忙,请稍后再试'; } //$res = $user->commit(); } else { $res = $user->getError(); } if (is_numeric($res)) { //操作成功 return $this->getSuccInfo($res); } else { return $this->getSuccInfo(0, $res); } }