Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

166 wiersze
6.6 KiB

  1. <?php
  2. class DbDisney
  3. {
  4. var $dbh;
  5. function __construct($dbh) {
  6. $this->dbh = $dbh;
  7. }
  8. ///////////////////////////////////////////
  9. // GET //
  10. ///////////////////////////////////////////
  11. function getGoodsArray( $good_type = false ) {
  12. $sqlWhere = " SELECT * FROM good WHERE ";
  13. if( $good_type == false ) {
  14. $sqlWhere .= " is_delete=0 ";
  15. } else {
  16. $sqlWhere .= " good_type = {$good_type} AND is_delete=0 ";
  17. }
  18. $row = $this->dbh->getMultiRow($sqlWhere);
  19. return ($row)? $row : false;
  20. }
  21. function getGoodInfoFromId( $id ) {
  22. $sqlWhere = " SELECT * FROM good WHERE id={$id} ";
  23. $row = $this->dbh->getMultiRow($sqlWhere);
  24. return ($row)? $row[0] : false;
  25. }
  26. function getOrderInfoFromSN( $serial_no ) {
  27. $sqlWhere = " SELECT * FROM order_common WHERE order_serial_no='{$serial_no}' ";
  28. $row = $this->dbh->getMultiRow($sqlWhere);
  29. return ($row)? $row[0] : false;
  30. }
  31. function getOrderGoodsArray( $order_id ) {
  32. $sqlWhere = " SELECT * FROM order_goods WHERE order_id='{$order_id}' ";
  33. $row = $this->dbh->getMultiRow($sqlWhere);
  34. return ($row)? $row : false;
  35. }
  36. function getCS1Info( $org_id ) {
  37. $sqlWhere = " SELECT * FROM cs1 WHERE org_id = '{$org_id}' ";
  38. echo $sqlWhere;
  39. $row = $this->dbh->getMultiRow($sqlWhere);
  40. return ($row)? $row[0] : false;
  41. }
  42. function getCS1Array() {
  43. $sqlWhere = " SELECT * FROM cs1 WHERE org_id > 0 ";
  44. $row = $this->dbh->getMultiRow($sqlWhere);
  45. return ($row)? $row : false;
  46. }
  47. function getCS2Array() {
  48. $sqlWhere = " SELECT * FROM cs2 WHERE org_id > 0 ";
  49. $row = $this->dbh->getMultiRow($sqlWhere);
  50. return ($row)? $row : false;
  51. }
  52. function getUnpaidOrder($serial_no){
  53. //$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";
  54. $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";
  55. $row = $this->dbh->getMultiRow($sqlWhere);
  56. return ($row)? $row[0] : false;
  57. }
  58. function getBaseOrgInfoFromId( $id ) {
  59. $sqlWhere = " SELECT * FROM base_org WHERE org_id={$id} ";
  60. $row = $this->dbh->getMultiRow($sqlWhere);
  61. return ($row)? $row[0] : false;
  62. }
  63. function getBaseOrgInfoFromCode( $code ) {
  64. $sqlWhere = " SELECT * FROM base_org WHERE org_code='{$code}' ";
  65. $row = $this->dbh->getMultiRow($sqlWhere);
  66. return ($row)? $row[0] : false;
  67. }
  68. function getDisney2csArray() {
  69. $sqlWhere = " SELECT d_order_id FROM disney2cs WHERE id > 0 ";
  70. $row = $this->dbh->getMultiRow($sqlWhere);
  71. return ($row)? $row : false;
  72. }
  73. function getActiveOrderCommonCount( $extra_sql = false ) {
  74. $sqlWhere = " SELECT count(id) as total_num FROM order_common WHERE (( order_user_id = 0 AND is_payed = 1 ) OR order_user_id > 0 )";
  75. if( $extra_sql != false ) {
  76. $sqlWhere .= " AND ".$extra_sql;
  77. }
  78. $row = $this->dbh->getMultiRow($sqlWhere);
  79. return ($row)? $row[0]["total_num"] : 0;
  80. }
  81. function getActiceOrderCommonArray( $extra_sql = false, $limit = false ) {
  82. $sqlWhere = " SELECT * FROM order_common WHERE (( order_user_id = 0 AND is_payed = 1 ) OR order_user_id > 0 )";
  83. if( $extra_sql != false ) {
  84. $sqlWhere .= " AND ".$extra_sql;
  85. }
  86. if( $limit != false ) {
  87. $sqlWhere .= $limit;
  88. }
  89. $row = $this->dbh->getMultiRow($sqlWhere);
  90. return ($row)? $row : false;
  91. }
  92. function getBaseOrgArray() {
  93. $sqlWhere = " SELECT * FROM base_org WHERE org_id > 0 ";
  94. $row = $this->dbh->getMultiRow($sqlWhere);
  95. return ($row)? $row : false;
  96. }
  97. function getBaseOrgAndAccountArray() {
  98. $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";
  99. $row = $this->dbh->getMultiRow($sqlWhere);
  100. return ($row)? $row : false;
  101. }
  102. function getLoginAccountInfo( $user_name, $user_pwd ) {
  103. $sqlWhere = " SELECT * FROM account WHERE account_name='{$user_name}' AND account_pwd='{$user_pwd}' ";
  104. $row = $this->dbh->getMultiRow($sqlWhere);
  105. return ($row)? $row[0] : false;
  106. }
  107. function getAccountInfoFromId( $id ) {
  108. $sqlWhere = " SELECT * FROM account WHERE id={$id} ";
  109. $row = $this->dbh->getMultiRow($sqlWhere);
  110. return ($row)? $row[0] : false;
  111. }
  112. function getWarnOrderCommonArray( $start_time ) {
  113. $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 )";
  114. $row = $this->dbh->getMultiRow($sqlWhere);
  115. return ($row)? $row : false;
  116. }
  117. function getStartEndTimeArray( $type_id, $org_id ) {
  118. $sqlWhere = " SELECT * FROM start_end_time WHERE good_type_id = {$type_id} AND org_id IN(0,{$org_id}) ";
  119. $row = $this->dbh->getMultiRow($sqlWhere);
  120. return ($row)? $row : false;
  121. }
  122. ///////////////////////////////////////////
  123. // UPDATE //
  124. ///////////////////////////////////////////
  125. function updateOrderCommonInfo( $id, $update_array ) {
  126. return $this->dbh->update('order_common', $update_array, 'order_serial_no', $id);
  127. }
  128. ///////////////////////////////////////////
  129. // INSERT //
  130. ///////////////////////////////////////////
  131. function insertNewOrder( $order_array ) {
  132. return $this->dbh->insert( 'order_common', $order_array );
  133. }
  134. function insertOrderGoods( $order_goods_array ) {
  135. foreach( $order_goods_array as $order_goods_info ) {
  136. $this->dbh->insert( 'order_goods', $order_goods_info );
  137. }
  138. }
  139. }