微信支付开发-程序开发

news2024/11/15 18:31:47

一、操作流程图

二、后端代码实现

        1、题库实现

                a、列表、所有、详情、保存、启禁用、导入答题

                b、获取奖品信息、保存奖品信息、

class Question extends Base
{
    // 列表
    public function getList(){
        $param = $this->request->param();
        $where = [];
        if(!empty($param['title']))$where[] = ['title','like','%'.$param['title'].'%'];
        if(!empty($param['id']))$where[] = ['id','=',$param['id']];
        if(!empty($param['status']))$where[] = ['status','=',$param['status'] == 1 ? 1 : 0];
        $resList = AQBModel::getList($where, 'id,title,option_number,status,create_time,update_time',[$param['currentPage'], $param['currentSize']]);
        $list  =  $resList['info'];
        $res['list'] = $list;
        $res['meat'] = $resList['page'];
        return success($res);
    }

    // 所有
    public function getAll(){
        $param = $this->request->param();
        $where = [];
        if(!empty($param['title']))$where[] = ['title','like','%'.$param['title'].'%'];
        $list = AQBModel::getAll($where, 'id,title','id DESC');
        return success($list);
    }

    // 详情
    public function getInfo(){
        $id = $this->request->param('id',0);
        if(empty($id)) return error('主键不能为空');
        $data = AQBModel::dataFind([['id','=',$id]],'id,title,status',true);
        if(!empty($data))$data['quest_opt'] = AQOModel::getAll(['bank_id' =>  $id],'content,is_correct','id DESC');
        return success($data);
    }

    // 保存
    public function saveInfo(){
        $param = $this->request->param();
        $validateBank = new \app\validate\anxun\admin\activity\QuestionBank;
        if (!$validateBank->check($param)) return error($validateBank->getError());//验证参数
        $validateOpt = new \app\validate\anxun\admin\activity\QuestionOpt;
        $dataOpt = [];
        foreach($param['quest_opt'] as $k => $v){
            $dataOpt[$k]['content'] = $v['content'];
            $dataOpt[$k]['is_correct'] = $v['is_correct'];
            if (!$validateOpt->check($dataOpt[$k])) return error($validateOpt->getError());//验证参数
            $dataOpt[$k]['opt'] = question_bank($k);
        }
        if(count($dataOpt) < 2) return error('题目选项最低两个选项');//验证参数
        $where = empty($param['id']) ? [] : ['id' => $param['id']];
        $data['title'] = $param['title'];
        $data['status'] = $param['status'];
        $data['update_time'] = date('Y-m-d H:i:s',time());
        $data['option_number'] = count($dataOpt);
        if(empty($param['id']))$data['create_time'] = date('Y-m-d H:i:s',time());
        $bankId = AQBModel::save($data,$where);
        if($param['id'] > 0)AQOModel::dataDetele(['bank_id' => $bankId]);
        foreach ($dataOpt as $ks => $vs){
            $dataOpt[$ks]['bank_id'] = $bankId;
        }
        AQOModel::dataAllSave($dataOpt);
        return success([],"操作成功");
    }

    // 启禁用
    public function saveStatus(){
        $param = $this->request->param();
        AQBModel::save(['status' => $param['status']],[['id','in',$param['id']]]);
        return success([],"操作成功");
    }

    //获取奖品信息
    public function getPrizeInfo(){
        $data = AQPModel::dataFind(['id' => 1],'prize_name,prize_price,postage_price,prize_picture,status',true);
        return success($data);
    }

    //保存产品信息
    public function savePrizeInfo(){
        $param = $this->request->param();
        $validateBank = new \app\validate\anxun\admin\activity\QuestionPrize;
        if (!$validateBank->check($param)) return error($validateBank->getError());//验证参数
        $data['prize_name'] = $param['prize_name'];
        $data['prize_price'] = $param['prize_price'];
        $data['postage_price'] = $param['postage_price'];
        $data['prize_picture'] = $param['prize_picture'];
        $data['status'] = $param['status'];
        $data['update_time'] = date('Y-m-d H:i:s',time());
        AQPModel::save($data,['id' => 1]);
        return success([],"操作成功");
    }

