Exemple #1
0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $id = intval($this->getDataItem('order_id', 0));
     $pay = new Pay();
     $payInfo = $pay->weiXin2AppPay($id);
     $this->setResult($payInfo ? $payInfo : null);
 }
Exemple #2
0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $mobile = $this->getDataItem('mobile');
     $payType = $this->getDataItem('pay_type');
     $goods = $this->getDataItem('goods');
     if (empty($mobile) || empty($payType) || empty($goods) || !is_array($goods) || count($goods) == 0) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR);
     }
     $payTypeValue = $this->getPayTypeNum($payType);
     if ($payTypeValue <= 0) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '支付方式不支持.');
     }
     $userId = $this->getUserAuth()->userId;
     $goodsInfo = $this->getGoodsInfo($goods);
     if (count($goodsInfo) == 0) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '商品内容为空.');
     }
     // 计算总价格
     $money = 0;
     foreach ($goodsInfo as $gi) {
         $money = $money + $gi['order_number'] * $gi['service_price'];
     }
     $longId = Util::LongId(true);
     $orderId = $this->addOrderBase($longId, $mobile, $payTypeValue, $money, $userId);
     if ($orderId == 0) {
         return;
     }
     foreach ($goodsInfo as $gi) {
         $ogid = $this->addOrderGoods($userId, $orderId, $gi);
         if ($ogid <= 0) {
             UserOrder::SetOrderState($userId, $orderId, -1);
             return;
         }
     }
     $weixinPay = null;
     // 判断是否微信支付,微信支付需去下单
     if ($payTypeValue == 1) {
         $pay = new Pay();
         $weixinPay = $pay->weiXin2AppPay($orderId);
     }
     $this->setResult(['success' => 1, 'order_id' => $orderId, 'order_long_id' => $longId, 'weixin_pay' => $weixinPay ? $weixinPay : null]);
 }