public function httpGetMethod(Http $http, array $queryFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP GET
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $queryFields contient l'équivalent de $_GET en PHP natif.
      */
     $userSession = new UserSession();
     if ($userSession->isAuthenticated() == false) {
         $http->redirectTo('/User/Login');
     }
     if (array_key_exists('order_Id', $queryFields)) {
         if (ctype_digit($queryFields['order_Id'])) {
             //var_dump($queryFields['order_Id']);
             $orderModel = new OrderModel();
             $orderInformation = $orderModel->findOrder($queryFields['order_Id']);
             $customerModel = new CustomerModel();
             $customerInformation = $customerModel->findCustomer($orderInformation['Customer_Id']);
             $order = $orderModel->getOrderLineByOrderId($queryFields['order_Id']);
             return ['customerInformation' => $customerInformation, 'order' => $order, 'orderInformation' => $orderInformation];
         }
     }
     $http->redirectTo('/');
 }
示例#2
0
文件: login.php 项目: davpal/Kuriex
 public function login()
 {
     $view = new ViewModel('admin/login');
     if (isset($_SESSION['user']) && $_SESSION['user'] != 'admin') {
         $view->assign('user', $_SESSION['user']);
         header('Location: yourAccount');
         return;
     }
     if (isset($_POST['user']) && $_POST['user'] == 'admin') {
         $admin = new AdminController();
         $admin->login();
     }
     if (isset($_POST['user'])) {
         $customer = new CustomerModel();
         $logged = $customer->selectWithPassword($_POST['user'], $_POST['pass']);
         if (!$logged) {
             $view->assign('message-type', 'error');
             $view->assign('message', 'Błędne dane');
             $view->display();
             return;
         }
         $_SESSION['user'] = $_POST['user'];
         $view->assign('user', $_SESSION['user']);
         $view->setTemplate('customer/index');
         header('Location: yourAccount');
     }
     $view->display();
 }
示例#3
0
 public function get_project_action_id($id)
 {
     try {
         $data = "";
         $sql = " SELECT * FROM action \n                     WHERE member_id = :member_id ";
         $stmh = $this->pdo->prepare($sql);
         $stmh->bindValue(':member_id', $id, PDO::PARAM_INT);
         $stmh->execute();
         $count = $stmh->rowCount();
         $i = 0;
         $data = [];
         //案件の詳細情報の取得
         $CustomerModel = new CustomerModel();
         while ($row = $stmh->fetch(PDO::FETCH_ASSOC)) {
             foreach ($row as $key => $value) {
                 $data[$i][$key] = $value;
             }
             $project_data = $CustomerModel->get_project($data[$i]['project_id']);
             $data[$i]['title'] = $project_data['title'];
             $data[$i]['company_name'] = $CustomerModel->get_company_name_company_id($data[$i]['company_id']);
             $i++;
         }
     } catch (PDOException $Exception) {
         print "エラー" . $Exception->getMessage();
     }
     return array($data, $count);
 }
 public function httpPostMethod(Http $http, array $formFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP POST
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $formFields contient l'équivalent de $_POST en PHP natif.
      */
     try {
         $Customer = new CustomerModel();
         $verifEmail = $Customer->sameMail($formFields['Email']);
         if ($verifEmail && ctype_digit($formFields['Year']) && ctype_digit($formFields['Month']) && ctype_digit($formFields['Day']) && ctype_digit($formFields['Phone']) && strlen($formFields['Phone']) === 10 && ctype_digit($formFields['ZipCode']) && strlen($formFields['ZipCode']) === 5 && isset($formFields['password']) && $formFields['password2'] == $formFields['password'] && isset($formFields['Email']) && filter_var($formFields['Email'], FILTER_VALIDATE_EMAIL) != false) {
             $Birthdate = $formFields['Year'] . '-' . $formFields['Month'] . '-' . $formFields['Day'];
             //var_dump($Birthdate);
             $Customer_id = $Customer->registerCustomer($formFields['FirstName'], $formFields['LastName'], $Birthdate, $formFields['Phone'], $formFields['Address'], $formFields['Address2'], $formFields['City'], $formFields['ZipCode'], $formFields['Email'], $formFields['password']);
             //var_dump($Customer_id);
             $user = $Customer->findCustomer($Customer_id);
             $UserSession = new UserSession();
             $UserSession->create($user);
             $http->redirectTo('');
         } else {
             $http->redirectTo('Exception?Error=3');
         }
     } catch (DomainException $event) {
         $form = new RegisterForm();
         $form->bind($formFields);
         $form->setErrorMessage($event->getMessage());
         return ['_form' => $form];
     }
 }
 public function httpPostMethod(Http $http, array $formFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP POST
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $formFields contient l'équivalent de $_POST en PHP natif.
      */
     $Customer = new CustomerModel();
     $verifEmail = $Customer->sameMail($formFields['Email']);
     //var_dump(strlen($_POST['Phone']));
     //var_dump(strlen($_POST['ZipCode']));
     if ($verifEmail['result'] === '0' && ctype_digit($formFields['Year']) && ctype_digit($formFields['Month']) && ctype_digit($formFields['Day']) && ctype_digit($formFields['Phone']) && strlen($formFields['Phone']) === 10 && ctype_digit($formFields['ZipCode']) && strlen($formFields['ZipCode']) === 5 && isset($formFields['password']) && isset($formFields['Email']) && filter_var($formFields['Email'], FILTER_VALIDATE_EMAIL) != false) {
         $password = password_hash($formFields['password'], PASSWORD_DEFAULT);
         //var_dump($password);
         $Birthdate = $formFields['Year'] . '-' . $formFields['Month'] . '-' . $formFields['Day'];
         //var_dump($Birthdate);
         $Customer_id = $Customer->registerCustomer($formFields['FirstName'], $formFields['LastName'], $Birthdate, $formFields['Phone'], $formFields['Address'], $formFields['Address2'], $formFields['City'], $formFields['ZipCode'], $formFields['Email'], $formFields['password']);
         //var_dump($Customer_id);
         $user = $Customer->findCustomer($Customer_id);
         $UserSession = new UserSession();
         $UserSession->create($user);
         $http->redirectTo('');
     } elseif ($verifEmail != '0') {
         $http->redirectTo('Exception?Error=3');
     }
 }
 function CreateCustomerTables($types)
 {
     $customerModel = new CustomerModel();
     $customerArray = $customerModel->GetCustomerByType($types);
     $result = "";
     foreach ($customerArray as $key => $customer) {
         $result = $result . "<table class = 'customerTable'>\n                        <tr>\n                           \n                            \n                            \n                            <th width = '75px' >CustomerId : </th>\n                            <td>{$customer->CustomerId}</td>\n                        </tr>\n                          \n                        <tr>\n                            <th width = '75px' >Customer Name : </th>\n                            <td>{$customer->UserName}</td>\n                        </tr>\n                        \n                        <tr>\n                            <th>Address : </th>\n                            <td>{$customer->Address}</td>\n                        </tr>\n                        \n                        <tr>\n                            <th>Contact Number : </th>\n                            <td>{$customer->ContactNo}</td>\n                        </tr>\n                        \n                            \n                       \n      \n                                         \n                     </table>";
     }
     return $result;
 }