    //导入答题
    public function saveImportInfo(){
        $file = $this->request->file();
        $savename = Filesystem::disk('public')->putFile('topic',$file['file'],'md5');
        $reader = IOFactory::createReader('Xlsx');
        $reader->setReadDataOnly(true);
        $filePath = app()->getRootPath().'public/storage/'.$savename;
        $spreadsheet=$reader->load($filePath);//载入文件
        $worksheet=$spreadsheet->getActiveSheet();
        $highestRow=$worksheet->getHighestRow();//总行数
        for($row=2;$row<=$highestRow;$row++){
            $questionOpt[$row] = array_filter(explode('|', $worksheet->getCellByColumnAndRow(2, $row)->getValue()), 'remove_empty_values', ARRAY_FILTER_USE_BOTH);
            $questionOpt[$row] = remove_array_values($questionOpt[$row]);
            if(count($questionOpt[$row]) < 2)continue;
            $title[$row] = trim($worksheet->getCellByColumnAndRow(1, $row)->getValue());
            $bankId[$row] = AQBModel::dataFind([['title','=',$title[$row]]],'id',false);
            if(empty($bankId[$row])){
                //添加题目
                $data[$row]['title'] = $title[$row];
                $data[$row]['status'] = 1;
                $data[$row]['option_number'] = count($questionOpt[$row]);
                $data[$row]['create_time'] = date('Y-m-d H:i:s', time());
                $data[$row]['update_time'] = date('Y-m-d H:i:s', time());
                $bankId[$row] = AQBModel::save($data[$row]);
                $correct[$row] = array_filter(explode(',', $worksheet->getCellByColumnAndRow(3, $row)->getValue()), 'remove_empty_values', ARRAY_FILTER_USE_BOTH);
                //添加选项
                foreach($questionOpt[$row] as $k => $v) {
                    $da[$row.$k]['bank_id'] = $bankId[$row];
                    $da[$row.$k]['opt'] = question_bank($k);
                    $da[$row.$k]['content'] = trim($v);
                    foreach ($correct[$row] as $ko => $vo) {
                        $da[$row.$k]['is_correct'] = $da[$row.$k]['opt'] == trim($vo) ? 1 : 0;
                    }
                    AQOModel::save($da[$row.$k]);
                }
            }
        }
        @unlink($filePath);
        return success([],'导入成功');
    }
}

        2、机器人实现

                a、列表、详情、保存、删除

class DigitizedHuman extends Base
{
    //列表
    public function getList(){
        $param = $this->request->param();
        $where = [];
        if(!empty($param['digitized_human_name']))$where[] = ['digitized_human_name','like','%'.$param['digitized_human_name'].'%'];
        if(!empty($param['digitized_human_id']))$where[] = ['digitized_human_id','=',$param['digitized_human_id']];
        if(!empty($param['area_code'])){
            if(count($param['area_code']) >= 1){
                if(count($param['area_code']) == 1)$where[] = ['province_code','=',$param['area_code'][0]];
                if(count($param['area_code']) >= 2)$where[] = ['municipality_code','=',$param['area_code'][1]];
                if(count($param['area_code']) == 3)$where[] = ['district_code','=',$param['area_code'][2]];
            }
        }
        $resList = ASDHModel::getList($where, 'id,digitized_human_code,digitized_human_name,digitized_human_id,province_code,municipality_code,district_code,address,update_time',[$param['currentPage'], $param['currentSize']]);
        $list  =  $resList['info'];
        foreach ($list as $k => $v) {
            $areaTitle[$k] = PPModel::dataFind(['id' => $v['province_code']],'title',false);
            if(!empty($v['municipality_code']))$areaTitle[$k] = $areaTitle[$k].'-'.PPModel::dataFind(['id' => $v['municipality_code']],'title',false);
            if(!empty($v['district_code']))$areaTitle[$k] = $areaTitle[$k].'-'.PPModel::dataFind(['id' => $v['district_code']],'title',false);
            $list[$k]['area_title'] = $areaTitle[$k];
            unset($list[$k]['province_code']);
            unset($list[$k]['municipality_code']);
            unset($list[$k]['district_code']);
        }
        $res['list'] = $list;
        $res['meat'] = $resList['page'];
        return success($res);
    }

