ApplyBroadcastGoodsJob.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 crmeb\jobs;
  12. use app\common\repositories\store\broadcast\BroadcastGoodsRepository;
  13. use crmeb\interfaces\JobInterface;
  14. use crmeb\services\YunxinSmsService;
  15. use think\facade\Log;
  16. class ApplyBroadcastGoodsJob implements JobInterface
  17. {
  18. public function fire($job, $goodsId)
  19. {
  20. $broadcastRoomGoodsRepository = app()->make(BroadcastGoodsRepository::class);
  21. $goods = $broadcastRoomGoodsRepository->get($goodsId);
  22. if ($goods) {
  23. try {
  24. $res = $broadcastRoomGoodsRepository->wxCreate($goods);
  25. } catch (\Exception $e) {
  26. $goods->error_msg = $e->getMessage();
  27. $goods->status = -1;
  28. }
  29. if (isset($res)) {
  30. $goods->goods_id = $res->goodsId;
  31. $goods->audit_id = $res->auditId;
  32. $goods->status = 1;
  33. }
  34. $goods->save();
  35. }
  36. $job->delete();
  37. }
  38. public function failed($data)
  39. {
  40. // TODO: Implement failed() method.
  41. }
  42. }