人人商城

store.mod.php 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. function store_goods_info($id) {
  8. $result = array();
  9. $id = intval($id);
  10. if (empty($id)) {
  11. return $result;
  12. }
  13. $store_table = table('store');
  14. $result = $store_table->goodsInfo($id);
  15. return $result;
  16. }
  17. function store_goods_changestatus($id) {
  18. $result = false;
  19. $id = intval($id);
  20. if (empty($id)) {
  21. return $result;
  22. }
  23. $if_exist = pdo_get('site_store_goods', array('id' => $id));
  24. if (!empty($if_exist)) {
  25. $status = $if_exist['status'] == 1 ? 0 : 1;
  26. $data = array('status' => $status);
  27. $result = pdo_update('site_store_goods', $data, array('id' => $id));
  28. }
  29. return $result;
  30. }
  31. function store_goods_delete($id) {
  32. $result = false;
  33. $id = intval($id);
  34. if (empty($id)) {
  35. return $result;
  36. }
  37. $result = pdo_update('site_store_goods', array('status' => 2), array('id' => $id));
  38. return $result;
  39. }
  40. function store_goods_post($data) {
  41. $result = false;
  42. if (empty($data)) {
  43. return $result;
  44. }
  45. $post = array();
  46. if (!empty($data['title'])) {
  47. $post['title'] = trim($data['title']);
  48. }
  49. if (!empty($data['price']) && is_numeric($data['price'])) {
  50. $post['price'] = $data['price'];
  51. }
  52. if (!empty($data['slide'])) {
  53. $post['slide'] = $data['slide'];
  54. }
  55. if (!empty($data['status'])) {
  56. $post['status'] = 1;
  57. }
  58. if (!empty($data['ability']) || !empty($data['synopsis'])) {
  59. $post['synopsis'] = empty($data['ability']) ? trim($data['synopsis']) : trim($data['ability']);
  60. }
  61. if (!empty($data['description'])) {
  62. $post['description'] = trim($data['description']);
  63. }
  64. if (!empty($data['api_num'])) {
  65. $post['api_num'] = intval($data['api_num']);
  66. }
  67. if (!empty($data['unit'])) {
  68. $post['unit'] = $data['unit'];
  69. } else {
  70. if ($data['type'] != STORE_TYPE_API) {
  71. $post['unit'] = 'month';
  72. }
  73. }
  74. $post['account_num'] = $data['account_num'];
  75. $post['wxapp_num'] = $data['wxapp_num'];
  76. $post['module_group'] = $data['module_group'];
  77. $post['user_group'] = $data['user_group'];
  78. $post['user_group_price'] = $data['user_group_price'];
  79. if (!empty($data['id'])) {
  80. $result = pdo_update('site_store_goods', $post, array('id' => $data['id']));
  81. } else {
  82. $post['type'] = $data['type'];
  83. $post['createtime'] = TIMESTAMP;
  84. $post['title_initial'] = get_first_pinyin($data['title']);
  85. if ($data['type'] == STORE_TYPE_USER_PACKAGE && !empty($post['unit'])) {
  86. $post['unit'] = $data['unit'];
  87. } else {
  88. $post['unit'] = 'month';
  89. }
  90. if ($data['type'] == STORE_TYPE_API) {
  91. $post['unit'] = 'ten_thousand';
  92. }
  93. $post['module'] = trim($data['module']);
  94. $result = pdo_insert('site_store_goods', $post);
  95. }
  96. return $result;
  97. }
  98. function store_order_info($id) {
  99. $result = array();
  100. $id = intval($id);
  101. if (empty($id)) {
  102. return $result;
  103. }
  104. $store_table = table('store');
  105. $result = $store_table->searchOrderInfo($id);
  106. return $result;
  107. }
  108. function store_order_change_price($id, $price) {
  109. global $_W;
  110. $result = false;
  111. $id = intval($id);
  112. $price = floatval($price);
  113. $if_exist = store_order_info($id);
  114. if (empty($id) || empty($if_exist)) {
  115. return $result;
  116. }
  117. if (user_is_vice_founder() || empty($_W['isfounder'])) {
  118. return $result;
  119. }
  120. pdo_update('core_paylog', array('card_fee' => $price), array('module' => 'store', 'tid' => $id));
  121. $result = pdo_update('site_store_order', array('amount' => $price, 'changeprice' => 1), array('id' => $id));
  122. return $result;
  123. }
  124. function store_order_delete($id) {
  125. $result = false;
  126. $id = intval($id);
  127. if (empty($id)) {
  128. return $result;
  129. }
  130. $result = pdo_update('site_store_order', array('type' => STORE_ORDER_DELETE), array('id' => $id));
  131. return $result;
  132. }