ScorePay.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace common\components\payment;
  3. use common\enums\UserWalletEnum;
  4. use common\models\common\PaymentRefund;
  5. use common\models\common\PaymentTransfer;
  6. use common\traits\ErrorTrait;
  7. use services\common\UserWalletService;
  8. /**
  9. * 积分支付类
  10. * Class ScorePay
  11. * @Author: mz
  12. * @DateTime: 2022/12/09 9:21
  13. * @Copyright: copyright (c) 2022 广东七件事集团
  14. * @package common\components\payment
  15. */
  16. class ScorePay
  17. {
  18. use ErrorTrait;
  19. /**
  20. * 实例化类
  21. *
  22. * @param $type
  23. *
  24. */
  25. private function create($type)
  26. {
  27. }
  28. /**
  29. * 积分退款
  30. * @Author:hua
  31. * @Date:2024-03-08 09:17
  32. * @Copyright:copyright(c)2024 广东七件事集团
  33. * @param PaymentRefund $payment_refund
  34. * @param $order_no
  35. * @param $source_table
  36. * @param $source_table_id
  37. * @param string $desc
  38. * @param string $from_type
  39. * @param string $capital_type
  40. * @return bool
  41. */
  42. public function refund( PaymentRefund $payment_refund,$order_no,$source_table,$source_table_id,$desc='',$from_type='',$capital_type='')
  43. {
  44. try {
  45. $user_id = $payment_refund->user_id;
  46. $money = $payment_refund->amount;
  47. $mall_id = $payment_refund->mall_id;
  48. $insert_wallet [] = [
  49. 'mall_id' => $mall_id,
  50. 'user_id' => $user_id,
  51. 'is_frozen' => false,
  52. 'wallet_type' => UserWalletService::WALLET_TYPE_SCORE,
  53. 'money' => $money,
  54. 'desc' => $desc,
  55. 'source_table' => $source_table,
  56. 'source_table_id' => $source_table_id,
  57. 'from_type' => $from_type,
  58. 'capital_type' => $capital_type,
  59. 'order_no' => $order_no
  60. ];
  61. $res = UserWalletService::batchHandleByQueue($insert_wallet);
  62. if ($res == false) throw new \Exception(UserWalletService::getStaticError());
  63. $payment_refund->is_pay = 1;
  64. $res = $payment_refund->save();
  65. if ($res == false) throw new \Exception('生成余额退款记录失败');
  66. return true;
  67. } catch (\Exception $e) {
  68. self::setStaticError($e->getMessage());
  69. return false;
  70. }
  71. }
  72. }