    //详情
    public function getInfo(){
        $id = $this->request->param('id');//接收参数
        if(empty($id)) return error('主键不能为空');
        $data = ASDHModel::dataFind(['id' => $id],'id,digitized_human_id,digitized_human_name,province_code,municipality_code,district_code,address',true);
        return success($data);
    }

    //保存
    public function saveInfo(){
        $param = $this->request->param();
        // 模板基础验证
        $validate = new \app\validate\anxun\admin\shuziren\DigitizedHuman;
        if (!$validate->check($param)) return error($validate->getError());//验证参数
        if(count($param['area_code']) == 0 || count($param['area_code']) >= 4) return error('省市区至少选择一项');//验证参数
        $time = date('Y-m-d H:i:s', time());
        $data['digitized_human_name'] = $param['digitized_human_name'];
        $data['digitized_human_id'] = $param['digitized_human_id'];
        $data['province_code'] = $param['area_code'][0];
        $data['municipality_code'] = count($param['area_code']) >= 2 ? $param['area_code'][1] : 0;
        $data['district_code'] = count($param['area_code']) == 3 ? $param['area_code'][2] : 0;
        $data['address'] = $param['address'];
        $data['update_time'] = $time;
        if($param['id'] == 0){
            $data['status'] = 1;
            $data['create_time'] = $time;
            $data['digitized_human_code'] = create_order();
        }
        $where = empty($param['id']) ? [] : ['id' => $param['id']];
        ASDHModel::save($data,$where);
        return success([], '操作成功');
    }

    //删除
    public function deleteInfo(){
        $id = $this->request->param('id');//接收参数
        if(empty($id)) return error('主键不能为空');
        ASDHModel::dataDetele(['id' => 1]);
        return success([], '操作成功');
    }
}

        3、订单实现(也就是发货记录)

                a、列表、详情、发货、修改发货信息、导出信息

class QuestionOrder extends Base
{
    //获取分页数据
    public function getList(){
        $param = $this->request->param();
        $where = [];
        if(!empty($param['express_company']))$where[] = ['express_company','like','%'.$param['express_company'].'%'];
        if(!empty($param['express_number']))$where[] = ['express_number','like','%'.$param['express_number'].'%'];
        if(!empty($param['receipt_status']))$where[] = ['receipt_status','=',$param['receipt_status']];
        $resList = ASQOModel::getList($where, 'id,order_no,consignee_name,consignee_phone,prize_name,receipt_status,express_company,status,express_number',[$param['currentPage'], $param['currentSize']]);
        $list  =  $resList['info'];
        $res['list'] = $list;
        $res['meat'] = $resList['page'];
        return success($res);
    }

    //获取详情
    public function getInfo(){
        $id = $this->request->param('id');//接收参数
        if(empty($id)) return error('主键不能为空');
        $data =  ASQOModel::dataFind(['id' => $id], 'id,order_no,consignee_name,consignee_phone,area,details_addr,receipt_status,express_company,express_number',true);
        return success($data);
    }

    //发货
    public function saveInfo(){
        $param = $this->request->param();
        // 模板基础验证
        $validate = new \app\validate\anxun\admin\shuziren\QuestionOrder;
        if (!$validate->check($param)) return error($validate->getError());//验证参数
        $data['prize_name'] = $param['prize_name'];
        $data['express_company'] = $param['express_company'];
        $data['express_number'] = $param['express_number'];
        $data['receipt_status'] = 3;
        ASQOModel::save($data,['id' => $param['id'],'receipt_status' => 2]);
        return success('操作成功');
    }

