| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace common\components\payment;
- use common\enums\UserWalletEnum;
- use common\models\common\PaymentRefund;
- use common\models\common\PaymentTransfer;
- use common\traits\ErrorTrait;
- use services\common\UserWalletService;
- /**
- * 积分支付类
- * Class ScorePay
- * @Author: mz
- * @DateTime: 2022/12/09 9:21
- * @Copyright: copyright (c) 2022 广东七件事集团
- * @package common\components\payment
- */
- class ScorePay
- {
- use ErrorTrait;
- /**
- * 实例化类
- *
- * @param $type
- *
- */
- private function create($type)
- {
- }
- /**
- * 积分退款
- * @Author:hua
- * @Date:2024-03-08 09:17
- * @Copyright:copyright(c)2024 广东七件事集团
- * @param PaymentRefund $payment_refund
- * @param $order_no
- * @param $source_table
- * @param $source_table_id
- * @param string $desc
- * @param string $from_type
- * @param string $capital_type
- * @return bool
- */
- public function refund( PaymentRefund $payment_refund,$order_no,$source_table,$source_table_id,$desc='',$from_type='',$capital_type='')
- {
- try {
- $user_id = $payment_refund->user_id;
- $money = $payment_refund->amount;
- $mall_id = $payment_refund->mall_id;
- $insert_wallet [] = [
- 'mall_id' => $mall_id,
- 'user_id' => $user_id,
- 'is_frozen' => false,
- 'wallet_type' => UserWalletService::WALLET_TYPE_SCORE,
- 'money' => $money,
- 'desc' => $desc,
- 'source_table' => $source_table,
- 'source_table_id' => $source_table_id,
- 'from_type' => $from_type,
- 'capital_type' => $capital_type,
- 'order_no' => $order_no
- ];
- $res = UserWalletService::batchHandleByQueue($insert_wallet);
- if ($res == false) throw new \Exception(UserWalletService::getStaticError());
- $payment_refund->is_pay = 1;
- $res = $payment_refund->save();
- if ($res == false) throw new \Exception('生成余额退款记录失败');
- return true;
- } catch (\Exception $e) {
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
|