request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if ($token == "") { return error_show(101, 'token不能为空'); } $effetc = VerifyTokens($token); if (!empty($effetc) && $effetc['code'] != 0) { return error_show($effetc['code'], $effetc['message']); } $condition = [['is_del',"=",1]]; $companyNo = isset($post['companyNo'])&&$post['companyNo']!="" ? trim($post['companyNo']) :""; if($companyNo!=""){ $condition[] = ["companyNo","=",$companyNo]; } $inv_status = isset($post['inv_status'])&&$post['inv_status']!="" ? trim($post['inv_status']) :""; if($inv_status!=""){ $condition[] = ["inv_status","=",$inv_status]; } $fund_status = isset($post['fund_status'])&&$post['fund_status']!="" ? trim($post['fund_status']) :""; if($fund_status!=""){ $condition[] = ["fund_status","=",$fund_status]; } $starttime = isset($post['starttime'])&&$post['starttime']!="" ? $post['starttime'] :""; if($starttime!=""){ $condition[] = ["addtime",">=",$starttime]; } $endtime = isset($post['endtime'])&&$post['endtime']!="" ? $post['endtime']:""; if($endtime!=""){ $condition[] = ["addtime","<=",$endtime]; } $page = isset($post['page']) && $post['page'] != "" ? intval($post['page']) : 1; $size = isset($post['size']) && $post['size'] != "" ? intval($post['size']) : 10; $count = Db::name("order_pool")->where($condition)->count(); $total = ceil($count / $size) > 1 ? ceil($count / $size) : 1; $page = $page >= $total ? intval($total) : $page; $list = Db::name("order_pool")->where($condition)->page(intval($page), $size)->select(); $data=[]; foreach ($list as $value){ $customer = Db::name("customer_info")->where("companyNo","=",$value['companyNo'])->find(); $value['companyName'] = isset($customer['companyName']) ?$customer['companyName']:"" ; $value['contactor'] = isset($customer['contactor']) ?$customer['contactor']:""; $goodlist = Db::name("order_info")->where("orderNo","=",$value['orderNo'])->select(); $value['goodlist'] = $goodlist; $data[]=$value; } return app_show(0,"获取成功",['list'=>$data,"count"=>$count]); } /** * 显示创建资源表单页. * * @return \think\Response */ public function create() { $post = $this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if ($token == "") { return error_show(101, 'token不能为空'); } $effetc = VerifyTokens($token); if (!empty($effetc) && $effetc['code'] != 0) { return error_show($effetc['code'], $effetc['message']); } $type = isset($post['type']) && $post['type']!="" ? $post['type'] : ""; if($type==""){ return error_show(1003,"参数type 不能为空"); } $company = isset($post['company']) && $post['company']!="" ? $post['company'] : ""; if($company==""){ return error_show(1003,"参数company 不能为空"); } $goodid = isset($post['goodid']) && $post['goodid']!="" ? $post['goodid'] : ""; if($goodid==""){ return error_show(1003,"参数goodid 不能为空"); } if($type==1){ $goodlist = Db::name("qrd_list")->where("id","in",$goodid)->field("sequenceNo,goodname,brand,unit,num,price,total_fee,diff_price")->select(); if(empty($goodlist)){ return error_show(1003,"未找到对应的商品"); } } $userinfo = GetUserInfo($token); if(!isset($userinfo['code'])|| $userinfo['code']!=0){ return error_show(101,'未能获取用户信息'); } $nickname = $userinfo['data']["nickname"]; $uid = $userinfo['data']['id']; $orderNo = makeNo("ORD"); $data=[ "orderNo"=>$orderNo, "companyNo"=>$company, "sales_id"=>$uid, "sales_name"=>$nickname, "total_amount"=>0, "inv_status"=>0, "fund_status"=>0, "status"=>0, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; Db::startTrans(); try{ $orderinfo=[]; foreach ($goodlist as $value){ $temp=[]; $temp['orderNo']= $orderNo; $temp['goodNo']= $value['sequenceNo']; $temp['good_name']= $value['goodname']; $temp['type_name']= $value['brand']; $temp['unit']=$value['unit']; $temp['good_num']=$value['num']; $temp['price']=$value['price']; $temp['other_fee']=$value['diff_price']; $temp['total_fee']=$value['total_fee']; $temp['status']=1; $temp['addtime']=date("Y-m-d H:i:s"); $temp['updatetime']=date("Y-m-d H:i:s"); $data['total_amount'] += $value['total_fee']; $orderinfo[]=$temp; } $num = Db::name("order_info")->insertAll($orderinfo); if($num>0){ $orderin = Db::name("order_pool")->insert($data); if($orderin){ Db::commit(); return app_show(0,"新建成功"); } } Db::rollback(); return error_show(1004,"新建失败"); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } /** * 财务需求的数据列表 * @param \think\Request $request * @return \think\Response */ public function CWlist() { $post = request()->post(); // $token = isset($post['token']) ? trim($post['token']) : ""; // if ($token == "") { // return error_show(101, 'token不能为空'); // } // $effetc = VerifyTokens($token); // if (!empty($effetc) && $effetc['code'] != 0) { // return error_show($effetc['code'], $effetc['message']); // } $condition="1=1"; $qrd_start = isset($post['qrd_start']) && $post['qrd_start'] != "" ? $post['qrd_start'] :"" ; if($qrd_start!=""){ $condition .=" and ordertime>='". $qrd_start." 00:00:00'"; } $qrd_end = isset($post['qrd_end']) && $post['qrd_end'] != "" ? $post['qrd_end'] :"" ; if($qrd_end!=""){ $condition .=" and ordertime <='". $qrd_end." 23:59:59'"; } $hk_start = isset($post['hk_start']) && $post['hk_start'] != "" ? $post['hk_start'] :"" ; $hk_end = isset($post['hk_end']) && $post['hk_end'] != "" ? $post['hk_end'] :"" ; if($hk_start!=""){ $condition .=" and addtime >='". $hk_start." 00:00:00'"; } if($hk_end!=""){ $condition .=" and addtime <='". $hk_end." 23:59:59'"; } if($qrd_start==""&&$hk_start==""){ $condition .=" and ordertime>='". date("Y-m-d")." 00:00:00'"; } $count = Db::name("cw_report")->where($condition)->count(); $page = isset($post['page']) && $post['page'] != "" ? intval($post['page']) : 1; $size = isset($post['size']) && $post['size'] != "" ? intval($post['size']) : 10; $total = ceil($count / $size) > 1 ? ceil($count / $size) : 1; $page = $page >= $total ? intval($total) : $page; $list = Db::name("cw_report")->where($condition)->page($page,$size)->order('ordertime')->select(); return app_show(0,"获取成功",["list"=>$list,"count"=>$count]); } /** * 显示指定的资源 * * @param int $id * @return \think\Response */ public function read($id) { // } /** * 显示编辑资源表单页. * * @param int $id * @return \think\Response */ public function edit($id) { // } /** * 保存更新的资源 * * @param \think\Request $request * @param int $id * @return \think\Response */ public function update(Request $request, $id) { // } /** * 删除指定资源 * * @param int $id * @return \think\Response */ public function delete($id) { // } }