|
- <?php
- class DbDisney
- {
-
- var $dbh;
-
- function __construct($dbh) {
- $this->dbh = $dbh;
- }
-
- ///////////////////////////////////////////
- // GET //
- ///////////////////////////////////////////
- function getGoodsArray( $good_type = false ) {
- $sqlWhere = " SELECT * FROM good WHERE ";
- if( $good_type == false ) {
- $sqlWhere .= " is_delete=0 ";
- } else {
- $sqlWhere .= " good_type = {$good_type} AND is_delete=0 ";
- }
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row : false;
- }
-
- function getGoodInfoFromId( $id ) {
- $sqlWhere = " SELECT * FROM good WHERE id={$id} ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row[0] : false;
- }
-
- function getOrderInfoFromSN( $serial_no ) {
- $sqlWhere = " SELECT * FROM order_common WHERE order_serial_no='{$serial_no}' ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row[0] : false;
- }
-
- function getOrderGoodsArray( $order_id ) {
- $sqlWhere = " SELECT * FROM order_goods WHERE order_id='{$order_id}' ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row : false;
- }
-
- function getCS1Info( $org_id ) {
- $sqlWhere = " SELECT * FROM cs1 WHERE org_id = '{$org_id}' ";
- echo $sqlWhere;
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row[0] : false;
- }
-
- function getCS1Array() {
- $sqlWhere = " SELECT * FROM cs1 WHERE org_id > 0 ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row : false;
- }
- function getCS2Array() {
- $sqlWhere = " SELECT * FROM cs2 WHERE org_id > 0 ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row : false;
- }
-
- function getUnpaidOrder($serial_no){
- //$sqlWhere = " SELECT order_price,prod_name FROM order_common WHERE order_serial_no='{$serial_no}' AND status=0 AND is_payed=0 AND pay_type=0";
- $sqlWhere = "SELECT a.order_serial_no,a.order_price,a.prod_name,b.good_type,a.cus_name,a.cus_mobile,a.create_time,a.outside_order_no FROM order_common AS a INNER JOIN good AS b ON a.prod_id=b.id WHERE a.order_serial_no='{$serial_no}' AND a.`status`=0 AND a.is_payed=0 AND a.pay_type=0";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row[0] : false;
- }
-
- function getBaseOrgInfoFromId( $id ) {
- $sqlWhere = " SELECT * FROM base_org WHERE org_id={$id} ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row[0] : false;
- }
-
- function getBaseOrgInfoFromCode( $code ) {
- $sqlWhere = " SELECT * FROM base_org WHERE org_code='{$code}' ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row[0] : false;
- }
-
- function getDisney2csArray() {
- $sqlWhere = " SELECT d_order_id FROM disney2cs WHERE id > 0 ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row : false;
- }
-
- function getActiveOrderCommonCount( $extra_sql = false ) {
- $sqlWhere = " SELECT count(id) as total_num FROM order_common WHERE (( order_user_id = 0 AND is_payed = 1 ) OR order_user_id > 0 )";
- if( $extra_sql != false ) {
- $sqlWhere .= " AND ".$extra_sql;
- }
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row[0]["total_num"] : 0;
- }
-
- function getActiceOrderCommonArray( $extra_sql = false, $limit = false ) {
- $sqlWhere = " SELECT * FROM order_common WHERE (( order_user_id = 0 AND is_payed = 1 ) OR order_user_id > 0 )";
- if( $extra_sql != false ) {
- $sqlWhere .= " AND ".$extra_sql;
- }
- if( $limit != false ) {
- $sqlWhere .= $limit;
- }
-
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row : false;
- }
-
- function getBaseOrgArray() {
- $sqlWhere = " SELECT * FROM base_org WHERE org_id > 0 ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row : false;
- }
- function getBaseOrgAndAccountArray() {
- $sqlWhere = " SELECT * FROM base_org,account WHERE base_org.org_id > 0 AND account.org_id=base_org.org_id ORDER BY base_org.org_id";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row : false;
- }
-
- function getLoginAccountInfo( $user_name, $user_pwd ) {
- $sqlWhere = " SELECT * FROM account WHERE account_name='{$user_name}' AND account_pwd='{$user_pwd}' ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row[0] : false;
- }
-
- function getAccountInfoFromId( $id ) {
- $sqlWhere = " SELECT * FROM account WHERE id={$id} ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row[0] : false;
- }
-
-
- function getWarnOrderCommonArray( $start_time ) {
- $sqlWhere = " SELECT * FROM order_common WHERE send_warn_message = 0 AND prod_id IN(1,2) AND start_time <= '{$start_time}' AND (( order_user_id = 0 AND is_payed = 1 ) OR order_user_id > 0 )";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row : false;
- }
-
-
- function getStartEndTimeArray( $type_id, $org_id ) {
- $sqlWhere = " SELECT * FROM start_end_time WHERE good_type_id = {$type_id} AND org_id IN(0,{$org_id}) ";
- $row = $this->dbh->getMultiRow($sqlWhere);
- return ($row)? $row : false;
- }
- ///////////////////////////////////////////
- // UPDATE //
- ///////////////////////////////////////////
- function updateOrderCommonInfo( $id, $update_array ) {
- return $this->dbh->update('order_common', $update_array, 'order_serial_no', $id);
- }
-
- ///////////////////////////////////////////
- // INSERT //
- ///////////////////////////////////////////
- function insertNewOrder( $order_array ) {
- return $this->dbh->insert( 'order_common', $order_array );
- }
-
- function insertOrderGoods( $order_goods_array ) {
- foreach( $order_goods_array as $order_goods_info ) {
- $this->dbh->insert( 'order_goods', $order_goods_info );
- }
- }
-
-
- }
|