IncomeWithdrawAward.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /****************************************************************
  3. * Author: king -- LiBaoJia
  4. * Date: 2020/5/25 2:19 PM
  5. * Email: livsyitian@163.com
  6. * QQ: 995265288
  7. * IDE: PhpStorm
  8. * User: 芸众商城 www.yunzshop.com
  9. ****************************************************************/
  10. namespace app\common\services\point;
  11. use app\common\events\withdraw\WithdrawPayedEvent;
  12. use app\common\facades\Setting;
  13. use app\common\models\Withdraw;
  14. use app\common\services\finance\PointService;
  15. class IncomeWithdrawAward
  16. {
  17. /**
  18. * @var Withdraw
  19. */
  20. private $withdrawModel;
  21. /**
  22. * 收入提现,奖励手续费等值积分
  23. *
  24. * @param WithdrawPayedEvent $event
  25. */
  26. public function award($event)
  27. {
  28. $this->withdrawModel = $event->getWithdrawModel();
  29. if ($this->awardStatus()) {
  30. $this->awardPoint();
  31. }
  32. }
  33. private function awardPoint()
  34. {
  35. $data = [
  36. 'point_income_type' => PointService::POINT_INCOME_GET,
  37. 'point_mode' => PointService::POINT_INCOME_WITHDRAW_AWARD,
  38. 'member_id' => $this->withdrawModel->member_id,
  39. 'point' => $this->withdrawModel->actual_poundage,
  40. 'remark' => "收入提现奖励消费积分[ID:{$this->withdrawModel->id}]",
  41. ];
  42. (new PointService($data))->changePoint();
  43. }
  44. /**
  45. * 收入提现,奖励比例积分
  46. *
  47. * @param WithdrawPayedEvent $event
  48. */
  49. public function awardScale($event)
  50. {
  51. $this->withdrawModel = $event->getWithdrawModel();
  52. if ($this->awardScaleStatus()) {
  53. $this->awardScalePoint();
  54. }
  55. }
  56. private function awardScalePoint()
  57. {
  58. $scale_point = Setting::get('point.set.income_withdraw_award_scale_point');
  59. \Log::info('积分设置比例',$scale_point);
  60. if($scale_point){
  61. $amounts = round((($scale_point * ($this->withdrawModel->actual_amounts+$this->withdrawModel->actual_poundage+$this->withdrawModel->actual_servicetax))/100),2).'%';
  62. $data = [
  63. 'point_income_type' => PointService::POINT_INCOME_GET,
  64. 'point_mode' => PointService::POINT_INCOME_WITHDRAW_AWARD_SCALE,
  65. 'member_id' => $this->withdrawModel->member_id,
  66. 'point' => $amounts,
  67. 'remark' => "收入提现奖励比例消费积分[ID:{$this->withdrawModel->id}]",
  68. ];
  69. (new PointService($data))->changePoint();
  70. }
  71. }
  72. private function awardStatus()
  73. {
  74. return !!Setting::get('point.set.income_withdraw_award');
  75. }
  76. private function awardScaleStatus()
  77. {
  78. return !!Setting::get('point.set.income_withdraw_award_scale');
  79. }
  80. }