예제 #1
0
 public function run()
 {
     $user_id = intval(Input::get('user_id', 0));
     $album_id = intval(Input::get('album_id', 0));
     $quantity = intval(Input::get('quantity', 1));
     $real_name = trim(Input::get('real_name', ''));
     $mobile = trim(Input::get('mobile', ''));
     $address = trim(Input::get('address', ''));
     if (empty($real_name)) {
         return '姓名必须填写';
     }
     if (empty($mobile)) {
         return '联系电话必须填写';
     }
     if (empty($address)) {
         return '联系地址必须填写';
     }
     $user = UserORM::whereId($user_id)->whereStatus(BaseORM::ENABLE)->first();
     if (empty($user)) {
         return '用户未找到';
     }
     $album = AlbumORM::whereId($album_id)->whereUserId($user_id)->first();
     if (empty($album)) {
         return '相册未找到';
     }
     $source = AlbumSourceORM::whereAlbumId($album_id)->get();
     if (count($source) == 0) {
         return '该相册没有任何图片';
     }
     $template = TemplateORM::whereId($album->template_id)->first();
     if (empty($template)) {
         return '相册模版未找到';
     }
     if (intval($quantity) <= 0) {
         return '数量错误';
     }
     $price = $template->price;
     $total_amount = $price * $quantity;
     $orm = new OrderORM();
     $orm->user_id = $user_id;
     $orm->album_id = $album_id;
     $orm->quantity = $quantity;
     $orm->total_amount = $total_amount;
     $orm->save();
     $order = OrderORM::find($orm->id);
     $user->real_name = $real_name;
     $user->mobile = $mobile;
     $user->address = $address;
     $user->save();
     return $order;
 }
예제 #2
0
 public function run()
 {
     $post_str = file_get_contents("php://input", true);
     $post_obj = simplexml_load_string($post_str, 'SimpleXMLElement', LIBXML_NOCDATA);
     if (isset($post_obj->return_code)) {
         $result_code = $post_obj->result_code;
         $return_code = $post_obj->return_code;
         $out_trade_no = $post_obj->out_trade_no;
         $payOrder = PayMentORM::where('out_trade_no', '=', $out_trade_no)->first();
         if (!empty($payOrder)) {
             $payOrder->notify_time = date("Y-m-d H:i:s", time());
             $payOrder->result_code = $result_code;
             $payOrder->return_code = $return_code;
             $payOrder->save();
         }
         if ($result_code == "SUCCESS" || $return_code == "SUCCESS") {
             $payOrder->transaction_id = $post_obj->transaction_id;
             $payOrder->time_end = $post_obj->time_end;
             $payOrder->server_paid = 1;
             $payOrder->save();
             //更新订单
             $order = OrderORM::whereId($payOrder->order_id)->first();
             $order->pay_status = 1;
             $order->save();
         }
         echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
     } else {
         echo '<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[ERROR_MSG]]></return_msg></xml>';
     }
     exit;
 }
예제 #3
0
 public function save()
 {
     $params = Input::all();
     $id = $params['id'];
     unset($params['id']);
     try {
         OrderORM::edit($id, $params);
         $this->_succ('保存成功');
     } catch (Exception $e) {
         $this->_fail('保存失败');
     }
 }
예제 #4
0
 public function run()
 {
     $order_id = Input::get('order_id', 0);
     $user_id = Input::get('user_id', 0);
     $open_id = Input::get('open_id', '');
     $pay_ment = PayMentORM::whereOrderId($order_id)->where('openid', '<>', '')->first();
     if (empty($pay_ment)) {
         $order = OrderORM::whereId($order_id)->wherePayStatus(BaseORM::DISABLE)->first();
         if (empty($order)) {
             return '订单未找到';
         }
         if ($user_id != $order->user_id) {
             return '用户不正确';
         }
         $album = AlbumORM::whereId($order->album_id)->first();
         if (empty($album)) {
             return '相册未找到';
         }
         $template = TemplateORM::whereId($album->template_id)->first();
         if (empty($template)) {
             return '相册模版未找到';
         }
         $params['out_trade_no'] = $this->_generate_out_trade_no($order_id, $user_id);
         $params['subject'] = '购买相册打印服务';
         $params['quantity'] = $order->quantity;
         $params['total_fee'] = $order->total_amount;
         $params['price'] = $template->price;
         $params['body'] = '购买相册打印服务';
         $params['user_id'] = $user_id;
         $params['openid'] = $open_id;
         $params['order_id'] = $order_id;
         $r = PayMentORM::edit(0, $params);
         $pay_ment = $r[1];
     }
     try {
         $m = new Wxpay();
         $jsParameters = $m->getJsApiParameters($pay_ment->out_trade_no, $pay_ment->total_fee * 100, $pay_ment->openid);
         return json_decode($jsParameters, true);
     } catch (Exception $e) {
         return '内部错误';
     }
 }