DoublePaymentRepair.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2018/8/15
  6. * Time: 下午3:53
  7. */
  8. namespace app\backend\modules\orderPay\fix;
  9. use app\common\exceptions\AppException;
  10. use app\common\models\OrderPay;
  11. use app\common\services\PayFactory;
  12. class DoublePaymentRepair
  13. {
  14. public $message=[];
  15. /**
  16. * @var OrderPay
  17. */
  18. private $orderPay;
  19. /**
  20. * DoublePaymentRepair constructor.
  21. * @param OrderPay $orderPay
  22. */
  23. public function __construct(OrderPay $orderPay)
  24. {
  25. $this->orderPay = $orderPay;
  26. }
  27. /**
  28. * @throws AppException
  29. */
  30. public function handle()
  31. {
  32. $result = $this->orderPay->fastRefund();
  33. if ($result['status']) {
  34. $this->message[]="{$this->orderPay->pay_type_name}[{$this->orderPay->pay_type_id}]退款成功";
  35. } else {
  36. $this->message[]="{$this->orderPay->pay_type_name}[{$this->orderPay->pay_type_id}]退款失败:{$result['msg']}";
  37. return false;
  38. }
  39. return $this->message;
  40. }
  41. /**
  42. * @throws AppException
  43. */
  44. public function check()
  45. {
  46. if ($this->orderPay != OrderPay::STATUS_PAID){
  47. throw new AppException($this->orderPay->status_name.'的支付单无法退款');
  48. }
  49. //todo 对应的订单已经支付
  50. //todo 对应的订单有其他有效的支付记录
  51. }
  52. }