hrjy 2 éve
szülő
commit
741ea1689c

+ 184 - 0
app/admin/controller/water/WaterCate.php

@@ -0,0 +1,184 @@
+<?php
+/**
+ *
+ * @author: xaboy<365615158@qq.com>
+ * @day: 2017/11/11
+ */
+
+namespace app\admin\controller\water;
+
+use app\admin\controller\AuthController;
+use crmeb\services\{ExpressService,
+    JsonService,
+    JsonService as Json,
+    MiniProgramService,
+    WechatService,
+    FormBuilder as Form,
+    CacheService,
+    UtilService as Util};
+use think\facade\Route as Url;
+use think\facade\Validate;
+Use app\admin\model\water\WaterCate as model;
+
+/**
+ * 订单管理控制器 同一个订单表放在一个控制器
+ * Class StoreOrder
+ * @package app\admin\controller\store
+ */
+class WaterCate extends AuthController
+{
+    /**
+     * @return mixed
+     */
+    public function index()
+    {
+        return $this->fetch();
+    }
+
+
+    public function list()
+    {
+        $where = Util::getMore([
+            ['page', 1],
+            ['limit', 20],
+            ['name', ''],
+            ['role', '']
+        ]);
+
+        return Json::successlayui(model::list($where));
+    }
+
+    /**
+     * 显示创建资源表单页.
+     *
+     * @return \think\Response
+     */
+    public function create($id = 0)
+    {
+        $f = [];
+        $f[] = Form::input('name', '分类名称');
+        $f[] = Form::select('type', '选择分类', '')->options([
+            ['value' => 0, 'label' => '请选择分类'],
+            ['value' => 1, 'label' => '顶板'],
+            ['value' => 2, 'label' => '侧板'],
+            ['value' => 3, 'label' => '拉筋'],
+            ['value' => 4, 'label' => '底板'],
+            ['value' => 5, 'label' => '立柱'],
+            ['value' => 6, 'label' => '辅拉'],
+            ['value' => 7, 'label' => '保温'],
+            ['value' => 8, 'label' => '槽钢'],
+            ['value' => 9, 'label' => '扶梯管'],
+        ])->filterable(true);
+        $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
+        $this->assign(compact('form'));
+        return $this->fetch('public/form-builder');
+
+
+    }
+
+    public function save()
+    {
+        $model = new model;
+        $data = Util::postMore([
+            'name',
+            'type',
+        ]);
+        $validate = Validate::rule([
+            'name' => 'require',
+            'type' => 'require',
+        ]);
+        $validate->message([
+            'name.require' => '名称不能为空',
+            'type.require' => '分类不能为空',
+        ]);
+        if (!$validate->check($data)) {
+            return Json::fail($validate->getError());
+        }
+        $res = $model->save($data);
+        if ($res) return Json::successful('添加成功');
+        return Json::fail('添加失败');
+    }
+
+
+    /**
+     * 显示创建资源表单页.
+     *
+     * @return \think\Response
+     */
+    public function edit($id = 0)
+    {
+        $data = model::find($id);
+        $f = [];
+        $f[] = Form::input('name', '分类名称', $data['name']);
+        $f[] = Form::select('type', '选择分类',  (string)$data['type'])->options([
+            ['value' => 0, 'label' => '请选择分类'],
+            ['value' => 1, 'label' => '顶板'],
+            ['value' => 2, 'label' => '侧板'],
+            ['value' => 3, 'label' => '拉筋'],
+            ['value' => 4, 'label' => '底板'],
+            ['value' => 5, 'label' => '立柱'],
+            ['value' => 6, 'label' => '辅拉'],
+            ['value' => 7, 'label' => '保温'],
+            ['value' => 8, 'label' => '槽钢'],
+            ['value' => 9, 'label' => '扶梯管'],
+        ])->filterable(true);
+        $f[] = Form::hidden('id', $id);
+        $form = Form::make_post_form('修改', $f, Url::buildUrl('update'));
+        $this->assign(compact('form'));
+        return $this->fetch('public/form-builder');
+    }
+
+
+    /**
+     * 修改
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function update()
+    {
+        $model = new model;
+        $data = Util::postMore([
+            'name',
+            'type',
+            'id'
+        ]);
+        $validate = Validate::rule([
+            'title' => 'require',
+            'price' => 'require',
+        ]);
+        $validate->message([
+            'name.require' => '名称不能为空',
+            'type.require' => '分类不能为空',
+        ]);
+        $details = $model->find($data['id']);
+        $details['name'] = $data['name'];
+        $details['type'] = $data['type'];
+        $res = $details->save();
+        if ($res) return Json::successful('修改成功');
+        return Json::fail('修改失败');
+    }
+
+
+    /**
+     * 删除
+     * @param $id
+     * @return void
+     * @throws \Exception
+     */
+    public function delete($id)
+    {
+        if (!$id) Json::fail('删除失败');
+        $model = new model;
+
+        $res = model::destroy($id);
+        if ($res){
+            return Json::success('删除成功!');
+        }else{
+            return Json::fail($model->getErrorInfo());
+        }
+
+    }
+
+}

+ 36 - 4
app/admin/controller/water/WaterMaterialScience.php

@@ -117,8 +117,12 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::input('name', '名称')->col(12);
         $f[] = Form::hidden('type', $type);
         $f[] = Form::select('th_id', '选择厚度', '')->options(
-            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterThickness::order('id DESC')->field('id as value,name as label')->select()->toArray())
+            array_merge([['value' => 0, 'label' => '请选择厚度']], \app\admin\model\water\WaterThickness::order('id DESC')->field('id as value,name as label')->select()->toArray())
+        )->filterable(true);
+        $f[] = Form::select('cate_id', '选择分类', '')->options(
+            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterCate::order('id DESC')->where('type', $type)->field('id as value,name as label')->select()->toArray())
         )->filterable(true);
+
         $f[] = Form::input('weight', '重量(kg)');
         $f[] = Form::input('unit_price', '单价');
         $f[] = Form::input('company', '单位');
@@ -154,7 +158,10 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::input('name', '名称')->col(12);
         $f[] = Form::hidden('type', $type);
         $f[] = Form::select('th_id', '选择厚度', '')->options(
-            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterThickness::order('id DESC')->field('id as value,name as label')->select()->toArray())
+            array_merge([['value' => 0, 'label' => '请选择厚度']], \app\admin\model\water\WaterThickness::order('id DESC')->field('id as value,name as label')->select()->toArray())
+        )->filterable(true);
+        $f[] = Form::select('cate_id', '选择分类', '')->options(
+            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterCate::order('id DESC')->where('type', $type)->field('id as value,name as label')->select()->toArray())
         )->filterable(true);
         $f[] = Form::input('weight', '重量(kg)');
         $f[] = Form::input('unit_price', '单价');
@@ -182,6 +189,9 @@ class WaterMaterialScience extends AuthController
         $f = [];
         $f[] = Form::input('name', '名称')->col(12);
         $f[] = Form::hidden('type', $type);
+        $f[] = Form::select('cate_id', '选择分类', '')->options(
+            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterCate::order('id DESC')->where('type', $type)->field('id as value,name as label')->select()->toArray())
+        )->filterable(true);
         $f[] = Form::input('weight', '重量(kg)');
         $f[] = Form::input('unit_price', '单价');
         $f[] = Form::input('company', '单位');
@@ -211,6 +221,9 @@ class WaterMaterialScience extends AuthController
         $f = [];
         $f[] = Form::input('name', '名称')->col(12);
         $f[] = Form::hidden('type', $type);
+        $f[] = Form::select('cate_id', '选择分类', '')->options(
+            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterCate::order('id DESC')->where('type', $type)->field('id as value,name as label')->select()->toArray())
+        )->filterable(true);
         $f[] = Form::input('weight', '重量(kg)');
         $f[] = Form::input('unit_price', '单价');
         $f[] = Form::input('company', '单位');
@@ -232,7 +245,8 @@ class WaterMaterialScience extends AuthController
             'company',
             'long',
             'wide',
