独角数卡v2.0.6魔改教程(+模版下载)

如果后台数值填 0.85,表示85折优惠,支付总价的 85%

修改文件/app/Service/CouponService.php,替换下面的代码(大概29行位置)

public function withHasGoods(string $coupon, int $goodsID)
{
    // 彻底删除 whereHas 块
    return Coupon::query()
        ->where('is_open', Coupon::STATUS_OPEN)
        ->where('coupon', $coupon)
        ->first();
}

修改文件/app/Service/OrderService.php,替换下面的代码(大概154行位置)

public function validatorCoupon(Request $request):? Coupon
{
    if ($request->filled('coupon_code')) {
        // 修改点:直接从数据库查询优惠码文本,不带商品 ID 过滤
        $coupon = Coupon::query()
            ->where('coupon', $request->input('coupon_code'))
            ->where('is_open', BaseModel::STATUS_OPEN)
            ->first();

        if (empty($coupon)) {
            throw new RuleValidationException(__('dujiaoka.prompt.coupon_does_not_exist'));
        }
        if ($coupon->ret <= 0) {
            throw new RuleValidationException(__('dujiaoka.prompt.coupon_lack_of_available_opportunities'));
        }
        return $coupon;
    }
    return null;
}

修改文件/app/Service/OrderProcessService.php,替换下面的代码(大概229行位置)

    private function calculateTheCouponPrice(): float
    {
        $couponPrice = 0;
        if ($this->coupon) {
            $totalPrice = $this->calculateTheTotalPrice();
            
            $payableAmount = bcmul($totalPrice, $this->coupon->discount, 2);

            $couponPrice = bcsub($totalPrice, $payableAmount, 2);
        }
        return (float)$couponPrice;
    }

修改文件 /app/Service/OrderService.php

将197行所代码:
$otherIpt .= $item['desc'].':'.$request->input($item['field']) . PHP_EOL;
替换下面代码:

$otherIpt .= $item['desc'].':'
    .'<span class="charge-value">'.$request->input($item['field']).'</span>'
    . PHP_EOL;

然后在CSS文件中给它增加一下美化

修改文件/app/Helpers/functions.php,让主页图片支持第三方链接,替换下面的代码(大概229行位置)

if (!function_exists('picture_ulr')) {

    function picture_ulr($file, $getHost = false)
    {
        // ⭐ 1. 核心修复:检查是否已经是完整的 URL ⭐
        if (strpos($file, 'http://') === 0 || strpos($file, 'https://') === 0) {
            return $file;
        }
        
        // 2. 原有逻辑:如果只需要主机名
        if ($getHost) {
            return Storage::disk('admin')->url('');
        }
        
        // 3. 原有逻辑:如果是相对路径或空值
        return $file 
            ? Storage::disk('admin')->url($file) 
            : url('assets/common/images/default.jpg');
    }
}