    //修改发货信息
    public function saveDeliverGoods(){
        $param = $this->request->param();
        // 模板基础验证
        $validate = new \app\validate\anxun\admin\shuziren\QuestionOrder;
        if (!$validate->check($param)) return error($validate->getError());//验证参数
        $data['prize_name'] = $param['prize_name'];
        $data['express_company'] = $param['express_company'];
        $data['express_number'] = $param['express_number'];
        ASQOModel::save($data,['id' => $param['id'],'receipt_status' => 3]);
        return success('操作成功');
    }

    //导出信息
    public function exportInfo(){
        $list = ASQOModel::getAll([],'receipt_status,order_no,consignee_name,consignee_phone,area,details_addr,express_company,express_number','id DESC');
        if(!$list) return error('暂无可导出');
        // 处理标题
        $title = ['发货状态', '订单号', '收货人','收货手机号','所在地区','详细地址','快递公司','快递单号'];
        $filename = '发货记录';
        $spreadsheet = new Spreadsheet();
        $spreadsheet->getDefaultStyle()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); //设置水平默认对齐方式
        $spreadsheet->getDefaultStyle()->getAlignment()->setVertical(Alignment::VERTICAL_CENTER); //设置垂直默认对齐方式
        $sheet = $spreadsheet->getActiveSheet();
        $everyDay = date('Y-m-d', time()). '_' .$this->user_id;
        foreach ($title as $key => $value) {
            $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
        }
        $row = 2;
        foreach ($list as $item) {
            $column = 1;
            foreach ($item as $k => $value) {
                $sheet->setCellValueByColumnAndRow($column, $row, $value);
                $column++;
            }
            $row++;
        }
        $savename = '/storage/'.$filename . '_' . $everyDay . '.xlsx';
        $object = date('Y-m-d',time()).'/' . $filename . '_' . $everyDay . '.xlsx';
        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
        $writer->save('.' . $savename);
        $UploadFactory = new UploadFactory();
        $uploadHandle = $UploadFactory->getUploadHandle();
        $res = $uploadHandle->uploadFile($object,'.' . $savename);
        $data['url'] = $res;
        $filePath = app()->getRuntimePath() . $savename;
        @unlink($filePath);
        return success($data,'上传成功');
    }
}

        4、题库参数配置

                a、获取配置、保存配置

class QuestionParam extends Base
{
    //获取配置
    public function getInfo(){
        $data = ASQPModel::dataFind(['id' => 1],'answer_number,answer_accuracy,answer_interval_period,postage_price');
        return success($data, '操作成功');
    }

    //保存配置
    public function saveInfo(){
        $param = $this->request->param();
        $validate = new \app\validate\anxun\admin\shuziren\QuestionParam;
        if(!$validate->check($param)) return error($validate->getError());
        ASQPModel::save([
            'answer_number' => $param['answer_number'],
            'answer_accuracy' => $param['answer_accuracy'],
            'answer_interval_period' => $param['answer_interval_period'],
            'postage_price' => $param['postage_price']
        ],[['id','=',1]]);
        return success([], '操作成功');
    }
}

        5、统计

                a、列表、详情、导出

class Statistics extends Base
{
    //列表
    public function getList(){
        $param = $this->request->param();
        if(empty($param['currentPage']))return error('狗日的,到底是第几页呀。不要瞎闹');
        if(empty($param['currentSize']))return error('狗日的,一页我给你拉取多少条合适呀。不要瞎闹');
        //初始化工厂
        $statisticsFactory = new StatisticsFactory($param['types']);
        //选择通道
        $statisticsHandle = $statisticsFactory->statisticsHandle();
        $res = $statisticsHandle->getList($param);
        return success($res);
    }

    //详情
    public function getInfo(){
        $param = $this->request->param();//接收参数
        if(empty($param['id'])) return error('主键不能为空');
        //初始化工厂
        $statisticsFactory = new StatisticsFactory($param['types']);
        //选择通道
        $statisticsHandle = $statisticsFactory->statisticsHandle();
        $res = $statisticsHandle->getInfo($param['id']);
        return success($res);
    }

