Ejemplo n.º 1
0
 /**
  * @param int $supplierId 供应商id
  * @return array 渠道包管理列表
  */
 public function getChannelListBySupplierId($supplierId, $page = 1, $page_size = 10)
 {
     if (!empty($supplierId) && is_numeric($supplierId)) {
         $where = array("supplier_id" => $supplierId);
     }
     $offest = ($page - 1) * $page_size;
     $channeList = $this->supplier_channel_channels->find($where, array(), $page_size, $offest);
     if (!empty($channeList)) {
         $supplierIds = array();
         foreach ($channeList as $channeRow) {
             $supplierIds[] = $channeRow['supplier_id'];
         }
         $supplierListRs = $this->supplier_channel_account->findById($supplierIds);
         $supplierList = array();
         foreach ($supplierListRs as $supplierRow) {
             $supplierList[$supplierRow['id']] = $supplierRow;
         }
         foreach ($channeList as &$channeRow) {
             $supplier_id = $channeRow['supplier_id'];
             $channeRow['supplier'] = $supplierList[$supplier_id]['supplier'];
             $channeRow['price'] /= 100;
             // 数据库存储单位为分
         }
     }
     return $channeList;
 }
Ejemplo n.º 2
0
 public function addSupplier($supplier, $new_username, $new_password)
 {
     $result = "";
     if (!trim($supplier)) {
         return "0aa";
     }
     $is_legal_username = preg_match("/^[a-zA-Z0-9_@.]{6,50}\$/", $new_username);
     if (!$is_legal_username) {
         return "a0a";
     }
     $is_legal_password = preg_match("/[0-9]{6}/", $new_password);
     if (!$is_legal_password) {
         return "aa0";
     }
     $suppliers = $this->getSuppliers();
     if (in_array($supplier, $suppliers)) {
         return "1aa";
     }
     $accounts = $this->getAccounts();
     if (in_array($new_username, $accounts)) {
         return "a1a";
     }
     $new_password = md5($new_password);
     $row_affected = $this->supplier_channel_account->insert(array('supplier' => $supplier, 'account_name' => $new_username, 'password' => $new_password, 'is_admin' => 0));
     if ($row_affected > 0) {
         $result = "aaa";
     }
     return $result;
 }