-            'is_gc'
+            'is_gc',
+            'cate_id',
         ]);
         $validate = Validate::rule('name', 'require')->rule([
             'name' => 'require',
@@ -240,6 +254,7 @@ class WaterMaterialScience extends AuthController
             'weight' => 'require',
             'unit_price' => 'require',
             'company' => 'require',
+            'cate_id' => 'require',
         ]);
         $validate->message([
             'name.require' => '名称不能为空',
@@ -247,6 +262,7 @@ class WaterMaterialScience extends AuthController
             'weight.require' => '请填写重量',
             'unit_price.require' => '请填写单价',
             'company.require' => '请填写单位',
+            'cate_id.require' => '请选择分类',
         ]);
         if (!$validate->check($data)) {
             return Json::fail($validate->getError());
@@ -270,6 +286,9 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::select('th_id', '选择厚度', (string)$data['th_id'])->options(
             array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterThickness::order('id DESC')->field('id as value,name as label')->select()->toArray())
         )->filterable(true);
+        $f[] = Form::select('cate_id', '选择分类', (string)$data['cate_id'])->options(
+            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterCate::order('id DESC')->where('type', $data['type'])->field('id as value,name as label')->select()->toArray())
+        )->filterable(true);
         $f[] = Form::input('weight', '重量(kg)', $data['weight']);
         $f[] = Form::input('unit_price', '单价', $data['unit_price']);
         $f[] = Form::input('company', '单位', $data['company']);
@@ -295,6 +314,9 @@ class WaterMaterialScience extends AuthController
         $f[] = Form::select('th_id', '选择厚度', (string)$data['th_id'])->options(
             array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterThickness::order('id DESC')->field('id as value,name as label')->select()->toArray())
         )->filterable(true);
+        $f[] = Form::select('cate_id', '选择分类', (string)$data['cate_id'])->options(
+            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterCate::order('id DESC')->where('type', $data['type'])->field('id as value,name as label')->select()->toArray())
+        )->filterable(true);
         $f[] = Form::input('weight', '重量(kg)', $data['weight']);
         $f[] = Form::input('unit_price', '单价', $data['unit_price']);
         $f[] = Form::input('company', '单位', $data['company']);
@@ -315,6 +337,9 @@ class WaterMaterialScience extends AuthController
         $data = model::find($id);
         $f = [];
         $f[] = Form::input('name', '名称', $data['name'])->col(12);
+        $f[] = Form::select('cate_id', '选择分类', (string)$data['cate_id'])->options(
+            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterCate::order('id DESC')->where('type', $data['type'])->field('id as value,name as label')->select()->toArray())
+        )->filterable(true);
         $f[] = Form::input('weight', '重量(kg)', $data['weight']);
         $f[] = Form::input('unit_price', '单价', $data['unit_price']);
         $f[] = Form::input('company', '单位', $data['company']);
@@ -338,6 +363,9 @@ class WaterMaterialScience extends AuthController
         $data = model::find($id);
         $f = [];
         $f[] = Form::input('name', '名称', $data['name'])->col(12);
+        $f[] = Form::select('cate_id', '选择分类', (string)$data['cate_id'])->options(
+            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterCate::order('id DESC')->where('type', $data['type'])->field('id as value,name as label')->select()->toArray())
+        )->filterable(true);
         $f[] = Form::input('weight', '重量(kg)', $data['weight']);
         $f[] = Form::input('unit_price', '单价', $data['unit_price']);
         $f[] = Form::input('company', '单位', $data['company']);
@@ -367,13 +395,15 @@ class WaterMaterialScience extends AuthController
             'long',
             'wide',
             'id',
-            'is_gc'
+            'is_gc',
+            'cate_id'
         ]);
         $validate = Validate::rule('name', 'require')->rule([
             'name' => 'require',
             'weight' => 'require',
             'unit_price' => 'require',
             'company' => 'require',
+            'cate_id' => 'require',
         ]);
         $validate->message([
             'name.require' => '名称不能为空',
@@ -381,6 +411,7 @@ class WaterMaterialScience extends AuthController
             'weight.require' => '请填写重量',
             'unit_price.require' => '请填写单价',
             'company.require' => '请填写单位',
+            'cate_id.require' => '请选择分类',
         ]);
         $details = $model->find($data['id']);
         $details['name'] = $data['name'];
@@ -391,6 +422,7 @@ class WaterMaterialScience extends AuthController
         $details['is_gc'] = $data['is_gc'];
         $details['long'] = $data['long'];
         $details['wide'] = $data['wide'];
+        $details['cate_id'] = $data['cate_id'];
         $res = $details->save();
         if ($res) return Json::successful('修改成功');
         return Json::fail('修改失败');

+ 60 - 116
app/admin/controller/water/WaterQuery.php

@@ -8,6 +8,7 @@
 namespace app\admin\controller\water;
 
 use app\admin\controller\AuthController;