示例#7
0
 public function delete()
 {
     $view = new ViewModel('admin/customers');
     $customerModel = new CustomerModel();
     try {
         $view->assign('customers', $customerModel->deleteCustomer($_POST['delete']));
     } catch (PDOException $e) {
         $view->assign('message-type', 'error');
         $view->assign('message', 'Nie można usunąć klienta. Sprawdź czy nie jest powiązany z przesyłką lub zleceniem!');
         $view->display();
         return;
     }
     $view->assign('message-type', 'info');
     $view->assign('message', 'Usunięto klienta!');
     $view->display();
 }
 public function httpPostMethod(Http $http, array $formFields)
 {
     if (filter_var($formFields['Login'], FILTER_VALIDATE_EMAIL) != false) {
         $CustomerModel = new CustomerModel();
         $user_id = $CustomerModel->findWithCredentials($formFields['Login'], $formFields['Password']);
         //var_dump($user_id);
         if (ctype_digit($user_id)) {
             $user = $CustomerModel->findCustomer($user_id);
             $UserSession = new UserSession();
             $UserSession->create($user);
             $http->redirectTo('/');
         } else {
             $http->redirectTo('Exception?' . $user_id);
         }
     } else {
         $http->redirectTo('Exception?Error=4');
     }
 }
示例#9
0
文件: order.php 项目: davpal/Kuriex
 public function newOrder()
 {
     $view = new ViewModel('customer/newOrder');
     $post = array_filter($_POST);
     if (empty($post)) {
         $view->display();
         return;
     }
     $empty_fields = array();
     foreach ($_POST as $key => $value) {
         if (empty($value)) {
             $empty_fields[] = $key;
         }
     }
     if (!empty($empty_fields)) {
         $view->assign('message-type', 'error');
         $view->assign('message', 'Prosze wypełnić brakujące pola: ');
         $view->assign('fields', $empty_fields);
         $view->display();
         return;
     }
     $orderModel = new OrderModel();
     $customerModel = new CustomerModel();
     $logged = $customerModel->selectByEmail($_SESSION['user']);
     $prepare[0] = $logged['pesel_klienta'];
     $prepare[1] = NULL;
     $order = array_merge($prepare, array_values($_POST));
     try {
         $orderModel->newOrder($order);
     } catch (PDOException $e) {
         $view->assign('message-type', 'error');
         $view->assign('message', 'Błąd spójności danych!');
         $view->display();
         return;
     }
     $view->assign('message-type', 'info');
     $view->assign('message', 'Dodano zlecenie!');
     $view->display();
 }
