Skip to content

Commit

Permalink
修复luna模板公告导致商品无法显示bug
Browse files Browse the repository at this point in the history
  • Loading branch information
assimon committed Oct 28, 2021
1 parent 478daff commit 1b50ca1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
32 changes: 14 additions & 18 deletions app/Http/Controllers/Pay/CoinbaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function gateway(string $payway, string $orderSN)
$price_amount =(double)$price_amount * (1.00+$fees);// 价格 * (1 + 0.05)
}

$redirect_url = url('detail-order-sn', ['orderSN' => $this->order->order_sn]); //同步地址

$redirect_url = url('detail-order-sn', ['orderSN' => $this->order->order_sn]); //同步地址
$cancel_url = url('detail-order-sn', ['orderSN' => $this->order->order_sn]); //同步地址
$config = [
'name'=>$this->order->title,
Expand Down Expand Up @@ -57,7 +57,7 @@ public function gateway(string $payway, string $orderSN)
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($config));
$coinbase_json = curl_exec($ch);
curl_close($ch);

$coinbase_date=json_decode($coinbase_json,true);
if(is_array($coinbase_date))
{
Expand All @@ -83,24 +83,24 @@ public function notifyUrl(Request $request)
$payload = file_get_contents( 'php://input' );
$sig = $_SERVER['HTTP_X_CC_WEBHOOK_SIGNATURE'];
$data = json_decode( $payload, true );
$event_data = $data['event']['data'];
$order = $this->orderService->detailOrderSN($event_data['metadata']['customer_id']);//
$event_data = $data['event']['data'];
$order = $this->orderService->detailOrderSN($event_data['metadata']['customer_id']);//
if (!$order) {
return 'fail';
}
$payGateway = $this->payService->detail($order->pay_id);
if (!$payGateway) {
return 'fail';
}
}
$secret = $payGateway->merchant_pem;//共享密钥
$sig2 = hash_hmac( 'sha256', $payload, $secret );
$result_str=array("confirmed","resolved");//返回的结果字符串数组
if (!empty( $payload ) && ($sig === $sig2))
if (!empty( $payload ) && ($sig === $sig2))
{

foreach ($event_data['payments'] as $payment) {
//if ((strtolower($payment['status']) === 'confirmed')||(strtolower($payment['status']) === 'resolved')) {
if(in_array(strtolower($payment['status']),$result_str){
if(in_array(strtolower($payment['status']),$result_str)){
$return_pay_amount = $payment['value']['local']['amount'];
$return_currency=$payment['value']['local']['currency'];
$return_status=strtolower($payment['status']);
Expand All @@ -110,35 +110,31 @@ public function notifyUrl(Request $request)
{
return 'error|Notify: Wrong currency:'.$return_currency;
}

$bccomp = bccomp($order->actual_price, $return_pay_amount, 2); //如果订单金额 大于 实际支付金额 返回1,抛出异常
if ($bccomp == 1) {
throw new \Exception(__('Coinbase付款金额不足'));
}
$return_merchant_order_id = $event_data['metadata']['customer_id'];//卡网订单号
$tradeid = $event_data['code'];//Coinbase订单号
//if($return_status === 'confirmed'||$return_status === 'resolved')
if(in_array(strtolower($payment['status']),$result_str)
{
if(in_array(strtolower($payment['status']),$result_str)) {
$this->orderProcessService->completedOrder($return_merchant_order_id, $order->actual_price, $tradeid);// 卡网订单号,订单金额(不能传入支付金额,否则抛出订单金额不一致异常),收款平台订单号
return "{\"status\": 200}";
}
else
{
} else {
//不合法的数据
return 'fail';
//返回失败 继续补单
}

}
else
{
} else {
//不合法的数据
return 'fail|wrong sig';
//返回失败 继续补单
}


}


}
}
5 changes: 3 additions & 2 deletions resources/views/luna/static_pages/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
</svg>
<span>{{ __('luna.home_choice_cate') }}</span>
</div>
<div class="cate"></div>
<div class="cate">

</div>
<div class="goods">
<p class="title-2">
<svg t="1602925988984" class="icon" viewBox="0 0 1024 1024"
Expand Down Expand Up @@ -96,7 +98,6 @@ class="goods-box" style="<<# if(d.in_stock <= 0){ >>cursor:not-allowed;<<# }; >>

<script>
let title = "{{ __('dujiaoka.site_announcement') }}",
tipsCon = '{!! str_replace(["\r\n", "\r", "\n"], "", dujiaoka_config_get('notice')); !!}',
goodsMsg = {!! json_encode($data) !!};
</script>
@endsection
Expand Down

0 comments on commit 1b50ca1

Please sign in to comment.