diff --git a/application/api/controller/Preaccept.php b/application/api/controller/Preaccept.php index e1e2de6b..603a0711 100644 --- a/application/api/controller/Preaccept.php +++ b/application/api/controller/Preaccept.php @@ -37,14 +37,17 @@ class Preaccept extends Base } $dois = $this->production_article_refer_obj->where("p_article_id", $production_info['p_article_id'])->where("refer_doi","<>","")->where("state",0)->group("refer_doi")->having("count(*)>1")->column("refer_doi"); $list = $this->production_article_refer_obj->where("p_article_id", $production_info['p_article_id'])->where('state', 0)->order("index")->select(); + $aRepeat = []; foreach ($list as $k => $v){ if(in_array($v['refer_doi'],$dois)){ $list[$k]['is_repeat'] = 1; + $aRepeat[$v['refer_doi']][] = $v['index']; }else{ $list[$k]['is_repeat'] = 0; } } $re["refers"] = $list; + $re['repeat'] = empty($aRepeat) ? [] : $aRepeat; return jsonSuccess($re); } @@ -752,44 +755,23 @@ class Preaccept extends Base } $article_info = $this->article_obj->where("article_id",$data['article_id'])->find(); $journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find(); - if(intval($journal_info['fee'])==0||$article_info['ctime']<1735660800){//非收费期刊的文章直接返回 - $re['state'] = 1; - $re['order'] = null; - $re["fee"] = 0; - return jsonSuccess($re); - } $order_info = $this->order_obj->where("article_id",$article_info['article_id'])->find(); - if($order_info==null){//这里有疑问 - $re['state'] = 1; - $re['order'] = null; - $re["fee"] = 0; - return jsonSuccess($re); - } -// if($order_info['pay_type']==2){ - $paystation = $this->paystation_obj->where("ps_id",$order_info['ps_id'])->find(); - $order_info['paystation'] = $paystation; - if($order_info['state']==0){ - $res = object_to_array(json_decode(paystationLookup($paystation['transaction_id']))); - if(isset($res['result']['success'])&&$res['result']['success']){ - $this->article_obj->where("article_id",$order_info['article_id'])->update(['is_buy'=>1]); - $this->order_obj->where("order_id",$order_info['order_id'])->update(['state'=>1]); - $re['state'] = 1; - $re['fee'] = $journal_info['fee']; - $re['order'] = $order_info; - return jsonSuccess($re); - }else{ - $re['state'] = 0; - $re['fee'] = $journal_info['fee']; - $re['order'] = $order_info; - return jsonSuccess($re); - } - }else{ - $re['state'] = 1; - $re['fee'] = $journal_info['fee']; - $re['order'] = $order_info; - return jsonSuccess($re); + $paystation = $this->paystation_obj->where("ps_id",$order_info['ps_id'])->find(); + $order_info['paystation'] = $paystation; + if($order_info['state']==0){ + $res = xml_to_array(paystationLookup($paystation['merchant_session'])); + if(isset($res['PaystationQuickLookup']['LookupResponse']['Authentication']['auth_Status'])&&$res['PaystationQuickLookup']['LookupResponse']['Authentication']['auth_Status']=="Y"){ + $this->article_obj->where("article_id",$order_info['article_id'])->update(['is_buy'=>1]); + $this->order_obj->where("order_id",$order_info['order_id'])->update(['state'=>1]); + $article_info = $this->article_obj->where("article_id",$data['article_id'])->find(); } -// } + } + $re['state'] = $article_info['is_buy']; + $re['order'] = $order_info; + $re["fee"] = $article_info['fee']; + $re['article'] = $article_info; + $re['journal'] = $journal_info; + return jsonSuccess($re); } @@ -1633,9 +1615,9 @@ return null; if(empty($p_article_id)){ return []; } - //查询参考文献 - $aWhere = ['p_article_id' => $p_article_id,'article_id' => $article_id,'state' => 0,'refer_doi' => ['<>','']]; - $aRefer = Db::name('production_article_refer')->where($aWhere)->column('refer_doi'); + // //查询参考文献 + // $aWhere = ['p_article_id' => $p_article_id,'article_id' => $article_id,'state' => 0,'refer_doi' => ['<>','']]; + // $aRefer = Db::name('production_article_refer')->where($aWhere)->column('refer_doi'); $extension = substr($afile, strrpos($afile, '.') + 1); vendor("PHPExcel.PHPExcel"); if ($extension == 'xlsx') { @@ -1660,13 +1642,13 @@ return null; } $aa['refer_doi'] = trim($aa['refer_doi']); $aa['refer_content'] = trim($aa['refer_content']); - //判断是否添加过 - $doiLinkPattern = '/^(https?:\/\/)?([a-zA-Z0-9_-]+\.)*[a-zA-Z0-9_-]+\.[a-zA-Z]{2,}(\/.*)?$/i'; - if(preg_match($doiLinkPattern, $aa['refer_doi'], $matches)){ - if(in_array($aa['refer_doi'], $aRefer)){ - continue; - } - } + // //判断是否添加过 + // $doiLinkPattern = '/^(https?:\/\/)?([a-zA-Z0-9_-]+\.)*[a-zA-Z0-9_-]+\.[a-zA-Z]{2,}(\/.*)?$/i'; + // if(preg_match($doiLinkPattern, $aa['refer_doi'], $matches)){ + // if(in_array($aa['refer_doi'], $aRefer)){ + // continue; + // } + // } $aa['p_article_id'] = $p_article_id; $aa['article_id'] = $article_id; $aa['index'] = $k; @@ -1674,7 +1656,7 @@ return null; $aa['index'] = $k; $aa['refer_frag'] = $aa['refer_content']; $aa['refer_type'] = 'other'; - $aa['is_change'] = 2; + $aa['is_deal'] = 2; $k++; $frag[] = $aa; } @@ -1697,23 +1679,30 @@ return null; } //查询参考文献数据 $aWhere = ['p_article_id' => $iPArticleId,'article_id' => $iArticleId,'state' => 0]; - $iCount = Db::name('production_article_refer')->where($aWhere)->count(); - if(empty($iCount)){ + $aRefer = Db::name('production_article_refer')->where($aWhere)->select(); + if(empty($aRefer)){ return json_encode(array('status' => 3,'msg' => 'Reference is empty','data' => ['total' => 0,'unprocessed_total' => 0,'processed_total' => 0])); } - //获取未处理的数据 - $aWhere['is_deal'] = 2; - $aUnprocessed = Db::name('production_article_refer')->where($aWhere)->select(); - //获取已处理的数据 - $aWhere['is_deal'] = 1; - $aProcessed = Db::name('production_article_refer')->where($aWhere)->select(); - //未处理的数量 - $iUnprocessed = empty($aUnprocessed) ? 0 : count($aUnprocessed); - //已处理的数量 - $iProcessed = empty($aProcessed) ? 0 : count($aProcessed); - - //数据组合 - $aRefer = array_merge($aUnprocessed,$aProcessed); + //获取总数量 + $iCount = empty($aRefer) ? 0 : count($aRefer); + $aWhere["refer_doi"] = ["<>",""]; + $aDoi = Db::name('production_article_refer')->field('count(p_article_id) as num,refer_doi')->where($aWhere)->group('refer_doi')->select(); + $aDoi = empty($aDoi) ? [] : array_column($aDoi, 'num','refer_doi'); + //数据处理 + $iUnprocessed = $iProcessed = 0; + foreach ($aRefer as $key => $value) { + if($value['is_deal'] == 1){ + $iProcessed++; + } + if($value['is_deal'] == 2){ + $iUnprocessed++; + } + $iIsRepat = 0; + if(!empty($value['refer_doi']) && (!empty($aDoi[$value['refer_doi']]) && $aDoi[$value['refer_doi']] > 1)){ + $iIsRepat = 1; + } + $aRefer[$key]['is_repeat'] = $iIsRepat; + } $aRefer = ['total' => $iCount,'unprocessed_total' => $iUnprocessed,'processed_total' => $iProcessed,'refer' => $aRefer]; return json_encode(['status' => 1,'msg' => 'success','data' => $aRefer]); } @@ -1733,10 +1722,10 @@ return null; if(empty($aArticle)){ return jsonError('No article information found'); } - $iIsBuy = empty($aArticle['is_buy']) ? 0 : $aArticle['is_buy']; - if($iIsBuy != 1){ - return jsonError('Article unpaid'); - } + // $iIsBuy = empty($aArticle['is_buy']) ? 0 : $aArticle['is_buy']; + // if($iIsBuy != 1){ + // return jsonError('Article unpaid'); + // } $aWhere = ['article_id' => $iArticleId,'state' => 0]; $aProductionArticle = $this->production_article_obj->field('p_article_id')->where($aWhere)->find(); if(!empty($aProductionArticle)) { @@ -1751,4 +1740,5 @@ return null; } return jsonSuccess([]); } + }