示例#10
0
 /**
  * @param array $result
  *
  * @return array of customer records
  */
 public function getCustomers($result)
 {
     $customersMdl = new CustomerModel();
     $customers = $customersMdl->get();
     $contacts = $customersMdl->getContacts();
     if (is_array($customers)) {
         $cdata = [];
         foreach ($customers as $customer) {
             $customer['contacts'] = [];
             $cdata[$customer['id']] = $customer;
         }
         // add custoner contacts
         foreach ($contacts as $contact) {
             if (isset($cdata[$contact['customerid']])) {
                 $cdata[$contact['customerid']]['contacts'][$contact['id']] = $contact;
             }
         }
         $result['data'] = $cdata;
     } else {
         $result['error'] = $customersMdl->errorInfo;
     }
     return $result;
 }
示例#11
0
 /**
  * 兑换优惠券
  * @param $couponId
  * @param $openId
  * @return bool
  */
 public function exchangeCoupon($couponId, $openId)
 {
     $customerModel = new CustomerModel();
     $customer = $customerModel->readOne($openId);
     // 获得积分
     if (!$customer) {
         return false;
     }
     $coupon = $this->readOne($couponId);
     if (!$couponId) {
         return false;
     }
     if ($coupon['remain_number'] <= 0) {
         return false;
     }
     // 用户的积分 >= 所需要的积分
     if ($customer['credits'] >= $coupon['exchange_credits']) {
         $customerModel->subCredits($openId, $coupon['exchange_credits']);
         $this->subCouponNumber($couponId);
     } else {
         return false;
     }
 }
