WaterQueryController.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\api\controller\water;
  3. use app\admin\model\water\WaterMaterialScience;
  4. use app\Request;
  5. use crmeb\services\GroupDataService;
  6. use crmeb\services\QrcodeService;
  7. use crmeb\services\UtilService;
  8. /**
  9. * 秒杀产品类
  10. * Class StoreSeckillController
  11. * @package app\api\controller\activity
  12. */
  13. class WaterQueryController
  14. {
  15. public function calculation(Request $request)
  16. {
  17. $data = UtilService::postMore([
  18. ['long', ''],// 长
  19. ['wide', ''],// 宽
  20. ['high', ''],// 高
  21. ['is_warm', ''], // 是否保温
  22. ['is_channel', ''], // 是否需要槽钢
  23. ['is_human_ladder', ''] ,// 是否需要人梯
  24. ['is_gc', ''] ,// 公差
  25. ['floor', ''], // 底板厚度
  26. ['side_plate', ''], // 侧板厚度
  27. ['roof', ''], // 顶板厚度
  28. ['column', ''], // 立柱厚度
  29. ['lacing', ''], // 拉筋厚度
  30. ['fula', ''], // 辅拉
  31. ]);
  32. //顶板
  33. if ($data['is_gc'] > 0){
  34. $where[] = ['is_gc', '=' ,1];
  35. }else{
  36. $where[] = ['is_gc', '=' ,0];
  37. }
  38. $roof = WaterMaterialScience::where('id', $data['roof'])->find();
  39. $roofs = WaterMaterialScience::where('type', 1)->where('th_id', $roof['th_id'])->where($where)->column('long,wide', 'id');//符合厚度的顶板
  40. $area = $data['long'] * $data['wide'];// 面积
  41. $roof_number = ($data['long']/1) * intval(($data['wide']/1)); // 顶板使用数量1*1
  42. halt($roof_number);
  43. }
  44. /**
  45. * 材料列表
  46. * @return mixed
  47. * @throws \think\db\exception\DataNotFoundException
  48. * @throws \think\db\exception\DbException
  49. * @throws \think\db\exception\ModelNotFoundException
  50. */
  51. public function list()
  52. {
  53. $data = UtilService::getMore(['is_gc']);
  54. $list = [];
  55. if ($data['is_gc'] > 0){
  56. $where[] = ['is_gc', '=' ,1];
  57. }else{
  58. $where[] = ['is_gc', '=' ,0];
  59. }
  60. $list['warm'] = WaterMaterialScience::field('id,name,unit_price,company')->where('type', 7)->where($where)->select(); // 保温
  61. $list['channel'] = WaterMaterialScience::field('id,name,unit_price,company')->where('type', 8)->where($where)->select(); // 槽钢
  62. $list['roof'] = WaterMaterialScience::field('id,name,unit_price,company')->where('type', 1)->where($where)->select();// 顶板
  63. $list['side_plate'] = WaterMaterialScience::field('id,name,unit_price,company')->where('type', 2)->where($where)->select();// 侧板
  64. $list['lacing'] = WaterMaterialScience::field('id,name,unit_price,company')->where('type', 3)->where($where)->select();// 拉筋
  65. $list['floor'] = WaterMaterialScience::field('id,name,unit_price,company')->where('type', 4)->where($where)->select(); // 底板
  66. $list['column'] = WaterMaterialScience::field('id,name,unit_price,company')->where('type', 5)->where($where)->select(); // 立柱
  67. $list['fula'] = WaterMaterialScience::field('id,name,unit_price,company')->where('type', 6)->where($where)->select(); // 辅拉
  68. return app('json')->success($list);
  69. }
  70. }