SearchController.php 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Model\Adminuser;
  4. use App\Model\Project;
  5. use App\Model\Table_eight;
  6. use App\Model\Table_five;
  7. use App\Model\Table_four;
  8. use App\Model\Table_nine;
  9. use App\Model\Table_one;
  10. use App\Model\Table_seven;
  11. use App\Model\Table_six;
  12. use App\Model\Table_three;
  13. use App\Model\Table_two;
  14. use App\Model\Tablelist;
  15. use App\Http\Controllers\Admin\CommonController;
  16. use App\Model\User;
  17. use Illuminate\Support\Facades\DB;
  18. use Session;
  19. use Symfony\Component\HttpFoundation\Request;
  20. class SearchController extends CommonController
  21. {
  22. public function table_search(Request $request,$table_type_id)
  23. {
  24. $user_data = User::where('role','=','0')->get();
  25. $input = $request->all();
  26. if (isset($table_type_id)) {
  27. switch ($table_type_id) {
  28. case 1:
  29. $table_name = '国有土地房屋征收与补偿安置单(货币化安置)';
  30. $th = [
  31. '1' => '姓名',
  32. '2' => '购买存量房面积',
  33. '3' => '拆迁补偿总金额',
  34. '4' => '购买存量房总价格',
  35. '5' => '应交总差额',
  36. '6' => '应退总差额'
  37. ];
  38. //都不搜索 显示表单姓名
  39. if(empty($input['user_id']) && empty($input['project_id']))
  40. {
  41. $table = Table_one::query()
  42. ->where('status','>','1')
  43. ->groupBy('bzc_name')
  44. ->selectRaw('bzc_name')
  45. ->selectRaw('SUM(home_area+money_bus_area) as area')
  46. ->selectRaw('SUM(total_money) as total_money')
  47. ->selectRaw('SUM(money_home_price+money_bus_price) as price')
  48. ->selectRaw('SUM(money_home_jchae+money_bus_jchae) as jchae ')
  49. ->selectRaw('SUM(money_home_tchae+money_bus_tchae) as tchae')
  50. ;
  51. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  52. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  53. $table = $table->get();
  54. }
  55. //搜索录入人 显示收录人
  56. if(!empty($input['user_id'])&& empty($input['project_id']))
  57. {
  58. $table = Table_one::query()
  59. ->where('status','>','1')
  60. ->where('user_id','=',$input['user_id'])
  61. ->groupBy('id')
  62. ->selectRaw('user_id')
  63. ->selectRaw('SUM(home_area+money_bus_area) as area')
  64. ->selectRaw('SUM(total_money) as total_money')
  65. ->selectRaw('SUM(money_home_price+money_bus_price) as price')
  66. ->selectRaw('SUM(money_home_jchae+money_bus_jchae) as jchae ')
  67. ->selectRaw('SUM(money_home_tchae+money_bus_tchae) as tchae')
  68. ;
  69. $th[1] = '收录人';
  70. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  71. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  72. $table = $table->get();
  73. foreach($table as $value){
  74. $value['bzc_name'] = User::where('id','=',$value['user_id'])->first()->surname;
  75. }
  76. }
  77. //搜索项目 显示项目名
  78. if(!empty($input['project_id']) && empty($input['user_id'])){
  79. $table = Table_one::query()
  80. ->where('project_id','=',$input['project_id'])
  81. ->where('status','>','1')
  82. ->groupBy('id')
  83. ->selectRaw('project_id')
  84. ->selectRaw('SUM(home_area+money_bus_area) as area')
  85. ->selectRaw('SUM(total_money) as total_money')
  86. ->selectRaw('SUM(money_home_price+money_bus_price) as price')
  87. ->selectRaw('SUM(money_home_jchae+money_bus_jchae) as jchae ')
  88. ->selectRaw('SUM(money_home_tchae+money_bus_tchae) as tchae')
  89. ;
  90. $th[1] = '项目';
  91. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  92. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  93. $table = $table->get();
  94. foreach($table as $value){
  95. $value['bzc_name'] = Project::where('id','=',$value['project_id'])->first()->project_name;
  96. }
  97. }
  98. //搜索收录人 项目名 显示收录人
  99. if(!empty($input['project_id']) && !empty($input['user_id'])){
  100. $table = Table_one::query()
  101. ->where('status','>','1')
  102. ->where('user_id','=',$input['user_id'])
  103. ->where('project_id','=',$input['project_id'])
  104. ->groupBy('id')
  105. ->selectRaw('user_id')
  106. ->selectRaw('SUM(home_area+money_bus_area) as area')
  107. ->selectRaw('SUM(total_money) as total_money')
  108. ->selectRaw('SUM(money_home_price+money_bus_price) as price')
  109. ->selectRaw('SUM(money_home_jchae+money_bus_jchae) as jchae ')
  110. ->selectRaw('SUM(money_home_tchae+money_bus_tchae) as tchae')
  111. ;
  112. $th[1] = '收录人';
  113. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  114. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  115. $table = $table->get();
  116. foreach($table as $value){
  117. $value['bzc_name'] = User::where('id','=',$value['user_id'])->first()->surname;
  118. }
  119. }
  120. return view('admin.sta.sta_one', compact('user_data','table_name', 'table', 'th', 'table_type_id'));
  121. break;
  122. case 2:
  123. $table_name = '违章建筑自行拆除费用申领表';
  124. $th = [
  125. '1' => '姓名',
  126. '2' => '违章面积',
  127. '3' => '拆除金额',
  128. ];
  129. if(empty($input['user_id']) && empty($input['project_id'])){
  130. $table = Table_two::query()
  131. ->where('status','>','1')
  132. ->groupBy('bzc_name')
  133. ->selectRaw('bzc_name')
  134. ->selectRaw('SUM(bzc_area) as area')
  135. ->selectRaw('SUM(chaichuje)as money')
  136. ;
  137. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  138. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  139. $table = $table->get();
  140. }
  141. if(!empty($input['user_id'])&& empty($input['project_id'])){
  142. $table = Table_two::query()
  143. ->where('status','>','1')
  144. ->where('user_id','=',$input['user_id'])
  145. ->groupBy('id')
  146. ->selectRaw('user_id')
  147. ->selectRaw('SUM(bzc_area) as area')
  148. ->selectRaw('SUM(chaichuje)as money')
  149. ;
  150. $th[1] = '收录人';
  151. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  152. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  153. $table = $table->get();
  154. foreach($table as $value){
  155. $value['bzc_name'] = User::where('id','=',$value['user_id'])->first()->surname;
  156. }
  157. }
  158. if(!empty($input['project_id']) && empty($input['user_id'])){
  159. $table = Table_two::query()
  160. ->where('status','>','1')
  161. ->where('project_id','=',$input['project_id'])
  162. ->groupBy('id')
  163. ->selectRaw('project_id')
  164. ->selectRaw('SUM(bzc_area) as area')
  165. ->selectRaw('SUM(chaichuje)as money')
  166. ;
  167. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  168. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  169. $table = $table->get();
  170. foreach($table as $value){
  171. $value['bzc_name'] = Project::where('id','=',$value['project_id'])->first()->project_name;
  172. }
  173. }
  174. if(!empty($input['project_id']) && !empty($input['user_id'])){
  175. $table = Table_three::query()
  176. ->where('status','>','1')
  177. ->where('user_id','=',$input['user_id'])
  178. ->where('project_id','=',$input['project_id'])
  179. ->groupBy('id')
  180. ->selectRaw('user_id')
  181. ->selectRaw('SUM(bzc_area) as area')
  182. ->selectRaw('SUM(chaichuje)as money')
  183. ;
  184. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  185. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  186. $table = $table->get();
  187. foreach($table as $value){
  188. $value['bzc_name'] = User::where('id','=',$value['user_id'])->first()->surname;
  189. }
  190. }
  191. return view('admin.sta.sta_two', compact('table_type_id','user_data','table_name', 'table', 'th'));
  192. break;
  193. case 3:
  194. $table_name = '残疾人房征补贴审批确认单';
  195. $th = [
  196. '1' => '姓名',
  197. '2' => '残疾人补贴',
  198. '3' => '临时安置补贴 ',
  199. '4' => '搬迁补贴',
  200. '5' => '合计'
  201. ];
  202. if(empty($input['user_id']) && empty($input['project_id'])){
  203. $table = Table_three::query()
  204. ->where('status','>','1')
  205. ->groupBy('bzc_name')
  206. ->selectRaw('bzc_name')
  207. ->selectRaw('SUM(canbu) as canbu')
  208. ->selectRaw('SUM(linshibu)as linshibu')
  209. ->selectRaw('SUM(banqianbu) as banqianbu')
  210. ->selectRaw('SUM(total) as total')
  211. ;
  212. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  213. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  214. $table = $table->get();
  215. }
  216. if(!empty($input['user_id'])&& empty($input['project_id'])){
  217. $table = Table_three::query()
  218. ->where('status','>','1')
  219. ->where('user_id','=',$input['user_id'])
  220. ->groupBy('id')
  221. ->selectRaw('user_id')
  222. ->selectRaw('SUM(canbu) as canbu')
  223. ->selectRaw('SUM(linshibu)as linshibu')
  224. ->selectRaw('SUM(banqianbu) as banqianbu')
  225. ->selectRaw('SUM(total) as total')
  226. ;
  227. $th[1] = '收录人';
  228. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  229. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  230. $table = $table->get();
  231. foreach($table as $value){
  232. $value['bzc_name'] = User::where('id','=',$value['user_id'])->first()->surname;
  233. }
  234. }
  235. if(!empty($input['project_id']) && empty($input['user_id'])){
  236. $table = Table_three::query()
  237. ->where('status','>','1')
  238. ->where('project_id','=',$input['project_id'])
  239. ->groupBy('id')
  240. ->selectRaw('project_id')
  241. ->selectRaw('SUM(canbu) as canbu')
  242. ->selectRaw('SUM(linshibu)as linshibu')
  243. ->selectRaw('SUM(banqianbu) as banqianbu')
  244. ->selectRaw('SUM(total) as total')
  245. ;
  246. $th[1] = '项目';
  247. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  248. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  249. $table = $table->get();
  250. foreach($table as $value){
  251. $value['bzc_name'] = Project::where('id','=',$value['project_id'])->first()->project_name;
  252. }
  253. }
  254. if(!empty($input['project_id']) && !empty($input['user_id'])){
  255. $table = Table_three::query()
  256. ->where('status','>','1')
  257. ->where('project_id','=',$input['project_id'])
  258. ->where('user_id','=',$input['user_id'])
  259. ->groupBy('id')
  260. ->selectRaw('project_id')
  261. ->selectRaw('SUM(canbu) as canbu')
  262. ->selectRaw('SUM(linshibu)as linshibu')
  263. ->selectRaw('SUM(banqianbu) as banqianbu')
  264. ->selectRaw('SUM(total) as total')
  265. ;
  266. $th[1] = '收录人';
  267. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  268. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  269. $table = $table->get();
  270. foreach($table as $value){
  271. $value['bzc_name'] = User::where('id','=',$value['user_id'])->first()->surname;
  272. }
  273. }
  274. return view('admin.sta.sta_three', compact('table_type_id','user_data','user_data','table_name', 'table', 'th'));
  275. break;
  276. case 4:
  277. $table_name = '房屋征收提前搬迁奖励单';
  278. $th = [
  279. '1' => '姓名',
  280. '2' => '全额奖励',
  281. '3' => '差额奖励金',
  282. '4' => '同住奖励',
  283. '5' => '奖励总金额',
  284. ];
  285. if(empty($input['user_id']) && empty($input['project_id'])){
  286. $table = Table_four::query()
  287. ->where('status','>','1')
  288. ->groupBy('bzc_name')
  289. ->selectRaw('bzc_name')
  290. ->selectRaw('SUM(quanj) as quanj')
  291. ->selectRaw('SUM(chaj)as chaj')
  292. ->selectRaw('SUM(tongj) as tongj')
  293. ->selectRaw('SUM(zongj) as zongj')
  294. ;
  295. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  296. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  297. $table = $table->get();
  298. }
  299. if(!empty($input['user_id'])&& empty($input['project_id'])){
  300. $table = Table_four::query()
  301. ->where('status','>','1')
  302. ->where('user_id','=',$input['user_id'])
  303. ->groupBy('id')
  304. ->selectRaw('user_id')
  305. ->selectRaw('SUM(quanj) as quanj')
  306. ->selectRaw('SUM(chaj)as chaj')
  307. ->selectRaw('SUM(tongj) as tongj')
  308. ->selectRaw('SUM(zongj) as zongj')
  309. ;
  310. $th[1] = '收录人';
  311. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  312. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  313. $table = $table->get();
  314. foreach($table as $value){
  315. $value['bzc_name'] = User::where('id','=',$value['user_id'])->first()->surname;
  316. }
  317. }
  318. if(!empty($input['project_id']) && empty($input['user_id'])){
  319. $table = Table_four::query()
  320. ->where('status','>','1')
  321. ->where('project_id','=',$input['project_id'])
  322. ->groupBy('id')
  323. ->selectRaw('project_id')
  324. ->selectRaw('SUM(quanj) as quanj')
  325. ->selectRaw('SUM(chaj)as chaj')
  326. ->selectRaw('SUM(tongj) as tongj')
  327. ->selectRaw('SUM(zongj) as zongj')
  328. ;
  329. $th[1] = '项目';
  330. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  331. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  332. $table = $table->get();
  333. foreach($table as $value){
  334. $value['bzc_name'] = Project::where('id','=',$value['project_id'])->first()->project_name;
  335. }
  336. }
  337. if(!empty($input['project_id']) && !empty($input['user_id'])){
  338. $table = Table_four::query()
  339. ->where('status','>','1')
  340. ->where('project_id','=',$input['project_id'])
  341. ->where('user_id','=',$input['user_id'])
  342. ->groupBy('id')
  343. ->selectRaw('user_id')
  344. ->selectRaw('SUM(quanj) as quanj')
  345. ->selectRaw('SUM(chaj)as chaj')
  346. ->selectRaw('SUM(tongj) as tongj')
  347. ->selectRaw('SUM(zongj) as zongj')
  348. ;
  349. $th[1] = '收录人';
  350. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  351. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  352. $table = $table->get();
  353. foreach($table as $value){
  354. $value['bzc_name'] = User::where('id','=',$value['user_id'])->first()->surname;
  355. }
  356. }
  357. return view('admin.sta.sta_four', compact('table_type_id','user_data','table_name', 'table', 'th'));
  358. break;
  359. case 5:
  360. $table_name = '逾期过渡安置补助费发放单';
  361. $th = [
  362. '1' => '姓名',
  363. '2' => '逾期月数',
  364. '3' => '补助合计',
  365. '4' => '逾期补偿金',
  366. ];
  367. if(empty($input['user_id']) && empty($input['project_id'])){
  368. $table = Table_five::query()
  369. ->where('status','>','1')
  370. ->groupBy('bzc_name')
  371. ->selectRaw('bzc_name')
  372. ->selectRaw('SUM(yuqi_mothe1+yuqi_mothe2+yuqi_mothe3+yuqi_mothe4) as yuqi_mothe')
  373. ->selectRaw('SUM(total1+total2+total3+total4)as total')
  374. ->selectRaw('SUM(yuqij) as yuqij')
  375. ;
  376. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  377. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  378. $table = $table->get();
  379. }
  380. if(!empty($input['user_id'])&& empty($input['project_id'])){
  381. $table = Table_five::query()
  382. ->where('status','>','1')
  383. ->where('user_id','=',$input['user_id'])
  384. ->groupBy('id')
  385. ->selectRaw('user_id')
  386. ->selectRaw('SUM(yuqi_mothe1+yuqi_mothe2+yuqi_mothe3+yuqi_mothe4) as yuqi_mothe')
  387. ->selectRaw('SUM(total1+total2+total3+total4)as total')
  388. ->selectRaw('SUM(yuqij) as yuqij')
  389. ;
  390. $th = '收录人';
  391. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  392. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  393. $table = $table->get();
  394. foreach($table as $value){
  395. $value['bzc_name'] = User::where('id','=',$input['user_id'])->first()->surname;
  396. }
  397. }
  398. if(!empty($input['project_id']) && empty($input['user_id'])){
  399. $table = Table_five::query()
  400. ->where('status','>','1')
  401. ->where('project_id','=',$input['project_id'])
  402. ->groupBy('id')
  403. ->selectRaw('project_id')
  404. ->selectRaw('SUM(yuqi_mothe1+yuqi_mothe2+yuqi_mothe3+yuqi_mothe4) as yuqi_mothe')
  405. ->selectRaw('SUM(total1+total2+total3+total4)as total')
  406. ->selectRaw('SUM(yuqij) as yuqij')
  407. ;
  408. $th = '项目';
  409. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  410. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  411. $table = $table->get();
  412. foreach($table as $value){
  413. $value['bzc_name'] = Project::where('id','=',$input['project_id'])->first()->project_name;
  414. }
  415. }
  416. if(!empty($input['project_id']) && !empty($input['user_id'])){
  417. $table = Table_five::query()
  418. ->where('status','>','1')
  419. ->where('user_id','=',$input['user_id'])
  420. ->where('project_id','=',$input['project_id'])
  421. ->groupBy('id')
  422. ->selectRaw('user_id')
  423. ->selectRaw('SUM(yuqi_mothe1+yuqi_mothe2+yuqi_mothe3+yuqi_mothe4) as yuqi_mothe')
  424. ->selectRaw('SUM(total1+total2+total3+total4)as total')
  425. ->selectRaw('SUM(yuqij) as yuqij')
  426. ;
  427. $th = '收录人';
  428. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  429. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  430. $table = $table->get();
  431. foreach($table as $value){
  432. $value['bzc_name'] = User::where('id','=',$input['user_id'])->first()->surname;
  433. }
  434. }
  435. return view('admin.sta.sta_five', compact('table_type_id','user_data','table_name', 'table', 'th'));
  436. break;
  437. case 6:
  438. $table_name = '房屋征收安置补贴单';
  439. $th = [
  440. '1' => '姓名',
  441. '2' => '临时安置费',
  442. '3' => '搬迁费',
  443. '4' => '低保补贴',
  444. '5' => '其他',
  445. '6' => '补贴总金额',
  446. ];
  447. if(empty($input['user_id']) && empty($input['project_id'])){
  448. $table = Table_six::query()
  449. ->where('status','>','1')
  450. ->groupBy('bzc_name')
  451. ->selectRaw('bzc_name')
  452. ->selectRaw('SUM(anzhi) as anzhi')
  453. ->selectRaw('SUM(banqian)as banqian')
  454. ->selectRaw('SUM(dibu) as dibu')
  455. ->selectRaw('SUM(other) as other')
  456. ->selectRaw('SUM(totalj) as totalj')
  457. ;
  458. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  459. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  460. $table = $table->get();
  461. }
  462. if(!empty($input['user_id'])&& empty($input['project_id'])){
  463. $table = Table_six::query()
  464. ->where('status','>','1')
  465. ->where('user_id','=',$input['user_id'])
  466. ->groupBy('id')
  467. ->selectRaw('user_id')
  468. ->selectRaw('SUM(anzhi) as anzhi')
  469. ->selectRaw('SUM(banqian)as banqian')
  470. ->selectRaw('SUM(dibu) as dibu')
  471. ->selectRaw('SUM(other) as other')
  472. ->selectRaw('SUM(totalj) as totalj')
  473. ;
  474. $th[1] = '收录人';
  475. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  476. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  477. $table = $table->get();
  478. foreach($table as $value){
  479. $value['bzc_name'] = User::where('id','=',$input['user_id'])->first()->surname;
  480. }
  481. }
  482. if(!empty($input['project_id']) && empty($input['user_id'])){
  483. $table = Table_six::query()
  484. ->where('status','>','1')
  485. ->where('project_id','=',$input['project_id'])
  486. ->groupBy('id')
  487. ->selectRaw('project_id')
  488. ->selectRaw('SUM(anzhi) as anzhi')
  489. ->selectRaw('SUM(banqian)as banqian')
  490. ->selectRaw('SUM(dibu) as dibu')
  491. ->selectRaw('SUM(other) as other')
  492. ->selectRaw('SUM(totalj) as totalj')
  493. ;
  494. $th[1] = '项目';
  495. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  496. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  497. $table = $table->get();
  498. foreach($table as $value){
  499. $value['bzc_name'] = Project::where('id','=',$input['project_id'])->first()->project_name;
  500. }
  501. }
  502. if(!empty($input['project_id']) && !empty($input['user_id'])){
  503. $table = Table_six::query()
  504. ->where('status','>','1')
  505. ->where('project_id','=',$input['project_id'])
  506. ->where('user_id','=',$input['user_id'])
  507. ->groupBy('id')
  508. ->selectRaw('user_id')
  509. ->selectRaw('SUM(anzhi) as anzhi')
  510. ->selectRaw('SUM(banqian)as banqian')
  511. ->selectRaw('SUM(dibu) as dibu')
  512. ->selectRaw('SUM(other) as other')
  513. ->selectRaw('SUM(totalj) as totalj')
  514. ;
  515. $th[1] = '收录人';
  516. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  517. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  518. $table = $table->get();
  519. foreach($table as $value){
  520. $value['bzc_name'] = User::where('id','=',$input['user_id'])->first()->surname;
  521. }
  522. }
  523. return view('admin.sta.sta_six', compact('table_type_id','user_data','table_name', 'table', 'th'));
  524. break;
  525. case 7:
  526. $table_name = '核算单(货币化安置)';
  527. $th = [
  528. '1' => '姓名',
  529. '2' => '住宅有证面积可置换住宅面积',
  530. '3' => '住宅有证面积可置换商业面积',
  531. '4' => '住宅有证面积房务补偿',
  532. '5' => '无证面积可置换住宅面积',
  533. '6' => '无证面积可置换商业面积',
  534. '7' => '无证面积房务补偿',
  535. ];
  536. $th1 = [
  537. '1' => '姓名',
  538. '2' => '其中住改非可置换住宅面积',
  539. '3' => '其中住改非可置换商业面积',
  540. '4' => '其中住改非房务补偿',
  541. '5' => '商业有证面积可置换住宅面积',
  542. '6' => '商业有证面积可置换商业面积',
  543. '7' => '商业有证面积房务补偿',
  544. ];
  545. $th2 = [
  546. '1' => '姓名',
  547. '2' => '其他项可置换住宅面积',
  548. '3' => '其他项可置换商业面积',
  549. '4' => '其他项房务补偿',
  550. '5' => '可置换住宅面积小计',
  551. '6' => '可置换商业面积小计',
  552. '7' => '房务补偿小计',
  553. ];
  554. $th3 = [
  555. '1' => '姓名',
  556. '2' => '装修补偿额',
  557. '3' => '庭院补偿额',
  558. '4' => '停产停业损失补偿额',
  559. '5' => '构筑物及其他补偿金',
  560. '6' => '拆迁补偿总金额',
  561. ];
  562. if(empty($input['user_id']) && empty($input['project_id'])){
  563. $table = Table_seven::query()
  564. ->where('status','>','1')
  565. ->groupBy('bzc_name')
  566. ->selectRaw('bzc_name')
  567. ->selectRaw('SUM(bzc_area) as bzc_area')->selectRaw('SUM(data2)as data2')
  568. ->selectRaw('SUM(data3+data4) as data3')->selectRaw('SUM(data5) as data5')
  569. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data7+data8) as data7')
  570. ->selectRaw('SUM(data9) as data9')->selectRaw('SUM(data10) as data10')
  571. ->selectRaw('SUM(data11+data12) as data11')->selectRaw('SUM(data13) as data13')
  572. ->selectRaw('SUM(data14) as data14')->selectRaw('SUM(data15+data16) as data15')
  573. ->selectRaw('SUM(data17) as data17')->selectRaw('SUM(data18) as data18')
  574. ->selectRaw('SUM(data19+data20) as data19')->selectRaw('SUM(data21) as data21')
  575. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data23+data24) as data23')
  576. ->selectRaw('SUM(data25) as data25')->selectRaw('SUM(data26) as data26')
  577. ->selectRaw('SUM(data27) as data27')->selectRaw('SUM(data42) as data42')
  578. ->selectRaw('SUM(data43) as data43')
  579. ;
  580. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  581. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  582. $table = $table->get();
  583. }
  584. if(!empty($input['user_id'])&& empty($input['project_id'])){
  585. $table = Table_seven::query()
  586. ->where('status','>','1')
  587. ->where('user_id','=',$input['user_id'])
  588. ->groupBy('id')
  589. ->selectRaw('user_id')
  590. ->selectRaw('SUM(bzc_area) as bzc_area')->selectRaw('SUM(data2)as data2')
  591. ->selectRaw('SUM(data3+data4) as data3')->selectRaw('SUM(data5) as data5')
  592. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data7+data8) as data7')
  593. ->selectRaw('SUM(data9) as data9')->selectRaw('SUM(data10) as data10')
  594. ->selectRaw('SUM(data11+data12) as data11')->selectRaw('SUM(data13) as data13')
  595. ->selectRaw('SUM(data14) as data14')->selectRaw('SUM(data15+data16) as data15')
  596. ->selectRaw('SUM(data17) as data17')->selectRaw('SUM(data18) as data18')
  597. ->selectRaw('SUM(data19+data20) as data19')->selectRaw('SUM(data21) as data21')
  598. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data23+data24) as data23')
  599. ->selectRaw('SUM(data25) as data25')->selectRaw('SUM(data26) as data26')
  600. ->selectRaw('SUM(data27) as data27')->selectRaw('SUM(data42) as data42')
  601. ->selectRaw('SUM(data43) as data43')
  602. ;
  603. $th[1] = '收录人';
  604. $th1[1] = '收录人';
  605. $th2[1] = '收录人';
  606. $th3[1] = '收录人';
  607. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  608. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  609. $table = $table->get();
  610. foreach($table as $value){
  611. $value['bzc_name'] = User::where('id','=',$input['user_id'])->first()->surname;
  612. }
  613. }
  614. if(!empty($input['project_id']) && empty($input['user_id'])){
  615. $table = Table_seven::query()
  616. ->where('status','>','1')
  617. ->where('project_id','=',$input['project_id'])
  618. ->groupBy('id')
  619. ->selectRaw('project_id')
  620. ->selectRaw('SUM(bzc_area) as bzc_area')->selectRaw('SUM(data2)as data2')
  621. ->selectRaw('SUM(data3+data4) as data3')->selectRaw('SUM(data5) as data5')
  622. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data7+data8) as data7')
  623. ->selectRaw('SUM(data9) as data9')->selectRaw('SUM(data10) as data10')
  624. ->selectRaw('SUM(data11+data12) as data11')->selectRaw('SUM(data13) as data13')
  625. ->selectRaw('SUM(data14) as data14')->selectRaw('SUM(data15+data16) as data15')
  626. ->selectRaw('SUM(data17) as data17')->selectRaw('SUM(data18) as data18')
  627. ->selectRaw('SUM(data19+data20) as data19')->selectRaw('SUM(data21) as data21')
  628. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data23+data24) as data23')
  629. ->selectRaw('SUM(data25) as data25')->selectRaw('SUM(data26) as data26')
  630. ->selectRaw('SUM(data27) as data27')->selectRaw('SUM(data42) as data42')
  631. ->selectRaw('SUM(data43) as data43')
  632. ;
  633. $th[1] = '项目';
  634. $th1[1] = '项目';
  635. $th2[1] = '项目';
  636. $th3[1] = '项目';
  637. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  638. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  639. $table = $table->get();
  640. foreach($table as $value){
  641. $value['bzc_name'] = Project::where('id','=',$input['project_id'])->first()->project_name;
  642. }
  643. }
  644. if(!empty($input['project_id']) && !empty($input['user_id'])){
  645. $table = Table_seven::query()
  646. ->where('status','>','1')
  647. ->where('project_id','=',$input['project_id'])
  648. ->where('user_id','=',$input['user_id'])
  649. ->groupBy('id')
  650. ->selectRaw('user_id')
  651. ->selectRaw('SUM(bzc_area) as bzc_area')->selectRaw('SUM(data2)as data2')
  652. ->selectRaw('SUM(data3+data4) as data3')->selectRaw('SUM(data5) as data5')
  653. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data7+data8) as data7')
  654. ->selectRaw('SUM(data9) as data9')->selectRaw('SUM(data10) as data10')
  655. ->selectRaw('SUM(data11+data12) as data11')->selectRaw('SUM(data13) as data13')
  656. ->selectRaw('SUM(data14) as data14')->selectRaw('SUM(data15+data16) as data15')
  657. ->selectRaw('SUM(data17) as data17')->selectRaw('SUM(data18) as data18')
  658. ->selectRaw('SUM(data19+data20) as data19')->selectRaw('SUM(data21) as data21')
  659. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data23+data24) as data23')
  660. ->selectRaw('SUM(data25) as data25')->selectRaw('SUM(data26) as data26')
  661. ->selectRaw('SUM(data27) as data27')->selectRaw('SUM(data42) as data42')
  662. ->selectRaw('SUM(data43) as data43')
  663. ;
  664. $th[1] = '收录人';
  665. $th1[1] = '收录人';
  666. $th2[1] = '收录人';
  667. $th3[1] = '收录人';
  668. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  669. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  670. $table = $table->get();
  671. foreach($table as $value){
  672. $value['bzc_name'] = User::where('id','=',$input['user_id'])->first()->suranme;
  673. }
  674. }
  675. return view('admin.sta.sta_seven', compact('table_type_id','user_data','table_name', 'table', 'th', 'th1', 'th2', 'th3'));
  676. break;
  677. case 8:
  678. $table_name = '核算单(产权调换)';
  679. $th = [
  680. '1' => '姓名',
  681. '2' => '住宅有证面积可置换住宅面积',
  682. '3' => '住宅有证面积可置换商业面积',
  683. '4' => '住宅有证面积房务补偿',
  684. '5' => '无证面积可置换住宅面积',
  685. '6' => '无证面积可置换商业面积',
  686. '7' => '无证面积房务补偿',
  687. ];
  688. $th1 = [
  689. '1' => '姓名',
  690. '2' => '其中住改非可置换住宅面积',
  691. '3' => '其中住改非可置换商业面积',
  692. '4' => '其中住改非房务补偿',
  693. '5' => '商业有证面积可置换住宅面积',
  694. '6' => '商业有证面积可置换商业面积',
  695. '7' => '商业有证面积房务补偿',
  696. ];
  697. $th2 = [
  698. '1' => '姓名',
  699. '2' => '其他项可置换住宅面积',
  700. '3' => '其他项可置换商业面积',
  701. '4' => '其他项房务补偿',
  702. '5' => '可置换住宅面积小计',
  703. '6' => '可置换商业面积小计',
  704. '7' => '房务补偿小计',
  705. ];
  706. $th3 = [
  707. '1' => '姓名',
  708. '2' => '装修补偿额',
  709. '3' => '庭院补偿额',
  710. '4' => '停产停业损失补偿额',
  711. '5' => '构筑物及其他补偿金',
  712. '6' => '拆迁补偿总金额',
  713. ];
  714. $th4 = [
  715. '1' => '姓名',
  716. '2' => '住宅可调换面积',
  717. '3' => '住宅实际调换面积',
  718. '4' => '住宅大于可调换面积',
  719. '5' => '住宅可调换面积价格核算',
  720. '6' => '住宅大于可调换面积价格核算',
  721. '7' => '住宅调换房屋价格',
  722. ];
  723. $th5 = [
  724. '1' => '姓名',
  725. '2' => '商业可调换面积',
  726. '3' => '商业实际调换面积',
  727. '4' => '商业大于可调换面积',
  728. '5' => '商业可调换面积价格核算',
  729. '6' => '商业大于可调换面积价格核算',
  730. '7' => '商业调换房屋价格',
  731. '8' => '应退差额',
  732. '9' => '应缴差额',
  733. ];
  734. if(empty($input['user_id']) && empty($input['project_id'])){
  735. $table = Table_eight::query()
  736. ->where('status','>','1')
  737. ->groupBy('bzc_name')
  738. ->selectRaw('bzc_name')
  739. ->selectRaw('SUM(bzc_area) as bzc_area')->selectRaw('SUM(data2)as data2')
  740. ->selectRaw('SUM(data3+data4) as data3')->selectRaw('SUM(data5) as data5')
  741. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data7+data8) as data7')
  742. ->selectRaw('SUM(data9) as data9')->selectRaw('SUM(data10) as data10')
  743. ->selectRaw('SUM(data11+data12) as data11')->selectRaw('SUM(data13) as data13')
  744. ->selectRaw('SUM(data14) as data14')->selectRaw('SUM(data15+data16) as data15')
  745. ->selectRaw('SUM(data17) as data17')->selectRaw('SUM(data18) as data18')
  746. ->selectRaw('SUM(data19+data20) as data19')->selectRaw('SUM(data21) as data21')
  747. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data23+data24) as data23')
  748. ->selectRaw('SUM(data25) as data25')->selectRaw('SUM(data26) as data26')
  749. ->selectRaw('SUM(data27) as data27')->selectRaw('SUM(data42) as data42')
  750. ->selectRaw('SUM(data43) as data43')->selectRaw('SUM(home_area) as home_area')
  751. ->selectRaw('SUM(data50) as data50')->selectRaw('SUM(data51) as data51')
  752. ->selectRaw('SUM(data52) as data52')->selectRaw('SUM(data57) as data57')
  753. ->selectRaw('SUM(data58) as data58')->selectRaw('SUM(data53) as data53')
  754. ->selectRaw('SUM(data54) as data54')->selectRaw('SUM(data55) as data55')
  755. ->selectRaw('SUM(data56) as data56')->selectRaw('SUM(data61) as data61')
  756. ->selectRaw('SUM(data62) as data62')->selectRaw('SUM(data59) as data59')
  757. ->selectRaw('SUM(data60) as data60')
  758. ;
  759. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  760. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  761. $table = $table->get();
  762. }
  763. if(!empty($input['user_id'])&& empty($input['project_id'])){
  764. $table = Table_eight::query()
  765. ->where('status','>','1')
  766. ->where('user_id','=',$input['user_id'])
  767. ->groupBy('id')
  768. ->selectRaw('user_id')
  769. ->selectRaw('SUM(bzc_area) as bzc_area')->selectRaw('SUM(data2)as data2')
  770. ->selectRaw('SUM(data3+data4) as data3')->selectRaw('SUM(data5) as data5')
  771. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data7+data8) as data7')
  772. ->selectRaw('SUM(data9) as data9')->selectRaw('SUM(data10) as data10')
  773. ->selectRaw('SUM(data11+data12) as data11')->selectRaw('SUM(data13) as data13')
  774. ->selectRaw('SUM(data14) as data14')->selectRaw('SUM(data15+data16) as data15')
  775. ->selectRaw('SUM(data17) as data17')->selectRaw('SUM(data18) as data18')
  776. ->selectRaw('SUM(data19+data20) as data19')->selectRaw('SUM(data21) as data21')
  777. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data23+data24) as data23')
  778. ->selectRaw('SUM(data25) as data25')->selectRaw('SUM(data26) as data26')
  779. ->selectRaw('SUM(data27) as data27')->selectRaw('SUM(data42) as data42')
  780. ->selectRaw('SUM(data43) as data43')->selectRaw('SUM(home_area) as home_area')
  781. ->selectRaw('SUM(data50) as data50')->selectRaw('SUM(data51) as data51')
  782. ->selectRaw('SUM(data52) as data52')->selectRaw('SUM(data57) as data57')
  783. ->selectRaw('SUM(data58) as data58')->selectRaw('SUM(data53) as data53')
  784. ->selectRaw('SUM(data54) as data54')->selectRaw('SUM(data55) as data55')
  785. ->selectRaw('SUM(data56) as data56')->selectRaw('SUM(data61) as data61')
  786. ->selectRaw('SUM(data62) as data62')->selectRaw('SUM(data59) as data59')
  787. ->selectRaw('SUM(data60) as data60')
  788. ;
  789. $th[1] = '收录人';
  790. $th1[1] = '收录人';
  791. $th2[1] = '收录人';
  792. $th3[1] = '收录人';
  793. $th4[1] = '收录人';
  794. $th5[1] = '收录人';
  795. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  796. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  797. $table = $table->get();
  798. foreach($table as $value){
  799. $value['bzc_name'] = User::where('id','=',$input['user_id'])->first()->surname;
  800. }
  801. }
  802. if(!empty($input['project_id']) && empty($input['user_id'])){
  803. $table = Table_eight::query()
  804. ->where('status','>','1')
  805. ->where('project_id','=',$input['project_id'])
  806. ->groupBy('id')
  807. ->selectRaw('project_id')
  808. ->selectRaw('SUM(bzc_area) as bzc_area')->selectRaw('SUM(data2)as data2')
  809. ->selectRaw('SUM(data3+data4) as data3')->selectRaw('SUM(data5) as data5')
  810. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data7+data8) as data7')
  811. ->selectRaw('SUM(data9) as data9')->selectRaw('SUM(data10) as data10')
  812. ->selectRaw('SUM(data11+data12) as data11')->selectRaw('SUM(data13) as data13')
  813. ->selectRaw('SUM(data14) as data14')->selectRaw('SUM(data15+data16) as data15')
  814. ->selectRaw('SUM(data17) as data17')->selectRaw('SUM(data18) as data18')
  815. ->selectRaw('SUM(data19+data20) as data19')->selectRaw('SUM(data21) as data21')
  816. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data23+data24) as data23')
  817. ->selectRaw('SUM(data25) as data25')->selectRaw('SUM(data26) as data26')
  818. ->selectRaw('SUM(data27) as data27')->selectRaw('SUM(data42) as data42')
  819. ->selectRaw('SUM(data43) as data43')->selectRaw('SUM(home_area) as home_area')
  820. ->selectRaw('SUM(data50) as data50')->selectRaw('SUM(data51) as data51')
  821. ->selectRaw('SUM(data52) as data52')->selectRaw('SUM(data57) as data57')
  822. ->selectRaw('SUM(data58) as data58')->selectRaw('SUM(data53) as data53')
  823. ->selectRaw('SUM(data54) as data54')->selectRaw('SUM(data55) as data55')
  824. ->selectRaw('SUM(data56) as data56')->selectRaw('SUM(data61) as data61')
  825. ->selectRaw('SUM(data62) as data62')->selectRaw('SUM(data59) as data59')
  826. ->selectRaw('SUM(data60) as data60')
  827. ;
  828. $th[1] = '项目';
  829. $th1[1] = '项目';
  830. $th2[1] = '项目';
  831. $th3[1] = '项目';
  832. $th4[1] = '项目';
  833. $th5[1] = '项目';
  834. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  835. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  836. $table = $table->get();
  837. foreach($table as $value){
  838. $value['bzc_name'] = Project::where('id','=',$input['project_id'])->first()->project_name;
  839. }
  840. }
  841. if(!empty($input['project_id']) && !empty($input['user_id'])){
  842. $table = Table_eight::query()
  843. ->where('status','>','1')
  844. ->where('project_id','=',$input['project_id'])
  845. ->where('user_id','=',$input['user_id'])
  846. ->groupBy('id')
  847. ->selectRaw('user_id')
  848. ->selectRaw('SUM(bzc_area) as bzc_area')->selectRaw('SUM(data2)as data2')
  849. ->selectRaw('SUM(data3+data4) as data3')->selectRaw('SUM(data5) as data5')
  850. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data7+data8) as data7')
  851. ->selectRaw('SUM(data9) as data9')->selectRaw('SUM(data10) as data10')
  852. ->selectRaw('SUM(data11+data12) as data11')->selectRaw('SUM(data13) as data13')
  853. ->selectRaw('SUM(data14) as data14')->selectRaw('SUM(data15+data16) as data15')
  854. ->selectRaw('SUM(data17) as data17')->selectRaw('SUM(data18) as data18')
  855. ->selectRaw('SUM(data19+data20) as data19')->selectRaw('SUM(data21) as data21')
  856. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data23+data24) as data23')
  857. ->selectRaw('SUM(data25) as data25')->selectRaw('SUM(data26) as data26')
  858. ->selectRaw('SUM(data27) as data27')->selectRaw('SUM(data42) as data42')
  859. ->selectRaw('SUM(data43) as data43')->selectRaw('SUM(home_area) as home_area')
  860. ->selectRaw('SUM(data50) as data50')->selectRaw('SUM(data51) as data51')
  861. ->selectRaw('SUM(data52) as data52')->selectRaw('SUM(data57) as data57')
  862. ->selectRaw('SUM(data58) as data58')->selectRaw('SUM(data53) as data53')
  863. ->selectRaw('SUM(data54) as data54')->selectRaw('SUM(data55) as data55')
  864. ->selectRaw('SUM(data56) as data56')->selectRaw('SUM(data61) as data61')
  865. ->selectRaw('SUM(data62) as data62')->selectRaw('SUM(data59) as data59')
  866. ->selectRaw('SUM(data60) as data60')
  867. ;
  868. $th[1] = '收录人';
  869. $th1[1] = '收录人';
  870. $th2[1] = '收录人';
  871. $th3[1] = '收录人';
  872. $th4[1] = '收录人';
  873. $th5[1] = '收录人';
  874. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  875. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  876. $table = $table->get();
  877. foreach($table as $value){
  878. $value['bzc_name'] = User::where('id','=',$input['user_id'])->first()->surname;
  879. }
  880. }
  881. return view('admin.sta.sta_eight', compact('table_type_id','user_data','table_name', 'th', 'th1', 'th2', 'th3', 'th4', 'th5', 'table'));
  882. break;
  883. case 9:
  884. $table_name = '核算单(货币补偿)';
  885. $th = [
  886. '1' => '姓名',
  887. '2' => '房1房屋面积',
  888. '3' => '房2房屋面积',
  889. '4' => '房3房屋面积',
  890. '5' => '房4房屋面积',
  891. '6' => '房5房屋面积',
  892. '7' => '房6房屋面积',
  893. '8' => '合计',
  894. ];
  895. $th1 = [
  896. '1' => '姓名',
  897. '2' => '房1装修',
  898. '3' => '房2装修',
  899. '4' => '房3装修',
  900. '5' => '房4装修',
  901. '6' => '房5装修',
  902. '7' => '房6装修',
  903. '8' => '小计',
  904. ];
  905. $th2 = [
  906. '1' => '姓名',
  907. '2' => '空院补偿额',
  908. '3' => '停产停业损失补偿额',
  909. '4' => '房屋补偿总额',
  910. '5' => '构筑物及其他补偿金',
  911. '6' => '拆迁补偿总金额',
  912. ];
  913. if(empty($input['user_id']) && empty($input['project_id'])){
  914. $table = Table_nine::query()
  915. ->where('status','>','1')
  916. ->groupBy('bzc_name')
  917. ->selectRaw('bzc_name')
  918. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data9)as data9')
  919. ->selectRaw('SUM(data12) as data12')->selectRaw('SUM(data15) as data15')
  920. ->selectRaw('SUM(data18) as data18')->selectRaw('SUM(data21) as data21')
  921. ->selectRaw('SUM(data24) as data24')->selectRaw('SUM(data7) as data7')
  922. ->selectRaw('SUM(data10) as data10')->selectRaw('SUM(data13) as data13')
  923. ->selectRaw('SUM(data16) as data16')->selectRaw('SUM(data19) as data19')
  924. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data25) as data25')
  925. ->selectRaw('SUM(data26) as data26')->selectRaw('SUM(data27) as data27')
  926. ->selectRaw('SUM(data28) as data28')->selectRaw('SUM(data43) as data43')
  927. ->selectRaw('SUM(data44) as data44')
  928. ;
  929. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  930. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  931. $table = $table->get();
  932. }
  933. if(!empty($input['user_id'])&& empty($input['project_id'])){
  934. $table = Table_nine::query()
  935. ->where('status','>','1')
  936. ->where('user_id','=',$input['user_id'])
  937. ->groupBy('id')
  938. ->selectRaw('user_id')
  939. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data9)as data9')
  940. ->selectRaw('SUM(data12) as data12')->selectRaw('SUM(data15) as data15')
  941. ->selectRaw('SUM(data18) as data18')->selectRaw('SUM(data21) as data21')
  942. ->selectRaw('SUM(data24) as data24')->selectRaw('SUM(data7) as data7')
  943. ->selectRaw('SUM(data10) as data10')->selectRaw('SUM(data13) as data13')
  944. ->selectRaw('SUM(data16) as data16')->selectRaw('SUM(data19) as data19')
  945. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data25) as data25')
  946. ->selectRaw('SUM(data26) as data26')->selectRaw('SUM(data27) as data27')
  947. ->selectRaw('SUM(data28) as data28')->selectRaw('SUM(data43) as data43')
  948. ->selectRaw('SUM(data44) as data44')
  949. ;
  950. $th[1] = '收录人';
  951. $th1[1] = '收录人';
  952. $th2[1] = '收录人';
  953. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  954. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  955. $table = $table->get();
  956. foreach($table as $value){
  957. $value['bzc_name'] = User::where('id','=',$value['user_id'])->first()->surname;
  958. }
  959. }
  960. if(!empty($input['project_id']) && empty($input['user_id'])){
  961. $table = Table_nine::query()
  962. ->where('status','>','1')
  963. ->where('project_id','=',$input['project_id'])
  964. ->groupBy('id')
  965. ->selectRaw('project_id')
  966. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data9)as data9')
  967. ->selectRaw('SUM(data12) as data12')->selectRaw('SUM(data15) as data15')
  968. ->selectRaw('SUM(data18) as data18')->selectRaw('SUM(data21) as data21')
  969. ->selectRaw('SUM(data24) as data24')->selectRaw('SUM(data7) as data7')
  970. ->selectRaw('SUM(data10) as data10')->selectRaw('SUM(data13) as data13')
  971. ->selectRaw('SUM(data16) as data16')->selectRaw('SUM(data19) as data19')
  972. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data25) as data25')
  973. ->selectRaw('SUM(data26) as data26')->selectRaw('SUM(data27) as data27')
  974. ->selectRaw('SUM(data28) as data28')->selectRaw('SUM(data43) as data43')
  975. ->selectRaw('SUM(data44) as data44')
  976. ;
  977. $th[1] = '项目';
  978. $th1[1] = '项目';
  979. $th2[1] = '项目';
  980. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  981. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  982. $table = $table->get();
  983. foreach($table as $value){
  984. $value['bzc_name'] = Project::where('id','=',$value['project_id'])->first()->project_name;
  985. }
  986. }
  987. if(!empty($input['project_id']) && !empty($input['user_id'])){
  988. $table = Table_nine::query()
  989. ->where('status','>','1')
  990. ->where('project_id','=',$input['project_id'])
  991. ->where('user_id','=',$input['user_id'])
  992. ->groupBy('id')
  993. ->selectRaw('user_id')
  994. ->selectRaw('SUM(data6) as data6')->selectRaw('SUM(data9)as data9')
  995. ->selectRaw('SUM(data12) as data12')->selectRaw('SUM(data15) as data15')
  996. ->selectRaw('SUM(data18) as data18')->selectRaw('SUM(data21) as data21')
  997. ->selectRaw('SUM(data24) as data24')->selectRaw('SUM(data7) as data7')
  998. ->selectRaw('SUM(data10) as data10')->selectRaw('SUM(data13) as data13')
  999. ->selectRaw('SUM(data16) as data16')->selectRaw('SUM(data19) as data19')
  1000. ->selectRaw('SUM(data22) as data22')->selectRaw('SUM(data25) as data25')
  1001. ->selectRaw('SUM(data26) as data26')->selectRaw('SUM(data27) as data27')
  1002. ->selectRaw('SUM(data28) as data28')->selectRaw('SUM(data43) as data43')
  1003. ->selectRaw('SUM(data44) as data44')
  1004. ;
  1005. $th[1] = '收录人';
  1006. $th1[1] = '收录人';
  1007. $th2[1] = '收录人';
  1008. $table = $input['start_time'] != '' ? $table->where('created_at', '>', $input['start_time']) : $table;
  1009. $table = $input['end_time'] != '' ? $table->where('created_at', '<', $input['end_time']) : $table;
  1010. $table = $table->get();
  1011. foreach($table as $value){
  1012. $value['bzc_name'] = User::where('id','=',$value['user_id'])->first()->surname;
  1013. }
  1014. }
  1015. return view('admin.sta.sta_nine', compact('table_type_id','user_data','table_name', 'table', 'th', 'th1', 'th2'));
  1016. break;
  1017. case 0:
  1018. $table_name = '成本审计汇总表';
  1019. $th = [
  1020. '合同编号',
  1021. '姓名',
  1022. '房栋号',
  1023. '身份证',
  1024. '联系电话',
  1025. '有证面积',
  1026. '无证面积',
  1027. '房屋补偿金',
  1028. '庭院面积',
  1029. '庭院补偿',
  1030. '装修',
  1031. '构筑物及其他',
  1032. '停产停业损失补偿(临街路补偿)',
  1033. '临时安置',
  1034. '搬迁',
  1035. '低保',
  1036. '全额奖励金',
  1037. '整栋奖励',
  1038. '违章自行拆除费',
  1039. '残疾及其他',
  1040. '补偿总额',
  1041. '回迁套数',
  1042. '回迁小区楼栋号',
  1043. '回迁住宅面积',
  1044. '回迁商铺面积',
  1045. '回迁楼房金额',
  1046. '应缴差价',
  1047. '应退差价',
  1048. '签约日期',
  1049. '交房日期',
  1050. '备注',
  1051. ];
  1052. $result = Tablelist::query();
  1053. $data = $request->all();
  1054. $result = $result->where('status', '>', '0');
  1055. $result = $data['name'] != '' ? $result->where('bzc_name','like', '%'.$data['name'].'%') : $result;
  1056. $result = $data['project_name'] != '' ? $result->where('project_name', $data['project_name']) : $result;
  1057. $result = $data['start_time'] != '' ? $result->where('updated_at', '>', $data['start_time']) : $result;
  1058. $result = $data['end_time'] != '' ? $result->where('updated_at', '<', $data['end_time']) : $result;
  1059. return view('admin.sta.sta_all',compact('th','table_name','user_data','table'));
  1060. break;
  1061. }
  1062. } else {
  1063. return redirect('/');
  1064. }
  1065. }
  1066. }