Confirm.php 6.8 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 Confirm 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(101, 'token不能为空');
  20. }
  21. $effetc = VerifyTokens($token);
  22. if (!empty($effetc) && $effetc['code'] != 0) {
  23. return error_show($effetc['code'], $effetc['message']);
  24. }
  25. $guserinfo =GetUserInfo($token);
  26. if(isset($guserinfo['code']) && $guserinfo['code']!=0){
  27. return error_show($guserinfo['code'],$guserinfo['message']);
  28. }
  29. $check = checkRole($guserinfo['data']['roleid'],53);
  30. $condition = [];
  31. if($check){
  32. $condition[] =["sales_name", "=", $guserinfo['data']['nickname']];
  33. }
  34. $no = isset($post['sequenceNo']) && $post['sequenceNo'] != "" ? trim($post['sequenceNo']) : "";
  35. if ($no != "") {
  36. $condition[] = ["sequenceNo", "like", "%{$no}%"];
  37. }
  38. $platform = isset($post['platform']) && $post['platform'] != "" ? trim($post['platform']) : "";
  39. if ($platform != "") {
  40. $condition[] = ["depart", "like", "%{$platform}%"];
  41. }
  42. $inv_status = isset($post['inv_status']) && $post['inv_status'] != "" ? trim($post['inv_status']) : "";
  43. if ($inv_status != "") {
  44. $condition[] =$inv_status==4? ["inv_status", "in", [1,2]]:["inv_status", "=", "{$inv_status}"];
  45. }
  46. $order_status = isset($post['pay_status']) && $post['pay_status'] != "" ? trim($post['pay_status']) : "";
  47. if ($order_status != "") {
  48. $condition[] =$order_status==4?["pay_status", "in", [1,2]]:["pay_status", "=", "{$order_status}"];
  49. }
  50. $company = isset($post['companyNo']) && $post['companyNo'] != "" ? trim($post['companyNo']) : "";
  51. if ($company != "") {
  52. $condition[] = ["companyNo", "like", "%{$company}%"];
  53. }
  54. $starttime = isset($post['starttime'])&&$post['starttime']!="" ? $post['starttime'] :"";
  55. if($starttime!=""){
  56. $condition[] = ["createdTime",">=",$starttime];
  57. }
  58. $endtime = isset($post['endtime'])&&$post['endtime']!="" ? $post['endtime']:"";
  59. if($endtime!=""){
  60. $condition[] = ["createdTime","<=",$endtime];
  61. }
  62. $total = isset($post['total_low'])&&$post['total_low']!="" ? $post['total_low']:"";
  63. if($total!=""){
  64. $condition[] = ["total_fee",">=",$total];
  65. }
  66. $total_up = isset($post['total_up'])&&$post['total_up']!="" ? $post['total_up']:"";
  67. if($total_up!=""){
  68. $condition[] = ["total_fee","<=",$total_up];
  69. }
  70. $inv_low = isset($post['inv_low'])&&$post['inv_low']!="" ? $post['inv_low']:"";
  71. if($inv_low!=""){
  72. $condition[] = ["winv_fee",">=",$inv_low];
  73. }
  74. $pay_up = isset($post['pay_up'])&&$post['pay_up']!="" ? $post['pay_up']:"";
  75. if($pay_up!=""){
  76. $condition[] = ["wpay_fee","<=",$pay_up];
  77. }
  78. $pay_low = isset($post['pay_low'])&&$post['pay_low']!="" ? $post['pay_low']:"";
  79. if($pay_low!=""){
  80. $condition[] = ["wpay_fee",">=",$pay_low];
  81. }
  82. $inv_up = isset($post['inv_up'])&&$post['inv_up']!="" ? $post['inv_up']:"";
  83. if($inv_up!=""){
  84. $condition[] = ["winv_fee","<=",$inv_up];
  85. }
  86. $page = isset($post['page']) && $post['page'] != "" ? intval($post['page']) : 1;
  87. $size = isset($post['size']) && $post['size'] != "" ? intval($post['size']) : 10;
  88. $count = Db::name("qrd")->where($condition)->count();
  89. $total = ceil($count / $size) > 1 ? ceil($count / $size) : 1;
  90. $page = $page >= $total ? intval($total) : $page;
  91. $list = Db::name("qrd")->where($condition)->field("id,createdTime,companyNo,sequenceNo,sales_name,sales_depart,customer,total_fee,contactor,mobile,type,depart as platform,addr,apay_fee,wpay_fee,ainv_fee,winv_fee,pay_fee,inv_fee,pay_status,inv_status")->page
  92. (intval($page), $size)->order("createdTime desc")->select();
  93. $data=[];
  94. foreach ($list as $value){
  95. $where=[["qrdNo","=",$value['sequenceNo']]];
  96. if($order_status==4){
  97. $where[]=['pay_status',"in",[1,2]];
  98. }
  99. if($inv_status==4){
  100. $where[]=['inv_status',"in",[1,2]];
  101. }
  102. $good = Db::name("qrd_list")->where($where)->field("id,sequenceNo,goodname,goodNo,brand,unit,taxPoint,num,goldprice,weight,price,total_fee,touser,gys,kehu,apay_fee,wpay_fee,ainv_fee,winv_fee,paying_fee,inving_fee,pay_status,inv_status,inv_num")
  103. ->select()->toArray();
  104. array_walk($good,function (&$val){
  105. $val['goldprice'] =isset($val['goldprice']) ? sprintf("%.2f",$val['goldprice']):"";
  106. $val['price'] =isset($val['price']) ? sprintf("%.2f",$val['price']):"";
  107. $val['total_fee'] =isset($val['total_fee']) ? sprintf("%.2f",$val['total_fee']):"";
  108. $val['apay_fee'] = sprintf("%.2f",$val['apay_fee']);
  109. $val['wpay_fee'] = sprintf("%.2f",$val['wpay_fee']);
  110. $val['ainv_fee'] = sprintf("%.2f",$val['ainv_fee']);
  111. $val['winv_fee'] = sprintf("%.2f",$val['winv_fee']);
  112. $val['num'] = intval($val['num']);
  113. $val['inv_num'] = isset($val['inv_num']) ? sprintf("%d",$val['inv_num']):"0";
  114. });
  115. $value['good']=$good;
  116. $data[]=$value;
  117. }
  118. return app_show(0,"获取成功",['list'=>$data,"count"=>$count]);
  119. }
  120. /**
  121. * 显示创建资源表单页.
  122. *
  123. * @return \think\Response
  124. */
  125. public function create()
  126. {
  127. }
  128. /**
  129. * 保存新建的资源
  130. *
  131. * @param \think\Request $request
  132. * @return \think\Response
  133. */
  134. public function save(Request $request)
  135. {
  136. //
  137. }
  138. /**
  139. * 显示指定的资源
  140. *
  141. * @param int $id
  142. * @return \think\Response
  143. */
  144. public function read($id)
  145. {
  146. //
  147. }
  148. /**
  149. * 显示编辑资源表单页.
  150. *
  151. * @param int $id
  152. * @return \think\Response
  153. */
  154. public function edit($id)
  155. {
  156. //
  157. }
  158. /**
  159. * 保存更新的资源
  160. *
  161. * @param \think\Request $request
  162. * @param int $id
  163. * @return \think\Response
  164. */
  165. public function update(Request $request, $id)
  166. {
  167. //
  168. }
  169. /**
  170. * 删除指定资源
  171. *
  172. * @param int $id
  173. * @return \think\Response
  174. */
  175. public function delete($id)
  176. {
  177. //
  178. }
  179. }