瀏覽代碼

Merge branch 'master' of http://git.9026.com/roobe/miao

YanaDH 7 年之前
父節點
當前提交
46de55ac91

二進制
.vs/miaomiao/v14/.suo


+ 1 - 2
miaomiao/config.xml

xqd xqd
@@ -6,7 +6,7 @@
     </description>
   <author email="you@example.com" href="http://example.com.com/">
       Mike
-    </author>
+  </author>
   <content src="index.html"/>
   <access origin="*"/>
   <allow-intent href="*"/>
@@ -99,7 +99,6 @@
   <plugin name="ionic-plugin-keyboard" spec="~1.0.9"/>
   <plugin name="jpush-phonegap-plugin" spec="^3.2.3">
     <variable name="APP_KEY" value="041b70b4c7eee686870a32cd"/>
-    <variable name="API_KEY" value="041b70b4c7eee686870a32cd"/>
   </plugin>
   <plugin name="phonegap-plugin-barcodescanner" spec="https://github.com/phonegap/phonegap-plugin-barcodescanner.git">
     <variable name="CAMERA_USAGE_DESCRIPTION" value="请摄像头对准条码"/>

+ 1 - 1
miaomiao/cordova-hcp.json

xqd
@@ -1,4 +1,4 @@
 {
   "update": "now",
-  "content_url": "http://i.9026.com/miaomiao/www"
+  "content_url": "http://i.9026.com/miaomiao"
 }

+ 1 - 1
miaomiao/package.json

xqd
@@ -90,4 +90,4 @@
       }
     }
   }
-}
+}

+ 4 - 8
miaomiao/plugins/android.json

xqd
@@ -37,18 +37,14 @@
         "cordova-plugin-media-capture": {
             "PACKAGE_NAME": "com.miaomiao.app"
         },
-        "cordova-plugin-splashscreen": {
-            "PACKAGE_NAME": "com.miaomiao.app"
-        },
-        "cordova-plugin-statusbar": {
-            "PACKAGE_NAME": "com.miaomiao.app"
-        },
         "cordova-plugin-offbye-alipay": {
             "PARTNER_ID": "2088721135315822",
             "PACKAGE_NAME": "com.miaomiao.app"
         },
-        "cordova-plugin-weibosdk": {
-            "WEIBO_APP_ID": "YOUR_WEIBO_APPID",
+        "cordova-plugin-splashscreen": {
+            "PACKAGE_NAME": "com.miaomiao.app"
+        },
+        "cordova-plugin-statusbar": {
             "PACKAGE_NAME": "com.miaomiao.app"
         }
     },

+ 2 - 0
miaomiao/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/device/.npmignore

xqd
@@ -0,0 +1,2 @@
+/src
+/public

+ 2 - 0
miaomiao/plugins/phonegap-plugin-barcodescanner/src/blackberry10/native/simulator/.npmignore

xqd
@@ -0,0 +1,2 @@
+/public
+/src

+ 2 - 2
miaomiao/www/chcp.json

xqd
@@ -1,5 +1,5 @@
 {
   "update": "now",
-  "content_url": "http://i.9026.com/miaomiao/www",
-  "release": "2017.08.23-09.55.35"
+  "content_url": "http://i.9026.com/miaomiao",
+  "release": "2017.08.23-18.23.45"
 }

+ 13 - 9
miaomiao/www/chcp.manifest