+use app\admin\model\water\WaterMaterial;
 use crmeb\services\{ExpressService,
     JsonService,
     JsonService as Json,
@@ -57,23 +58,10 @@ class WaterQuery extends AuthController
     public function create($id = 0)
     {
         $f = [];
-        $f[] = Form::input('name', '名称')->col(12);
-        $f[] = Form::select('type', '选择分类', '')->options([
-            ['value' => 0, 'label' => '请选择分类'],
-            ['value' => 1, 'label' => '顶板'],
-            ['value' => 2, 'label' => '侧板'],
-            ['value' => 3, 'label' => '拉筋'],
-            ['value' => 4, 'label' => '底板'],
-        ])->filterable(true);
-        $f[] = Form::select('th_id', '选择厚度', '')->options(
-            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterThickness::order('id DESC')->field('id as value,name as label')->select()->toArray())
-        )->filterable(true);
-        $f[] = Form::input('weight', '重量(kg)');
-        $f[] = Form::input('unit_price', '单价');
-        $f[] = Form::input('company', '单位');
-        $f[] = Form::input('long', '长');
-        $f[] = Form::input('wide', '宽');
-        $f[] = Form::radio('is_gc', '公差', 0)->options([['value' => 0, 'label' => '正常'], ['value' => 1, 'label' => '大公差']]);
+        $f[] = Form::number('water_mouth', '水口价格');
+        $f[] = Form::number('partition', '隔板价格');
+        $f[] = Form::number('tax_point', '税点(百分比)');
+        $f[] = Form::hidden('id', $id);
         $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
         $this->assign(compact('form'));
         return $this->fetch('public/form-builder');
@@ -85,125 +73,81 @@ class WaterQuery extends AuthController
     {
         $model = new model;
         $data = Util::postMore([
-            'name',
-            'type',
-            'th_id',
-            'weight',
-            'unit_price',
-            'company',
-            'long',
-            'wide',
+            'water_mouth',
+            'partition',
+            'tax_point',
+            'id',
         ]);
-        $validate = Validate::rule('name', 'require')->rule([
-            'name' => 'require',
-            'type' => 'require',
-            'th_id' => 'require',
-            'weight' => 'require',
-            'unit_price' => 'require',
-            'company' => 'require',
-            'long' => 'require',
-            'wide' => 'require',
+        $validate = Validate::rule([
+            'water_mouth' => 'require',
+            'partition' => 'require',
+            'tax_point' => 'require',
         ]);
         $validate->message([
-            'name.require' => '名称不能为空',
-            'type.require' => '请选择分类',
-            'th_id.require' => '请选择厚度',
-            'weight.require' => '请填写重量',
-            'unit_price.require' => '请填写单价',
-            'company.require' => '请填写单位',
-            'long.require' => '请填写长度',
-            'wide.require' => '请填写宽度',
+            'water_mouth.require' => '输入水口价格',
+            'partition.require' => '隔板价格',
+            'tax_point.require' => '输入税点',
         ]);
         if (!$validate->check($data)) {
             return Json::fail($validate->getError());
         }
-        $res = $model->save($data);
-        if ($res) return Json::successful('添加成功');
+        $query = model::where('id', $data['id'])->find();
+        if (!$query) return Json::fail('查询订单不存在');
+
+        $money = $query['price'] + $data['water_mouth'] + $data['partition'];
+        $res = \app\admin\model\water\WaterOrder::create([
+            'uid' => $query['uid'],
+            'query_id' => $query['id'],
+            'order_id' => $this->getNewOrderId(),
+            'long' => $query['long'],
+            'wide' => $query['wide'],
+            'high' => $query['high'],
+            'is_warm' => $query['is_warm'],
+            'is_channel' => $query['is_channel'],
+            'is_ladder' => $query['is_ladder'],
+            'is_gc' => $query['is_gc'],
+            'water_mouth' => $data['water_mouth'],
+            'partition' => $data['partition'],
+            'tax_point' => $data['tax_point'],
+            'tax' => $money * ($data['tax_point']/100),
+            'price' => $money,
+            'weight' => $query['weight'],
+        ]);
+        if ($res) return Json::successful('转为订单成功');
         return Json::fail('添加失败');
     }
 
 
     /**
-     * 显示创建资源表单页.
-     *
-     * @return \think\Response
+     * 生成订单唯一id
+     * @param $uid 用户uid
+     * @return string
      */
-    public function edit($id = 0)
+    public function getNewOrderId()
     {
-        $data = model::find($id);
-        $f = [];
-        $f[] = Form::input('name', '名称', $data['name'])->col(12);
-        $f[] = Form::select('type', '选择分类', (string)$data['type'])->options([
-            ['value' => 0, 'label' => '请选择分类'],
-            ['value' => 1, 'label' => '顶板'],
-            ['value' => 2, 'label' => '侧板'],
-            ['value' => 3, 'label' => '拉筋'],
-            ['value' => 4, 'label' => '底板'],
-        ])->filterable(true);
-        $f[] = Form::select('th_id', '选择厚度', (string)$data['th_id'])->options(
-            array_merge([['value' => 0, 'label' => '请选择分类']], \app\admin\model\water\WaterThickness::order('id DESC')->field('id as value,name as label')->select()->toArray())
-        )->filterable(true);
-        $f[] = Form::input('weight', '重量(kg)', $data['weight']);
-        $f[] = Form::input('unit_price', '单价', $data['unit_price']);
-        $f[] = Form::input('company', '单位', $data['company']);
-        $f[] = Form::input('long', '长', $data['long']);
-        $f[] = Form::input('wide', '宽', $data['wide']);
-        $f[] = Form::hidden('id', $id);
-        $form = Form::make_post_form('修改', $f, Url::buildUrl('update'));
-        $this->assign(compact('form'));
-        return $this->fetch('public/form-builder');
+        do {
+            list($msec, $sec) = explode(' ', microtime());
+            $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
+            $orderId = 'w' . $msectime . mt_rand(10000, 99999);
+        } while (\app\admin\model\water\WaterOrder::be(['order_id' => $orderId]));// $orderId = 'wx' . $msectime . mt_rand(10000, 99999);
+        return $orderId;
     }
 
-
     /**
-     * 修改
-     * @return void
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
+     * 详情
+     * @param $id
+     * @return string
+     * @throws \Exception
      */
-    public function update()
+    public function details($id)
     {
-        $model = new model;
-        $data = Util::postMore([
-            'name',
-            'type',
-            'th_id',
-            'weight',
-            'unit_price',
-            'company',
-            'long',
-            'wide',
-            'id',
-        ]);
-        $validate = Validate::rule('name', 'require')->rule([
-            'name' => 'require',
-            'type' => 'require',
-            'th_id' => 'require',
-            'weight' => 'require',
-            'unit_price' => 'require',
-            'company' => 'require',
-            'long' => 'require',
-            'wide' => 'require',
-        ]);
-        $validate->message([
-            'name.require' => '名称不能为空',
-            'type.require' => '请选择分类',
-            'th_id.require' => '请选择厚度',
-            'weight.require' => '请填写重量',
-            'unit_price.require' => '请填写单价',
-            'company.require' => '请填写单位',
-            'long.require' => '请填写长度',
-            'wide.require' => '请填写宽度',
-        ]);
-        $details = $model->find($data['id']);
-        $details['name'] = $data['name'];
-        $details['thickness'] = $data['thickness'];
-        $res = $details->save();
-        if ($res) return Json::successful('修改成功');
-        return Json::fail('修改失败');
-    }
+        $model = new WaterMaterial();
+        $model = $model->where('query_id', $id);
+//        $model = $model->order('id desc');
+        $this->assign( WaterMaterial::page($model, null, null, '100'));
+        return $this->fetch();
 
+    }
 
     /**
      * 删除

+ 66 - 0
app/admin/model/water/WaterCate.php

@@ -0,0 +1,66 @@
+<?php
+/**
+ * @author: xaboy<365615158@qq.com>
+ * @day: 2017/11/11
+ */
+
+namespace app\admin\model\water;
+
+use app\models\user\WechatUser;
+use crmeb\services\MiniProgramService;
+use crmeb\services\WechatService;
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+use think\model\concern\SoftDelete;
+
+/**
+ * Class StoreCategory
+ * @package app\admin\model\store
+ */
+class WaterCate extends BaseModel
+{
+
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'water_cate';
+
+    use ModelTrait;
+    protected $autoWriteTimestamp = true;
+
+
+
+
+    public static function list($where)
+    {
+        $model = self::field('*')->order('id DESC');
+
+        if ($where['name'])$model->where('name' , 'like', '%'.$where['name'],'%');
+        $data['count'] = $model->count();
+        if ($where['page'] && $where['limit']){
+            $model->page($where['page'], $where['limit']);
+        }else{
+            $model->page(20, 1);
+        }
+        $list = $model->select()->toArray();
+
+        $type = [1 => '顶板', 2 =>'侧板', 3 =>'拉筋', 4 =>'底板',5 => '立柱', 6 =>'辅拉', 7 =>'保温', 8 =>'槽钢', 9 =>'扶梯管'];
+        foreach ($list as &$item){
+            $item['type'] = $type[$item['type']];
+        }
+
+        $data['data'] = $list;
+        return $data;
+
+    }
+
+
+
+}

+ 3 - 2
app/admin/model/water/WaterMaterialScience.php

@@ -36,8 +36,9 @@ class WaterMaterialScience extends BaseModel
 
     public static function list($where)
     {
-        $model = self::alias('a')->field('a.*,b.name as th_name')->order('a.id DESC')
-        ->leftJoin('water_thickness b', 'a.th_id = b.id');
+        $model = self::alias('a')->field('a.*,b.name as th_name,c.name as cate_name')->order('a.id DESC')
+        ->leftJoin('water_thickness b', 'a.th_id = b.id')
+        ->leftJoin('water_cate c', 'a.cate_id = c.id');
 
         if ($where['name'])$model->where('a.name' , 'like', '%'.$where['name'],'%');
         if ($where['role'] == 'roof'){

+ 3 - 2
app/admin/model/water/WaterOrder.php

@@ -36,9 +36,10 @@ class WaterOrder extends BaseModel
 
     public static function list($where)
     {
-        $model = self::field('*')->order('id DESC');
+        $model = self::alias('a')->field('a.*,u.nickname')->order('a.id DESC')
+            ->leftJoin('user u', 'a.uid = u.uid');
 
-        if ($where['name'])$model->where('name' , 'like', '%'.$where['name'],'%');
+        if ($where['name'])$model->where('u.uid|u.nickname' , 'like', '%'.$where['name'],'%');
         $data['count'] = $model->count();
         if ($where['page'] && $where['limit']){
             $model->page($where['page'], $where['limit']);

+ 187 - 0
app/admin/view/water/water_cate/index.php

@@ -0,0 +1,187 @@
+{extend name="public/container"}
+{block name="head_top"}
+
+{/block}
+{block name="content"}
+<style>
+    .btn-outline{
+        border:none;
+    }
+    .btn-outline:hover{
+        background-color: #0e9aef;
+        color: #fff;
+    }
+    .layui-form-item .layui-btn {
+        margin-top: 5px;
+        margin-right: 10px;
+    }
+    .layui-btn-primary{
+        margin-right: 10px;
+        margin-left: 0!important;
+    }
+    label{
+        margin-bottom: 0!important;
+        margin-top: 4px;
+    }
+</style>
+<div class="layui-fluid">
+    <div class="layui-row layui-col-space15" id="app">
+        <!--搜索条件-->
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-header">搜索条件</div>
+                <div class="layui-card-body">
+                    <div class="layui-carousel layadmin-carousel layadmin-shortcut" lay-anim="" lay-indicator="inside" lay-arrow="none" style="background:none">
+                        <form class="layui-form layui-form-pane" action="">
+                            <div class="layui-form-item">
+
+                                <div class="layui-col-lg12">
+                                    <label class="layui-form-label" style="top: -5.5px;">搜索条件</label>
+                                    <div class="layui-input-inline">
+                                        <input type="text" id="name" name="name" class="layui-input" placeholder="请输入名称">
+                                    </div>
+                                </div>
+                                <div class="layui-inline">
+                                    <div class="layui-input-inline">
+                                        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
+                                            <i class="layui-icon layui-icon-search"></i>搜索</button>
+                                    </div>
+                                </div>
+                            </div>
+                        </form>
+                    </div>
+                </div>
+            </div>
+        </div>
+
+        <!-- 中间详细信息-->
+        <div :class="item.col!=undefined ? 'layui-col-sm'+item.col+' '+'layui-col-md'+item.col:'layui-col-sm6 layui-col-md3'"
+             v-for="item in badge" v-cloak="" v-if="item.count > 0">
+        </div>
+        <!--enb-->
+    </div>
+    <!--列表-->
+    <div class="layui-row layui-col-space15">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-header">会员卡</div>
+                <div class="layui-card-body">
+
+                    <div class="layui-btn-container" id="container-action">
+                        <a class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'{:Url('create')}',{h:500,w:650})">添加分类</a>
+<!--                        <button class="layui-btn layui-btn-sm" data-type="del_auction">批量删除</button>-->
+                    </div>
+                    <table class="layui-hide" id="List" lay-filter="List"></table>
+
+
+                    <script type="text/html" id="image">
+                        <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
+                    </script>
+                    <script type="text/html" id="status">
+                        {{#  if(d.status == 0){ }}
+                        <button type="button" name="suc" class="layui-btn-disabled layui-btn-xs" id="">
+                            关闭
+                        </button>
+                        {{#  } else if(d.status == 1) { }}
+                        <button type="button" name="suc" class="layui-btn-xs layui-btn" id="">
+                            开启
+                        </button>
+                        {{#  } }}
+                    </script>
+                    <script type="text/html" id="suc">
+                        {{#  if(d.suc == 0){ }}
+                        <button type="button" name="suc" class="layui-btn layui-btn-xs" id="">
+                            正常
+                        </button>
+                        {{#  } else if(d.suc == 1) { }}
+                        <button type="button" name="suc" class="layui-btn-xs layui-btn" id="">
+                            种植成功
+                        </button>
+                        {{#  } else if(d.suc == 2) { }}
+                        <button type="button" name="suc" class="layui-btn-disabled layui-btn-xs layui-btn-danger" id="">
+                            种植失败
+                        </button>
+                        {{#  } }}
+                    </script>
+                    <script type="text/html" id="act">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('编辑','{:Url('edit')}?id={{d.id}}',{h:500,w:500})">
+                            编辑
+                        </button>
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" lay-event='delete' id="">
+                            删除
+                        </button>
+
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+    <!--end-->
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name="script"}
+<script>
+    layList.tableList('List', "{:Url('list')}", function () {
+        return [
+            {type: 'checkbox'},
+            {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
+            {field: 'name', title: '名称', templet: '#name',  align: 'center'},
+            {field: 'type', title: '分类', templet: '#name',  align: 'center'},
+            {field: 'create_time', title: '时间', align: 'center', width: '8%'},
+            {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
+        ];
+    });
+
+    //查询
+    layList.search('search',function(where){
+        layList.reload(where,true);
+    });
+
+    //点击事件绑定
+    layList.tool(function (event,data,obj) {
+        switch (event) {
+            case 'delete':
+                var url=layList.U({c:'many.many',a:'delete',q:{id:data.id}});
+                var code = {title:"操作提示",text:"确定将该商品移入回收站吗?",type:'info',confirm:'是的,移入回收站'};
+                $eb.$swal('delete',function(){
+                    $eb.axios.get(url).then(function(res){
+                        if(res.status == 200 && res.data.code == 200) {
+                            $eb.$swal('success',res.data.msg);
+                            obj.del();
+                            location.reload();
+                        }else
+                            return Promise.reject(res.data.msg || '删除失败')
+                    }).catch(function(err){
+                        $eb.$swal('error',err);
+                    });
+                },code)
+                break;
+            case 'open_image':
+                $eb.openImage(data.image);
+                break;
+            case 'edit':
+                location.href = layList.U({a:'edit',q:{id:data.id}});
+                break;
+        }
+    })
+
+
+    //改状态
+    layList.switch('status',function (odj,value) {
+        if(odj.elem.checked==true){
+            layList.baseGet(layList.Url({c:'auction.auction',a:'set_status',p:{status:1,id:value}}),function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        }else{
+            layList.baseGet(layList.Url({c:'auction.auction',a:'set_status',p:{status:0,id:value}}),function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        }
+    });
+</script>
+{/block}

+ 1 - 0
app/admin/view/water/water_material_science/channel.php

@@ -112,6 +112,7 @@
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
             {field: 'type', title: '材料分类', align: 'center',templet: '#type',},
+            {field: 'cate_name', title: '分类', align: 'center',templet: '#cate_name'},
             // {field: 'th_name', title: '厚度', align: 'center'},
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},

+ 2 - 1
app/admin/view/water/water_material_science/column.php

@@ -123,7 +123,8 @@
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
-            {field: 'type', title: '材料分类', align: 'center',templet: '#type',},
+            {field: 'type', title: '材料分类', align: 'center',templet: '#type'},
+            {field: 'cate_name', title: '分类', align: 'center',templet: '#cate_name'},
             {field: 'th_name', title: '厚度', align: 'center'},
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},

+ 2 - 1
app/admin/view/water/water_material_science/escalator.php

@@ -111,7 +111,8 @@
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
-            {field: 'type', title: '材料分类', align: 'center',templet: '#type',},
+            {field: 'type', title: '材料分类', align: 'center',templet: '#type'},
+            {field: 'cate_name', title: '分类', align: 'center',templet: '#cate_name'},
             // {field: 'th_name', title: '厚度', align: 'center'},
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},

+ 2 - 1
app/admin/view/water/water_material_science/floor.php

@@ -119,7 +119,8 @@
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
-            {field: 'type', title: '材料分类', align: 'center',templet: '#type',},
+            {field: 'type', title: '材料分类', align: 'center',templet: '#type'},
+            {field: 'cate_name', title: '分类', align: 'center',templet: '#cate_name'},
             {field: 'th_name', title: '厚度', align: 'center'},
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},

+ 2 - 1
app/admin/view/water/water_material_science/fula.php

@@ -123,7 +123,8 @@
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
-            {field: 'type', title: '材料分类', align: 'center',templet: '#type',},
+            {field: 'type', title: '材料分类', align: 'center',templet: '#type'},
+            {field: 'cate_name', title: '分类', align: 'center',templet: '#cate_name'},
             {field: 'th_name', title: '厚度', align: 'center'},
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},

+ 2 - 1
app/admin/view/water/water_material_science/lacing.php

@@ -119,7 +119,8 @@
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
-            {field: 'type', title: '材料分类', align: 'center',templet: '#type',},
+            {field: 'type', title: '材料分类', align: 'center',templet: '#type'},
+            {field: 'cate_name', title: '分类', align: 'center',templet: '#cate_name'},
             {field: 'th_name', title: '厚度', align: 'center'},
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},

+ 2 - 1
app/admin/view/water/water_material_science/roof.php

@@ -118,7 +118,8 @@
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
-            {field: 'type', title: '材料分类', align: 'center',templet: '#type',},
+            {field: 'type', title: '材料分类', align: 'center',templet: '#type'},
+            {field: 'cate_name', title: '分类', align: 'center',templet: '#cate_name'},
             {field: 'th_name', title: '厚度', align: 'center'},
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},

+ 2 - 1
app/admin/view/water/water_material_science/side_plate.php

@@ -120,7 +120,8 @@
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
-            {field: 'type', title: '材料分类', align: 'center',templet: '#type',},
+            {field: 'type', title: '材料分类', align: 'center',templet: '#type'},
+            {field: 'cate_name', title: '分类', align: 'center',templet: '#cate_name'},
             {field: 'th_name', title: '厚度', align: 'center'},
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},

+ 2 - 1
app/admin/view/water/water_material_science/warm.php

@@ -111,7 +111,8 @@
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
             {field: 'name', title: '名称', templet: '#name',  align: 'center'},
-            {field: 'type', title: '材料分类', align: 'center',templet: '#type',},
+            {field: 'type', title: '材料分类', align: 'center',templet: '#type'},
+            {field: 'cate_name', title: '分类', align: 'center',templet: '#cate_name'},
             // {field: 'th_name', title: '厚度', align: 'center'},
             {field: 'weight', title: '重量', align: 'center'},
             {field: 'unit_price', title: '单价', align: 'center'},

+ 32 - 33
app/admin/view/water/water_order/index.php

@@ -72,7 +72,7 @@
     <div class="layui-row layui-col-space15">
         <div class="layui-col-md12">
             <div class="layui-card">
-                <div class="layui-card-header">会员卡订单</div>
+                <div class="layui-card-header">计算订单</div>
                 <div class="layui-card-body">
 
                     <div class="layui-btn-container" id="container-action">
@@ -81,38 +81,37 @@
                     </div>
                     <table class="layui-hide" id="List" lay-filter="List"></table>
 
-
-                    <script type="text/html" id="image">
-                        <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
+                    <script type="text/html" id="is_warm">
+                        {{#  if(d.is_warm == 0){ }}
+                        不需要
+                        {{#  } else if(d.is_warm > 0) { }}
+                        需要
+                        {{#  } }}
                     </script>
-                    <script type="text/html" id="status">
-                        {{#  if(d.status == 0){ }}
-                        <button type="button" name="suc" class="layui-btn-disabled layui-btn-xs" id="">
-                            关闭
-                        </button>
-                        {{#  } else if(d.status == 1) { }}
-                        <button type="button" name="suc" class="layui-btn-xs layui-btn" id="">
-                            开启
-                        </button>
+                    <script type="text/html" id="is_channel">
+                        {{#  if(d.is_channel == 0){ }}
+                        不需要
+                        {{#  } else if(d.is_channel > 0) { }}
+                        需要
                         {{#  } }}
                     </script>
-                    <script type="text/html" id="suc">
-                        {{#  if(d.suc == 0){ }}
-                        <button type="button" name="suc" class="layui-btn layui-btn-xs" id="">
-                            正常
-                        </button>
-                        {{#  } else if(d.suc == 1) { }}
-                        <button type="button" name="suc" class="layui-btn-xs layui-btn" id="">
-                            种植成功
-                        </button>
-                        {{#  } else if(d.suc == 2) { }}
-                        <button type="button" name="suc" class="layui-btn-disabled layui-btn-xs layui-btn-danger" id="">
-                            种植失败
-                        </button>
+                    <script type="text/html" id="is_ladder">
+                        {{#  if(d.is_ladder == 0){ }}
+                        不需要
+                        {{#  } else if(d.is_ladder == 1) { }}
+                        需要
                         {{#  } }}
                     </script>
+                    <script type="text/html" id="is_gc">
+                        {{#  if(d.is_gc == 0){ }}
+                        正常
+                        {{#  } else if(d.is_gc == 1) { }}
+                        大公差
+                        {{#  } }}
+                    </script>
+
                     <script type="text/html" id="act">
-                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('编辑','{:Url('details')}?id={{d.id}}',{h:500,w:500})">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('编辑','{:Url('water.WaterQuery/details')}?id={{d.query_id}}',{h:1100,w:1100})">
                             详情
                         </button>
                         <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" lay-event='delete' id="">
@@ -139,13 +138,13 @@
             {field: 'long', title: '水箱长',  align: 'center'},
             {field: 'wide', title: '水箱宽',  align: 'center'},
             {field: 'high', title: '水箱高',  align: 'center'},
-            {field: 'is_warm', title: '是否保温',  align: 'center'},
-            {field: 'is_channel', title: '槽钢', align: 'center' },
-            {field: 'is_ladder', title: '人梯', align: 'center'},
-            {field: 'is_gc', title: '公差', align: 'center', },
+            {field: 'is_warm', title: '是否保温',  align: 'center',templet: '#is_warm'},
+            {field: 'is_channel', title: '槽钢', align: 'center',templet: '#is_channel'},
+            {field: 'is_ladder', title: '人梯', align: 'center',templet: '#is_ladder'},
+            {field: 'is_gc', title: '公差', align: 'center',templet: '#is_gc', width: '8%'},
             {field: 'water_mouth', title: '水口', align: 'center'},
             {field: 'partition', title: '隔板', align: 'center'},
-            // {field: 'tax_point', title: '税点', align: 'center'},
+            {field: 'tax_point', title: '税点', align: 'center'},
             {field: 'tax', title: '总税', align: 'center'},
             {field: 'price', title: '总价', align: 'center'},
             {field: 'create_time', title: '时间', align: 'center', width: '8%'},
@@ -162,7 +161,7 @@
     layList.tool(function (event,data,obj) {
         switch (event) {
             case 'delete':
-                var url=layList.U({c:'many.many',a:'delete',q:{id:data.id}});
+                var url=layList.U({c:'water.water_order',a:'delete',q:{id:data.id}});
                 var code = {title:"操作提示",text:"确定将该商品移入回收站吗?",type:'info',confirm:'是的,移入回收站'};
                 $eb.$swal('delete',function(){
                     $eb.axios.get(url).then(function(res){

+ 88 - 0
app/admin/view/water/water_query/details.php

@@ -0,0 +1,88 @@
+{extend name="public/container"}
+{block name="content"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox">
+            <div class="ibox-content">
+<!--                <div class="row">-->
+<!--                    <div class="m-b m-l">-->
+<!--                    </div>-->
+<!---->
+<!--                </div>-->
+                <div class="table-responsive">
+                    <table class="table table-striped  table-bordered">
+                        <thead>
+                        <tr>
+
+                            <th class="text-center">编号</th>
+                            <th class="text-center">标题</th>
+                            <th class="text-center">名称</th>
+                            <th class="text-center">规格</th>
+                            <th class="text-center">数量</th>
+                            <th class="text-center">单价</th>
+                            <th class="text-center">总价</th>
+                            <th class="text-center">分类</th>
+                            <th class="text-center">单位</th>
+                        </tr>
+                        </thead>
+                        <tbody class="">
+                        {volist name="list" id="vo"}
+                        <tr>
+                            <td class="text-center">
+                                {$vo.id}
+                            </td>
+                            <td class="text-center">
+                                {$vo.title}
+                            </td>
+                            <td class="text-center">
+                                {$vo.name}
+                            </td>
+                            <td class="text-center">
+                                {$vo.specifications}
+                            </td>
+                            <td class="text-center">
+                                {$vo.number}
+                            </td>
+                            <td class="text-center">
+                                {$vo.unit_price}
+                            </td>
+                            <td class="text-center">
+                                {$vo.ot_price}
+                            </td>
+                            <td class="text-center">
+                                {if condition="$vo['type'] eq 1"}
+                                顶板
+                                {elseif condition="$vo['type'] eq 2"/}
+                                侧板
+                                {elseif condition="$vo['type'] eq 3"/}
+                                拉筋
+                                {elseif condition="$vo['type'] eq 4"/}
+                                底板
+                                {elseif condition="$vo['type'] eq 5"/}
+                                立柱
+                                {elseif condition="$vo['type'] eq 6"/}
+                                辅拉
+                                {elseif condition="$vo['type'] eq 7"/}
+                                保温
+                                {elseif condition="$vo['type'] eq 8"/}
+                                槽钢
+                                {elseif condition="$vo['type'] eq 9"/}
+                                扶梯管
+                                {else/}
+                                错误分类
+                                {/if}
+                            </td>
+                            <td class="text-center">
+                                {$vo.company}
+                            </td>
+                        </tr>
+                        {/volist}
+                        </tbody>
+                    </table>
+                </div>
+                {include file="public/inner_page"}
+            </div>
+        </div>
+    </div>
+</div>
+{/block}

+ 31 - 29
app/admin/view/water/water_query/index.php

@@ -85,37 +85,39 @@
                     <script type="text/html" id="image">
                         <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
                     </script>
-                    <script type="text/html" id="status">
-                        {{#  if(d.status == 0){ }}
-                        <button type="button" name="suc" class="layui-btn-disabled layui-btn-xs" id="">
-                            关闭
-                        </button>
-                        {{#  } else if(d.status == 1) { }}
-                        <button type="button" name="suc" class="layui-btn-xs layui-btn" id="">
-                            开启
-                        </button>
+                    <script type="text/html" id="is_warm">
+                        {{#  if(d.is_warm == 0){ }}
+                        不需要
+                        {{#  } else if(d.is_warm > 0) { }}
+                        需要
                         {{#  } }}
                     </script>
-                    <script type="text/html" id="suc">
-                        {{#  if(d.suc == 0){ }}
-                        <button type="button" name="suc" class="layui-btn layui-btn-xs" id="">
+                    <script type="text/html" id="is_channel">
+                        {{#  if(d.is_channel == 0){ }}
+                        不需要
+                        {{#  } else if(d.is_channel > 0) { }}
+                        需要
+                        {{#  } }}
+                    </script>
+                    <script type="text/html" id="is_ladder">
+                        {{#  if(d.is_ladder == 0){ }}
+                        不需要
+                        {{#  } else if(d.is_ladder == 1) { }}
+                        需要
+                        {{#  } }}
+                    </script>
+                    <script type="text/html" id="is_gc">
+                        {{#  if(d.is_gc == 0){ }}
                             正常
-                        </button>
-                        {{#  } else if(d.suc == 1) { }}
-                        <button type="button" name="suc" class="layui-btn-xs layui-btn" id="">
-                            种植成功
-                        </button>
-                        {{#  } else if(d.suc == 2) { }}
-                        <button type="button" name="suc" class="layui-btn-disabled layui-btn-xs layui-btn-danger" id="">
-                            种植失败
-                        </button>
+                        {{#  } else if(d.is_gc == 1) { }}
+                            大公差
                         {{#  } }}
                     </script>
                     <script type="text/html" id="act">
-                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('编辑','{:Url('details')}?id={{d.id}}',{h:500,w:500})">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('详情','{:Url('details')}?id={{d.id}}',{h:1100,w:1100})">
                             详情
                         </button>
-                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('编辑','{:Url('details')}?id={{d.id}}',{h:500,w:500})">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('转为订单','{:Url('create')}?id={{d.id}}',{h:800,w:800})">
                             转为订单
                         </button>
                         <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" lay-event='delete' id="">
@@ -137,16 +139,16 @@
         return [
             {type: 'checkbox'},
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '5%', templet: '#id'},
-            {field: 'uid', title: 'UID',  align: 'center'},
             {field: 'nickname', title: '用户昵称',  align: 'center'},
             {field: 'long', title: '水箱长',  align: 'center'},
             {field: 'wide', title: '水箱宽',  align: 'center'},
             {field: 'high', title: '水箱高',  align: 'center'},
-            {field: 'is_warm', title: '是否保温',  align: 'center'},
-            {field: 'is_channel', title: '槽钢', align: 'center', width: '8%'},
-            {field: 'is_ladder', title: '人梯', align: 'center', width: '8%'},
-            {field: 'is_gc', title: '公差', align: 'center', width: '8%'},
+            {field: 'is_warm', title: '是否保温',  align: 'center',templet: '#is_warm'},
+            {field: 'is_channel', title: '槽钢', align: 'center',templet: '#is_channel'},
+            {field: 'is_ladder', title: '人梯', align: 'center',templet: '#is_ladder'},
+            {field: 'is_gc', title: '公差', align: 'center',templet: '#is_gc', width: '8%'},
             {field: 'price', title: '总价', align: 'center', width: '8%'},
+            {field: 'weight', title: '重量', align: 'center', width: '8%'},
             {field: 'create_time', title: '查询时间', align: 'center', width: '8%'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act',width: '15%'},
         ];
@@ -161,7 +163,7 @@
     layList.tool(function (event,data,obj) {
         switch (event) {
             case 'delete':
-                var url=layList.U({c:'many.many',a:'delete',q:{id:data.id}});
+                var url=layList.U({c:'water.water_query',a:'delete',q:{id:data.id}});
                 var code = {title:"操作提示",text:"确定将该商品移入回收站吗?",type:'info',confirm:'是的,移入回收站'};
                 $eb.$swal('delete',function(){
                     $eb.axios.get(url).then(function(res){

+ 276 - 30
app/api/controller/water/WaterQueryController.php

@@ -2,11 +2,16 @@
 
 namespace app\api\controller\water;
 
+use app\admin\model\water\WaterCate;
+use app\admin\model\water\WaterMaterial;
 use app\admin\model\water\WaterMaterialScience;
+use app\admin\model\water\WaterQuery;
+use app\models\user\User;
 use app\Request;
 use crmeb\services\GroupDataService;
 use crmeb\services\QrcodeService;
 use crmeb\services\UtilService;
+use think\facade\Db;
 
 /**
  * 秒杀产品类
@@ -16,7 +21,7 @@ use crmeb\services\UtilService;
 class WaterQueryController
 {
 
-    public function calculation(Request $request)
+    public function query(Request $request)
     {
         $data = UtilService::postMore([
             ['long', ''],// 长
@@ -26,19 +31,208 @@ class WaterQueryController
             ['is_channel', ''], // 是否需要槽钢
             ['is_human_ladder', ''] ,// 是否需要人梯
             ['is_gc', ''] ,// 公差
-            ['floor', ''], // 底板厚度
-            ['side_plate', ''], // 侧板厚度
             ['roof', ''], // 顶板厚度
+            ['floor', ''], // 底板厚度
+            ['side_plate', []], // 侧板厚度
             ['column', ''], // 立柱厚度
-            ['lacing', ''], // 拉筋厚度
-            ['fula', ''], // 辅拉
+            ['lacing', []], // 拉筋厚度
+            ['fula', []], // 辅拉
         ]);
+        $user = User::where('uid', $request->uid())->find();
+        if ($user['member'] == 0){
+            if ($user['frequency'] == 0 and $user['free'] == 0){
+                return app('json')->fail('查询次数已用完');
+            }
+        }
         //顶板
+        $calculation = $this->calculation($data);
+        $amount = $this->AmountOfMoney($calculation, $data);// 计算总价,表格
+        Db::startTrans();
+        try {
+            $res = WaterQuery::create([
+                'uid' =>  $request->uid(),
+                'long' => $data['long'],
+                'wide' => $data['wide'],
+                'high' => $data['high'],
+                'is_warm' => $data['is_warm'],
+                'is_channel' => $data['is_channel'],
+                'is_ladder' => $data['is_human_ladder'],
+                'is_gc' => $data['is_gc'],
+                'price' => $amount['zj'],
+                'weight' => $amount['zzl'],
+            ]);
+            foreach ($amount['table'] as $item){
+                $item['query_id'] = $res['id'];
+                WaterMaterial::create($item);
+            }
+            if ($user['member'] == 0){
+                if ($user['free'] > 0){
+                    User::where('uid', $request->uid())->dec('free', 1)->update();
+                }else{
+                    User::where('uid', $request->uid())->dec('frequency', 1)->update();
+                }
+            }
+            Db::commit();
+            return app('json')->success($amount);
+        } catch (\Exception $e) {
+            Db::rollback();
+            return app('json')->fail($e->getMessage());
+        }
+    }
+
+    public function AmountOfMoney($calculation, $data)
+    {
+        $table = [];
+        $zj = 0; //总价
+        $zzl = 0; // 总重量
         if ($data['is_gc'] > 0){
             $where[] = ['is_gc', '=' ,1];
         }else{
             $where[] = ['is_gc', '=' ,0];
         }
+        foreach ($calculation['roof_number'] as $k => $v){
+            if ($k == '1*1'){
+                $details = WaterMaterialScience::where('cate_id', $data['roof'])->where($where)->where([['long', '=', 1], ['wide', '=', 1]])->find();
+
+                $zj += $details['unit_price'] * $v;
+                $zzl += $details['weight'] * $v;
+                $table[] = ['title' => '顶板', 'name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v ,'type' => 1];
+            }elseif ($k == '1*0.5'){
+                $details = WaterMaterialScience::where('cate_id', $data['roof'])->where($where)->where([['long', '=', 1], ['wide', '=', 0.5]])->find();
+
+                $zj += $details['unit_price'] * $v;
+                $zzl += $details['weight'] * $v;
+                $table[] = ['title' => '顶板','name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v ,'type' => 1];
+            }elseif ($k == '0.5*0.5'){
+                $details = WaterMaterialScience::where('cate_id', $data['roof'])->where($where)->where([['long', '=', 0.5], ['wide', '=', 0.5]])->find();
+
+                $zj += $details['unit_price'] * $v;
+                $zzl += $details['weight'] * $v;
+                $table[] = ['title' => '顶板','name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 1];
+            }
+        }
+        // 底板
+        foreach ($calculation['floor_number'] as $k => $v){
+            if ($k == '1*1'){
+                $details = WaterMaterialScience::where('cate_id', $data['floor'])->where($where)->where([['long', '=', 1], ['wide', '=', 1]])->find();
+
+                $zj += $details['unit_price'] * $v;
+                $zzl += $details['weight'] * $v;
+                $table[] = ['title' => '底板','name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v ,'type' => 4];
+            }elseif ($k == '1*0.5'){
+                $details = WaterMaterialScience::where('cate_id', $data['floor'])->where($where)->where([['long', '=', 1], ['wide', '=', 0.5]])->find();
+
+                $zj += $details['unit_price'] * $v;
+                $zzl += $details['weight'] * $v;
+                $table[] = ['title' => '底板','name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v ,'type' => 4];
+            }elseif ($k == '0.5*0.5'){
+                $details = WaterMaterialScience::where('cate_id', $data['floor'])->where($where)->where([['long', '=', 0.5], ['wide', '=', 0.5]])->find();
+
+                $zj += $details['unit_price'] * $v;
+                $zzl += $details['weight'] * $v;
+                $table[] = ['title' => '底板','name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 4];
+            }
+        }
+        // 侧板
+        $storey = 0;
+        foreach ($calculation['side_number'] as $item){
+            $storey ++;
+            foreach ($item as $k => $v){
+                if ($k == '1*1'){
+                    $details = WaterMaterialScience::where('cate_id', $data['side_plate'][$storey-1])->where($where)->where([['long', '=', 1], ['wide', '=', 1]])->find();
+                    $zj += $details['unit_price'] * $v;
+                    $zzl += $details['weight'] * $v;
+                    $table[] = ['title' => '侧板B'.$storey.'层' , 'name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 2];
+                }elseif ($k == '1*0.5'){
+                    $details = WaterMaterialScience::where('cate_id', $data['side_plate'][$storey-1])->where($where)->where([['long', '=', 1], ['wide', '=', 0.5]])->find();
+
+                    $zj += $details['unit_price'] * $v;
+                    $zzl += $details['weight'] * $v;
+                    $table[] = ['title' => '侧板B'.$storey.'层' , 'name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 2];
+                }elseif ($k == '0.5*0.5'){
+                    $details = WaterMaterialScience::where('cate_id', $data['side_plate'][$storey-1])->where($where)->where([['long', '=', 0.5], ['wide', '=', 0.5]])->find();
+
+                    $zj += $details['unit_price'] * $v;
+                    $zzl += $details['weight'] * $v;
+                    $table[] = ['title' => '侧板B'.$storey.'层' , 'name' => $details['name'], 'specifications' => $details['long'].'*'.$details['wide'], 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 2];
+                }
+            }
+        }
+        //拉筋
+        $lac_storey = 0;
+        foreach ($calculation['lacing_number'] as $v){
+            $lac_storey ++;
+            $details = WaterMaterialScience::where('cate_id', $data['lacing'][$lac_storey-1])->where($where)->find();
+            $zj += $details['unit_price'] * $v;
+            $zzl += $details['weight'] * $v;
+            $table[] = ['title' => '辅拉B'.$lac_storey.'层' , 'name' => $details['name'], 'specifications' => '1', 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 3];
+        }
+
+        $fula_storey = 0;
+        foreach ($calculation['fula_number'] as $v){
+            $fula_storey ++;
+            $details = WaterMaterialScience::where('cate_id', $data['fula'][$fula_storey-1])->where($where)->find();
+            $zj += $details['unit_price'] * $v;
+            $zzl += $details['weight'] * $v;
+            $table[] = ['title' => '辅拉B'.$fula_storey.'层' , 'name' => $details['name'], 'specifications' => '1', 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 6];
+        }
+
+        // 立柱
+        $details = WaterMaterialScience::where('cate_id', $data['column'])->where($where)->find();
+        $zj += $details['unit_price'] * $calculation['column_number'];
+        $zzl += $details['weight'] * $calculation['column_number'];
+        $table[] = ['title' => '立柱' , 'name' => $details['name'], 'specifications' => '1', 'number' => $calculation['column_number'], 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $calculation['column_number'], 'weight' => $details['weight'] * $calculation['column_number'] , 'type' => 5];
+
+        //保温
+        foreach ($calculation['warm'] as $k => $v){
+            if ($k == 'warm1' and $v > 0){
+                $details = WaterMaterialScience::where('cate_id', $data['is_warm'])->where([['long', '=', 1], ['wide', '=', 1]])->where($where)->find();
+                $zj += $details['unit_price'] * $v;
+                $zzl += $details['weight'] * $v;
+                $table[] = ['title' => '保温板' , 'name' => $details['name'], 'specifications' => '1*1', 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 7];
+            }elseif ($k == 'warm2' and $v > 0){
+                $details = WaterMaterialScience::where('cate_id', $data['is_warm'])->where([['long', '=', 1], ['wide', '=', 0.5]])->where($where)->find();
+                $zj += $details['unit_price'] * $v;
+                $zzl += $details['weight'] * $v;
+                $table[] = ['title' => '保温板' , 'name' => $details['name'], 'specifications' => '1*0.5', 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 7];
+            }elseif ($k == 'warm3' and $v > 0){
+                $details = WaterMaterialScience::where('cate_id', $data['is_warm'])->where([['long', '=', 0.5], ['wide', '=', 0.5]])->where($where)->find();
+                $zj += $details['unit_price'] * $v;
+                $zzl += $details['weight'] * $v;
+                $table[] = ['title' => '保温板' , 'name' => $details['name'], 'specifications' => '0.5*0.5', 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 7];
+            }
+
+        }
+        //槽钢
+        if ($data['is_channel'] > 0){
+            $details = WaterMaterialScience::where('cate_id', $data['is_channel'])->where($where)->find();
+            $zj += $details['unit_price'] * $calculation['channel_number'];
+            $zzl += $details['weight'] * $calculation['channel_number'];
+            $table[] = ['title' => '槽钢' , 'name' => $details['name'], 'specifications' => '1', 'number' => $calculation['channel_number'], 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $calculation['channel_number'], 'weight' => $details['weight'] * $calculation['channel_number'] , 'type' => 8];
+        }
+
+        // 扶梯
+        if ($data['is_human_ladder'] > 0){
+            $details = WaterMaterialScience::where('cate_id', 9)->find();
+            $zj += $details['unit_price'] * $calculation['ladder'];
+            $zzl += $details['weight'] * $calculation['ladder'];
+            $table[] = ['title' => '扶梯' , 'name' => $details['name'], 'specifications' => '1', 'number' => $calculation['ladder'], 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $calculation['ladder'], 'weight' => $details['weight'] * $calculation['ladder'] , 'type' => 9];
+        }
+
+        return ['table' => $table, 'zj' => $zj, 'zzl' => $zzl];
+
+    }
+
+
+
+
+    /**计算使用材料数量
+     * @param $data
+     * @return array
+     */
+    public function calculation($data)
+    {
+
         $long = (double)$data['long'];
         $wide = (double)$data['wide'];
         $high = (double)$data['high'];
@@ -48,8 +242,9 @@ class WaterQueryController
         $side_number = []; // 侧板数量
         $lacing_number = []; // 拉经数量
         $fula_number = [];//辅拉数量
-        $warm = []; //保温数量
-        $channel_number = 0;
+        $column_number = 0;// 立柱数量
+        $channel_number = 0; // 槽钢
+        $ladder = 0;// 扶梯管米数
         for ($i = 0; $i < intval($high); $i++){
             $high_array[] = 1;
         }
@@ -69,7 +264,7 @@ class WaterQueryController
             $floor_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => intval($long) + intval($wide), '0.5*0.5' => 1];// 底板数量
             foreach ($high_array as $item){
                 if ($item >= 1){
-                    $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '0.1*0.5' => 4];
+                    $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 4];
                 }else{
                     $side_number[] = ['1*0.5' => ((intval($long)) + (intval($wide))) * 2, '0.5*0.5' => 4];
                 }
@@ -80,26 +275,26 @@ class WaterQueryController
                 $roof_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => $wide]; // 顶板数量
                 $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $wide];// 底板数量
                 foreach ($high_array as $item){
-                    $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '0.1*0.5' => 2];
+                    $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 2];
                 }
             }elseif (ceil($long) == $long && ceil($wide) != $wide and ceil($high) == $high){
                 $roof_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => $long]; // 顶板数量
                 $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $long];// 底板数量
                 foreach ($high_array as $item){
-                    $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '0.1*0.5' => 2];
+                    $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 2];
                 }
             }elseif (ceil($long) != $long && ceil($wide) != $wide and ceil($high) == $high){
                 $roof_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => intval($long) + intval($wide), '0.5*0.5' => 1]; // 顶板数量
                 $floor_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => intval($long) + intval($wide), '0.5*0.5' => 1];// 底板数量
                 foreach ($high_array as $item){
-                    $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '0.1*0.5' => 4];
+                    $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 4];
                 }
             } elseif (ceil($long) != $long && ceil($wide) == $wide and ceil($high) != $high){
                 $roof_number = ['1*1' =>  intval($long) * intval($wide), '1*0.5' => $wide]; // 顶板数量
                 $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $wide];// 底板数量
                 foreach ($high_array as $item){
                     if ($item >= 1){
-                        $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '0.1*0.5' => 2];
+                        $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 2];
                     }else{
                         $side_number[] = ['1*0.5' => ((intval($long)) + (intval($wide))) * 2, '0.5*0.5' => 2];
                     }
@@ -109,7 +304,7 @@ class WaterQueryController
                 $floor_number = ['1*1' => intval($long) * intval($wide), '1*0.5' => $long];// 底板数量
                 foreach ($high_array as $item){
                     if ($item >= 1){
-                        $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '0.1*0.5' => 2];
+                        $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2, '1*0.5' => 2];
                     }else{
                         $side_number[] = ['1*0.5' => ((intval($long)) + (intval($wide))) * 2, '0.5*0.5' => 2];
                     }
@@ -130,7 +325,7 @@ class WaterQueryController
         array_pop($high_array);// 删除最后一位,算出主拉层数
         // 拉筋
         foreach ($high_array as $item){
-            $lacing_number[] = ceil(((ceil($long) * (ceil($wide) - 1)) + (ceil($wide) * (ceil($long) - 1)))/2);
+            $lacing_number[] = ceil((($long * (ceil($wide) - 1)) + ($wide * (ceil($long) - 1)))/2);
         }
         // 辅拉
         if ($high > 1){
@@ -154,6 +349,9 @@ class WaterQueryController
                 }
             }
         }
+        //立柱
+        $column_number = ceil((ceil($long) - 1) * (ceil($wide) -1) * $wide / 2);
+        //保温板数量
         $warm1 = 0;// 1*1 数量
         $warm2 = 0;// 1*0.5数量
         $warm3 = 0;// 0.5*0.5数量
@@ -181,7 +379,7 @@ class WaterQueryController
                 }
             }
         }
-
+        //槽钢
         if ($data['is_channel'] > 0){
             if (ceil($long) == $long && ceil($wide) == $wide && ceil($high) == $high){
                 //都为整数
@@ -192,7 +390,29 @@ class WaterQueryController
                 $channel_number = $long * (ceil($wide) * 2 + 1) + $wide * 2;
             }
         }
-        halt($channel_number);
+        // 扶梯管
+        if ($data['is_human_ladder'] > 0){
+            if ($high <= 1.5){
+                $ladder = 5;
+            }elseif ($high == 2){
+                $ladder = 7;
+            }elseif ($high >= 2.5){
+                $ladder = $high * 4;
+            }
+        }
+        $calculation = [
+            'roof_number' => $roof_number,// 顶板
+            'floor_number' => $floor_number,// 底板
+            'side_number' => $side_number,// 侧板
+            'lacing_number' => $lacing_number,// 拉筋
+            'fula_number' => $fula_number,// 辅拉
+            'column_number' => $column_number,// 立柱
+            'warm' => ['warm1' => $warm1,'warm2' => $warm2,'warm3' => $warm3],// 保温
+            'channel_number' => $channel_number,// 槽钢
+            'ladder' => $ladder,// 保温
+        ];
+
+        return $calculation;
 
     }
 
@@ -206,24 +426,50 @@ class WaterQueryController
      */
     public function list()
     {
-        $data = UtilService::getMore(['is_gc']);
         $list = [];
-        if ($data['is_gc'] > 0){
-            $where[] = ['is_gc', '=' ,1];
-        }else{
-            $where[] = ['is_gc', '=' ,0];
-        }
-        $list['warm'] = WaterMaterialScience::field('id,name,unit_price,company')->where('type', 7)->where($where)->select(); // 保温
-        $list['channel'] =  WaterMaterialScience::field('id,name,unit_price,company')->where('type', 8)->where($where)->select(); // 槽钢
-        $list['roof'] =  WaterMaterialScience::field('id,name,unit_price,company')->where('type', 1)->where($where)->select();// 顶板
-        $list['side_plate'] =  WaterMaterialScience::field('id,name,unit_price,company')->where('type', 2)->where($where)->select();// 侧板
-        $list['lacing'] =  WaterMaterialScience::field('id,name,unit_price,company')->where('type', 3)->where($where)->select();// 拉筋
-        $list['floor'] =  WaterMaterialScience::field('id,name,unit_price,company')->where('type', 4)->where($where)->select(); // 底板
-        $list['column'] =  WaterMaterialScience::field('id,name,unit_price,company')->where('type', 5)->where($where)->select(); // 立柱
-        $list['fula'] =  WaterMaterialScience::field('id,name,unit_price,company')->where('type', 6)->where($where)->select(); // 辅拉
+        $list['warm'] = WaterCate::field('id,name')->where('type', 7)->select(); // 保温
+        $list['channel'] =  WaterCate::field('id,name')->where('type', 8)->select(); // 槽钢
+        $list['roof'] =  WaterCate::field('id,name')->where('type', 1)->select();// 顶板
+        $list['side_plate'] =  WaterCate::field('id,name')->where('type', 2)->select();// 侧板
+        $list['lacing'] =  WaterCate::field('id,name')->where('type', 3)->select();// 拉筋
+        $list['floor'] =  WaterCate::field('id,name')->where('type', 4)->select(); // 底板
+        $list['column'] =  WaterCate::field('id,name')->where('type', 5)->select(); // 立柱
+        $list['fula'] =  WaterCate::field('id,name')->where('type', 6)->select(); // 辅拉
 
         return app('json')->success($list);
     }
 
+    /**
+     * 计算记录
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function query_list(Request $request)
+    {
+        $list = WaterQuery::where('uid', $request->uid())->select();
+        $list = count($list) > 0 ? $list->toArray(): [];
+        return app('json')->success($list);
+    }
+
+    /**
+     * 计算详情
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function query_details(Request $request)
+    {
+        $data = UtilService::getMore(['id']);
+        if (!$data['id'])  return app('json')->fail('传入正确参数');
+
+        $list = WaterMaterial::where('query_id', $data['id'])->select();
+        return app('json')->success($list->toArray());
+    }
+
 
 }

+ 13 - 0
app/common.php

@@ -593,4 +593,17 @@ if (!function_exists('do_request')) {
         curl_close($curl);
         return $result;
     }
+
+
+    if (!function_exists('pr')) {
+        function pr($var, $int = '')
+        {
+            $template = PHP_SAPI !== 'cli' ? '<pre>%s</pre>' : "\n%s\n";
+            printf($template, print_r($var, true));
+            if (!empty($int)) {
+                exit($int);
+            }
+
+        }
+    }
 }

+ 3 - 1
route/api/route.php

@@ -163,7 +163,9 @@ Route::group(function () {
     Route::get('order/nopay', 'order.StoreOrderController/get_noPay')->name('getNoPay');//获取未支付订单
 
     //计算
-    Route::post('water/calculation', 'water.WaterQueryController/calculation')->name('waterquery');
+    Route::post('water/calculation', 'water.WaterQueryController/query')->name('waterquery');
+    Route::get('water/query_list', 'water.WaterQueryController/query_list')->name('query_list');// 计算记录
+    Route::get('water/query_details', 'water.WaterQueryController/query_details')->name('query_details');//计算详情
     //充值类
     Route::post('card/routine', 'user.UserCardController/routine')->name('CardRoutine');//小程序购买会员卡
     Route::post('card/wechat', 'user.UserCardController/wechat')->name('CardWechat');//公众号购买会员卡