Manage.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <?php
  2. namespace Option\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. public function updateMember($id, $name, $data)
  7. {
  8. Dever::config('base')->hook = true;
  9. $where['id'] = $id;
  10. $where['clear'] = true;
  11. $info = Dever::db('option/member')->find($where);
  12. if ($info) {
  13. if ($info['main'] == 1) {
  14. $update['mid'] = $id;
  15. $account = Dever::db('option/account')->one($update);
  16. if (!$account) {
  17. $update['audit'] = 1;
  18. $aid = Dever::db('option/account')->insert($update);
  19. } else {
  20. $aid = $account['id'];
  21. }
  22. Dever::db('option/member')->update(array('where_id' => $info['id'], 'aid' => $aid));
  23. }
  24. $main = Dever::db('option/member')->getMain(array('key' => $info['key']));
  25. if ($main && $main['aid']) {
  26. $where = array();
  27. $where['option_key'] = $info['key'];
  28. $where['set_aid'] = $main['aid'];
  29. Dever::db('option/member')->updates($where);
  30. }
  31. }
  32. }
  33. public function updateAccount($id, $name, $data)
  34. {
  35. Dever::config('base')->hook = true;
  36. $update = array();
  37. $audit = Dever::param('audit', $data);
  38. $desc = Dever::param('audit_desc', $data);
  39. $send_email = Dever::param('send_email', $data);
  40. $email = Dever::param('email', $data);
  41. $info = Dever::db('option/account')->one($id);
  42. if ($info) {
  43. if ($audit && $audit > 2) {
  44. $update['audit_date'] = time();
  45. $update['where_id'] = $info['id'];
  46. Dever::db('option/account')->update($update);
  47. }
  48. if ($send_email == 2 && (($email && $email != $info['email']) || $info['is_email'] == 2)) {
  49. $update = array();
  50. $update['is_email'] = 2;
  51. $update['where_id'] = $info['id'];
  52. Dever::db('option/account')->update($update);
  53. if ($send_email == 2) {
  54. $member = Dever::db('option/member')->one($info['mid']);
  55. if ($member) {
  56. $code = Dever::load('passport/reg')->code(false, false);
  57. $email = base64_encode($email);
  58. Dever::daemon('lib/email.renzheng?aid='.$info['id'].'&email=' . $email . '&code=' . $code . '&username=' . $member['name'], 'option');
  59. }
  60. }
  61. }
  62. $member = Dever::db('option/member')->one($info['mid']);
  63. if ($audit == 3) {
  64. if (Dever::project('sms')) {
  65. Dever::load('sms/api')->send('qiquan_reg_yes', $member['mobile'], array('name' => $member['name']));
  66. }
  67. } elseif ($audit == 4) {
  68. if (Dever::project('sms')) {
  69. Dever::load('sms/api')->send('qiquan_reg_no', $member['mobile'], array('name' => $member['name'], 'content' => $desc));
  70. }
  71. }
  72. }
  73. }
  74. # 协议审核
  75. public function setAgreement($id, $name, $data)
  76. {
  77. Dever::config('base')->hook = true;
  78. $update = array();
  79. $audit = Dever::param('audit', $data);
  80. $desc = Dever::param('audit_desc', $data);
  81. $info = Dever::db('option/agreement')->one($id);
  82. if ($audit > 1 && $info) {
  83. $admin = Dever::load('manage/auth.info');
  84. $update['audit_date'] = time();
  85. $update['audit_admin'] = $admin['id'];
  86. if ($audit == 3) {
  87. $update['status'] = 2;
  88. }
  89. $update['where_id'] = $info['id'];
  90. $state = Dever::db('option/agreement')->update($update);
  91. if ($state && $audit == 3) {
  92. Dever::load('option/lib/cash.setValue_commit', $info);
  93. }
  94. if ($audit == 3) {
  95. if (Dever::project('sms')) {
  96. Dever::load('sms/api')->send('qiquan_audit', $info['mobile'], array('name' => $info['name']));
  97. }
  98. } elseif ($audit == 4) {
  99. if (Dever::project('sms')) {
  100. Dever::load('sms/api')->send('qiquan_audit', $info['mobile'], array('name' => $info['name'], 'content' => $desc));
  101. }
  102. }
  103. }
  104. }
  105. # 交付审核 已废弃
  106. public function setJiaofu($id, $name, $data)
  107. {
  108. Dever::config('base')->hook = true;
  109. $update = array();
  110. $audit = Dever::param('audit', $data);
  111. $info = Dever::db('option/bill_jiaofu')->one($id);
  112. if ($audit > 1 && $info) {
  113. $admin = Dever::load('manage/auth.info');
  114. $update['audit_date'] = time();
  115. $update['audit_admin'] = $admin['id'];
  116. $update['where_id'] = $info['id'];
  117. $state = Dever::db('option/bill_jiaofu')->update($update);
  118. if ($state && $audit == 3) {
  119. Dever::load('option/lib/cash.setValue_commit', $info);
  120. }
  121. }
  122. }
  123. public function setFafang($id, $name, $data)
  124. {
  125. Dever::config('base')->hook = true;
  126. $update = array();
  127. $audit = Dever::param('audit', $data);
  128. $info = Dever::db('option/bill_fafang')->one($id);
  129. if ($audit > 1 && $info) {
  130. $admin = Dever::load('manage/auth.info');
  131. $update['audit_date'] = time();
  132. $update['audit_admin'] = $admin['id'];
  133. $update['where_id'] = $info['id'];
  134. $state = Dever::db('option/bill_fafang')->update($update);
  135. if ($state && $audit == 2) {
  136. # 已作废,减掉这个数据
  137. $account_cash = Dever::db('option/cash')->find(array('type' => $info['type'], 'aid' => $info['aid']));
  138. if ($account_cash) {
  139. $update['where_id'] = $account_cash['id'];
  140. $update['fafang'] = $account_cash['fafang'] - $info['cash'];
  141. $update['jiaofu'] = $account_cash['jiaofu'] + $info['cash'];
  142. if ($update['fafang'] < 0) {
  143. $update['fafang'] = 0;
  144. }
  145. $update['clear'] = true;
  146. Dever::db('option/cash')->update($update);
  147. }
  148. }
  149. }
  150. }
  151. public function setDuifu($id, $name, $data)
  152. {
  153. Dever::config('base')->hook = true;
  154. $update = array();
  155. $audit = Dever::param('audit', $data);
  156. $info = Dever::db('option/bill_duifu')->one($id);
  157. if ($audit && $audit > 1 && $info) {
  158. $admin = Dever::load('manage/auth.info');
  159. $update['audit_date'] = time();
  160. $update['audit_admin'] = $admin['id'];
  161. $update['where_id'] = $info['id'];
  162. $state = Dever::db('option/bill_duifu')->update($update);
  163. if ($state && $audit == 2) {
  164. # 已作废,恢复这个数据
  165. $account_cash = Dever::db('option/cash')->find(array('type' => $info['type'], 'aid' => $info['aid']));
  166. if ($account_cash) {
  167. $update['where_id'] = $account_cash['id'];
  168. $update['duifu'] = $account_cash['duifu'] - $info['cash'];
  169. $update['fafang'] = $account_cash['fafang'] + $info['cash'];
  170. if ($update['duifu'] < 0) {
  171. $update['duifu'] = 0;
  172. }
  173. $update['clear'] = true;
  174. Dever::db('option/cash')->update($update);
  175. }
  176. }
  177. }
  178. }
  179. public function cashUpdate($id, $name, $data)
  180. {
  181. Dever::config('base')->hook = true;
  182. $aid = Dever::param('aid', $data);
  183. $mid = Dever::param('mid', $data);
  184. $type = Dever::param('type', $data);
  185. $cash = Dever::param('cash', $data);
  186. $desc = Dever::param('desc', $data);
  187. if ($aid && $type && $cash && $desc) {
  188. $account = Dever::db('option/account')->find($aid);
  189. if ($account && $account['status'] <= 2) {
  190. Dever::load('option/lib/cash')->up($aid, $mid, $type, $cash, $desc);
  191. } else {
  192. Dever::db('option/push_cash')->update(array('where_id' => $id, 'status' => 2));
  193. Dever::alert('期权账户已停用或者未审核,操作失败');
  194. }
  195. }
  196. }
  197. public function getDate($id)
  198. {
  199. $info = Dever::db('option/agreement')->find($id);
  200. if ($info) {
  201. $html = '';
  202. $html .= '处理时间:' . date('Y-m-d H:i', $info['cdate']);
  203. if ($info['qdate']) {
  204. $html .= '<br />确认时间:' . date('Y-m-d H:i', $info['qdate']);
  205. }
  206. if ($info['audit_date']) {
  207. $html .= '<br />审核时间:' . date('Y-m-d H:i', $info['audit_date']);
  208. }
  209. return $html;
  210. }
  211. return '';
  212. }
  213. public function upAgreement_api()
  214. {
  215. $id = Dever::input('id');
  216. if ($id) {
  217. Dever::load('option/lib/agreement')->upContent($id);
  218. }
  219. return 'reload';
  220. }
  221. public function dropAgreement_api()
  222. {
  223. $id = Dever::input('id');
  224. if ($id) {
  225. Dever::load('option/lib/agreement')->drop($id);
  226. }
  227. return 'reload';
  228. }
  229. public function checkMember($id, $name, $data)
  230. {
  231. $main = Dever::param('main', $data);
  232. $key = Dever::param('key', $data);
  233. if (!$key) {
  234. Dever::alert('请传入账户索引');
  235. }
  236. if ($main == 2) {
  237. $main = Dever::db('option/member')->getMain(array('key' => $key));
  238. if (!$main) {
  239. Dever::alert('请先创建主账号');
  240. }
  241. } elseif ($main == 1) {
  242. $main = Dever::db('option/member')->getMain(array('key' => $key));
  243. if ($main) {
  244. Dever::alert('已存在主账号');
  245. }
  246. }
  247. }
  248. public function setAudit($id, $name, $data)
  249. {
  250. $audit = Dever::param('audit', $data);
  251. if ($audit == 3) {
  252. $data['set_audit_desc'] = 'null';
  253. return $data;
  254. } else {
  255. return $data;
  256. }
  257. }
  258. }