示例#12
0
 /**
  * Initialize the AddModel class
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     try {
         $pdo_options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION;
         $this->db = new \PDO('mysql:host=' . _HOST_ . ';dbname=' . _DATABASE_, _LOGIN_, _PASSWORD_, $pdo_options);
         $this->db->exec('SET NAMES utf8');
     } catch (Exception $e) {
         throw new Exception('Connexion à la base de données impossible: ' . $e->getMessage());
     }
 }
示例#13
0
 public function httpPostMethod(Http $http, array $formFields)
 {
     if (filter_var($formFields['Login'], FILTER_VALIDATE_EMAIL) != false) {
         try {
             $userSession = new UserSession();
             $CustomerModel = new CustomerModel();
             $user_id = $CustomerModel->findWithCredentials($formFields['Login'], $formFields['Password'], $_SERVER['REMOTE_ADDR']);
             if (ctype_digit($user_id)) {
                 $user = $CustomerModel->findCustomer($user_id);
                 $userSession->create($user);
                 $http->redirectTo('/');
             }
         } catch (DomainException $event) {
             //var_dump($event);
             $form = new LoginForm();
             $form->bind($formFields);
             $form->setErrorMessage($event->getMessage());
             return ['_form' => $form];
             //AVEC CONTROLEUR EXECPTION --- $http->redirectTo('Exception?'.$user_id);
         }
     } else {
         $http->redirectTo('Exception?Error=4');
     }
 }
示例#14
0
 private function insertDemoRecords()
 {
     $suppliers = json_decode('[{"id": 1, "name":"Joe\'s Fruit&Veg Supplies", "dt":"0000-00-00 00:00:00"},
                     {"id": 2, "name":"Elecsys Electronic Distibution", "dt":"0000-00-00 00:00:00"},
                     {"id": 3, "name":"Fitwear Clothing Wholesale", "dt":"0000-00-00 00:00:00"},
                     {"id": 4, "name":"Yumbox Packaged Goods", "dt":"0000-00-00 00:00:00"},
                     {"id": 5, "name":"No Place Like Home-warehouse", "dt":"0000-00-00 00:00:00"}]');
     if ($suppliers == false) {
         die("Failed to add suppliers");
     } else {
         $supMdl = new SuppliersModel();
         foreach ($suppliers as $supplier) {
             $supMdl->create($supplier->name);
         }
         echo "Inserted Suppliers.<br/>";
     }
     $items = json_decode('[{"id": 1,"supplierid": 1,"code": "A","qty": 1,"name": "Apple","description": "Golden Delicious","taxid": "2","price": "0.99", "type":"general", "modifiers":[]},
                 {"id": 2,"supplierid": 1,"code": "B","qty": 1,"name": "Bannana","description": "Lady Finger","taxid": "2","price": "3.00", "type":"general", "modifiers":[]},
                 {"id": 3,"supplierid": 1,"code": "C","qty": 1,"name": "Coconut","description": "","taxid": "2","price": "3.00", "type":"general", "modifiers":[]},
                 {"id": 4,"supplierid": 4,"code": "D","qty": 1,"name": "Doritos","description": "","taxid": "2","price": "2.50", "type":"general", "modifiers":[]},
                 {"id": 5, "supplierid": 4,"code": "E","qty": 1,"name": "Energy Drink","description": "","taxid": "2","price": "3.45", "type":"general", "modifiers":[]},
                 {"id": 6, "supplierid": 4,"code": "F","qty": 1,"name": "Chocolate Fudge","description": "","taxid": "2","price": "1.55", "type":"general", "modifiers":[]},
                 {"id": 7, "supplierid": 5,"code": "G","qty": 1,"name": "Gardening Gloves","description": "","taxid": "2","price": "8.55", "type":"general", "modifiers":[]},
                 {"id": 8,"supplierid": 5,"code": "H","qty": 1,"name": "Homewares","description": "","taxid": "1","price": "", "type":"general", "modifiers":[]},
                 {"id": 9,"supplierid": 4,"code": "I","qty": 1,"name": "Ice Cream","description": "","taxid": "1","price": "4.65", "type":"general", "modifiers":[]},
                 {"id": 10,"supplierid": 5,"code": "J","qty": 1,"name": "Jug","description": "","taxid": "1","price": "11.00", "type":"general", "modifiers":[]},
                 {"id": 11,"supplierid": 5,"code": "K","qty": 1,"name": "Kettle","description": "","taxid": "1","price": "15.00", "type":"general", "modifiers":[]},
                 {"id": 12,"supplierid": 1,"code": "L","qty": 1,"name": "Lime","description": "","taxid": "1","price": "2.00", "type":"general", "modifiers":[]},
                 {"id": 13,"supplierid": 3,"code": "M","qty": 1,"name": "Men\'s Clothing","description": "","taxid": "1","price": "", "type":"general", "modifiers":[]},
                 {"id": 14,"supplierid": 4,"code": "N","qty": 1,"name": "Nut mix","description": "","taxid": "1","price": "4.60", "type":"general", "modifiers":[]},
                 {"id": 15,"supplierid": 1,"code": "O","qty": 1,"name": "Orange","description": "","taxid": "1","price": "1.50", "type":"general", "modifiers":[]},
                 {"id": 16,"supplierid": 1,"code": "P","qty": 1,"name": "Pineapple","description": "","taxid": "1","price": "4.00", "type":"general", "modifiers":[]},
                 {"id": 17,"supplierid": 1,"code": "Q","qty": 1,"name": "Quince","description": "","taxid": "1","price": "1.70", "type":"general", "modifiers":[]},
                 {"id": 18,"supplierid": 4,"code": "R","qty": 1,"name": "Raviolli","description": "","taxid": "1","price": "7.35", "type":"general", "modifiers":[]},
                 {"id": 19,"supplierid": 4,"code": "S","qty": 1,"name": "Shapes Pizza","description": "","taxid": "1","price": "3.00", "type":"general", "modifiers":[]},
                 {"id": 20,"supplierid": 5,"code": "T","qty": 1,"name": "Toys","description": "","taxid": "1","price": "", "type":"general", "modifiers":[]},
                 {"id": 21,"supplierid": 5,"code": "U","qty": 1,"name": "Ukelele","description": "","taxid": "1","price": "16.90", "type":"general", "modifiers":[]},
                 {"id": 22,"supplierid": 3,"code": "V","qty": 1,"name": "Vest","description": "","taxid": "1","price": "47.00", "type":"general", "modifiers":[]},
                 {"id": 23,"supplierid": 3,"code": "W","qty": 1,"name": "Women\'s Clothing","description": "","taxid": "1","price": "", "type":"general", "modifiers":[]},
                 {"id": 24,"supplierid": 5,"code": "X","qty": 1,"name": "Xylophone","description": "","taxid": "1","price": "200.50", "type":"general", "modifiers":[]},
                 {"id": 25,"supplierid": 4,"code": "Y","qty": 1,"name": "Yeast","description": "","taxid": "1","price": "5.80", "type":"general", "modifiers":[]},
                 {"id": 26,"supplierid": 1,"code": "Z","qty": 1,"name": "Zuccini","description": "","taxid": "1","price": "1.10", "type":"general", "modifiers":[]},
                 {"id": 27,"supplierid": 4,"code": "BEER","qty": 1,"name": "Tasman Bitter","description": "375ml bottle","taxid": "1","price": "2.20", "type":"general", "modifiers":[]},
                 {"id": 28,"supplierid": 2,"code": "ROBO3D","qty": 1,"name": "Robo 3d Printer","description": "","taxid": "2","price": "599.00", "type":"general", "modifiers":[]},
                 {"id": 29,"supplierid": 2,"code": "PS4","qty": 1,"name": "Sony Playstation 4","description": "","taxid": "2","price": "600.00", "type":"general", "modifiers":[]},
                 {"id": 30,"supplierid": 2,"code": "XBOX","qty": 1,"name": "Xbox","description": "","taxid": "2","price": "600.00", "type":"general", "modifiers":[]}]');
     if ($items == false) {
         die("Failed to add items");
     } else {
         $itemMdl = new StoredItemsModel();
         foreach ($items as $item) {
             $itemMdl->create($item);
         }
         echo "Inserted Items.<br/>";
     }
     $locations = json_decode('[{"id": 1, "name":"Sydney", "dt":"0000-00-00 00:00:00"},
                     {"id": 2, "name":"Melbourne", "dt":"0000-00-00 00:00:00"},
                     {"id": 3, "name":"Adelaide", "dt":"0000-00-00 00:00:00"},
                     {"id": 4, "name":"Perth", "dt":"0000-00-00 00:00:00"}]');
     if ($locations == false) {
         die("Failed to add locations");
     } else {
         $locMdl = new LocationsModel();
         foreach ($locations as $location) {
             $locMdl->create($location->name);
         }
         echo "Inserted Locations.<br/>";
     }
     $devices = json_decode('[{"id": 1, "name":"Register 1", "locationid":1, "type":"general_register", "dt":"0000-00-00 00:00:00"},
                     {"id": 2, "name":"Register 2", "locationid":1, "type":"general_register", "dt":"0000-00-00 00:00:00"},
                     {"id": 3, "name":"Register 1", "locationid":2, "type":"general_register", "dt":"0000-00-00 00:00:00"},
                     {"id": 4, "name":"Register 2", "locationid":2, "type":"general_register", "dt":"0000-00-00 00:00:00"},
                     {"id": 5, "name":"Register 1", "locationid":3, "type":"general_register", "dt":"0000-00-00 00:00:00"},
                     {"id": 6, "name":"Register 1", "locationid":4, "type":"general_register", "dt":"0000-00-00 00:00:00"}]');
     if ($devices == false) {
         die("Failed to add devices");
     } else {
         $devMdl = new DevicesModel();
         foreach ($devices as $device) {
             $devMdl->create($device);
         }
         echo "Inserted Devices.<br/>";
     }
     $customers = json_decode('[{"id":1,"name":"Jo Doe", "email":"*****@*****.**", "address":"10 Fake St", "phone":"99999999", "mobile":"111111111", "suburb":"Faketown", "state":"NSW", "postcode":"2000", "country":"Australia", "notes":"", "dt":"0000-00-00 00:00:00"},
                     {"id": 2, "name":"Jane Doe", "email":"*****@*****.**", "address":"10 Fake St", "phone":"99999999", "mobile":"111111111", "suburb":"Faketown", "state":"NSW", "postcode":"2000", "country":"Australia", "notes":"", "dt":"0000-00-00 00:00:00"}]');
     if ($customers == false) {
         die("Failed to add customers");
     } else {
         $devMdl = new CustomerModel();
         foreach ($customers as $cust) {
             $devMdl->create($cust->email, $cust->name, $cust->phone, $cust->mobile, $cust->address, $cust->suburb, $cust->postcode, $cust->state, $cust->country);
         }
         echo "Inserted Customers.<br/>";
     }
 }
示例#15
0
 public function screen_detail_project()
 {
     $this->title = "お仕事の詳細";
     $this->message = "下記に応募しますか?";
     $project_id = "";
     $member_id = "";
     if (isset($_REQUEST['project_id'])) {
         $project_id = $_REQUEST['project_id'];
     }
     if (isset($_SESSION[_MEMBER_AUTHINFO]['id'])) {
         $member_id = $_SESSION[_MEMBER_AUTHINFO]['id'];
     }
     $CustomerModel = new CustomerModel();
     $data = $CustomerModel->get_project($project_id, $member_id);
     $data2 = $CustomerModel->get_customer_authinfo_id($data['company_id']);
     $this->view->assign('data', $data);
     $this->view->assign('data2', $data2);
     $this->file = "index_detail_project.tpl";
     $this->view_display();
 }
示例#16
0
 public function getExchangeGoods($exchangeGoodsId)
 {
     $openId = (new WeixinUtil())->getOpenId();
     if (!$openId) {
         ResponseUtil::failure('错误的授权!');
     }
     // 查询是否已经领取优惠券
     if ((new CustomerExchangeGoodsModel())->readOne($exchangeGoodsId, $openId)) {
         ResponseUtil::failure('您已经兑换了此商品!');
     }
     $exchangeGoods = (new ExchangeGoodsModel())->readOne($exchangeGoodsId);
     // 剩余数量为0
     if ($exchangeGoods['remain_number'] <= 0) {
         ResponseUtil::failure('商品已经兑换完!');
     }
     $today = date('Y-m-d');
     // 是否到领取时间
     if ($today < $exchangeGoods['start_time']) {
         ResponseUtil::failure('商品未到兑换时间!');
     }
     if ($today > $exchangeGoods['expire_time']) {
         ResponseUtil::failure('商品已过兑换时间!');
     }
     // 判断积分
     $customerModel = new CustomerModel();
     $customer = $customerModel->readOne($openId);
     if ($exchangeGoods['exchange_credits'] > $customer['credits']) {
         ResponseUtil::failure('积分不足,兑换商品失败!');
     }
     $userName = $this->input->post('contact_name', true);
     $phoneNumber = $this->input->post('contact_phone', true);
     $userName = urldecode($userName);
     // 检查用户
     $userName = trim(strip_tags($userName));
     if (empty($userName)) {
         ResponseUtil::failure('联系人不能为空,请检查!');
     }
     if (!preg_match('~^1\\d{10}$~', $phoneNumber)) {
         ResponseUtil::failure('手机号错误,请检查!');
     }
     $this->db->trans_start();
     // 领取
     $data = array('exchange_goods_id' => $exchangeGoodsId, 'open_id' => $openId, 'is_get' => 0, 'contact_name' => $userName, 'contact_phone' => $phoneNumber, 'exchange_time' => DateUtil::now());
     $customerExchangeGoodsId = (new CustomerExchangeGoodsModel())->create($data);
     if ($customerExchangeGoodsId) {
         (new ExchangeGoodsModel())->subExchangeGoodsNumber($exchangeGoodsId);
     }
     // 积分
     $customerModel->subCredits($openId, $exchangeGoods['exchange_credits']);
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         $this->db->trans_rollback();
         ResponseUtil::failure('兑换商品失败!');
     } else {
         $this->db->trans_commit();
         ResponseUtil::executeSuccess('兑换商品成功!');
     }
 }
示例#17
0
文件: Order.php 项目: guohao214/xinya
 /**
  * 微信支付后的异步回调
  */
 public function notice()
 {
     $weixin = new WeixinPayUtil();
     //通知微信
     $notice = $weixin->notifyData();
     // 签名成功, 返回数组, 否则返回xml数据
     if (!is_array($notice) || !isset($notice['transaction_id'])) {
         exit($notice);
     }
     //签名成功,处理数据
     /**
      * 返回的数据
      * 'appid' => string 'wxf5b5e87a6a0fde94' (length=18)
      * 'bank_type' => string 'CFT' (length=3)
      * 'fee_type' => string 'CNY' (length=3)
      * 'is_subscribe' => string 'N' (length=1)
      * 'mch_id' => string '10000097' (length=8)
      * 'nonce_str' => string 'dz8nirk7gmxhhxn38zgib28yx14ul2gf' (length=32)
      * 'openid' => string 'ozoKAt-MmA74zs7MBafCix6Dg8o0' (length=28)
      * 'out_trade_no' => string 'wxf5b5e87a6a0fde941409708791' (length=28)
      * 'result_code' => string 'SUCCESS' (length=7)
      * 'return_code' => string 'SUCCESS' (length=7)
      * 'sign' => string 'EDACA525F6C675337B2DAC25B7145028' (length=32)
      * 'sub_mch_id' => string '10000097' (length=8)
      * 'time_end' => string '20140903094659' (length=14)
      * 'total_fee' => string '1' (length=1)
      * 'trade_type' => string 'NATIVE' (length=6)
      * 'transaction_id' => string '1004400737201409030005091526' (length=28)  //微信支付单号
      */
     //        $notice  = array(
     //            'out_trade_no' => '201512271710391206225994',
     //            'transaction_id' => '1004400737201409030005091526'
     //        );
     $orderNo = $notice['out_trade_no'];
     $wxOrderNo = $notice['transaction_id'];
     $openId = $notice['openid'];
     $orderModel = new OrderModel();
     // 获得订单
     $orders = $orderModel->orders(array('order_no' => $orderNo));
     if (!$orders || !$orders[0]) {
         exit($weixin->notifyFailure());
     }
     // 判断是否已经支付
     $order = $orders[0];
     if ($order['order_sign'] == OrderModel::ORDER_PAYED) {
         exit($weixin->notifyPayed());
     }
     // 更新订单信息
     $this->db->trans_start();
     $orderModel->payed($orderNo, $wxOrderNo);
     // 更新积分
     $customerModel = new CustomerModel();
     $score = $order['total_fee'];
     $customer = $customerModel->readOne($openId);
     if ($customer) {
         $customerModel->addCredits($openId, $score);
     }
     // 事物完成
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         $this->db->trans_rollback();
         exit($weixin->notifyFailure());
     } else {
         $this->db->trans_commit();
         // 获得access token
         $weixinUtil = new WeixinUtil();
         $token = $weixinUtil->getToken();
         if ($token) {
             //foreach ($orders as $order) {
             $orderNo = $order['order_no'];
             $appointmentDay = DateUtil::buildDateTime($order['appointment_day'], $order['appointment_start_time']);
             $shops = (new ShopModel())->getAllShops();
             $shop = $shops[$order['shop_id']];
             $beautician = (new BeauticianModel())->readOne($order['beautician_id']);
             $beauticianName = $beautician['name'];
             $project = (new CurdUtil(new OrderProjectModel()))->readOne(array('order_id' => $order['order_id']));
             $projectName = $project['project_name'];
             // 计算总积分
             $totalCredits = $customer['credits'] + $score;
             // 发送模板消息
             // $orderNo, $appointmentDay, $shop, $beautician, $projectName
             $weixinUtil->sendOrderMessage($orderNo, $appointmentDay, $shop, $beauticianName, $projectName, $openId, $token, $totalCredits);
             //}
         }
         exit($weixin->notifySuccess());
     }
 }
 /**
  * Perform user initiated password reset using the given token
  * @param $result
  * @return mixed
  */
 public function doPasswordReset($result)
 {
     // validate input + additional validation
     $jsonval = new JsonValidate($this->data, '{"pass":"", "token":""}');
     if (($errors = $jsonval->validate()) !== true) {
         $result['error'] = $errors;
         return $result;
     }
     $custMdl = new CustomerModel();
     $tokres = $custMdl->tokenReset($this->data->token, $this->data->pass);
     if ($tokres === 0) {
         $result['error'] = "Failed to reset password using the given token\nThe token may have expired.";
     } else {
         if ($tokres === false) {
             $result['error'] = "Failed to update your password: " . $custMdl->errorInfo;
         }
     }
     return $result;
 }
