ShowPromotion.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\memberconsume\event;
  11. use addon\memberconsume\model\Consume;
  12. /**
  13. * 活动展示
  14. */
  15. class ShowPromotion
  16. {
  17. /**
  18. * 活动展示
  19. * @param array $params
  20. * @return array
  21. */
  22. public function handle($params = [])
  23. {
  24. $data = [
  25. 'shop' => [
  26. [
  27. //插件名称
  28. 'name' => 'memberconsume',
  29. //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
  30. 'show_type' => 'member',
  31. //展示主题
  32. 'title' => '消费奖励',
  33. //展示介绍
  34. 'description' => '客户消费后发放奖励',
  35. //展示图标
  36. 'icon' => 'addon/memberconsume/icon.png',
  37. //跳转链接
  38. 'url' => 'memberconsume://shop/config/index',
  39. 'summary' => $this->summary($params)
  40. ]
  41. ]
  42. ];
  43. return $data;
  44. }
  45. /**
  46. * 营销活动概况
  47. * @param $params
  48. * @return array
  49. */
  50. private function summary($params)
  51. {
  52. if (empty($params)) {
  53. return [];
  54. }
  55. if (isset($params[ 'count' ]) || isset($params[ 'summary' ])) $config = ( new Consume() )->getConfig($params[ 'site_id' ])[ 'data' ];
  56. //获取活动数量
  57. if (isset($params[ 'count' ])) {
  58. return [
  59. 'count' => $config[ 'is_use' ]
  60. ];
  61. }
  62. //获取活动概况,需要获取开始时间与结束时间
  63. if (isset($params[ 'summary' ])) {
  64. $content = [];
  65. $value = $config[ 'value' ];
  66. if ($value[ 'return_point_rate' ]) array_push($content, '消费返消费额' . $value[ 'return_point_rate' ] . '%积分');
  67. if ($value[ 'return_growth_rate' ]) array_push($content, '消费返消费额' . $value[ 'return_growth_rate' ] . '%成长值');
  68. if ($value[ 'coupon_list' ]) array_push($content, '消费送优惠券');
  69. return [
  70. 'unlimited_time' => [
  71. 'status' => $config[ 'is_use' ],
  72. 'detail' => empty($content) ? '未配置活动' : implode('、', $content),
  73. 'switch_type' => empty($content) ? 'jump' : 'switch',
  74. 'config_key' => 'MEMBER_CONSUME_CONFIG'
  75. ]
  76. ];
  77. }
  78. }
  79. }