    //导出
    public function exportInfo(){
        $param = $this->request->param();//接收参数
        //初始化工厂
        $statisticsFactory = new StatisticsFactory($param['types']);
        //选择通道
        $statisticsHandle = $statisticsFactory->statisticsHandle();
        $res = $statisticsHandle->exportInfo($param);
        return success($res,'导出成功');
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2138920.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

spdlog二次封装

这里写自定义目录标题 封装的原因封装的思想初始化接口的封装对日志输出接口进行宏的封装 封装的原因 1.避免单例的锁冲突&#xff0c;因此直接创建全局的线程安全的日志器进行使用 2.因为日志输出没有文件名行号&#xff0c;因此使用宏进行二次封装输出日志的文件名和行号 3.…

【JavaScript】LeetCode:707设计链表

文章目录 题目内容题目分析(1) 获取第n个节点的值(2) 头部插入节点(3) 尾部插入节点(4) 第n个节点前插入节点(5) 删除第n个节点 完整代码 题目内容 题目分析 添加哨兵节点dummy。在第n个节点前插入节点时&#xff0c;应该找到第n - 1个节点&#xff08;即前一个节点&#xff0…

国内人工智能产业发展现状及对策研究

一、引言 人工智能作为新时代科技革命和产业变革的核心力量&#xff0c;正深刻改变着全球经济格局。我国政府高度重视人工智能产业发展&#xff0c;将其列为国家战略性新兴产业。在此背景下&#xff0c;本文旨在分析我国人工智能产业发展现状&#xff0c;探讨面临的挑战&#x…

java基础面试题总结

java基础面试题总结 目录 前言 1. JVM vs JDK vs JRE的了解 2. 谈谈你对编程、编译、运行的理解 3. 什么是字节码?采用字节码的好处是什么? 5. java中的注解有几种&#xff0c;分别是什么&#xff1f; 6. 字符型常量和字符串常量 7.标识符和关键字的认识 8. 泛型&#xff…

初识Verilog HDL其二

文章目录 运算符往期回顾 运算符 往期回顾 初识Verilog HDL其一

储能运维管理云平台解决方案EMS能量管理系统

在储能行业蓬勃发展的今天&#xff0c;储能运维管理的重要性日益凸显。而储能运维管理云平台的出现&#xff0c;正为储能系统的稳定运行和高效管理注入了新的活力。 一、储能运维管理面临的挑战 传统的储能运维管理方式往往依赖人工巡检和现场操作&#xff0c;存在诸多问题。比…

虚幻引擎 | 实时语音转口型 Multilingual lipsync

实时语音转口型&#xff1a;EPIC的metahuman sdk&#xff0c;NVIDIA的audio2face&#xff0c;都好。本文使用metahuman sdk 需要工具&#xff1a;Metahuman SDK网页账号&#xff0c;获取两日免费tokens https://space.metahumansdk.io/#/unauthorized ———————————…

6,csdn 语法

1 &#xff0c;标题 &#xff1a; 1.1 &#xff0c;语法 &#xff1a; 1 &#xff0c;语法 &#xff1a;几级标题&#xff0c;就几个井号   例如&#xff1a;### 1.1&#xff0c;语法 2 &#xff0c;小技巧 &#xff1a; 2.1&#xff0c;一条横线 &#xff1a; 1 &#x…

Table列表复现框实现【勾选-搜索-再勾选】

Table列表复现框实现【勾选-搜索-再勾选】 概要整体架构流程代码实现技术细节注意参考文献 概要 最近在开发时遇到一个问题&#xff0c;在进行表单渲染时&#xff0c;正常选中没有问题&#xff0c;单如果需要搜索选中时&#xff0c;一个是已选中的不会回填&#xff0c;二是在搜…

【运营攻略】怎样进行游戏产品的定位

关于游戏商业化设计的一些思考 - 游戏干饭之家 游戏运营进阶&#xff1a;数据分析驱动游戏版本调优 - 游戏干饭之家 在深入挖掘某款游戏数据时&#xff0c;发现了一个有趣的现象&#xff1a;70%的玩家好友数量在1-5个之间&#xff0c;11%的玩家好友数在6-10个&#xff0c;而平…

Fiddler下载安装及汉化

直接上干货 1.下载地址&#xff1a; 通过百度网盘分享的文件&#xff1a;fiddler汉化&#xff0c;FiddlerSetup抓包.exe等2个文件 链接&#xff1a;https://pan.baidu.com/s/12JBZO8z0mDHlHM1DCL365g 提取码&#xff1a;1111 2.fiddler安装&#xff1a; 注意安装位置 3.汉化&…

基于协同过滤+python+django+vue+的音乐推荐系统

作者&#xff1a;计算机学姐 开发技术&#xff1a;SpringBoot、SSM、Vue、MySQL、JSP、ElementUI、Python、小程序等&#xff0c;“文末源码”。 专栏推荐&#xff1a;前后端分离项目源码、SpringBoot项目源码、SSM项目源码 系统展示 【2025最新】基于协同过滤pythondjangovue…

计算机毕业设计 在线新闻聚合平台的设计与实现 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试

&#x1f34a;作者&#xff1a;计算机编程-吉哥 &#x1f34a;简介&#xff1a;专业从事JavaWeb程序开发&#xff0c;微信小程序开发&#xff0c;定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事&#xff0c;生活就是快乐的。 &#x1f34a;心愿&#xff1a;点…

象过河手机进销存,外出办公更方便,随时了解经营情况

你还在为外出时无法即时查看库存、处理订单而烦恼吗&#xff1f;电脑端进销存虽强&#xff0c;但一离开办公桌就仿佛与店铺“失联”&#xff0c;那些紧急的调货请求、客户咨询&#xff0c;都让人手忙脚乱&#xff01; 这里强烈推荐你试试【象过河手机进销存】&#xff0c;它就像…

计算机网络入门基础

1. 基础概念 我们在聊网络的时候&#xff0c;就像是我们在日常生活中寄信一样。我们可以把网络想象成一个巨大的邮局系统&#xff0c;负责把信息从一个地方传送到另一个地方。 a. 什么是协议栈&#xff1f; 协议栈就像是寄信过程中的多个步骤。我们可以把它想象成寄信的时候…

Python3 SMTP发送邮件

SMTP&#xff08;Simple Mail Transfer Protocol&#xff09;即简单邮件传输协议,它是一组用于由源地址到目的地址传送邮件的规则&#xff0c;由它来控制信件的中转方式。 python的smtplib提供了一种很方便的途径发送电子邮件。它对smtp协议进行了简单的封装。 Python创建 SM…

Kotlin:1.9.0 的新特性

一、概述 Kotlin 1.9.0版本英语官方文档 Kotlin 1.9.0 中文官方文档 The Kotlin 1.9.0 release is out and the K2 compiler for the JVM is now in Beta. Additionally, here are some of the main highlights: Kotlin 1.9.0版本已经发布&#xff0c;用于JVM的K2编译器现在…

运用Java实现倒计时功能

这个功能其实是比较好实现的&#xff0c;一般来说java中实现倒计时有两种方法&#xff1a; 1、使用 scheduledexecutorservice创建一个可重复执行的任务&#xff0c;直到时间到&#xff1a; ScheduledExecutorService 是 Java 中一种用于安排延迟或定期任务的工具。我们可以使…

PMP--一模--解题--61-70

文章目录 14.敏捷61、 [单选] 作为估算活动持续时间过程的一部分&#xff0c;项目经理促成了与产品负责人和Scrum团队的冲刺计划会议。项目经理将用户故事分解为较小的任务项&#xff0c;以小时为单位估算所需时间&#xff0c;并根据团队的能力确定冲刺待办事项列表。尽管计划周…

6. Transforms的使用(一)--ToTensor()

Transforms的使用&#xff08;一&#xff09; 1.使用ToTensor类将数据转化为Tensor形式 导入需要使用的transforms类 from torchvision import transforms创建ToTensor类的实例 totensor transforms.ToTensor()将读取的图片ndarray数据转化为Tensor数据 img cv.imread(img_p…