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']); } $guserinfo =GetUserInfo($token); if(isset($guserinfo['code']) && $guserinfo['code']!=0){ return error_show($guserinfo['code'],$guserinfo['message']); } // $companyNo = isset($post['tradeNo'])&&$post['tradeNo']!=""?trim($post['tradeNo']):""; $companyNo = isset($post['companyNo']) && $post['companyNo'] != "" ? trim($post['companyNo']) : ""; $type = isset($post['type']) && $post['type'] != "" ? intval($post['type']) : 2; // $invid = isset($post['invid'])&&$post['invid']!="" ? $post['invid'] : ""; $tradid = isset($post['tradid']) && $post['tradid'] != "" ? $post['tradid'] : ""; if (!in_array($type, [2, 3])) { return error_show(1004, "参数type 有误"); } $tralog = ""; $tradeno=[]; // $invlog=""; if ($type == 2) { $tralog = Db::name("trade_pool")->where([["is_del", "=", 0], ["id", "in", $tradid]])->select()->toArray(); if (!$tralog) { return error_show(1004, "未找到对应的资金数据"); } $tradeno = array_column($tralog,'traNo'); } if ($type == 3) { $tralog = Db::name("trade_pool")->where([["is_del", "=", 0], ["id", "=", $tradid]])->find(); if (!$tralog) { return error_show(1004, "未找到对应的资金数据"); } $tradeno[] = $tralog['traNo']; } $isinv = Db::name("assoc_list")->where([["codeNo|viceNo","in",$tradeno],["is_del","=",0],['bstatus',"=",1],['rela_form','in',[4,5]]])->select()->toArray(); $userinfo = GetUserInfo($token); $username = ""; if ($companyNo == "") { return error_show(1004, "参数companyNo 不能为空"); } if (isset($userinfo['code']) && $userinfo['code'] == 0) { $username = isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : ""; } $customer = Db::name("customer_info")->where("companyNo", "=", $companyNo)->find(); if (empty($customer)) { return error_show(1004, "未找到客户企业信息"); } $good = isset($post['good']) && $post['good'] ? explode(",", $post['good']) : ""; if ($good == "" && empty($good)) { return error_show(1004, "商品信息不能为空"); } $orderall = Db::name("order_list")->where([['is_del',"=",0],['type',"<>",4],['goodNo',"in",$good]])->column('orderNo'); $isorderinv = Db::name("assoc_list")->where([["codeNo","in",$orderall],["is_del","=",0],['bstatus', "=",1],['rela_form','=',1]])->select()->toArray(); if(!empty($isinv)&&!empty($isorderinv)){ return error_show(1004, "订单和资金不能同时都有开票信息"); } Db::startTrans(); try { $orderinfo = []; $orderNo = makeNo('ORD'); $total = 0; $fund_fee = 0; $wfund_fee = 0; $inv_fee = 0; $winv_fee = 0; foreach ($good as $value) { $temp = []; $temp['orderNo'] = $orderNo; $temp['goodNo'] = $value; $goocp = Db::name("qrd_list")->where("sequenceNo", "=", $value)->find(); if (!$goocp) { continue; } $temp['good_name'] = $goocp['goodname']; $temp['qrdNo'] = $goocp['qrdNo']; $temp['brand'] = $goocp['brand']; $temp['unit'] = $goocp['unit']; $temp['good_num'] = $goocp['num']; $temp['price'] = $goocp['price']; $temp['total_fee'] = $goocp['total_fee']; $temp['wfund_fee'] = $goocp['wpay_fee']; $temp['winv_fee'] = $goocp['winv_fee']; $temp['other_fee'] = 0; $temp['status'] = 1; $temp['remark'] = ""; $temp['addtime'] = date("Y-m-d H:i:s"); $temp['updatetime'] = date("Y-m-d H:i:s"); $total += $goocp['total_fee']; $fund_fee += $goocp['apay_fee']; $winv_fee += $goocp['winv_fee']; $inv_fee += $goocp['ainv_fee']; $wfund_fee += $goocp['wpay_fee']; $orderinfo[] = $temp; } $orderins = Db::name("order_info")->insertAll($orderinfo); if ($orderins) { $order = [ "orderNo" => $orderNo, "companyNo" => $companyNo, "sales_id" => $effetc['data']['user']['id'], "sales_name" => $username, "total_amount" => $total, "inv_status" => 1, "fund_status" => 1, "fund_fee" => 0, "wfund_fee" => $wfund_fee, "inv_fee" => 0, "winv_fee" => $winv_fee, "status" => 0, "type" => $type, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $orderpool = Db::name("order_pool")->insert($order, true); if ($orderpool > 0) { if ($tralog != "" && is_array($tralog)) { $rela = []; $assNo = makeNo("ASC"); $cancel = 0; if ($type == 2) { foreach ($tralog as $value) { $balance = $value["worder_fee"] > $wfund_fee ? $wfund_fee : $value["worder_fee"]; if ($wfund_fee <= 0) { Db::rollback(); return error_show(1004, "资金额度大于订单的未开票额度"); } $wfund_fee -= $balance; $cancel += $balance; $rela[] = [ "assocNo" => $assNo, "viceNo" => $value['traNo'], "vice_fee" => $value['worder_fee'] - $balance, "vice_total" => $value['total_fee'], "cancel_fee" => $balance, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $value['worder_fee'] -= $balance; $value['order_used'] += $balance; // $value['order_status']=$balance; $value['is_order'] = 1; $value['updatetime'] = date("Y-m-d H:i:s"); Db::name("trade_pool")->save($value); } $assoc = Db::name("assoc_rela")->insertAll($rela); if ($assoc) { $data = [ "assocNo" => $assNo, "companyNo" => $companyNo, "type" => 1, "apply_id"=> $guserinfo["data"]["id"], "apply_name"=> $guserinfo["data"]["nickname"], "rela_form" => $type, "codeNo" => $orderNo, "total_fee" => $order['total_amount'], "balance" => $wfund_fee, "cancel_total" => $cancel, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $realkey = Db::name("assoc_key")->insert($data); if ($realkey) { Db::name("order_pool")->where("orderNo", "=", $orderNo)->save (["wfund_fee" => $wfund_fee,'fund_used'=>$cancel, "updatetime" => date("Y-m-d H:i:s")]); $qrdup=$this->updateQrd($orderNo,$cancel); if(!$qrdup){ Db::rollback(); return error_show(1004, "新建关联申请失败"); } Db::commit(); return app_show(0, "新建关联成功"); } } } if ($type == 3) { $balance = $tralog["worder_fee"] > $wfund_fee ? $wfund_fee : $tralog["worder_fee"]; $wfund_fee -= $balance; $tralog['worder_fee'] -= $balance; $tralog['order_used'] += $balance; $tralog['is_order'] = 1; $tralog['updatetime'] = date("Y-m-d H:i:s"); Db::name("trade_pool")->save($tralog); $rela = [ "assocNo" => $assNo, "viceNo" => $orderNo, "vice_total" => $order['total_amount'], "vice_fee" => $wfund_fee, "cancel_fee" => $balance, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $assoc = Db::name("assoc_rela")->insert($rela); if ($assoc) { $data = [ "assocNo" => $assNo, "companyNo" => $companyNo, "type" => 3, "rela_form" => $type, "codeNo" => $tralog["traNo"], "total_fee" => $tralog['total_fee'], "balance" => $tralog['worder_fee'], "cancel_total" => $balance, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $realkey = Db::name("assoc_key")->insert($data); if ($realkey) { Db::name("order_pool")->where("orderNo", "=", $orderNo)->save (["wfund_fee" => $wfund_fee,'fund_used'=>$balance, "updatetime" => date("Y-m-d H:i:s")]); $qrdup=$this->updateQrd($orderNo,$balance); if(!$qrdup){ Db::rollback(); return error_show(1004, "新建关联申请失败"); } Db::commit(); return app_show(0, "新建关联成功"); } } } Db::rollback(); return error_show(1004, "新建关联申请失败"); } } } 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 add() { $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']); } $guserinfo =GetUserInfo($token); if(isset($guserinfo['code']) && $guserinfo['code']!=0){ return error_show($guserinfo['code'],$guserinfo['message']); } // $companyNo = isset($post['tradeNo'])&&$post['tradeNo']!=""?trim($post['tradeNo']):""; $companyNo = isset($post['companyNo']) && $post['companyNo'] != "" ? trim($post['companyNo']) : ""; $type = isset($post['type']) && $post['type'] != "" ? intval($post['type']) : 4; $invid = isset($post['invid']) && $post['invid'] != "" ? $post['invid'] : ""; $tradid = isset($post['tradid']) && $post['tradid'] != "" ? $post['tradid'] : ""; if (!in_array($type, [4, 5])) { return error_show(1004, "参数type 有误"); } if ($invid == "") { return error_show(1004, "缺少必要参数invid"); } if ($tradid == "") { return error_show(1004, "缺少必要参数tradid"); } if ($type == 5) { $tralog = Db::name("trade_pool")->where([["is_del", "=", 0], ["id", "=", $tradid]])->find(); if (!$tralog) { return error_show(1004, "未找到对应的资金数据"); } $invlog = Db::name("invoice_pool")->where([["is_del", "=", 0], ["id", "in", $invid]])->select()->toArray(); if (!$invlog) { return error_show(1004, "未找到对应的发票数据"); } } if ($type == 4) { $invlog = Db::name("invoice_pool")->where([["is_del", "=", 0], ["id", "=", $invid]])->find(); if (!$invlog) { return error_show(1004, "未找到对应的发票数据"); } $tralog = Db::name("trade_pool")->where([["is_del", "=", 0], ["id", "in", $tradid]])->select()->toArray(); if (!$tralog) { return error_show(1004, "未找到对应的资金数据"); } } Db::startTrans(); try { if ($type == 5) { $rela = []; $trade = 0; $assNo = makeNo("ASC"); foreach ($invlog as $value) { $balance = $tralog['winv_fee'] > $value['wtrade_fee'] ? $value['wtrade_fee'] : $tralog['winv_fee']; if ($tralog['winv_fee'] <= 0) { Db::rollback(); return error_show(1005, "发票总额大于资金额度"); } if ($value['wtrade_fee'] <= 0) { Db::rollback(); return error_show(1005, "发票核销金额为0"); } $tralog['winv_fee'] -= $balance; $tralog['inv_used'] += $balance; $trade += $balance; $rela[] = [ "assocNo" => $assNo, "viceNo" => $value['invNo'], "vice_total" => $value['inv_value'], "vice_fee" => $value['wtrade_fee'] - $balance, "cancel_fee" => $balance, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $value['wtrade_fee'] -= $balance; $value['fund_used'] += $balance; // $value['order_status']=$balance; // $value['is_order']=1; $value['updatetime'] = date("Y-m-d H:i:s"); Db::name("invoice_pool")->save($value); } $assoc = Db::name("assoc_rela")->insertAll($rela); if ($assoc) { $data = [ "assocNo" => $assNo, "companyNo" => $companyNo, "type" => 3, "apply_id"=> $guserinfo["data"]["id"], "apply_name"=> $guserinfo["data"]["nickname"], "rela_form" => $type, "codeNo" => $tralog["traNo"], "total_fee" => $tralog['total_fee'], "balance" => $tralog['winv_fee'], "cancel_total" => $trade, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $realkey = Db::name("assoc_key")->insert($data); if ($realkey) { $tralog['updatetime'] = date("Y-m-d H:i:s"); Db::name("trade_pool")->save($tralog); Db::commit(); return app_show(0, "新建关联成功"); } } Db::rollback(); return error_show(1004, "新建关联申请失败"); } else { $rela = []; $trade = 0; $assNo = makeNo("ASC"); foreach ($tralog as $value) { $balance = $invlog['wtrade_fee'] > $value['winv_fee'] ? $value['winv_fee'] : $invlog['wtrade_fee']; if ($invlog['wtrade_fee'] <= 0) { Db::rollback(); return error_show(1005, "资金总额大于发票额度"); } if ($value['winv_fee'] <= 0) { Db::rollback(); return error_show(1005, "发票核销金额为0"); } $invlog['wtrade_fee'] -= $balance; $invlog['fund_used'] += $balance; $trade += $balance; $rela[] = [ "assocNo" => $assNo, "viceNo" => $value['traNo'], "vice_total" => $value['total_fee'], "vice_fee" => $value['winv_fee'] - $balance, "cancel_fee" => $balance, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $value['winv_fee'] -= $balance; $value['inv_used'] += $balance; $value['updatetime'] = date("Y-m-d H:i:s"); Db::name("trade_pool")->save($value); } $assoc = Db::name("assoc_rela")->insertAll($rela); if ($assoc) { $data = [ "assocNo" => $assNo, "companyNo" => $companyNo, "type" => 2, "rela_form" => $type, "codeNo" => $invlog["invNo"], "total_fee" => $invlog['inv_value'], "balance" => $invlog['wtrade_fee'], "cancel_total" => $trade, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $realkey = Db::name("assoc_key")->insert($data); if ($realkey) { $invlog['updatetime'] = date("Y-m-d H:i:s"); $order_up = Db::name("invoice_pool")->save($invlog); Db::commit(); return app_show(0, "新建关联成功"); } } Db::rollback(); return error_show(1004, "新建关联申请失败"); } } catch (\Exception $e) { Db::rollback(); return error_show(1006, $e->getMessage()); } } /** * 显示指定的资源 * * @param int $id * @return \think\Response */ public function read() { $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']); } $id = isset($post['id']) && $post['id'] != "" ? $post['id'] : ""; if ($id == "") { return error_show(1004, "参数id 不能为空"); } $condition = [['is_del', "=", 0], ["id", "=", $id]]; $relainfo = Db::name("assoc_key")->where($condition)->find(); if (!$relainfo) { return error_show(1004, "未找到关联数据"); } $relainfo["order_info"] = []; $relainfo["inv_info"] = []; $relainfo["tra_info"] = []; $customer1 = Db::name("customer_info")->where("companyNo", "=", $relainfo['companyNo'])->find(); $relainfo["companyName"] =$customer1?$customer1['companyName']:""; if ($relainfo['type'] == 1) { $order = Db::name("order_pool")->where("orderNo", "=", $relainfo['codeNo'])->find(); $customer = Db::name("customer_info")->where("companyNo", "=", $order['companyNo'])->find(); $order["companyName"] = $customer['companyName']; $order["cancel_fee"] = $relainfo['cancel_total']; $good = Db::name("order_info")->where([["orderNo", "=", $relainfo['codeNo']], ["status", "=", 1]])->select(); $order['good'] = []; $qrdinfo =[]; foreach ($good as $key => $value) { $tep = Db::name("qrd_list")->where("sequenceNo", "=", $value["goodNo"])->field("id,sequenceNo,goodname,qrdNo,goodNo,brand,unit,taxPoint,num,goldprice,weight,price,total_fee,touser,gys,kehu,apay_fee,wpay_fee,ainv_fee,winv_fee,pay_status,inv_status,inv_num") ->find(); if(isset($tep["qrdNo"])&& !isset($qrdinfo[$tep["qrdNo"]])){ $qrdinfo[$tep["qrdNo"]]= Db::name("qrd")->where("sequenceNo", "=", $tep["qrdNo"])->field("id,createdTime,sequenceNo,sales_name,sales_depart,customer,total_fee,contactor,mobile,type,addr,apay_fee,wpay_fee,ainv_fee,winv_fee,pay_status,inv_status")->find(); } $tep['goldprice'] = isset($tep['goldprice']) ? sprintf("%.2f", $tep['goldprice']) : ""; $tep['price'] = isset($tep['price']) ? sprintf("%.2f", $tep['price']) : ""; $tep['total_fee'] = isset($tep['total_fee']) ? sprintf("%.2f", $tep['total_fee']) : ""; $tep['apay_fee'] = sprintf("%.2f", $tep['apay_fee']); $tep['wpay_fee'] = sprintf("%.2f", $tep['wpay_fee']); $tep['ainv_fee'] = sprintf("%.2f", $tep['ainv_fee']); $tep['winv_fee'] = sprintf("%.2f", $tep['winv_fee']); $tep['num'] = intval($tep['num']); $tep['inv_num'] = isset($tep['inv_num']) ? sprintf("%d", $tep['inv_num']) : "0"; //$order['good'][] = $tep; $qrdinfo[$tep["qrdNo"]]['good'][]= $tep; } $list = Db::name("assoc_rela")->where([["assocNo", "=", $relainfo['assocNo']]])->select()->toArray(); $relainfo["order_info"] = array_values($qrdinfo);; if ($list) { foreach ($list as $key => $value) { if ($relainfo['rela_form'] == 1) { $temp = Db::name("invoice_pool")->where("invNo", "=", $value['viceNo'])->find(); $customer = Db::name("customer_info")->where("companyNo", "=", $temp['inv_in'])->find(); $temp["companyName"] = $customer['companyName']; $temp["cancel_fee"] = $value['cancel_fee']; $relainfo["inv_info"][] = $temp; } if ($relainfo['rela_form'] == 2) { $temp = Db::name("trade_list")->where("traNo", "=", $value['viceNo'])->find(); $customer = Db::name("customer_info")->where("companyNo", "=", $temp['companyNo'])->find(); $temp["companyName"] = $customer['companyName']; $temp["cancel_fee"] = $value['cancel_fee']; $relainfo["tra_info"][] = $temp; } } } } if ($relainfo['type'] == 2) { $inv = Db::name("invoice_pool")->where("invNo", "=", $relainfo['codeNo'])->find(); //$relainfo["tra_info"] = Db::name("trade_pool")->where("traNo","=",$relainfo['viceNo'])->find(); $customer = Db::name("customer_info")->where("companyNo", "=", $inv['inv_in'])->find(); $inv["companyName"] = $customer['companyName']; $inv["cancel_fee"] = $relainfo['cancel_total']; $list = Db::name("assoc_rela")->where([["assocNo", "=", $relainfo['assocNo']]])->select()->toArray(); $relainfo["inv_info"][] = $inv; if ($list) { foreach ($list as $key => $value) { if ($relainfo['rela_form'] == 4) { $temp = Db::name("trade_list")->where("traNo", "=", $value['viceNo'])->find(); $customer = Db::name("customer_info")->where("companyNo", "=", $temp['companyNo'])->find(); $temp["companyName"] = $customer['companyName']; $temp["cancel_fee"] = $value['cancel_fee']; $relainfo["tra_info"][] = $temp; } } } // $customer = Db::name("customer_info")->where("companyNo","=",$relainfo["tra_info"]['companyNo'])->find(); // $relainfo["tra_info"]["companyName"] = $customer['companyName']; } if ($relainfo['type'] == 3) { // $relainfo["inv_info"] = Db::name("invoice_pool")->where("invNo","=",$relainfo['mainNo'])->find(); $tra = Db::name("trade_list")->where("traNo", "=", $relainfo['codeNo'])->find(); $customer = Db::name("customer_info")->where("companyNo", "=", $tra['companyNo'])->find(); $tra["companyName"] = $customer['companyName']; $tra["cancel_fee"] = $relainfo['cancel_total']; $relainfo["tra_info"][] = $tra; $list = Db::name("assoc_rela")->where([["assocNo", "=", $relainfo['assocNo']]])->select()->toArray(); if ($list) { foreach ($list as $key => $value) { if ($relainfo['rela_form'] == 5) { $temp = Db::name("invoice_pool")->where("invNo", "=", $value['viceNo'])->find(); $customer = Db::name("customer_info")->where("companyNo", "=", $temp['inv_in'])->find(); $temp["companyName"] = $customer['companyName']; $temp["cancel_fee"] = $value['cancel_fee']; $relainfo["inv_info"][] = $temp; } if ($relainfo['rela_form'] == 3) { $temp = Db::name("order_pool")->where("orderNo", "=", $value['viceNo'])->find(); $customer = Db::name("customer_info")->where("companyNo", "=", $temp['companyNo'])->find(); // $temp['good']=Db::name("order_info")->where([["orderNo","=", $value['viceNo']],["status","=",1]]) // ->select(); $good = Db::name("order_info")->where([["orderNo", "=", $value['viceNo']], ["status", "=", 1]])->select(); $temp['good'] = []; $qrdinfo = []; foreach ($good as $key => $val) { $tep = Db::name("qrd_list")->where("sequenceNo", "=", $val["goodNo"])->field("id,sequenceNo,goodname,qrdNo,goodNo,brand,unit,taxPoint,num,goldprice,weight,price,total_fee,touser,gys,kehu,apay_fee,wpay_fee,ainv_fee,winv_fee,pay_status,inv_status,inv_num") ->find(); if(isset($tep["qrdNo"])&& !isset($qrdinfo[$tep["qrdNo"]])){ $qrdinfo[$tep["qrdNo"]]= Db::name("qrd")->where("sequenceNo", "=", $tep["qrdNo"]) ->field("id,createdTime,sequenceNo,sales_name,sales_depart,customer,total_fee,contactor,mobile,type,addr,apay_fee,wpay_fee,ainv_fee,winv_fee,pay_status,inv_status")->find(); } // $tep = Db::name("qrd_list")->where("sequenceNo", "=", $value["goodNo"])->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,pay_status,inv_status,inv_num") // ->find(); $tep['goldprice'] = isset($tep['goldprice']) ? sprintf("%.2f", $tep['goldprice']) : ""; $tep['price'] = isset($tep['price']) ? sprintf("%.2f", $tep['price']) : ""; $tep['total_fee'] = isset($tep['total_fee']) ? sprintf("%.2f", $tep['total_fee']) : ""; $tep['apay_fee'] = sprintf("%.2f", $tep['apay_fee']); $tep['wpay_fee'] = sprintf("%.2f", $tep['wpay_fee']); $tep['ainv_fee'] = sprintf("%.2f", $tep['ainv_fee']); $tep['winv_fee'] = sprintf("%.2f", $tep['winv_fee']); $tep['num'] = intval($tep['num']); $tep['inv_num'] = isset($tep['inv_num']) ? sprintf("%d", $tep['inv_num']) : "0"; $qrdinfo[$tep["qrdNo"]]['good'][] = $tep; } $temp["companyName"] = $customer['companyName']; $temp["cancel_fee"] = $value['cancel_fee']; $relainfo["order_info"] = array_values($qrdinfo); } } } } return app_show(0, "获取成功", $relainfo); } /** * 显示指定的资源 * * @param int $id * @return \think\Response */ public function list() { $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']); } $condition = [['is_del', "=", 0]]; $guserinfo =GetUserInfo($token); if(isset($guserinfo['code']) && $guserinfo['code']!=0){ return error_show($guserinfo['code'],$guserinfo['message']); } $check = checkRole($guserinfo['data']['roleid'],56); if($check){ $condition[]=["apply_id","=", $guserinfo['data']['id']]; } // $companyNo = isset($post['tradeNo'])&&$post['tradeNo']!=""?trim($post['tradeNo']):""; $companyNo = isset($post['companyNo']) && $post['companyNo'] != "" ? trim($post['companyNo']) : ""; if ($companyNo != "") { $condition[] = ["companyNo", "=", $companyNo]; } $type = isset($post['type']) && $post['type'] != "" ? intval($post['type']) : ""; if ($type != "") { $condition[] = ["rela_form", "=", $type]; } $status = isset($post['status']) && $post['status'] != "" ? $post['status'] : ""; if ($status != "") { $condition[] = ["status", "=", $status]; } $startTime = isset($post['start']) && $post['start'] != "" ? $post['start'] : ""; if ($startTime != "") { $condition[] = ["addtime", ">=", $startTime]; } $endTime = isset($post['end']) && $post['end'] != "" ? $post['end'] : ""; if ($endTime != "") { $condition[] = ["addtime", "<=", $endTime]; } $assocNo = isset($post['assocNo']) && $post['assocNo'] != "" ? trim($post['assocNo']) : ""; if ($assocNo != "") { $condition[] = ["assocNo", "like", "%{$assocNo}%"]; } $codeNo = isset($post['codeNo']) && $post['codeNo'] != "" ? trim($post['codeNo']) : ""; $codeType = isset($post['codeType']) && $post['codeType'] != "" ? intval($post['codeType']) : ""; if($codeType==1){ if ($codeNo != "") { $condition[]=['rela_form',"in",[1,2,3]]; $order = Db::name("order_info")->where("qrdNo", "like", "%{$codeNo}%")->column("orderNo"); $accoslist = Db::name("assoc_list")->where('codeNo|viceNo',"in",$order)->column('assocNo'); $condition[]=['assocNo',"in",$accoslist]; } }else if($codeType==2){ if ($codeNo != "") { $condition[]=['rela_form',"in",[1,4,5]]; $accoslist = Db::name("assoc_list")->where("(codeNo='{$codeNo}' and rela_form=4) or (viceNo='{$codeNo}' and rela_form in (1,5))")->column('assocNo'); $condition[]=['assocNo',"in",$accoslist]; } }else if($codeType==3){ if ($codeNo != "") { $condition[]=['rela_form',"in",[2,3,4,5]]; $accoslist = Db::name("assoc_list")->where("(viceNo='{$codeNo}' and rela_form in (2,4)) or (codeNo='{$codeNo}' and rela_form in (3,5))")->column('assocNo'); $condition[]=['assocNo',"in",$accoslist]; } } $page = isset($post['page']) && $post['page'] != "" ? intval($post['page']) : 1; $size = isset($post['size']) && $post['size'] != "" ? intval($post['size']) : 10; $count = Db::name("assoc_key")->where("source=1 or (source=2 and status=3)")->where($condition)->count(); $total = ceil($count / $size) > 1 ? ceil($count / $size) : 1; $page = $page >= $total ? intval($total) : $page; $list = Db::name("assoc_key")->where("source=1 or (source=2 and status=3)")->where($condition)->order("addtime desc")->page(intval($page), $size)->select(); $data = []; foreach ($list as $key => $value) { $temp = []; $customer = Db::name("customer_info")->where("companyNo", "=", $value['companyNo'])->find(); $temp["id"] = $value['id']; $temp["assocNo"] = $value['assocNo']; $temp["status"] = $value['status']; $temp["cancel_total"] = $value['cancel_total']; $temp["is_source"] = $value['source']; $temp["rela_form"] = $value['rela_form']; $temp["exam_remark"] = $value['exam_remark']; $temp["companyNo"] = $value['companyNo']; $temp["companyName"] = isset($customer['companyName']) ? $customer['companyName'] : ""; $temp["addtime"] = $value['addtime']; if ($value['type'] == 1) { $ordercp = Db::name("order_info")->where([["orderNo","=",$value['codeNo']],["status","=",1]]) ->column("qrdNo"); $temp["orderNo"] = implode(",", array_unique($ordercp)); // $temp["orderNo"] = $value['codeNo']; $temp["order_fee"] = $value['balance']; $temp["total_fee"] = $value['total_fee']; if ($value["rela_form"] == 1) { $inv = Db::name("assoc_rela")->where("assocNo", "=", $value["assocNo"])->column("viceNo"); $temp["invNo"] = implode(",", $inv); $temp["traNo"] = ""; $temp["inv_fee"] = ""; $temp["tra_fee"] = ""; } if ($value["rela_form"] == 2) { $trade = Db::name("assoc_rela")->where("assocNo", "=", $value["assocNo"])->column("viceNo"); $temp["traNo"] = implode(",", $trade); $temp["invNo"] = ""; $temp["tra_fee"] = ""; $temp["inv_fee"] = ""; } } if ($value['type'] == 2) { $temp["invNo"] = $value['codeNo']; $temp["inv_fee"] = $value['balance']; $temp["total_fee"] = $value['total_fee']; if ($value["rela_form"] == 4) { $trade = Db::name("assoc_rela")->where("assocNo", "=", $value["assocNo"])->column("viceNo"); $temp["traNo"] = implode(",", $trade); $temp["tra_fee"] = ""; $temp["order_fee"] = ""; $temp["orderNo"] = ""; } } if ($value['type'] == 3) { $temp["tra_fee"] = $value['balance']; $temp["total_fee"] = $value['total_fee']; $temp["traNo"] = $value['codeNo']; if ($value["rela_form"] == 3) { $order = Db::name("assoc_rela")->where("assocNo", "=", $value["assocNo"])->column("viceNo"); $ordercp =[]; if($order){ $ordercp = Db::name("order_info")->where([["orderNo","in",$order],["status","=",1]])->column("qrdNo"); } $temp["orderNo"] = implode(",", array_unique($ordercp) ); $temp["invNo"] = ""; $temp["inv_fee"] = ""; $temp["order_fee"] = ""; } if ($value["rela_form"] == 5) { $inv = Db::name("assoc_rela")->where("assocNo", "=", $value["assocNo"])->column("viceNo"); $temp["invNo"] = implode(",", $inv); $temp["inv_fee"] = ""; $temp["order_fee"] = ""; $temp["orderNo"] = ""; } } $data[] = $temp; } return app_show(0, "获取成功", ["list" => $data, "count" => $count]); } /** * 显示编辑资源表单页. * * @param int $id * @return \think\Response */ public function edit() { $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']); } $status = isset($post['status']) && $post['status'] != "" ? $post['status'] : ""; if ($status == "") { return error_show(1003, "参数status 不能为空"); } $id = isset($post['id']) && $post['id'] != "" ? $post['id'] : ""; if ($id == "") { return error_show(1004, "参数id 不能为空"); } $remark = isset($post['remark']) && $post['remark'] ? $post['remark'] : ""; Db::startTrans(); $assinfo = Db::name("assoc_key")->where([['id', "=", $id], ["is_del", "=", 0]])->lock(true)->find(); if (!$assinfo) { Db::rollback(); return error_show(1004, "未找到关联数据"); } if ($assinfo["status"] == 3) { Db::rollback(); return error_show(1004, "关联关系已通过审核"); } try { $temp=[]; $temp['status'] = $status; $temp['exam_remark'] = $remark; $temp['updatetime'] = date("Y-m-d H:i:s"); $upadte = Db::name("assoc_key")->where($assinfo)->save($temp); if ($status == 3) { $list = Db::name("assoc_rela")->where("assocNo", "=", $assinfo["assocNo"])->select(); if ($upadte) { $orderinfo = ""; $invinfo = ""; $trainfo = ""; if ($assinfo['type'] == 1) { $orderinfo = Db::name("order_pool")->where("orderNo", "=", $assinfo['codeNo'])->find(); if ($assinfo['rela_form'] == 1) { $invinfo = []; foreach ($list as $value) { $temp = Db::name("invoice_pool")->where([["is_del", "=", 0], ["invNo", "=",$value["viceNo"]]])->find(); $temp['aorder_fee'] += $value['cancel_fee']; $temp['order_used'] -= $value['cancel_fee']; $temp['order_status'] = $temp['worder_fee'] == 0 ? 3 : 2; $temp['updatetime'] = date("Y-m-d H:i:s"); $invinfo[] = $temp; } } if ($assinfo['rela_form'] == 2) { $trainfo = []; foreach ($list as $value) { $temp = Db::name("trade_pool")->where([["is_del", "=", 0], ["traNo", "=", $value["viceNo"]]])->find(); $temp['order_fee'] += $value['cancel_fee']; $temp['order_used'] -= $value['cancel_fee']; $temp['order_status'] = $temp['worder_fee'] == 0 ? 3 : 2; $temp['updatetime'] = date("Y-m-d H:i:s"); $trainfo[] = $temp; } } } if ($assinfo['type'] == 2) { $invinfo = Db::name("invoice_pool")->where("invNo", "=", $assinfo['codeNo'])->find(); if ($assinfo['rela_form'] == 4) { $trainfo = []; foreach ($list as $value) { $temp = Db::name("trade_pool")->where([["is_del", "=", 0], ["traNo", "=", $value["viceNo"]]])->find(); $temp['inv_fee'] += $value['cancel_fee']; $temp['inv_used'] -= $value['cancel_fee']; $temp['inv_status'] = $temp['winv_fee'] == 0 ? 3 : 2; $temp['updatetime'] = date("Y-m-d H:i:s"); $trainfo[] = $temp; } } } if ($assinfo['type'] == 3) { // $invinfo = Db::name("invoice_pool")->where("invNo","=",$assinfo['mainNo'])->find(); $trainfo = Db::name("trade_pool")->where("traNo", "=", $assinfo['codeNo'])->find(); $ty = Db::name("trade_log")->where("logNo","=",$trainfo['logNo'])->find(); if ($assinfo['rela_form'] == 3) { $orderinfo = []; foreach ($list as $value) { $temp = Db::name("order_pool")->where([["is_del", "=", 0], ["orderNo", "=", $value["viceNo"]]])->find(); $temp['fund_fee'] += $value['cancel_fee']; $temp['fund_used'] -= $value['cancel_fee']; $temp['fund_status'] = $temp['wfund_fee'] == 0 ? 3 : 2; $temp['updatetime'] = date("Y-m-d H:i:s"); $ipdate=$this->qrd_sure($temp["orderNo"],$value['cancel_fee']); if(!$ipdate){ Db::rollback(); return error_show(1004,"审核失败"); } $orderinfo[] = $temp; } } if ($assinfo['rela_form'] == 5) { $invinfo = []; foreach ($list as $value) { $temp = Db::name("invoice_pool")->where([["is_del", "=", 0], ["invNo", "=", $value["viceNo"]]])->find(); if($ty['trade_type']==1){ $temp['wtrade_fee'] += $value['cancel_fee']; $temp['fund_used'] -= $value['cancel_fee']; $temp['trade_status'] = $temp['wtrade_fee'] == 0 ? 3 : 2; $temp['updatetime'] = date("Y-m-d H:i:s"); }else{ $temp['atrade_fee'] += $value['cancel_fee']; $temp['fund_used'] -= $value['cancel_fee']; $temp['trade_status'] = $temp['wtrade_fee'] == 0 ? 3 : 2; $temp['updatetime'] = date("Y-m-d H:i:s"); } $invinfo[] = $temp; } } } if ($orderinfo) { if ($assinfo['rela_form'] == 1) { $orderinfo['inv_fee'] += $assinfo['cancel_total']; $orderinfo['inv_used'] -= $assinfo['cancel_total']; $orderinfo['inv_status'] = $orderinfo['winv_fee'] == 0 ? 3 : 2; $orderinfo['updatetime'] = date("Y-m-d H:i:s"); Db::name("order_pool")->save($orderinfo); $ipdate=$this->qrd_sure_inv($orderinfo ["orderNo"],$assinfo['cancel_total']); if(!$ipdate){ Db::rollback(); return error_show(1004,"审核失败"); } } if ($assinfo['rela_form'] == 2) { $orderinfo['fund_fee'] += $assinfo['cancel_total']; $orderinfo['fund_used'] -= $assinfo['cancel_total']; $orderinfo['fund_status'] = $orderinfo['wfund_fee'] == 0 ? 3 : 2; $orderinfo['updatetime'] = date("Y-m-d H:i:s"); Db::name("order_pool")->save($orderinfo); $ipdate=$this->qrd_sure($orderinfo ["orderNo"],$assinfo['cancel_total']); if(!$ipdate){ Db::rollback(); return error_show(1004,"审核失败"); } } if ($assinfo['type'] == 3) { foreach ($orderinfo as $value) { Db::name("order_pool")->save($value); } } } if ($invinfo) { if ($assinfo["type"] == 2) { $invinfo["atrade_fee"] += $assinfo['cancel_total']; $invinfo["fund_used"] -= $assinfo['cancel_total']; $invinfo["trade_status"] = $invinfo["wtrade_fee"] == 0 ? 3 : 2; $invinfo['updatetime'] = date("Y-m-d H:i:s"); Db::name("invoice_pool")->save($invinfo); } else { foreach ($invinfo as $value) { Db::name("invoice_pool")->save($value); } } } if ($trainfo) { if ($assinfo['rela_form'] == 3) { $trainfo['order_fee'] += $assinfo['cancel_total']; $trainfo['order_used'] -= $assinfo['cancel_total']; $trainfo['order_status'] = $trainfo['worder_fee'] == 0 ? 3 : 2; $trainfo['updatetime'] = date("Y-m-d H:i:s"); Db::name("trade_pool")->save($trainfo); } if ($assinfo['rela_form'] == 5) { $trainfo['inv_fee'] += $assinfo['cancel_total']; $trainfo['inv_used'] -= $assinfo['cancel_total']; $trainfo['inv_status'] = $trainfo['winv_fee'] == 0 ? 3 : 2; $trainfo['updatetime'] = date("Y-m-d H:i:s"); Db::name("trade_pool")->save($trainfo); } if ($assinfo["rela_form"] == 2 || $assinfo["rela_form"] == 4) { foreach ($trainfo as $value) { Db::name("trade_pool")->save($value); } } } Db::commit(); return app_show(0, "审核通过"); } Db::rollback(); return app_show(1005, "审核失败"); } if ($status == 2) { Db::commit(); return app_show(0, "审核未通过"); } } catch (\Exception $e) { Db::rollback(); return error_show(1005, $e->getMessage()); } } /** * 保存更新的资源 * * @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() { $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']); } $id = isset($post['id']) && $post['id'] != "" ? $post['id'] : ""; if ($id == "") { return error_show(1004, "参数id 不能为空"); } $assinfo = Db::name("assoc_key")->where([['id', "=", $id], ["is_del", "=", 0]])->find(); if (!$assinfo) { return error_show(1004, "未找到关联数据"); } if ($assinfo['status'] == 3) { return error_show(1004, "数据已通过审核无法取消"); } Db::startTrans(); try { $assinfo['is_del'] = 1; $assinfo['updatetime'] = date("Y-m-d H:i:s"); $upadte = Db::name("assoc_key")->save($assinfo); $list = Db::name("assoc_rela")->where("assocNo", "=", $assinfo["assocNo"])->select()->toArray(); if ($upadte) { $orderinfo = ""; $invinfo = ""; $trainfo = ""; if ($assinfo['type'] == 1) { $orderinfo = Db::name("order_pool")->where("orderNo", "=", $assinfo['codeNo'])->find(); if ($assinfo['rela_form'] == 1) { $invinfo = []; foreach ($list as $value) { $temp = Db::name("invoice_pool")->where([["is_del", "=", 0], ["invNo", "=", $value["viceNo"]]])->find(); $temp['worder_fee'] += $value['cancel_fee']; $temp['order_used'] -= $value['cancel_fee']; $temp['order_status'] = $temp['worder_fee'] ==$temp['inv_value'] ? 1: 2; $temp['updatetime'] = date("Y-m-d H:i:s"); $invinfo[] = $temp; } } if ($assinfo['rela_form'] == 2) { $trainfo = []; foreach ($list as $value) { $temp = Db::name("trade_pool")->where([["is_del", "=", 0], ["traNo", "=", $value["viceNo"]]])->find(); $temp['worder_fee'] += $value['cancel_fee']; $temp['order_used'] -= $value['cancel_fee']; $temp['order_status'] = $temp['worder_fee'] == $temp['total_fee'] ? 1 : 2; $temp['updatetime'] = date("Y-m-d H:i:s"); $trainfo[] = $temp; } } } if ($assinfo['type'] == 2) { $invinfo = Db::name("invoice_pool")->where("invNo", "=", $assinfo['codeNo'])->find(); if ($assinfo['rela_form'] == 4) { $trainfo = []; foreach ($list as $value) { $temp = Db::name("trade_pool")->where([["is_del", "=", 0], ["traNo", "=", $value["viceNo"]]])->find(); $temp['winv_fee'] += $value['cancel_fee']; $temp['inv_used'] -= $value['cancel_fee']; $temp['inv_status'] = $temp['winv_fee'] ==$temp['total_fee'] ? 1 : 2; $temp['updatetime'] = date("Y-m-d H:i:s"); $trainfo[] = $temp; } } } if ($assinfo['type'] == 3) { // $invinfo = Db::name("invoice_pool")->where("invNo","=",$assinfo['mainNo'])->find(); $trainfo = Db::name("trade_pool")->where("traNo", "=", $assinfo['codeNo'])->find(); if ($assinfo['rela_form'] == 3) { $orderinfo = []; foreach ($list as $value) { $temp = Db::name("order_pool")->where([["is_del", "=", 0], ["orderNo", "=", $value["viceNo"]]])->find(); $temp['wfund_fee'] += $value['cancel_fee']; $temp['fund_used'] -= $value['cancel_fee']; $temp['fund_status'] = $temp['wfund_fee'] == $temp['total_amount'] ? 1 : 2; $temp['updatetime'] = date("Y-m-d H:i:s"); $del= $this->qrd_delet($temp['orderNo'],$value['cancel_fee']); if(!$del){ Db::rollback(); return app_show(1005, "核销申请取消失败"); } $orderinfo[] = $temp; } } if ($assinfo['rela_form'] == 5) { $invinfo = []; foreach ($list as $value) { $temp = Db::name("invoice_pool")->where([["is_del", "=", 0], ["invNo", "=", $value["viceNo"]]])->find(); $temp['wtrade_fee'] += $value['cancel_fee']; $temp['fund_used'] -= $value['cancel_fee']; $temp['trade_status'] = $temp['wtrade_fee'] ==$temp['inv_value'] ? 1: 2; $temp['updatetime'] = date("Y-m-d H:i:s"); $invinfo[] = $temp; } } } if ($orderinfo) { if ($assinfo['rela_form'] == 1) { $orderinfo['winv_fee'] += $assinfo['cancel_total']; $orderinfo['inv_used'] -= $assinfo['cancel_total']; $orderinfo['inv_status'] = $orderinfo['winv_fee'] ==$orderinfo['total_amount'] ? 1 : 2; $orderinfo['updatetime'] = date("Y-m-d H:i:s"); Db::name("order_pool")->save($orderinfo); $del= $this->qrd_delet_inv($orderinfo['orderNo'],$assinfo['cancel_total']); if(!$del){ Db::rollback(); return app_show(1005, "核销申请取消失败"); } } if ($assinfo['rela_form'] == 2) { $orderinfo['wfund_fee'] += $assinfo['cancel_total']; $orderinfo['fund_used'] -= $assinfo['cancel_total']; $orderinfo['fund_status'] = $orderinfo['wfund_fee']==$orderinfo['total_amount'] ? 1 : 2; $orderinfo['updatetime'] = date("Y-m-d H:i:s"); Db::name("order_pool")->save($orderinfo); $del= $this->qrd_delet($orderinfo['orderNo'],$assinfo['cancel_total']); if(!$del){ Db::rollback(); return app_show(1005, "核销申请取消失败"); } } if ($assinfo['type'] == 3) { foreach ($orderinfo as $value) { Db::name("order_pool")->save($value); } } } if ($invinfo) { if ($assinfo["type"] == 2) { $invinfo["wtrade_fee"] += $assinfo['cancel_total']; $invinfo["fund_used"] -= $assinfo['cancel_total']; $invinfo["trade_status"] = $invinfo["wtrade_fee"] ==$invinfo['inv_value'] ? 1 : 2; $invinfo['updatetime'] = date("Y-m-d H:i:s"); Db::name("invoice_pool")->save($invinfo); } else { foreach ($invinfo as $value) { Db::name("invoice_pool")->save($value); } } } if ($trainfo) { if ($assinfo['rela_form'] == 3) { $trainfo['worder_fee'] += $assinfo['cancel_total']; $trainfo['order_used'] -= $assinfo['cancel_total']; $trainfo['order_status'] = $trainfo['worder_fee'] ==$trainfo['total_fee'] ? 1 : 2; $trainfo['updatetime'] = date("Y-m-d H:i:s"); Db::name("trade_pool")->save($trainfo); } if ($assinfo['rela_form'] == 5) { $trainfo['winv_fee'] += $assinfo['cancel_total']; $trainfo['inv_used'] -= $assinfo['cancel_total']; $trainfo['inv_status'] = $trainfo['winv_fee']==$trainfo['total_fee'] ? 1 : 2; $trainfo['updatetime'] = date("Y-m-d H:i:s"); Db::name("trade_pool")->save($trainfo); } if ($assinfo["rela_form"] == 2 || $assinfo["rela_form"] == 4) { foreach ($trainfo as $value) { Db::name("trade_pool")->save($value); } } } Db::commit(); return app_show(0, "核销申请取消成功"); } Db::rollback(); return app_show(1005, "核销申请取消失败"); } catch (\Exception $e) { Db::rollback(); return error_show(1005, $e->getMessage()); } } /** * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function GetList() { $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']); } $condition = [['is_del', "=", 0],['status',"=",3]]; $guserinfo =GetUserInfo($token); if(isset($guserinfo['code']) && $guserinfo['code']!=0){ return error_show($guserinfo['code'],$guserinfo['message']); } $check = checkRole($guserinfo['data']['roleid'],57); if($check){ $condition[]=["apply_id","=", $guserinfo['data']['id']]; } // $companyNo = isset($post['tradeNo'])&&$post['tradeNo']!=""?trim($post['tradeNo']):""; $companyNo = isset($post['companyNo']) && $post['companyNo'] != "" ? trim($post['companyNo']) : ""; $codeNo = isset($post['codeNo']) && $post['codeNo'] != "" ? trim($post['codeNo']) : ""; $assocNo = isset($post['assocNo']) && $post['assocNo'] != "" ? trim($post['assocNo']) : ""; $type = isset($post['type']) && $post['type'] != "" ? intval($post['type']) : 1; $page = isset($post['page']) && $post['page'] != "" ? intval($post['page']) : 1; $size = isset($post['size']) && $post['size'] != "" ? intval($post['size']) : 10; if ($companyNo != "") { $condition[] = ["companyNo", "=", $companyNo]; } // $condition[] = ["type", "=", $type]; if($type==1){ $field = Db::raw("if(type=1,codeNo,if(type=3,viceNo,'')) as keyno"); $condition[]=['rela_form',"in",[1,2,3]]; if ($codeNo != "") { $order = Db::name("order_info")->alias('a')->leftJoin("cfp_order_pool b","a.orderNo=b.orderNo and b.is_del=0") ->where("qrdNo","like","%{$codeNo}%")->column("a.orderNo"); $condition[]=['codeNo|viceNo',"in",$order]; } }else{ if ($codeNo != "") { $condition[] = ["codeNo|viceNo", "like", "%{$codeNo}%"]; } } if($type==2){ $field = Db::raw("if(type=2,codeNo,if(type<>2,viceNo,'')) as keyno"); $condition[]=['rela_form',"in",[1,4,5]]; } if($type==3){ $field = Db::raw("if(type=3,codeNo,if(type<>3,viceNo,'')) as keyno"); $condition[]=['rela_form',"in",[2,3,4,5]]; } $count = Db::name("assoc_list")->where($condition)->field("{$field}")->group("keyno")->count(); $total = ceil($count / $size) > 1 ? ceil($count / $size) : 1; $page = $page >= $total ? intval($total) : $page; $list = Db::name("assoc_list")->where($condition)->field("{$field}") ->page(intval($page), $size)->group("keyno")->select(); $data = []; foreach ($list as $value) { $data[] = $this->GetRela($type,$value['keyno']); } return app_show(0, "获取成功", ["list" => $data, "count" => $count]); } /** * @param int $type * @param $mainNo * @return array[] * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ private function GetRela($type,$assoc) { $condition = [["is_del", "=", 0]]; $data = ["orderinfo" => [], "invinfo" => [], "tradeinfo" => [],"dashd"=>""]; $order = []; $inv = []; $trad = []; $assocall = Db::name("assoc_list")->where([["is_del","=",0],['status',"=",3],['bstatus',"=",1],["codeNo|viceNo", "=",$assoc]])->select()->toArray(); if ($type == 1) { if(!empty($assocall)){ $condition[] = ["orderNo", "=", $assoc]; $order[] = Db::name("order_pool")->where($condition)->field("orderNo,companyNo,sales_id,sales_name,total_amount,inv_status,fund_status,fund_fee,inv_fee,wfund_fee,winv_fee,addtime")->find(); isset($orderdat) ?$order[]=$orderdat :''; foreach ($assocall as $value){ if ($value["rela_form"] == 1) { $inv[] = Db::name("invoice_pool")->where("invNo", "=", $value["viceNo"])->field("invNo,inv_in,apply_id,apply_name,inv_value,trade_status,order_status,aorder_fee,atrade_fee,worder_fee,wtrade_fee,addtime,refund_status")->find(); } if ($value["rela_form"] == 2) { $trad[] = Db::name("trade_list")->where("traNo", "=", $value["viceNo"])->field("traNo,companyNo,trade_out,trade_in,total_fee,inv_status,order_status,order_fee,inv_fee,worder_fee,winv_fee,addtime,refund_status")->find(); } if($value["rela_form"] == 3){ $trad[] = Db::name("trade_list")->where("traNo", "=", $value["codeNo"])->field("traNo,companyNo,trade_out,trade_in,total_fee,inv_status,order_status,order_fee,inv_fee,worder_fee,winv_fee,addtime,refund_status")->find(); } } } } if ($type== 2) { $condition[] = ["invNo", "=", $assoc]; $inv[] = Db::name("invoice_pool")->where($condition)->field("invNo,inv_in,apply_id,apply_name,inv_value,trade_status,order_status,aorder_fee,atrade_fee,worder_fee,wtrade_fee,refund_status,addtime")->find(); if(!empty($assocall)){ foreach ($assocall as $value){ if ($value["rela_form"] == 1) { $order[] = Db::name("order_pool")->where("orderNo", "=", $value["codeNo"])->field("orderNo,companyNo,sales_id,sales_name,total_amount,inv_status,fund_status,fund_fee,inv_fee,wfund_fee,winv_fee,addtime")->find(); } if ($value["rela_form"] == 4) { $trad[] = Db::name("trade_list")->where("traNo", "=", $value["viceNo"])->field("traNo,companyNo,trade_out,trade_in,total_fee,inv_status,order_status,order_fee,inv_fee,worder_fee,winv_fee,refund_status,addtime")->find(); } if($value["rela_form"] == 5){ $trad[] = Db::name("trade_list")->where("traNo", "=", $value["codeNo"])->field("traNo,companyNo,trade_out,trade_in,total_fee,inv_status,order_status,order_fee,inv_fee,worder_fee,winv_fee,refund_status,addtime")->find(); } } } } if ($type== 3) { $condition[] = ["traNo", "=", $assoc]; $trad[] = Db::name("trade_list")->where($condition)->field("traNo,companyNo,trade_out,trade_in,total_fee,inv_status,order_status,order_fee,inv_fee,worder_fee,winv_fee,refund_status,addtime")->find(); if(!empty($assocall)){ foreach ($assocall as $value){ if ($value["rela_form"] == 2) { $order[] = Db::name("order_pool")->where("orderNo", "=", $value["codeNo"])->field("orderNo,companyNo,sales_id,sales_name,total_amount,inv_status,fund_status,fund_fee,inv_fee,wfund_fee,winv_fee,addtime")->find(); } if ($value["rela_form"] == 3) { $order[] = Db::name("order_pool")->where("orderNo", "=", $value["viceNo"])->field("orderNo,companyNo,sales_id,sales_name,total_amount,inv_status,fund_status,fund_fee,inv_fee,wfund_fee,winv_fee,addtime")->find(); } if ($value["rela_form"] == 4) { $inv[] = Db::name("invoice_pool")->where("invNo", "=", $value["codeNo"])->field("invNo,inv_in,apply_id,apply_name,inv_value,trade_status,order_status,aorder_fee,atrade_fee,worder_fee,wtrade_fee,refund_status,addtime")->find(); } if($value["rela_form"] == 5){ $inv[] = Db::name("invoice_pool")->where("invNo", "=", $value["viceNo"])->field("invNo,inv_in,apply_id,apply_name,inv_value,trade_status,order_status,aorder_fee,atrade_fee,worder_fee,wtrade_fee,refund_status,addtime")->find(); } } } } if (!empty($order)) { foreach ($order as $val){ $good = Db::name("order_info")->where([["orderNo", "=", $val['orderNo']], ["status", "=", 1]]) ->select(); $val['good'] = []; $orderno = []; foreach ($good as $key => $value) { $tep = Db::name("qrd_list")->where("sequenceNo", "=", $value["goodNo"])->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,pay_status,inv_status,inv_num") ->find(); $tep['goldprice'] = isset($tep['goldprice']) ? sprintf("%.2f", $tep['goldprice']) : ""; $tep['price'] = isset($tep['price']) ? sprintf("%.2f", $tep['price']) : ""; $tep['total_fee'] = isset($tep['total_fee']) ? sprintf("%.2f", $tep['total_fee']) : ""; $tep['apay_fee'] = sprintf("%.2f", $tep['apay_fee']); $tep['wpay_fee'] = sprintf("%.2f", $tep['wpay_fee']); $tep['ainv_fee'] = sprintf("%.2f", $tep['ainv_fee']); $tep['winv_fee'] = sprintf("%.2f", $tep['winv_fee']); $tep['num'] = intval($tep['num']); $tep['inv_num'] = isset($tep['inv_num']) ? sprintf("%d", $tep['inv_num']) : "0"; $val['good'][] = $tep; $orderno[$value['qrdNo']]['qrdNo']=$value['qrdNo']; isset($orderno[$value['qrdNo']]['total_fee']) ? $orderno[$value['qrdNo']]['total_fee']+=$value['total_fee'] : $orderno[$value['qrdNo']]['total_fee']=$value['total_fee']; isset($orderno[$value['qrdNo']]['afund_fee']) ? $orderno[$value['qrdNo']]['afund_fee']+=$value['afund_fee'] : $orderno[$value['qrdNo']]['afund_fee']=$value['afund_fee']; isset($orderno[$value['qrdNo']]['ainv_fee']) ? $orderno[$value['qrdNo']]['ainv_fee']+=$value['ainv_fee'] : $orderno[$value['qrdNo']]['ainv_fee']=$value['ainv_fee']; isset($orderno[$value['qrdNo']]['wfund_fee']) ? $orderno[$value['qrdNo']]['wfund_fee']+=$value['wfund_fee'] : $orderno[$value['qrdNo']]['wfund_fee']=$value['wfund_fee']; isset($orderno[$value['qrdNo']]['winv_fee']) ? $orderno[$value['qrdNo']]['winv_fee']+=$value['winv_fee'] : $orderno[$value['qrdNo']]['winv_fee']=$value['winv_fee']; isset($orderno[$value['qrdNo']]['inv_fee']) ? $orderno[$value['qrdNo']]['inv_fee']+=$value['winv_fee'] : $orderno[$value['qrdNo']]['inv_fee']=$value['inv_fee']; isset($orderno[$value['qrdNo']]['fund_fee']) ? $orderno[$value['qrdNo']]['fund_fee']+=$value['fund_fee'] : $orderno[$value['qrdNo']]['fund_fee']=$value['fund_fee']; } array_walk($orderno,function (&$value){ $value['total_fee'] = round( $value['total_fee'],2); $value['afund_fee'] = round( $value['afund_fee'],2); $value['ainv_fee'] = round( $value['ainv_fee'],2); $value['wfund_fee'] = round( $value['wfund_fee'],2); $value['winv_fee'] = round( $value['winv_fee'],2); $value['inv_fee'] = round( $value['inv_fee'],2); $value['fund_fee'] = round( $value['fund_fee'],2); }); $customer = Db::name("customer_info")->where("companyNo", "=", $val['companyNo'])->find(); $val["companyName"] = $customer['companyName']; $val["qrdNo"] = array_values($orderno); $data["orderinfo"][] = $val; } }else{ $data['dashd']="orderinfo"; } if (!empty($inv)) { foreach ($inv as $val){ $customer = Db::name("customer_info")->where("companyNo", "=", $val['inv_in'])->find(); $val["companyName"] = $customer['companyName']; $data['invinfo'][] = $val; } }else{ $data['dashd']="invinfo"; } if (!empty($trad)) { foreach ($trad as $val){ $customer = Db::name("customer_info")->where("companyNo", "=", $val['companyNo'])->find(); $val["companyName"] = $customer['companyName']; $data['tradeinfo'][] = $val; } }else{ $data['dashd']="tradeinfo"; } return $data; } public function GetRelaList() { $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"] != "" ? intval($post['type']) : 1; $codeNo = isset($post['codeNo']) && $post['codeNo'] != "" ? trim($post['codeNo']) : ""; if ($codeNo == "") { return error_show(1004, "参数codeNo 不能为空"); } $condition = [["is_del", "=", "0"],['status',"=",3], ["codeNo|viceNo", "=", $codeNo]]; $list = Db::name("assoc_list")->where( $condition)->field("id,codeNo,total_fee,balance,type,rela_form,cancel_total,viceNo,vice_total,vice_fee,cancel_fee,addtime,bstatus") ->select(); $data=[]; foreach ($list as $value){ $value['qrdNo'] =[]; if($value['type']==1){ $order = Db::name("order_info")->where([["orderNo","=",$value['codeNo']],['status',"=",1]]) ->field("sum(total_fee) as total_fee,sum(wfund_fee) as wfund_fee,sum(fund_fee) as fund_fee,sum(afund_fee) as afund_fee, sum(ainv_fee) as ainv_fee,sum(inv_fee) as inv_fee,sum(winv_fee) as winv_fee,qrdNo")->group('qrdNo')->select()->toArray(); $value['qrdNo'] = $order; } if($value['rela_form']==3){ $order = Db::name("order_info")->where([["orderNo","=",$value['viceNo']],['status',"=",1]]) ->field("sum(total_fee) as total_fee,sum(wfund_fee) as wfund_fee,sum(fund_fee) as fund_fee,sum(afund_fee) as afund_fee, sum(ainv_fee) as ainv_fee,sum(inv_fee) as inv_fee,sum(winv_fee) as winv_fee,qrdNo")->group('qrdNo')->select()->toArray(); $value['qrdNo'] = $order; } $data[]=$value; } return app_show(0, "获取成功", $data); } /** * @param $orderNo * @param $balance * @return bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ private function updateQrd($orderNo,$balance) { $orderinfo = Db::name("order_pool")->where([["orderNo", "=", $orderNo], ["is_del", "=", 0]])->find(); if (empty($orderinfo)) { return false; } $orderlist = Db::name("order_info")->where([["orderNo", "=", $orderNo], ["status", "=", 1]])->select(); if (empty($orderlist)) { return false; } foreach ($orderlist as $value) { if($balance==0){ break; } if($value['wfund_fee'] == 0){ continue; } $order_fee=0; if($value['wfund_fee']<=$balance){ $order_fee = $value['wfund_fee']; $balance -=$value['wfund_fee']; $value['fund_fee'] += $value['wfund_fee']; $value['wfund_fee'] = 0; }else{ $value['fund_fee'] += $balance; $value['wfund_fee']-= $balance; $order_fee = $balance; $balance=0; } $value['updatetime'] = date("Y-m-d H:i:s"); $orde = Db::name("order_info")->save($value); if(!$orde){ return false; } $qrdinfo = Db::name("qrd_info")->where([["sequenceNo", "=", $value['goodNo']]])->field("id,ShortText1617650701648,Number1618249202608,Number1618249205231,Number1618249146997,number1618249149738,ShortText1618559043560,number1618249258956,ShortText1618559274859,inving_fee,paying_fee")->find(); if (($order_fee <= $qrdinfo['number1618249149738'])||($order_fee <= $qrdinfo['Number1618249146997']&& $orderinfo['type']==4)) { $qrdinfo['paying_fee'] += $order_fee; if($orderinfo['type']==4){ $qrdinfo['Number1618249146997'] -= $order_fee; }else{ $qrdinfo['number1618249149738'] -= $order_fee; } //$qrdinfo['number1618249258956'] += $value['good_num']; // $qrdinfo['ShortText1618559043560'] = $value['total_fee'] < $qrdinfo['number1618249149738'] ? "2" : "3"; $qinfo = Db::name("qrd_info")->save($qrdinfo); if ($qinfo) { $qrdp = Db::name("qrd")->where([["sequenceNo", "=", $qrdinfo['ShortText1617650701648']]])->find(); if (($qrdp['wpay_fee'] >= $order_fee) || ($qrdp['apay_fee'] >= $order_fee &&$orderinfo['type']==4 )) { if($orderinfo['type']==4) { $qrdp['apay_fee'] -= $order_fee; }else{ $qrdp['wpay_fee'] -= $order_fee; } $qrdp['pay_fee'] += $order_fee; // $qrdp['inv_status'] = $qrdp['winv_fee'] == 0 ? 3 : 2; $qrd = Db::name("qrd")->save($qrdp); if(!$qrd){ return false; } }else { return false; } }else { return false; } } else { return false; } } return true; } private function qrd_sure($orderNo,$balance){ $orderinfo = Db::name("order_pool")->where([["orderNo", "=", $orderNo], ["is_del", "=", 0]])->find(); if (empty($orderinfo)) { return false; } $orderlist = Db::name("order_info")->where([["orderNo", "=", $orderNo], ["status", "=", 1]])->select(); if (empty($orderlist)) { return false; } foreach ($orderlist as $value) { if($balance==0){ break; } if($value['fund_fee'] == 0){ continue; } $order_fee=0; if($value['fund_fee']<=$balance){ $order_fee = $value['fund_fee']; $balance -=$value['fund_fee']; $value['afund_fee'] += $value['fund_fee']; $value['fund_fee'] = 0; }else{ $value['afund_fee'] += $balance; $value['fund_fee']-= $balance; $order_fee = $balance; $balance=0; } $value['updatetime'] = date("Y-m-d H:i:s"); $orde = Db::name("order_info")->save($value); if(!$orde){ return false; } $qrdinfo = Db::name("qrd_info")->where([["sequenceNo", "=", $value['goodNo']]])->field("id,ShortText1617650701648,Number1618249202608,Number1618249205231,Number1618249146997,number1618249149738,ShortText1618559043560,number1618249258956,ShortText1618559274859,inving_fee,paying_fee")->find(); if ($order_fee <= $qrdinfo['paying_fee']) { $qrdinfo['paying_fee'] -= $order_fee; if($orderinfo['type']==4){ $qrdinfo['number1618249149738'] += $order_fee; $qrdinfo['ShortText1618559043560'] = $qrdinfo['Number1618249146997']>0 ? "2" : "1"; }else{ $qrdinfo['Number1618249146997'] += $order_fee; $qrdinfo['ShortText1618559043560'] = $qrdinfo['number1618249149738']>0 ? "2" : "3"; } $qinfo = Db::name("qrd_info")->save($qrdinfo); if ($qinfo) { $qrdp = Db::name("qrd")->where([["sequenceNo", "=", $qrdinfo['ShortText1617650701648']]])->find(); if ($qrdp['pay_fee'] >= $order_fee) { if($orderinfo['type']==4){ $qrdp['pay_fee'] -= $order_fee; $qrdp['wpay_fee'] += $order_fee; $qrdp['pay_status'] = $qrdp['apay_fee'] == 0 ? 1 : 2; }else{ $qrdp['pay_fee'] -= $order_fee; $qrdp['apay_fee'] += $order_fee; $qrdp['pay_status'] = $qrdp['wpay_fee'] == 0 ? 3 : 2; } $qrd = Db::name("qrd")->save($qrdp); if(!$qrd){ return false; } }else { return false; } }else { return false; } } else { return false; } } return true; } private function qrd_delet($orderNo,$balance){ $orderinfo = Db::name("order_pool")->where([["orderNo", "=", $orderNo], ["is_del", "=", 0]])->find(); if (empty($orderinfo)) { return false; } $orderlist = Db::name("order_info")->where([["orderNo", "=", $orderNo], ["status", "=", 1]])->select(); if (empty($orderlist)) { return false; } foreach ($orderlist as $value) { if($balance==0){ break; } if($value['fund_fee'] == 0){ continue; } $order_fee=0; if($value['fund_fee']<=$balance){ $order_fee = $value['fund_fee']; $balance -=$value['fund_fee']; $value['wfund_fee'] += $value['fund_fee']; $value['fund_fee'] = 0; }else{ $value['fund_fee'] -= $balance; $value['wfund_fee']+= $balance; $order_fee = $balance; $balance=0; } $value['updatetime'] = date("Y-m-d H:i:s"); $orde = Db::name("order_info")->save($value); if(!$orde){ return false; } $qrdinfo = Db::name("qrd_info")->where([["sequenceNo", "=", $value['goodNo']]])->field("id,ShortText1617650701648,Number1618249202608,Number1618249205231,Number1618249146997,number1618249149738,ShortText1618559043560,number1618249258956,ShortText1618559274859,inving_fee,paying_fee")->find(); if ($order_fee <= $qrdinfo['paying_fee']) { $qrdinfo['paying_fee'] -= $order_fee; if($orderinfo['type']==4){ $qrdinfo['Number1618249146997'] += $order_fee; }else{ $qrdinfo['number1618249149738'] += $order_fee; } //$qrdinfo['number1618249258956'] += $value['good_num']; // $qrdinfo['ShortText1618559043560'] = $value['total_fee'] < $qrdinfo['number1618249149738'] ? "2" : "3"; $qinfo = Db::name("qrd_info")->save($qrdinfo); if ($qinfo) { $qrdp = Db::name("qrd")->where([["sequenceNo", "=", $qrdinfo['ShortText1617650701648']]])->find(); if ($qrdp['pay_fee'] >= $order_fee) { if($orderinfo['type']==4){ $qrdp['apay_fee'] += $order_fee; $qrdp['pay_fee'] -= $order_fee; }else{ $qrdp['wpay_fee'] += $order_fee; $qrdp['pay_fee'] -= $order_fee; } // $qrdp['inv_status'] = $qrdp['winv_fee'] == 0 ? 3 : 2; $qrd = Db::name("qrd")->save($qrdp); if(!$qrd){ return false; } }else { return false; } }else { return false; } } else { return false; } } return true; } /** * @param $orderNo * @param $balance * @return bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ private function updateQrd_inv($orderNo,$balance) { $orderinfo = Db::name("order_pool")->where([["orderNo", "=", $orderNo], ["is_del", "=", 0]])->find(); if (empty($orderinfo)) { return false; } $orderlist = Db::name("order_info")->where([["orderNo", "=", $orderNo], ["status", "=", 1]])->select(); if (empty($orderlist)) { return false; } foreach ($orderlist as $value) { if($balance==0){ break; } if($value['winv_fee'] == 0){ continue; } $order_fee=0; if($value['winv_fee']<=$balance){ $order_fee = $value['winv_fee']; $balance -=$value['winv_fee']; $value['inv_fee'] += $value['winv_fee']; $value['winv_fee'] = 0; }else{ $value['inv_fee'] += $balance; $value['winv_fee']-= $balance; $order_fee = $balance; $balance=0; } $value['updatetime'] = date("Y-m-d H:i:s"); $orde = Db::name("order_info")->save($value); if(!$orde){ return false; } $qrdinfo = Db::name("qrd_info")->where([["sequenceNo", "=", $value['goodNo']]])->field("id,ShortText1617650701648,Number1618249202608,Number1618249205231,Number1618249146997,number1618249149738,ShortText1618559043560,number1618249258956,ShortText1618559274859,inving_fee,paying_fee")->find(); if (($order_fee <= $qrdinfo['Number1618249205231'])||($order_fee <= $qrdinfo['Number1618249202608']&&$orderinfo['type']==4)) { $qrdinfo['inving_fee'] += $order_fee; if($orderinfo['type']==4){ $qrdinfo['Number1618249202608'] -= $order_fee; // $qrdinfo['number1618249258956'] += $value['good_num']; }else{ $qrdinfo['Number1618249205231'] -= $order_fee; $qrdinfo['number1618249258956'] += $value['good_num']; } // $qrdinfo['ShortText1618559043560'] = $value['total_fee'] < $qrdinfo['number1618249149738'] ? "2" : "3"; $qinfo = Db::name("qrd_info")->save($qrdinfo); if ($qinfo) { $qrdp = Db::name("qrd")->where([["sequenceNo", "=", $qrdinfo['ShortText1617650701648']]])->find(); if(($qrdp['winv_fee'] >= $order_fee)|| ($qrdp['ainv_fee'] >= $order_fee &&$orderinfo['type']==4 )) { if($orderinfo['type']==4){ $qrdp['ainv_fee'] -= $order_fee; $qrdp['inv_fee'] += $order_fee; }else{ $qrdp['winv_fee'] -= $order_fee; $qrdp['inv_fee'] += $order_fee; } // $qrdp['inv_status'] = $qrdp['winv_fee'] == 0 ? 3 : 2; $qrd = Db::name("qrd")->save($qrdp); if(!$qrd){ return false; } }else { return false; } }else { return false; } } else { return false; } } return true; } /** * @param $orderNo * @param $balance * @return bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ private function qrd_sure_inv($orderNo,$balance){ $orderinfo = Db::name("order_pool")->where([["orderNo", "=", $orderNo], ["is_del", "=", 0]])->find(); if (empty($orderinfo)) { return false; } $orderlist = Db::name("order_info")->where([["orderNo", "=", $orderNo], ["status", "=", 1]])->select(); if (empty($orderlist)) { return false; } foreach ($orderlist as $value) { if($balance==0){ break; } if($value['inv_fee'] == 0){ continue; } $order_fee=0; if($value['inv_fee']<=$balance){ $order_fee = $value['inv_fee']; $balance -=$value['inv_fee']; $value['ainv_fee'] += $value['inv_fee']; $value['inv_fee'] = 0; }else{ $value['ainv_fee'] += $balance; $value['inv_fee']-= $balance; $order_fee = $balance; $balance=0; } $value['updatetime'] = date("Y-m-d H:i:s"); $orde = Db::name("order_info")->save($value); if(!$orde){ return false; } $qrdinfo = Db::name("qrd_info")->where([["sequenceNo", "=", $value['goodNo']]])->field("id,ShortText1617650701648,Number1618249202608,Number1618249205231,Number1618249146997,number1618249149738,ShortText1618559043560,number1618249258956,ShortText1618559274859,inving_fee,paying_fee")->find(); if (($order_fee <= $qrdinfo['inving_fee'])||($order_fee <= $qrdinfo['inving_fee']&&$orderinfo['type']==4 )) { if($orderinfo['type']==4 ){ $qrdinfo['inving_fee'] -= $order_fee; //$qrdinfo['number1618249149738'] -= $order_fee; $qrdinfo['Number1618249205231'] += $order_fee; //$qrdinfo['number1618249258956'] += $value['good_num']; $qrdinfo['ShortText1618559274859'] = $qrdinfo['Number1618249202608']>0 ? "2" : "1"; }else{ $qrdinfo['inving_fee'] -= $order_fee; //$qrdinfo['number1618249149738'] -= $order_fee; $qrdinfo['Number1618249202608'] += $order_fee; //$qrdinfo['number1618249258956'] += $value['good_num']; $qrdinfo['ShortText1618559274859'] = $qrdinfo['Number1618249205231']>0 ? "2" : "3"; } $qinfo = Db::name("qrd_info")->save($qrdinfo); if ($qinfo) { $qrdp = Db::name("qrd")->where([["sequenceNo", "=", $qrdinfo['ShortText1617650701648']]])->find(); if ($qrdp['inv_fee'] >= $order_fee || ($qrdp['inv_fee'] >= $order_fee &&$orderinfo['type']==4 )) { if($orderinfo['type']==4){ $qrdp['inv_fee'] -= $order_fee; $qrdp['winv_fee'] += $order_fee; $qrdp['inv_status'] = $qrdp['ainv_fee'] == 0 ? 1 : 2; }else{ $qrdp['inv_fee'] -= $order_fee; $qrdp['ainv_fee'] += $order_fee; $qrdp['inv_status'] = $qrdp['winv_fee'] == 0 ? 3 : 2; } $qrd = Db::name("qrd")->save($qrdp); if(!$qrd){ return false; } }else { return false; } }else { return false; } } else { return false; } } return true; } /** * @param $orderNo * @param $balance * @return bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ private function qrd_delet_inv($orderNo,$balance){ $orderinfo = Db::name("order_pool")->where([["orderNo", "=", $orderNo], ["is_del", "=", 1]])->find(); if (empty($orderinfo)) { return false; } $orderlist = Db::name("order_info")->where([["orderNo", "=", $orderNo], ["status", "=", 1]])->select(); if (empty($orderlist)) { return false; } foreach ($orderlist as $value) { if($balance==0){ break; } if($value['inv_fee'] == 0){ continue; } $order_fee=0; if($value['inv_fee']<=$balance){ $order_fee = $value['inv_fee']; $balance -=$value['inv_fee']; $value['winv_fee'] += $value['inv_fee']; $value['inv_fee'] = 0; }else{ $value['inv_fee'] -= $balance; $value['winv_fee']+= $balance; $order_fee = $balance; $balance=0; } $value['updatetime'] = date("Y-m-d H:i:s"); $orde = Db::name("order_info")->save($value); if(!$orde){ return false; } $qrdinfo = Db::name("qrd_info")->where([["sequenceNo", "=", $value['goodNo']]])->field("id,ShortText1617650701648,Number1618249202608,Number1618249205231,Number1618249146997,number1618249149738,ShortText1618559043560,number1618249258956,ShortText1618559274859,inving_fee,paying_fee")->find(); if ($order_fee <= $qrdinfo['inving_fee']) { $qrdinfo['inving_fee'] -= $order_fee; if($orderinfo['type']==4){ $qrdinfo['Number1618249202608'] += $order_fee; // $qrdinfo['number1618249258956'] += $value['good_num']; }else{ $qrdinfo['Number1618249205231'] += $order_fee; $qrdinfo['number1618249258956'] -= $value['good_num']; } // $qrdinfo['ShortText1618559043560'] = $value['total_fee'] < $qrdinfo['number1618249149738'] ? "2" : "3"; $qinfo = Db::name("qrd_info")->save($qrdinfo); if ($qinfo) { $qrdp = Db::name("qrd")->where([["sequenceNo", "=", $qrdinfo['ShortText1617650701648']]])->find(); if ($qrdp['inv_fee'] >= $order_fee) { if($orderinfo['type']==4){ $qrdp['ainv_fee'] += $order_fee; }else{ $qrdp['winv_fee'] += $order_fee; } $qrdp['inv_fee'] -= $order_fee; // $qrdp['inv_status'] = $qrdp['winv_fee'] == 0 ? 3 : 2; $qrd = Db::name("qrd")->save($qrdp); if(!$qrd){ return false; } }else { return false; } }else { return false; } } else { return false; } } return true; } /**查询退款可关联订单 * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function RefundByTrade(){ $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'] != "" ? intval($post['type']) : 1; $traNo =isset($post['traNo'])&& $post['traNo'] != "" ? trim($post['traNo']) : ""; if($traNo==""){ return error_show(1005,"参数traNo 不能为空"); } $tradeinfo =Db::name("trade_list")->where([["traNo","=",$traNo],['is_del',"=",0]])->find(); if(!$tradeinfo){ return error_show(1005,"数据未找到"); } if($tradeinfo['trade_type']!=1){ return error_show(1005,"数据不是退款资金"); } $refundlist = Db::name("refund")->where([["is_del","=",0],["backNo","=",$traNo],["refund_type","=",1]]) ->select()->toArray(); if(empty($refundlist)){ return error_show(1006,"退款关联资金未找到"); } $tradlist = array_column($refundlist,"relaNo"); $condition = [["is_del","=",0],["codeNo|viceNo","in",$tradlist]]; $condition[] = ["rela_form","in",[2,3]]; $assoc = Db::name("assoc_list")->where($condition)->select()->toArray(); if(empty($assoc)){ return error_show(1005,"未找到关联数据"); } $lsi=[]; foreach ($assoc as $value){ $temp=[]; if($value['rela_form']==2){ $temp['orderNo'] =$value['codeNo']; $temp['cancel'] =$value['cancel_fee']; $temp['is_all'] =0; } if($value['rela_form']==3){ $temp['orderNo'] =$value['viceNo']; $temp['cancel'] =$value['cancel_fee']; $temp['is_all'] =1; } $lsi[]=$temp; } $orderno = array_column($lsi,"orderNo"); $total_fee = array_sum(array_column($lsi,"cancel_fee")); $orderlist = Db::name("order_list")->where("orderNo","in",$orderno)->select()->toArray(); $qrdlsit=[]; if(!empty($orderno)){ foreach ($orderlist as $value){ if(!isset($qrdlsit[$value['qrdNo']])){ $qrdlsit[$value['qrdNo']]= Db::name("qrd")->where([["sequenceNo","=",$value['qrdNo']]]) ->field("sequenceNo,sales_name,sales_depart,customer,total_fee,wpay_fee,apay_fee,pay_fee,winv_fee,ainv_fee,inv_fee,inv_status,pay_status")->find(); } $good = Db::name("qrd_list")->where([["sequenceNo","=",$value['goodNo']]])->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") ->find(); // $good['price'] =isset($value['price']) ? sprintf("%.2f",$value['price']):""; $good['price'] =isset($value['price']) ? sprintf("%.2f",$value['price']):""; $good['total_fee'] =isset($value['total_fee']) ? sprintf("%.2f",$value['total_fee']):""; $good['apay_fee'] = sprintf("%.2f",$value['gafund_fee']); $good['wpay_fee'] = sprintf("%.2f",$value['gwfund_fee']); $good['ainv_fee'] = sprintf("%.2f",$value['gainv_fee']); $good['winv_fee'] = sprintf("%.2f",$value['gwinv_fee']); $good['num'] = intval($value['good_num']); // $good['inv_num'] = isset($good['inv_num']) ? sprintf("%d",$good['inv_num']):"0"; foreach ($lsi as $val){ if($value['orderNo']==$val['orderNo']){ $good['isall'] = $val['is_all']; $good['orderNo'] = $val['orderNo']; } } $qrdlsit[$value['qrdNo']]['good'][]=$good; } } $data = ['orderlist'=>array_values($qrdlsit),"total_fee"=>$lsi]; return app_show(0,"获取成功",$data); } /** * 退款关联可退款记录 * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function AssocRefund(){ $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']); } $guserinfo =GetUserInfo($token); if(isset($guserinfo['code']) && $guserinfo['code']!=0){ return error_show($guserinfo['code'],$guserinfo['message']); } $traNo = isset($post['traNo'])&& $post['traNo']!=""? trim($post['traNo']):""; if($traNo==""){ return error_show(1005,"参数traNo 不能为空"); } $tradeinfo = Db::name("trade_list")->where([['traNo',"=",$traNo],["is_del","=",0]])->find(); if(empty($tradeinfo)){ return error_show(1005,"未找到数据"); } $companyNo = isset($post['companyNo']) && $post['companyNo'] != "" ? trim($post['companyNo']) : ""; $userinfo = GetUserInfo($token); $username = ""; if ($companyNo == "") { return error_show(1004, "参数companyNo 不能为空"); } if (isset($userinfo['code']) && $userinfo['code'] == 0) { $username = isset($userinfo['data']['nickname']) ? $userinfo['data']['nickname'] : ""; } $customer = Db::name("customer_info")->where("companyNo", "=", $companyNo)->find(); if (empty($customer)) { return error_show(1004, "未找到客户企业信息"); } $good = isset($post['good']) && $post['good'] ? explode(",", $post['good']) : ""; if ($good == "" && empty($good)) { return error_show(1004, "商品信息不能为空"); } Db::startTrans(); try { $orderinfo = []; $orderNo = makeNo('ORD'); $total = 0; $fund_fee = 0; $wfund_fee = 0; $inv_fee = 0; $winv_fee = 0; foreach ($good as $value) { $temp = []; $temp['orderNo'] = $orderNo; $temp['goodNo'] = $value['goodNo']; $goocp = Db::name("qrd_list")->where("sequenceNo", "=", $value['goodNo'])->find(); if (!$goocp) { continue; } $temp['good_name'] = $goocp['goodname']; $temp['qrdNo'] = $goocp['qrdNo']; $temp['brand'] = $goocp['brand']; $temp['unit'] = $goocp['unit']; $temp['good_num'] = $value['num']; $temp['price'] = $goocp['price']; $temp['total_fee'] = $value['total_fee']; $temp['wfund_fee'] = $value['total_fee']; $temp['winv_fee'] = $value['total_fee']; $temp['other_fee'] = 0; $temp['status'] = 1; $temp['remark'] = ""; $temp['addtime'] = date("Y-m-d H:i:s"); $temp['updatetime'] = date("Y-m-d H:i:s"); $total += $value['total_fee']; $fund_fee += $value['apay_fee']; $winv_fee += $value['winv_fee']; $inv_fee += $value['ainv_fee']; $wfund_fee += $value['wpay_fee']; $orderinfo[] = $temp; } if($total!=$tradeinfo['worder_fee']){ Db::rollback(); return error_show(1004, "商品总额于资金不符"); } $orderins = Db::name("order_info")->insertAll($orderinfo); if ($orderins) { $order = [ "orderNo" => $orderNo, "companyNo" => $companyNo, "sales_id" => $effetc['data']['user']['id'], "sales_name" => $username, "total_amount" => $total, "inv_status" => 1, "fund_status" => 1, "fund_fee" => 0, "wfund_fee" => $total, "inv_fee" => 0, "winv_fee" => $total, "status" => 0, "type" => 3, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $orderpool = Db::name("order_pool")->insert($order, true); if ($orderpool > 0) { if ($tradeinfo != "" && is_array($tradeinfo)) { $rela = []; $assNo = makeNo("ASC"); $cancel = 0; $balance = $tradeinfo["worder_fee"] > $total ? $total : $tradeinfo["worder_fee"]; $total -= $balance; $sav=[ "worder_fee" =>$tradeinfo['worder_fee']-$balance, "order_used" =>$tradeinfo['order_used']+$balance, "is_order" =>1, "updatetime" =>date("Y-m-d H:i:s") ]; Db::name("trade_pool")->where([["traNo","=",$tradeinfo['traNo']]])->save($sav); $rela = [ "assocNo" => $assNo, "viceNo" => $orderNo, "vice_total" => $order['total_amount'], "vice_fee" => $total, "cancel_fee" => $balance, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $assoc = Db::name("assoc_rela")->insert($rela); if ($assoc) { $data = [ "assocNo" => $assNo, "companyNo" => $companyNo, "type" => 3, "rela_form" => 3, "codeNo" => $tradeinfo["traNo"], "total_fee" => $tradeinfo['total_fee'], "balance" => $tradeinfo['worder_fee'], "cancel_total" => $balance, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $realkey = Db::name("assoc_key")->insert($data); if ($realkey) { Db::name("order_pool")->where("orderNo", "=", $orderNo)->save (["wfund_fee" => $total,'fund_used'=>$balance, "updatetime" => date("Y-m-d H:i:s")]); $qrdup=$this->updateQrd($orderNo,$balance); if(!$qrdup){ Db::rollback(); return error_show(1004, "新建关联申请失败"); } Db::commit(); return app_show(0, "新建关联成功"); } } Db::rollback(); return error_show(1004, "新建关联申请失败"); } } } Db::rollback(); return error_show(1004, "新建关联申请失败"); } catch (\Exception $e) { Db::rollback(); return error_show(1004, $e->getMessage()); } } /** * 退票关联可退资金 * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function RefundAssocInv(){ $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']); } $guserinfo =GetUserInfo($token); if(isset($guserinfo['code']) && $guserinfo['code']!=0){ return error_show($guserinfo['code'],$guserinfo['message']); } // $companyNo = isset($post['tradeNo'])&&$post['tradeNo']!=""?trim($post['tradeNo']):""; $companyNo = isset($post['companyNo']) && $post['companyNo'] != "" ? trim($post['companyNo']) : ""; $type = isset($post['type']) && $post['type'] != "" ? intval($post['type']) : 5; $tralog = isset($post['tralog']) && $post['tralog'] != "" ? $post['tralog'] : ""; $invNo = isset($post['invNo']) && $post['invNo'] != "" ? $post['invNo'] : ""; if (!in_array($type, [4, 5])) { return error_show(1004, "参数type 有误"); } if ($invNo == "") { return error_show(1004, "缺少必要参数invNo"); } if ($tralog == "") { return error_show(1004, "缺少必要参数tralog"); } $inv = Db::name("invoice_pool")->where([["is_del", "=", 0], ["invNo", "=", $invNo]])->find(); if (!$inv) { return error_show(1004, "未找到对应的发票数据"); } if ($inv['type_check']!=5) { return error_show(1004, "发票不属于退票数据"); } Db::startTrans(); try { $rela = []; $trade = 0; $assNo = makeNo("ASC"); foreach ($tralog as $value) { if(isset($value['traNo']) && isset($value['cancel'])){ $trainfo = Db::name("trade_pool")->where([["traNo","=",$value['traNo']],["is_del","=",0]]) ->find(); if($trainfo['inv_fee']>=$value['cancel']){ $trade+=$value['cancel']; $trainfo['inv_fee']-=$value['cancel']; $trainfo['inv_used']+=$value['cancel']; $trainfo['updatetime']=date("Y-m-d H:i:s"); Db::name("trade_pool")->save($trainfo); $rela[] = [ "assocNo" => $assNo, "viceNo" => $value['traNo'], "vice_total" => $trainfo['total_fee'], "vice_fee" => $value['inv_fee'], "cancel_fee" => $value['cancel'], "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; }else{ Db::rollback(); return error_show(1005,"资金核销金额不足"); } }else{ Db::rollback(); return error_show(1005,"参数tralog 有误"); } } if($inv['wtrade_fee']<$trade){ Db::rollback(); return error_show(1005,"发票核销余额不足"); } $assoc = Db::name("assoc_rela")->insertAll($rela); if ($assoc) { $data = [ "assocNo" => $assNo, "companyNo" => $companyNo, "type" => 2, "apply_id"=> $guserinfo["data"]["id"], "apply_name"=> $guserinfo["data"]["nickname"], "rela_form" =>4, "codeNo" => $tralog["invNo"], "total_fee" => $tralog['inv_value'], "balance" => $tralog['wtrade_fee']-$trade, "cancel_total" => $trade, "status" => 1, "addtime" => date("Y-m-d H:i:s"), "updatetime" => date("Y-m-d H:i:s") ]; $realkey = Db::name("assoc_key")->insert($data); if ($realkey) { $tralog['wtrade_fee'] -= $trade; $tralog['fund_used'] += $trade; $tralog['updatetime'] = date("Y-m-d H:i:s"); Db::name("invoice_pool")->save($tralog); Db::commit(); return app_show(0, "新建关联成功"); } } Db::rollback(); return error_show(1005,"新建关联失败"); } catch (\Exception $e) { Db::rollback(); return error_show(1006, $e->getMessage()); } } /*** *退票可关联数据 订单资金 * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function RefundByInv(){ $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'] != "" ? intval($post['type']) : 1; $invNo =isset($post['invNo'])&& $post['invNo'] != "" ? trim($post['invNo']) : ""; if($invNo==""){ return error_show(1005,"参数invNo 不能为空"); } $invinfo =Db::name("invoice_pool")->where([["invNo","=",$invNo],['is_del',"=",0]])->find(); if(!$invinfo){ return error_show(1005,"数据未找到"); } if($invinfo['type_check']!=5){ return error_show(1005,"数据不是退票数据"); } $refundlist = Db::name("refund")->where([["is_del","=",0],["backNo","=",$invNo],["refund_type","=",2]]) ->select()->toArray(); if(empty($refundlist)){ return error_show(1006,"退票关联发票未找到"); } $tradlist = array_column($refundlist,"relaNo"); $condition = [["is_del","=",0],["codeNo|viceNo","in",$tradlist]]; $condition[] = ["rela_form","in",[1,4,5]]; $assoc = Db::name("assoc_list")->where($condition)->select()->toArray(); if(empty($assoc)){ return error_show(1005,"未找到关联数据"); } $lsi=[]; foreach ($assoc as $value){ $temp=[]; if($value['rela_form']==4){ $temp['traNo'] =$value['viceNo']; $temp['cancel'] =$value['cancel_fee']; $temp['is_all'] =1; $lsi["trade"][]=$temp; } if($value['rela_form']==5){ $temp['traNo'] =$value['codeNo']; $temp['cancel'] =$value['cancel_fee']; $temp['is_all'] =1; $lsi["trade"][]=$temp; } if($value['rela_form']==1){ $temp['orderNo'] =$value['codeNo']; $temp['cancel'] =$value['cancel_fee']; $temp['is_all'] =1; $lsi["order"][]=$temp; } } if(isset($lsi['order']) && !empty($lsi['order'])){ $orderno = array_column($lsi['order'],"orderNo"); $total_fee = array_sum(array_column($lsi['order'],"cancel_fee")); $orderlist = Db::name("order_list")->where("orderNo","in",$orderno)->select()->toArray(); $qrdlsit=[]; if(!empty($orderno)){ foreach ($orderlist as $value){ if(!isset($qrdlsit[$value['qrdNo']])){ $qrdlsit[$value['qrdNo']]= Db::name("qrd")->where([["sequenceNo","=",$value['qrdNo']]]) ->field("sequenceNo,sales_name,sales_depart,customer,total_fee,wpay_fee,apay_fee,pay_fee,winv_fee,ainv_fee,inv_fee,inv_status,pay_status")->find(); } $good = Db::name("qrd_list")->where([["sequenceNo","=",$value['goodNo']]])->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") ->find(); // $good['price'] =isset($value['price']) ? sprintf("%.2f",$value['price']):""; $good['price'] =isset($value['price']) ? sprintf("%.2f",$value['price']):""; $good['total_fee'] =isset($value['total_fee']) ? sprintf("%.2f",$value['total_fee']):""; $good['apay_fee'] = sprintf("%.2f",$value['gafund_fee']); $good['wpay_fee'] = sprintf("%.2f",$value['gwfund_fee']); $good['ainv_fee'] = sprintf("%.2f",$value['gainv_fee']); $good['winv_fee'] = sprintf("%.2f",$value['gwinv_fee']); $good['num'] = intval($value['good_num']); // $good['inv_num'] = isset($good['inv_num']) ? sprintf("%d",$good['inv_num']):"0"; foreach ($lsi['order'] as $val){ if($value['orderNo']==$val['orderNo']){ $good['isall'] = $val['is_all']; $good['orderNo'] = $val['orderNo']; } } $qrdlsit[$value['qrdNo']]['good'][]=$good; } } $data = ['orderlist'=>array_values($qrdlsit),"total_fee"=>$lsi['order']]; return app_show(0,"获取成功",$data); } if(isset($lsi['trade']) && !empty($lsi['trade'])){ $tradeno = array_column($lsi['trade'],"traNo"); $tradelist = Db::name("trade_list")->where("traNo","in",$tradeno)->select()->toArray(); $kst=[]; foreach ($tradelist as $value){ $temp=[]; $temp['id']=$value['id']; $temp['traNo']=$value['traNo']; $temp['companyNo']=$value['companyNo']; $customer = Db::name("customer_info")->where([["companyNo","=",$value['companyNo']]])->find(); $temp['companyNo']=$value['companyNo']; $temp['companyName']=$customer['companyName']; $temp['total_fee']= $value['total_fee']; $temp['order_fee']= $value['order_fee']; $temp['order_used']= $value['order_used']; $temp['worder_fee']= $value['worder_fee']; $temp['inv_fee']= $value['inv_fee']; $temp['inv_used']= $value['inv_used']; $temp['winv_fee']= $value['winv_fee']; $temp['inv_status']= $value['inv_status']; $temp['order_status']= $value['order_status']; $temp['isall'] = 0; $temp['cancel'] = $value['inv_fee']; foreach ($lsi['order'] as $val){ if($value['orderNo']==$val['orderNo']){ $temp['isall'] = $val['is_all']; $temp['cancel'] = $val['cancel']; } } $kst[]=$temp; } $data = ['orderlist'=>$kst,"total_fee"=>$lsi['trade']]; return app_show(0,"获取成功",$data); } } }