Manage.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. <?php
  2. namespace Active\Lib;
  3. use Dever;
  4. Class Manage
  5. {
  6. public function upCode_api($id)
  7. {
  8. $id = Dever::input('id');
  9. if ($id) {
  10. $data = Dever::db('active/code')->find($id);
  11. if ($data && $data['status'] == 1) {
  12. $where['where_id'] = $id;
  13. $where['status'] = 2;
  14. $admin = Dever::load('manage/auth.info');
  15. $where['audit_admin'] = $admin['id'];
  16. Dever::db('active/code')->update($where);
  17. // echo Dever::sql();die;
  18. }
  19. }
  20. return 'reload';
  21. }
  22. #全额退款
  23. public function refund_api($id)
  24. {
  25. $data = Dever::db('active/order')->find($id);
  26. // if ($data['mid'] && $data['mid'] > 0) {
  27. // $user = Dever::db('active/user')->find(array('mid'=>$data['mid']));
  28. // if ($user && $user['id']) {
  29. // $uid = $user['id'];
  30. // }
  31. // } else {
  32. // $uid = $data['uid'];
  33. // }
  34. $this->common($data,1);
  35. return 'reload';
  36. }
  37. public function insertInfoRefund ($id,$name,$data)
  38. {
  39. $num = Dever::param('num',$data);
  40. $price = Dever::param('price',$data);
  41. $order_id = Dever::param('order_id',$data);
  42. $data = Dever::db('active/order')->find($order_id);
  43. if ($num < 1) {
  44. Dever::alert('退款数量不正确');
  45. }
  46. if($num > $data['num']) {
  47. Dever::alert('退款数量大于购买数量');
  48. }
  49. $info = Dever::db('active/info')->find($data['active_id']);
  50. // $refund_price = $num*$info['price'];
  51. if ($price > $info['price']) {
  52. Dever::alert('退款金额大于购买金额');
  53. }
  54. $code = Dever::db('active/code')->getCode(array('order_id' => $order_id,'status'=>'1,2'));
  55. $use_code = count($code);#已领取的所有数量
  56. if (!$data['refund_num']) {
  57. $data['refund_num'] = 0;
  58. }
  59. $no_code = $data['num'] - $use_code - $data['refund_num'];#未使用的数量
  60. if ($num > $no_code){
  61. Dever::alert('退款数量不正确');
  62. }
  63. // if ($data['refund_num'] > 0){
  64. // $info = Dever::db('active/info_refund')->state(array('order_id'=>$order_id,'status'=>2));
  65. // $count = $data['num'] - count($info);
  66. // if ($num > $count) {
  67. // Dever::alert('退款数量大于购买数量');
  68. // }
  69. // }
  70. }
  71. public function updateInfoRefund ($id,$name,$data)
  72. {
  73. $num = Dever::param('num',$data);
  74. $price = Dever::param('price',$data);
  75. $desc = Dever::param('desc',$data);
  76. $order_id = Dever::param('order_id',$data);
  77. $code_id = Dever::param('code_id',$data);
  78. $data = Dever::db('active/order')->find($order_id);
  79. // $info = Dever::db('active/info_refund')->state(array('order_id'=>$order_id));
  80. // $active = Dever::db('active/info')->find($data['active_id']);
  81. $this->common($data,2,$num,$id,$price,$desc);
  82. return 'reload';
  83. }
  84. public function show($id)
  85. {
  86. $data = Dever::db('active/order')->find($id);
  87. $refund_admin = '-';
  88. $rdate = '-';
  89. if ($data && isset($data['refund_admin']) && $data['refund_admin'] && $data['refund_admin']>0 && $data['rdate']) {
  90. $admin = Dever::load('manage/admin-find',$data['refund_admin']);
  91. $refund_admin = $admin['username'];
  92. $rdate = date('Y-m-d H:i',$data['rdate']);
  93. }
  94. $html = $refund_admin.'<br/>'.$rdate;
  95. return $html;
  96. }
  97. public function active($id)
  98. {
  99. $data = Dever::db('active/info')->find($id);
  100. $html = array();
  101. if (isset($data) && $data) {
  102. $html['active_name'] = $data['name'];
  103. }
  104. $info = Dever::db('active/code')->find($id);
  105. if ($info && isset($info['audit_admin']) && $info['audit_admin'] && $info['audit_admin'] > 0) {
  106. $aduit = Dever::load('manage/admin-find',$info['audit_admin']);
  107. $html['admin_name'] = $aduit['username'];
  108. } elseif ($info && $info['top_admin']) {
  109. $off = Dever::db('active/info_off')->find($info['top_admin']);
  110. $html['admin_name'] = $off['name'];
  111. }
  112. return $html;
  113. }
  114. public function user($id)
  115. {
  116. $html = '';
  117. $data = Dever::db('active/user')->find($id);
  118. if ($data) {
  119. $member = Dever::load('active/lib/user')->agent($data);
  120. if ($member) {
  121. $user = '<br/>(代理商)';
  122. } else {
  123. $user = '';
  124. }
  125. $html = $data['name'].'<br/>'.$data['mobile'].$user;
  126. }
  127. return $html;
  128. }
  129. public function dOff($id)
  130. {
  131. $data = Dever::db('active/code')->state(array('active_id' => $id,'status'=>1));
  132. $html = count($data);
  133. return $html;
  134. }
  135. public function insertInfoCode($id, $name, $data)
  136. {
  137. $code = Dever::param('code',$data);
  138. if ($code) {
  139. $info = Dever::db('active/info_code')->find(array('code'=>$code));
  140. if ($info['code']) {
  141. Dever::alert('核销码已核销');
  142. }
  143. }
  144. }
  145. public function updateInfoCode($id, $name, $data)
  146. {
  147. $code = Dever::param('code',$data);
  148. $data = Dever::db('active/code')->find(array('write_code'=>$code));
  149. if ($data) {
  150. $where['where_id'] = $data['id'];
  151. $where['status'] = 2;
  152. $where['offdate'] = time();
  153. $admin = Dever::load('manage/auth.info');
  154. $where['audit_admin'] = $admin['id'];
  155. Dever::db('active/code')->update($where);
  156. }
  157. }
  158. public function get()
  159. {
  160. $data[0]['name'] = '头衔';
  161. $data[0]['child'] = Dever::db('setting/title')->select();
  162. $data['state'] = 1;
  163. return $data;
  164. }
  165. public function search_api()
  166. {
  167. $value = Dever::input('value');
  168. if (!$value) {
  169. return '核销码或手机号不存在';
  170. }
  171. $active_id = Dever::input('search_option_active_id');
  172. if ($value) {
  173. $data = Dever::db('active/code')->one(array('write_code' => $value,'state' =>1));
  174. if (!$data) {
  175. if (strlen($value) != 11){
  176. return '核销码或手机号不正确';
  177. } else {
  178. $tell = preg_match("/^1[3456789]\d{9}$/",$value);
  179. if ($tell) {
  180. $user = Dever::db('active/user')->find(array('mobile'=>$value));
  181. if ($user) {
  182. $data = Dever::db('active/code')->find(array('join_uid'=>$user['id'],'active_id'=>1,'status' => 1));
  183. if (!$data) {
  184. return '核销码或手机号不正确或已核销';
  185. }
  186. } else {
  187. return '核销码或手机号不正确';
  188. }
  189. }
  190. }
  191. }
  192. $table = array();
  193. if ($data) {
  194. $user = Dever::db('active/user')->find(array('id'=>$data['join_uid']));
  195. $parent = Dever::db('active/user')->find(array('id'=>$data['buy_uid']));
  196. $table = array();
  197. $table['head'] = array('姓名', '手机号','邀请人', '邀请人手机号');
  198. $table['body'] = array();
  199. $table['body'] = array($user['name'], $user['mobile'],$parent['name'], $parent['mobile']);
  200. $result[] = array
  201. (
  202. 'type' => 'table',
  203. 'content' => $table,
  204. );
  205. $html = Dever::show('', $result, false, false);
  206. return $html;
  207. }else{
  208. return '核销码不存在';
  209. }
  210. } else {
  211. return '';
  212. }
  213. }
  214. public function checkMcode()
  215. {
  216. $mobile = Dever::input('mobile');
  217. $code = Dever::input('mcode');
  218. if (!$code) {
  219. Dever::alert('请输入验证码');
  220. }
  221. $code = Dever::load('passport/reg')->mcode($mobile, $code, 2);
  222. if (!$code) {
  223. Dever::alert('验证码输入错误');
  224. }
  225. return 'ok';
  226. }
  227. public function list()
  228. {
  229. $id = Dever::input('id');
  230. $info = Dever::db('active/order')->find($id);
  231. $active = Dever::db('active/info')->find($info['active_id']);
  232. $config = Dever::db('active/order')->config['config_status'];
  233. $status = Dever::status($config,$info['status']);
  234. if ( !$info['uid']) {
  235. $user = Dever::db('active/user')->find($info['mid']);
  236. $info['uid'] = $user['id'];
  237. }
  238. $code = Dever::db('active/code')->getCode(array('order_id' => $id,'status'=>'1,2'));
  239. $use_code = count($code);#已领取的所有数量
  240. // print_R($use_code);die;
  241. if (!$info['refund_num']) {
  242. $info['refund_num'] = 0;
  243. }
  244. $no_code = $info['num'] - $use_code - $info['refund_num'];#未使用的数量
  245. if ($info['uid'] && $info['uid'] > 0) {
  246. $user = Dever::db('active/user')->find($info['uid']);
  247. $user_name = $user['name'];
  248. $user_mobile = $user['mobile'];
  249. $user_idcard = $user['idcard'];
  250. $member = Dever::load('active/lib/user')->agent($user);
  251. if ($member) {
  252. $role = Dever::db('setting/role')->find($member['role']);
  253. if (isset($role) && $role && isset($role['name']) && $role['name']) {
  254. $role_name = '<br/>'.$role['name'];
  255. } else {
  256. $role_name = '';
  257. }
  258. $title = Dever::db('setting/title')->find($member['title_id']);
  259. if (isset($title) && $title && isset($title['name']) && $title['name']) {
  260. $title_name = '('.$title['name'].')';
  261. } else {
  262. $title_name = '';
  263. }
  264. $level = Dever::db('setting/level')->find($member['level_id']);
  265. if (isset($level) && $level && isset($level['name']) && $level['name']) {
  266. $level_name = '('.$level['name'].')';
  267. } else {
  268. $level_name = '';
  269. }
  270. $user_name = $member['name'].$role_name.$title_name.$level_name;
  271. $user_mobile = $member['mobile'];
  272. $user_idcard = $member['idcard'];
  273. }
  274. }
  275. // print_R($id);die;
  276. $refund = Dever::db('active/info_refund')->getSearch(array('order_id'=>$id));
  277. $refund_path = array();
  278. $refund_desc = '';
  279. if ($refund) {
  280. foreach ($refund as $k1 => $v1) {
  281. $refund_log = Dever::db('active/info_refund_log')->getSearch(array('order_id'=>$v1['id']));
  282. $refund_desc = $v1['desc'];
  283. if ($refund_log) {
  284. if ($refund_log['desc'] != $v1['desc']) {
  285. $refund_desc = $refund_log['desc'];
  286. }
  287. }
  288. if (!$v1['num']) {
  289. $v1['num'] = 0;
  290. }
  291. if (!$v1['price']) {
  292. $v1['price'] = 0;
  293. }
  294. $refund_path[] = array('退款数量',$v1['num']);
  295. $refund_path[] = array('退款金额',$v1['price']);
  296. $refund_path[] = array('退款备注',$refund_desc);
  297. }
  298. }
  299. $path = array();
  300. $path_data = array();
  301. if ($info['path']) {
  302. $path = Dever::json_decode($info['path']);
  303. foreach ($path as $k => $v) {
  304. $field = Dever::db('active/info_field')->find($v['id']);
  305. if ($field['type'] == 1) {
  306. $path_data[] = array($field['name'], $v['value']);
  307. } elseif ($field['type'] == 2) {
  308. $value = Dever::db('active/info_field_value')->find($v['value']);
  309. if ($value) {
  310. $path_data[] = array($field['name'], $value['name']);
  311. }
  312. }
  313. }
  314. }
  315. $result['订单信息'] = array
  316. (
  317. 'type' => 'info',
  318. 'content' => array
  319. (
  320. array
  321. (
  322. array('订单单号', $info['order_num']),
  323. array('活动名称', $active['name']),
  324. array('订单状态', $status),
  325. ),
  326. array
  327. (
  328. array('购买数量', $info['num']),
  329. array('支付金额', $info['price']),
  330. array('备注',$info['remark']),
  331. ),
  332. array
  333. (
  334. array('已使用', $use_code),
  335. array('未使用', $no_code),
  336. // array('退款数量', $info['refund_num']),
  337. ),
  338. array
  339. (
  340. // array('退款数量', $info['refund_num']),
  341. // array('退款总金额', $refund_money),
  342. // array('退款备注', $refund_desc),
  343. ),
  344. ),
  345. );
  346. if ($refund_path && $refund) {
  347. $result['退款信息'] = array
  348. (
  349. 'type' => 'info',
  350. 'content' => array
  351. (
  352. $refund_path,
  353. ),
  354. );
  355. }
  356. $result['用户信息'] = array
  357. (
  358. 'type' => 'info',
  359. 'content' => array
  360. (
  361. array
  362. (
  363. array('用户姓名', $user_name),
  364. array('用户电话', $user_mobile),
  365. array('用户身份证号', $user_idcard),
  366. ),
  367. ),
  368. );
  369. if ($path) {
  370. $result['报名信息'] = array
  371. (
  372. 'type' => 'info',
  373. 'content' => array
  374. (
  375. $path_data,
  376. ),
  377. );
  378. }
  379. $button = array();
  380. if (Dever::load('manage/auth')->checkFunc('active.order', 'edit', '备注')) {
  381. $purl = Dever::url('project/database/update?project=active&table=order&where_id='.$info['id'].'&col=remark', 'manage');
  382. $button[] = array
  383. (
  384. 'type' => 'edit',
  385. 'link' => $purl,
  386. 'name' => '备注',
  387. );
  388. }
  389. if ($info['status'] == 2 && $info['code_num'] < 1 && time() < $active['act_start'] && $active['refund_type'] == 2 ) {
  390. if (Dever::load('manage/auth')->checkFunc('active.order', 'editrefund', '全额退款')) {
  391. $purl = Dever::url('active/lib/manage.refund&id='.$id);
  392. $button[] = array
  393. (
  394. 'type' => 'action',
  395. 'link' => $purl,
  396. 'name' => '全额退款',
  397. );
  398. }
  399. }
  400. if ($info['status'] > 1 && $no_code > 0 && $info['status'] != 3 && $active['refund_type'] == 2) {
  401. // && time()<$active['act_start']
  402. if (Dever::load('manage/auth')->checkFunc('active.order', 'editrefund1', '未使用退款')) {
  403. $purl = Dever::url('project/database/update?project=active&table=info_refund&search_option_price='.$active['price'].'&search_option_order_id='.$info['id'].'&col=num,order_id,price,desc', 'manage');
  404. $button[] = array
  405. (
  406. 'type' => 'edit',
  407. 'link' => $purl,
  408. 'name' => '未使用退款',
  409. );
  410. }
  411. }
  412. if ($use_code >= 0) {
  413. $result += $this->table($id);
  414. }
  415. $head = array
  416. (
  417. 'name' => '基本资料',
  418. 'btn' => $button,
  419. );
  420. $html = Dever::show($head, $result);
  421. return $html;
  422. }
  423. private function table ($id)
  424. {
  425. $data = Dever::db('active/code')->state(array('order_id' => $id));
  426. if ($data) {
  427. $head = array('参加人信息', '核销码', '核销状态', '领取时间', '核销人', '管理');
  428. // '核销时间',
  429. $body = array();
  430. foreach ($data as $k => $v) {
  431. $user = Dever::db('active/user')->find($v['join_uid']);
  432. $join_name = '';
  433. if ($user) {
  434. $join_name = $user['name'].'<br/>'.$user['mobile'];
  435. }
  436. $admin_name = '';
  437. if ($v['status'] == 1) {
  438. $status = '待核销';
  439. } elseif($v['status'] == 2) {
  440. $status = '已核销';
  441. if ($v['audit_admin'] && $v['audit_admin'] >0) {
  442. $admin = Dever::load('manage/admin-find',$v['audit_admin']);
  443. if ($admin) {
  444. $admin_name = $admin['username'];
  445. }
  446. } else {
  447. if ($v['top_admin'] && $v['top_admin'] > 0) {
  448. $admin = Dever::db('active/info_off')->find($v['top_admin']);
  449. if ($admin) {
  450. $admin_name = $admin['name'];
  451. }
  452. }
  453. }
  454. } else {
  455. $status = '已作废';
  456. }
  457. $cdate = '';
  458. if ($v['cdate']) {
  459. $cdate = date('Y-m-d H:i',$v['cdate']);
  460. }
  461. // $offdate = '';
  462. // if ($v['offdate']) {
  463. // $offdate = date('Y-m-d H:i',$v['offdate']);
  464. // }
  465. $active = Dever::db('active/info')->find($v['active_id']);
  466. $m = '';
  467. if ($v['status'] == 1 && $active['refund_type'] == 2 ) {
  468. // && time()<$active['act_start']
  469. if ($active['off_type'] == 2) {
  470. if ($v['status']!=3) {
  471. $url = Dever::url('project/database/update?project=active&table=info_refund_log&search_option_price='.$active['price'].'&search_option_code_id='.$v['id'].'&search_option_order_id='.$id.'&col=price,order_id,code_id,desc', 'manage');
  472. }
  473. } else {
  474. if ($v['status']==1) {
  475. $url = Dever::url('project/database/update?project=active&table=info_refund_log&search_option_price='.$active['price'].'&search_option_code_id='.$v['id'].'&search_option_order_id='.$id.'&col=price,order_id,code_id,desc', 'manage');
  476. }
  477. }
  478. // $url = Dever::url('lib/manage.setOrder&order_id=' . $v['order_id'].'&code_id='.$v['id'].'&col=price', 'active');
  479. if (Dever::load('manage/auth')->checkFunc('active.order', 'editorder', '退款')) {
  480. $m = '<a href="javascript:;" onclick="fastEdit($(this), \''.$url.'\')" class="layui-btn">退款</a>';
  481. }
  482. }
  483. $d = array
  484. (
  485. $join_name,
  486. $v['write_code'],
  487. $status,
  488. $cdate,
  489. // $offdate,
  490. $admin_name,
  491. $m,
  492. );
  493. $body[] = $d;
  494. }
  495. $result['核销码使用列表'] = array
  496. (
  497. 'type' => 'table',
  498. 'content' => array
  499. (
  500. 'head' => $head,
  501. 'body' => $body,
  502. )
  503. );
  504. return $result;
  505. } else {
  506. return array();
  507. }
  508. }
  509. public function insertInfoRefundLog($id,$name,$data)
  510. {
  511. $price = Dever::param('price',$data);
  512. $order_id = Dever::param('order_id',$data);
  513. $code_id = Dever::param('code_id',$data);
  514. $order = Dever::db('active/order')->find($order_id);
  515. $active = Dever::db('active/info')->find($order['active_id']);
  516. if (!$price) {
  517. Dever::alert('退款金额不能为空');
  518. }
  519. if ($price > $active['price']) {
  520. Dever::alert('退款金额大于购买金额');
  521. }
  522. $data = Dever::db('active/info_refund_log')->find(Array('order_id'=>$order_id,'code_id'=>$code_id));
  523. if($data) {
  524. // Dever::alert('不可重复退款');
  525. }
  526. }
  527. public function updateInfoRefundLog($id,$name,$data)
  528. {
  529. $price = Dever::param('price',$data);
  530. $order_id = Dever::param('order_id',$data);
  531. $code_id = Dever::param('code_id',$data);
  532. $desc = Dever::param('desc',$data);
  533. $order = Dever::db('active/order')->find($order_id);
  534. $where['order_id'] = $order_id;
  535. $where['code_id'] = $code_id;
  536. $where['price'] = trim($price);
  537. $where['desc'] = $desc;
  538. $data = Dever::db('active/order')->find($order_id);
  539. $ids = $this->common($data,3,false,false,$price,$desc);
  540. if ($ids) {
  541. $where['status'] = 2;
  542. $where['id'] = $id;
  543. Dever::db('active/info_refund_log')->update($where);
  544. $admin = Dever::load('manage/auth.info');
  545. $w['where_id'] = $code_id;
  546. $w['status'] = 3;
  547. $w['offdate'] = time();
  548. $w['audit_admin'] = $admin['id'];
  549. Dever::db('active/code')->update($w);
  550. }
  551. return 'reload';
  552. }
  553. public function setOrder_api($order_id,$code_id){
  554. $data = Dever::db('active/order')->find($order_id);
  555. $ids = $this->common($data,3);
  556. if ($ids) {
  557. $admin = Dever::load('manage/auth.info');
  558. $w['where_id'] = $code_id;
  559. $w['status'] = 3;
  560. $w['offdate'] = time();
  561. $w['audit_admin'] = $admin['id'];
  562. Dever::db('active/code')->update($w);
  563. }
  564. return 'reload';
  565. }
  566. public function common($data,$type,$num=false,$refund_id=false,$refund_price=false,$refund_desc=false){
  567. Dever::config('base')->hook = true;
  568. $active = Dever::db('active/info')->find($data['active_id']);
  569. $info = Dever::db('active/info_refund')->state(array('order_id'=>$data['id']));
  570. if (time() > $active['act_start']) {
  571. // Dever::alert('活动已开始,不能退款');
  572. }
  573. if ($type == 1) {
  574. $code = Dever::db('active/code')->find(array('order_id'=>$data['id']));
  575. if ($data['code_num'] > 0 || (isset($code) && $code)) {
  576. Dever::alert('此状态下不可退款');
  577. }
  578. if ($data['status'] != 2) {
  579. Dever::alert('此状态下不可退款');
  580. }
  581. $refund_num = $data['num'];
  582. $price = $data['price'];
  583. }
  584. if ($type == 2) {
  585. if ($refund_price) {
  586. $price = $num * $refund_price;
  587. } else {
  588. $price = $num * $active['price'];
  589. }
  590. $refund_num = $num;
  591. }
  592. if ($type == 3) {
  593. $refund_num = 1;
  594. if ($refund_price) {
  595. $price = $refund_price;
  596. } else {
  597. $price = $active['price'];
  598. }
  599. }
  600. // if ($refund_desc) {
  601. // $where['desc'] = $refund_desc;
  602. // }
  603. $param = array
  604. (
  605. 'project_id' => 6,
  606. 'channel_id' => 1,
  607. 'system_source' => 1,
  608. 'account_id' => 8,
  609. 'order_id' => $data['order_num'],
  610. 'refund_cash' => $price,
  611. //'refund_order_id' => '',
  612. );
  613. if ($type != 1) {
  614. $param['refund_order_id'] = count($info) + 1;
  615. }
  616. if ($data['price'] > 0) {
  617. $result = Dever::load('pay/api.refund', $param);
  618. if (!$result) {
  619. # 退款失败,抛出错误
  620. //throw new \Exception('退款失败');
  621. Dever::alert('退款失败,请联系管理员');
  622. } else {
  623. $admin = Dever::load('manage/auth.info');
  624. $time = time();
  625. $where['where_id'] = $data['id'];
  626. $where['status'] = 6;
  627. $where['refund_admin'] = $admin['id'];
  628. $where['rdate'] = $time;
  629. if (!$data['refund_num']) {
  630. $data['refund_num'] = 0;
  631. }
  632. $where['refund_num'] = $refund_num + $data['refund_num'];
  633. if ($type == 1 || ($price == $data['price']) || ($data['num'] == $where['refund_num'])) {
  634. $ids = Dever::db('active/order')->update($where);
  635. } else {
  636. $where['status'] = 2;
  637. $ids = Dever::db('active/order')->update($where);
  638. }
  639. if ($type == 2) {
  640. $insert['status'] = 2;
  641. $insert['where_id'] = $refund_id;
  642. $insert['audit_admin'] = $admin['id'];
  643. if ($refund_desc) {
  644. $insert['desc'] = $refund_desc;
  645. }
  646. $insert['price'] = $price;
  647. Dever::db('active/info_refund')->update($insert);
  648. } elseif ($type == 3) {
  649. $add['status'] = 2;
  650. $add['order_id'] = $data['id'];
  651. $add['num'] = 1;
  652. $add['price'] = $price;
  653. if ($refund_desc) {
  654. $add['desc'] = $refund_desc;
  655. }
  656. Dever::db('active/info_refund')->insert($add);
  657. }
  658. if (isset($ids) && $ids){
  659. return $ids;
  660. }
  661. }
  662. }
  663. }
  664. #扫码核销活动
  665. public function code_api(){
  666. $active_id = Dever::input('id');
  667. if (!$active_id) {
  668. return '活动id不存在';
  669. }
  670. $active = Dever::db('active/info')->find($active_id);
  671. $config = Dever::db('active/info')->config['config_act_status'];
  672. $code = Dever::input('code');
  673. if (!$code) {
  674. $data = array();
  675. $data['active_name'] = $active['name'];
  676. $data['status'] = Dever::status($config,$active['act_status']);
  677. $data['act_time'] = date('Y.m.d H:i:s',$active['act_start']).'~'.date('Y.m.d H:i:s',$active['act_end']);
  678. $data['active_id'] = $active_id;
  679. $one = Dever::db('active/code')->find(array('code'=>$code));
  680. $data['seat_num'] = $one['seat_num'];
  681. return Dever::render('off_code', $data);
  682. }
  683. // print_R($code);die;
  684. $data = Dever::db('active/code')->find(array('write_code'=>$code,'active_id'=>$active_id,'status'=>1));
  685. if ($data) {
  686. $data['active_name'] = $active['name'];
  687. $data['status'] = Dever::status($config,$active['act_status']);
  688. $data['act_time'] = date('Y.m.d H:i:s',$active['act_start']).'~'.date('Y.m.d H:i:s',$active['act_end']);
  689. $join_user = Dever::db('active/user')->find($data['join_uid']);
  690. $data['join_name'] = $join_user['name'];
  691. $data['join_mobile'] = $join_user['mobile'];
  692. $con = Dever::db('deploy/base-one');
  693. if ($join_user['avatar']) {
  694. $data['join_avatar'] = $join_user['avatar'];
  695. } else {
  696. $data['join_avatar'] = $con['avatar'];
  697. }
  698. $data['buy_name'] = '';
  699. $data['buy_mobile'] = '';
  700. $data['buy_avatar'] = '';
  701. $buy_user = Dever::db('active/user')->find($data['buy_uid']);
  702. if ($buy_user) {
  703. $data['buy_name'] = $buy_user['name'];
  704. $data['buy_mobile'] = $buy_user['mobile'];
  705. $data['buy_avatar'] = '';
  706. if ($buy_user['avatar']) {
  707. $data['buy_avatar'] = $buy_user['avatar'];
  708. }
  709. }
  710. $member = Dever::load('active/lib/user')->agent($buy_user);
  711. $data['role_name'] ='';
  712. $data['title_name'] = '';
  713. if ($member) {
  714. $role = Dever::db('setting/role')->find($member['role']);
  715. $title = Dever::db('setting/title')->find($member['title_id']);
  716. $level = Dever::db('setting/level')->find($member['level_id']);
  717. if ($role) {
  718. if (isset($level) && $level && isset($level['name']) && $level['name']) {
  719. $data['role_name'] = $role['name'] .'('.$level['name'].')';
  720. } else {
  721. $data['role_name'] = $role['name'];
  722. }
  723. }
  724. if ($title && $title['name']) {
  725. $data['title_name'] = $title['name'];
  726. }
  727. if (!$data['buy_avatar']) {
  728. $data['buy_avatar'] = $member['avatar'];
  729. } else {
  730. $data['buy_avatar'] = $con['avatar'];
  731. }
  732. }
  733. } else {
  734. return '核销码不存在或已核销';
  735. }
  736. $type = Dever::input('type');
  737. if ($type == 1) {
  738. return Dever::render('off_code', $data);
  739. }else {
  740. return $data;
  741. }
  742. }
  743. }