85 lines
3.3 KiB
PHP
85 lines
3.3 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | 开源版本可自由商用,可去除界面版权logo
|
||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||
// | 访问官网:https://www.likeadmin.cn
|
||
// | likeadmin团队 版权所有 拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeadminTeam
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\common\logic;
|
||
|
||
|
||
use app\common\enum\PayEnum;
|
||
use app\common\enum\PayOrderEnum;
|
||
use app\common\enum\YesNoEnum;
|
||
use app\common\model\pay\PayOrder;
|
||
use app\common\model\pay\PayWay;
|
||
use app\common\model\pay\RefundOrder;
|
||
use app\common\model\recharge\RechargeOrder;
|
||
use app\common\model\SubMerchant;
|
||
use app\common\model\user\User;
|
||
use app\common\service\pay\WeChatPayService;
|
||
|
||
|
||
/**
|
||
* 支付逻辑
|
||
* Class PaymentLogic
|
||
* @package app\common\logic
|
||
*/
|
||
class WechatPayServiceMerchantPaymentLogic extends BaseLogic
|
||
{
|
||
|
||
// 创建微信支付订单
|
||
public static function createPayOrder($params)
|
||
{
|
||
// 收款账户
|
||
$subMerchant = SubMerchant::where(['street' => $params['street']])->find();
|
||
if (empty($subMerchant)){
|
||
$subMerchant = SubMerchant::where(['sub_merchant_name' => '泸州市海之农科技有限公司'])->find();
|
||
}
|
||
$data = [
|
||
'order_from' => $params['order_from'],
|
||
'order_type' => $params['order_type'],
|
||
'collection_account' => $subMerchant['sub_mch_id'], // 子商户号
|
||
'pay_user_role' => $params['pay_user_role'],
|
||
'pay_user_info' => json_encode($params['pay_user_info']),
|
||
'order_no' => 'order'.generate_sn(PayOrder::class, 'order_no'),
|
||
'business_order_no' => $params['business_order_no'],
|
||
'total_fee' => $params['total_fee'], // int 单位:分
|
||
'pay_type' => PayOrderEnum::PAY_TYPE,
|
||
'pay_status' => PayOrderEnum::PAY_STATUS_UNPAID,
|
||
'business_callback_url' => $params['business_callback_url'],
|
||
'create_time' => time(),
|
||
'update_time' => time(),
|
||
];
|
||
return PayOrder::create($data);
|
||
}
|
||
|
||
// 创建微信退款订单
|
||
public static function createRefundOrder($params)
|
||
{
|
||
$payOrder = PayOrder::where(['business_order_no' => $params['business_order_no'], 'pay_status'=>PayOrderEnum::PAY_STATUS_ISPAID])->find();
|
||
|
||
$data = [
|
||
'refund_sn' => 'refund'.generate_sn(RefundOrder::class, 'refund_sn'),
|
||
'order_sn' => $payOrder['order_no'],
|
||
'business_order_sn' => $payOrder['business_order_no'],
|
||
'order_from' => $payOrder['order_from'],
|
||
'order_amount' => $payOrder['total_fee'],
|
||
'refund_amount' => $payOrder['total_fee'],
|
||
'refund_type' => 1,
|
||
'refund_status' => 0,
|
||
'business_callback_url' => $params['business_callback_url'],
|
||
'create_time' => time(),
|
||
'update_time' => time(),
|
||
];
|
||
return RefundOrder::create($data);
|
||
}
|
||
|
||
} |