xqd xqd xqd xqd xqd xqd
@@ -13,7 +13,7 @@
   },
   {
     "file": ".idea/workspace.xml",
-    "hash": "4171b3999655f1262098329ca055a80f"
+    "hash": "0ca83fcf6e1f13fc63df3fbf698ca565"
   },
   {
     "file": ".idea/www.iml",
@@ -29,7 +29,7 @@
   },
   {
     "file": "css/style.css",
-    "hash": "2ece1df08e758cb5a6fd1448a611f927"
+    "hash": "a756d7e02ed8e14f4b56de9ea23412ce"
   },
   {
     "file": "img/alipay.png",
@@ -369,11 +369,11 @@
   },
   {
     "file": "js/config/router.js",
-    "hash": "3e72be424ee66203c122c2fefe33a151"
+    "hash": "e5fae9284235efb500d94ace6ec81f86"
   },
   {
     "file": "js/controllers/account.js",
-    "hash": "4991794aac4d09176ea22253e945b93c"
+    "hash": "fe3ef2c90e4b2caa1208b2c672dc54b9"
   },
   {
     "file": "js/controllers/add.js",
@@ -381,11 +381,11 @@
   },
   {
     "file": "js/controllers/home.js",
-    "hash": "2ed102ad7af44e4947f9dca76153aa24"
+    "hash": "3f2f9d1aec9286050dbb523a76e40eb0"
   },
   {
     "file": "js/controllers/my.js",
-    "hash": "ff5d39a366893ac3a0eed80e03f970cd"
+    "hash": "aa1f6f5f801802075c3af039588eac13"
   },
   {
     "file": "js/controllers/tabs.js",
@@ -713,7 +713,11 @@
   },
   {
     "file": "templates/account/login.html",
-    "hash": "61b13bece0aae2d92f55f8f21c13081b"
+    "hash": "d7ec097c6b4560a23ce5c5b19d953406"
+  },
+  {
+    "file": "templates/account/loginAccount.html",
+    "hash": "77c0e041f70b3c9bb3954f5973bcf991"
   },
   {
     "file": "templates/add/addExplain.html",
@@ -725,11 +729,11 @@
   },
   {
     "file": "templates/home/dream-detail.html",
-    "hash": "7d9debbf1ade697a2f74fdb7e9f9b4ed"
+    "hash": "d620451043f133f2bb98b3ed84f637a1"
   },
   {
     "file": "templates/home/index.html",
-    "hash": "457c77c56b4de63bb16662bb2cc7de6d"
+    "hash": "935146196b3ff3dceb761e5db0618d33"
   },
   {
     "file": "templates/home/oldDream.html",

+ 117 - 3
server/app/Http/Controllers/Api/V1/AuthController.php

xqd xqd xqd xqd
@@ -66,7 +66,7 @@ class AuthController extends Controller
      *    1610    SERVICE_CODE_FAILED          验证码错误
      *
      */
-    public function login(Request $request) {
+    public function login(Request $request,$openid_webo=null,$type=null) {
         $validator = Validator::make($request->all(),
             [
                 'phone'         => 'required|regex:/^1[34578]\d{9}$/',
@@ -86,8 +86,7 @@ class AuthController extends Controller
         $key = $this->keySmsCode . $phone;
         $code = Cache::store('file')->get($key);
         $password = 123456;
-        if ($request->verify_code != $code)
-            return $this->error(ErrorCode::SERVICE_CODE_FAILED);
+        if ($request->verify_code != $code) return $this->error(ErrorCode::SERVICE_CODE_FAILED);
         $user = UserInfoModel::where('phone',$phone)->first();
         if (empty($user)) {
             $user = UserInfoModel::create(['phone'=>$phone,'password'=>bcrypt(123456)]);
@@ -97,6 +96,15 @@ class AuthController extends Controller
         if ($status == 0) return $this->error(ErrorCode::LOCK_USER);
         if (Auth::attempt(['phone'=>$phone,'password'=>$password])) {
             $user = Auth::user();
+            if (!empty($openid_webo)) {
+                if ($type == 'wechat') {
+                    $user->wechat =$openid_webo;
+                }
+                if ($type == 'webo') {
+                    $user->webo =$openid_webo;
+                }
+                $user->save();
+            }
             \Log::info($user);
             $token = $user->createToken($user->phone)->accessToken;
             return $this->api(compact( 'user', 'code','token'));
@@ -105,6 +113,112 @@ class AuthController extends Controller
         }
     }
 
+
+//    第三方登录  微信、微博
+    /**
+     * @api {post} /api/auth/wechat_login 微信登陆(login)
+     * @apiDescription 微信登陆(login)
+     * @apiGroup Auth
+     * @apiPermission none
+     * @apiVersion 0.1.0
+     * @apiParam {string}  wechat   微信id
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     *     "state": true,
+     *     "code": 0,
+     *     "message": "",
+     *     "data": {
+     *         "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjdjYWUyYzFmYTUwMTIyZDI0ZTRiYTZhZGZhNmQxYmZlOWNiMzIxMTBmYWJlZjNjYzIyNmViZjRmNGExNWM3NjllNmU2ZTNiYWE5OGNhOWUzIn0.eyJhdWQiOiIxIiwianRpIjoiN2NhZTJjMWZhNTAxMjJkMjRlNGJhNmFkZmE2ZDFiZmU5Y2IzMjExMGZhYmVmM2NjMjI2ZWJmNGY0YTE1Yzc2OWU2ZTZlM2JhYTk4Y2E5ZTMiLCJpYXQiOjE0NzU0MTE1NTgsIm5iZiI6MTQ3NTQxMTU1OCwiZXhwIjo0NjMxMDg1MTU4LCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.E9YGEzuRUOk02aV1EiWLJ_pD0hKoCyW0k_sGy63hM3u5X8K_HI1kVhaU6JNLqLZeszIAroTEDB8XMgZKAqTLlwtL8PLCJcuDoxfk1BRHbfjhDheTsahBysKGalvNEpzRCrGlao0mS0Cg9qDpEsndtypPFS8sfaflToOzbJjiSK2DvQiHSH8xZI3zHJTezgZMz-pB_hPTxp8ajdv0ve1gWtWjs3vERr0Y91X4hngO8X7LuXtAYtfxGZRIye12YE7TuLBMYzj8CCfiRt7Smhyf4palNW5mzKlZpa2l87n6NQ14Iy4oMzQ2PON1j_swrosuE2yZohGOn6fDdSCBRdJ6dLD_emjBdQCQOoB63R7BbhFZgvFX25TjzFJ7r9AdVMiGmebuRKEVSZV_JCGu1C71OIbQk-UK35s00gSr2fmJGBbN2cZTXBRTJpfuMZ_ihFYEZrvVq_Ih2X0xkd36JUuxaUld1BXRgPZvH-9jBuhe0YW2OOlgwpdm6ZB8BMcuS4ftLoi6FipgzFqfIuy-0ZqPMDnJaG7Gycrdpxza00mgOFxYxJtqwZNsUWFRZEVU881l6VC_cy294YXSPQxUwEoyKg-G5Pm8AEB9bqv5z4EU4B8-XTd3zKNqtNba_snHbc711i4EytCiZfYSjNB1hwenq45YYOAhPTwOpFI0kxyRazc",
+     *         "user": {
+     *             "id": 1,
+     *             "name": "15888888888",
+     *             "email": "abcdefg@gmail.com",
+     *             "type": 2,
+     *             "phone": "15888888888",
+     *             "avatar": null,
+     *             "last_ip": null,
+     *             "created_at": "2016-09-30 00:45:13",
+     *             "updated_at": "2016-09-29 16:43:36"
+     *         }
+     *     }
+     * }
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     */
+    public function wechatLogin(Request $request) {
+        $validator = Validator::make($request->all(),
+            [
+                'wechat'      => 'required',
+            ],
+            [
+                'wechat.required'      => '微信id不存在',
+            ]
+        );
+
+        if ($validator->fails())
+            return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
+        $user = UserInfoModel::where('wechat',$request->wechat)->first();
+        if (empty($user)) {
+           $this->login($request,$request->wechat,'wechat');
+        }else{
+            $token = $user->createToken($user->phone)->accessToken;
+            return $this->api(compact( 'user', 'code','token'));
+        }
+    }
+
+    /**
+     * @api {post} /api/auth/webo_login 微博登录
+     * @apiDescription 微博登录
+     * @apiGroup Auth
+     * @apiPermission none
+     * @apiVersion 0.1.0
+     * @apiParam {string}  webo   微博id
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     *     "state": true,
+     *     "code": 0,
+     *     "message": "",
+     *     "data": {
+     *         "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjdjYWUyYzFmYTUwMTIyZDI0ZTRiYTZhZGZhNmQxYmZlOWNiMzIxMTBmYWJlZjNjYzIyNmViZjRmNGExNWM3NjllNmU2ZTNiYWE5OGNhOWUzIn0.eyJhdWQiOiIxIiwianRpIjoiN2NhZTJjMWZhNTAxMjJkMjRlNGJhNmFkZmE2ZDFiZmU5Y2IzMjExMGZhYmVmM2NjMjI2ZWJmNGY0YTE1Yzc2OWU2ZTZlM2JhYTk4Y2E5ZTMiLCJpYXQiOjE0NzU0MTE1NTgsIm5iZiI6MTQ3NTQxMTU1OCwiZXhwIjo0NjMxMDg1MTU4LCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.E9YGEzuRUOk02aV1EiWLJ_pD0hKoCyW0k_sGy63hM3u5X8K_HI1kVhaU6JNLqLZeszIAroTEDB8XMgZKAqTLlwtL8PLCJcuDoxfk1BRHbfjhDheTsahBysKGalvNEpzRCrGlao0mS0Cg9qDpEsndtypPFS8sfaflToOzbJjiSK2DvQiHSH8xZI3zHJTezgZMz-pB_hPTxp8ajdv0ve1gWtWjs3vERr0Y91X4hngO8X7LuXtAYtfxGZRIye12YE7TuLBMYzj8CCfiRt7Smhyf4palNW5mzKlZpa2l87n6NQ14Iy4oMzQ2PON1j_swrosuE2yZohGOn6fDdSCBRdJ6dLD_emjBdQCQOoB63R7BbhFZgvFX25TjzFJ7r9AdVMiGmebuRKEVSZV_JCGu1C71OIbQk-UK35s00gSr2fmJGBbN2cZTXBRTJpfuMZ_ihFYEZrvVq_Ih2X0xkd36JUuxaUld1BXRgPZvH-9jBuhe0YW2OOlgwpdm6ZB8BMcuS4ftLoi6FipgzFqfIuy-0ZqPMDnJaG7Gycrdpxza00mgOFxYxJtqwZNsUWFRZEVU881l6VC_cy294YXSPQxUwEoyKg-G5Pm8AEB9bqv5z4EU4B8-XTd3zKNqtNba_snHbc711i4EytCiZfYSjNB1hwenq45YYOAhPTwOpFI0kxyRazc",
+     *         "user": {
+     *             "id": 1,
+     *             "name": "15888888888",
+     *             "email": "abcdefg@gmail.com",
+     *             "type": 2,
+     *             "phone": "15888888888",
+     *             "avatar": null,
+     *             "last_ip": null,
+     *             "created_at": "2016-09-30 00:45:13",
+     *             "updated_at": "2016-09-29 16:43:36"
+     *         }
+     *     }
+     * }
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     */
+    public function weboLogin(Request $request) {
+        $validator = Validator::make($request->all(),
+            [
+                'webo'      => 'required',
+            ],
+            [
+                'webo.required'      => '微博id不存在',
+            ]
+        );
+
+        if ($validator->fails())
+            return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
+        $user = UserInfoModel::where('webo',$request->webo)->first();
+        if (empty($user)) {
+            $this->login($request,$request->webo,'webo');
+        }else{
+            $token = $user->createToken($user->phone)->accessToken;
+            return $this->api(compact( 'user', 'code','token'));
+        }
+    }
+
     /**
      * @api {get} /api/auth/logout 退出(logout)
      * @apiDescription 退出(logout)

+ 0 - 1
server/app/Http/Controllers/Api/V1/IndexController.php

xqd
@@ -119,7 +119,6 @@ class IndexController extends Controller
         $id_arr2 = array_column($arr2,'id');
         $dtusers =UserCareUser::where('user_id',$id)->with('other_user')->
         where('dream_number','>',0)->orderBy('created_at')->get()->toArray();
-
         $hdusers = CommentInfoModel::where(function ($query) use ($id) {
             $query->where('user_id',$id)->orWhere('to_user_id',$id);
         })->where('is_read',0)->with('to_user')->orderBy('created_at')->get()->toArray();

+ 387 - 0
server/app/Http/Controllers/Api/V1/PayController.php

xqd
@@ -0,0 +1,387 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1;
+
+use App\Http\HelperTraits\LogHelper;
+use App\Http\HelperTraits\PayHelper;
+use App\Http\HelperTraits\JpushHelper;
+use Omnipay\Omnipay;
+use App\User;
+use App\Models\MerchantMemberService;
+use App\Models\Order;
+use App\Models\AccountLog;
+use Request, Config, DB;
+
+class PayController extends Controller
+{
+    use PayHelper, LogHelper,JpushHelper;
+
+    /**
+     * p++ webhooks通知
+     */
+//    public function pppNotify() {
+//        $sig = Request::header('x-pingplusplus-signature');
+//        $request = Request::instance();
+//        $data = $request->getContent();
+//
+//        if (!$this->checkPppSignature($data, $sig)) {//验签失败
+//            header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
+//            exit("fail");
+//        }
+//
+//        $event = json_decode($data);
+//        if (!isset($event->type)) {
+////            return Response::make('fail', 400);
+//            header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
+//            exit("fail");
+//        }
+//        switch ($event->type) {
+//            case "charge.succeeded":
+//                // 开发者在此处加入对支付异步通知的处理代码
+//                header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
+//                break;
+//            case "refund.succeeded":
+//                // 开发者在此处加入对退款异步通知的处理代码
+//                header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
+//                break;
+//            default:
+//                header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
+//                break;
+//        }
+//    }
+
+    public function alipayNotify() {
+        $rawInfo = Request::all();
+        \Log::info('aliplay callback');
+        \Log::info($rawInfo);
+
+        $config = Config::get('laravel-omnipay.gateways.alipay');
+
+        $gateway = Omnipay::create($config['driver']);
+        $gateway->setEnvironment($config['options']['environment']);
+        $gateway->setAppId($config['options']['appid']);
+        $gateway->setEncryptKey($config['options']['encrypt_key']);
+        $gateway->setPrivateKey($config['options']['prikey']);
+        $gateway->setAlipayPublicKey($config['options']['ali_pubkey']);
+        $gateway->setNotifyUrl($config['options']['notify_url']);
+
+        $request = $gateway->completePurchase();
+        $request->setParams($rawInfo);//Optional
+
+        try {
+            $response = $request->send();
+
+            if($response->isPaid()){
+                \Log::info('支付成功');
+
+                $out_trade_no = $rawInfo['out_trade_no'];
+                $order = Order::where('transaction_id', '=', $out_trade_no)->first();
+                if (!$order) {
+                    \Log::error('找不到订单' . $out_trade_no);
+                    return 'fail';
+                }
+                $master_amount =  $order->number;
+                $slave_amount = 0;
+                if (!empty($order->ext_info)) {
+                    $extInfo = json_decode($order->ext_info, true);
+                    if ($extInfo !== null) {
+                        $cc = $extInfo['cc_bonus'];
+                        $master_amount = round(($cc / 100) * $order->number);
+                        $slave_amount = $order->number - $master_amount;
+                    }
+                }
+                $tp = '';
+//                $u = null;
+                if ($order->user_type == Order::USER_TYPE_MERCHANT) {
+                    $tp = 'Merchant';
+//                    $u = Merchant::find($order->user_id);
+                } elseif ($order->user_type == Order::USER_TYPE_MEMBER) {
+                    $tp = 'Member';
+                    //Not handled here
+                }
+                $u = User::find($order->user_id);
+                if (!$u) {
+                    \Log::error('用户不存在' . $order->user_type . ', ' . $order->user_id);
+                    return 'success';
+                }
+
+                DB::beginTransaction();
+
+                if ($order->goods_type == Order::GOODS_TYPE_BALANCE||$order->goods_type == Order::GOODS_TYPE_COSUME) {
+                    $cType = AccountLog::TYPE_BALANCE;
+//                    $u->account_balance += $order->number;
+                    $u->balance += $master_amount;
+                } elseif ($order->goods_type == Order::GOODS_TYPE_CREDIT) {
+                    $cType = AccountLog::TYPE_CREDIT;
+//                    $u->credit_balance += $order->number;
+                    $u->credit += $master_amount;
+                } else {
+                    \Log::error('商品不存在' . $order->goods_type);
+                    return 'success';
+                }
+                \Log::info('支付金额 '.$master_amount);
+                if ($u->save()) {
+
+                    //更新订单状态
+                    $order->status = Order::STATUS_FINISHED;
+                    $order->save();
+
+                    //记日志
+                    $amount = $rawInfo['total_amount'] * 100;
+                    if (empty($extInfo)) {
+                        $this->logAccount($tp, $u->id, $u->name,
+                            AccountLog::OP_CHARGE, $cType, $master_amount,
+                            AccountLog::DIRECTION_INC, $cType == AccountLog::TYPE_BALANCE ? $u->balance : $u->credit, AccountLog::CHANNEL_ALIPAY);
+                    } else {
+                        //续消费
+                        $this->continue_consume($order);
+
+                        $this->logAccount($tp, $u->id, $u->name,
+                            AccountLog::OP_CC, $cType, $master_amount,
+                            AccountLog::DIRECTION_INC, $cType == AccountLog::TYPE_BALANCE ? $u->balance : $u->credit, AccountLog::CHANNEL_ALIPAY);
+                    }
+                    \Log::info('支付完成');
+
+                } else {
+                    DB::rollBack();
+                    \Log::error('保存数据失败');
+                }
+
+
+                DB::commit();
+
+                return 'success';
+            }else{
+                \Log::error('支付失败');
+
+                return 'fail';
+            }
+        } catch (\Exception $e) {
+            \Log::error('支付异常' . $e->getMessage());
+
+            return 'fail';
+        }
+
+    }
+
+    public function wechatpayNotify() {
+        \Log::debug('wechatpay callback');
+//        \Log::debug(Request::all());
+
+        $config = Config::get('laravel-omnipay.gateways.wechatpay');
+
+        $gateway = Omnipay::create("WechatPay");
+//        $gateway->setEnvironment('sandbox');
+        $gateway->setAppId($config['options']['appid']);
+        $gateway->setMchId($config['options']['merchant_id']);
+        $gateway->setApiKey($config['options']['apikey']);
+
+        $response = $gateway->completePurchase([
+            'request_params' => file_get_contents('php://input')
+        ])->send();
+        try {
+            if ($response->isPaid()) {
+                //pay success
+                $rawInfo = $response->getRequestData();
+                \Log::debug($rawInfo);
+                \Log::info('支付成功');
+
+                $out_trade_no = $rawInfo['out_trade_no'];
+                $order = Order::where('transaction_id', '=', $out_trade_no)->first();
+                if (!$order) {
+                    \Log::error('找不到订单' . $out_trade_no);
+                    return 'fail';
+                }
+                $master_amount =  $order->number;
+                $slave_amount = 0;
+                if (!empty($order->ext_info)) {
+                    $extInfo = json_decode($order->ext_info, true);
+                    if ($extInfo !== null) {
+                        $cc = $extInfo['cc_bonus'];
+                        $master_amount = round(($cc / 100) * $order->number);
+                        $slave_amount = $order->number - $master_amount;
+                    }
+                }
+                $tp = '';
+//                $u = null;
+                if ($order->user_type == Order::USER_TYPE_MERCHANT) {
+                    $tp = 'Merchant';
+//                    $u = Merchant::find($order->user_id);
+                } elseif ($order->user_type == Order::USER_TYPE_MEMBER) {
+                    $tp = 'Member';
+                    //Not handled here
+                }
+                $u = User::find($order->user_id);
+                if (!$u) {
+                    \Log::error('用户不存在' . $order->user_type . ', ' . $order->user_id);
+                    return 'success';
+                }
+
+                DB::beginTransaction();
+
+                if ($order->goods_type == Order::GOODS_TYPE_BALANCE||$order->goods_type == Order::GOODS_TYPE_COSUME) {
+                    $cType = AccountLog::TYPE_BALANCE;
+//                    $u->account_balance += $order->number;
+                    $u->balance += $master_amount;
+                } elseif ($order->goods_type == Order::GOODS_TYPE_CREDIT) {
+                    $cType = AccountLog::TYPE_CREDIT;
+//                    $u->credit_balance += $order->number;
+                    $u->credit += $master_amount;
+                } else {
+                    \Log::error('商品不存在' . $order->goods_type);
+                    return 'success';
+                }
+                //测试
+                \Log::info('支付金额 '.$master_amount);
+                if ($u->save()) {
+
+                    //更新订单状态
+                    $order->status = Order::STATUS_FINISHED;
+                    $order->save();
+
+                    //记日志
+                    $amount = $rawInfo['total_fee'] * 100;
+                    if (empty($extInfo)) {
+                        $this->logAccount($tp, $u->id, $u->name,
+                            AccountLog::OP_CHARGE, $cType, $master_amount,
+                            AccountLog::DIRECTION_INC, $cType == AccountLog::TYPE_BALANCE ? $u->balance : $u->credit, AccountLog::CHANNEL_WECHATPAY);
+                    } else {
+
+                        $this->logAccount($tp, $u->id, $u->name,
+                            AccountLog::OP_CC, $cType, $master_amount,
+                            AccountLog::DIRECTION_INC, $cType == AccountLog::TYPE_BALANCE ? $u->balance : $u->credit, AccountLog::CHANNEL_WECHATPAY);
+                    }
+
+                    \Log::info('支付完成');
+
+                } else {
+                    DB::rollBack();
+                    \Log::error('保存数据失败');
+                }
+
+                DB::commit();
+
+                return 'success';
+            }else{
+                //pay fail
+                \Log::error($response->getData());
+                return 'fail';
+            }
+
+        } catch (\Exception $e) {
+            \Log::error('支付异常' . $e->getMessage());
+
+            return 'fail';
+        }
+    }
+
+
+    function continue_consume($order){
+
+    }
+
+
+
+
+    /**
+     * @api {post} /api/pay/charge 充值
+     * @apiDescription 充值(向平台充值)
+     * @apiGroup Merchant
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiParam {int}  [goods=1]   充值商品(1:余额,2:卡金)
+     * @apiParam {int}  number      充值数量,人民币,以分表示
+     * @apiParam {int}  type        支付类型(1:支付宝,2:微信支付)
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     *     "state": true,
+     *     "code": 0,
+     *     "message": "",
+     *     "data": {
+     *         "id": 2,
+     *         "code": "ALIPAY_201610231314145719",
+     *         "transaction_id": "201610231314145719",
+     *         "user_type": 2,
+     *         "user_id": 1,
+     *         "goods_type": 1,
+     *         "price": 1,
+     *         "number": 1,
+     *         "amount": 1,
+     *         "pay_type": 1,
+     *         "status": 0,
+     *         "created_at": "2016-10-23 13:14:14",
+     *         "updated_at": "2016-10-23 13:14:14",
+     *         "orderString": "alipay_sdk=lokielse%2Fomnipay-alipay&app_id=2016091201894867&biz_content=%7B%22subject%22%3A%22%5Cu7532%5Cu8c61%5Cu8054%5Cu5408-%5Cu4f59%5Cu989d%5Cu5145%5Cu503c%22%2C%22out_trade_no%22%3A%22201610231314145719%22%2C%22total_amount%22%3A0.01%2C%22product_code%22%3A1%7D&charset=UTF-8&format=JSON&method=alipay.trade.app.pay&notify_url=http%3A%2F%2Fweb%2Fapi%2Fpay%2Falipay%2Fnotify&sign_type=RSA&timestamp=2016-10-23+13%3A14%3A14&version=1.0&sign=oxKM0qGMHLWDlMrXHIiy9%2Fk2BXJq3rC3RKdmcfFwkBJVRXvtG6cBoAYPll6VxJYOMQWeu78Ibfov%2FxIVCuN9yUfzEiokfQrzBoptc94bCQ5k0pNyJcSdgezOUKHB12P5Zmm3Hd6AAbGRDV9UCaLVz0wYkFJPrCyUv1ZfhrM%2BBqc%3D"
+     *     }
+     * }
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     * 可能出现的错误代码:
+     * 1000    CLIENT_WRONG_PARAMS             传入参数不正确
+     * 1300    MERCHANT_NOT_EXIST              商户不存在
+     */
+    public function charge(Request $request)
+    {
+        $goodsTypes = Order::getAllGoodsTypes();
+        $gTypes = array_keys($goodsTypes);
+        $payTypes = Order::getAllPayTypes();
+        $pTypes = array_keys($payTypes);
+        $validator = Validator::make($data = $request->input(),
+            [
+                'number' => 'required|integer|min:1',
+                'type' => 'required|in:' . join(',', $pTypes),
+                'goods' => 'in:' . join(',', $gTypes),
+            ],
+            [
+                'number.required' => '充值金额必填',
+                'number.integer' => '金额必须为整数',
+                'number.min' => '充值金额至少为1',
+                'type.required' => '支付类型必填',
+                'type.in' => '支付类型非法',
+                'goods.in' => '充值商品非法',
+            ]
+        );
+
+        if ($validator->fails()) {
+            return $this->validatorError($validator->messages()->all(), ErrorCode::CLIENT_WRONG_PARAMS);
+        }
+
+        $user = Auth::user();
+        $merchant = Merchant::where('user_id', '=', $user->id)->first();//模型支持单用户多商户,业务只设计单商户
+        if (!$merchant) {
+            return $this->error(ErrorCode::MERCHANT_NOT_EXIST);
+        }
+
+        $data['goods_id'] = 0;
+        if (!isset($data['goods'])) {//默认充余额
+            $data['goods'] = Order::GOODS_TYPE_BALANCE;
+        }
+
+        $data['user_type'] = Order::USER_TYPE_MERCHANT;
+        $data['user_id'] = $user->id;//$merchant->id;
+        if ($data['type'] == Order::PAY_TYPE_ALIPAY) {
+            $result = $this->createAlipayCharge($data);
+        } else {
+            $result = $this->createWechatpayCharge($data);
+        }
+
+        if ($result === false) {
+            return $this->error(ErrorCode::ORDER_GENERATE_FAILED);
+        }
+        //log
+//        $data['amount'] = $data['number'];
+//        $this->chargeLog('Merchant', $merchant->id, $merchant->name,
+//            'balance', $data['amount'], 'balance', $data['amount'],
+//            'Merchant', $user->id, $merchant->name);
+
+        return $this->api($result);
+    }
+
+}

+ 1 - 0
server/app/Models/UserInfoModel.php

xqd
@@ -52,6 +52,7 @@ class UserInfoModel extends Authenticatable
                            'detail_address',
                            'status',
                            'remember_token',
+                           'birthday',
                           ];
 
     protected $hidden = ['password'];

+ 26 - 0
server/routes/api.php

xqd xqd
@@ -56,6 +56,14 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'auth.login',
         'uses' => 'AuthController@login',
     ]);
+    $api->post('auth/wechat_login', [
+        'as' => 'auth.wechat_login',
+        'uses' => 'AuthController@wechatLogin',
+    ]);
+    $api->post('auth/webo_login', [
+        'as' => 'auth.webo_login',
+        'uses' => 'AuthController@weboLogin',
+    ]);
     $api->get('auth/logout', [
         'as' => 'auth.logout',
         'uses' => 'AuthController@logout',
@@ -250,4 +258,22 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'interaction.reply',
         'uses' => 'InteractionController@reply',
     ]);
+
+    //支付宝支付回调
+    $api->post('pay/alipay/notify', [
+        'as' => 'pay.alipay.notify',
+        'uses' => 'PayController@alipayNotify',
+    ]);
+    //微信支付回调
+    $api->post('pay/wechatpay/notify', [
+        'as' => 'pay.wechatpay.notify',
+        'uses' => 'PayController@wechatpayNotify',
+    ]);
+
+    //商户充值
+    $api->post('pay/charge', [
+        'as' => 'pay.charge',
+        'uses' => 'PayController@charge',
+    ]);
+
 });