示例#19
0
 /**
  * Send password reset email to customer
  * @param $result
  * @return mixed
  */
 public function sendResetEmail($result)
 {
     // validate input
     if (!is_numeric($this->data->id)) {
         $result['error'] = "A valid id must be supplied";
         return $result;
     }
     // get customer details
     $custMdl = new CustomerModel();
     $customer = $custMdl->get($this->data->id)[0];
     if (strpos($customer['email'], '@') === -1) {
         $result['error'] = "The customer does not have a valid email";
         return $result;
     }
     // generate url
     $token = WposAdminUtilities::getToken();
     $link = "https://" . $_SERVER['SERVER_NAME'] . "/myaccount/resetpassword.php?token=" . $token;
     // set token
     if ($custMdl->setAuthToken($this->data->id, $token) === false) {
         $result['error'] = "Could not set auth token: " . $custMdl->errorInfo;
     }
     // send reset email
     $linkhtml = '<a href="' . $link . '">' . $link . '</a>';
     $mailer = new WposMail();
     if (($mres = $mailer->sendPredefinedMessage($customer['email'], 'reset_email', ['name' => $customer['name'], 'link' => $linkhtml])) !== true) {
         $result['error'] = $mres;
     }
     return $result;
 }
示例#20
0
 /**
  * Attempt a login; on success setup session vars and send to node server else log the failed attempt
  * @param $username
  * @param $password
  * @return bool|int
  */
 public function customerLogin($username, $password)
 {
     $custMdl = new CustomerModel();
     $customer = $custMdl->login($username, $password, true);
     if ($customer == -1) {
         // log data
         Logger::write("An authentication attempt was made by " . $username . " but the customer has been disabled.", "AUTH");
         return -1;
         // the user is disabled
     }
     if ($customer == -2) {
         return -2;
         // the user is not activated
     }
     if (is_array($customer)) {
         // check for
         $_SESSION['cust_username'] = $username;
         $_SESSION['cust_name'] = $customer['name'];
         $_SESSION['cust_id'] = $customer['id'];
         $_SESSION['cust_hash'] = $customer['pass'];
         // log data
         Logger::write("Authentication successful for customer:" . $username, "AUTH");
         return true;
     } else {
         // log data
         Logger::write("Authentication failed for customer:" . $username . " with hash:" . $password, "AUTH");
         return false;
     }
 }
