人人商城

credit.ctrl.php 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. uni_user_permission_check('mc_credit');
  8. $dos = array('display', 'strategy');
  9. $do = in_array($do, $dos) ? $do : 'display';
  10. if($do == 'display') {
  11. $_W['page']['title'] = '积分列表 - 积分设置 - 会员中心';
  12. if(checksubmit('submit')) {
  13. $titlearr = $_GPC['title'];
  14. $enabledarr = $_GPC['enabled'];
  15. foreach($titlearr as $key => $value){
  16. if($key == 'credit1' || $key == 'credit2') {
  17. $enabled_tmp = 1;
  18. } else {
  19. $enabled_tmp = isset($enabledarr[$key]) ? intval($enabledarr[$key]) : 0;
  20. }
  21. $creditnamearr[$key] = array('title' => $value,'enabled' => $enabled_tmp);
  22. }
  23. $list = pdo_fetch("SELECT creditbehaviors FROM ".tablename('uni_settings') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid']));
  24. $list = iunserializer($list['creditbehaviors']);
  25. $type = array('activity' => '基本&营销', 'currency' => '交易&支付(余额)');
  26. foreach ($list as $key=>$value) {
  27. foreach ($creditnamearr as $k=>$v) {
  28. if ($v['enabled'] === 0) {
  29. if ($value == $k) {
  30. message("关闭前请先更改 $type[$key] 积分策略", url('mc/credit/strategy'), 'error');
  31. }
  32. }
  33. }
  34. }
  35. $data = array(
  36. 'uniacid' => $_W['uniacid'],
  37. 'creditnames' => iserializer($creditnamearr)
  38. );
  39. $row = pdo_fetch("SELECT uniacid FROM ".tablename('uni_settings') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid']));
  40. if(empty($row)) {
  41. pdo_insert('uni_settings', $data);
  42. cache_delete("unisetting:{$_W['uniacid']}");
  43. message('积分列表更新成功!', referer(), 'success');
  44. } else {
  45. pdo_update('uni_settings', $data, array('uniacid' => $_W['uniacid']));
  46. cache_delete("unisetting:{$_W['uniacid']}");
  47. message('积分列表更新成功!', referer(), 'success');
  48. }
  49. }
  50. $credits = array();
  51. $credits['credit1'] = array('enabled' => 0, 'title' => '');
  52. $credits['credit2'] = array('enabled' => 0, 'title' => '');
  53. $credits['credit3'] = array('enabled' => 0, 'title' => '');
  54. $credits['credit4'] = array('enabled' => 0, 'title' => '');
  55. $credits['credit5'] = array('enabled' => 0, 'title' => '');
  56. $list = pdo_fetch("SELECT creditnames FROM ".tablename('uni_settings') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid']));
  57. if(!empty($list['creditnames'])) {
  58. $list = iunserializer($list['creditnames']);
  59. if(is_array($list)) {
  60. foreach($list as $k => $v) {
  61. $credits[$k] = $v;
  62. }
  63. }
  64. }
  65. }
  66. if($do == 'strategy') {
  67. $_W['page']['title'] = '积分策略 - 积分设置 - 会员中心';
  68. $row = pdo_fetch("SELECT creditnames,creditbehaviors FROM ".tablename('uni_settings') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid']));
  69. if(!empty($row['creditnames'])) {
  70. $list = iunserializer($row['creditnames']);
  71. $creditbehaviors = iunserializer($row['creditbehaviors']);
  72. if(!is_array($creditbehaviors)) {
  73. $creditbehaviors=array();
  74. }
  75. if(is_array($list)) {
  76. foreach($list as $key => $v) {
  77. if($v['enabled'] == '1') {
  78. $credits[$key] = $v;
  79. }
  80. }
  81. }
  82. }
  83. if(checksubmit('submit')) {
  84. $activity = $_GPC['activity'];
  85. $currency = $_GPC['currency'];
  86. $arr = array('activity' => $activity,'currency' => $currency);
  87. $data = array(
  88. 'uniacid' => $_W['uniacid'],
  89. 'creditbehaviors' => iserializer($arr)
  90. );
  91. $row = pdo_fetch("SELECT uniacid FROM ".tablename('uni_settings') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid']));
  92. if(empty($row)) {
  93. pdo_insert('uni_settings', $data);
  94. cache_delete("unisetting:{$_W['uniacid']}");
  95. message('积分列表更新成功!', referer(), 'success');
  96. } else {
  97. pdo_update('uni_settings', $data, array('uniacid' => $_W['uniacid']));
  98. cache_delete("unisetting:{$_W['uniacid']}");
  99. message('积分列表更新成功!', referer(), 'success');
  100. }
  101. }
  102. }
  103. template('mc/credit');