From 4a0dce40e8f3f424289acbb9ce3af093c7aea137 Mon Sep 17 00:00:00 2001 From: "ZLW-PC\\Administrator" <374861669@qq.com> Date: Tue, 12 Dec 2017 21:33:10 +0800 Subject: [PATCH] order comment withdraw --- app/Common/function.php | 1 - .../Controllers/Api/CommentController.php | 65 ++++---- app/Http/Controllers/Api/OrderController.php | 146 +++++++++++++++++- app/Http/Controllers/Api/UserController.php | 24 ++- .../Api/UserWithdrawController.php | 12 +- .../Controllers/Weixin/OrderController.php | 105 ++++++++++++- .../Controllers/Weixin/UserController.php | 64 +++++++- .../Controllers/Weixin/WxPayController.php | 47 +++++- app/Http/Model/Comment.php | 63 ++++++-- app/Http/Model/Order.php | 22 ++- app/Http/Model/UserRecharge.php | 2 + app/Http/Model/UserWithdraw.php | 52 ++++++- .../views/weixin/order/orderComment.blade.php | 42 +++++ .../views/weixin/order/orderDetail.blade.php | 101 +++++++++++- .../views/weixin/order/orderList.blade.php | 100 +++++++++++- resources/views/weixin/user/index.blade.php | 12 +- .../views/weixin/user/userAccount.blade.php | 2 +- .../views/weixin/user/userWithdraw.blade.php | 125 +++++++++++++++ .../weixin/user/userWithdrawList.blade.php | 98 ++++++++++++ routes/web.php | 21 ++- 20 files changed, 1015 insertions(+), 89 deletions(-) create mode 100644 resources/views/weixin/order/orderComment.blade.php create mode 100644 resources/views/weixin/user/userWithdraw.blade.php create mode 100644 resources/views/weixin/user/userWithdrawList.blade.php diff --git a/app/Common/function.php b/app/Common/function.php index 412fa81..dd04082 100644 --- a/app/Common/function.php +++ b/app/Common/function.php @@ -18,7 +18,6 @@ if (! function_exists('curl_request')) case 'POST' : curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, $params); - break; case 'PUT' : curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); diff --git a/app/Http/Controllers/Api/CommentController.php b/app/Http/Controllers/Api/CommentController.php index e2c4983..192d737 100644 --- a/app/Http/Controllers/Api/CommentController.php +++ b/app/Http/Controllers/Api/CommentController.php @@ -15,17 +15,19 @@ class CommentController extends CommonController parent::__construct(); } - public function goodsCommentList(Request $request) + public function commentList(Request $request) { //参数 $data['limit'] = $request->input('limit', 10); $data['offset'] = $request->input('offset', 0); $data['user_id'] = Token::$uid; $data['comment_type'] = $request->input('comment_type', 0); //0商品评价,1文章评价 - if($request->input('comment_rank', null) !== null){$data['comment_rank'] = $request->input('comment_rank');} + if($request->input('comment_rank', '') != ''){$data['comment_rank'] = $request->input('comment_rank');} + if($request->input('id_value', '') != ''){$data['id_value'] = $request->input('id_value');} + if($request->input('parent_id', '') != ''){$data['parent_id'] = $request->input('parent_id');} $res = Comment::getList($data); - if($res !== true) + if($res === false) { return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); } @@ -33,16 +35,14 @@ class CommentController extends CommonController return ReturnData::create(ReturnData::SUCCESS,$res); } - //添加评价 - public function goodsCommentAdd(Request $request) + //添加一条评价 + public function commentAdd(Request $request) { //参数 $data['comment_type'] = $request->input('comment_type',0); $data['id_value'] = $request->input('id_value',null); $data['content'] = $request->input('content',null); $data['comment_rank'] = $request->input('comment_rank',null); - if($request->input('email', null) !== null){$data['email'] = $request->input('email');} - if($request->input('user_name', null) !== null){$data['user_name'] = $request->input('user_name');} if($request->input('ip_address', null) !== null){$data['ip_address'] = $request->input('ip_address');} if($request->input('parent_id', null) !== null){$data['parent_id'] = $request->input('parent_id');} $data['add_time'] = time(); @@ -54,47 +54,50 @@ class CommentController extends CommonController return ReturnData::create(ReturnData::PARAMS_ERROR); } - $res = Comment::add($data); - if($res !== true) - { - return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); - } + return Comment::add($data); + } + + //评价批量添加 + public function commentBatchAdd(Request $request) + { + if($request->input('comment',null)===null){return ReturnData::create(ReturnData::PARAMS_ERROR);} + $comment = json_decode($request->input('comment'),true); + foreach($comment as $k=>$v) + { + $comment[$k]['user_id'] = Token::$uid; + $comment[$k]['ip_address'] = Helper::getRemoteIp(); + $comment[$k]['add_time'] = time(); + } - return ReturnData::create(ReturnData::SUCCESS,$res); + return Comment::batchAdd($comment); } - public function goodsCommentUpdate(Request $request) + public function commentUpdate(Request $request) { //参数 $id = $request->input('id',null); - $data['comment_type'] = $request->input('comment_type',0); - $data['id_value'] = $request->input('id_value',null); - $data['content'] = $request->input('content',null); - $data['comment_rank'] = $request->input('comment_rank',null); - if($request->input('email', null) !== null){$data['email'] = $request->input('email');} - if($request->input('user_name', null) !== null){$data['user_name'] = $request->input('user_name');} + if($request->input('content', null) !== null){$data['content'] = $request->input('content');} + if($request->input('comment_rank', null) !== null){$data['comment_rank'] = $request->input('comment_rank');} if($request->input('ip_address', null) !== null){$data['ip_address'] = $request->input('ip_address');} if($request->input('parent_id', null) !== null){$data['parent_id'] = $request->input('parent_id');} - $data['add_time'] = time(); - $data['user_id'] = Token::$uid; - $data['ip_address'] = Helper::getRemoteIp(); + if($id===null) { return ReturnData::create(ReturnData::PARAMS_ERROR); } - $res = Comment::modify(array('id'=>$id),$data); - if($res !== true) - { - return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); - } + if(isset($data)) + { + $data['user_id'] = Token::$uid; + Comment::modify(array('id'=>$id),$data); + } - return ReturnData::create(ReturnData::SUCCESS,$res); + return ReturnData::create(ReturnData::SUCCESS); } //删除评价 - public function goodsCommentDelete(Request $request) + public function commentDelete(Request $request) { //参数 $data['comment_type'] = $request->input('comment_type',null); @@ -107,7 +110,7 @@ class CommentController extends CommonController } $res = Comment::remove($data); - if($res !== true) + if($res === false) { return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); } diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php index 2cb2213..065519f 100644 --- a/app/Http/Controllers/Api/OrderController.php +++ b/app/Http/Controllers/Api/OrderController.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use App\Common\ReturnData; use App\Common\Token; use App\Http\Model\Order; +use DB; class OrderController extends CommonController { @@ -19,7 +20,7 @@ class OrderController extends CommonController { //参数 $data['user_id'] = Token::$uid; - $data['status'] = $request->input('status',''); + $data['status'] = $request->input('status',-1); return Order::getList($data); } @@ -32,6 +33,7 @@ class OrderController extends CommonController $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($request->input('refund_status','') != ''){$data['refund_status'] = $request->input('refund_status');} if($data['order_id']=='') { @@ -64,6 +66,148 @@ class OrderController extends CommonController return Order::add($data); } + //订单修改 + public function orderUpdate(Request $request) + { + if($request->input('id', '')!=''){$where['id'] = $request->input('id');} + if($request->input('order_sn', '')!=''){$where['order_sn'] = $request->input('order_sn');} + + if($request->input('order_amount', '')!=''){$data['order_amount'] = $request->input('order_amount');} + if($request->input('out_trade_no', '')!=''){$data['out_trade_no'] = $request->input('out_trade_no');} + if($request->input('shipping_name', '')!=''){$data['shipping_name'] = $request->input('shipping_name');} + if($request->input('shipping_id', '')!=''){$data['shipping_id'] = $request->input('shipping_id');} + if($request->input('shipping_sn', '')!=''){$data['shipping_sn'] = $request->input('shipping_sn');} + if($request->input('shipping_fee', '')!=''){$data['shipping_fee'] = $request->input('shipping_fee');} + if($request->input('shipping_time', '')!=''){$data['shipping_time'] = $request->input('shipping_time');} + if($request->input('name', '')!=''){$data['name'] = $request->input('name');} + if($request->input('province', '')!=''){$data['province'] = $request->input('province');} + if($request->input('city', '')!=''){$data['city'] = $request->input('city');} + if($request->input('district', '')!=''){$data['district'] = $request->input('district');} + if($request->input('address', '')!=''){$data['address'] = $request->input('address');} + if($request->input('zipcode', '')!=''){$data['zipcode'] = $request->input('zipcode');} + if($request->input('mobile', '')!=''){$data['mobile'] = $request->input('mobile');} + if($request->input('message', '')!=''){$data['message'] = $request->input('message');} + if($request->input('is_comment', '')!=''){$data['is_comment'] = $request->input('is_comment');} + if($request->input('is_delete', '')!=''){$data['is_delete'] = $request->input('is_delete');} + if($request->input('to_buyer', '')!=''){$data['to_buyer'] = $request->input('to_buyer');} + if($request->input('invoice', '')!=''){$data['invoice'] = $request->input('invoice');} + if($request->input('invoice_title', '')!=''){$data['invoice_title'] = $request->input('invoice_title');} + if($request->input('invoice_taxpayer_number', '')!=''){$data['invoice_taxpayer_number'] = $request->input('invoice_taxpayer_number');} + + if(!isset($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);} + + if (isset($data)) + { + $where['user_id'] = Token::$uid; + Order::modify($where,$data); + } + + return ReturnData::create(ReturnData::SUCCESS); + } + + //订单状态修改 + public function orderStatusUpdate(Request $request) + { + $type = $request->input('type',''); + if($request->input('id', '')!=''){$where['id'] = $request->input('id');} + $where['user_id'] = Token::$uid; + + if($type=='' || $where['id'] =='') + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + + //修改订单状态,1设为支付,2设为取消,3设为确认收货,4设为退款退货,5设为删除,6设为已评价 + if($type == 1) + { + //判断订单是否存在或本人 + $where['order_status'] = 0; + $where['pay_status'] = 0; + $order = Order::where($where)->first(); + if(!$order){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'订单不存在');} + + //判断用户余额是否足够 + $user_money = DB::table('user')->where(array('id'=>Token::$uid))->value('money'); + if($order['order_amount']>$user_money){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'余额不足');} + + $data['pay_status'] = 1; + $data['pay_money'] = $order['order_amount']; //支付金额 + $data['pay_id'] = $request->input('pay_id',''); + $data['pay_time'] = $request->input('pay_time',time()); + if($request->input('pay_name', '')!=''){$data['pay_name'] = $request->input('pay_name');} + + //扣除用户余额 + if($data['pay_money']<=0 || !DB::table('user')->where(array('id'=>Token::$uid))->decrement('money', $data['pay_money'])) + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + + //增加用户余额记录 + DB::table('user_money')->insert(array('user_id'=>Token::$uid,'type'=>1,'money'=>$data['pay_money'],'des'=>'订单余额支付','user_money'=>DB::table('user')->where(array('id'=>Token::$uid))->value('money'),'add_time'=>time())); + } + elseif($type == 2) + { + //判断订单是否存在或本人 + $where['order_status'] = 0; + $where['pay_status'] = 0; + $order = Order::where($where)->first(); + if(!$order){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'订单不存在');} + + $data['order_status'] = 1; + } + elseif($type == 3) + { + //判断订单是否存在或本人 + $where['order_status'] = 0; + $where['refund_status'] = 0; + $where['pay_status'] = 1; + $order = Order::where($where)->first(); + if(!$order){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'订单不存在');} + + $data['order_status'] = 3; + $data['shipping_status'] = 2; + $data['refund_status'] = 0; + $data['is_comment'] = 0; + } + elseif($type == 4) + { + //判断订单是否存在或本人 + $where['order_status'] = 3; + $where['refund_status'] = 0; + $where['shipping_status'] = 2; + $order = Order::where($where)->first(); + if(!$order){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'订单不存在');} + + $data['refund_status'] = 1; + } + elseif($type == 5) + { + //判断订单是否存在或本人 + $order = Order::where(array('order_status'=>3,'refund_status'=>0))->orWhere(array('order_status'=>1))->orWhere(array('order_status'=>2))->first(); + if(!$order){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'订单不存在');} + + $data['is_delete'] = 1; + } + elseif($type == 6) + { + //判断订单是否存在或本人 + $where['order_status'] = 3; + $where['refund_status'] = 0; + $order = Order::where($where)->first(); + if(!$order){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'订单不存在');} + + $data['is_comment'] = 1; + } + + //修改订单状态 + if (isset($data)) + { + Order::modify($where,$data); + } + + return ReturnData::create(ReturnData::SUCCESS); + } + //删除订单 public function orderDelete(Request $request) { diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index b9b89a4..23b8c65 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -34,12 +34,13 @@ class UserController extends CommonController if($request->input('user_name', null)!==null) { $data['user_name'] = $request->input('user_name'); - + if(User::getOneUser($data)) { return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户名已存在'); } } + if($request->input('email', null)!==null){$data['email'] = $request->input('email');} if($request->input('sex', null)!==null){$data['sex'] = $request->input('sex');} if($request->input('birthday', null)!==null){$data['birthday'] = $request->input('birthday');} @@ -63,7 +64,26 @@ class UserController extends CommonController return ReturnData::create(ReturnData::SUCCESS); } - + + //修改用户余额 + public function userMoneyUpdate(Request $request) + { + $data['money'] = $request->input('money',''); + + if($data['money'] == '' || $data['money'] <= 0) + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + + $user = User::getOneUser(array('id'=>Token::$uid)); + $data['money'] = $user['money'] - $data['money']; + + if(User::modify(array('id'=>Token::$uid),$data)) + { + return ReturnData::create(ReturnData::SUCCESS); + } + } + //修改用户密码、支付密码 public function userPasswordUpdate(Request $request) { diff --git a/app/Http/Controllers/Api/UserWithdrawController.php b/app/Http/Controllers/Api/UserWithdrawController.php index ba35b30..480b36a 100644 --- a/app/Http/Controllers/Api/UserWithdrawController.php +++ b/app/Http/Controllers/Api/UserWithdrawController.php @@ -40,14 +40,16 @@ class UserWithdrawController extends CommonController $data['method'] = $request->input('method',''); $data['money'] = $request->input('money',''); $data['account'] = $request->input('account',''); + $data['name'] = $request->input('name',''); if($request->input('note', '') != ''){$data['note'] = $request->input('note');} if($request->input('status', '') != ''){$data['status'] = $request->input('status');} if($request->input('bank_name', '') != ''){$data['bank_name'] = $request->input('bank_name');} if($request->input('bank_place', '') != ''){$data['bank_place'] = $request->input('bank_place');} $data['add_time'] = time(); $data['user_id'] = Token::$uid; + $data['pay_password'] = $request->input('pay_password',''); - if($data['method']=='' || $data['money']=='' || $data['account']=='') + if($data['method']=='' || $data['money']=='' || $data['account']=='' || $data['name']=='' || $data['pay_password']=='') { return ReturnData::create(ReturnData::PARAMS_ERROR); } @@ -57,13 +59,7 @@ class UserWithdrawController extends CommonController return ReturnData::create(ReturnData::PARAMS_ERROR); } - $res = UserWithdraw::add($data); - if(!$res) - { - return ReturnData::create(ReturnData::SYSTEM_FAIL); - } - - return ReturnData::create(ReturnData::SUCCESS,$res); + return UserWithdraw::add($data); } //修改提现 diff --git a/app/Http/Controllers/Weixin/OrderController.php b/app/Http/Controllers/Weixin/OrderController.php index ba6dd80..6c2afb1 100644 --- a/app/Http/Controllers/Weixin/OrderController.php +++ b/app/Http/Controllers/Weixin/OrderController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Weixin; use App\Http\Controllers\Weixin\CommonController; use Illuminate\Http\Request; use App\Common\ReturnData; +use App\Common\Helper; class OrderController extends CommonController { @@ -20,7 +21,7 @@ class OrderController extends CommonController if(isset($_REQUEST['page'])){$offset = ($_REQUEST['page']-1)*$pagesize;} - $status = $request->input('status',''); + $status = $request->input('status',-1); $postdata = array( 'limit' => $pagesize, @@ -72,7 +73,63 @@ class OrderController extends CommonController return view('weixin.order.orderDetail', $data); } - + + //订单评价 + public function orderComment(Request $request) + { + if(Helper::isPostRequest()) + { + if($_POST['comment']) + { + foreach($_POST['comment'] as $k=>$v) + { + $_POST['comment'][$k]['comment_type'] = 0; + $_POST['comment'][$k]['comment_rank'] = 5; + } + } + else + { + $this->error_jump('评论失败'); + } + + $postdata = array( + 'order_id' => $_POST['order_id'], + 'comment' => json_encode($_POST['comment']), + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/comment_batch_add"; + $res = curl_request($url,$postdata,'POST'); + if($res['code']!=0){$this->error_jump('评论失败');} + + //订单状态设为已评价 + $postdata = array( + 'id' => $_POST['order_id'], + 'type' => 6, + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/order_status_update"; + $res = curl_request($url,$postdata,'POST'); + + $this->success_jump('评论成功',route('weixin_order_list')); + } + + $id = $request->input('id',''); + if($id==''){$this->error_jump('您访问的页面不存在或已被删除!');} + + $postdata = array( + 'order_id' => $id, + 'order_status' => 3, + 'refund_status' => 0, + '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.orderComment', $data); + } + //订单支付 public function pay($id) { @@ -138,6 +195,49 @@ class OrderController extends CommonController } } + //订单余额支付 + public function orderYuepay(Request $request) + { + $order_id = $request->input('order_id',''); + + //获取订单详情 + $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"; + $res = curl_request($url,$postdata,'GET'); + $order_detail = $res['data']; + if($res['code']!=0){$this->error_jump('订单不存在或已过期');} + + //获取会员信息 + $postdata = array( + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/user_info"; + $res = curl_request($url,$postdata,'GET'); + $user_info = $res['data']; + + if($order_detail['order_amount']>$user_info['money']){$this->error_jump('余额不足');} + + //修改订单状态 + $postdata = array( + 'id' => $order_detail['id'], + 'type' => 1, + 'pay_id' => 1, + 'pay_name' => '余额支付', + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/order_status_update"; + $res = curl_request($url,$postdata,'POST'); + if($res['code']!=0){$this->error_jump('支付失败');} + + $this->success_jump('支付成功',route('weixin_order_list')); + } + + //订单余额支付 public function orderWxpay(Request $request) { $order_id = $request->input('order_id',''); @@ -153,7 +253,6 @@ class OrderController extends CommonController $res = curl_request($url,$postdata,'GET'); $data['order_detail'] = $res['data']; $data['order_id'] = $order_id; - if($res['code']!=0){$this->error_jump('订单不存在或已过期');} //微信支付-start diff --git a/app/Http/Controllers/Weixin/UserController.php b/app/Http/Controllers/Weixin/UserController.php index 5455cf7..a449917 100644 --- a/app/Http/Controllers/Weixin/UserController.php +++ b/app/Http/Controllers/Weixin/UserController.php @@ -109,6 +109,64 @@ class UserController extends CommonController return view('weixin.user.userAccount', $data); } + //提现 + public function userWithdraw(Request $request) + { + $postdata = array( + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/user_info"; + $res = curl_request($url,$postdata,'GET'); + $data['user_info'] = $res['data']; + $data['is_withdraw'] = 0; //是否达到可提现要求,0否 + $data['min_withdraw_money'] = sysconfig('CMS_MIN_WITHDRAWAL_MONEY'); //最低可提现金额 + + if($data['user_info']['money']>=$data['min_withdraw_money']){$data['is_withdraw'] = 1;} + + return view('weixin.user.userWithdraw', $data); + } + + //提现明细 + public function userWithdrawList(Request $request) + { + $pagesize = 10; + $offset = 0; + if(isset($_REQUEST['page'])){$offset = ($_REQUEST['page']-1)*$pagesize;} + + $postdata = array( + 'limit' => $pagesize, + 'offset' => $offset, + 'access_token' => $_SESSION['weixin_user_info']['access_token'] + ); + $url = env('APP_API_URL')."/user_withdraw_list"; + $res = curl_request($url,$postdata,'GET'); + $data['list'] = $res['data']['list']; + + $data['totalpage'] = ceil($res['data']['count']/$pagesize); + + if(isset($_REQUEST['page_ajax']) && $_REQUEST['page_ajax']==1) + { + $html = ''; + + if($res['data']['list']) + { + foreach($res['data']['list'] as $k => $v) + { + $html .= '
  • '; + $html .= '- '.$v['money'].''; + $html .= '

    提现

    '; + $html .= '

    收款账号:'.$v['name'].' ,提现方式:'.$v['method'].' ,姓名:'.$v['name'].'
    状态:'.$v['status_text'].'

    '; + $html .= '

    '.date('Y-m-d H:i:s',$v['add_time']).'

    '; + $html .= '
  • '; + } + } + + exit(json_encode($html)); + } + + return view('weixin.user.userWithdrawList', $data); + } + //用户充值 public function userRecharge(Request $request) { @@ -169,15 +227,15 @@ class UserController extends CommonController ); $url = env('APP_API_URL')."/user_recharge_detail"; $res = curl_request($url,$postdata,'GET'); - $data['post'] = $res['data']; + $user_recharge = $data['post'] = $res['data']; //微信支付-start require_once(resource_path('org/wxpay/WxPayConfig.php')); // 导入微信配置类 require_once(resource_path('org/wxpay/WxPayPubHelper.class.php')); // 导入微信支付类 $body = '充值';//订单详情 - $out_trade_no = '20177878738';//订单号 - $total_fee = floatval(0.01*100);//价格0.01 + $out_trade_no = $user_recharge['recharge_sn'];//订单号 + $total_fee = floatval($user_recharge['money']*100);//价格0.01 $attach = 'pay_type=1'; //pay_type=1充值支付 $notify_url = route('weixin_wxpay_notify');//通知地址 $wxconfig= \WxPayConfig::wxconfig(); diff --git a/app/Http/Controllers/Weixin/WxPayController.php b/app/Http/Controllers/Weixin/WxPayController.php index e23d591..83a3211 100644 --- a/app/Http/Controllers/Weixin/WxPayController.php +++ b/app/Http/Controllers/Weixin/WxPayController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Weixin; use App\Http\Controllers\Weixin\CommonController; use Illuminate\Http\Request; +use DB; class WxPayController extends CommonController { @@ -30,10 +31,52 @@ class WxPayController extends CommonController if($post_data['result_code'] == 'SUCCESS') { + $pay_money = $post_data['total_fee']/100; + $pay_time_timestamp = strtotime(date_format(date_create($post_data['time_end']),"Y-m-d H:i:s")); //$post_data['out_trade_no'] //$post_data['transaction_id'] - //$post_data['total_fee'] - file_put_contents("2.txt",$post_data['total_fee'].'--'.$post_data['out_trade_no'].'--'.$post_data['attach']); + + //附加参数pay_type:1充值支付,2订单支付 + if($post_data['pay_type'] == 1) + { + //获取充值支付记录 + $user_recharge = DB::table('user_recharge')->where(array('recharge_sn'=>$post_data['out_trade_no'],'status'=>0))->first(); + if(!$user_recharge){exit;} + if($pay_money < $user_recharge->money){exit;} //如果支付金额小于要充值的金额 + + //更新充值支付记录状态 + DB::table('user_recharge')->where(array('recharge_sn'=>$post_data['out_trade_no'],'status'=>0))->update(array('pay_time'=>$pay_time_timestamp,'pay_type'=>1,'status'=>1,'trade_no'=>$post_data['transaction_id'],'pay_money'=>$pay_money)); + //增加用户余额 + DB::table('user')->where(array('id'=>$user_recharge->user_id))->decrement('money', $pay_money); + //添加用户余额记录 + DB::table('user_money')->insert(array('user_id'=>$user_recharge->user_id,'type'=>0,'money'=>$pay_money,'des'=>'充值','user_money'=>DB::table('user')->where(array('id'=>$user_recharge->user_id))->value('money'),'add_time'=>time())); + } + if($post_data['pay_type'] == 2) + { + //获取订单记录 + $order = DB::table('order')->where(array('order_sn'=>$post_data['out_trade_no'],'order_status'=>0,'pay_status'=>0))->first(); + if(!$order){exit;} + if($pay_money < $order->order_amount){exit;} //如果支付金额小于订单金额 + + //修改订单状态 + $order_update_data['pay_status'] = 1; + $order_update_data['pay_money'] = $pay_money; //支付金额 + $order_update_data['pay_id'] = 2; + $order_update_data['pay_time'] = $pay_time_timestamp; + $order_update_data['pay_name'] = '微信'; + $order_update_data['out_trade_no'] = $post_data['transaction_id']; + DB::table('order')->where(array('order_sn'=>$post_data['out_trade_no'],'order_status'=>0,'pay_status'=>0))->update($order_update_data); + } + if($post_data['pay_type'] == 3) + { + + } + if($post_data['pay_type'] == 4) + { + + } + + file_put_contents("2.txt",$post_data['total_fee'].'--'.$post_data['out_trade_no'].'--'.$post_data['attach'].'--'.$post_data['pay_type']); echo "SUCCESS"; } else diff --git a/app/Http/Model/Comment.php b/app/Http/Model/Comment.php index d22cf95..7a75d21 100644 --- a/app/Http/Model/Comment.php +++ b/app/Http/Model/Comment.php @@ -2,6 +2,7 @@ namespace App\Http\Model; use App\Common\Token; +use App\Common\ReturnData; class Comment extends BaseModel { @@ -28,15 +29,17 @@ class Comment extends BaseModel extract($param); //参数:limit,offset $where['user_id'] = $user_id; - $where['comment_type'] = $comment_type; //0商品评价,1文章评价 $where['status'] = self::SHOW_COMMENT; $limit = isset($limit) ? $limit : 10; $offset = isset($offset) ? $offset : 0; - $model = new Comment; + $model = new self; if(isset($comment_rank)){$where['comment_rank'] = $comment_rank;} //评价分 + if(isset($id_value)){$where['id_value'] = $id_value;} //商品的id + if(isset($comment_type)){$where['comment_type'] = $comment_type;} //0商品评价,1文章评价 + if(isset($parent_id)){$where['parent_id'] = $parent_id;} $model = $model->where($where); @@ -45,31 +48,63 @@ class Comment extends BaseModel if($res['count']>0) { - $res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray(); - } - else - { - return '暂无记录'; + $res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get(); } return $res; } - public static function getOne($id) + public static function getOne($where) { - return self::where('id', $id)->first()->toArray(); + return self::where($where)->first(); } public static function add(array $data) { - if(self::where(array('user_id'=>$data['user_id'],'id_value'=>$data['id_value'],'comment_type'=>$data['comment_type']))->first()){return '亲,您已经评价啦!';} + if(!isset($data['comment_type']) || !isset($data['id_value']) || !isset($data['user_id']) || $data['comment_type']===null || $data['id_value']===null || $data['user_id']===null) + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + + if(!isset($data['content']) && !isset($data['comment_rank'])) + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + else + { + if($data['content']===null && $data['comment_rank']===null) + { + return ReturnData::create(ReturnData::PARAMS_ERROR); + } + } + + if(self::where(array('user_id'=>$data['user_id'],'id_value'=>$data['id_value'],'comment_type'=>$data['comment_type']))->first()){return ReturnData::create(ReturnData::SYSTEM_FAIL,null,'亲,您已经评价啦!');} if ($id = self::insertGetId($data)) { - return true; + return ReturnData::create(ReturnData::SUCCESS,$id); } - - return false; + + return ReturnData::create(ReturnData::SYSTEM_FAIL); + } + + //批量添加 + public static function batchAdd(array $data) + { + $res = ''; + + if($data) + { + foreach($data as $k=>$v) + { + $id = self::add($v); + if($id['code']==0){$res[] = $id['data'];}else{return $id;} + } + + return ReturnData::create(ReturnData::SUCCESS,$res); + } + + return ReturnData::create(ReturnData::SYSTEM_FAIL); } public static function modify($where, array $data) @@ -87,7 +122,7 @@ class Comment extends BaseModel { if(!self::where(array('user_id'=>$data['user_id'],'comment_type'=>$data['comment_type'],'id_value'=>$data['id_value']))->first()){return '商品尚未评价';} - if (!self::where(array('user_id'=>$data['user_id'],'comment_type'=>$data['comment_type'],'id_value'=>$data['id_value']))->delete()) + if (self::where(array('user_id'=>$data['user_id'],'comment_type'=>$data['comment_type'],'id_value'=>$data['id_value']))->delete() === false) { return false; } diff --git a/app/Http/Model/Order.php b/app/Http/Model/Order.php index 17cc8e9..b0c633c 100644 --- a/app/Http/Model/Order.php +++ b/app/Http/Model/Order.php @@ -73,8 +73,8 @@ class Order extends BaseModel foreach($order_list as $k=>$v) { $order_status_arr = self::getOrderStatusText($v); - $order_list[$k]['order_status_text'] = $order_status_arr['text']; - $order_list[$k]['order_status_num'] = $order_status_arr['num']; + $order_list[$k]['order_status_text'] = $order_status_arr?$order_status_arr['text']:''; + $order_list[$k]['order_status_num'] = $order_status_arr?$order_status_arr['num']:''; $order_goods = OrderGoods::where(array('order_id'=>$v['id']))->get(); $order_list[$k]['goods_list'] = $order_goods; @@ -223,12 +223,12 @@ class Order extends BaseModel public static function modify($where, array $data) { - if (self::where($where)->update($data)) + if (self::where($where)->update($data) === false) { - return true; + return false; } - return false; + return true; } //删除一条记录 @@ -243,7 +243,7 @@ class Order extends BaseModel return true; } - //获取订单状态文字,1待付款,2待发货,3待收货,4待评价(确认收货,交易成功),5退款/售后 + //获取订单状态文字:1待付款,2待发货,3待收货,4待评价(确认收货,交易成功),5退款/售后,6已取消,7无效 public static function getOrderStatusText($where) { $res = ''; @@ -259,7 +259,7 @@ class Order extends BaseModel { $res = array('text'=>'待收货','num'=>3); } - elseif($where['order_status'] == 3 && $where['refund_status'] == 0 && $where['shipping_status'] == 2 && $where['is_comment'] == 0) + elseif($where['order_status'] == 3 && $where['refund_status'] == 0) { $res = array('text'=>'交易成功','num'=>4); } @@ -267,6 +267,14 @@ class Order extends BaseModel { $res = array('text'=>'售后','num'=>5); } + elseif($where['order_status'] == 1) + { + $res = array('text'=>'已取消','num'=>6); + } + elseif($where['order_status'] == 2) + { + $res = array('text'=>'无效','num'=>7); + } return $res; } diff --git a/app/Http/Model/UserRecharge.php b/app/Http/Model/UserRecharge.php index 8d5af6e..9815449 100644 --- a/app/Http/Model/UserRecharge.php +++ b/app/Http/Model/UserRecharge.php @@ -52,6 +52,8 @@ class UserRecharge extends BaseModel public static function add(array $data) { + $data['recharge_sn'] = date('YmdHis'.rand(1000,9999)); + if ($id = self::insertGetId($data)) { return $id; diff --git a/app/Http/Model/UserWithdraw.php b/app/Http/Model/UserWithdraw.php index 8b728c6..3e068e0 100644 --- a/app/Http/Model/UserWithdraw.php +++ b/app/Http/Model/UserWithdraw.php @@ -3,6 +3,7 @@ namespace App\Http\Model; use App\Common\Token; use DB; +use App\Common\ReturnData; class UserWithdraw extends BaseModel { @@ -41,6 +42,11 @@ class UserWithdraw extends BaseModel if($res['count']>0) { $res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get(); + + foreach($res['list'] as $k=>$v) + { + $res['list'][$k]['status_text'] = self::getStatusText($v); + } } else { @@ -62,12 +68,26 @@ class UserWithdraw extends BaseModel public static function add(array $data) { + $user = User::where(array('id'=>$data['user_id'],'pay_password'=>$data['pay_password']))->first(); + if(!$user){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'支付密码错误');} + unset($data['pay_password']); + + $min_withdraw_money = sysconfig('CMS_MIN_WITHDRAWAL_MONEY'); //最低可提现金额 + if($user['money']<$data['money']){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'余额不足');} + if($user['money']<$min_withdraw_money){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户金额小于最小提现金额');} + if($data['money']<$min_withdraw_money){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'提现金额不得小于最小提现金额');} + if ($id = self::insertGetId($data)) { - return $id; + //扣除用户余额 + DB::table('user')->where(array('id'=>$data['user_id']))->decrement('money', $data['money']); + //增加用户余额记录 + DB::table('user_money')->insert(array('user_id'=>$data['user_id'],'type'=>1,'money'=>$data['money'],'des'=>'提现','user_money'=>DB::table('user')->where(array('id'=>$data['user_id']))->value('money'),'add_time'=>time())); + + return ReturnData::create(ReturnData::SUCCESS,$id); } - return false; + return ReturnData::create(ReturnData::SYSTEM_FAIL); } public static function modify($where, array $data) @@ -90,4 +110,32 @@ class UserWithdraw extends BaseModel return true; } + + //获取提现状态文字:0未处理,1处理中,2成功,3取消,4拒绝 + public static function getStatusText($where) + { + $res = ''; + if($where['status'] == 0) + { + $res = '未处理'; + } + elseif($where['status'] == 1) + { + $res = '处理中'; + } + elseif($where['status'] == 2) + { + $res = '成功'; + } + elseif($where['status'] == 3) + { + $res = '取消'; + } + elseif($where['status'] == 4) + { + $res = '拒绝'; + } + + return $res; + } } \ No newline at end of file diff --git a/resources/views/weixin/order/orderComment.blade.php b/resources/views/weixin/order/orderComment.blade.php new file mode 100644 index 0000000..a680118 --- /dev/null +++ b/resources/views/weixin/order/orderComment.blade.php @@ -0,0 +1,42 @@ + +发表评价 + + + +
    +
    返回
    +
    发表评价
    + +
    + +
    + + +
    +$v){ ?> +
    + +
    +
    匿名 你写的评价会以匿名的形式展现
    + + +
    + +
    暂无记录
    + +
    + + + + + \ No newline at end of file diff --git a/resources/views/weixin/order/orderDetail.blade.php b/resources/views/weixin/order/orderDetail.blade.php index 18f526c..bdc32dc 100644 --- a/resources/views/weixin/order/orderDetail.blade.php +++ b/resources/views/weixin/order/orderDetail.blade.php @@ -13,7 +13,7 @@ @include('weixin.common.headerNav')
    -

    +

    订单状态:

    + + @include('weixin.common.footer') \ No newline at end of file diff --git a/resources/views/weixin/order/orderList.blade.php b/resources/views/weixin/order/orderList.blade.php index fd78867..ebcc053 100644 --- a/resources/views/weixin/order/orderList.blade.php +++ b/resources/views/weixin/order/orderList.blade.php @@ -51,7 +51,7 @@ var swiper = new Swiper('.swiper-nav', {

    合计: ¥ (含运费:¥)

    -
    我要付款评价
    +
    删除取消订单付款查看物流确认收货评价
    暂无记录
    @@ -72,4 +72,102 @@ var swiper = new Swiper('.swiper-nav', { .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;} + + + \ No newline at end of file diff --git a/resources/views/weixin/user/index.blade.php b/resources/views/weixin/user/index.blade.php index 72bdfc0..3302cf1 100644 --- a/resources/views/weixin/user/index.blade.php +++ b/resources/views/weixin/user/index.blade.php @@ -64,28 +64,28 @@