修改文件/app/Admin/Controllers/GoodsController.php,后台商品增加一个输入第三方链接的选项,替换下面的代码(大概135行位置)

    protected function form()
    {
        return Form::make(new Goods(), function (Form $form) {
            $form->display('id');
            $form->text('gd_name')->required();
            $form->text('gd_description')->required();
            $form->text('gd_keywords')->required();
            $form->select('group_id')->options(
                GoodsGroupModel::query()->pluck('gp_name', 'id')
            )->required();
            
            // 1. 原始图片上传字段(绑定到 picture 字段)
            $form->image('picture')->autoUpload()->uniqueName();
            
            // 2. 新增一个文本输入框,用于输入图片 URL (临时字段)
            $form->text('picture_url_input', '商品图片URL')
                 ->help('如果同时操作,系统将优先保存输入的图片URL');

            $form->radio('type')->options(GoodsModel::getGoodsTypeMap())->default(GoodsModel::AUTOMATIC_DELIVERY)->required();
            $form->currency('retail_price')->default(0)->help(admin_trans('goods.helps.retail_price'));
            $form->currency('actual_price')->default(0)->required();
            $form->number('in_stock')->help(admin_trans('goods.helps.in_stock'));
            $form->number('sales_volume');
            $form->number('buy_limit_num')->help(admin_trans('goods.helps.buy_limit_num'));
            $form->editor('buy_prompt');
            $form->editor('description');
            $form->textarea('other_ipu_cnf')->help(admin_trans('goods.helps.other_ipu_cnf'));
            $form->textarea('wholesale_price_cnf')->help(admin_trans('goods.helps.wholesale_price_cnf'));
            $form->textarea('api_hook');
            $form->number('ord')->default(1)->help(admin_trans('dujiaoka.ord'));
            $form->switch('is_open')->default(GoodsModel::STATUS_OPEN);
            $form->saving(function (Form $form) {
                
                // 获取手动输入的链接
                $inputUrl = trim($form->picture_url_input);
                
                // 如果用户手动输入了链接 (高优先级)
                if (!empty($inputUrl)) {
                    // 检查是否为完整 URL
                    if (strpos($inputUrl, 'http://') === 0 || strpos($inputUrl, 'https://') === 0) {
                        $form->picture = $inputUrl; 

                    } else {
                        // 提示用户错误,并停止保存操作
                        return $form->error('手动输入链接必须是完整的URL(以 http:// 或 https://:// 开头),请重新输入!');
                    }
                } 
                // 清理临时字段
                $form->deleteInput('picture_url_input');
            });
        });
    }
}

删除或注释掉原来的提交订单按钮代码

<!--
<div class="mt-4 text-center">
    {{-- 提交订单 --}}
    <button style="margin: -20px 0 0px 0" type="submit" class="btn buy-btn" id="submit">
        {{ __('hyper.buy_order_now') }}
    </button>
</div>
-->

在底部 <script> 标签上再添加以下JS代码​:

<script>
$('.pay-type').click(function () {
    var email = $("input[name='email']").val().trim();
    var byAmount = parseInt($("input[name='by_amount']").val(), 10);
    var inStock = {{ $in_stock }}; // 服务器渲染的库存数字

    if (email === '') {
        $.NotificationApp.send("{{ __('hyper.buy_warning') }}", "{{ __('hyper.buy_empty_mailbox') }}", "top-center", "rgba(0,0,0,0.2)", "info");
        return;
    }
    if (byAmount <= 0) {
        $.NotificationApp.send("{{ __('hyper.buy_warning') }}", "{{ __('hyper.buy_zero_quantity') }}", "top-center", "rgba(0,0,0,0.2)", "info");
        return;
    }
    if (byAmount > inStock) {
        $.NotificationApp.send("{{ __('hyper.buy_warning') }}", "{{ __('hyper.buy_exceeds_stock') }}", "top-center", "rgba(0,0,0,0.2)", "info");
        return;
    }

    // 校验通过,继续设置 payway 并提交表单
    var payId = $(this).data('id');
    $('input[name="payway"]').val(payId);

    $('.pay-type').removeClass('active');
    $(this).addClass('active');

    $('#buy-form').submit();
});
</script>

修改文件 /app/Jobs/WorkWeiXinPush.php 替换以下全部代码:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use GuzzleHttp\Client;

class WorkWeiXinPush implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * 任务最大尝试次数
     */
    public $tries = 1;

    /**
     * 任务运行的超时时间
     */
    public $timeout = 10;

    /**
     * Execute the job.
     */
    public function handle()
    {
        try {
            $client = new Client();
            $url = dujiaoka_config_get('qywxbot_key'); // 完整 URL
            $client->get($url, [
                'timeout' => 5,
                'verify' => false,
            ]);
        } catch (\Exception $e) {
            \Log::error("访问 URL 失败:" . $e->getMessage());
        }
    }
}

功能说明:

