Example #1
0
 /**
  * 插入
  * @param 认证类型 $auth_type
  * @param 数据库连接 $conn
  */
 public function insertVendorAuth($auth_type, $conn)
 {
     $res = -1;
     $data = array('auth_type' => $auth_type, "auth_license_loc" => "", "auth_ispass" => 1);
     if (self::insertTransaction($data, $conn)) {
         $res = DaoBase::_getLastId($conn);
     }
     return $res;
 }
Example #2
0
 /**
  * 插入
  * @param 商家公司名称  $info_name
  * @param 数据库连接 $conn
  */
 public function insertVendorInfo($info_name, $conn)
 {
     $res = -1;
     $data = array('info_name' => $info_name);
     if (self::insertTransaction($data, $conn)) {
         $res = DaoBase::_getLastId($conn);
     }
     return $res;
 }
Example #3
0
 /**
  * 插入数据
  * @param 用户名 $name
  * @param 密码 $pwd
  * @param 基本信息id $info_id
  * @param 数据库连接 $conn
  * @return 成功,返回id,失败返回-1
  */
 public function insertVendor($name, $pwd, $info_id, $iden_id, $certi_id, $conn)
 {
     $res = -1;
     $data = array("vendor_name" => $name, "vendor_pass" => $pwd, "vendor_info_id" => $info_id, "vendor_time" => Tools::getNowTime(), "vendor_certi_id" => $certi_id, "vendor_iden_id" => $iden_id, "vendor_isadmin" => 0, "vendor_isdelete" => 0);
     if (self::insertTransaction($data, $conn)) {
         $res = DaoBase::_getLastId($conn);
     }
     return $res;
 }
Example #4
0
 function DaoBase($conn = NULL)
 {
     global $hostname, $dbusername, $dbpassword, $dbname;
     DaoBase::$dbhost = $hostname;
     DaoBase::$dbuser = $dbusername;
     DaoBase::$dbpwd = $dbpassword;
     DaoBase::$dbinst = $dbname;
     $this->table_name = "";
     if (isset($conn)) {
         $this->conn = $conn;
     } else {
     }
 }
 /**
  * 新增产品信息
  * 1、保存产品基本信息basicinfo
  * 2、保存生长周期图片product_growimages
  * 3、保存肥料,农药使用表fertilizer_pesticides_use
  * 4、产品认证 product_certi
  * 5、购买信息 product_buyinfo
  * 6、保存product表
  * @param 产品的记录  $record
  * 这个函数负责产品认证信息
  */
 public function addProductRecord($record)
 {
     $result = false;
     //新建一个连接
     $conn = DaoBase::_getConn();
     mysql_query("BEGIN");
     //或者mysql_query("START TRANSACTION");
     //新建一个产品
     $productDAO = new DaoProduct();
     $product = array("product_intro" => $record['product_intro']);
     $isRight = false;
     $isUpdate = false;
     $productID = null;
     if (empty($record['product_id'])) {
         $productResult = $productDAO->insertTransaction($product, $conn);
         if ($productResult) {
             $productID = $productDAO->_getLastId($conn);
             $isRight = true;
         }
     } else {
         $productID = $record['product_id'];
         $isRight = true;
         $isUpdate = true;
     }
     if ($isRight) {
         //更新product_basicinfo表
         $record['basicinfo']['product_id'] = $productID;
         $resBasicinfo = $this->saveBasicinfo($record['basicinfo'], $conn);
         //更新product_growimages表
         $resGrowimages = $this->saveGrowimages($record['growimages'], $conn);
         if ($resGrowimages['result']) {
             $product['growthing_img_list'] = $resGrowimages['idList'];
         }
         //更新fertilizer_pesticides_use表 fertilizer 肥料,pesticides 农药
         $resFerPesUse = $this->saveFerPesUse($record['fertilizer'], $record['pesticides'], $conn);
         if ($resFerPesUse['result']) {
             $product['fertilizer_list'] = $resFerPesUse['ferIdList'];
             $product['pesticides_list'] = $resFerPesUse['pesIdList'];
         }
         //更新产品认证表 product_certi
         $resCerti = $this->saveProCerti($record['certi'], $conn);
         if ($resCerti['result']) {
             $product['product_certi_list'] = $resCerti['certiIdList'];
         }
         //更新产品购买信息表 product_buyinfo
         $resBuyInfo = $this->saveProBuyinfo($record['buyinfo'], $conn);
         if ($resBuyInfo['result']) {
             $product['buy_info_list'] = $resBuyInfo['buyinfoIdList'];
         }
         $resultAll = $resBasicinfo['result'] && $resGrowimages['result'] && $resFerPesUse['result'] && $resCerti['result'] && $resBuyInfo['result'];
         if ($resultAll) {
             if ($isUpdate) {
                 $data = array("growthing_img_list" => $product['growthing_img_list'], "fertilizer_list" => $product['fertilizer_list'], "pesticides_list" => $product['pesticides_list'], "product_certi_list" => $product['product_certi_list'], "product_intro" => $product['product_intro'], "buy_info_list" => $product['buy_info_list']);
                 $daoProduct = new DaoProduct();
                 $result = $daoProduct->updateTransaction($conn, $data, array("product_id =" => $productID));
             } else {
                 //获取商家id
                 $vendor = User::_getVendor();
                 //生成二维码
                 $url = "http://www.baidu.com";
                 $product['qrcodeloc'] = "";
                 $product['qrcodeloc'] = Tools::createQRcode($url);
                 if (!empty($vendor)) {
                     $product['vendor_id'] = $vendor['vendor_id'];
                     //更新产品信息
                     $data = array("vendor_id" => $product['vendor_id'], "growthing_img_list" => $product['growthing_img_list'], "fertilizer_list" => $product['fertilizer_list'], "pesticides_list" => $product['pesticides_list'], "video_loc" => "", "environment_data_exist" => 0, "product_certi_list" => $product['product_certi_list'], "product_intro" => $product['product_intro'], "buy_info_list" => $product['buy_info_list'], "batchlist" => "", "qrcodeloc" => $product['qrcodeloc'], "product_isdelete" => 0);
                     $daoProduct = new DaoProduct();
                     $result = $daoProduct->updateTransaction($conn, $data, array("product_id =" => $productID));
                 }
             }
         }
     }
     if ($result) {
         mysql_query("COMMIT");
     } else {
         mysql_query("ROLLBACK");
     }
     DaoBase::_closeConn($conn);
     return $result;
 }
