params[ 'out_trade_no' ] ?? ''; $promotion = !empty($this->params[ 'promotion' ]) ? json_decode($this->params[ 'promotion' ], true) : []; $data = array ( 'pay_type' => $this->params[ 'pay_type' ] ?? '', 'site_id' => $this->site_id,//站点id 'out_trade_no' => $out_trade_no, 'store_id' => $this->store_id ?? 0, 'promotion' => $promotion, 'member_id' => $this->params[ 'member_id' ], 'cash' => $this->params[ 'cash' ] ?? 0 ); $cashier_order_calculate_model = new CashierOrderCalculate(); $result = $cashier_order_calculate_model->calculate($data); //记录缓存(操作记录保存) $cashier_order_pay_model = new CashierOrderPay(); $cashier_order_pay_model->setCache($out_trade_no, [ 'promotion' => $promotion, 'member_id' => $this->params[ 'member_id' ] ?? 0 ]); return $this->response($result); } /** * 订单支付 */ public function confirm() { $out_trade_no = $this->params[ 'out_trade_no' ] ?? ''; $promotion = !empty($this->params[ 'promotion' ]) ? json_decode($this->params[ 'promotion' ], true) : []; $cashier_order_pay_model = new CashierOrderPay(); $data = array ( 'pay_type' => $this->params[ 'pay_type' ] ?? '', 'site_id' => $this->site_id,//站点id 'out_trade_no' => $out_trade_no, 'store_id' => $this->store_id ?? 0, 'promotion' => $promotion, 'member_id' => $this->params[ 'member_id' ], 'cash' => $this->params[ 'cash' ] ?? 0 ); $result = $cashier_order_pay_model->confirm($data); return $this->response($result); } /** * 支付信息 * @return false|string */ public function info() { $out_trade_no = $this->params[ 'out_trade_no' ]; $pay = new PayModel(); $info = $pay->getPayInfo($out_trade_no); return $this->response($info); } /** * 生成支付二维码 */ public function payQrcode() { $out_trade_no = $this->params[ 'out_trade_no' ]; $cashier_order_pay_model = new CashierOrderPay(); $data = array ( 'site_id' => $this->site_id,//站点id 'out_trade_no' => $this->params[ 'out_trade_no' ] ?? '', 'store_id' => $this->store_id ?? 0, ); $result = $cashier_order_pay_model->createPay($data); if ($result[ 'code' ] < 0) { return $this->response($result); } $data = event('Qrcode', [ 'app_type' => 'h5', 'site_id' => $this->site_id, 'page' => '/pages/pay/cashier', 'qrcode_path' => 'upload/qrcode/cashier_pay', 'qrcode_name' => $out_trade_no, 'data' => [ 'out_trade_no' => $out_trade_no ] ], true); return $this->response($data); } }