初始版本
This commit is contained in:
75
server/app/common/service/CoachBalancePayService.php
Executable file
75
server/app/common/service/CoachBalancePayService.php
Executable file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | LikeShop100%开源免费商用电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | Gitee下载:https://gitee.com/likeshop_gitee/likeshop
|
||||
// | 访问官网:https://www.likemarket.net
|
||||
// | 访问社区:https://home.likemarket.net
|
||||
// | 访问手册:http://doc.likemarket.net
|
||||
// | 微信公众号:好象科技
|
||||
// | 好象科技开发团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// | Author: LikeShopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
|
||||
use app\common\enum\accountLog\AccountLogEnum;
|
||||
use app\common\enum\accountLog\CoachAccountLogEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\common\logic\CoachAccountLogLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\user\User;
|
||||
use http\Cookie;
|
||||
|
||||
|
||||
class CoachBalancePayService extends BasePayService
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 余额支付
|
||||
* @param $from
|
||||
* @param $order
|
||||
* @return array|false
|
||||
* @author ljj
|
||||
* @date 2022/12/26 5:28 下午
|
||||
*/
|
||||
public function pay($from, $order)
|
||||
{
|
||||
try {
|
||||
$coach = Coach::findOrEmpty($order['relation_id']);
|
||||
if ($coach->isEmpty() || $coach['money'] < $order['order_amount']) {
|
||||
throw new \Exception('余额不足');
|
||||
}
|
||||
//扣除余额
|
||||
Coach::update([
|
||||
'money' => ['dec', $order['order_amount']]
|
||||
], ['id' => $coach['id']]);
|
||||
//余额流水
|
||||
CoachAccountLogLogic::add(
|
||||
$coach->id,
|
||||
CoachAccountLogEnum::DEPOSIT,
|
||||
CoachAccountLogEnum::RECHARGE_INC_DEPOSIT,
|
||||
1,
|
||||
$order['order_amount'],
|
||||
$order['sn'],
|
||||
);
|
||||
|
||||
return [
|
||||
'pay_way' => PayEnum::BALANCE_PAY
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
$this->setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user