static function Create($user) { $errorCode = MispErrorCode::SUCCESS; FuegoLog::getLog()->LogInfo("Create user..."); //获取用户类型 $roleDao = MispDaoContext::SystemRole(); $roleCondition['role_id'] = $user['role_id']; $userType = $roleDao->where($roleCondition)->getField('user_type_id'); //用户信息查重条件 $condition['user_name'] = $user['user_name']; if (UserTypeEnum::CUSTOMER == $userType) { $condition['company_id'] = $user['company_id']; } $systemUserDao = MispDaoContext::SystemUser(); $userID = $systemUserDao->where($condition)->getField('user_id'); if ($userID != '') { //用户已存在 FuegoLog::getLog()->LogWarn("Create user failed, user_name has exist." . json_encode($condition)); $errorCode = MispErrorCode::USER_EXISTED; throw new FuegoException(null, $errorCode); } FuegoLog::getLog()->LogInfo("User info is " . json_encode($user)); $result = MispCommonService::Create($systemUserDao, $user); FuegoLog::getLog()->LogInfo("Create user success."); return $result; }
public function Create() { $this->LogInfo("create admin..."); $systemUserDao = MispDaoContext::SystemUser(); $req = $this->GetCommonData(); if ("" == $req->role_id) { $this->errorCode = MispErrorCode::ERROR_ROLE_IS_EMPTY; $this->ReturnJson(); return; } //创建User信息 $user['user_name'] = $req->user_name; $user['password'] = "******"; $user['role_id'] = $req->role_id; $user['reg_date'] = date('Y-m-d H:i:s', time()); $user['company_id'] = $_SESSION['user']['company_id']; $this->LogInfo("Create user info " . json_encode($user)); try { $result = MispCommonUserService::Create($user); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); $this->ReturnJson(); return; } //创建管理员信息 $adminDao = $this->GetModel(); $admin['user_id'] = $result; $admin['user_name'] = $req->user_name; $admin['email'] = $req->email; $admin['company_id'] = $_SESSION['user']['company_id']; $this->LogInfo("Create admin info " . json_encode($admin)); try { $result = MispCommonService::Create($adminDao, $admin); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); } $this->ReturnJson(); }
public function Create() { $this->LogInfo("customer create ..."); $obj = $this->GetCommonData(); if ("" == $obj->role_id) { $this->errorCode = MispErrorCode::ERROR_ROLE_IS_EMPTY; $this->ReturnJson(); return; } //创建用户 $user['user_name'] = $obj->user_name; $user['password'] = '******'; $user['role_id'] = $obj->role_id; $user['reg_date'] = date('Y-m-d H:i:s', time()); $user['company_id'] = $_SESSION['user']['company_id']; try { $result = MispCommonUserService::Create($user); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); $this->ReturnJson(); return; } //创建会员 $customerDao = $this->GetModel(); $customer['user_id'] = $result; $customer['user_name'] = $obj->user_name; $customer['customer_name'] = $obj->customer_name; $customer['nickname'] = $obj->nickname; $customer['phone'] = $obj->phone; $customer['birthday'] = $obj->birthday; $customer['addr'] = $obj->addr; $customer['score'] = $obj->score; $customer['card_number'] = $obj->card_number; $customer['customer_sex'] = $obj->customer_sex; $customer['customer_email'] = $obj->customer_email; $customer['company_id'] = $_SESSION['user']['company_id']; $this->LogInfo("Create customer " . json_encode($customer)); try { $result = MispCommonService::Create($customerDao, $customer); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); } $this->ReturnJson(); }
public function CreateAdmin($admin) { $errorCode = MispErrorCode::SUCCESS; FuegoLog::getLog()->LogInfo("Create admin"); $adminDao = LaundryDaoContext::administrators(); try { $result = MispCommonService::Create($adminDao, $admin); } catch (FuegoException $e) { $errorCode = $e->getCode(); } return $errorCode; }
public function Create() { $this->LogInfo("APP create order..."); //验证APP是否登录 $this->DoAuth(); $req = $this->GetReqObj(); //创建订单 $order = $req->order; $orderData = $this->objectToArray($order); $orderDao = $this->GetModel(); do { $orderData['order_code'] = date('ymdHis', time()) . rand(1000, 9999); } while ($orderDao->where('order_code=' . $orderData['order_code'])->count()); if (OrderEnum::OnlinePay == $orderData['pay_option']) { $orderData['order_status'] = OrderEnum::WaitBuyerPay; } else { $orderData['order_status'] = OrderEnum::OrderSubmit; } $orderData['create_time'] = date('Y-m-d H:i:s', time()); $orderData['company_id'] = $req->app_id; $this->LogInfo("order info is " . json_encode($orderData)); try { $result = MispCommonService::Create($orderDao, $orderData); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); $this->ReturnJson(); return; } //正常下单创建订单详情 if ($orderData['order_type'] == OrderEnum::NormalOrder) { //创建订单详情 $orderDetailDao = LaundryDaoContext::OrderDetail(); $orderDetailList = $req->orderDetailList; for ($i = 0; $i < count($orderDetailList); $i++) { $orderDetailList[$i] = $this->objectToArray($orderDetailList[$i]); $orderDetailList[$i]['order_id'] = $result; } $this->LogInfo("order type is " . OrderEnum::NormalOrder); $this->LogInfo("order detail is " . json_encode($orderDetailList)); try { $detailResult = MispCommonService::CreateList($orderDetailDao, $orderDetailList); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); $this->ReturnJson(); return; } } //直接下单 if (OrderEnum::DirectOrder == $orderData['order_type']) { $this->LogInfo("order type is " . OrderEnum::DirectOrder); } //发出订单邮件通知 $adminDao = LaundryDaoContext::administrators(); $CompanyCondition['company_id'] = $req->app_id; $Email = $adminDao->where($CompanyCondition)->getField('email'); $this->LogInfo("admin email is " . $Email); if (false == SendMail($Email, OrderEnum::EMAIL_TITLE, "会员:" . $orderData['user_name'] . " 已成功提交订单,订单号为:" . $orderData['order_code'] . "。请及时处理!")) { $this->LogErr("Order has create,But send mail failed."); } //获取订单信息返回 $orderCondition['order_code'] = $orderData['order_code']; try { $object = MispCommonService::GetUniRecord($orderDao, $orderCondition); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); $this->ReturnJson(); return; } $data['obj'] = $object; $this->ReturnJson($data); }
public function Create() { $this->LogInfo("Create product..."); //导入图片上传类 import("ORG.Net.UploadFile"); //实例化上传类 $upload = new UploadFile(); $upload->maxSize = 20976; //138px*152px //$upload->maxSize = 4145728; //设置文件上传类型 $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg'); //设置文件上传位置 $upload->savePath = "./Public/Fuego/Uploads/"; //根目录下的Public文件夹 //设置文件上传名(按照时间) //$upload->saveRule = "time"; if (!$upload->upload()) { //上传图片错误 $this->LogWarn("Upload image failed." . $upload->getErrorMsg()); $this->LogWarn("Modify product failed."); $this->errorCode = MispErrorCode::UPLOAD_IMG_FAILED; $data['PrivateErrorMsg'] = $upload->getErrorMsg(); $this->ReturnJson($data); return; } else { //上传成功,获取上传信息 $this->LogInfo("Upload image success."); $info = $upload->getUploadFileInfo(); } $productDao = $this->GetModel(); $data['product_name'] = $_POST['product_name']; $data['price_type'] = $_POST['price_type']; $data['price'] = $_POST['price']; $data['describe'] = $_POST['describe']; $data['type_id'] = $_POST['type_id']; $data['company_id'] = $_SESSION['user']['company_id']; $data['img'] = $info[0]['savename']; $this->LogInfo("Create product info " . json_encode($data)); try { $result = MispCommonService::Create($productDao, $data); $this->LogInfo("Create product success."); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); } $this->ReturnJson(); }
public function CreateModel($model) { $this->LogInfo("create"); $obj = $this->GetObj(); $result = $this->Validator($obj); if (SUCCESS != $result) { $this->errorCode = $result; $this->LogErr("validator failed when create " . $model— > tableName); $this->LogErr("the error is " . $result); $this->ReturnJson(); return; } $object = $this->objectToArray($obj); try { $result = MispCommonService::Create($model, $object); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); } $this->ReturnJson(); }
public function CreateBasicRole($companyID) { //创建公司基本角色 $roleDao = MispDaoContext::SystemRole(); //创建管理员角色 $role['role_name'] = "管理员"; $role['user_type_id'] = UserTypeEnum::ADMIN; $role['user_type_name'] = "ADMIN"; $role['company_id'] = $companyID; $adminRoleID = MispCommonService::Create($roleDao, $role); //创建管理员权限 $privilegeDao = MispDaoContext::Privilege(); $privilegeList = array(); for ($i = 1; $i < 5; $i++) { $privilege['master_type'] = PrivilegeEnum::MASTER_TYPE_ROLE; $privilege['master_value'] = $adminRoleID; $privilege['access_obj_type'] = PrivilegeEnum::ACCESS_TYPE_MENU; $privilege['access_obj_value'] = $i; array_push($privilegeList, $privilege); } $loginPrivilege['master_type'] = PrivilegeEnum::MASTER_TYPE_ROLE; $loginPrivilege['master_value'] = $adminRoleID; $loginPrivilege['access_obj_type'] = PrivilegeEnum::ACCESS_TYPE_LOGIN; $loginPrivilege['access_obj_value'] = PrivilegeEnum::ACCESS_VALUE_WEB_LOGIN; array_push($privilegeList, $loginPrivilege); $result = MispCommonService::CreateList($privilegeDao, $privilegeList); //创建消费者角色 $role['role_name'] = "消费者"; $role['user_type_id'] = UserTypeEnum::CUSTOMER; $role['user_type_name'] = "CUSTOMER"; $role['company_id'] = $companyID; $sellerRoleID = MispCommonService::Create($roleDao, $role); //创建消费者权限 $loginPrivilege['master_type'] = PrivilegeEnum::MASTER_TYPE_ROLE; $loginPrivilege['master_value'] = $sellerRoleID; $loginPrivilege['access_obj_type'] = PrivilegeEnum::ACCESS_TYPE_LOGIN; $loginPrivilege['access_obj_value'] = PrivilegeEnum::ACCESS_VALUE_APP_LOGIN; $result = MispCommonService::Create($privilegeDao, $loginPrivilege); return $adminRoleID; }