Пример #1
0
 public function actionCharge()
 {
     if (\Yii::$app->request->post()) {
         $orderId = ChargeOrder::getInstance()->createOrder(\Yii::$app->request->post('user_id'), \Yii::$app->request->post());
         // 创建订单
         $result = ChargeOrder::getInstance()->setOrderStatus($orderId, 1, true);
         $this->renderAjax(['status' => $result]);
         exit;
     }
     $goods = ChargeGoods::getInstance()->getAllList(['status' => 1]);
     $this->assign('goods', $goods);
     return $this->render();
 }
Пример #2
0
 public function actionSetChargeType()
 {
     $this->renderAjax(['status' => ChargeOrder::getInstance()->setOrderChargeType($this->get['chargeTypeId'])]);
 }
Пример #3
0
 /**
  * 微信支付
  * @param $orderId
  * @return array
  * @throws \WxPayException
  */
 public function weiXinPay($orderId)
 {
     //①、获取用户openid
     $tools = new \JsApiPay();
     $openId = $tools->GetOpenid();
     if ($openId == -1) {
         return false;
     }
     //②、统一下单
     $orderInfo = ChargeOrder::getInstance()->getOne($orderId);
     $goods = ChargeGoods::getInstance()->getOne($orderInfo['charge_goods_id']);
     $input = new \WxPayUnifiedOrder();
     $input->SetBody("嘉瑞百合缘-【" . $goods['name'] . "】");
     $input->SetAttach("手机网站");
     $input->SetOut_trade_no($orderInfo['order_id']);
     $input->SetTotal_fee((string) $orderInfo['money']);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetNotify_url("http://wechat.baihey.com/wap/charge/notify-url");
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = \WxPayApi::unifiedOrder($input);
     $jsApiParameters = $tools->GetJsApiParameters($order);
     return ['orderInfo' => $orderInfo, 'jsApiParameters' => $jsApiParameters];
 }