OrderStatusJob.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\order;
  12. use app\services\order\StoreOrderStatusServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. /**
  16. * Class OrderStatusJob
  17. * @package app\jobs\order
  18. */
  19. class OrderStatusJob extends BaseJobs
  20. {
  21. use QueueTrait;
  22. public function doJob($orderId, $group, $totalPrice, $payPrice)
  23. {
  24. /** @var StoreOrderStatusServices $statusService */
  25. $statusService = app()->make(StoreOrderStatusServices::class);
  26. $statusService->save([
  27. 'oid' => $orderId,
  28. 'change_type' => 'cache_key_create_order',
  29. 'change_message' => '订单生成',
  30. 'change_time' => time()
  31. ]);
  32. if (isset($group['changePrice']) && $group['changePrice'] > 0) {
  33. $totalPrice = $group['priceData']['pay_price'] ?? $totalPrice;
  34. $statusService->save([
  35. 'oid' => $orderId,
  36. 'change_type' => 'order_edit',
  37. 'change_time' => time(),
  38. 'change_message' => '商品总价为:' . $totalPrice . ' 修改实际支付金额为:' . $payPrice
  39. ]);
  40. }
  41. return true;
  42. }
  43. /**
  44. * 保存支付成功
  45. * @param $oid
  46. * @return bool
  47. */
  48. public function savePayStatus($oid)
  49. {
  50. if (!$oid) {
  51. return true;
  52. }
  53. /** @var StoreOrderStatusServices $statusService */
  54. $statusService = app()->make(StoreOrderStatusServices::class);
  55. $statusService->save([
  56. 'oid' => $oid,
  57. 'change_type' => 'pay_success',
  58. 'change_message' => '用户付款成功',
  59. 'change_time' => time()
  60. ]);
  61. return true;
  62. }
  63. }