BalanceNoticeService.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /****************************************************************
  3. * Author: libaojia
  4. * Date: 2017/7/25 下午10:32
  5. * Email: livsyitian@163.com
  6. * QQ: 995265288
  7. * User: 芸众商城 www.yunzshop.com
  8. ****************************************************************/
  9. namespace app\common\services\finance;
  10. use app\common\models\Member;
  11. use app\common\models\notice\MessageTemp;
  12. use app\common\services\MessageService;
  13. use app\common\services\notice\official\WithdrawFailNotice;
  14. use app\common\services\notice\official\WithdrawRejectNotice;
  15. use app\common\services\notice\official\WithdrawSubmitNotice;
  16. use app\common\services\notice\official\WithdrawSuccessNotice;
  17. use Illuminate\Database\Eloquent\Model;
  18. class BalanceNoticeService
  19. {
  20. public static function withdrawSubmitNotice(Model $withdrawModel)
  21. {
  22. $template_id = \Setting::get('shop.notice.withdraw_submit');
  23. $subNotice = new WithdrawSubmitNotice($withdrawModel);
  24. $subNotice->sendMessage();
  25. return ;
  26. if (!$template_id) {
  27. return null;
  28. }
  29. $params = [
  30. ['name' => '时间', 'value' => $withdrawModel->created_at->toDateTimeString()],
  31. ['name' => '金额', 'value' => $withdrawModel->amounts],
  32. ['name' => '手续费', 'value' => $withdrawModel->actual_poundage],
  33. ];
  34. static::notice($template_id,$params,$withdrawModel->member_id);
  35. }
  36. public static function withdrawSuccessNotice(Model $withdrawModel)
  37. {
  38. $template_id = \Setting::get('shop.notice.withdraw_success');
  39. $successNotice = new WithdrawSuccessNotice($withdrawModel);
  40. $successNotice->sendMessage();
  41. return ;
  42. if (!$template_id) {
  43. return null;
  44. }
  45. $pay_at = $withdrawModel->pay_at;
  46. if(empty($pay_at)){
  47. $pay_at = time();
  48. }
  49. $params = [
  50. ['name' => '时间', 'value' => date('Y-m-d H:i:s', $pay_at)],
  51. ['name' => '金额', 'value' => $withdrawModel->amounts],
  52. ['name' => '手续费', 'value' => $withdrawModel->actual_poundage],
  53. ];
  54. static::notice($template_id,$params,$withdrawModel->member_id);
  55. }
  56. public static function withdrawFailureNotice(Model $withdrawModel)
  57. {
  58. $template_id = \Setting::get('shop.notice.withdraw_fail');
  59. $failNotice = new WithdrawFailNotice($withdrawModel);
  60. $failNotice->sendMessage();
  61. return ;
  62. if (!$template_id) {
  63. return null;
  64. }
  65. $params = [
  66. ['name' => '时间', 'value' => date('Y-m-d H:i:s', $withdrawModel->audit_at)],
  67. ['name' => '金额', 'value' => $withdrawModel->amounts],
  68. ['name' => '手续费', 'value' => $withdrawModel->actual_poundage],
  69. ['name' => '提现单号', 'value' => $withdrawModel->withdraw_sn],
  70. ];
  71. static::notice($template_id,$params,$withdrawModel->member_id);
  72. }
  73. public static function withdrawRejectNotice(Model $withdrawModel)
  74. {
  75. $template_id = \Setting::get('shop.notice.withdraw_reject');
  76. $rejectNotice = new WithdrawRejectNotice($withdrawModel);
  77. $rejectNotice->sendMessage();
  78. return ;
  79. if (!$template_id) {
  80. return null;
  81. }
  82. $params = [
  83. ['name' => '时间', 'value' => date('Y-m-d H:i:s', $withdrawModel->audit_at)],
  84. ['name' => '金额', 'value' => $withdrawModel->amounts],
  85. ['name' => '手续费', 'value' => $withdrawModel->actual_poundage],
  86. ];
  87. static::notice($template_id,$params,$withdrawModel->member_id);
  88. }
  89. public static function notice($templateId,$params,$memberId)
  90. {
  91. if (!$templateId) {
  92. return;
  93. }
  94. $msg = MessageTemp::getSendMsg($templateId, $params);
  95. if (!$msg) {
  96. return;
  97. }
  98. $news_link = MessageTemp::find($templateId)->news_link;
  99. $news_link = $news_link ?:'';
  100. MessageService::notice(MessageTemp::$template_id, $msg, $memberId,'',$news_link);
  101. }
  102. }