WithdrawMessageService.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: yunzhong
  5. * Date: 2018/10/16
  6. * Time: 15:35
  7. */
  8. namespace app\frontend\modules\withdraw\services;
  9. use app\common\models\notice\MessageTemp;
  10. use app\common\services\MessageService;
  11. class WithdrawMessageService extends MessageService
  12. {
  13. protected $order;
  14. protected $msg;
  15. protected $templateId;
  16. protected $notice;
  17. /**
  18. * @param $withdrawModel
  19. */
  20. public function withdraw($withdrawModel)
  21. {
  22. $temp_id = \Setting::get('withdraw.notice')['member_withdraw'];
  23. if (!$temp_id) {
  24. return;
  25. }
  26. $params = [
  27. ['name' => '粉丝昵称', 'value' => $withdrawModel->hasOneMember->nickname],
  28. ['name' => '申请时间', 'value' => $withdrawModel->created_at->toDateTimeString()],
  29. ['name' => '提现金额', 'value' => $withdrawModel->amounts],
  30. ['name' => '手续费金额', 'value' => $withdrawModel->poundage],
  31. ['name' => '劳务税金额', 'value' => $withdrawModel->servicetax],
  32. ['name' => '提现类型', 'value' => $withdrawModel->type_name],
  33. ['name' => '提现方式', 'value' => $withdrawModel->pay_way_name],
  34. ['name' => '提现单号', 'value' => $withdrawModel->withdraw_sn],
  35. ];
  36. $this->transfer($temp_id, $params);
  37. }
  38. private function transfer($temp_id, $params)
  39. {
  40. $this->msg = MessageTemp::getSendMsg($temp_id, $params);
  41. if (!$this->msg) {
  42. return;
  43. }
  44. $this->templateId = MessageTemp::$template_id;
  45. $this->sendToShops();
  46. }
  47. private function sendToShops()
  48. {
  49. if (empty(\Setting::get('withdraw.notice.withdraw_user'))) {
  50. return;
  51. }
  52. if (empty($this->templateId)) {
  53. return;
  54. }
  55. $news_link = MessageTemp::find($this->templateId)->news_link;
  56. $news_link = $news_link ?:'';
  57. //客服发送消息通知
  58. foreach (\Setting::get('withdraw.notice.withdraw_user') as $withdraw_user) {
  59. $this->notice($this->templateId, $this->msg, $withdraw_user['uid'],'',$news_link);
  60. }
  61. }
  62. }