ActivateSvipReportJob.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Jobs\GrowingIO;
  3. use App\Models\OrderModel;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Queue\SerializesModels;
  6. use Illuminate\Queue\InteractsWithQueue;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use Illuminate\Foundation\Bus\Dispatchable;
  9. class ActivateSvipReportJob extends BaseReportJob implements ShouldQueue
  10. {
  11. use Dispatchable;
  12. use InteractsWithQueue;
  13. use Queueable;
  14. use SerializesModels;
  15. protected $order;
  16. public function __construct(OrderModel $order)
  17. {
  18. $this->order = $order;
  19. }
  20. /**
  21. * Execute the job.
  22. *
  23. * @return void
  24. */
  25. public function doHandle()
  26. {
  27. $this->order->load([
  28. 'coupon',
  29. 'user',
  30. ]);
  31. if (!$this->order->user) {
  32. return;
  33. }
  34. $coupon = '';
  35. $this->doReport(self::ACTIVATE_SVIP, $this->order->uid, [
  36. 'gender' => $this->transformGender($this->order->user->sex),
  37. 'location' => $this->order->user->address,
  38. 'device' => $this->order->device,
  39. 'type' => $this->transformOrderType($this->order->type),
  40. 'amount_float' => $this->order->cash_fee / 100,
  41. 'coupon_type' => $this->transformCoupon($this->order->coupon),
  42. // 开通性别 字符串 : 男生、女生
  43. //
  44. //定位城市 字符串 : 具体城市名称
  45. //
  46. //用户系统 字符串 : ios、android
  47. //
  48. //开通类型 字符串 : 一月会员、一季会员、一年会员
  49. //
  50. //充值金额 浮点 : 具体充值数额
  51. //
  52. //用券类型 字符串 : 未用券、8.8折优惠券、…
  53. ]);
  54. }
  55. protected function transformCoupon($coupon)
  56. {
  57. if (!$coupon) {
  58. return '未用券';
  59. }
  60. if ($coupon->type == '折扣券') {
  61. return ($coupon->discount / 100) . '折扣券';
  62. } elseif ($coupon->type == '满减券') {
  63. return '最低消费' . ($coupon->min_amount / 100) . '满减券';
  64. } elseif ($coupon->type == '抵扣券') {
  65. return ($coupon->coupon_amount / 100) . '抵扣券';
  66. } else {
  67. return $coupon->type;
  68. }
  69. }
  70. }