function_trade.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: function_trade.php 24961 2011-10-19 06:48:00Z liulanbo $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $apitype = empty($apitype) || !preg_match('/^[a-z0-9]+$/i', $apitype) ? 'alipay' : $apitype;
  12. require_once DISCUZ_ROOT.'./api/trade/api_'.$apitype.'.php';
  13. function trade_offline($tradelog, $returndlang = 1, $trade_message = '') {
  14. global $_G;
  15. $tmp = $return = array();
  16. if($_G['uid'] == $tradelog['buyerid']) {
  17. $data = array(
  18. 0 => array(4,8),
  19. 1 => array(4,8),
  20. 5 => array(7,10),
  21. 11 => array(10,7),
  22. 12 => array(13)
  23. );
  24. $tmp = $data[$tradelog['status']];
  25. } elseif($_G['uid'] == $tradelog['sellerid']) {
  26. $data = array(
  27. 4 => array(5),
  28. 10 => array(12,11),
  29. 13 => array(17)
  30. );
  31. $tmp = $data[$tradelog['status']];
  32. }
  33. if($returndlang) {
  34. for($i = 0, $count = count($tmp);$i < $count;$i++) {
  35. $return[$tmp[$i]] = lang('forum/misc', 'trade_offline_'.$tmp[$i]);
  36. $trade_message .= isset($language['trade_message_'.$tmp[$i]]) ? lang('forum/misc', 'trade_message_'.$tmp[$i]).'<br />' : '';
  37. }
  38. return $return;
  39. } else {
  40. return $tmp;
  41. }
  42. }
  43. function trade_create($trade) {
  44. global $_G;
  45. extract($trade);
  46. $special = 2;
  47. $expiration = $item_expiration ? strtotime($item_expiration) : 0;
  48. $closed = $expiration > 0 && strtotime($item_expiration) < TIMESTAMP ? 1 : $closed;
  49. $item_price = floatval($item_price);
  50. switch($transport) {
  51. case 'offline' : $item_transport = 0; break;
  52. case 'seller' : $item_transport = 1; break;
  53. case 'buyer' : $item_transport = 2; break;
  54. case 'virtual' : $item_transport = 3; break;
  55. case 'logistics': $item_transport = 4; break;
  56. }
  57. $seller = dhtmlspecialchars($seller);
  58. $item_name = dhtmlspecialchars($item_name);
  59. $item_locus = dhtmlspecialchars($item_locus);
  60. $item_number = intval($item_number);
  61. $item_quality = intval($item_quality);
  62. $item_transport = intval($item_transport);
  63. $postage_mail = intval($postage_mail);
  64. $postage_express = intval($postage_express);
  65. $postage_ems = intval($postage_ems);
  66. $item_type = intval($item_type);
  67. $typeid = intval($typeid);
  68. $item_costprice = floatval($item_costprice);
  69. if(!$item_price || $item_price <= 0) {
  70. $item_price = $postage_mail = $postage_express = $postage_ems = '';
  71. }
  72. if(empty($pid)) {
  73. $pid = C::t('forum_post')->fetch_threadpost_by_tid_invisible($tid);
  74. $pid = $pid['pid'];
  75. }
  76. if(!$item_price && $item_credit) {
  77. $seller == '';
  78. }
  79. C::t('forum_trade')->insert(array(
  80. 'tid' => $tid,
  81. 'pid' => $pid,
  82. 'typeid' => $typeid,
  83. 'sellerid' => $_G['uid'],
  84. 'seller' => $author,
  85. 'tenpayaccount' => $tenpayaccount,
  86. 'account' => $seller,
  87. 'subject' => $item_name,
  88. 'price' => $item_price,
  89. 'amount' => $item_number,
  90. 'quality' => $item_quality,
  91. 'locus' => $item_locus,
  92. 'transport' => $item_transport,
  93. 'ordinaryfee' => $postage_mail,
  94. 'expressfee' => $postage_express,
  95. 'emsfee' => $postage_ems,
  96. 'itemtype' => $item_type,
  97. 'dateline' => $_G['timestamp'],
  98. 'expiration' => $expiration,
  99. 'lastupdate' => $_G['timestamp'],
  100. 'totalitems' => '0',
  101. 'tradesum' => '0',
  102. 'closed' => $closed,
  103. 'costprice'=>$item_costprice,
  104. 'aid'=>$aid,'credit'=>$item_credit,
  105. 'costcredit'=>$item_costcredit
  106. ));
  107. }
  108. ?>