🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] # 商品---订单模块 ## 商铺后台查看订单列表 > 如下图: ![](https://box.kancloud.cn/e87ae3fc1e8e9d9448ed8f1d6e949fea_1688x194.png) ![](https://box.kancloud.cn/db902f6d17629cee08547c7150723301_1684x445.png) ## 目录结构 ~~~ ├─admin │ └─themes │ └─simplebootx │ ├─Organ │ │ ├─Goods │ │ create.html 商品添加页面 │ │ edit.html 商品修改页面 │ │ index.html 商品查看页面 │ ├─order │ │ wait.html 订单页面 ├─application │ ├─Organ │ │ ├─Common │ │ ├─Conf │ │ ├─Controller │ │ OrderController.class.php 订单控制器 │ │ GoodsController.class.php 商铺控制器 │ │ └─Lang ~~~ ## 数据库结构 >服务 商品表 | 字段名 | 说明 | 类型 | | --- | --- | --- | | service_id | 服务id | int | | cate_id | 服务分类id | int | | province_id | 省id | int | | city_id | 市id | int | | district_id | 区id | int | | service_name | 服务名称 | varchar(255| | service_img |服务图片 | varchar(255 | | service_rule | 服务标准 | varchar(255 | | service_price |服务价格 | decimal(10 | | use_device | 使用设备 | varchar(255 | | detection_period | 检测周期 |varchar(255 | | keywords | 关键字 | varchar(255 | | technical_feature | 技术特点 |varchar(255 | | service_scope | 服务领域 | varchar(255 | | service_description | 服务简介 | varchar(255 | | sample_request | 样品要求 | varchar(255 | > 订单表 | 字段名 | 说明 | 类型 | | --- | --- | --- | |order_id | 订单id | int | | service_id | 检测服务的id | int | | user_id | 用户id | int | | total_price | 总价格 | int | | create_time | 创建时间 | int | | status | 1代表已经付款 2代表正在配送 3客户已经确认 | tinyint | | is_daofu | 是否是货到付款 | tinyint | | addr_id | 收货地址id | int | | number | 商品数量 | int | | order_reference | 订单编号 | varchar | | organ_id |机构id |int | > 联系人表 | 字段名 | 说明 | 类型 | | --- | --- | --- | |addr_id | 地址id | int | | user_id | 用户id | int | | province_id |省id | int | | city_id | 市id | int | | district_id | 区id | int | | name | 名字 | varchar | | mobile | 手机 | varchar | | addr | 详细地址 | varchar | | is_default | 是否默认地址 | tinyint | > 商品分类表 | 字段名 | 说明 | 类型 | | --- | --- | --- | |term_id| 分类id | bigint | | name | 分类名称 | varchar | | description |描述 | text | | parent |分类父id | bigint | | path | 分类层级关系路径 | bigint | | listorder | 排序 | int | | stastus | 状态 | int | > 商户 机构表 |字段名| 说明 | 类型 | | --- | --- | --- | |id| 机构id | int | |user_id| 用户id | int | |cate_id| 机构检测分类id | int | |region_id| 地区id | int | |city_id| 城市id | int | |area_id| 区域id | int | |organ_name| 机构名称 | varchar | |tel| 电话 | varchar | |addr| 地址 | varchar | |postcode| 邮编 | varchar | |realname| 真实姓名 | varchar | |logo| logo图片 | varchar | |idphoto| 证件照 | varchar | |qualification| 企业资格证书 | varchar | |create_time| 加入时间 | int | |description| 机构描述 | varchar | |audit| 审核 默认0 1代表审核 | tinyint | ## 订单控制器 > OrderController.class.php ~~~ <?php namespace Organ\Controller; use Common\Controller\AdminbaseController; class OrderController extends AdminbaseController{ public function wait(){ $order_model = M('order_organ'); $order_arr = $order_model->select(); foreach ($order_arr as &$value) { $statue_name[1] = "已经付款"; $statue_name[2] = "正在配送"; $staue_name[3] = "已经确认"; $value['status'] = $statue_name[$value['status']]; //服务商品ID $service_id = $value['service_id']; $service_model = M('detection_service'); //服务商品详细信息 $service_arr = $service_model->where("service_id=$service_id")->find(); $value['serviceInfo'] = $service_arr; //用户信息 $user_model = M('users'); $user_id = $value['user_id']; //$user_arr = $user_model->field('user_nicename')->where("id=$user_id")->find(); $user_arr = $user_model->where("id=$user_id")->find(); $value['userInfo'] = $user_arr; //收货地址 $addr_model = M('user_addr'); $addr_id = $value['addr_id']; // $addr_arr = $addr_model->field('addr')->where("addr_id=$addr_id")->find(); $addr_arr = $addr_model->where("addr_id=$addr_id")->find(); $value['addrInfo'] = $addr_arr; } $this->assign('order_arr',$order_arr); $this->display(); } } ~~~ ## 商品控制器 > GoodsController.class.php ~~~ <?php namespace Organ\Controller; use Common\Controller\AdminbaseController; header("content-type:text/html;charset=utf-8"); class GoodsController extends AdminbaseController{ //机构产品 public function index(){ $keyword = $_POST['keyword']; $shop_model = M('detection_service'); if ($keyword != "" || $keyword != null) { $where['service_name']= array('like','%'.$keyword.'%'); $where['keywords']= array('like','%'.$keyword.'%'); $shop_arr = $shop_model->where($where)->select(); }else{ $shop_arr = $shop_model->select(); } // echo $shop_model->getLastSql(); // dump($shop_arr);exit; $this->assign("shop_arr",$shop_arr); $this->display(); } //发布检测服务 public function create(){ // 获取一级分类 $classify_model = M('testingcate'); $classify_one = $classify_model->where('parent = 0')->select(); $this->assign("classify_one",$classify_one); $this->display(); } public function create_two(){ //二级分类父级id $classify_model = M('testingcate'); $term_id_T = $_GET['id']; $classify_two = $classify_model->where("parent = $term_id_T")->select(); $html = ""; if ($classify_two) { foreach ($classify_two as $h) { $html .= "<option value='{$h['term_id']}'>{$h['name']}</option>"; } } echo $html; } public function create_tree(){ //二级分类父级id $classify_model = M('testingcate'); $term_id_T = $_GET['id']; $classify_tree = $classify_model->where("parent = $term_id_T")->select(); $html = ""; if ($classify_tree) { foreach ($classify_tree as $h) { $html .= "<option value='{$h['term_id']}'>{$h['name']}</option>"; } } echo $html; } //添加商品 public function create_shop(){ $arr = I('post.'); $one_id = $arr['cateOne_id']; $two_id = $arr['cateTwo_id'] ; $tree_id = $arr['cateTree_id']; $data['cate_id'] = "$one_id-$two_id-$tree_id"; $data['service_name'] = $arr['service_name']; $data['service_img'] = $arr['service_img']; $data['service_price'] = $arr['service_price']; $data['use_device'] = $arr['use_device']; $data['detection_period'] = $arr['detection_period']; $data['keywords'] = $arr['keywords']; $data['service_scope'] = $arr['service_scope']; $data['service_rule'] = $arr['service_rule']; $data['technical_feature'] = $arr['technical_feature']; $data['sample_request'] = $arr['sample_request']; $data['service_description'] = $arr['service_description']; $data['datetime'] = date('Y-m-d H:i:s', time()); $shop_model = M('detection_service'); $lastInsId = $shop_model->add($data); if ($lastInsId) { $this->success('新增成功', U('Goods/index')); }else{ $this->error('数据写入错误!'); } } //修改商品 public function edit(){ $service_id = $_GET['goods_id']; $shop_model = M('detection_service'); $shop_arr = $shop_model->where("service_id=$service_id")->find(); $cate = $shop_arr['cate_id']; $cate_arr = explode('-',$cate); $model = M('testingcate'); $one =$model->where("term_id=$cate_arr[0]")->find(); $one_name = $one['name']; $two =$model->where("term_id=$cate_arr[1]")->find(); $two_name = $two['name']; $tree =$model->where("term_id=$cate_arr[2]")->find(); $tree_name = $tree['name']; $shop_arr['one_id'] = $cate_arr[0]; $shop_arr['two_id'] = $cate_arr[1]; $shop_arr['tree_id'] = $cate_arr[2]; $shop_arr['one_name'] = $one_name; $shop_arr['two_name'] = $two_name; $shop_arr['tree_name'] = $tree_name; $classify_model = M('testingcate'); $classify_one = $classify_model->where('parent = 0')->select(); $this->assign("classify_one",$classify_one); $this->assign("shop_arr",$shop_arr); $this->display(); } public function edit_shop(){ $service_id = I('get.goods_id'); $arr = I('post.'); $one_id = $arr['cateOne_id']; $two_id = $arr['cateTwo_id'] ; $tree_id = $arr['cateTree_id']; $data['cate_id'] = "$one_id-$two_id-$tree_id"; $data['service_name'] = $arr['service_name']; $data['service_img'] = $arr['service_img']; $data['service_price'] = $arr['service_price']; $data['use_device'] = $arr['use_device']; $data['detection_period'] = $arr['detection_period']; $data['keywords'] = $arr['keywords']; $data['service_scope'] = $arr['service_scope']; $data['service_rule'] = $arr['service_rule']; $data['technical_feature'] = $arr['technical_feature']; $data['sample_request'] = $arr['sample_request']; $data['service_description'] = $arr['service_description']; $data['datetime'] = date('Y-m-d H:i:s', time()); $shop_model = M('detection_service'); $result = $shop_model->data($data)->where("service_id=$service_id")->save(); if ( false !== $result ){ $this->success('更新成功', U('Goods/index')); }else{ $this->error('更新失败!'); } } } ~~~