示例#21
0
 /**
  * 检测微信登录
  */
 public function loginCallback($code)
 {
     if (!$code) {
         return false;
     }
     $accessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?" . "appid={$this->appId}&secret={$this->appSecret}&code={$code}&grant_type=authorization_code";
     $accessToken = RequestUtil::get($accessTokenUrl);
     LogUtil::weixinLog('授权登录:', $accessToken);
     if (!$accessToken || $accessToken['error']) {
         return false;
     }
     $this->saveAuthorize($accessToken);
     // 判断是否已经获取了微信用户信息
     $customerModel = new CustomerModel();
     $customer = $customerModel->readOne($this->getOpenId());
     if (!$customer) {
         $userInfo = $this->getWeixinUserInfo($this->getToken(), $this->getOpenId());
         $customerModel->insert($this->getOpenId(), 0, $userInfo['nickname'], $userInfo['headimgurl'], $userInfo['city'], $userInfo['province'], $userInfo['sex']);
     } else {
         if (!$customer['nick_name']) {
             $userInfo = $this->getWeixinUserInfo($this->getToken(), $this->getOpenId());
             $customerModel->update($this->getOpenId(), $userInfo['nickname'], $userInfo['headimgurl'], $userInfo['city'], $userInfo['province'], $userInfo['sex']);
         } else {
         }
     }
     return true;
 }
