gift.php 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. return [
  3. 'shop_coupon' => [
  4. 'key' => 'shop_coupon',
  5. 'name' => '优惠券', // 礼包名称
  6. 'desc' => '发放优惠券', // 礼包说明
  7. 'component' => '/src/addon/mall/views/mall/member/components/gift-coupon.vue',
  8. // 礼包发放调用方法
  9. 'grant' => function($site_id, $member_id, $config) {
  10. $service = new \addon\mall\app\service\core\coupon\CoreCouponMemberService();
  11. foreach ($config['coupon_id'] as $coupon_id) {
  12. if (!isset($config['coupon_list']['id_' . $coupon_id])) continue;
  13. $service->sendCoupon($site_id, $member_id, $coupon_id, $config['coupon_list']['id_' . $coupon_id]);
  14. }
  15. },
  16. "content" => [
  17. // 管理端
  18. 'admin' => function($site_id, $config) {
  19. $content = [];
  20. $model = (new addon\mall\app\model\coupon\Coupon());
  21. $coupon_list = $model->where([ ['site_id', '=', $site_id], ['id', 'in', $config['coupon_id'] ] ])->field('id,title')->select()->toArray();
  22. if (!empty($coupon_list)) {
  23. foreach ($coupon_list as $item) {
  24. $content[] = $item['title'] . '*' . $config['coupon_list']['id_' . $item['id'] ];
  25. }
  26. }
  27. return implode(',', $content);
  28. },
  29. // 会员等级
  30. 'member_level' => function($site_id, $config) {
  31. $content = [];
  32. $model = (new addon\mall\app\model\coupon\Coupon());
  33. $coupon_list = $model->where([ ['site_id', '=', $site_id], ['id', 'in', $config['coupon_id'] ] ])->field('id,price')->select()->toArray();
  34. if (!empty($coupon_list)) {
  35. foreach ($coupon_list as $item) {
  36. $content[] = [
  37. 'text' => round($item['price']) . "元优惠券",
  38. 'background' => '/addon/mall/gift/gift_coupon_bg.png'
  39. ];
  40. }
  41. }
  42. return $content;
  43. },
  44. // 会员签到(日签)
  45. 'member_sign' => function($site_id, $config) {
  46. $content = [];
  47. $model = (new addon\mall\app\model\coupon\Coupon());
  48. $coupon_list = $model->where([ ['site_id', '=', $site_id], ['id', 'in', $config['coupon_id'] ] ])->field('id,price')->select()->toArray();
  49. if (!empty($coupon_list)) {
  50. foreach ($coupon_list as $item) {
  51. $content[] = [
  52. 'text' => round($item['price']) . "元优惠券",
  53. 'icon' => '/addon/mall/sign/coupon.png'
  54. ];
  55. }
  56. }
  57. return $content;
  58. },
  59. // 会员签到(连签)
  60. 'member_sign_continue' => function($site_id, $config) {
  61. $content = [];
  62. $model = (new addon\mall\app\model\coupon\Coupon());
  63. $coupon_list = $model->where([ ['site_id', '=', $site_id], ['id', 'in', $config['coupon_id'] ] ])->field('id,price')->select()->toArray();
  64. if (!empty($coupon_list)) {
  65. foreach ($coupon_list as $item) {
  66. $content[] = [
  67. 'text' => round($item['price']) . "元优惠券",
  68. 'icon' => '/addon/mall/sign/coupon01.png'
  69. ];
  70. }
  71. }
  72. return $content;
  73. }
  74. ]
  75. ]
  76. ];