Config.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\memberconsume\shop\controller;
  11. use app\shop\controller\BaseShop;
  12. use addon\memberconsume\model\Consume;
  13. /**
  14. * 会员消费
  15. */
  16. class Config extends BaseShop
  17. {
  18. /**
  19. * 消费返积分
  20. */
  21. public function index()
  22. {
  23. if (request()->isAjax()) {
  24. //订单消费返积分设置数据
  25. $data = [
  26. 'return_point_status' => input('return_point_status', 'complete'),//返积分事件 pay 订单付款 receive 订单收货 complete 订单完成 单选或下拉
  27. 'return_point_rate' => input('return_point_rate', 0),//返积分比率 0-100 不取小数
  28. 'return_growth_rate' => input('return_growth_rate', 0),//成长值返还比例0-100 不取小数
  29. 'return_coupon' => input('return_coupon', ''),//优惠券
  30. 'is_return_coupon' => input('is_return_coupon', 0),//是否送优惠券
  31. 'is_recovery_reward' => input('is_recovery_reward', 0),//退款是否回收奖励
  32. ];
  33. $this->addLog("设置会员消费奖励");
  34. $is_use = input("is_use", 0);//是否启用
  35. $config_model = new Consume();
  36. $res = $config_model->setConfig($data, $is_use, $this->site_id);
  37. return $res;
  38. } else {
  39. $event_list = array(
  40. ["name" => "receive", "title" => "订单收货"],
  41. ["name" => "pay", "title" => "订单付款"],
  42. ["name" => "complete", "title" => "订单完成"],
  43. );
  44. $this->assign("event_list", $event_list);
  45. $config_model = new Consume();
  46. //订单返积分设置
  47. $config_result = $config_model->getConfig($this->site_id);
  48. $this->assign('config', $config_result['data']);
  49. $this->forthMenu();
  50. return $this->fetch('config/index');
  51. }
  52. }
  53. /**
  54. * 奖励记录
  55. */
  56. public function lists()
  57. {
  58. if (request()->isAjax()) {
  59. $page = input('page', 1);
  60. $page_size = input('page_size', PAGE_LIST_ROWS);
  61. $status = input('status', '');
  62. $order_no = input('order_no', '');
  63. $username = input('username', '');
  64. $condition = [];
  65. if ($status !== '') {
  66. $condition[] = ['pcr.type', '=', $status];
  67. }
  68. if($order_no){
  69. $condition[] = ['o.order_no', 'like', '%'.$order_no.'%'];
  70. }
  71. if($username){
  72. $condition[] = ['m.username', 'like', '%'.$username.'%'];
  73. }
  74. $condition[] = ['pcr.site_id', '=', $this->site_id];
  75. $order = 'pcr.create_time desc';
  76. $field = 'pcr.*,m.username,m.nickname,m.mobile,m.headimg,o.order_no';
  77. $alias = 'pcr';
  78. $join = [
  79. ['member m','pcr.member_id = m.member_id','left'],
  80. ['order o','pcr.order_id = o.order_id','left'],
  81. ];
  82. $start_time = input('start_time', '');
  83. $end_time = input('end_time', '');
  84. if ($start_time && !$end_time) {
  85. $condition[] = ['pcr.create_time', '>=', date_to_time($start_time)];
  86. } elseif (!$start_time && $end_time) {
  87. $condition[] = ['pcr.create_time', '<=', date_to_time($end_time)];
  88. } elseif ($start_time && $end_time) {
  89. $condition[] = [ 'pcr.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
  90. }
  91. $config_model = new Consume();
  92. $res = $config_model->getConsumeRecordPageList($condition, $page, $page_size, $order, $field, $alias, $join);
  93. return $res;
  94. } else {
  95. $event_list = array(
  96. ["name" => "coupon", "title" => "优惠券"],
  97. ["name" => "point", "title" => "积分"],
  98. ["name" => "growth", "title" => "成长值"],
  99. );
  100. $this->assign("event_list", $event_list);
  101. $this->forthMenu();
  102. return $this->fetch('config/lists');
  103. }
  104. }
  105. }