示例#22
0
 /**
  * get single CustomerModel instance from a DOMElement
  *
  * @param DOMElement $node
  * @return CustomerModel
  */
 public static function fromDOMElement(DOMElement $node)
 {
     if ('CustomerModel' != $node->nodeName) {
         return new InvalidArgumentException('expected: CustomerModel, got: ' . $node->nodeName, 0);
     }
     $result = array();
     foreach (self::$FIELD_NAMES as $fieldName) {
         $n = $node->getElementsByTagName($fieldName)->item(0);
         if (!is_null($n)) {
             $result[$fieldName] = $n->nodeValue;
         }
     }
     $o = new CustomerModel();
     $o->assignByHash($result);
     $o->notifyPristine();
     return $o;
 }
示例#23
0
 public function system_get_detail_message_messsage_id($message_id)
 {
     try {
         $sql = " SELECT * FROM message \n                    WHERE\n                     id = :message_id \n                     limit 1 ";
         $stmh = $this->pdo->prepare($sql);
         $stmh->bindValue(':message_id', $message_id, PDO::PARAM_INT);
         $stmh->execute();
         $i = 0;
         $data = array();
         $MemberModel = new MemberModel();
         $CustomerModel = new CustomerModel();
         $ActionModel = new ActionModel();
         $data = $stmh->fetch(PDO::FETCH_ASSOC);
         $action_data = $ActionModel->get_action_id($data['action_id']);
         $customer_data = $CustomerModel->get_customer_authinfo_id($data['company_id']);
         $member_data = $MemberModel->get_member_base_info_id($data['member_id']);
         $project_data = $CustomerModel->get_project_title($data['project_id']);
         $data['action_reg_date'] = $action_data['reg_date'];
         $data['company_name'] = $customer_data['company_name'];
         $data['member_name'] = $member_data['last_name'] . '&nbsp;' . $member_data['first_name'];
         $data['title'] = $project_data;
         $data['body'] = htmlspecialchars($data['body'], ENT_QUOTES);
         $data['body'] = nl2br($data['body']);
         $i++;
     } catch (PDOException $Exception) {
         print "エラー" . $Exception->getMessage();
     }
     return $data;
 }
