Tz.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\Admin\controller;
  4. use app\BaseController;
  5. use think\facade\Db;
  6. use think\Request;
  7. class Tz extends BaseController
  8. {
  9. /**
  10. * 显示资源列表
  11. *
  12. * @return \think\Response
  13. */
  14. public function list()
  15. {
  16. $post =$this->request->post();
  17. $token = isset($post['token']) ? trim($post['token']) : "";
  18. // if($token==""){
  19. // return error_show(1001,'token不能为空');
  20. // }
  21. // $effetc = VerifyTokens($token);
  22. // if(!empty($effetc) && $effetc['code']!=0){
  23. // return error_show($effetc['code'],$effetc['message']);
  24. // }
  25. $page = isset($post['page'])&&$post['page']!='' ? intval($post['page']): 1;
  26. $size = isset($post['size'])&&$post['size']!='' ? intval($post['size']):10;
  27. $condition=[];
  28. $qrdno = isset($post['qrdno'])&&$post['qrdno']!="" ? trim($post['qrdno']):"";
  29. if($qrdno!=""){
  30. $condition[]=['qrdNo',"=",$qrdno];
  31. }
  32. $cgdno = isset($post['cgdno'])&&$post['cgdno']!="" ? trim($post['cgdno']):"";
  33. if($cgdno!=""){
  34. $condition[]=['cgdNo',"=",$cgdno];
  35. }
  36. $type = isset($post['type'])&&$post['type']!="" ? trim($post['type']):"";
  37. if($type!=""){
  38. $condition[]=['cgdtype',"like","%{$type}%"];
  39. }
  40. $supllier = isset($post['supllier'])&&$post['supllier']!="" ? trim($post['supllier']):"";
  41. if($supllier!=""){
  42. $condition[]=['supllier_name',"like","%{$supllier}%"];
  43. }
  44. $count =Db::name("tz")->where($condition)->count();
  45. $total = ceil($count/$size)>1 ? ceil($count/$size) : 1;
  46. $page = $page>=$total?intval($total):$page;
  47. $list = Db::name("tz")->where($condition)->page($page,$size)->select();
  48. return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
  49. }
  50. /**
  51. * 显示创建资源表单页.
  52. *
  53. * @return \think\Response
  54. */
  55. public function create()
  56. {
  57. $arr =[1528938.18,2548230.3,1019292.12];
  58. $total = round(5096460.60000000,2);
  59. echo $total == array_sum($arr);
  60. die();
  61. $post =$this->request->post();
  62. $token = isset($post['token']) ? trim($post['token']) : "";
  63. // if($token==""){
  64. // return error_show(1001,'token不能为空');
  65. // }
  66. // $effetc = VerifyTokens($token);
  67. // if(!empty($effetc) && $effetc['code']!=0){
  68. // return error_show($effetc['code'],$effetc['message']);
  69. // }
  70. $qrdNo = isset($post['id'])&&$post["id"] !='' ? intval($post['id']) :"";
  71. if($qrdNo==''){
  72. return error_show(1006,"参数id 不能为空");
  73. }
  74. $list = Db::name("tz")->where("id","=",$qrdNo)->find();
  75. if(empty($list)){
  76. return error_show(1006,"未找到数据");
  77. }
  78. $list['qrdpay'] = $this->read($list['productNo']);
  79. $list['cgdpay'] = $this->save($list['cgdNo']);
  80. $list['fh'] = $this->edit($list['productNo']);
  81. $list['th'] = $this->update($list['productNo']);
  82. return app_show(0,"获取成功",$list);
  83. }
  84. /**
  85. * 保存新建的资源
  86. *
  87. * @param \think\Request $request
  88. * @return \think\Response
  89. */
  90. public function save($cgdcode)
  91. {
  92. if($cgdcode==""){
  93. return [];
  94. }
  95. $list = Db::name('pay')->alias('a')->leftJoin('cfp_pay_info b','a.payNo = b.payNo')->where([['a.status',">=",
  96. 0],['b.status',"=",1],['sequenceNo',"=",$cgdcode]])->field('payNo,total_fee,ainv_fee')->select();
  97. foreach ($list as $key=>$value){
  98. $invtime = Db::name('pay_stages')->where([['is_del',"=",0],['status',"=",7],['payNo',"=",
  99. $value['payNo']]])->order('invtime desc')
  100. ->find();
  101. $paytime = Db::name('pay_stages')->where([['is_del',"=",0],['paystatus',"=",4],['payNo',"=",
  102. $value['payNo']]])
  103. ->order('paytime desc')
  104. ->find();
  105. $list[$key]['invtime']=isset($invtime['invtime'])&& $invtime!="" ?$invtime['invtime'] : '';
  106. $list[$key]['paytime']=isset($paytime['paytime'])&& $paytime!="" ?$paytime['paytime'] : '';
  107. }
  108. return empty($list)?[] : $list;
  109. }
  110. /**
  111. * 显示指定的资源
  112. *
  113. * @param int $id
  114. * @return \think\Response
  115. */
  116. public function read($qrdno)
  117. {
  118. $order = Db::name("order_info")->alias('a')->leftJoin("cfp_order_pool b","a.orderNo = b.orderNo
  119. AND b.is_del = 0 ")->leftJoin("cfp_assoc_list ak","ak.codeNo = a.orderNo OR ak.viceNo = a.orderNo ")->where
  120. ("ak.rela_form IN ( 1, 2, 3 ) AND ak.STATUS = 3 AND ak.is_del = 0 and a.goodNo = '{$qrdno}' AND a.STATUS = 1")
  121. ->field('ak.*')
  122. ->find();
  123. $list =['pay'=>[],'inv'=>[]];
  124. if(empty($order)){
  125. return $list;
  126. }
  127. foreach ($order as $key=>$value){
  128. $temp=[];
  129. if($value['rela_form'] == 2 || $value['rela_form'] == 3){
  130. $temp['paytime']=$value['addtime'];
  131. $temp['payfee']=$value['cancel_total'];
  132. $temp['payNo']=$value['rela_form']==2?$value['viceNo']:$value['codeNo'];
  133. $list['pay'][]=$temp;
  134. }
  135. if($value['rela_form'] ==1 ){
  136. $temp['invtime']=$value['addtime'];
  137. $temp['invfee']=$value['cancel_total'];
  138. $temp['invNo']=$value['viceNo'];
  139. $list['inv'][]=$temp;
  140. }
  141. }
  142. return $list;
  143. }
  144. /**
  145. * 显示编辑资源表单页.
  146. *
  147. * @param int $id
  148. * @return \think\Response
  149. */
  150. public function edit($qrdNo)
  151. {
  152. $fh = Db::table("fh_source")->where([['qrdNo',"=",$qrdNo],['sendstatus',"=",1]])->field("fhNo,send,bala,send_date,post_company,post_code")->select();
  153. return empty($fh)?[]:$fh;
  154. }
  155. /**
  156. * 保存更新的资源
  157. *
  158. * @param \think\Request $request
  159. * @param int $id
  160. * @return \think\Response
  161. */
  162. public function update($qrdNo)
  163. {
  164. $th = Db::name("th_source")->where([['th_qrdcpNo',"=",$qrdNo],['th_status',"=",1]])->field("thNo,createtime,th_qrd_fee,th_cgd_fee,th_num")->select();
  165. return empty($th)?[]:$th;
  166. }
  167. /**
  168. * 删除指定资源
  169. *
  170. * @param int $id
  171. * @return \think\Response
  172. */
  173. public function delete($id)
  174. {
  175. //
  176. }
  177. }