public function yinlian() { include_once '../vendor/yinlian_sdk/acp_service.php'; if (isset($_POST['signature'])) { if (\AcpService::validate($_POST) && ($_POST['respCode'] == '00' || $_POST['respCode'] == 'A6')) { $order = Order::where('out_trade_no', $_POST['orderId'])->first(); if ($order != null) { $orderId = $order->id; $order->status = 1; $time = date("Y-m-d H:i:s", time()); $order->payment_time = $time; $order->payment_way = 3; $order->save(); $useCouponRecords = UseCouponRecords::where('order_id', $orderId)->first(); if ($useCouponRecords != null) { $useCouponRecords->status = 2; //礼券金额 $apiParam = ['accessToken' => $useCouponRecords->access_token, 'coupon' => $useCouponRecords->coupon, 'orderId' => $_POST['orderId']]; $res = $this->post('/zhmf/member/consumerCoupon/useCoupon', $apiParam); $res = json_decode($res); if ($res->Code == 0) { $useCouponRecords->status = 1; } $useCouponRecords->save(); } echo 'success'; } } else { @header('HTTP/1.1 500 Internal Server Error'); } } else { @header('HTTP/1.1 500 Internal Server Error'); } }
/** * * @SWG\Api( * path="/use_coupon_records", * description="礼券使用记录(新20160225)", * @SWG\Operation( * method="GET", summary="获得用户礼券使用记录列表", notes="获得用户礼券使用记录列表", * type="UseCouponRecords", * @SWG\ResponseMessage(code=0, message="成功"), * @SWG\Parameter( * name="user_id", * description="用户id", * paramType="query", * required=true, * allowMultiple=false, * type="integer" * ), * @SWG\Parameter( * name="PageNum", * description="分页开始位置", * paramType="query", * required=false, * allowMultiple=false, * type="integer", * defaultValue=1 * ),@SWG\Parameter( * name="PerPage", * description="取得长度", * paramType="query", * required=false, * allowMultiple=false, * type="integer", * defaultValue=10 * ) * * ) * ) */ public function index(Request $request) { $start = $request->input('PageNum', 0); $length = $request->input('PerPage', 5); $user_id = $request->input('user_id'); $start = ($start - 1) * $length; $response = new BaseResponse(); $records = UseCouponRecords::where('user_id', $user_id)->where('status', 1); $rows = $records->skip($start)->take($length)->orderBy('id', 'desc')->get()->toArray(); foreach ($rows as &$v) { foreach ($v['order']['goods_list'] as &$g) { $g['properties'] = json_decode($g['properties']); } } $response->rows = $rows; $response->total = $records->count(); return $response->toJson(); }
public function notify(Request $request) { $out_trade_no = $request->input('out_trade_no'); $trade_status = $request->input('trade_status'); if ($out_trade_no != null && $trade_status != null && ($trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS')) { $order = Order::where('out_trade_no', $out_trade_no)->first(); if ($order != null) { $orderId = $order->id; $order->status = 1; $time = $request->input('gmt_payment'); if ($time == null) { $time = date("Y-m-d H:i:s", time()); } $order->payment_time = $time; $order->payment_way = 1; $order->save(); $useCouponRecords = UseCouponRecords::where('order_id', $orderId)->first(); if ($useCouponRecords != null) { //礼券金额 $useCouponRecords->status = 2; $apiParam = ['accessToken' => $useCouponRecords->access_token, 'coupon' => $useCouponRecords->coupon, 'orderId' => $out_trade_no]; $res = $this->post('/zhmf/member/consumerCoupon/useCoupon', $apiParam); $res = json_decode($res); if ($res->Code == 0) { $useCouponRecords->status = 1; } $useCouponRecords->save(); } } } echo 'success'; // $params=$request->all(); // $params=(array)$params; // Log::info(json_encode($params)); // if($this->rsaCheckV2($params,'../config/alipay_rsa_public_key.pem')){ // Log::info('验证成功'); // echo 'success'; // }else{ // Log::info('验证失败'); // } }