将后台原来的企业微信推送订单详情,修改成访问Webhooks链接功能,然后每次订单完成都会访问这个Webhooks链接,触发更多自己想要的高级功能。

例如:当订单完成,会监控某个网站数据变化,修改参数,充值额度,增加设备,滚动公告等。

图片[11]-独角数卡v2.0.6魔改教程(+模版下载)-坤哥资源

在网站目录 resources/views 下创建新的文件夹/errors/
在里面新建一个空白文件,粘贴以下代码,保存为:500.blade.php
完整路径为:resources/views/errors/500.blade.php

@extends('hyper.layouts.default')

@section('content')
<div class="row justify-content-center" style="padding:50px 0;">
    <div class="col-lg-6 text-center">
        <div class="code" style="font-size:72px; font-weight:bold; color:#dc3545;">500</div>
        <div class="message" style="font-size:24px; margin:20px 0;">
            服务器内部错误
        </div>
        <p>抱歉,服务器出现异常。你可以返回主页或稍后再试。</p>
        <a href="{{ url('/') }}" class="btn btn-primary mt-3">
            <i class="mdi mdi-home"></i> 返回首页
        </a>
        <button onclick="location.reload()" class="btn btn-secondary mt-3">
            <i class="mdi mdi-refresh"></i> 稍后重试
        </button>
    </div>
</div>
@stop
图片[12]-独角数卡v2.0.6魔改教程(+模版下载)-坤哥资源

修改2个显示订单详情的文件

/resources/views/hyper/static_pages/searchOrder.blade.php
/resources/views/hyper/static_pages/orderinfo.blade.php

找到需要替换的内容

            <div class="orderinfo-kami">
                <h5 class="card-title">
                    {{ __('hyper.orderinfo_carmi') }}
                </h5>
                <textarea class="form-control textarea-kami" rows="5">{{$order['info']}}</textarea>
                <button class="btn btn-outline-primary kami-btn" data-clipboard-text="{{$order['info']}}">
                    {{ __('hyper.orderinfo_copy_carmi') }}
                </button>
            </div>

替换以下代码

<div class="orderinfo-kami">
    @if($order['status'] == \App\Models\Order::STATUS_COMPLETED)
        <h5 class="card-title">⬇️ {{ __('hyper.orderinfo_carmi') }}(请保存好)</h5>
        <div class="form-control textarea-kami">{!! nl2br($info) !!}</div>

    @elseif($order['status'] == \App\Models\Order::STATUS_PENDING)
        <h5 class="card-title">卡密内容</h5>
        <div class="form-control textarea-kami">此订单需人工处理发货,等待6分钟左右刷新网页或重新查询</div>

    @else
        <h5 class="card-title">卡密内容</h5>
        <div class="form-control textarea-kami">网络超时请切换网络重新下单</div>
    @endif
        <button class="btn btn-outline-primary kami-btn" data-clipboard-text="{{ $order['info'] }}">
            {{ __('hyper.orderinfo_copy_carmi') }}
        </button>
</div>

修改文件 /config/admin.php
第25行,是修改后台-左上角的图标和标题
第91行,是修改后台-网页标题

修改文件 /resources/views/admin/dashboard/title.blade.php
里面的html代码就是修改后台仪表盘的图标、文字、链接

直接下载已修改好的模板文件

将文件上传至网站根目录“/www/wwwroot/你的域名/”,并解压文件

登录后台设置,切换模版,重启PHP和守护进程,OK

查看网站实际效果:https://pingguo.id/

独角数卡v2.0.6魔改教程(+模版下载)-坤哥资源
独角数卡v2.0.6魔改教程(+模版下载)
此内容为付费阅读,请付费后查看
158
立即购买
您当前未登录!建议登陆后购买,可保存购买订单
付费阅读

签名证书     苹果ID商店     本站TG频道

  温馨提示:本文最后更新于2025年12月26日20时35分,某些文章资源具有时效性,若内容或链接失效,请在下方评论区留言反馈。
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容