123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 |
- <?php
- 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;
- /**
- * 秒杀产品类
- * Class StoreSeckillController
- * @package app\api\controller\activity
- */
- class WaterQueryController
- {
- public function query(Request $request)
- {
- $data = UtilService::postMore([
- ['long', ''],// 长
- ['wide', ''],// 宽
- ['high', ''],// 高
- ['is_warm', ''], // 是否保温
- ['is_channel', ''], // 是否需要槽钢
- ['is_human_ladder', ''] ,// 是否需要人梯
- ['is_gc', ''] ,// 公差
- ['roof', ''], // 顶板厚度
- ['floor', ''], // 底板厚度
- ['side_plate', []], // 侧板厚度
- ['column', ''], // 立柱厚度
- ['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'];
- $high_array = []; // 高度数组
- $roof_number = []; // 顶板数量
- $floor_number = []; // 底板数量
- $side_number = []; // 侧板数量
- $lacing_number = []; // 拉经数量
- $fula_number = [];//辅拉数量
- $column_number = 0;// 立柱数量
- $channel_number = 0; // 槽钢
- $ladder = 0;// 扶梯管米数
- for ($i = 0; $i < intval($high); $i++){
- $high_array[] = 1;
- }
- if (intval($high) != $high){
- $high_array = array_merge($high_array, [0.5]);
- }
- if (ceil($long) == $long && ceil($wide) == $wide && ceil($high) == $high){
- //都为整数
- $roof_number = ['1*1' => $long * $wide]; // 顶板数量
- $floor_number = ['1*1' => $long * $wide];// 底板数量
- foreach ($high_array as $item){
- $side_number[] = ['1*1' => (($item * $long) + ($item * $wide)) * 2];
- }
- }elseif (ceil($long) != $long && ceil($wide) != $wide && 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){
- if ($item >= 1){
- $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];
- }
- }
- }elseif (ceil($long) != $long || ceil($wide) != $wide || ceil($high) != $high){
- //一个整数
- if (ceil($long) != $long && ceil($wide) == $wide && 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){
- $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, '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, '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, '1*0.5' => 2];
- }else{
- $side_number[] = ['1*0.5' => ((intval($long)) + (intval($wide))) * 2, '0.5*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){
- if ($item >= 1){
- $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];
- }
- }
- }elseif (ceil($long) == $long && ceil($wide) == $wide and ceil($high) != $high){
- $roof_number = ['1*1' => $long * $wide]; // 顶板数量
- $floor_number = ['1*1' => $long * $wide];// 底板数量
- foreach ($high_array as $item){
- if ($item >= 1){
- $side_number[] = ['1*1' => ((intval($long)) + (intval($wide))) * 2];
- }else{
- $side_number[] = ['1*0.5' => ((intval($long)) + (intval($wide))) * 2];
- }
- }
- }
- }
- array_pop($high_array);// 删除最后一位,算出主拉层数
- // 拉筋
- foreach ($high_array as $item){
- $lacing_number[] = ceil((($long * (ceil($wide) - 1)) + ($wide * (ceil($long) - 1)))/2);
- }
- // 辅拉
- if ($high > 1){
- if ($high == 1.5){
- $fula_number = [2 * ( (ceil($long) - 1) + (ceil($wide) - 1) ) + 1];
- }elseif ($high == 2){
- $fula_number = [3 * ( (ceil($long) - 1) + (ceil($wide) - 1) ) + 1];
- }elseif ($high == 2.5){
- $fula_number = [
- 2 * ( (ceil($long) - 1) + (ceil($wide) - 1) ) + 1,
- 2 * ( (ceil($long) - 1) + (ceil($wide) - 1) ) + 1,
- ];
- }elseif ($high == 3){
- $fula_number = [
- 3 * ( (ceil($long) - 1) + (ceil($wide) - 1) ) + 1,
- 2 * ( (ceil($long) - 1) + (ceil($wide) - 1) ) + 1,
- ];
- }elseif ($high >= 3.5){
- foreach ($high_array as $item){
- $fula_number[] = 2 * ( (ceil($long) - 1) + (ceil($wide) - 1) ) + 1;
- }
- }
- }
- //立柱
- $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数量
- if ($data['is_warm'] > 0){
- foreach ($side_number as $item){
- // 侧板
- foreach ($item as $key => $value){
- if ($key == '1*1'){
- $warm1 += $value;
- }elseif ($key == '1*0.5'){
- $warm2 += $value;
- }elseif ($key == '0.5*0.5'){
- $warm3 += $value;
- }
- }
- }
- foreach ($floor_number as $key => $value){
- // 顶板
- if ($key == '1*1'){
- $warm1 += $value;
- }elseif ($key == '1*0.5'){
- $warm2 += $value;
- }elseif ($key == '0.5*0.5'){
- $warm3 += $value;
- }
- }
- }
- //槽钢
- if ($data['is_channel'] > 0){
- if (ceil($long) == $long && ceil($wide) == $wide && ceil($high) == $high){
- //都为整数
- $channel_number = $long * ($wide * 2 + 1) + $wide * 2;
- }elseif (ceil($long) != $long || ceil($wide) || $wide && ceil($high) || $high){
- //不为整数
- $channel_number = $long * (ceil($wide) * 2 + 1) + $wide * 2;
- }
- }
- // 扶梯管
- 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;
- }
- /**
- * 材料列表
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function list()
- {
- $list = [];
- $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());
- }
- }
|