From 67053621c1619efa39577e2e46a6b3cc699d2bba Mon Sep 17 00:00:00 2001
From: lihan <3398341942@qq.com>
Date: Fri, 19 Oct 2018 18:24:44 +0800
Subject: [PATCH] 确认收货

---
 app/pay/controller/PayController.php | 42 +++++++++++++++++++++++++++++++-----------
 1 file changed, 31 insertions(+), 11 deletions(-)

diff --git a/app/pay/controller/PayController.php b/app/pay/controller/PayController.php
index b7ac237..50751da 100644
--- a/app/pay/controller/PayController.php
+++ b/app/pay/controller/PayController.php
@@ -79,36 +79,56 @@ class PayController extends HomeBaseController
                             'total_fee' => $order['whole']
                         ];
                         $this->wxPay($info);
-                    }
-
-                    //积分支付
+                    } //积分支付
                     elseif ($order['pay_type'] == 3) {
                         //先判断剩余积分是否足够支付
-                        $balance = Db::name('user')->where(['id'=>session('user.id')])->value('balance');
-                        if($balance < $whole) {
+                        $balance = Db::name('user')->where(['id' => session('user.id')])->value('balance');
+                        if ($balance < $whole) {
                             $this->success('您的积分不足', '', false);
-                        }else {
+                        } else {
                             //先减积分
-                            $balance-=$whole;
-                            if(Db::name('user')->update(['id'=>session('user.id'),'balance'=>$balance])) {
+                            $balance -= $whole;
+                            if (Db::name('user')->update(['id' => session('user.id'), 'balance' => $balance])) {
                                 //支付后改变订单状态
                                 $update = [
                                     'id' => $oid,
                                     'step' => 2,
                                 ];
-                                if(Db::name('zj_order')->update($update)) {
+                                if (Db::name('zj_order')->update($update)) {
                                     Db::commit();
                                     session('goods.id', null);
                                     Db::name('zj_cart')->where(['id' => ['in', session('cart.id')]])->delete();
                                     session('cart.id', null);
                                     $this->success('积分支付成功', url('user/center/orderList'), true);
-                                }else {
+                                } else {
                                     Db::rollback();
                                 }
-                            }else {
+                            } else {
                                 Db::rollback();
                             }
                         }
+                    } //组合支付
+                    elseif ($order['pay_type'] == 2) {
+                        $pay_cash = $request->param('pay_cash');    //支付的金额
+                        $pay_num = $request->param('pay_num');      //支付的积分
+                        $balance = Db::name('user')->where(['id' => session('user.id')])->value('balance');
+                        if ($balance < $pay_num) {
+                            $this->success('您的积分不足', '', false);
+                        } else {
+                            //先减余额
+                            $balance -= $pay_num;
+                            Db::name('user')->update(['id' => session('user.id'), 'balance' => $balance]);
+                            $info = [
+                                'attach' => $oid,
+                                'openid' => session('user.openid'),
+                                'body' => '微信支付-天生红商城',
+                                'total_fee' => $pay_cash
+                            ];
+                            $this->wxPay($info);
+                        }
+
+                    } else {
+                        $this->success('请选择支付方式', '', false);
                     }
 
                 } else {
--
libgit2 0.24.0