订单bug 文章生产实例bug
This commit is contained in:
@@ -211,34 +211,14 @@ class Order extends base{
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
if(isset($data['type'])&&$data['type']==2){
|
||||
$payType = 2;
|
||||
}else{
|
||||
$payType = 0;
|
||||
}
|
||||
$frag = [];
|
||||
$article_info = $this->article_obj->where("article_id",$data['article_id'])->find();
|
||||
if($article_info['is_buy']==1){
|
||||
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();
|
||||
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;
|
||||
$paystation_res = $this->creatPaystation($article_info['article_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['detail'] =$this->order_obj->where("order_id",$check['order_id'])->find();
|
||||
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)));
|
||||
$insert1['order_sn'] = $ca_sn;
|
||||
$insert1['user_id'] = $article_info['user_id'];
|
||||
$insert1['pay_type'] = 2;
|
||||
$insert1["article_id"] = $data['article_id'];
|
||||
$insert1["currency"] = "USD";
|
||||
$insert1['order_fee'] = $journal_info['fee'];
|
||||
$insert1['real_fee'] = $journal_info['fee'];
|
||||
$insert1['order_fee'] = $article_info['fee'];
|
||||
$insert1['real_fee'] = $article_info['fee'];
|
||||
$accessToken = createPayStationToken();
|
||||
$data_array = [
|
||||
'paystation_id' => Env::get("paystation.client_id"),
|
||||
'gateway_id' => "PAYSTATION",//GATEWAY_ID,
|
||||
"merchant_session" => $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,
|
||||
// "currency"=>"USD",//目前paystation仅支持nzd
|
||||
"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);
|
||||
$frag['paystation'] = $paystation_res;
|
||||
$frag["paypal"] = null;
|
||||
}else{//暂时不处理,其他情况
|
||||
return jsonError("pay_type error");
|
||||
}
|
||||
|
||||
$frag['detail'] = $this->order_obj->where("order_id",$id)->find();
|
||||
return jsonSuccess($frag);
|
||||
}
|
||||
|
||||
private function creatPaystation($article_id){
|
||||
$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)));
|
||||
$accessToken = createPayStationToken();
|
||||
$data_array = [
|
||||
@@ -334,7 +292,7 @@ class Order extends base{
|
||||
'gateway_id' => "PAYSTATION",//GATEWAY_ID,
|
||||
"merchant_session" => $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'],
|
||||
"response_url"=>"http://api.tmrjournals.com/public/index.php/api/Order/completePaystation"
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user