作者 lihan
1 个管道 的构建 通过 耗费 0 秒

支付宝

... ... @@ -441,19 +441,45 @@ class OrderController extends HomeBaseController
$out_trade_no = $arr['out_trade_no'];
$temp = explode('_', $out_trade_no);
$order_sn = $temp[0];
$oid = Db::name('order_info')->where(['order_sn' => $order_sn])->value('id');
$order = new OrderModel;
$order->orderCallBack($oid, $arr['total_amount']);
$info = Db::name('order_info')->field('id,order_amount')->where(['order_sn' => $order_sn])->find();
if($info['order_amount'] == $arr['total_amount']) {
$order = new OrderModel;
$order->orderCallBack($info['id'], $arr['total_amount']);
}else {
//严谨需要退款
}
} else {
//严谨需要退款
}
echo "success";
}else {
echo "fail";
}
}
//支付宝同步通知
//支付宝同步通知给用户跳转页面
public function alipayNotifys()
{
require EXTEND_PATH . '/alipay/config.php';
require_once EXTEND_PATH . '/alipay/wappay/service/AlipayTradeService.php';
$arr = request()->param();
$alipaySevice = new \AlipayTradeService($config);
$alipaySevice->writeLog(var_export($_POST, true));
$result = $alipaySevice->check($arr);
if ($result) {
if ($arr['trade_status'] == 'TRADE_SUCCESS') {
$out_trade_no = $arr['out_trade_no'];
$temp = explode('_', $out_trade_no);
$order_sn = $temp[0];
$oid = Db::name('order_info')->where(['order_sn' => $order_sn])->value('id');
$this->redirect(url('user/Center/orderDetail',['oid'=>$oid]));
} else {
//严谨需要退款
}
echo "success";
}else {
echo "fail";
}
}
}
\ No newline at end of file
... ...
... ... @@ -40,7 +40,7 @@ class OrderModel extends Model
}
//通用订单回调类(未完待续。。。)
//余额扣除(如果余额支付->钱包记录)->优惠券变为已使用(如果使用优惠券)->改变订单状态(必然)->相应批次库存减少(必然)
//余额扣除(如果余额支付->钱包记录)->改变订单状态(必然)->相应批次库存减少(必然)
public function orderCallBack($oid, $order_amount = null)
{
$orderInfo = Db::name('order_info')->alias('o')
... ...