Manage.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. namespace User\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. public function feedback($id)
  7. {
  8. $info = Dever::db('user/feedback')->one($id);
  9. $user = Dever::load("passport/user-one", $info['uid']);
  10. $table['用户名'] = $user['username'];
  11. $table['手机号'] = $user['mobile'];
  12. if ($info['pic']) {
  13. $table['图片'] = '<a><img src="'.$info['pic'].'" style="width:150px" /></a>';
  14. }
  15. if ($info['content']) {
  16. $table['内容'] = $info['content'];
  17. }
  18. return Dever::table($table);
  19. }
  20. public function showOrderUser($id)
  21. {
  22. $info = Dever::db('user/ticket_order')->one($id);
  23. $table = array();
  24. $user = Dever::db('passport/user')->one($info['uid']);
  25. $table['用户名'] = $user['username'] . '('.$info['uid'].')';
  26. $table['手机号'] = $user['mobile'];
  27. $table['产品名'] = $info['name'];
  28. //$table['购买数量'] = $info['num'];
  29. if ($info['parent_uid'] && $info['parent_uid'] != $info['uid']) {
  30. $user = Dever::db('passport/user')->one($info['parent_uid']);
  31. $table['邀请人'] = $user['username'];
  32. }
  33. return Dever::table($table);
  34. }
  35. public function showSeatOrderUser($id)
  36. {
  37. $info = Dever::db('user/seat_order')->one($id);
  38. $table = array();
  39. $user = Dever::db('passport/user')->one($info['uid']);
  40. $table['用户名'] = $user['username'] . '('.$info['uid'].')';
  41. $table['手机号'] = $user['mobile'];
  42. $table['产品名'] = $info['name'];
  43. //$table['购买数量'] = $info['num'];
  44. if ($info['parent_uid'] && $info['parent_uid'] != $info['uid']) {
  45. $user = Dever::db('passport/user')->one($info['parent_uid']);
  46. $table['邀请人'] = $user['username'];
  47. }
  48. return Dever::table($table);
  49. }
  50. public function showOrderStatus($id, $type)
  51. {
  52. $info = Dever::db('user/'.$type.'_order')->one($id);
  53. if ($info) {
  54. if ($info['status'] == 1) {
  55. #return '*已支付';
  56. return '待支付';
  57. } elseif ($info['status'] == 2) {
  58. return '已支付';
  59. } elseif ($info['status'] == 3) {
  60. return '支付失败';
  61. } elseif ($info['status'] == 5) {
  62. $table['状态'] = '已退款';
  63. $manage = Dever::db('manage/admin')->one($info['tk_admin']);
  64. $table['备注'] = $info['tk_desc'];
  65. $table['截图'] = '<a><img src="'.$info['tk_pic'].'" style="width:150px" /></a>';
  66. //$table['退款时间'] = date('Y-m-d H:i:s', $info['tk_time']);
  67. $table['操作人'] = $manage['username'];
  68. return Dever::table($table);
  69. }
  70. }
  71. }
  72. # 退款操作
  73. public function refund($id, $name, $data)
  74. {
  75. $status = Dever::param('status', $data);
  76. if ($status == 5 && $id > 0) {
  77. $send = array();
  78. $info = Dever::db('act/order')->one($id);
  79. if ($info['system'] == 1) {
  80. if ($info['cate_id'] == 1) {
  81. $account_id = 1;
  82. }
  83. if ($info['cate_id'] == 2) {
  84. $account_id = 4;
  85. }
  86. if ($info['cate_id'] == 3) {
  87. $account_id = 5;
  88. }
  89. } elseif ($info['system'] == 2) {
  90. $account_id = 2;
  91. if ($info['cate_id'] == 2) {
  92. $account_id = 7;
  93. }
  94. } else {
  95. $account_id = 3;
  96. }
  97. $send['pay_project_id'] = 3;
  98. $send['pay_uid'] = $info['uid'];
  99. $send['pay_order_id'] = $info['order_id'] ? $info['order_id'] : Dever::load('act/order')->createOrderId($info, $info['id']);
  100. $send['pay_tk_pic'] = Dever::param('tk_pic', $data);
  101. $send['pay_tk_time'] = Dever::param('tk_time', $data);
  102. $send['pay_tk_desc'] = Dever::param('tk_desc', $data);
  103. $send['pay_account_id'] = $account_id;
  104. $send['pay_cash'] = $info['cash'];
  105. $send['pay_status'] = $status;
  106. $send['dever_token'] = $this->key;
  107. Dever::load('pay/lib/set.updateStatus', $send);
  108. if ($info['buy_id'] > 0) {
  109. $buy = Dever::db('journal/buy_num')->one($info['buy_id']);
  110. if ($buy) {
  111. if ($info['buy_num'] > 0) {
  112. $num = $info['buy_num'];
  113. } else {
  114. $num = $buy['num'];
  115. }
  116. # 减少积分
  117. $score = $num * 20;
  118. $user = Dever::db('score/user')->one(array('uid' => $info['uid']));
  119. if ($user) {
  120. $user_id = $user['id'];
  121. $user_score = $user['score'];
  122. $user_score = $user_score - $score;
  123. if ($user_score < 0) {
  124. $user_score = 0;
  125. }
  126. Dever::db('score/user')->update(array('where_id' => $user_id, 'score' => $user_score));
  127. }
  128. # 减少排行榜
  129. $journal_num = Dever::db('act/journal_num')->one(array('uid' => $info['uid'], 'journal_id' => $info['product_id']));
  130. if ($journal_num) {
  131. $journal_num_id = $journal_num['id'];
  132. $journal_num = $journal_num['num'];
  133. $journal_num = $journal_num - $num;
  134. if ($journal_num < 0) {
  135. $journal_num = 0;
  136. }
  137. Dever::db('act/journal_num')->update(array('where_id' => $journal_num_id, 'num' => $journal_num));
  138. }
  139. # 减少订阅本数 这个定时跑就行了 不管了
  140. $journal = Dever::db('journal/info')->one($info['product_id']);
  141. if ($journal) {
  142. $journal_id = $journal['id'];
  143. $journal_num = $journal['num_ding'];
  144. $journal_num = $journal_num - $num;
  145. if ($journal_num < 0) {
  146. $journal_num = 0;
  147. }
  148. Dever::db('journal/info')->update(array('where_id' => $journal_id, 'num_ding' => $journal_num));
  149. }
  150. }
  151. }
  152. }
  153. return 'reload';
  154. }
  155. }