Changeset 18489 for branches/comu-ver2/data/class/helper/SC_Helper_DB.php
- Timestamp:
- 2010/01/10 19:53:26 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/class/helper/SC_Helper_DB.php
r18436 r18489 206 206 function sf_getBasisData($force = false) { 207 207 static $data; 208 208 209 209 if ($force || !isset($data)) { 210 210 $objQuery = new SC_Query(); 211 211 $arrRet = $objQuery->select('*', 'dtb_baseinfo'); 212 212 213 213 if (isset($arrRet[0])) { 214 214 $data = $arrRet[0]; … … 217 217 } 218 218 } 219 219 220 220 return $data; 221 221 } … … 344 344 $quantity = $arrCart['quantity']; 345 345 } 346 346 347 347 // (商品規格単位でなく)商品単位での評価のための準備 348 348 $product_id = $arrCart['id'][0]; … … 350 350 $arrQuantityInfo_by_product[$product_id]['sale_limit'] = $arrData['sale_limit']; 351 351 $arrQuantityInfo_by_product[$product_id]['name'] = $arrData['name']; 352 352 353 353 $objPage->arrProductsClass[$cnt] = $arrData; 354 354 $objPage->arrProductsClass[$cnt]['quantity'] = $quantity; … … 391 391 } 392 392 } 393 393 394 394 foreach ($arrQuantityInfo_by_product as $product_id => $quantityInfo) { 395 395 if (SC_Utils_Ex::sfIsInt($quantityInfo['sale_limit']) && $quantityInfo['quantity'] > $quantityInfo['sale_limit']) { … … 404 404 } 405 405 } 406 406 407 407 // 全商品合計金額(税込み) 408 408 $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal(); … … 439 439 $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid)); 440 440 } 441 441 442 442 // 受注_Tempテーブルの名称列を更新 443 443 $this->sfUpdateOrderNameCol($uniqid, true); … … 987 987 GROUP BY T1.category_id, T2.category_id 988 988 __EOS__; 989 989 990 990 $objQuery->query($sql); 991 991 992 992 //子カテゴリ内の商品数を集計する 993 993 994 994 // カテゴリ情報を取得 995 995 $arrCat = $objQuery->select('category_id', 'dtb_category'); 996 996 997 997 foreach ($arrCat as $row) { 998 998 $category_id = $row['category_id']; 999 999 $arrval = array(); 1000 1000 1001 1001 $arrval[] = $category_id; 1002 1002 1003 1003 list($tmp_where, $tmp_arrval) = $this->sfGetCatWhere($category_id); 1004 1004 if ($tmp_where != "") { … … 1008 1008 $sql_where_product_ids = '0<>0'; // 一致させない 1009 1009 } 1010 1010 1011 1011 $sql = <<< __EOS__ 1012 1012 INSERT INTO dtb_category_total_count (category_id, product_count, create_date) … … 1018 1018 WHERE ($sql_where) AND ($sql_where_product_ids) 1019 1019 __EOS__; 1020 1020 1021 1021 $objQuery->query($sql, $arrval); 1022 1022 } … … 1521 1521 // 店舗基本情報を取得する 1522 1522 $arrInfo = SC_Helper_DB_Ex::sf_getBasisData(); 1523 1523 1524 1524 // 未定義変数を定義 1525 1525 if (!isset($arrData['deliv_pref'])) $arrData['deliv_pref'] = ""; … … 1553 1553 // 商品の合計数量 1554 1554 $total_quantity = $objCartSess->getTotalQuantity(true); 1555 1555 1556 1556 if($total_quantity >= DELIV_FREE_AMOUNT) { 1557 1557 $arrData['deliv_fee'] = 0; … … 1576 1576 if (USE_POINT !== false) { 1577 1577 $arrData['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point']); 1578 1578 1579 1579 if($objCustomer != "") { 1580 1580 // 誕生日月であった場合 … … 1765 1765 function sfUpdateOrderNameCol($order_id, $temp_table = false) { 1766 1766 $objQuery = new SC_Query(); 1767 1767 1768 1768 if ($temp_table) { 1769 1769 $tgt_table = 'dtb_order_temp'; … … 1773 1773 $sql_where = 'WHERE order_id = ?'; 1774 1774 } 1775 1775 1776 1776 $sql = <<< __EOS__ 1777 1777 UPDATE … … 1782 1782 $sql_where 1783 1783 __EOS__; 1784 1784 1785 1785 $objQuery->query($sql, array($order_id)); 1786 1786 } … … 1795 1795 // 店舗基本情報を取得 1796 1796 $CONF = SC_Helper_DB_Ex::sf_getBasisData(); 1797 1797 1798 1798 return SC_Utils_Ex::sfTax($price, $CONF['tax'], $CONF['tax_rule']); 1799 1799 } … … 1808 1808 // 店舗基本情報を取得 1809 1809 $CONF = SC_Helper_DB_Ex::sf_getBasisData(); 1810 1810 1811 1811 return SC_Utils_Ex::sfPreTax($price, $CONF['tax'], $CONF['tax_rule']); 1812 1812 } … … 1822 1822 // 店舗基本情報を取得 1823 1823 $CONF = SC_Helper_DB_Ex::sf_getBasisData(); 1824 1824 1825 1825 return SC_Utils_Ex::sfGetAddPoint($totalpoint, $use_point, $CONF['point_rate']); 1826 1826 } … … 1834 1834 * @param integer|null $newStatus 対応状況 (null=変更無し) 1835 1835 * @param integer|null $newAddPoint 加算ポイント (null=変更無し) 1836 * @param integer|null $newUsePoint ポイント (null=変更無し)1836 * @param integer|null $newUsePoint 使用ポイント (null=変更無し) 1837 1837 * @return void 1838 1838 */ 1839 1839 function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddPoint = null, $newUsePoint = null) { 1840 1840 $objQuery = new SC_Query(); 1841 1841 1842 1842 $arrOrderOld = $objQuery->getRow('dtb_order', 'status, add_point, use_point, customer_id', 'order_id = ?', array($orderId)); 1843 1844 // 対応状況 1843 1844 // 対応状況が変更無しの場合、DB値を引き継ぐ 1845 1845 if (is_null($newStatus)) { 1846 1846 $newStatus = $arrOrderOld['status']; 1847 1847 } 1848 1848 1849 // 使用ポイント、DB値を引き継ぐ 1850 if (is_null($newUsePoint)) { 1851 $newUsePoint = $arrOrderOld['use_point']; 1852 } 1853 1854 // 加算ポイント、DB値を引き継ぐ 1855 if (is_null($newAddPoint)) { 1856 $newAddPoint = $arrOrderOld['add_point']; 1857 } 1858 1849 1859 if (USE_POINT !== false) { 1850 $addPoint = 0; 1851 1852 // 使用ポイント 1853 if (!is_null($newUsePoint)) { 1854 $addPoint += $arrOrderOld['use_point']; // 変更前のポイントを戻す 1855 $addPoint -= $newUsePoint; // 変更後のポイントを引く 1856 } 1857 1860 // 顧客.ポイントの加減値 1861 $addCustomerPoint = 0; 1862 1863 // ▼使用ポイント 1864 // 変更前の対応状況が利用対象の場合、変更前の使用ポイント分を戻す 1865 if (SC_Utils_Ex::sfIsUsePoint($arrOrderOld['status'])) { 1866 $addCustomerPoint += $arrOrderOld['use_point']; 1867 } 1868 1869 // 変更後の対応状況が利用対象の場合、変更後の使用ポイント分を引く 1870 if (SC_Utils_Ex::sfIsUsePoint($newStatus)) { 1871 $addCustomerPoint -= $newUsePoint; 1872 } 1873 // ▲使用ポイント 1874 1858 1875 // ▼加算ポイント 1859 // 変更前の 状態が加算対象の場合、1876 // 変更前の対応状況が加算対象の場合、変更前の加算ポイント分を戻す 1860 1877 if (SC_Utils_Ex::sfIsAddPoint($arrOrderOld['status'])) { 1861 $add Point -= $arrOrderOld['add_point'];1862 } 1863 1864 // 変更後の 状態が加算対象の場合、1878 $addCustomerPoint -= $arrOrderOld['add_point']; 1879 } 1880 1881 // 変更後の対応状況が加算対象の場合、変更後の加算ポイント分を足す 1865 1882 if (SC_Utils_Ex::sfIsAddPoint($newStatus)) { 1866 $add Point += is_null($newAddPoint) ? $arrOrderOld['add_point'] :$newAddPoint;1883 $addCustomerPoint += $newAddPoint; 1867 1884 } 1868 1885 // ▲加算ポイント 1869 1870 if ($add Point != 0) {1886 1887 if ($addCustomerPoint != 0) { 1871 1888 // ▼顧客テーブルの更新 1872 1889 $sqlval = array(); … … 1875 1892 $arrRawSql = array(); 1876 1893 $arrRawSqlVal = array(); 1877 1894 1878 1895 $sqlval['update_date'] = 'Now()'; 1879 1896 $arrRawSql['point'] = 'point + ?'; 1880 $arrRawSqlVal[] = $add Point;1897 $arrRawSqlVal[] = $addCustomerPoint; 1881 1898 $where .= 'customer_id = ?'; 1882 1899 $arrVal[] = $arrOrderOld['customer_id']; 1883 1900 1884 1901 $objQuery->update('dtb_customer', $sqlval, $where, $arrVal, $arrRawSql, $arrRawSqlVal); 1885 1902 // ▲顧客テーブルの更新 1886 1887 // ポイントをマイナスした場合、1888 if ($add Point < 0) {1903 1904 // 顧客.ポイントをマイナスした場合、 1905 if ($addCustomerPoint < 0) { 1889 1906 $sql = 'SELECT point FROM dtb_customer WHERE customer_id = ?'; 1890 1907 $point = $objQuery->getone($sql, array($arrOrderOld['customer_id'])); 1891 // 変更後の ポイントがマイナスの場合、1908 // 変更後の顧客.ポイントがマイナスの場合、 1892 1909 if ($point < 0) { 1893 1910 // ロールバック … … 1899 1916 } 1900 1917 } 1901 1918 1902 1919 // ▼受注テーブルの更新 1903 1920 $sqlval = array(); 1904 1921 if (USE_POINT !== false) { 1905 if (!is_null($newAddPoint)) { 1906 $sqlval['add_point'] = $newAddPoint; 1907 } 1908 if (!is_null($newUsePoint)) { 1909 $sqlval['use_point'] = $newUsePoint; 1910 } 1922 $sqlval['add_point'] = $newAddPoint; 1923 $sqlval['use_point'] = $newUsePoint; 1911 1924 } 1912 1925 // ステータスが発送済みに変更の場合、発送日を更新 … … 1916 1929 $sqlval['status'] = $newStatus; 1917 1930 $sqlval['update_date'] = 'Now()'; 1918 1931 1919 1932 $objQuery->update('dtb_order', $sqlval, 'order_id = ?', array($orderId)); 1920 1933 // ▲受注テーブルの更新
Note: See TracChangeset
for help on using the changeset viewer.