diff --git a/app/Http/Logic/OrderLogic.php b/app/Http/Logic/OrderLogic.php index 1395c3a..44e6f59 100644 --- a/app/Http/Logic/OrderLogic.php +++ b/app/Http/Logic/OrderLogic.php @@ -305,8 +305,8 @@ class OrderLogic extends BaseLogic /** * 订单-余额支付 - * @param int $data['id'] 订单id - * @param int $data['user_id'] 用户id + * @param int $where['id'] 订单id + * @param int $where['user_id'] 用户id * @return array */ public function orderYuepay($where = array()) @@ -318,6 +318,14 @@ class OrderLogic extends BaseLogic $order = $this->getModel()->getOne($where); if(!$order){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'订单不存在');} + //获取用户余额信息 + $user = model('User')->getOne(array('id'=>$where['user_id'])); + if(!$user){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户不存在');} + if($user->money < $order->order_amount) + { + return ReturnData::create(ReturnData::PARAMS_ERROR, null, '余额不足'); + } + DB::beginTransaction(); $data['pay_status'] = 1; @@ -326,20 +334,20 @@ class OrderLogic extends BaseLogic $data['pay_time'] = time(); $data['updated_at'] = time(); $res = $this->getModel()->edit($data,$where); - if($res) + if(!$res) { - $user_money_data['user_id'] = $where['user_id']; - $user_money_data['type'] = 1; - $user_money_data['money'] = $order->order_amount; - $user_money_data['des'] = '订单余额支付'; - if(!logic('UserMoney')->add($user_money_data)){DB::rollBack();} - - DB::commit(); - return ReturnData::create(ReturnData::SUCCESS,$res,'支付成功'); + DB::rollBack(); + return ReturnData::create(ReturnData::FAIL); } - DB::rollBack(); - return ReturnData::create(ReturnData::FAIL); + $user_money_data['user_id'] = $where['user_id']; + $user_money_data['type'] = 1; + $user_money_data['money'] = $order->order_amount; + $user_money_data['des'] = '订单余额支付'; + if(!logic('UserMoney')->add($user_money_data)){ DB::rollBack(); return ReturnData::create(ReturnData::FAIL); } + + DB::commit(); + return ReturnData::create(ReturnData::SUCCESS,$res,'支付成功'); } /** diff --git a/app/Http/Logic/UserMoneyLogic.php b/app/Http/Logic/UserMoneyLogic.php index 41cea9d..32dfe22 100644 --- a/app/Http/Logic/UserMoneyLogic.php +++ b/app/Http/Logic/UserMoneyLogic.php @@ -130,13 +130,14 @@ class UserMoneyLogic extends BaseLogic $user_money = model('User')->getDb()->where(array('id'=>$data['user_id']))->value('money'); //用户余额 $data['user_money'] = $user_money; - $res = $this->getModel()->add($data,$type); + $res = $this->getModel()->add($data, $type); if($res) { DB::commit(); //事务提交 return ReturnData::create(ReturnData::SUCCESS,$res); } + DB::rollBack(); //事务回滚 return ReturnData::create(ReturnData::FAIL); } diff --git a/app/Http/Model/Comment.php b/app/Http/Model/Comment.php index f945b52..7542d5a 100644 --- a/app/Http/Model/Comment.php +++ b/app/Http/Model/Comment.php @@ -17,7 +17,6 @@ class Comment extends BaseModel const GOODS_COMMENT_TYPE = 0; //商品评论 const ARTICLE_COMMENT_TYPE = 1; //文章评论 - public function getDb() { return DB::table($this->table); diff --git a/app/Http/Model/Kuaidi.php b/app/Http/Model/Kuaidi.php index dfe5b34..dc790b1 100644 --- a/app/Http/Model/Kuaidi.php +++ b/app/Http/Model/Kuaidi.php @@ -166,6 +166,6 @@ class Kuaidi extends BaseModel public function getStatusAttr($data) { $arr = array(0 => '显示', 1 => '不显示'); - return $arr[$data['status']]; + return $arr[$data->status]; } } \ No newline at end of file diff --git a/resources/views/admin/index/index.blade.php b/resources/views/admin/index/index.blade.php index 2960337..56c32a6 100644 --- a/resources/views/admin/index/index.blade.php +++ b/resources/views/admin/index/index.blade.php @@ -74,4 +74,7 @@ $(document).ready(function(){ + \ No newline at end of file diff --git a/resources/views/home/index/index.blade.php b/resources/views/home/index/index.blade.php index e898acb..73f9c2e 100644 --- a/resources/views/home/index/index.blade.php +++ b/resources/views/home/index/index.blade.php @@ -191,5 +191,8 @@ $(function(){ }); + @include('home.common.footer') \ No newline at end of file diff --git a/resources/views/weixin/feedback/userFeedbackAdd.blade.php b/resources/views/weixin/feedback/userFeedbackAdd.blade.php index 20ed929..395c0b7 100644 --- a/resources/views/weixin/feedback/userFeedbackAdd.blade.php +++ b/resources/views/weixin/feedback/userFeedbackAdd.blade.php @@ -32,7 +32,7 @@
- +
diff --git a/resources/views/weixin/index/index.blade.php b/resources/views/weixin/index/index.blade.php index 8f4811e..91eca27 100644 --- a/resources/views/weixin/index/index.blade.php +++ b/resources/views/weixin/index/index.blade.php @@ -179,4 +179,7 @@ var swiper = new Swiper('.swiper-nav', { .banner_tit{font-size:18px;font-weight:400;background-color:#fff;color:#f23030;height:46px;line-height:46px;padding-left:10px;padding-right:10px;border-bottom:1px solid #eee;text-align:center;} @include('weixin.common.footer') + \ No newline at end of file diff --git a/resources/views/weixin/user/userWithdraw.blade.php b/resources/views/weixin/user/userWithdraw.blade.php index 0ca8550..010829b 100644 --- a/resources/views/weixin/user/userWithdraw.blade.php +++ b/resources/views/weixin/user/userWithdraw.blade.php @@ -68,7 +68,7 @@ function submit() { var url = ''; var name = $("#name").val(); - var method = $('[name="method"][checked]').val(); + var method = $('input[name="method"]:checked').val(); var money = $("#money").val(); var account = $("#account").val(); var bank_name = $("#bank_name").val();