人人商城

card.ctrl.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. $dos = array('check');
  8. $do = in_array($do, $dos) ? $do : 'check';
  9. load()->model('card');
  10. if($do == 'check') {
  11. $set = card_setting();
  12. if(is_error($set)) {
  13. message($set, '', 'ajax');
  14. }
  15. $_GPC = $_GPC['__input'];
  16. $cardsn = trim($_GPC['cardsn']);
  17. $card_member = pdo_getall('mc_card_members', array('uniacid' => $_W['uniacid'], 'cardsn' => $cardsn));
  18. if(empty($card_member)) {
  19. message(error(-1, '卡号不存在或已经删除'), '', 'ajax');
  20. }
  21. if(count($card_member) > 1) {
  22. message(error(-1, '卡号对应用户不唯一'), '', 'ajax');
  23. }
  24. $card_member = $card_member[0];
  25. if($card_member['status'] != 1) {
  26. message(error(-1, '该会员卡已被禁用'), '', 'ajax');
  27. }
  28. $member = pdo_get('mc_members', array('uniacid' => $_W['uniacid'], 'uid' => $card_member['uid']));
  29. if(empty($member)) {
  30. message(error(-1, '会员卡对应的会员不存在'), '', 'ajax');
  31. }
  32. $member['openid'] = $card_member['openid'];
  33. $member['createtime'] = $card_member['createtime'];
  34. $member['cardsn'] = $card_member['cardsn'];
  35. $member['groupname'] = $_W['account']['groups'][$member['groupid']]['title'];
  36. $member['discount_type'] = 0;
  37. $member['discount'] = array();
  38. $member['discount_cn'] = '暂无';
  39. $member['credit1'] = floatval($member['credit1']);
  40. $member['credit2'] = floatval($member['credit2']);
  41. $member['offset_rate'] = $set['offset_rate'];
  42. $member['offset_max'] = $set['offset_max'];
  43. if($set['discount_type'] > 0 && !empty($set['discount'])) {
  44. $discount = $set['discount'][$member['groupid']];
  45. if(!empty($discount)) {
  46. $member['discount'] = $discount;
  47. $member['discount_type'] = $set['discount_type'];
  48. if($set['discount_type'] == 1 ) {
  49. $member['discount_cn'] = "满 {$discount['condition']} 元减 {$discount['discount']}元";
  50. } else {
  51. $zhe = $discount['discount'] * 10;
  52. $member['discount_cn'] = "满 {$discount['condition']} 元打 {$zhe}折";
  53. }
  54. }
  55. }
  56. message(error(0, $member), '', 'ajax');
  57. }