Browse Source

order detail

master
ZLW-PC\Administrator 7 years ago
parent
commit
be9d9522dd
  1. 29
      app/Common/Helper.php
  2. 6
      app/Common/ReturnData.php
  3. 4
      app/Http/Controllers/Api/OrderController.php
  4. 25
      app/Http/Controllers/Weixin/OrderController.php
  5. 2
      app/Http/Controllers/Weixin/UserController.php
  6. 1
      app/Http/Model/BaseModel.php
  7. 75
      app/Http/Model/Order.php
  8. 21
      app/Http/Model/Region.php
  9. 1
      resources/views/weixin/goods/goodsDetail.blade.php
  10. 67
      resources/views/weixin/order/orderDetail.blade.php
  11. 77
      resources/views/weixin/order/orderList.blade.php
  12. 1
      routes/web.php

29
app/Common/Helper.php

@ -219,6 +219,25 @@ class Helper
return false;
}
/**
* 检查是否是POST请求
*/
public static function isPostRequest()
{
if($_SERVER['REQUEST_METHOD'] == 'POST') return true;
if($_POST) return true;
return false;
}
/**
* 是否是GET提交的
*/
public static function isGetRequest()
{
return $_SERVER['REQUEST_METHOD'] == 'GET' ? true : false;
}
/**
* 301跳转。
* Header 301 Moved Permanently.
@ -286,4 +305,14 @@ class Helper
return false;
}
//判断是不是https
public static function isHttpsRequest()
{
if((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) return true;
if($_SERVER['SERVER_PORT'] == 443) return true;
return false;
}
}

6
app/Common/ReturnData.php

@ -97,7 +97,7 @@ class ReturnData
//验证码
8801 =>'验证码无效',
);
public static function create($code, $data = null, $msg = '')
{
if (empty($msg) && isset(self::$codeTexts[$code]))
@ -107,7 +107,7 @@ class ReturnData
return array('code' => $code, 'msg' => $msg, 'data' => $data);
}
public static function success($data = null, $msg = '')
{
if (empty($msg) && isset(self::$codeTexts[self::SUCCESS]))
@ -117,7 +117,7 @@ class ReturnData
return array('code' => self::SUCCESS, 'msg' => $msg, 'data' => $data);
}
public static function error($code, $data = null, $msg = '')
{
if (empty($msg) && isset(self::$codeTexts[$code]))

4
app/Http/Controllers/Api/OrderController.php

@ -30,13 +30,15 @@ class OrderController extends CommonController
//参数
$data['user_id'] = Token::$uid;
$data['order_id'] = $request->input('order_id','');
if($request->input('order_status','') != ''){$data['order_status'] = $request->input('order_status');}
if($request->input('pay_status','') != ''){$data['pay_status'] = $request->input('pay_status');}
if($data['order_id']=='')
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
return Order::getUnpaidOrder($data);
return Order::getOne($data);
}
//生成订单

25
app/Http/Controllers/Weixin/OrderController.php

@ -55,6 +55,23 @@ class OrderController extends CommonController
return view('weixin.order.orderList', $data);
}
//订单详情
public function orderDetail(Request $request)
{
$id = $request->input('id','');
$postdata = array(
'order_id' => $id,
'access_token' => $_SESSION['weixin_user_info']['access_token']
);
$url = env('APP_API_URL')."/order_detail";
$res = curl_request($url,$postdata,'GET');
$data['post'] = $res['data'];
if(empty($data['post'])){$this->error_jump('订单不存在');}
return view('weixin.order.orderDetail', $data);
}
//订单支付
public function pay($id)
@ -62,6 +79,8 @@ class OrderController extends CommonController
//获取订单详情
$postdata = array(
'order_id' => $id, //要支付的订单id
'order_status' => 0,
'pay_status' => 0,
'access_token' => $_SESSION['weixin_user_info']['access_token']
);
$url = env('APP_API_URL')."/order_detail";
@ -69,7 +88,7 @@ class OrderController extends CommonController
$data['order_detail'] = $res['data'];
$data['order_id'] = $id;
/* if(!$res['code']!=0){$this->error_jump('订单不存在或已过期');} */
if($res['code']!=0 || empty($data['order_detail'])){$this->error_jump('订单不存在或已过期');}
//获取会员信息
$postdata = array(
@ -126,6 +145,8 @@ class OrderController extends CommonController
//获取订单详情
$postdata = array(
'order_id' => $order_id, //要支付的订单id
'order_status' => 0,
'pay_status' => 0,
'access_token' => $_SESSION['weixin_user_info']['access_token']
);
$url = env('APP_API_URL')."/order_detail";
@ -133,7 +154,7 @@ class OrderController extends CommonController
$data['order_detail'] = $res['data'];
$data['order_id'] = $order_id;
if(!$res['code']!=0){$this->error_jump('订单不存在或已过期');}
if($res['code']!=0){$this->error_jump('订单不存在或已过期');}
//微信支付-start
require_once(resource_path('org/wxpay/WxPayConfig.php')); // 导入微信配置类

2
app/Http/Controllers/Weixin/UserController.php

@ -379,7 +379,7 @@ class UserController extends CommonController
{
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
$callback_url = $http_type . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; //回调地址,当前页面
//-------生成唯一随机串防CSRF攻击
//生成唯一随机串防CSRF攻击
$state = md5(uniqid(rand(), true));
$_SESSION['weixin_oauth']['state'] = $state; //存到SESSION
$authorize_url = $wechat_auth->get_authorize_url($callback_url, $state);

1
app/Http/Model/BaseModel.php

@ -1,6 +1,5 @@
<?php
namespace App\Http\Model;
use Illuminate\Database\Eloquent\Model;
class BaseModel extends Model

75
app/Http/Model/Order.php

@ -27,7 +27,7 @@ class Order extends BaseModel
$where['user_id'] = $user_id;
$where['is_delete'] = 0;
//0或者不传表示全部,1待付款,2待发货,3待收货,4待评价(确认收货,交易成),5退款/售后
//0或者不传表示全部,1待付款,2待发货,3待收货,4待评价(确认收货,交易成),5退款/售后
if($status == 1)
{
$where['order_status'] = 0;
@ -66,26 +66,52 @@ class Order extends BaseModel
if($res['count']>0)
{
$res['list'] = $model->skip($offset)->take($limit)->get();
$order_list = $model->skip($offset)->take($limit)->get();
if($res['list'])
if($order_list)
{
foreach($res['list'] as $k=>$v)
foreach($order_list as $k=>$v)
{
$order_list[$k]['order_status_text'] = self::getOrderStatusText($v);
$order_goods = OrderGoods::where(array('order_id'=>$v['id']))->get();
$res[$k]['goods_list'] = $order_goods;
$order_list[$k]['goods_list'] = $order_goods;
}
}
$res['list'] = $order_list;
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
public static function getOne($where)
public static function getOne(array $param)
{
$goods = self::where($where)->first();
extract($param);
$where['id'] = $order_id;
$where['user_id'] = $user_id;
if(isset($order_status)){$where['order_status'] = $order_status;}
if(isset($pay_status)){$where['pay_status'] = $pay_status;}
$res = self::where($where)->first();
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
$res['order_status_text'] = self::getOrderStatusText($res);
return $goods;
$res['province_name'] = Region::getRegionName($res['province']);
$res['city_name'] = Region::getRegionName($res['city']);
$res['district_name'] = Region::getRegionName($res['district']);
$order_goods = OrderGoods::where(array('order_id'=>$res['id']))->get();
$res['goods_list'] = $order_goods;
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//生成订单
@ -96,7 +122,7 @@ class Order extends BaseModel
//获取订单商品列表
$cartCheckoutGoods = Cart::cartCheckoutGoodsList(array('ids'=>$cartids,'user_id'=>$user_id));
$order_goods = $cartCheckoutGoods['data'];
if(!$order_goods['list']){return ReturnData::create(ReturnData::SYSTEM_FAIL,null,'订单商品不存在');}
if(empty($order_goods['list'])){return ReturnData::create(ReturnData::SYSTEM_FAIL,null,'订单商品不存在');}
//获取收货地址
$user_address = UserAddress::getOne($user_id,$default_address_id);
@ -213,18 +239,31 @@ class Order extends BaseModel
return true;
}
//获取未支付的订单详情
public static function getUnpaidOrder(array $param)
//获取订单状态文字,1待付款,2待发货,3待收货,4待评价(确认收货,交易成功),5退款/售后
public static function getOrderStatusText($where)
{
extract($param);
$res = self::where(array('id'=>$order_id,'order_status'=>0,'pay_status'=>0,'user_id'=>$user_id))->select('id', 'order_sn', 'user_id', 'add_time', 'order_amount')->first();
if(!$res)
$res = '';
if($where['order_status'] == 0 && $where['pay_status'] ==0)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,'');
$res = '待付款';
}
elseif($where['order_status'] == 0 && $where['shipping_status'] == 0 && $where['pay_status'] == 1)
{
$res = '待发货';
}
elseif($where['order_status'] == 0 && $where['refund_status'] == 0 && $where['shipping_status'] == 1 && $where['pay_status'] == 1)
{
$res = '待收货';
}
elseif($where['order_status'] == 3 && $where['refund_status'] == 0 && $where['shipping_status'] == 2 && $where['is_comment'] == 0)
{
$res = '交易成功';
}
elseif($where['order_status'] == 3 && $where['refund_status'] == 1)
{
$res = '售后';
}
return ReturnData::create(ReturnData::SUCCESS,$res);
return $res;
}
}

21
app/Http/Model/Region.php

@ -1,9 +1,6 @@
<?php
namespace App\Http\Model;
use Illuminate\Database\Eloquent\Model;
use App\Common\Token;
class Region extends BaseModel
{
//地区
@ -13,15 +10,9 @@ class Region extends BaseModel
public static function getRegionName($id)
{
if(empty($id)){return '';}
if(empty($id) || $id==0){return '';}
$res = self::where('id', $id)->value('name');
if (!empty($res))
{
return $res;
}
return '';
return self::where('id', $id)->value('name');
}
public static function getList($parent_id=86)
@ -31,12 +22,6 @@ class Region extends BaseModel
public static function getOne($id)
{
$res = self::where('id', $id)->first();
if (!empty($res))
{
return $res;
}
return false;
return self::where('id', $id)->first();
}
}

1
resources/views/weixin/goods/goodsDetail.blade.php

@ -57,7 +57,6 @@ var swiper = new Swiper('.swiper-container', {
<span></span><i class="price"><?php echo $post['price']; ?></i>
</div>
<span class="btn-retail">门店有售</span>
</div>
<div class="stock-detail table-cell">

67
resources/views/weixin/order/orderDetail.blade.php

@ -0,0 +1,67 @@
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>订单详情</title><meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
<link href="<?php echo env('APP_URL'); ?>/css/weixin/style.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/jquery.min.js"></script><script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/weixin/mobile.js"></script>
<meta name="keywords" content="关键词"><meta name="description" content="描述">
<link href="<?php echo env('APP_URL'); ?>/css/font-awesome.min.css" type="text/css" rel="stylesheet"></head><body style="background-color:#f1f1f1;">
<div class="classreturn loginsignup">
<div class="ds-in-bl return"><a href="javascript:history.back(-1);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/return.png" alt="返回"></a></div>
<div class="ds-in-bl tit center"><span>订单详情</span></div>
<div class="ds-in-bl nav_menu"><a href="javascript:void(0);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/class1.png" alt="菜单"></a></div>
</div>
@include('weixin.common.headerNav')
<!-- 选择收货地址-start -->
<div class="checkout-addr">
<p class="title"><span class="name" id="default_consignee"><?php echo $post['name']; ?></span> <span class="tel" id="default_phone"><?php echo $post['mobile']; ?></span></p>
<p class="des" id="default_address"><?php echo $post['province_name'].$post['city_name'].$post['district_name']; ?> <?php echo $post['address']; ?></p>
<i class="fa fa-street-view"></i>
</div>
<style>
.checkout-addr{position: relative;background:#fff;margin-top:10px;padding:10px;}
.checkout-addr p{margin-right:20px;}.checkout-addr .title{font-size:18px;color:#353535;}.checkout-addr .des{color:#9b9b9b;}
.checkout-addr i{position:absolute;top:50%;right:12px;margin-top:-6px;color:#bbb;display:inline-block;}
</style>
<!-- 选择收货地址-end -->
<!-- 订单商品-start -->
<div class="floor mt10">
<div class="tit_h">订单商品</div>
<ul class="goodslist">
<?php if($post){foreach($post['goods_list'] as $key=>$value){ ?>
<li>
<img src="<?php echo $value['goods_img']; ?>">
<p><b><?php echo $value['goods_name']; ?></b><span>¥<?php echo $value['goods_price']; ?><i>x<?php echo $value['goods_number']; ?></i></span></p>
</li>
<?php }} ?>
</ul>
<p class="des">合计: <?php echo $post['order_amount']; ?> <small>(含运费:¥<?php echo $post['shipping_fee']; ?>)</small></p>
<div class="tag"><a href="" class="activate">我要付款</a><a href="">评价</a></div>
</div>
<style>
.goodslist{background-color:#fbfbfb;}
.goodslist li{display:-webkit-box;margin:0 10px;padding:10px 0;border-bottom:1px solid #f1f1f1;}.goodslist li:last-child{border-bottom:none;}
.goodslist li img{margin-right:10px;display:block;width:60px;height:60px;border:1px solid #e1e1e1;}
.goodslist li p {display: block;-webkit-box-flex:1;width:100%;}
.goodslist li p b {display:block;font-size:16px;font-weight:400;line-height:28px;color:#333;}
.goodslist li p span {color:#f23030;font-size:18px;display: block;padding-top:5px;}
.goodslist li p i{color:#666;float:right;font-size:14px;}
.tit_h{font-size:16px;font-weight:400;background-color:#fff;color:#383838;height:42px;line-height:41px;padding-left:10px;padding-right:10px;border-bottom:1px solid #eee;}
.tit_h span{color:#e94e45;}
.floor .des{text-align:right;background-color:#fff;font-size:14px;padding:6px 10px;}
.tag{background-color:#fff;padding-bottom:10px;text-align:right;}
.tag a{color:#666;background-color:#fff;border:1px solid #ddd;border-radius:5px;font-size:14px;padding:2px 6px;display:inline-block;margin-right:10px;}
.tag a.activate{color:#ea6f5a;border:1px solid #ea6f5a;}
</style>
<!-- 订单商品-end -->
<div class="order_expand mt10">
<p>创建时间:<?php echo date('Y-m-d H:i:s',$post['add_time']); ?></p>
<p>订单编号:<?php echo $post['order_sn']; ?></p>
</div>
<style>
.order_expand{background-color:#fff;padding:10px;font-size:14px;color:#666;}
</style>
@include('weixin.common.footer')
</body></html>

77
resources/views/weixin/order/orderList.blade.php

@ -2,7 +2,7 @@
<title>我的订单</title><meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
<link href="<?php echo env('APP_URL'); ?>/css/weixin/style.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/jquery.min.js"></script><script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/weixin/mobile.js"></script>
<meta name="keywords" content="关键词"><meta name="description" content="描述"></head><body>
<meta name="keywords" content="关键词"><meta name="description" content="描述"></head><body style="background-color:#f1f1f1;">
<div class="classreturn loginsignup">
<div class="ds-in-bl return"><a href="javascript:history.back(-1);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/return.png" alt="返回"></a></div>
<div class="ds-in-bl tit center"><span>我的订单</span></div>
@ -10,56 +10,39 @@
</div>
@include('weixin.common.headerNav')
<?php if($list){foreach($list as $key=>$value){ ?>
<div class="floor mt10">
<a href="<?php echo route('weixin_order_detail',array('id'=>$value['id'])); ?>">
<div class="tit_h">单号:<?php echo $value['id']; ?><span class="fr"><?php echo $value['order_status_text']; ?></span></div>
<ul class="goodslist">
<?php if($value['goods_list']){foreach($value['goods_list'] as $k=>$v){ ?>
<li>
<img src="<?php echo $v['goods_img']; ?>">
<p><b><?php echo $v['goods_name']; ?></b><span>¥<?php echo $v['goods_price']; ?><i>x<?php echo $v['goods_number']; ?></i></span></p>
</li>
<?php }} ?>
</ul>
</a>
<div class="floor">
<form action="<?php echo route('weixin_order_dopay'); ?>" method="POST" id="goto_pay">
<input type="hidden" name="order_id" value="<?php echo $order_id; ?>">
<div class="step_main">
<div class="clue_on"><p>您的订单已成功生成,选择您想用的支付方式进行支付。</p></div>
<div class="order_info">
<p>订单编号:<span><?php echo $order_id; ?></span></p>
<p>应付金额:<span>¥<?php echo $order_detail['order_amount']; ?></span></p>
</div>
<div class="payment mt10">
<h3>选择支付方式付款</h3>
<dl class="defray">
<?php if($is_balance_enough){ ?>
<dd>
<p class="radio"><input id="payment_yuer" name="payment_id" value="1" type="radio"></p>
<label for="payment_yuer"><p class="logo"><img src="<?php echo env('APP_URL'); ?>/images/weixin/yuepay_icon.png"></p>
<p class="explain">余额支付</p></label>
</dd>
<?php } ?>
<dd>
<p class="radio"><input id="payment_wxpay" name="payment_id" value="2" type="radio" checked="checked"></p>
<label for="payment_wxpay"><p class="logo"><img src="<?php echo env('APP_URL'); ?>/images/weixin/wxpay_icon.png"></p>
<p class="explain">微信支付</p></label>
</dd>
</dl>
<div class="cl"></div>
</div>
<a href="javascript:$('#goto_pay').submit();" class="bottoma" style="margin-top:10px;margin-bottom:15px;background-color:#1aad19;border:1px solid #179e16;color:white;border-radius:2px;text-align:center;">确认支付</a>
<div class="remark" style="color:#666;">
您可以在 <a href="<?php echo route('weixin_order_list'); ?>">我的订单</a> 中查看或取消您的订单。<br>
如果您现在不方便支付,可以随后到 <a href="<?php echo route('weixin_order_list'); ?>">我的订单</a>完成支付,我们会在48小时内为您保留未支付的订单。
</div>
<p class="des">合计: <?php echo $value['order_amount']; ?> <small>(含运费:¥<?php echo $value['shipping_fee']; ?>)</small></p>
<div class="tag"><a href="" class="activate">我要付款</a><a href="">评价</a></div>
</div>
</form>
</div>
<?php }} ?>
<style>
.step_main{padding:10px;}
.step_main .clue_on{color:#666;}
.step_main .order_info{color:#999;}
.step_main .order_info span{color:#f34;}
.step_main h4,.step_main h3{padding:5px 0;font-weight:normal;color:#333;}
.defray{margin-top:5px;}
.defray dd{min-height:36px;line-height:36px;border-top:1px solid #eee;padding:6px 0;clear:both;}
.defray dd p.logo img{float:left;height:36px;}
.defray dd p.explain{float:left;color:#787878;margin-left:10px;}
.radio{float:left;width:20px;}
.goodslist{background-color:#fbfbfb;}
.goodslist li{display:-webkit-box;margin:0 10px;padding:10px 0;border-bottom:1px solid #f1f1f1;}.goodslist li:last-child{border-bottom:none;}
.goodslist li img{margin-right:10px;display:block;width:60px;height:60px;border:1px solid #e1e1e1;}
.goodslist li p{display: block;-webkit-box-flex:1;width:100%;}
.goodslist li p b{display:block;font-size:16px;font-weight:400;line-height:28px;color:#333;}
.goodslist li p span{color:#f23030;font-size:16px;display:block;padding-top:5px;}
.goodslist li p i{color:#666;float:right;font-size:14px;}
.bottoma{display:block;font-size:18px;padding:10px;color:white;background-color:#f23030;text-align:center;}
.tit_h{font-size:16px;font-weight:400;background-color:#fff;color:#383838;height:42px;line-height:41px;padding-left:10px;padding-right:10px;border-bottom:1px solid #eee;}
.tit_h span{color:#e94e45;}
.des{text-align:right;background-color:#fff;font-size:14px;padding:6px 10px;}
.tag{background-color:#fff;padding-bottom:10px;text-align:right;}
.tag a{color:#666;background-color:#fff;border:1px solid #ddd;border-radius:5px;font-size:14px;padding:2px 6px;display:inline-block;margin-right:10px;}
.tag a.activate{color:#ea6f5a;border:1px solid #ea6f5a;}
</style>
@include('weixin.common.footer')
</body></html>

1
routes/web.php

@ -103,6 +103,7 @@ Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin', 'middleware' => ['w
Route::get('/order_pay/{id}', 'OrderController@pay')->name('weixin_order_pay'); //订单支付
Route::post('/order_dopay', 'OrderController@dopay')->name('weixin_order_dopay'); //订单支付
Route::get('/order_list', 'OrderController@orderList')->name('weixin_order_list'); //全部订单列表
Route::get('/order_detail', 'OrderController@orderDetail')->name('weixin_order_detail'); //订单详情
Route::get('/order_wxpay', 'OrderController@orderWxpay')->name('weixin_order_wxpay'); //订单微信支付
Route::get('/order_yuepay', 'OrderController@orderYuepay')->name('weixin_order_yuepay'); //订单余额支付
//收货地址

Loading…
Cancel
Save