Example #6
0
 public function updateVendorOtherInfo($vendor_desc, $vendor_topImg, $vendor_logoImg)
 {
     $result = false;
     //获取数据库连接
     $conn = DaoBase::_getConn();
     mysql_query("BEGIN");
     //或者mysql_query("START TRANSACTION");
     //获取Session中的vendor
     $vendor = User::_getVendor();
     if ($vendor != null) {
         $infoId = $vendor['vendor_info_id'];
         //更新商家信息
         $data = array("vendor_desc" => $vendor_desc);
         if ($vendor_topImg != null) {
             $data['vendor_adver_loc'] = $vendor_topImg;
         }
         if ($vendor_logoImg != null) {
             $data['vendor_img_loc'] = $vendor_logoImg;
         }
         $where = array("info_id = " => $infoId);
         $dao = new DaoVendorInfo();
         $result = $dao->update($data, $where);
     }
     if ($result) {
         mysql_query("COMMIT");
         //更新session信息
     } else {
         mysql_query("ROLLBACK");
     }
     DaoBase::_closeConn($conn);
     return $result;
 }
Example #7
0
 /** 
  * 构造函数
  * 
  * @return 
  */
 public function __construct()
 {
     parent::__construct('entity\\ChapterInfoDao');
 }
Example #8
0
 protected static function SetErro($msg)
 {
     self::$erro = $msg;
 }
Example #9
0
 /** 
  * 构造函数
  * 
  * @return 
  */
 public function __construct()
 {
     parent::__construct('entity\\UserChapterDao');
 }
 /**
  * 发布批次
  * @param 产品id $productID
  * @param 批次信息 $batch
  * 1. 判断产品状态是否为已通过,只有审核通过的产品才能发布批次
  * 2. 创建产品批次信息
  * 3. 更新product表中的Batchlist字段
  */
 public function addProductBatch($productID, $batch)
 {
     $result = false;
     $daoProduct = new DaoProduct();
     $products = $daoProduct->getProductByproductId($productID);
     $daoProductBasicinfo = new DaoProductBasicinfo();
     $basicinfo = $daoProductBasicinfo->getProductBasicinfoByproductId($productID);
     $product = array();
     if (count($products) != 1 || count($basicinfo) != 1) {
         return $result;
     } else {
         $product = $products[0];
     }
     //判断产品状态是否合格
     if ($basicinfo[0]['basicinfo_status'] != 3) {
         return $result;
     }
     $conn = DaoBase::_getConn();
     mysql_query("BEGIN");
     //或者mysql_query("START TRANSACTION");
     $batchResult = false;
     $productResult = false;
     $data = array("batch_harvesttime" => Tools::getNowTime(), "batch_num" => Tools::getFileName(), "batch_auditstatus" => 1, "batch_isvalid" => 1, "batch_isdelete" => 0, "batch_remark_color" => $batch['color'], "batch_remark_power" => $batch['power'], "batch_remark_weight" => $batch['weight'], "batch_remark_SugarScale" => $batch['sugar'], "batch_remark_other" => $batch['other'], "batch_qrcode_loc" => $batch['batch_qrcode_loc']);
     $batchDAO = new DaoProductBatch();
     $batchResult = $batchDAO->insertTransaction($data, $conn);
     if ($batchResult) {
         $batchID = $batchDAO->_getLastId($conn);
         //更新product表
         $batchlist = $product['batchlist'];
         if (!empty($batchlist)) {
             $batchlist .= "," . $batchID;
         } else {
             $batchlist = $batchID;
         }
         $dao = new DaoProduct();
         $productResult = $dao->updateTransaction($conn, array("batchlist" => $batchlist), array("product_id = " => $productID));
     }
     $result = $batchResult && $productResult;
     if ($result) {
         mysql_query("COMMIT");
     } else {
         mysql_query("ROLLBACK");
     }
     DaoBase::_closeConn($conn);
     return $result;
 }