OrderProcessEvent.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\event\order;
  3. use app\admin\service\order\OrderProcessService;
  4. use app\model\OrderProcess;
  5. use support\Log;
  6. use Tinywan\Jwt\JwtToken;
  7. class OrderProcessEvent
  8. {
  9. public function orderComplete($params)
  10. {
  11. try {
  12. $userId = JwtToken::getCurrentId();
  13. } catch (\Exception $e) {
  14. }
  15. try {
  16. $data = [
  17. 'process_key' => 'DONE',
  18. 'process_name' => '订单完成',
  19. 'user_id' => $userId ?? '',
  20. 'process_json' => $params
  21. ];
  22. if (!empty($params['join_order_member_id'])) {
  23. $data['member_id'] = $params['join_order_member_id'];
  24. }
  25. if (!empty($params['orderId'])) {
  26. $data['order_id'] = $params['orderId'];
  27. }
  28. if (!empty($params['submit_premises_id'])) {
  29. $data['dept_id'] = $params['submit_premises_id'];
  30. }
  31. OrderProcessService::insert($data);
  32. } catch (\Exception $e) {
  33. dump($e->getMessage());
  34. $params['msg'] = $e->getMessage();
  35. Log::error("WRITE_ORDER_PROCESS_ERROR", $params);
  36. }
  37. }
  38. public function orderWriteOff($params)
  39. {
  40. try {
  41. $userId = JwtToken::getCurrentId();
  42. } catch (\Exception $e) {
  43. }
  44. try {
  45. $data = [
  46. 'process_key' => 'PAYOFF',
  47. 'process_name' => '订单核销',
  48. 'user_id' => $userId ?? '',
  49. 'process_json' => $params['write_off_data']
  50. ];
  51. if (!empty($params['join_order_member_id'])) {
  52. $data['member_id'] = $params['join_order_member_id'];
  53. }
  54. if (!empty($params['order_id'])) {
  55. $data['order_id'] = $params['order_id'];
  56. }
  57. if (!empty($params['dept'])) {
  58. $data['dept_id'] = $params['dept']->dept_id;
  59. }
  60. OrderProcessService::insert($data);
  61. } catch (\Exception $e) {
  62. dump($e->getMessage());
  63. $params['msg'] = $e->getMessage();
  64. Log::error("WRITE_ORDER_PROCESS_ERROR", $params);
  65. }
  66. }
  67. }