初始版本

This commit is contained in:
贾祥聪
2025-08-19 14:16:51 +08:00
commit f937a1f9b9
4373 changed files with 359728 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
<?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\PayEnum;
use app\common\logic\AccountLogLogic;
use app\common\model\order\Order;
use app\common\model\order\OrderAppend;
use app\common\model\order\OrderGap;
use app\common\model\RechargeOrder;
use app\common\model\user\User;
class BalancePayService extends BasePayService
{
/**
* @notes 余额支付
* @param $from
* @param $order
* @return array|false
* @author ljj
* @date 2022/12/26 5:28 下午
*/
public function pay($from, $order)
{
try {
$user = User::findOrEmpty($order['user_id']);
if ($user->isEmpty() || $user['user_money'] < $order['order_amount']) {
throw new \Exception('余额不足');
}
//扣除余额
User::update([
'user_money' => ['dec', $order['order_amount']]
], ['id' => $order['user_id']]);
if($from){
switch ($from) {
case 'order':
$changeType = AccountLogEnum::ORDER_DEC_MONEY;
break;
case 'orderGap':
$changeType = AccountLogEnum::ORDER_GAP_DEC_MONEY;
break;
case 'orderAppend':
$changeType = AccountLogEnum::ORDER_APPEND_DEC_MONEY;
break;
}
}
//余额流水
AccountLogLogic::add($order['user_id'], AccountLogEnum::MONEY,$changeType,AccountLogEnum::DEC, $order['order_amount'], $order['sn']);
return [
'pay_way' => PayEnum::BALANCE_PAY
];
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
}
}