Manage.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. Dever::load('option/lib/email.renzheng?aid='.$info['id'].'&email=' . $email . '&code=' . $code . '&username=' . $member['name']);
  60. }
  61. }
  62. }
  63. $member = Dever::db('option/member')->one($info['mid']);
  64. if ($audit == 3) {
  65. if (Dever::project('sms')) {
  66. Dever::load('sms/api')->send('qiquan_reg_yes', $member['mobile'], array('name' => $member['name']));
  67. }
  68. } elseif ($audit == 4) {
  69. if (Dever::project('sms')) {
  70. Dever::load('sms/api')->send('qiquan_reg_no', $member['mobile'], array('name' => $member['name'], 'content' => $desc));
  71. }
  72. }
  73. }
  74. }
  75. # 协议审核
  76. public function setAgreement($id, $name, $data)
  77. {
  78. Dever::config('base')->hook = true;
  79. $update = array();
  80. $audit = Dever::param('audit', $data);
  81. $desc = Dever::param('audit_desc', $data);
  82. if ($audit > 1) {
  83. $mul_type = Dever::config('base')->mul_type;
  84. if ($mul_type == 2) {
  85. $list = Dever::db('option/agreement')->select(array('status' => 2));
  86. } else {
  87. $list = explode(',', $id);
  88. }
  89. $admin = Dever::load('manage/auth.info');
  90. if (!$admin) {
  91. foreach ($list as $k => $v) {
  92. Dever::db('option/agreement')->update(array('where_id' => $v, 'audit' => 2));
  93. }
  94. Dever::alert('请先登录');
  95. }
  96. $update['audit_date'] = time();
  97. $update['audit_admin'] = $admin['id'];
  98. if ($audit == 3) {
  99. $update['status'] = 2;
  100. }
  101. foreach ($list as $k => $v) {
  102. $info = Dever::db('option/agreement')->one($v);
  103. if ($info) {
  104. $update['where_id'] = $info['id'];
  105. $state = Dever::db('option/agreement')->update($update);
  106. if ($state && $audit == 3) {
  107. Dever::load('option/lib/cash.setValue_act', $info);
  108. }
  109. if ($audit == 3) {
  110. if (Dever::project('sms')) {
  111. Dever::load('sms/api')->send('qiquan_audit', $info['mobile'], array('name' => $info['name']));
  112. }
  113. } elseif ($audit == 4) {
  114. if (Dever::project('sms')) {
  115. Dever::load('sms/api')->send('qiquan_audit', $info['mobile'], array('name' => $info['name'], 'content' => $desc));
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. # 交付审核 已废弃
  123. public function setJiaofu($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_jiaofu')->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_jiaofu')->update($update);
  135. if ($state && $audit == 3) {
  136. Dever::load('option/lib/cash.setValue_commit', $info);
  137. }
  138. }
  139. }
  140. public function setFafang($id, $name, $data)
  141. {
  142. Dever::config('base')->hook = true;
  143. $update = array();
  144. $audit = Dever::param('audit', $data);
  145. $info = Dever::db('option/bill_fafang')->one($id);
  146. if ($audit > 1 && $info) {
  147. $admin = Dever::load('manage/auth.info');
  148. $update['audit_date'] = time();
  149. $update['audit_admin'] = $admin['id'];
  150. $update['where_id'] = $info['id'];
  151. $state = Dever::db('option/bill_fafang')->update($update);
  152. if ($state && $audit == 2) {
  153. # 已作废,减掉这个数据
  154. $account_cash = Dever::db('option/cash')->find(array('type' => $info['type'], 'aid' => $info['aid']));
  155. if ($account_cash) {
  156. $update['where_id'] = $account_cash['id'];
  157. $update['fafang'] = $account_cash['fafang'] - $info['cash'];
  158. $update['jiaofu'] = $account_cash['jiaofu'] + $info['cash'];
  159. if ($update['fafang'] < 0) {
  160. $update['fafang'] = 0;
  161. }
  162. $update['clear'] = true;
  163. Dever::db('option/cash')->update($update);
  164. }
  165. }
  166. }
  167. }
  168. public function setDuifu($id, $name, $data)
  169. {
  170. Dever::config('base')->hook = true;
  171. $update = array();
  172. $audit = Dever::param('audit', $data);
  173. $info = Dever::db('option/bill_duifu')->one($id);
  174. if ($audit && $audit > 1 && $info) {
  175. $admin = Dever::load('manage/auth.info');
  176. $update['audit_date'] = time();
  177. $update['audit_admin'] = $admin['id'];
  178. $update['where_id'] = $info['id'];
  179. $state = Dever::db('option/bill_duifu')->update($update);
  180. if ($state && $audit == 2) {
  181. # 已作废,恢复这个数据
  182. $account_cash = Dever::db('option/cash')->find(array('type' => $info['type'], 'aid' => $info['aid']));
  183. if ($account_cash) {
  184. $update['where_id'] = $account_cash['id'];
  185. $update['duifu'] = $account_cash['duifu'] - $info['cash'];
  186. $update['fafang'] = $account_cash['fafang'] + $info['cash'];
  187. if ($update['duifu'] < 0) {
  188. $update['duifu'] = 0;
  189. }
  190. $update['clear'] = true;
  191. Dever::db('option/cash')->update($update);
  192. }
  193. }
  194. }
  195. }
  196. public function cashUpdate($id, $name, $data)
  197. {
  198. Dever::config('base')->hook = true;
  199. $aid = Dever::param('aid', $data);
  200. $mid = Dever::param('mid', $data);
  201. $type = Dever::param('type', $data);
  202. $cash = Dever::param('cash', $data);
  203. $desc = Dever::param('desc', $data);
  204. if ($aid && $type && $cash && $desc) {
  205. $account = Dever::db('option/account')->find($aid);
  206. if ($account && $account['status'] <= 2) {
  207. Dever::load('option/lib/cash')->up($aid, $mid, $type, $cash, $desc);
  208. } else {
  209. Dever::db('option/push_cash')->update(array('where_id' => $id, 'status' => 2));
  210. Dever::alert('期权账户已停用或者未审核,操作失败');
  211. }
  212. }
  213. }
  214. public function getDate($id)
  215. {
  216. $info = Dever::db('option/agreement')->find($id);
  217. if ($info) {
  218. $html = '';
  219. $html .= '处理时间:' . date('Y-m-d H:i', $info['cdate']);
  220. if ($info['qdate']) {
  221. $html .= '<br />确认时间:' . date('Y-m-d H:i', $info['qdate']);
  222. }
  223. if ($info['audit_date']) {
  224. $html .= '<br />审核时间:' . date('Y-m-d H:i', $info['audit_date']);
  225. }
  226. return $html;
  227. }
  228. return '';
  229. }
  230. public function upAgreement_api()
  231. {
  232. $id = Dever::input('id');
  233. if ($id) {
  234. Dever::load('option/lib/agreement')->upContent($id);
  235. }
  236. return 'reload';
  237. }
  238. public function dropAgreement_api()
  239. {
  240. $id = Dever::input('id');
  241. if ($id) {
  242. Dever::load('option/lib/agreement')->drop($id);
  243. }
  244. return 'reload';
  245. }
  246. public function checkMember($id, $name, $data)
  247. {
  248. $main = Dever::param('main', $data);
  249. $key = Dever::param('key', $data);
  250. if (!$key) {
  251. Dever::alert('请传入账户索引');
  252. }
  253. if ($main == 2) {
  254. $main = Dever::db('option/member')->getMain(array('key' => $key));
  255. if (!$main) {
  256. Dever::alert('请先创建主账号');
  257. }
  258. } elseif ($main == 1) {
  259. $main = Dever::db('option/member')->getMain(array('key' => $key));
  260. if ($main) {
  261. Dever::alert('已存在主账号');
  262. }
  263. }
  264. }
  265. public function setAudit($id, $name, $data)
  266. {
  267. $audit = Dever::param('audit', $data);
  268. if ($audit == 3) {
  269. $data['set_audit_desc'] = 'null';
  270. return $data;
  271. } else {
  272. return $data;
  273. }
  274. }
  275. }