LuckLotteryJob.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\jobs\activity;
  12. use app\services\activity\lottery\LuckLotteryRecordServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. /**
  17. * 营销:抽奖活动
  18. * Class LuckLotteryJob
  19. * @package app\jobs\activity
  20. */
  21. class LuckLotteryJob extends BaseJobs
  22. {
  23. use QueueTrait;
  24. /**
  25. * @param $oid
  26. * @param $orderInfo
  27. * @return bool|void
  28. */
  29. public function updateLotteryRecord($oid, $orderInfo)
  30. {
  31. if (!$oid) {
  32. return true;
  33. }
  34. try {
  35. /** @var LuckLotteryRecordServices $lotteryRecordServices */
  36. $lotteryRecordServices = app()->make(LuckLotteryRecordServices::class);
  37. $data['oid'] = $orderInfo['id'];
  38. $data['is_receive'] = 1;
  39. $data['receive_time'] = time();
  40. $receive_info['name'] = $orderInfo['real_name'];
  41. $receive_info['phone'] = $orderInfo['user_phone'];
  42. if ($orderInfo['shipping_type'] == 2) {
  43. $receive_info['address'] = '';
  44. } else {
  45. $receive_info['address'] = $orderInfo['user_address'];
  46. }
  47. $data['receive_info'] = $receive_info;
  48. $lotteryRecordServices->update($orderInfo['activity_id'], $data, 'id');
  49. } catch (\Throwable $e) {
  50. Log::error('抽奖订单处理中奖记录失败,失败原因:' . $e->getMessage());
  51. }
  52. return true;
  53. }
  54. }