post['tradNo'])&&$this->post['tradNo']!=""?trim($this->post['tradNo']):""; if($tradNo==""){ return error_show(1004,"参数 tradNo 不能为空"); } $orderArr = isset($this->post['orderArr'])&&!empty($this->post['orderArr'])?$this->post['orderArr']:[]; if(empty($orderArr)){ return error_show(1004,"参数 orderArr 不能为空"); } Db::startTrans(); try{ $logNo=makeNo("TRC"); $trade =Db::name("trade")->where(["tradNo"=>$tradNo,"is_del"=>0])->lock(true)->findOrEmpty(); if(empty($trade)){ Db::rollback(); return error_show(1004,"未找到资金信息"); } $total_fee =array_sum(array_column($orderArr,"trad_fee")); if ($trade['balance']<$total_fee){ Db::rollback(); return error_show(1004,"资金余额不足核销"); } $assoc=[]; foreach ($orderArr as $value){ if(!isset($value['sequenceNo'])||$value['sequenceNo']==""){ Db::rollback(); return error_show(1004,"销售单编号不能为空"); } if(!isset($value['trad_fee'])||$value['trad_fee']==""){ Db::rollback(); return error_show(1004,"销售单核销金额不能为空"); } $qrd =Db::name("qrd_info")->where("sequenceNo","=",$value['sequenceNo'])->field("id,status,pay_fee,wpay_fee,pay_status,totalPrice")->findOrEmpty(); if(empty($qrd)){ Db::rollback(); return error_show(1004,"销售单信息未找到"); } if($qrd['wpay_fee']<$value['trad_fee']){ Db::rollback(); return error_show(1004,"销售单未付款金额不足核销金额"); } $updt=[ "pay_fee"=>$qrd['pay_fee']+$value['trad_fee'], "wpay_fee"=>$qrd['wpay_fee']-$value['trad_fee'], "pay_status"=>2, "status"=>1, "updatetime"=>date("Y-m-d H:i:s") ]; $qrdup = Db::name("qrd_info")->where($qrd)->update($updt); if($qrdup==false){ Db::rollback(); return error_show(1004,"销售单核销金额失败"); } $temp=[ "assocNo"=>makeNo("AS"), "apply_id"=>$this->uid, "apply_name"=>$this->uname, "type"=>2, "orderCode"=>$value['sequenceNo'], "viceCode"=>$logNo, "order_total"=>$qrd['totalPrice'], "vice_total"=>$total_fee, "cancel_fee"=>$value['trad_fee'], "status"=>1, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $assoc[]=$temp; $report=ReportCode::where(["qrdNo"=>$value['sequenceNo']])->find(); $report->setField("logNo",$logNo); $report->setField("tradNo",$tradNo); } $asscin= Db::name("assoc")->insertAll($assoc); if($asscin!=count($assoc)){ Db::rollback(); return error_show(1004,"销售单核销金额关联失败"); } $update=[ "balance"=>$trade['balance']-$total_fee, "used_fee"=>$trade['used_fee']+$total_fee, "status"=>($trade['balance']-$total_fee)==0 ? 2:1, "updatetime"=>date("Y-m-d H:i:s"), ]; $tradup=Db::name("trade")->where($trade)->update($update); if($tradup){ $create = [ "logNo"=>$logNo, "tradNo"=>$tradNo, "apply_id"=>$this->uid, "apply_name"=>$this->uname, "trade_time"=>$trade['trade_time'], "total_fee"=>$total_fee, "status"=>1, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $tradchild =Db::name("trade_pool")->insert($create); if($tradchild){ Db::commit(); return app_show(0,"资金认领成功",["logNo"=>$logNo]); } } Db::rollback(); return error_show(1004,"资金认领失败"); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } // 1待审批2审批通过3审批驳回4退款5解除认领 public function status(){ $logNo = isset($this->post['logNo'])&&$this->post['logNo']!=""?trim($this->post['logNo']):""; if($logNo==""){ return error_show(1004,"参数logNo不能为空"); } $status=isset($this->post['status'])&&$this->post['status']!=""?intval($this->post['status']):""; if($status==""){ return error_show(1004,"参数 status 不能为空"); } $remark=isset($this->post['remark'])&&$this->post['remark']!=""?trim($this->post['remark']):""; if($remark==""){ return error_show(1004,"参数 remark 不能为空"); } Db::startTrans(); try { $logingo= Db::name("trade_pool")->where(["logNo"=>$logNo,"is_del"=>0])->find(); if($logingo==false){ Db::rollback(); return error_show(1004,"资金认领信息未找到"); } $up=["status"=>$status,"updatetime"=>date("Y-m-d H:i:s"),"remark"=>$remark]; $logup = Db::name("trade_pool")->where($logingo)->update($up); if($logup){ if($status==2){ $qrdArr=Db::name("assoc")->where(["viceCode"=>$logNo,"status"=>1,"is_del"=>0])->select()->toArray(); if(!empty($qrdArr)){ foreach ($qrdArr as $value){ $qrd =Db::name("qrd_info")->where(["sequenceNo"=>$value['orderCode']])->field("id,status,pay_fee,apay_fee,wpay_fee,pay_status,totalPrice")->findOrEmpty(); if(empty($qrd)){ Db::rollback(); return error_show(1005,"未找到销售单数据"); } if($qrd['pay_fee']<$value['cancel_fee']){ Db::rollback(); return error_show(1005,"销售单待付金额不足"); } $update =[ "apay_fee"=>$qrd['apay_fee']+$value['cancel_fee'], "pay_fee"=>$qrd['pay_fee']-$value['cancel_fee'], "paytime"=>date("Y-m-d H:i:s"), "pay_status"=>$qrd['wpay_fee']==0 && ($qrd['pay_fee']-$value['cancel_fee'])==0 ? 3:2, "updatetime"=>date("Y-m-d H:i:s") ]; $qrdup =Db::name("qrd_info")->where($qrd)->update($update); if($qrdup==false){ Db::rollback(); return error_show(1005,"销售单更新失败"); } $asscup =[ "status"=>2, "assoc_time"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $assc=Db::name("assoc")->where($value)->update($asscup); if($assc==false){ Db::rollback(); return error_show(1005,"销售单更新失败"); } } } } if($status==3){ $qrdArr=Db::name("assoc")->where(["viceCode"=>$logNo,"status"=>1,"is_del"=>0])->select()->toArray(); if(!empty($qrdArr)){ foreach ($qrdArr as $value){ $qrd =Db::name("qrd_info")->where(["sequenceNo"=>$value['orderCode']])->field("id,status,pay_fee,apay_fee,wpay_fee,pay_status,totalPrice")->findOrEmpty(); if(empty($qrd)){ Db::rollback(); return error_show(1005,"未找到销售单数据"); } if($qrd['pay_fee']<$value['cancel_fee']){ Db::rollback(); return error_show(1005,"销售单待付金额不足"); } $update =[ "wpay_fee"=>$qrd['wpay_fee']+$value['cancel_fee'], "pay_fee"=>$qrd['pay_fee']-$value['cancel_fee'], "pay_status"=>$qrd['apay_fee']==0 && ($qrd['pay_fee']-$value['cancel_fee'])==0 ? 1:2, "status"=>$qrd['apay_fee']==0 && ($qrd['pay_fee']-$value['cancel_fee'])==0 ?0:1, "updatetime"=>date("Y-m-d H:i:s") ]; $qrdup =Db::name("qrd_info")->where($qrd)->update($update); if($qrdup==false){ Db::rollback(); return error_show(1005,"销售单更新失败"); } $asscup =[ "status"=>3, "updatetime"=>date("Y-m-d H:i:s") ]; $assc=Db::name("assoc")->where($value)->update($asscup); if($assc==false){ Db::rollback(); return error_show(1005,"销售单更新失败"); } $report=ReportCode::where(["qrdNo"=>$value['orderCode']])->find(); $report->rmField("logNo",$logNo); } } $trade =Db::name("trade")->where(["tradNo"=>$logingo['tradNo'],"is_del"=>0])->findOrEmpty(); if($trade==false){ Db::rollback(); return error_show(1005,"资金信息未找到"); } if($trade['used_fee']<$logingo['total_fee']){ Db::rollback(); return error_show(1005,"资金信息已认领金额不足"); } $tradup =[ "used_fee"=>$trade['used_fee']-$logingo['total_fee'], "balance"=>$trade['balance']+$logingo['total_fee'], "status"=>($trade['used_fee']-$logingo['total_fee'])==0 ? 0 :1, "updatetime"=>date("Y-m-d H:i:s") ]; $updaT=Db::name("trade")->where($trade)->update($tradup); if($updaT==false){ Db::rollback(); return error_show(1005,"资金信息更新失败"); } } Db::commit(); return app_show(0,"审核成功"); } Db::rollback(); return error_show(1004,"审核失败"); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } //资金信息列表 public function list(){ $condition=[]; $page=isset($this->post['page'])&&$this->post['page']!="" ? intval($this->post['page']) :1; $size=isset($this->post['size'])&&$this->post['size']!="" ? intval($this->post['size']) :15; $name =isset($this->post['name'])&&$this->post['name']!=""? trim($this->post['name']):""; $bank =isset($this->post['bank'])&&$this->post['bank']!=""? trim($this->post['bank']):""; $start =isset($this->post['start'])&&$this->post['start']!=""? trim($this->post['start']):""; $end =isset($this->post['end'])&&$this->post['end']!=""? trim($this->post['end']):""; $status =isset($this->post['status'])&&$this->post['status']!==""? intval($this->post['status']):""; $tradNo =isset($this->post['tradNo'])&&$this->post['tradNo']!=""? trim($this->post['tradNo']):""; if($tradNo!==""){ $condition[]=["a.tradNo","like","%$tradNo%"]; } if($bank!=""){ $condition[]=["trade_bank","like","%$bank%"]; } if($name!=""){ $condition[]=["trade_out","like","%$name%"]; } if($start!=""){ $condition[]=["trade_time",">=",$start." 00:00:00"]; } if($end!=""){ $condition[]=["trade_time","<=",$end." 23:59:59"]; } if($status!==""){ $condition[]=["status","=",$status]; } $count=Db::name("trade")->where($condition)->count(); $total=ceil($count/$size); $page=$page>$total? intval($total):$page; $list =Db::name("trade")->where($condition)->page($page,$size)->order("trade_time desc")->select(); return app_show(0,"获取成功",["list"=>$list,"count"=>$count]); } // 认领资金列表明细 public function tradeList(){ $page=isset($this->post['page'])&&$this->post['page']!="" ? intval($this->post['page']) :1; $size=isset($this->post['size'])&&$this->post['size']!="" ? intval($this->post['size']) :15; $condition =[["a.is_del","=",0],["b.is_del","=",0]]; $name =isset($this->post['name'])&&$this->post['name']!=""? trim($this->post['name']):""; $bank =isset($this->post['bank'])&&$this->post['bank']!=""? trim($this->post['bank']):""; $start =isset($this->post['start'])&&$this->post['start']!=""? trim($this->post['start']):""; $end =isset($this->post['end'])&&$this->post['end']!=""? trim($this->post['end']):""; $status =isset($this->post['status'])&&$this->post['status']!==""? intval($this->post['status']):""; $apply_id =isset($this->post['apply_id'])&&$this->post['apply_id']!=""? intval($this->post['apply_id']):""; $apply_name =isset($this->post['apply_name'])&&$this->post['apply_name']!=""? trim($this->post['apply_name']):""; $tradNo =isset($this->post['tradNo'])&&$this->post['tradNo']!=""? trim($this->post['tradNo']):""; if($tradNo!==""){ $condition[]=["a.tradNo","like","%$tradNo%"]; } $logNo =isset($this->post['logNo'])&&$this->post['logNo']!=""? trim($this->post['logNo']):""; if($logNo!==""){ $condition[]=["a.logNo","like","%$logNo%"]; } if($bank!=""){ $condition[]=["b.trade_bank","like","%$bank%"]; } if($name!=""){ $condition[]=["b.trade_out","like","%$name%"]; } if($start!=""){ $condition[]=["a.add_time",">=",$start." 00:00:00"]; } if($end!=""){ $condition[]=["a.add_time","<=",$end." 23:59:59"]; } if($status!==""){ $condition[]=["a.status","=",$status]; } if($apply_id!==""){ $condition[]=["a.apply_id","=",$apply_id]; } if($apply_name!==""){ $condition[]=["a.apply_name","like","%$apply_name%"]; } $count=Db::name("trade_pool")->alias("a")->leftJoin("trade b","a.tradNo=b.tradNo")->where($condition)->count(); $total=ceil($count/$size); $page=$page>$total? intval($total):$page; $list =Db::name("trade_pool")->alias("a")->leftJoin("trade b","a.tradNo=b.tradNo")->where($condition) ->page($page,$size)->field("a.*,b.trade_bank,b.trade_account,b.trade_out,b.total_fee as btotal_fee,b.used_fee,b.balance")->order("a.addtime desc")->select(); return app_show(0,"获取成功",["list"=>$list,"count"=>$count]); } // 获取资金下面的认领信息 public function tradeQuery(){ $tradNo =isset($this->post['tradNo'])&&$this->post['tradNo']!=""? trim($this->post['tradNo']):""; $status =isset($this->post['status'])&&$this->post['status']!=""? intval($this->post['status']):""; $apply_id =isset($this->post['apply_id'])&&$this->post['apply_id']!=""? intval($this->post['apply_id']):""; $apply_name =isset($this->post['apply_name'])&&$this->post['apply_name']!=""? trim($this->post['apply_name']):""; $condition=[["is_del","=",0]]; if($apply_id!==""){ $condition[]=["apply_id","=",$apply_id]; } if($apply_name!==""){ $condition[]=["apply_name","like","%$apply_name%"]; } if($status!==""){ $condition[]=["status","=",$status]; } if($tradNo!==""){ $condition[]=["tradNo","like","%$tradNo%"]; } $list =Db::name("trade_pool")->where($condition)->order("addtime desc")->select(); return app_show(0,"获取成功",$list); } //认领资金退回或退款 type 1 退款 2 解除资金认领 public function ReturnPay(){ $logNo = isset($this->post['logNo'])&&$this->post['logNo']!="" ? trim($this->post['logNo']):""; if($logNo==''){ return error_show(1004,"参数 logNo 不能为空"); } $type = isset($this->post['type'])&&$this->post['type']!="" ? intval($this->post['type']):""; if($type==""){ return error_show(1004,"参数 type 不能为空"); } $loginfo = Db::name("trade_pool")->where(["logNo"=>$logNo,"is_del"=>0])->find(); if($loginfo==false){ return error_show(1004,"认领资金信息未找到"); } if($loginfo['status']!=2)return error_show(1004,"认领资金信息审核未通过"); $tradinfo = Db::name("trade")->where(["tradNo"=>$loginfo['tradNo'],"is_del"=>0])->find(); if($tradinfo==false){ return error_show(1004,"资金信息未找到"); } $reason = isset($this->post['return_reason'])&&$this->post['return_reason']!="" ? trim($this->post['return_reason']):""; $remark = isset($this->post['remark'])&&$this->post['remark']!="" ? trim($this->post['remark']):""; $returnCode =makeNo("RTA"); $data=[ "returnCode"=>$returnCode, "logNo"=>$logNo, "tradNo"=>$loginfo['tradNo'], "type"=>$type, "apply_id"=>$this->uid, "apply_name"=>$this->uname, "return_reason"=>$reason, "remark"=>$remark, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $in = Db::name("trade_return")->insert($data); if($in){ return app_show(0,"申请新建成功"); }else{ return error_show(1004,"申请新建失败"); } } /** * //page size tradNo logNo apply_id apply_name type status returnCode * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function returnList(){ $page=isset($this->post['page'])&&$this->post['page']!='' ? intval($this->post['page']):1; $size=isset($this->post['size'])&&$this->post['size']!='' ? intval($this->post['size']):15; $tradNo =isset($this->post['tradNo'])&&$this->post['tradNo']!=''?trim($this->post['tradNo']):""; $logNo =isset($this->post['logNo'])&&$this->post['logNo']!=''?trim($this->post['logNo']):""; $apply_id =isset($this->post['apply_id'])&&$this->post['apply_id']!=''?intval($this->post['apply_id']):""; $apply_name =isset($this->post['apply_name'])&&$this->post['apply_name']!=''?trim($this->post['apply_name']):""; $type =isset($this->post['type'])&&$this->post['type']!=''?intval($this->post['type']):""; $status =isset($this->post['status'])&&$this->post['status']!==''?intval($this->post['status']):""; $returnCode =isset($this->post['returnCode'])&&$this->post['returnCode']!=''?trim($this->post['returnCode']):""; $condition=[["is_del","=",0]]; if($tradNo!=''){ $condition[]=["tradNo","like","%$tradNo%"]; } if($logNo!=''){ $condition[]=["logNo","like","%$logNo%"]; } if($apply_id!=''){ $condition[]=["apply_id","=",$apply_id]; } if($apply_name!=''){ $condition[]=["apply_name","like","%$apply_name%"]; } if($returnCode!=''){ $condition[]=["returnCode","like","%$returnCode%"]; } if($type!=''){ $condition[]=["type","=",$type]; } if($status!=''){ $condition[]=["status","=",$status]; } $count =Db::name("trade_return")->where($condition)->count(); $total=ceil($count/$size); $page = $page>$total ? intval($total):$page; $list=Db::name("trade_return")->where($condition)->page($page,$size)->select(); return app_show(0,"获取成功",["list"=>$list,"count"=>$count]); } //退款状态审核 0 待审核 1 财务审核 2 财务驳回 public function returnStatus(){ $returnCode=isset($this->post['returnCode'])&&$this->post['returnCode']!=''?trim($this->post['returnCode']):""; if($returnCode==''){ return error_show(1004,"参数 returnCode 不能为空"); } $returninfo =Db::name("trade_return")->where(["returnCode"=>$returnCode,"is_del"=>0])->find(); if($returninfo==false){ return error_show(1004,"退款申请数据未找到"); } $status=isset($this->post['status']) &&$this->post['status']!=''?intval($this->post['status']) : ''; if($status==''){ return error_show(1004,"参数 status 不能为空"); } $return_img = isset($this->post['return_img'])&&$this->post['return_img']!=''?trim($this->post['return_img']):""; $remark = isset($this->post['remark'])&&$this->post['remark']!=''?trim($this->post['remark']):""; $loginfo = Db::name("trade_pool")->where(["logNo"=>$returninfo['logNo'],"is_del"=>0])->find(); if($loginfo==false){ return error_show(1004,"认领资金信息未找到"); } if($loginfo['status']!=2)return error_show(1004,"认领资金信息审核未通过"); Db::startTrans(); try{ $update=["status"=>$status,"return_img"=>$return_img,"remark"=>$remark,"updatetime"=>date("Y-m-d H:i:s")]; $up =Db::name("trade_return")->where($returninfo)->update($update); if($up){ if($status==1){ $qrdArr=Db::name("assoc")->where(["viceCode"=>$returninfo['logNo'],"status"=>1,"is_del"=>0])->select() ->toArray(); if(!empty($qrdArr)){ foreach ($qrdArr as $value){ $qrd =Db::name("qrd_info")->where(["sequenceNo"=>$value['orderCode']])->field("id,status,pay_fee,apay_fee,wpay_fee,pay_status,totalPrice")->findOrEmpty(); if(empty($qrd)){ Db::rollback(); return error_show(1005,"未找到销售单数据"); } if($qrd['pay_fee']<$value['cancel_fee']){ Db::rollback(); return error_show(1005,"销售单待付金额不足"); } $update =[ "wpay_fee"=>$qrd['wpay_fee']+$value['cancel_fee'], "apay_fee"=>$qrd['apay_fee']-$value['cancel_fee'], "pay_status"=>($qrd['apay_fee']-$value['cancel_fee'])==0 && $qrd['pay_fee']==0 ? 1:2, "status"=>$qrd['pay_fee']==0 && ($qrd['apay_fee']-$value['cancel_fee'])==0 ?0:1, "updatetime"=>date("Y-m-d H:i:s") ]; $qrdup =Db::name("qrd_info")->where($qrd)->update($update); if($qrdup==false){ Db::rollback(); return error_show(1005,"销售单更新失败"); } $asscup =[ "status"=>3, "updatetime"=>date("Y-m-d H:i:s") ]; $assc=Db::name("assoc")->where($value)->update($asscup); if($assc==false){ Db::rollback(); return error_show(1005,"销售单更新失败"); } $report=ReportCode::where(["qrdNo"=>$value['orderCode']])->find(); $report->setField("returnTrad",$returnCode); } } $logup =["status"=>$returninfo['type']==1?5:4,"updatetime"=>date("Y-m-d H:i:s")]; $upde =Db::name("trade_pool")->where($loginfo)->update($logup); if($upde==false){ Db::rollback(); return error_show(1005,"资金认领信息更新失败"); } if($returninfo['type']==1){ $trade =Db::name("trade")->where(["tradNo"=>$returninfo['tradNo'],"is_del"=>0])->find(); if($trade==false){ Db::rollback(); return error_show(1005,"资金信息未找到"); } if($trade['used_fee']<$loginfo['total_fee']){ Db::rollback(); return error_show(1005,"资金信息已认领金额不足"); } $tradup =[ "used_fee"=>$trade['used_fee']-$loginfo['total_fee'], "balance"=>$trade['balance']+$loginfo['total_fee'], "status"=>($trade['used_fee']-$loginfo['total_fee'])==0 ? 0 :1, "updatetime"=>date("Y-m-d H:i:s") ]; $updaT=Db::name("trade")->where($trade)->update($tradup); if($updaT==false){ Db::rollback(); return error_show(1005,"资金信息更新失败"); } } } Db::commit(); return app_show(0,"退款申请审核成功"); } Db::rollback(); return error_show(1004,'审核状态失败'); }catch (\Exception $e){ Db::rollback(); return error_show(1004,$e->getMessage()); } } /** * 显示创建资源表单页. * * @return \think\Response */ public function importTrade() { $files = $this->request->file("excel"); $data = upload($files,$files->getOriginalExtension()); if($data['code']!=0){ return error_show(1004,$data['msg']); } $trade = $data['data']; $list = []; foreach ( $trade as $key => $value) { if (!isset($value[0]) || $value[0] == '') { //return ['code' => 1003, "msg" => '交易时间不能为空']; return error_show( 1003, '交易时间不能为空!'); } if ((!isset($value[1]) || $value[1] == '') && (!isset($value[2]) || $value[2] == '')) { //return ['code' => 1003, "msg" => '收入/支出金额不能为空']; return error_show( 1003, '收入/支出金额不能为空!'); } if (!isset($value[4]) || $value[4] == '') { // return ['code' => 1003, "msg" => '交易行名不能为空']; return error_show( 1003, '交易行名不能为空!'); } if (!isset($value[6]) || $value[6] == '') { // return ['code' => 1003, "msg" => '对方账户不能为空']; return error_show( 1003, '对方账户不能为空!'); } if (!isset($value[7]) || $value[7] == '') { // return ['code' => 1003, "msg" => '对方户名不能为空']; return error_show( 1003, '对方户名不能为空!'); } if ($key == 0) { if ($value[0] != '交易时间') { // return ['code' => 1003, "msg" => '模板第一列为必须为交易时间!']; return error_show( 1003, '模板第一列为必须为交易时间!'); } if ($value[1] != '收入金额') { // return ['code' => 1003, "msg" => '模板第二列为必须为收入金额!']; return error_show( 1003, '模板第二列为必须为收入金额!'); } if ($value[2] != '支出金额') { // return ['code' => 1003, "msg" => '模板第二列为必须为支出金额!']; return error_show( 1003, '模板第二列为必须为支出金额!'); } if ($value[4] != '交易行名') { //return ['code' => 1003, "msg" => '模板第五列为必须为交易行名!']; return error_show( 1003, '模板第五列为必须为交易行名!'); } if ($value[6] != '对方账号') { // return ['code' => 1003, "msg" => '模板第七列为必须为对方账号!']; return error_show( 1003, '模板第七列为必须为对方账号!'); } if ($value[7] != '对方户名') { // return ['code' => 1003, "msg" => '模板第八列为必须为对方户名!']; return error_show( 1003, '模板第八列为必须为对方户名!'); } continue; } $total_fee = $value[1]==0&&$value[2]!=0 ? $value[2]: $value[1]; $type = $value[1]==0&&$value[2]!=0 ? 1: 0; $time = explode(" ", $value[0]); $list[$key]["tradeTime"] = date("Y-m-d", strtotime($time[0])) . " " . (isset($time[1]) ? $time[1] : "00:00:00"); $list[$key]["trade_fee"] = str_replace(",","",$total_fee); $list[$key]["trade_bank"] = $value[4]; $list[$key]["trade_account"] = $value[6]; $list[$key]["trade_out"] = $value[7]; $list[$key]["trade_in"] = ''; $list[$key]["trade_type"] = $type; $list[$key]["trade_used"] = isset($value[8]) ? $value[8] : ""; $list[$key]["trade_remark"] = ''; } if(empty($list)){ return error_show( 1003, '导入数据不能为空!'); } Db::startTrans(); try{ $tra=[]; foreach ($list as $value) { $temp = []; $temp["tradNo"] = makeStr('S'); $temp['trade_time'] = $value['tradeTime']; $temp['total_fee'] = $value['trade_fee']; $temp['trade_bank'] = $value['trade_bank']; $temp['trade_account'] = $value['trade_account']; $temp['trade_type'] =$value['trade_type']; $temp['trade_out'] = $value['trade_out']; $temp['trade_in'] = $value['trade_in']; $temp['trade_used'] = $value['trade_used']; $temp['trade_remark'] = $value['trade_remark']; $temp['balance'] =$value['trade_fee']; $temp['addtime'] = date("Y-m-d H:i:s"); $temp['updatetime'] = date("Y-m-d H:i:s"); $tra[]=$temp; } $list = Db::name('trade')->insertAll($tra); if($list==count($tra)){ Db::commit(); return app_show(0, "资金导入成功"); }else{ Db::rollback(); return app_show(1004, "资金导入失败"); } }catch (\Exception $e){ Db::rollback(); return app_show(1004, $e->getMessage()); } } }