示例#24
0
 public function get_base_applicant_list($data)
 {
     $MemberModel = new MemberModel();
     $CustomerModel = new CustomerModel();
     $array = array();
     for ($i = 0; $i < count($data); $i++) {
         $project_data = $CustomerModel->get_project($data[$i]['project_id']);
         $member_data = $MemberModel->get_member_base_info_id($data[$i]['member_id']);
         $array[$i]['action_id'] = $data[$i]['id'];
         $array[$i]['project_title'] = $project_data['title'];
         $array[$i]['project_reg_date'] = $project_data['reg_date'];
         $array[$i]['member_last_name'] = $member_data['last_name'];
         $now = date('Ymd');
         $array[$i]['member_age'] = floor(($now - $member_data['birthday']) / 10000);
         $array[$i] = array_merge($array[$i], $data[$i]);
     }
     return $array;
 }
示例#25
0
 /**
  * Generate invoice html
  * @return string
  */
 private function generateInvoiceHtml()
 {
     // copy invoice data, set tax values
     /** @noinspection PhpUnusedLocalVariableInspection */
     $invoice = $this->trans;
     $taxMdl = new TaxItemsModel();
     $taxdata = $taxMdl->get();
     $taxes = [];
     foreach ($taxdata as $value) {
         $taxes[$value['id']] = (object) $value;
     }
     // Get general settings
     $config = new WposAdminSettings();
     $settings = $config->getSettingsObject("general");
     $settings->payinst = $config->getSettingsObject("invoice")->payinst;
     // Get customer record
     $custMdl = new CustomerModel();
     /** @noinspection PhpUnusedLocalVariableInspection */
     $customer = (object) $custMdl->get($this->trans->custid)[0];
     $utils = new WposAdminUtilities();
     $utils->setCurrencyFormat($settings->currencyformat);
     // start output buffer and capture template output
     ob_start();
     include $_SERVER['DOCUMENT_ROOT'] . "/docs/templates/invoice.php";
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }