Manage.php 11 KB

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