订单bug 文章生产实例bug
This commit is contained in:
@@ -95,7 +95,6 @@ class Article extends Base
|
|||||||
if ($data['name'] != '') {
|
if ($data['name'] != '') {
|
||||||
$where['t_article.title'] = array('like', "%" . $data['name'] . "%");
|
$where['t_article.title'] = array('like', "%" . $data['name'] . "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
//分页查询数据
|
//分页查询数据
|
||||||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||||||
$res = $this->article_obj->field('t_article.*,t_journal.title journalname')
|
$res = $this->article_obj->field('t_article.*,t_journal.title journalname')
|
||||||
@@ -104,7 +103,6 @@ class Article extends Base
|
|||||||
->order('article_id desc')
|
->order('article_id desc')
|
||||||
->limit($limit_start, $data['pageSize'])->select();
|
->limit($limit_start, $data['pageSize'])->select();
|
||||||
$count = $this->article_obj->where($where)->count();
|
$count = $this->article_obj->where($where)->count();
|
||||||
|
|
||||||
foreach ($res as $key => $val) {
|
foreach ($res as $key => $val) {
|
||||||
//查询建议转投详情
|
//查询建议转投详情
|
||||||
$transfer_info = $this->article_transfer_obj
|
$transfer_info = $this->article_transfer_obj
|
||||||
@@ -1588,10 +1586,15 @@ class Article extends Base
|
|||||||
$this->addProductionEx($data['articleId']);
|
$this->addProductionEx($data['articleId']);
|
||||||
$this->addArticleMainEx($data['articleId']);
|
$this->addArticleMainEx($data['articleId']);
|
||||||
|
|
||||||
//如果是免费的期刊文章,那么直接变成付款完成
|
//处理缴费相关信息
|
||||||
if ($journal_info['fee'] == 0 || $article_info['ctime'] < 1735660800) {
|
if($journal_info['fee']==0){
|
||||||
$this->article_obj->where("article_id", $article_info['article_id'])->update(["is_buy" => 1]);
|
$this->article_obj->where("article_id", $article_info['article_id'])->update(["is_buy" => 1]);
|
||||||
|
}else{
|
||||||
|
$this->article_obj->where("article_id", $article_info['article_id'])->update(["fee" => $journal_info['fee']]);
|
||||||
}
|
}
|
||||||
|
// if ($journal_info['fee'] == 0 || $article_info['ctime'] < 1735660800) {
|
||||||
|
// $this->article_obj->where("article_id", $article_info['article_id'])->update(["is_buy" => 1]);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,34 +211,14 @@ class Order extends base{
|
|||||||
if(!$rule->check($data)){
|
if(!$rule->check($data)){
|
||||||
return jsonError($rule->getError());
|
return jsonError($rule->getError());
|
||||||
}
|
}
|
||||||
if(isset($data['type'])&&$data['type']==2){
|
|
||||||
$payType = 2;
|
|
||||||
}else{
|
|
||||||
$payType = 0;
|
|
||||||
}
|
|
||||||
$frag = [];
|
$frag = [];
|
||||||
$article_info = $this->article_obj->where("article_id",$data['article_id'])->find();
|
$article_info = $this->article_obj->where("article_id",$data['article_id'])->find();
|
||||||
if($article_info['is_buy']==1){
|
if($article_info['is_buy']==1){
|
||||||
return jsonError("paid");
|
return jsonError("paid");
|
||||||
}
|
}
|
||||||
$journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find();
|
// $journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find();
|
||||||
$check = $this->order_obj->where("user_id",$article_info['user_id'])->where("article_id",$data['article_id'])->whereIn("state",[0,1])->find();
|
$check = $this->order_obj->where("user_id",$article_info['user_id'])->where("article_id",$data['article_id'])->whereIn("state",[0,1])->find();
|
||||||
if($check){
|
if($check){
|
||||||
if($payType==0){
|
|
||||||
$ii = $this->createPaypalOrder($check['real_fee']);
|
|
||||||
// if(!isset($ii['jsonResponse']['status'])||$ii['jsonResponse']['status']!="CREATED"){
|
|
||||||
if(!isset($ii['jsonResponse']['status'])){
|
|
||||||
return jsonError("system error!");
|
|
||||||
}else{
|
|
||||||
$check['paypal_order_id'] = $ii['jsonResponse']['id'];
|
|
||||||
}
|
|
||||||
$check['pay_type'] = 0;
|
|
||||||
$this->order_obj->update($check);
|
|
||||||
$re['detail'] = $check;
|
|
||||||
$re['paypal'] = $ii;
|
|
||||||
$re['paystation'] = null;
|
|
||||||
return jsonSuccess($re);
|
|
||||||
}else{
|
|
||||||
$re['paypal'] = null;
|
$re['paypal'] = null;
|
||||||
$paystation_res = $this->creatPaystation($article_info['article_id']);
|
$paystation_res = $this->creatPaystation($article_info['article_id']);
|
||||||
$ps_insert['transaction_id'] = $paystation_res['transaction_id'];
|
$ps_insert['transaction_id'] = $paystation_res['transaction_id'];
|
||||||
@@ -255,42 +235,23 @@ class Order extends base{
|
|||||||
$re['paystation'] = $this->paystation_obj->where("ps_id",$ps_id)->find();
|
$re['paystation'] = $this->paystation_obj->where("ps_id",$ps_id)->find();
|
||||||
$re['detail'] =$this->order_obj->where("order_id",$check['order_id'])->find();
|
$re['detail'] =$this->order_obj->where("order_id",$check['order_id'])->find();
|
||||||
return jsonSuccess($re);
|
return jsonSuccess($re);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($payType==0){//支付方式为paypal
|
}
|
||||||
$insert['order_sn'] = 'TMR'.date('Ymd') . strtoupper(bin2hex(random_bytes(8)));
|
|
||||||
$insert['user_id'] = $article_info['user_id'];
|
|
||||||
$insert['pay_type'] = 0;
|
|
||||||
$insert["article_id"] = $data['article_id'];
|
|
||||||
$insert['currency'] = "USD";
|
|
||||||
$insert['order_fee'] = $journal_info['fee'];
|
|
||||||
$insert['real_fee'] = $journal_info['fee'];
|
|
||||||
$frag["paypal"] = $this->createPaypalOrder($insert['real_fee']);
|
|
||||||
if(!isset($paypal['jsonResponse']['status'])){
|
|
||||||
return jsonError("system error");
|
|
||||||
}else{
|
|
||||||
$insert['paypal_order_id'] = $paypal['jsonResponse']['id'];
|
|
||||||
}
|
|
||||||
$insert['ctime'] = time();
|
|
||||||
$id = $this->order_obj->insertGetId($insert);
|
|
||||||
$frag['paystation'] = null;
|
|
||||||
}elseif ($payType==2){//支付方式为paystation
|
|
||||||
$ca_sn = 'TMR'.date('Ymd') . strtoupper(bin2hex(random_bytes(8)));
|
$ca_sn = 'TMR'.date('Ymd') . strtoupper(bin2hex(random_bytes(8)));
|
||||||
$insert1['order_sn'] = $ca_sn;
|
$insert1['order_sn'] = $ca_sn;
|
||||||
$insert1['user_id'] = $article_info['user_id'];
|
$insert1['user_id'] = $article_info['user_id'];
|
||||||
$insert1['pay_type'] = 2;
|
$insert1['pay_type'] = 2;
|
||||||
$insert1["article_id"] = $data['article_id'];
|
$insert1["article_id"] = $data['article_id'];
|
||||||
$insert1["currency"] = "USD";
|
$insert1["currency"] = "USD";
|
||||||
$insert1['order_fee'] = $journal_info['fee'];
|
$insert1['order_fee'] = $article_info['fee'];
|
||||||
$insert1['real_fee'] = $journal_info['fee'];
|
$insert1['real_fee'] = $article_info['fee'];
|
||||||
$accessToken = createPayStationToken();
|
$accessToken = createPayStationToken();
|
||||||
$data_array = [
|
$data_array = [
|
||||||
'paystation_id' => Env::get("paystation.client_id"),
|
'paystation_id' => Env::get("paystation.client_id"),
|
||||||
'gateway_id' => "PAYSTATION",//GATEWAY_ID,
|
'gateway_id' => "PAYSTATION",//GATEWAY_ID,
|
||||||
"merchant_session" => $ca_sn,
|
"merchant_session" => $ca_sn,
|
||||||
"merchant_reference"=>$ca_sn,
|
"merchant_reference"=>$ca_sn,
|
||||||
"amount" =>(int)(prin($journal_info['fee'])*100),//(int)((((int)$journal_info['fee'])*726/416)*100),
|
"amount" =>(int)(prin($article_info['fee'])*100),//(int)((((int)$journal_info['fee'])*726/416)*100),
|
||||||
// "amount" =>100,
|
// "amount" =>100,
|
||||||
// "currency"=>"USD",//目前paystation仅支持nzd
|
// "currency"=>"USD",//目前paystation仅支持nzd
|
||||||
"return_url"=>"https://submission.tmrjournals.com/success?id=".$article_info['article_id'],
|
"return_url"=>"https://submission.tmrjournals.com/success?id=".$article_info['article_id'],
|
||||||
@@ -317,16 +278,13 @@ class Order extends base{
|
|||||||
$id = $this->order_obj->insertGetId($insert1);
|
$id = $this->order_obj->insertGetId($insert1);
|
||||||
$frag['paystation'] = $paystation_res;
|
$frag['paystation'] = $paystation_res;
|
||||||
$frag["paypal"] = null;
|
$frag["paypal"] = null;
|
||||||
}else{//暂时不处理,其他情况
|
|
||||||
return jsonError("pay_type error");
|
|
||||||
}
|
|
||||||
$frag['detail'] = $this->order_obj->where("order_id",$id)->find();
|
$frag['detail'] = $this->order_obj->where("order_id",$id)->find();
|
||||||
return jsonSuccess($frag);
|
return jsonSuccess($frag);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function creatPaystation($article_id){
|
private function creatPaystation($article_id){
|
||||||
$article_info = $this->article_obj->where("article_id",$article_id)->find();
|
$article_info = $this->article_obj->where("article_id",$article_id)->find();
|
||||||
$journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find();
|
|
||||||
$ca_sn = 'TMR'.date('Ymd') . strtoupper(bin2hex(random_bytes(8)));
|
$ca_sn = 'TMR'.date('Ymd') . strtoupper(bin2hex(random_bytes(8)));
|
||||||
$accessToken = createPayStationToken();
|
$accessToken = createPayStationToken();
|
||||||
$data_array = [
|
$data_array = [
|
||||||
@@ -334,7 +292,7 @@ class Order extends base{
|
|||||||
'gateway_id' => "PAYSTATION",//GATEWAY_ID,
|
'gateway_id' => "PAYSTATION",//GATEWAY_ID,
|
||||||
"merchant_session" => $ca_sn,
|
"merchant_session" => $ca_sn,
|
||||||
"merchant_reference"=>$ca_sn,
|
"merchant_reference"=>$ca_sn,
|
||||||
"amount" =>(int)(prin($journal_info['fee'])*100),//(int)((((int)$journal_info['fee'])*726/416)*100),
|
"amount" =>(int)(prin($article_info['fee'])*100),
|
||||||
"return_url"=>"https://submission.tmrjournals.com/success?id=".$article_info['article_id'],
|
"return_url"=>"https://submission.tmrjournals.com/success?id=".$article_info['article_id'],
|
||||||
"response_url"=>"http://api.tmrjournals.com/public/index.php/api/Order/completePaystation"
|
"response_url"=>"http://api.tmrjournals.com/public/index.php/api/Order/completePaystation"
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -750,44 +750,56 @@ class Preaccept extends Base
|
|||||||
return jsonError($rule->getError());
|
return jsonError($rule->getError());
|
||||||
}
|
}
|
||||||
$article_info = $this->article_obj->where("article_id",$data['article_id'])->find();
|
$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();
|
$order_info = $this->order_obj->where("article_id",$article_info['article_id'])->find();
|
||||||
if($order_info==null){//这里有疑问
|
$re['state'] = $article_info['is_buy'];
|
||||||
$re['state'] = 1;
|
$re['order'] = $order_info;
|
||||||
$re['order'] = null;
|
$re["fee"] = $article_info['fee'];
|
||||||
$re["fee"] = 0;
|
return jsonSuccess($re);
|
||||||
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]);
|
// if(intval($journal_info['fee'])==0||$article_info['ctime']<1735660800){//非收费期刊的文章直接返回
|
||||||
$this->order_obj->where("order_id",$order_info['order_id'])->update(['state'=>1]);
|
// $re['state'] = 1;
|
||||||
$re['state'] = 1;
|
// $re['order'] = null;
|
||||||
$re['fee'] = $journal_info['fee'];
|
// $re["fee"] = 0;
|
||||||
$re['order'] = $order_info;
|
// return jsonSuccess($re);
|
||||||
return jsonSuccess($re);
|
// }
|
||||||
}else{
|
//
|
||||||
$re['state'] = 0;
|
// if($order_info==null){//这里有疑问
|
||||||
$re['fee'] = $journal_info['fee'];
|
// $re['state'] = 1;
|
||||||
$re['order'] = $order_info;
|
// $re['order'] = null;
|
||||||
return jsonSuccess($re);
|
// $re["fee"] = 0;
|
||||||
}
|
// return jsonSuccess($re);
|
||||||
}else{
|
// }
|
||||||
$re['state'] = 1;
|
//// if($order_info['pay_type']==2){
|
||||||
$re['fee'] = $journal_info['fee'];
|
// $paystation = $this->paystation_obj->where("ps_id",$order_info['ps_id'])->find();
|
||||||
$re['order'] = $order_info;
|
// $order_info['paystation'] = $paystation;
|
||||||
return jsonSuccess($re);
|
// 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);
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user