├── thinkphp ├── .htaccess ├── .gitignore ├── logo.png ├── library │ ├── think │ │ ├── console │ │ │ ├── bin │ │ │ │ ├── hiddeninput.exe │ │ │ │ └── README.md │ │ │ ├── command │ │ │ │ ├── make │ │ │ │ │ ├── stubs │ │ │ │ │ │ ├── model.stub │ │ │ │ │ │ ├── controller.plain.stub │ │ │ │ │ │ └── controller.stub │ │ │ │ │ ├── Model.php │ │ │ │ │ └── Controller.php │ │ │ │ ├── Clear.php │ │ │ │ ├── Build.php │ │ │ │ ├── Help.php │ │ │ │ └── Lists.php │ │ │ ├── LICENSE │ │ │ └── output │ │ │ │ ├── driver │ │ │ │ ├── Nothing.php │ │ │ │ └── Buffer.php │ │ │ │ └── question │ │ │ │ └── Confirmation.php │ │ ├── exception │ │ │ ├── RouteNotFoundException.php │ │ │ ├── HttpResponseException.php │ │ │ ├── ClassNotFoundException.php │ │ │ ├── TemplateNotFoundException.php │ │ │ ├── ValidateException.php │ │ │ ├── HttpException.php │ │ │ ├── DbException.php │ │ │ ├── PDOException.php │ │ │ ├── ThrowableError.php │ │ │ └── ErrorException.php │ │ ├── config │ │ │ └── driver │ │ │ │ ├── Ini.php │ │ │ │ ├── Json.php │ │ │ │ └── Xml.php │ │ ├── log │ │ │ └── driver │ │ │ │ └── Test.php │ │ ├── Env.php │ │ ├── model │ │ │ └── Pivot.php │ │ ├── db │ │ │ ├── exception │ │ │ │ ├── BindParamException.php │ │ │ │ ├── ModelNotFoundException.php │ │ │ │ └── DataNotFoundException.php │ │ │ └── builder │ │ │ │ ├── Mysql.php │ │ │ │ ├── Sqlite.php │ │ │ │ └── Pgsql.php │ │ ├── controller │ │ │ └── Yar.php │ │ ├── Exception.php │ │ ├── process │ │ │ ├── exception │ │ │ │ ├── Faild.php │ │ │ │ └── Timeout.php │ │ │ ├── Utils.php │ │ │ └── pipes │ │ │ │ └── Pipes.php │ │ ├── response │ │ │ ├── Json.php │ │ │ └── Jsonp.php │ │ ├── template │ │ │ └── driver │ │ │ │ └── File.php │ │ └── paginator │ │ │ └── Collection.php │ └── traits │ │ └── think │ │ └── Instance.php ├── codecov.yml ├── start.php ├── console.php ├── tpl │ ├── default_index.tpl │ └── dispatch_jump.tpl ├── composer.json ├── phpunit.xml ├── .travis.yml └── LICENSE.txt ├── application ├── .htaccess ├── admin │ ├── common.php │ ├── config.php │ ├── view │ │ ├── index │ │ │ └── .DS_Store │ │ ├── public │ │ │ ├── .DS_Store │ │ │ ├── footer.html │ │ │ └── header.html │ │ ├── bis │ │ │ ├── dellist.html │ │ │ ├── index.html │ │ │ └── apply.html │ │ ├── category │ │ │ ├── add.html │ │ │ ├── edit.html │ │ │ └── index.html │ │ └── featured │ │ │ └── index.html │ ├── validate │ │ └── Category.php │ └── controller │ │ ├── Index.php │ │ ├── Base.php │ │ ├── Featured.php │ │ └── Bis.php ├── bis │ ├── common.php │ ├── config.php │ ├── .DS_Store │ ├── view │ │ ├── .DS_Store │ │ ├── register │ │ │ └── waiting.html │ │ ├── public │ │ │ ├── footer.html │ │ │ ├── menu.html │ │ │ └── header.html │ │ ├── location │ │ │ └── index.html │ │ └── login │ │ │ └── index.html │ └── controller │ │ ├── Index.php │ │ ├── Base.php │ │ ├── Login.php │ │ └── Deal.php ├── common │ ├── common.php │ ├── config.php │ ├── model │ │ ├── Admin.php │ │ ├── Coupons.php │ │ ├── BisAccount.php │ │ ├── BaseModel.php │ │ ├── Bis.php │ │ ├── Featured.php │ │ ├── BisLocation.php │ │ ├── User.php │ │ ├── City.php │ │ ├── Order.php │ │ └── Deal.php │ ├── validate │ │ └── Bis.php │ └── controller │ │ └── Index.php ├── .DS_Store ├── api │ ├── config.php │ ├── common.php │ └── controller │ │ ├── Image.php │ │ ├── City.php │ │ ├── Order.php │ │ ├── Category.php │ │ └── Index.php ├── extra │ ├── featured.php │ ├── email.php │ └── map.php ├── index │ ├── controller │ │ ├── Map.php │ │ ├── Index.php │ │ ├── Test.php │ │ ├── Detail.php │ │ ├── Order.php │ │ ├── Pay.php │ │ ├── Lists.php │ │ └── Base.php │ └── view │ │ ├── pay │ │ └── paysuccess.html │ │ ├── public │ │ ├── nav.html │ │ └── head.html │ │ └── user │ │ └── register.html ├── command.php ├── route.php ├── tags.php ├── build.php └── database.php ├── extend └── .gitignore ├── vendor └── .gitignore ├── public ├── static │ └── .gitignore ├── robots.txt ├── .DS_Store ├── favicon.ico ├── upload │ ├── 20170115 │ │ ├── .DS_Store │ │ ├── 2ce878768a40805c0a520f0cc6a6be32.png │ │ └── 86c3c46ae746dda1a4af393466e4c07b.png │ ├── 20170122 │ │ ├── .DS_Store │ │ ├── 0abbc2d97c52e0883bac9522d27f0244.png │ │ ├── 0e48c3472bc79c2232a64b086b798182.png │ │ ├── 28141ad57dbe4191f948bf3211b96b43.png │ │ ├── 4dd8bbfc7cd3b94cb1a7103191b76662.png │ │ ├── 6b472e073d3d9113841520ded129e599.png │ │ ├── 7b250f7b0af5a4a3c25fa050594fa518.png │ │ ├── 92954b81303a22bd63edce3146c40e19.png │ │ ├── b041ef62b92d17ca842713d136628005.png │ │ └── e65aa253ca066b4c0c6deebe3287f453.png │ ├── 20170205 │ │ ├── .DS_Store │ │ ├── 971ed11d347241e2077693ae178873b7.png │ │ ├── c157f7cbe8da9ff151781bc5930c64a2.png │ │ ├── e1f72f9ee1ab70c051db24d6e7c2e597.png │ │ └── eeb5d7e8ead52b94efe7fcb1fe04f25d.png │ ├── 20170206 │ │ ├── .DS_Store │ │ ├── 762564e8e90163d6e1a53a52f2fee5a8.png │ │ ├── 93aa915c68bf91d3c946bfab4c00491a.png │ │ ├── ca530a984bd4960fe6fa5633b4ca549e.png │ │ └── e0bf629155825b66375b1f4911544dc8.png │ ├── 20170219 │ │ ├── d1.jpg │ │ ├── .DS_Store │ │ ├── ads.jpg │ │ ├── datu.jpg │ │ ├── 0c419b2425c8935b4222354c0442f0dd.jpg │ │ ├── 1574822f08a76532a74047670f44015e.jpg │ │ ├── 3e35576eb4c321bf517f8d8ac2c95acf.jpg │ │ ├── 3fbf62aa64e2c197be655c010adfe0f3.jpg │ │ ├── 64fad76c6cb6084ba466b43810fe4d25.jpg │ │ ├── 8af01775f874b7ebf3583eb2fdf3e9ed.jpg │ │ ├── a89a8c417e7e5ff3079e4e2b6129d785.jpg │ │ ├── bc3356e2d1959ad830ca992e4606167e.jpg │ │ ├── d2f4a90b29ff6f9751456f0fe44d09f2.jpg │ │ ├── de895022acce2a7c94e1dd255a7565f9.jpg │ │ ├── ed6baf2b9686ffe4c17f9052b1c041aa.jpg │ │ └── f35c26b5069e96402d2f25a20f5e6faf.jpg │ ├── 20170309 │ │ └── .DS_Store │ ├── 20170311 │ │ ├── .DS_Store │ │ ├── 3461f6bc5de101e15d3dd5c059c6964f.png │ │ ├── 8f84f9e9d8ebc3a226c008bf842703ee.jpg │ │ └── f2c008ee590cffb3128f2e57e2e25945.jpg │ ├── 20170313 │ │ ├── .DS_Store │ │ ├── 2d8b03615df9193b551c62bd632c0956.jpg │ │ └── b041bc1a39e8a673680e4bdb41ac2683.jpg │ └── .DS_Store ├── weixin │ ├── .DS_Store │ ├── doc │ │ ├── README │ │ └── README.doc │ ├── image │ │ ├── bk.png │ │ ├── image001.jpg │ │ └── image002.png │ ├── lib │ │ ├── .DS_Store │ │ ├── WxPay.Exception.php │ │ ├── WxPay.Config.php │ │ └── WxPay.Notify.php │ ├── example │ │ ├── qrcode.php │ │ ├── WxPay.NativePay.php │ │ ├── notify.php │ │ ├── download.php │ │ ├── orderquery.php │ │ ├── native.php │ │ ├── micropay.php │ │ └── native_notify.php │ ├── cert │ │ ├── apiclient_cert.pem │ │ └── apiclient_key.pem │ └── index.php ├── ueditor │ └── php │ │ └── upload │ │ └── image │ │ ├── 20170114 │ │ └── 1484380249415690.png │ │ ├── 20170115 │ │ └── 1484473712156060.png │ │ ├── 20170311 │ │ └── 1489227732945077.jpg │ │ └── 20170313 │ │ ├── 1489403977273966.jpg │ │ └── 1489405649126829.jpg ├── .htaccess ├── nohup.out ├── index.php └── router.php ├── runtime ├── log │ └── 201709 │ │ └── 07_error.log └── temp │ └── 50386a63f26ecd5d0b88b2316bbc34b5.php ├── .idea ├── modules.xml └── tp5.iml ├── composer.json ├── think └── LICENSE.txt /thinkphp/.htaccess: -------------------------------------------------------------------------------- 1 | deny from all -------------------------------------------------------------------------------- /application/.htaccess: -------------------------------------------------------------------------------- 1 | deny from all -------------------------------------------------------------------------------- /application/admin/common.php: -------------------------------------------------------------------------------- 1 | 'json', 5 | ]; -------------------------------------------------------------------------------- /public/upload/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/.DS_Store -------------------------------------------------------------------------------- /public/weixin/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/weixin/.DS_Store -------------------------------------------------------------------------------- /public/weixin/doc/README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/weixin/doc/README -------------------------------------------------------------------------------- /application/bis/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/application/bis/.DS_Store -------------------------------------------------------------------------------- /public/weixin/image/bk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/weixin/image/bk.png -------------------------------------------------------------------------------- /public/weixin/lib/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/weixin/lib/.DS_Store -------------------------------------------------------------------------------- /public/upload/20170219/d1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170219/d1.jpg -------------------------------------------------------------------------------- /public/weixin/doc/README.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/weixin/doc/README.doc -------------------------------------------------------------------------------- /application/bis/view/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/application/bis/view/.DS_Store -------------------------------------------------------------------------------- /public/upload/20170115/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170115/.DS_Store -------------------------------------------------------------------------------- /public/upload/20170122/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170122/.DS_Store -------------------------------------------------------------------------------- /public/upload/20170205/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170205/.DS_Store -------------------------------------------------------------------------------- /public/upload/20170206/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170206/.DS_Store -------------------------------------------------------------------------------- /public/upload/20170219/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170219/.DS_Store -------------------------------------------------------------------------------- /public/upload/20170219/ads.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170219/ads.jpg -------------------------------------------------------------------------------- /public/upload/20170219/datu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170219/datu.jpg -------------------------------------------------------------------------------- /public/upload/20170309/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170309/.DS_Store -------------------------------------------------------------------------------- /public/upload/20170311/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170311/.DS_Store -------------------------------------------------------------------------------- /public/upload/20170313/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/upload/20170313/.DS_Store -------------------------------------------------------------------------------- /public/weixin/image/image001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/weixin/image/image001.jpg -------------------------------------------------------------------------------- /public/weixin/image/image002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/public/weixin/image/image002.png -------------------------------------------------------------------------------- /runtime/log/201709/07_error.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/runtime/log/201709/07_error.log -------------------------------------------------------------------------------- /application/admin/view/index/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/application/admin/view/index/.DS_Store -------------------------------------------------------------------------------- /application/admin/view/public/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ljhhhhhh/imooc_o2o/HEAD/application/admin/view/public/.DS_Store -------------------------------------------------------------------------------- /application/common/model/Admin.php: -------------------------------------------------------------------------------- 1 | intval($status), 5 | 'message' => $message, 6 | 'data' => $data, 7 | ]; 8 | } -------------------------------------------------------------------------------- /application/extra/featured.php: -------------------------------------------------------------------------------- 1 | [ 8 | 0 => '首页大图推荐位', 9 | 1 => '首页右侧广告位', 10 | // todo 11 | ], 12 | ]; -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/make/stubs/controller.plain.stub: -------------------------------------------------------------------------------- 1 | fetch(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /application/extra/email.php: -------------------------------------------------------------------------------- 1 | 'smtp.126.com', 7 | 'port' => 25, 8 | 'username' => 'singwa3@126.com', 9 | 'password' => 'you password o hah', 10 | 11 | ]; 12 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Options +FollowSymlinks -Multiviews 3 | RewriteEngine On 4 | 5 | RewriteCond %{REQUEST_FILENAME} !-d 6 | RewriteCond %{REQUEST_FILENAME} !-f 7 | RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 8 | 9 | -------------------------------------------------------------------------------- /public/weixin/lib/WxPay.Exception.php: -------------------------------------------------------------------------------- 1 | getMessage(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /thinkphp/codecov.yml: -------------------------------------------------------------------------------- 1 | comment: 2 | layout: header, changes, diff 3 | coverage: 4 | ignore: 5 | - base.php 6 | - helper.php 7 | - convention.php 8 | - lang/zh-cn.php 9 | - start.php 10 | - console.php 11 | status: 12 | patch: false 13 | -------------------------------------------------------------------------------- /application/index/controller/Map.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /application/extra/map.php: -------------------------------------------------------------------------------- 1 | 'ak', 7 | 'baidu_map_url' => 'http://api.map.baidu.com/', 8 | 'geocoder' => 'geocoder/v2/', 9 | 'width' => 400, 10 | 'height' => 300, 11 | 'staticimage' => 'staticimage/v2', 12 | ]; 13 | -------------------------------------------------------------------------------- /.idea/tp5.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /application/bis/view/register/waiting.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/header" /} 3 |
4 | {if $detail} 5 |

{$detail.status|bisRegister}

6 | {else /} 7 |

不存在该入驻申请情况

8 | {/if} 9 |
10 | {include file="public/footer" /} 11 | 12 | -------------------------------------------------------------------------------- /public/nohup.out: -------------------------------------------------------------------------------- 1 | PHP 5.5.14 Development Server started at Fri Dec 9 03:08:21 2016 2 | Listening on http://localhost:8181 3 | Document root is /Applications/MAMP/htdocs/imooc_o2o/public 4 | Press Ctrl-C to quit. 5 | [Fri Dec 9 03:10:26 2016] ::1:55174 [200]: /favicon.ico 6 | [Fri Dec 9 03:11:10 2016] ::1:55179 [200]: /favicon.ico 7 | -------------------------------------------------------------------------------- /application/common/model/BisAccount.php: -------------------------------------------------------------------------------- 1 | allowField(true)->save($data, ['id'=>$id]); 12 | } 13 | } -------------------------------------------------------------------------------- /application/api/controller/Image.php: -------------------------------------------------------------------------------- 1 | file('file'); 10 | // 给定一个目录 11 | $info = $file->move('upload'); 12 | if($info && $info->getPathname()) { 13 | return show(1, 'success','/'.$info->getPathname()); 14 | } 15 | return show(0,'upload error'); 16 | } 17 | } -------------------------------------------------------------------------------- /application/common/model/BaseModel.php: -------------------------------------------------------------------------------- 1 | save($data); 15 | return $this->id; 16 | } 17 | 18 | public function updateById($data, $id) { 19 | return $this->allowField(true)->save($data, ['id'=>$id]); 20 | } 21 | 22 | 23 | } -------------------------------------------------------------------------------- /application/common/model/Bis.php: -------------------------------------------------------------------------------- 1 | 'desc', 15 | ]; 16 | 17 | $data = [ 18 | 'status' => $status, 19 | ]; 20 | $result = $this->where($data) 21 | ->order($order) 22 | ->paginate(); 23 | return $result; 24 | } 25 | } -------------------------------------------------------------------------------- /application/common/model/Featured.php: -------------------------------------------------------------------------------- 1 | $type, 15 | 'status' => ['neq', -1], 16 | ]; 17 | 18 | $order = ['id'=>'desc']; 19 | 20 | $result = $this->where($data) 21 | ->order($order) 22 | ->paginate(); 23 | return $result; 24 | } 25 | } -------------------------------------------------------------------------------- /application/admin/validate/Category.php: -------------------------------------------------------------------------------- 1 | ['name', 'parent_id', 'id'],// 添加 17 | 'listorder' => ['id', 'listorder'], //排序 18 | 'status' => ['id', 'status'], 19 | ]; 20 | } -------------------------------------------------------------------------------- /application/command.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return []; -------------------------------------------------------------------------------- /application/admin/controller/Index.php: -------------------------------------------------------------------------------- 1 | fetch(); 9 | } 10 | public function test() { 11 | print_r(\Map::getLngLat('北京昌平沙河地铁')); 12 | return 'singwa'; 13 | } 14 | public function map() { 15 | return \Map::staticimage('北京昌平沙河地铁'); 16 | } 17 | public function welcome() { 18 | //\phpmailer\Email::send('463785435@qq.com','tp5-emaiil','sucess-hala'); 19 | //return '发送邮件成功'; 20 | //return $this->fetch(); 21 | return "欢迎来到o2o主后台首页!"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /application/common/validate/Bis.php: -------------------------------------------------------------------------------- 1 | 'require|max:25', 7 | 'email' => 'email', 8 | 'logo' => 'require', 9 | 'city_id' => 'require', 10 | 'bank_info' => 'require', 11 | 'bank_name' => 'require', 12 | 'bank_user' => 'require', 13 | 'faren' => 'require', 14 | 'faren_tel' => 'require', 15 | ]; 16 | 17 | // 场景设置 18 | protected $scene = [ 19 | 'add' => ['name', 'email', 'logo', 'city_id', 'bank_info', 'bank_name', 'bank_user', 'faren', 'faren_tel'], 20 | ]; 21 | } -------------------------------------------------------------------------------- /application/index/controller/Index.php: -------------------------------------------------------------------------------- 1 | getNormalDealByCategoryCityId(1, $this->city->id); 14 | // 获取4个子分类 15 | $meishicates = model('Category')->getNormalRecommendCategoryByParentId(1, 4); 16 | return $this->fetch('',[ 17 | 'datas' => $datas, 18 | 'meishicates' => $meishicates, 19 | 'controller' => 'ms', 20 | ]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /application/api/controller/City.php: -------------------------------------------------------------------------------- 1 | obj = model("City"); 9 | } 10 | public function getCitysByParentId() { 11 | $id = input('post.id'); 12 | if(!$id) { 13 | $this->error('ID不合法'); 14 | } 15 | //halt($id); 16 | // 通过id获取二级城市 17 | $citys = $this->obj->getNormalCitysByParentId($id); 18 | if(!$citys) { 19 | return show(0,'error'); 20 | } 21 | return show(1,'success', $citys); 22 | } 23 | 24 | 25 | 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /application/api/controller/Order.php: -------------------------------------------------------------------------------- 1 | obj = model("Order"); 9 | } 10 | 11 | public function payStatus() { 12 | $id = input('post.id', 0, 'intval'); 13 | if(!$id) { 14 | return show(0, 'error'); 15 | } 16 | 17 | //判定是否登录 18 | 19 | $order = $this->obj->get($id); 20 | 21 | if($order->pay_status == 1) { // 支付成功 22 | return show(1, 'success'); 23 | } 24 | return show(0, 'error'); 25 | } 26 | 27 | 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /application/api/controller/Category.php: -------------------------------------------------------------------------------- 1 | obj = model("Category"); 9 | } 10 | public function getCategoryByParentId() { 11 | $id = input('post.id',0, 'intval'); 12 | if(!$id) { 13 | $this->error('ID不合法'); 14 | } 15 | // 通过id获取二级城市 16 | $categorys = $this->obj->getNormalCategoryByParentId($id); 17 | if(!$categorys) { 18 | return show(0,'error'); 19 | } 20 | return show(1,'success', $categorys); 21 | } 22 | 23 | 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /application/common/model/BisLocation.php: -------------------------------------------------------------------------------- 1 | $bisId, 12 | 'status' => 1, 13 | ]; 14 | 15 | $result = $this->where($data) 16 | ->order('id', 'desc') 17 | ->select(); 18 | return $result; 19 | } 20 | 21 | public function getNormalLocationsInId($ids) { 22 | $data = [ 23 | 'id' => ['in', $ids], 24 | 'status' => 1, 25 | ]; 26 | return $this->where($data) 27 | ->select(); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "topthink/think", 3 | "description": "the new thinkphp framework", 4 | "type": "project", 5 | "keywords": [ 6 | "framework", 7 | "thinkphp", 8 | "ORM" 9 | ], 10 | "homepage": "http://thinkphp.cn/", 11 | "license": "Apache-2.0", 12 | "authors": [ 13 | { 14 | "name": "liu21st", 15 | "email": "liu21st@gmail.com" 16 | } 17 | ], 18 | "require": { 19 | "php": ">=5.4.0", 20 | "topthink/framework": "^5.0", 21 | "topthink/think-captcha": "^1.0" 22 | }, 23 | "extra": { 24 | "think-path": "thinkphp" 25 | }, 26 | "config": { 27 | "preferred-install": "dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /application/common/model/User.php: -------------------------------------------------------------------------------- 1 | data($data)->allowField(true) 16 | ->save(); 17 | } 18 | 19 | /** 20 | * 根据用户名获取用户信息 21 | * @param $username 22 | */ 23 | public function getUserByUsername($username) { 24 | if(!$username) { 25 | exception('用户名不合法'); 26 | } 27 | 28 | $data = ['username' => $username]; 29 | return $this->where($data)->find(); 30 | } 31 | } -------------------------------------------------------------------------------- /think: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 11 | // +---------------------------------------------------------------------- 12 | 13 | // 定义项目路径 14 | define('APP_PATH', __DIR__ . '/application/'); 15 | 16 | // 加载框架引导文件 17 | require './thinkphp/console.php'; -------------------------------------------------------------------------------- /thinkphp/start.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | // ThinkPHP 引导文件 15 | // 加载基础文件 16 | require __DIR__ . '/base.php'; 17 | // 执行应用 18 | App::run()->send(); 19 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // [ 应用入口文件 ] 13 | 14 | // 定义应用目录 15 | define('APP_PATH', __DIR__ . '/../application/'); 16 | // 加载框架引导文件 17 | require __DIR__ . '/../thinkphp/start.php'; 18 | -------------------------------------------------------------------------------- /thinkphp/console.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | // ThinkPHP 引导文件 15 | // 加载基础文件 16 | require __DIR__ . '/base.php'; 17 | 18 | // 执行应用 19 | App::initCommon(); 20 | Console::init(); -------------------------------------------------------------------------------- /public/router.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | // $Id$ 12 | 13 | if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["REQUEST_URI"])) { 14 | return false; 15 | } else { 16 | require __DIR__ . "/index.php"; 17 | } 18 | -------------------------------------------------------------------------------- /application/admin/controller/Base.php: -------------------------------------------------------------------------------- 1 | error('id不合法'); 12 | } 13 | if(!is_numeric($data['status'])) { 14 | $this->error('status不合法'); 15 | } 16 | 17 | // 获取控制器 18 | $model = request()->controller(); 19 | //echo $model;exit; 20 | $res = model($model)->save(['status'=>$data['status']], ['id'=>$data['id']]); 21 | if($res) { 22 | $this->success('更新成功'); 23 | }else { 24 | $this->error('更新失败'); 25 | } 26 | } 27 | 28 | // 排序功能 也放到 base 29 | } -------------------------------------------------------------------------------- /application/bis/controller/Base.php: -------------------------------------------------------------------------------- 1 | isLogin(); 10 | if(!$isLogin) { 11 | return $this->redirect(url('login/index')); 12 | } 13 | } 14 | 15 | //判定是否登录 16 | public function isLogin() { 17 | // 获取sesssion 18 | $user = $this->getLoginUser(); 19 | if($user && $user->id) { 20 | return true; 21 | } 22 | return false; 23 | 24 | } 25 | 26 | public function getLoginUser() { 27 | if(!$this->account) { 28 | $this->account = session('bisAccount', '', 'bis'); 29 | } 30 | return $this->account; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /application/common/model/City.php: -------------------------------------------------------------------------------- 1 | 1, 13 | 'parent_id' => $parentId, 14 | ]; 15 | 16 | $order = [ 17 | 'id' => 'desc', 18 | ]; 19 | 20 | return $this->where($data) 21 | ->order($order) 22 | ->select(); 23 | } 24 | 25 | public function getNormalCitys() { 26 | $data = [ 27 | 'status' => 1, 28 | 'parent_id' => ['gt', 0], 29 | ]; 30 | 31 | $order = ['id'=>'desc']; 32 | 33 | return $this->where($data) 34 | ->order($order) 35 | ->select(); 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /application/route.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return [ 13 | '__pattern__' => [ 14 | 'name' => '\w+', 15 | ], 16 | '[hello]' => [ 17 | ':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']], 18 | ':name' => ['index/hello', ['method' => 'post']], 19 | ], 20 | 21 | ]; 22 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/RouteNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\exception\HttpException; 15 | 16 | class RouteNotFoundException extends HttpException 17 | { 18 | 19 | public function __construct() 20 | { 21 | parent::__construct(404); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /thinkphp/library/think/config/driver/Ini.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\config\driver; 13 | 14 | class Ini 15 | { 16 | public function parse($config) 17 | { 18 | if (is_file($config)) { 19 | return parse_ini_file($config, true); 20 | } else { 21 | return parse_ini_string($config, true); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /thinkphp/library/think/config/driver/Json.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\config\driver; 13 | 14 | class Json 15 | { 16 | public function parse($config) 17 | { 18 | if (is_file($config)) { 19 | $config = file_get_contents($config); 20 | } 21 | $result = json_decode($config, true); 22 | return $result; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /thinkphp/library/think/log/driver/Test.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\log\driver; 13 | 14 | /** 15 | * 模拟测试输出 16 | */ 17 | class Test 18 | { 19 | /** 20 | * 日志写入接口 21 | * @access public 22 | * @param array $log 日志信息 23 | * @return bool 24 | */ 25 | public function save(array $log = []) 26 | { 27 | return true; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /application/tags.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // 应用行为扩展定义文件 13 | return [ 14 | // 应用初始化 15 | 'app_init' => [], 16 | // 应用开始 17 | 'app_begin' => [], 18 | // 模块初始化 19 | 'module_init' => [], 20 | // 操作开始执行 21 | 'action_begin' => [], 22 | // 视图内容过滤 23 | 'view_filter' => [], 24 | // 日志写入 25 | 'log_write' => [], 26 | // 应用结束 27 | 'app_end' => [], 28 | ]; 29 | -------------------------------------------------------------------------------- /application/admin/view/public/footer.html: -------------------------------------------------------------------------------- 1 | {load href="__STATIC__/admin/hui/lib/jquery/1.9.1/jquery.min.js" /} 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {load href="__STATIC__/admin/js/common.js" /} 10 | {load href="__STATIC__/admin/uploadify/jquery.uploadify.min.js" /} 11 | {load href="__STATIC__/admin/js/image.js" /} -------------------------------------------------------------------------------- /application/api/controller/Index.php: -------------------------------------------------------------------------------- 1 | *{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }

:)

ThinkPHP V5
十年磨一剑 - 为API开发设计的高性能框架

[ V5.0 版本由 七牛云 独家赞助发布 ]
'; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /application/bis/view/public/footer.html: -------------------------------------------------------------------------------- 1 | {load href="__STATIC__/admin/hui/lib/jquery/1.9.1/jquery.min.js" /} 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {load href="__STATIC__/admin/js/common.js" /} 10 | {load href="__STATIC__/admin/uploadify/jquery.uploadify.min.js" /} 11 | {load href="__STATIC__/admin/js/image.js" /} 12 | -------------------------------------------------------------------------------- /application/common/controller/Index.php: -------------------------------------------------------------------------------- 1 | *{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }

:)

ThinkPHP V5
十年磨一剑 - 为API开发设计的高性能框架

[ V5.0 版本由 七牛云 独家赞助发布 ]
'; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /thinkphp/tpl/default_index.tpl: -------------------------------------------------------------------------------- 1 | *{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }

:)

ThinkPHP V5
十年磨一剑 - 为API开发设计的高性能框架

[ V5.0 版本由 七牛云 独家赞助发布 ]
'; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /application/common/model/Order.php: -------------------------------------------------------------------------------- 1 | save($data); 13 | return $this->id; 14 | 15 | } 16 | 17 | public function updateOrderByOutTradeNo($outTradeTo, $weixinData) { 18 | if(!empty($weixinData['transaction_id'])) { 19 | $data['transaction_id'] = $weixinData['transaction_id']; 20 | } 21 | if(!empty($weixinData['total_fee'])) { 22 | $data['pay_amount'] = $weixinData['total_fee'] / 100; 23 | $data['pay_status'] = 1; 24 | } 25 | 26 | if(!empty($weixinData['time_end'])) { 27 | $data['pay_time'] = $weixinData['time_end']; 28 | } 29 | 30 | return $this->allowField(true) 31 | ->save($data, ['out_trade_no' => $outTradeTo]); 32 | } 33 | 34 | 35 | } -------------------------------------------------------------------------------- /thinkphp/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "topthink/framework", 3 | "description": "the new thinkphp framework", 4 | "type": "think-framework", 5 | "keywords": [ 6 | "framework", 7 | "thinkphp", 8 | "ORM" 9 | ], 10 | "homepage": "http://thinkphp.cn/", 11 | "license": "Apache-2.0", 12 | "authors": [ 13 | { 14 | "name": "liu21st", 15 | "email": "liu21st@gmail.com" 16 | } 17 | ], 18 | "require": { 19 | "php": ">=5.4.0", 20 | "topthink/think-installer": "~1.0" 21 | }, 22 | "require-dev": { 23 | "phpunit/phpunit": "4.8.*", 24 | "johnkary/phpunit-speedtrap": "^1.0", 25 | "mikey179/vfsStream": "~1.6", 26 | "phploc/phploc": "2.*", 27 | "sebastian/phpcpd": "2.*", 28 | "squizlabs/php_codesniffer": "2.*", 29 | "phpdocumentor/reflection-docblock": "^2.0" 30 | }, 31 | "autoload": { 32 | "psr-4": { 33 | "think\\": "library/think" 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/HttpResponseException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\Response; 15 | 16 | class HttpResponseException extends \RuntimeException 17 | { 18 | /** 19 | * @var Response 20 | */ 21 | protected $response; 22 | 23 | public function __construct(Response $response) 24 | { 25 | $this->response = $response; 26 | } 27 | 28 | public function getResponse() 29 | { 30 | return $this->response; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2016 Fabien Potencier 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /thinkphp/library/think/console/output/driver/Nothing.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\driver; 13 | 14 | use think\console\Output; 15 | 16 | class Nothing 17 | { 18 | 19 | public function __construct(Output $output) 20 | { 21 | // do nothing 22 | } 23 | 24 | public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL) 25 | { 26 | // do nothing 27 | } 28 | 29 | public function renderException(\Exception $e) 30 | { 31 | // do nothing 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /public/weixin/example/WxPay.NativePay.php: -------------------------------------------------------------------------------- 1 | SetProduct_id($productId); 21 | $values = WxpayApi::bizpayurl($biz); 22 | $url = "weixin://wxpay/bizpayurl?" . $this->ToUrlParams($values); 23 | return $url; 24 | } 25 | 26 | /** 27 | * 28 | * 参数数组转换为url参数 29 | * @param array $urlObj 30 | */ 31 | private function ToUrlParams($urlObj) 32 | { 33 | $buff = ""; 34 | foreach ($urlObj as $k => $v) 35 | { 36 | $buff .= $k . "=" . $v . "&"; 37 | } 38 | 39 | $buff = trim($buff, "&"); 40 | return $buff; 41 | } 42 | 43 | /** 44 | * 45 | * 生成直接支付url,支付url有效期为2小时,模式二 46 | * @param UnifiedOrderInput $input 47 | */ 48 | public function GetPayUrl($input) 49 | { 50 | if($input->GetTrade_type() == "NATIVE") 51 | { 52 | $result = WxPayApi::unifiedOrder($input); 53 | return $result; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /thinkphp/library/think/exception/ClassNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class ClassNotFoundException extends \RuntimeException 15 | { 16 | protected $class; 17 | public function __construct($message, $class = '') 18 | { 19 | $this->message = $message; 20 | $this->class = $class; 21 | } 22 | 23 | /** 24 | * 获取类名 25 | * @access public 26 | * @return string 27 | */ 28 | public function getClass() 29 | { 30 | return $this->class; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /thinkphp/library/think/Env.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | class Env 15 | { 16 | /** 17 | * 获取环境变量值 18 | * @param string $name 环境变量名(支持二级 .号分割) 19 | * @param string $default 默认值 20 | * @return mixed 21 | */ 22 | public static function get($name, $default = null) 23 | { 24 | $result = getenv(ENV_PREFIX . strtoupper(str_replace('.', '_', $name))); 25 | if (false !== $result) { 26 | return $result; 27 | } else { 28 | return $default; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/TemplateNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class TemplateNotFoundException extends \RuntimeException 15 | { 16 | protected $template; 17 | 18 | public function __construct($message, $template = '') 19 | { 20 | $this->message = $message; 21 | $this->template = $template; 22 | } 23 | 24 | /** 25 | * 获取模板文件 26 | * @access public 27 | * @return string 28 | */ 29 | public function getTemplate() 30 | { 31 | return $this->template; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/ValidateException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class ValidateException extends \RuntimeException 15 | { 16 | protected $error; 17 | 18 | public function __construct($error) 19 | { 20 | $this->error = $error; 21 | $this->message = is_array($error) ? implode("\n\r", $error) : $error; 22 | } 23 | 24 | /** 25 | * 获取验证错误信息 26 | * @access public 27 | * @return array|string 28 | */ 29 | public function getError() 30 | { 31 | return $this->error; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /thinkphp/library/think/model/Pivot.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\model; 13 | 14 | use think\Model; 15 | 16 | class Pivot extends Model 17 | { 18 | 19 | /** 20 | * 架构函数 21 | * @access public 22 | * @param array|object $data 数据 23 | * @param string $table 中间数据表名 24 | */ 25 | public function __construct($data = [], $table = '') 26 | { 27 | if (is_object($data)) { 28 | $this->data = get_object_vars($data); 29 | } else { 30 | $this->data = $data; 31 | } 32 | 33 | $this->table = $table; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /thinkphp/library/think/config/driver/Xml.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\config\driver; 13 | 14 | class Xml 15 | { 16 | public function parse($config) 17 | { 18 | if (is_file($config)) { 19 | $content = simplexml_load_file($config); 20 | } else { 21 | $content = simplexml_load_string($config); 22 | } 23 | $result = (array) $content; 24 | foreach ($result as $key => $val) { 25 | if (is_object($val)) { 26 | $result[$key] = (array) $val; 27 | } 28 | } 29 | return $result; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /application/admin/view/bis/dellist.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/header" /} 3 | 4 | 5 |
6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
ID商户名称法人联系电话申请时间状态操作
35 |
36 |
37 | 38 | {include file="public/footer" /} 39 | -------------------------------------------------------------------------------- /application/bis/view/public/menu.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/make/Model.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command\make; 13 | 14 | use think\console\command\Make; 15 | 16 | class Model extends Make 17 | { 18 | protected $type = "Model"; 19 | 20 | protected function configure() 21 | { 22 | parent::configure(); 23 | $this->setName('make:model') 24 | ->setDescription('Create a new model class'); 25 | } 26 | 27 | protected function getStub() 28 | { 29 | return __DIR__ . '/stubs/model.stub'; 30 | } 31 | 32 | protected function getNamespace($appNamespace, $module) 33 | { 34 | return parent::getNamespace($appNamespace, $module) . '\model'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /thinkphp/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | ./tests/thinkphp/ 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ./ 23 | 24 | tests 25 | vendor 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /thinkphp/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: php 4 | 5 | services: 6 | - memcached 7 | - mongodb 8 | - mysql 9 | - postgresql 10 | - redis-server 11 | 12 | matrix: 13 | fast_finish: true 14 | include: 15 | - php: 5.4 16 | - php: 5.5 17 | - php: 5.6 18 | - php: 7.0 19 | - php: hhvm 20 | allow_failures: 21 | - php: hhvm 22 | 23 | cache: 24 | directories: 25 | - $HOME/.composer/cache 26 | 27 | before_install: 28 | - composer self-update 29 | - mysql -e "create database IF NOT EXISTS test;" -uroot 30 | - psql -c 'DROP DATABASE IF EXISTS test;' -U postgres 31 | - psql -c 'create database test;' -U postgres 32 | 33 | install: 34 | - ./tests/script/install.sh 35 | 36 | script: 37 | ## LINT 38 | - find . -path ./vendor -prune -o -type f -name \*.php -exec php -l {} \; 39 | ## PHP_CodeSniffer 40 | - vendor/bin/phpcs --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 --standard=PSR2 --ignore="vendor/*" ./ 41 | ## PHP Copy/Paste Detector 42 | - vendor/bin/phpcpd --verbose --exclude vendor ./ || true 43 | ## PHPLOC 44 | - vendor/bin/phploc --exclude vendor ./ 45 | ## PHPUNIT 46 | - vendor/bin/phpunit --coverage-clover=coverage.xml --configuration=phpunit.xml 47 | 48 | after_success: 49 | - bash <(curl -s https://codecov.io/bash) 50 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/exception/BindParamException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\exception; 13 | 14 | use think\exception\DbException; 15 | 16 | /** 17 | * PDO参数绑定异常 18 | */ 19 | class BindParamException extends DbException 20 | { 21 | 22 | /** 23 | * BindParamException constructor. 24 | * @param string $message 25 | * @param array $config 26 | * @param string $sql 27 | * @param array $bind 28 | * @param int $code 29 | */ 30 | public function __construct($message, $config, $sql, $bind, $code = 10502) 31 | { 32 | $this->setData('Bind Param', $bind); 33 | parent::__construct($message, $config, $sql, $code); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/HttpException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class HttpException extends \RuntimeException 15 | { 16 | private $statusCode; 17 | private $headers; 18 | 19 | public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = [], $code = 0) 20 | { 21 | $this->statusCode = $statusCode; 22 | $this->headers = $headers; 23 | 24 | parent::__construct($message, $code, $previous); 25 | } 26 | 27 | public function getStatusCode() 28 | { 29 | return $this->statusCode; 30 | } 31 | 32 | public function getHeaders() 33 | { 34 | return $this->headers; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 3 | 版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn) 4 | All rights reserved。 5 | ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 6 | 7 | Apache Licence是著名的非盈利开源组织Apache采用的协议。 8 | 该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, 9 | 允许代码修改,再作为开源或商业软件发布。需要满足 10 | 的条件: 11 | 1. 需要给代码的用户一份Apache Licence ; 12 | 2. 如果你修改了代码,需要在被修改的文件中说明; 13 | 3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 14 | 带有原来代码中的协议,商标,专利声明和其他原来作者规 15 | 定需要包含的说明; 16 | 4. 如果再发布的产品中包含一个Notice文件,则在Notice文 17 | 件中需要带有本协议内容。你可以在Notice中增加自己的 18 | 许可,但不可以表现为对Apache Licence构成更改。 19 | 具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /thinkphp/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 3 | 版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn) 4 | All rights reserved。 5 | ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 6 | 7 | Apache Licence是著名的非盈利开源组织Apache采用的协议。 8 | 该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, 9 | 允许代码修改,再作为开源或商业软件发布。需要满足 10 | 的条件: 11 | 1. 需要给代码的用户一份Apache Licence ; 12 | 2. 如果你修改了代码,需要在被修改的文件中说明; 13 | 3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 14 | 带有原来代码中的协议,商标,专利声明和其他原来作者规 15 | 定需要包含的说明; 16 | 4. 如果再发布的产品中包含一个Notice文件,则在Notice文 17 | 件中需要带有本协议内容。你可以在Notice中增加自己的 18 | 许可,但不可以表现为对Apache Licence构成更改。 19 | 具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /application/admin/controller/Featured.php: -------------------------------------------------------------------------------- 1 | obj = model("Featured"); 9 | } 10 | 11 | public function index() { 12 | // 获取推荐位类别 13 | $types = config('featured.featured_type'); 14 | $type = input('get.type', 0 ,'intval'); 15 | // 获取列表数据 16 | $results = $this->obj->getFeaturedsByType($type); 17 | 18 | return $this->fetch('', [ 19 | 'types' => $types, 20 | 'results' => $results, 21 | 22 | ]); 23 | } 24 | public function add() { 25 | if(request()->isPost()) { 26 | // 入库的逻辑 27 | $data = input('post.'); 28 | // 数据需要做严格校验 validate 小伙伴仿照之前我们做的 自行完成 29 | 30 | $id = model('Featured')->add($data); 31 | if($id) { 32 | $this->success('添加成功'); 33 | }else{ 34 | $this->error('添加失败'); 35 | } 36 | }else { 37 | // 获取推荐位类别 38 | $types = config('featured.featured_type'); 39 | return $this->fetch('', [ 40 | 'types' => $types, 41 | ]); 42 | } 43 | } 44 | 45 | /*public function status() { 46 | // 获取值 47 | $data = input('get.'); 48 | // 利用tp5 validate 去做严格检验 id status 49 | 50 | $res = $this->obj->save(['status'=>$data['status']], ['id'=>$data['id']]); 51 | if($res) { 52 | $this->success('更新成功'); 53 | }else { 54 | $this->error('更新失败'); 55 | } 56 | }*/ 57 | 58 | } 59 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/exception/ModelNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\exception; 13 | 14 | use think\exception\DbException; 15 | 16 | class ModelNotFoundException extends DbException 17 | { 18 | protected $model; 19 | 20 | /** 21 | * 构造方法 22 | * @param string $message 23 | * @param string $model 24 | */ 25 | public function __construct($message, $model = '', Array $config = []) 26 | { 27 | $this->message = $message; 28 | $this->model = $model; 29 | 30 | $this->setData('Database Config', $config); 31 | } 32 | 33 | /** 34 | * 获取模型类名 35 | * @access public 36 | * @return string 37 | */ 38 | public function getModel() 39 | { 40 | return $this->model; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /application/bis/view/location/index.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/header" /} 3 | 4 | 5 |
6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
ID名称申请时间是否为总店状态操作
32 |
33 |
34 | 35 | {include file="public/footer" /} 36 | -------------------------------------------------------------------------------- /application/bis/controller/Login.php: -------------------------------------------------------------------------------- 1 | isPost()) { 9 | // 登录的逻辑 10 | //获取相关的数据 11 | $data = input('post.'); 12 | // 通过用户名 获取 用户相关信息 13 | // 严格的判定 14 | 15 | $ret = model('BisAccount')->get(['username'=>$data['username']]); 16 | 17 | if(!$ret || $ret->status !=1 ) { 18 | $this->error('改用户不存在,获取用户未被审核通过'); 19 | } 20 | 21 | if($ret->password != md5($data['password'].$ret->code)) { 22 | $this->error('密码不正确'); 23 | } 24 | 25 | model('BisAccount')->updateById(['last_login_time'=>time()], $ret->id); 26 | // 保存用户信息 bis是作用域 27 | session('bisAccount', $ret, 'bis'); 28 | return $this->success('登录成功', url('index/index')); 29 | 30 | 31 | }else { 32 | // 获取session 33 | $account = session('bisAccount', '', 'bis'); 34 | if($account && $account->id) { 35 | return $this->redirect(url('index/index')); 36 | } 37 | return $this->fetch(); 38 | } 39 | } 40 | 41 | public function logout() { 42 | // 清除session 43 | session(null, 'bis'); 44 | // 跳出 45 | $this->redirect('login/index'); 46 | } 47 | } -------------------------------------------------------------------------------- /thinkphp/library/think/db/exception/DataNotFoundException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\exception; 13 | 14 | use think\exception\DbException; 15 | 16 | class DataNotFoundException extends DbException 17 | { 18 | protected $table; 19 | 20 | /** 21 | * DbException constructor. 22 | * @param string $message 23 | * @param string $table 24 | * @param array $config 25 | */ 26 | public function __construct($message, $table = '', Array $config = []) 27 | { 28 | $this->message = $message; 29 | $this->table = $table; 30 | 31 | $this->setData('Database Config', $config); 32 | } 33 | 34 | /** 35 | * 获取数据表名 36 | * @access public 37 | * @return string 38 | */ 39 | public function getTable() 40 | { 41 | return $this->table; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /public/weixin/example/notify.php: -------------------------------------------------------------------------------- 1 | SetTransaction_id($transaction_id); 20 | $result = WxPayApi::orderQuery($input); 21 | Log::DEBUG("query:" . json_encode($result)); 22 | if(array_key_exists("return_code", $result) 23 | && array_key_exists("result_code", $result) 24 | && $result["return_code"] == "SUCCESS" 25 | && $result["result_code"] == "SUCCESS") 26 | { 27 | return true; 28 | } 29 | return false; 30 | } 31 | 32 | //重写回调处理函数 33 | public function NotifyProcess($data, &$msg) 34 | { 35 | Log::DEBUG("call back:" . json_encode($data)); 36 | $notfiyOutput = array(); 37 | 38 | if(!array_key_exists("transaction_id", $data)){ 39 | $msg = "输入参数不正确"; 40 | return false; 41 | } 42 | //查询订单,判断订单真实性 43 | if(!$this->Queryorder($data["transaction_id"])){ 44 | $msg = "订单查询失败"; 45 | return false; 46 | } 47 | return true; 48 | } 49 | } 50 | 51 | Log::DEBUG("begin notify"); 52 | $notify = new PayNotifyCallBack(); 53 | $notify->Handle(false); 54 | -------------------------------------------------------------------------------- /application/admin/view/category/add.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/header" /} 3 | 4 |
5 |
6 |
7 | 8 |
9 | 10 |
11 |
12 |
13 | 14 |
15 | 16 | 22 | 23 |
24 |
25 | 26 |
27 |
28 | 29 | 30 | 31 |
32 |
33 |
34 |
35 | 36 | 37 | {include file="public/footer" /} 38 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/DbException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\Exception; 15 | 16 | /** 17 | * Database相关异常处理类 18 | */ 19 | class DbException extends Exception 20 | { 21 | /** 22 | * DbException constructor. 23 | * @param string $message 24 | * @param array $config 25 | * @param string $sql 26 | * @param int $code 27 | */ 28 | public function __construct($message, array $config, $sql, $code = 10500) 29 | { 30 | $this->message = $message; 31 | $this->code = $code; 32 | 33 | $this->setData('Database Status', [ 34 | 'Error Code' => $code, 35 | 'Error Message' => $message, 36 | 'Error SQL' => $sql, 37 | ]); 38 | 39 | $this->setData('Database Config', $config); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /application/index/view/pay/paysuccess.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/head"} 3 | 4 | 5 | 6 |
7 | 28 | 29 |
恭喜,购买成功!
30 | 31 | 32 |
33 | 34 | 35 | 36 | 44 | 45 | 50 | 51 | -------------------------------------------------------------------------------- /thinkphp/library/think/controller/Yar.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\controller; 13 | 14 | /** 15 | * ThinkPHP Yar控制器类 16 | */ 17 | abstract class Yar 18 | { 19 | 20 | /** 21 | * 架构函数 22 | * @access public 23 | */ 24 | public function __construct() 25 | { 26 | //控制器初始化 27 | if (method_exists($this, '_initialize')) { 28 | $this->_initialize(); 29 | } 30 | 31 | //判断扩展是否存在 32 | if (!extension_loaded('yar')) { 33 | throw new \Exception('not support yar'); 34 | } 35 | 36 | //实例化Yar_Server 37 | $server = new \Yar_Server($this); 38 | // 启动server 39 | $server->handle(); 40 | } 41 | 42 | /** 43 | * 魔术方法 有不存在的操作的时候执行 44 | * @access public 45 | * @param string $method 方法名 46 | * @param array $args 参数 47 | * @return mixed 48 | */ 49 | public function __call($method, $args) 50 | {} 51 | } 52 | -------------------------------------------------------------------------------- /application/build.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return [ 13 | // 生成应用公共文件 14 | '__file__' => ['common.php', 'config.php', 'database.php'], 15 | 16 | // 定义demo模块的自动生成 (按照实际定义的文件名生成) 17 | /*'demo' => [ 18 | '__file__' => ['common.php'], 19 | '__dir__' => ['behavior', 'controller', 'model', 'view'], 20 | 'controller' => ['Index', 'Test', 'UserType'], 21 | 'model' => ['User', 'UserType'], 22 | 'view' => ['index/index'], 23 | ],*/ 24 | 'common' => [ 25 | '__dir__' => ['model'], 26 | 'model' => ['Category','Admin'], 27 | ], 28 | 'admin' => [ 29 | '__dir__' => ['controller','view'], 30 | 'controller' => ['Index'], 31 | 'view' => ['index/index'], 32 | ], 33 | 34 | 'api' => [ 35 | '__dir__' => ['controller','view'], 36 | 'controller' => ['Index','Image'], 37 | ], 38 | 'bis' => [ 39 | '__dir__' => ['controller', 'view'], 40 | 'controller' => ['Register','Login'], 41 | 42 | ], 43 | 44 | 45 | // 其他更多的模块定义 46 | ]; 47 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/output/driver/Buffer.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\driver; 13 | 14 | use think\console\Output; 15 | 16 | class Buffer 17 | { 18 | /** 19 | * @var string 20 | */ 21 | private $buffer = ''; 22 | 23 | public function __construct(Output $output) 24 | { 25 | // do nothing 26 | } 27 | 28 | public function fetch() 29 | { 30 | $content = $this->buffer; 31 | $this->buffer = ''; 32 | return $content; 33 | } 34 | 35 | public function write($messages, $newline = false, $options = Output::OUTPUT_NORMAL) 36 | { 37 | $messages = (array) $messages; 38 | 39 | foreach ($messages as $message) { 40 | $this->buffer .= $message; 41 | } 42 | if ($newline) { 43 | $this->buffer .= "\n"; 44 | } 45 | } 46 | 47 | public function renderException(\Exception $e) 48 | { 49 | // do nothing 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /public/weixin/example/download.php: -------------------------------------------------------------------------------- 1 | SetBill_date($bill_date); 11 | $input->SetBill_type($bill_type); 12 | $file = WxPayApi::downloadBill($input); 13 | echo $file; 14 | //TODO 对账单文件处理 15 | exit(0); 16 | } 17 | ?> 18 | 19 | 20 | 21 | 22 | 微信支付样例-查退款单 23 | 24 | 25 |
26 |
对账日期:

27 |

28 |
账单类型:

29 |

35 |
36 | 37 |
38 |
39 | 40 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/make/stubs/controller.stub: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\exception\DbException; 15 | 16 | /** 17 | * PDO异常处理类 18 | * 重新封装了系统的\PDOException类 19 | */ 20 | class PDOException extends DbException 21 | { 22 | /** 23 | * PDOException constructor. 24 | * @param \PDOException $exception 25 | * @param array $config 26 | * @param string $sql 27 | * @param int $code 28 | */ 29 | public function __construct(\PDOException $exception, array $config, $sql, $code = 10501) 30 | { 31 | $error = $exception->errorInfo; 32 | 33 | $this->setData('PDO Error Info', [ 34 | 'SQLSTATE' => $error[0], 35 | 'Driver Error Code' => isset($error[1]) ? $error[1] : 0, 36 | 'Driver Error Message' => isset($error[2]) ? $error[2] : '', 37 | ]); 38 | 39 | parent::__construct($exception->getMessage(), $config, $sql, $code); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /application/admin/view/category/edit.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/header" /} 3 | 4 |
5 |
6 |
7 | 8 |
9 | 10 |
11 |
12 |
13 | 14 |
15 | 16 | 22 | 23 |
24 |
25 | 26 |
27 | 28 |
29 | 30 | 31 | 32 |
33 |
34 |
35 |
36 | 37 | 38 | {include file="public/footer" /} 39 | -------------------------------------------------------------------------------- /thinkphp/library/traits/think/Instance.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace traits\think; 13 | 14 | use \think\Exception; 15 | 16 | trait Instance 17 | { 18 | protected static $instance = null; 19 | 20 | /** 21 | * @param array $options 22 | * @return static 23 | */ 24 | public static function instance($options = []) 25 | { 26 | if (is_null(self::$instance)) { 27 | self::$instance = new self($options); 28 | } 29 | return self::$instance; 30 | } 31 | 32 | // 静态调用 33 | public static function __callStatic($method, $params) 34 | { 35 | if (is_null(self::$instance)) { 36 | self::$instance = new self(); 37 | } 38 | $call = substr($method, 1); 39 | if (0 === strpos($method, '_') && is_callable([self::$instance, $call])) { 40 | return call_user_func_array([self::$instance, $call], $params); 41 | } else { 42 | throw new Exception("method not exists:" . $method); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /application/admin/view/bis/index.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/header" /} 3 | 4 | 5 |
6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {volist name="bis" id="vo"} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | {/volist} 33 | 34 | 35 |
ID商户名称法人联系电话申请时间状态操作
{$vo.id}{$vo.name}{$vo.faren}{$vo.faren_tel}{$vo.create_time|date="Y-m-d H:i",###}{$vo.status|status} 不通过
36 |
37 | {:pagination($bis)} 38 | 39 | 40 | {include file="public/footer" /} 41 | -------------------------------------------------------------------------------- /thinkphp/library/think/Exception.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think; 13 | 14 | class Exception extends \Exception 15 | { 16 | 17 | /** 18 | * 保存异常页面显示的额外Debug数据 19 | * @var array 20 | */ 21 | protected $data = []; 22 | 23 | /** 24 | * 设置异常额外的Debug数据 25 | * 数据将会显示为下面的格式 26 | * 27 | * Exception Data 28 | * -------------------------------------------------- 29 | * Label 1 30 | * key1 value1 31 | * key2 value2 32 | * Label 2 33 | * key1 value1 34 | * key2 value2 35 | * 36 | * @param string $label 数据分类,用于异常页面显示 37 | * @param array $data 需要显示的数据,必须为关联数组 38 | */ 39 | final protected function setData($label, array $data) 40 | { 41 | $this->data[$label] = $data; 42 | } 43 | 44 | /** 45 | * 获取异常额外Debug数据 46 | * 主要用于输出到异常页面便于调试 47 | * @return array 由setData设置的Debug数据 48 | */ 49 | final public function getData() 50 | { 51 | return $this->data; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /application/index/controller/Test.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\process\exception; 13 | 14 | 15 | use think\Process; 16 | 17 | class Failed extends \RuntimeException 18 | { 19 | 20 | private $process; 21 | 22 | public function __construct(Process $process) 23 | { 24 | if ($process->isSuccessful()) { 25 | throw new \InvalidArgumentException('Expected a failed process, but the given process was successful.'); 26 | } 27 | 28 | $error = sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText()); 29 | 30 | if (!$process->isOutputDisabled()) { 31 | $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput()); 32 | } 33 | 34 | parent::__construct($error); 35 | 36 | $this->process = $process; 37 | } 38 | 39 | public function getProcess() 40 | { 41 | return $this->process; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /public/weixin/cert/apiclient_cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEXzCCA8igAwIBAgIDEN9AMA0GCSqGSIb3DQEBBQUAMIGKMQswCQYDVQQGEwJD 3 | TjESMBAGA1UECBMJR3Vhbmdkb25nMREwDwYDVQQHEwhTaGVuemhlbjEQMA4GA1UE 4 | ChMHVGVuY2VudDEMMAoGA1UECxMDV1hHMRMwEQYDVQQDEwpNbXBheW1jaENBMR8w 5 | HQYJKoZIhvcNAQkBFhBtbXBheW1jaEB0ZW5jZW50MB4XDTE2MDIwMzExNDg1OVoX 6 | DTI2MDEzMTExNDg1OVowgY8xCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHdWFuZ2Rv 7 | bmcxETAPBgNVBAcTCFNoZW56aGVuMRAwDgYDVQQKEwdUZW5jZW50MQ4wDAYDVQQL 8 | EwVNTVBheTEkMCIGA1UEAxQb6Ieq5Yqo5YyW5rWL6K+V5ZWG5oi35ZCN56ewMREw 9 | DwYDVQQEEwgxMTM4NDEzMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB 10 | ALQ/qiPEwzmDLkWQhwA1Td6YQh1BxhgxH244rdpyfiiXv/m/QbYGfkJ27EZiNOkR 11 | tZg0kOh4XGfo99bQwia+SSxPsajtnTwbGOYPKRP4Xc44SlFR9n9v3N5XzLJSXZrv 12 | lKnz3Cf7PdHRTXxs0w0gsubMTu2P0MACLfUw11IPtGisx+SGMlgjGZ20q6suYF+R 13 | ydUTXvHelo9R/HFfyV3RPSZryOHP1CtKMh+H1DOwdwF+d/ZIY2nkdS9HBe3Q2QD1 14 | /Po6z1hD6LAnAdggGOyXjLNsSgkQwizQdf5Xc6xxIgLfEZlzHOM5ndLbLPovm+yP 15 | cilvm1qu7AeKs/qodj5FU9cCAwEAAaOCAUYwggFCMAkGA1UdEwQCMAAwLAYJYIZI 16 | AYb4QgENBB8WHSJDRVMtQ0EgR2VuZXJhdGUgQ2VydGlmaWNhdGUiMB0GA1UdDgQW 17 | BBSRQB0ev//y8tmCeOhM6YdhH88DGzCBvwYDVR0jBIG3MIG0gBQ+BSb2ImK0FVuI 18 | zWR+sNRip+WGdKGBkKSBjTCBijELMAkGA1UEBhMCQ04xEjAQBgNVBAgTCUd1YW5n 19 | ZG9uZzERMA8GA1UEBxMIU2hlbnpoZW4xEDAOBgNVBAoTB1RlbmNlbnQxDDAKBgNV 20 | BAsTA1dYRzETMBEGA1UEAxMKTW1wYXltY2hDQTEfMB0GCSqGSIb3DQEJARYQbW1w 21 | YXltY2hAdGVuY2VudIIJALtUlyu8AOhXMA4GA1UdDwEB/wQEAwIGwDAWBgNVHSUB 22 | Af8EDDAKBggrBgEFBQcDAjANBgkqhkiG9w0BAQUFAAOBgQADwihpkyMaJTaSII48 23 | fFz2QbuR14op8CDqYBfF1VKRUahqFWsNEJJ+3KgRLkphwfVWSa7z1Q9EiBCGpKTI 24 | ug7ER/ZPJUVRXZHbIkveGGV5PmBjAD544McjXHO8PGJ3AubD/iXFwYtHmLDwME8W 25 | 5nBNnaKkV4+uSPzg8UrBWbCfEw== 26 | -----END CERTIFICATE----- 27 | -------------------------------------------------------------------------------- /thinkphp/library/think/response/Json.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Response; 15 | 16 | class Json extends Response 17 | { 18 | // 输出参数 19 | protected $options = [ 20 | 'json_encode_param' => JSON_UNESCAPED_UNICODE, 21 | ]; 22 | 23 | protected $contentType = 'application/json'; 24 | 25 | /** 26 | * 处理数据 27 | * @access protected 28 | * @param mixed $data 要处理的数据 29 | * @return mixed 30 | * @throws \Exception 31 | */ 32 | protected function output($data) 33 | { 34 | try { 35 | // 返回JSON数据格式到客户端 包含状态信息 36 | $data = json_encode($data, $this->options['json_encode_param']); 37 | 38 | if ($data === false) { 39 | throw new \InvalidArgumentException(json_last_error_msg()); 40 | } 41 | 42 | return $data; 43 | } catch (\Exception $e) { 44 | if ($e->getPrevious()) { 45 | throw $e->getPrevious(); 46 | } 47 | throw $e; 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /application/bis/view/login/index.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/header" /} 3 | 4 |

商户登录系统

5 |
6 | 7 |
8 | 9 |
10 |
11 | 12 |
13 | 14 |
15 |
16 |
17 | 18 |
19 | 20 |
21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 | 30 | 31 |
32 |
33 |
34 |
35 |
36 | 37 | 38 | {include file="public/footer" /} -------------------------------------------------------------------------------- /application/index/view/public/nav.html: -------------------------------------------------------------------------------- 1 | 5 | 6 | -------------------------------------------------------------------------------- /application/admin/view/bis/apply.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/header" /} 3 | 4 | 5 |
6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {volist name="bis" id="vo"} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | {/volist} 33 | 34 | 35 |
ID商户名称法人联系电话申请时间状态操作
{$vo.id}{$vo.name}{$vo.faren}{$vo.faren_tel}{$vo.create_time|date="Y-m-d H:i",###}{$vo.status|status} 不通过
36 |
37 | {:pagination($bis)} 38 | 39 | 40 | {include file="public/footer" /} 41 | -------------------------------------------------------------------------------- /application/index/controller/Detail.php: -------------------------------------------------------------------------------- 1 | error('ID不合法'); 11 | } 12 | // 根据id查询商品的数据 13 | $deal = model('Deal')->get($id); 14 | //$bisId = $deal->bis_id; 15 | if(!$deal || $deal->status != 1) { 16 | $this->error('该商品不存在'); 17 | } 18 | // 获取分类信息 19 | $category = model('Category')->get($deal->category_id); 20 | // 获取分店信息 21 | $locations = model('BisLocation')->getNormalLocationsInId($deal->location_ids); 22 | $flag = 0; 23 | if($deal->start_time > time()) { 24 | $flag = 1; 25 | $dtime = $deal->start_time-time(); 26 | $timedata = ''; 27 | $d = floor($dtime/(3600*24)); // 0.6 0 1.2 1 28 | if($d) { 29 | $timedata .= $d . "天 "; 30 | } 31 | $h = floor($dtime%(3600*24)/3600); 32 | if($h) { 33 | $timedata .= $h . "小时 "; 34 | } 35 | $m = floor($dtime%(3600*24)%3600/60); 36 | if($h) { 37 | $timedata .= $m . "分 "; 38 | } 39 | $this->assign('timedata', $timedata); 40 | } 41 | return $this->fetch('', [ 42 | 'deal' => $deal, 43 | 'title' => $deal->name, 44 | 'category' => $category, 45 | 'locations' => $locations, 46 | 'overplus' => $deal->total_count-$deal->buy_count, 47 | 'flag' => $flag, 48 | 'mapstr' => $locations[0]['xpoint'].','.$locations[0]['ypoint'], 49 | ]); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /application/admin/view/public/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | {load href="__STATIC__/admin/hui/static/h-ui/css/H-ui.min.css" /} 17 | 18 | 19 | 20 | 21 | 22 | {load href="__STATIC__/admin/css/common.css" /} 23 | {load href="__STATIC__/admin/uploadify/uploadify.css" /} 24 | 28 | o2o平台 29 | 30 | 31 | -------------------------------------------------------------------------------- /application/bis/view/public/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | {load href="__STATIC__/admin/hui/static/h-ui/css/H-ui.min.css" /} 17 | 18 | 19 | 20 | 21 | 22 | {load href="__STATIC__/admin/css/common.css" /} 23 | {load href="__STATIC__/admin/uploadify/uploadify.css" /} 24 | 28 | o2o平台 29 | 30 | 31 | -------------------------------------------------------------------------------- /application/database.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return [ 13 | // 数据库类型 14 | 'type' => 'mysql', 15 | // 服务器地址 16 | 'hostname' => 'localhost', 17 | // 数据库名 18 | 'database' => 'imooc_o2o', 19 | // 用户名 20 | 'username' => 'root', 21 | // 密码 22 | 'password' => 'ljh19950615', 23 | // 端口 24 | 'hostport' => '3306', 25 | // 连接dsn 26 | 'dsn' => '', 27 | // 数据库连接参数 28 | 'params' => [], 29 | // 数据库编码默认采用utf8 30 | 'charset' => 'utf8', 31 | // 数据库表前缀 32 | 'prefix' => 'o2o_', 33 | // 数据库调试模式 34 | 'debug' => true, 35 | // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 36 | 'deploy' => 0, 37 | // 数据库读写是否分离 主从式有效 38 | 'rw_separate' => false, 39 | // 读写分离后 主服务器数量 40 | 'master_num' => 1, 41 | // 指定从服务器序号 42 | 'slave_no' => '', 43 | // 是否严格检查字段是否存在 44 | 'fields_strict' => true, 45 | // 数据集返回类型 array 数组 collection Collection对象 46 | 'resultset_type' => 'array', 47 | // 是否自动写入时间戳字段 48 | 'auto_timestamp' => false, 49 | // 是否需要进行SQL性能分析 50 | 'sql_explain' => false, 51 | ]; 52 | -------------------------------------------------------------------------------- /application/index/view/public/head.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {$title} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 | 44 |
45 |
-------------------------------------------------------------------------------- /thinkphp/library/think/exception/ThrowableError.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | class ThrowableError extends \ErrorException 15 | { 16 | public function __construct(\Throwable $e) 17 | { 18 | 19 | if ($e instanceof \ParseError) { 20 | $message = 'Parse error: ' . $e->getMessage(); 21 | $severity = E_PARSE; 22 | } elseif ($e instanceof \TypeError) { 23 | $message = 'Type error: ' . $e->getMessage(); 24 | $severity = E_RECOVERABLE_ERROR; 25 | } else { 26 | $message = 'Fatal error: ' . $e->getMessage(); 27 | $severity = E_ERROR; 28 | } 29 | 30 | parent::__construct( 31 | $message, 32 | $e->getCode(), 33 | $severity, 34 | $e->getFile(), 35 | $e->getLine() 36 | ); 37 | 38 | $this->setTrace($e->getTrace()); 39 | } 40 | 41 | protected function setTrace($trace) 42 | { 43 | $traceReflector = new \ReflectionProperty('Exception', 'trace'); 44 | $traceReflector->setAccessible(true); 45 | $traceReflector->setValue($this, $trace); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/Clear.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | namespace think\console\command; 12 | 13 | use think\console\Command; 14 | use think\console\Input; 15 | use think\console\input\Option; 16 | use think\console\Output; 17 | 18 | class Clear extends Command 19 | { 20 | protected function configure() 21 | { 22 | // 指令配置 23 | $this 24 | ->setName('clear') 25 | ->addOption('path', 'd', Option::VALUE_OPTIONAL, 'path to clear', null) 26 | ->setDescription('Clear runtime file'); 27 | } 28 | 29 | protected function execute(Input $input, Output $output) 30 | { 31 | $path = $input->getOption('path') ?: RUNTIME_PATH; 32 | $files = scandir($path); 33 | if ($files) { 34 | foreach ($files as $file) { 35 | if ('.' != $file && '..' != $file && is_dir($path . $file)) { 36 | array_map('unlink', glob($path . $file . '/*.*')); 37 | } elseif (is_file($path . $file)) { 38 | unlink($path . $file); 39 | } 40 | } 41 | } 42 | $output->writeln("Clear Successed"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /public/weixin/cert/apiclient_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC0P6ojxMM5gy5F 3 | kIcANU3emEIdQcYYMR9uOK3acn4ol7/5v0G2Bn5CduxGYjTpEbWYNJDoeFxn6PfW 4 | 0MImvkksT7Go7Z08GxjmDykT+F3OOEpRUfZ/b9zeV8yyUl2a75Sp89wn+z3R0U18 5 | bNMNILLmzE7tj9DAAi31MNdSD7RorMfkhjJYIxmdtKurLmBfkcnVE17x3paPUfxx 6 | X8ld0T0ma8jhz9QrSjIfh9QzsHcBfnf2SGNp5HUvRwXt0NkA9fz6Os9YQ+iwJwHY 7 | IBjsl4yzbEoJEMIs0HX+V3OscSIC3xGZcxzjOZ3S2yz6L5vsj3Ipb5taruwHirP6 8 | qHY+RVPXAgMBAAECggEAb+iLCLQUBTQV2WjW+GEf3JCpk6KPi9uLyRH1loe5HhjB 9 | PxzofkvfvgI5xaUZdo7hMQOJ6Fs5++WfYkawE//WTGWaRuhn07Z7KfLFrTlpfCxk 10 | r8J0iUB5X64hT6FlrlkK8s2NpWEOS6NoOVUTX7YqfLLiWgoNL/jqca2GMdPATa/V 11 | mZj/irYVBmkFbh7gUWWw7cYUwDJsc5jZkEB/wWwOHG8MzyMoOMttuX2Xt+5t36t7 12 | mon5a4u7zM7ctrRbONu3oXxmfqfhgvwgKKrcHOptjT3iF0DOoopGlkimRnVd672h 13 | 5CRzaBuV+71CrAYB0vE6WhhUQwnUylYUvFLqzR1EgQKBgQDYDkzPPNG6lJMto/4N 14 | GH3wtbI5Kad83eymQfeUQrtd8UUA7cYNWEXHZVWs+/fTu93DAIjOESoyWqpcyw4P 15 | P31CRT7I3fc6PIhEtnvscpK0ln+cq71QIX8Mcie5W3BuoIcTjvsPY3zM9pSZB9Re 16 | LkO9PY7MMRk9GMcsG+lSXN1clwKBgQDVkqX5M5scWpnO3kj0So6GyZScG2IWQ44C 17 | 0guTZh7dlmzhfwBmXh77sXYNFdIu2eGkGsPBRxqQl3QDdG6bSm2YqwF5VlplabnC 18 | q1oxHwt90u0L2441wXLWwquhrxvdlnQrJz0IqD476q6WqBeRxLGpIpkztOSwOK26 19 | 1GlkCtRqwQKBgBjKi0W8VNRz9+9kweH+zXSxZKHqha1uSZlKOH5qqdU9ug1BO1iM 20 | qHUYy5vtzaIeDHQzu37puU3N2X6MTjCxuE3CZFHoJlYoW/qGdfHLs8nE+x+fFTn8 21 | nfdvod9C/sOy58z2uxgo8kkSgjqNC3FDHcK5LYmAmMTJ8xC8oykwPrZBAoGAO4nc 22 | VzJ5xVfElRUGxYObZBwCH9rKZ2aBymt/6qGHbUKoK9zZ4a/Pd18rh85Tf9ghvTvw 23 | 4orN7w0pvGTTCNug3fSePpNCNA9bR9e5FwSOkY8hojKc3IOHXjN64WINpKJy1Czm 24 | KOmuH8n2ze0iVPK+jGYmy3FcZ3wFgpYAo3EZcoECgYBWlBWUK3CtT12uoRdepNWg 25 | DCPm0k7KDW71NqiXkA+jxGxsCcv4M3CuN2Xs//2dTWqErhWqMq7ASmfxumCmPHWs 26 | dmjya/fGc6G3IrZNj6/fxPrOLShHDBS1HP/9MmVTBd0d39CaSKBaMzvU3DaJu0rq 27 | d0IqLGwMv/t411orp77J1Q== 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /public/weixin/lib/WxPay.Config.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command\make; 13 | 14 | use think\Config; 15 | use think\console\command\Make; 16 | use think\console\input\Option; 17 | 18 | class Controller extends Make 19 | { 20 | 21 | protected $type = "Controller"; 22 | 23 | protected function configure() 24 | { 25 | parent::configure(); 26 | $this->setName('make:controller') 27 | ->addOption('plain', null, Option::VALUE_NONE, 'Generate an empty controller class.') 28 | ->setDescription('Create a new resource controller class'); 29 | } 30 | 31 | protected function getStub() 32 | { 33 | if ($this->input->getOption('plain')) { 34 | return __DIR__ . '/stubs/controller.plain.stub'; 35 | } 36 | 37 | return __DIR__ . '/stubs/controller.stub'; 38 | } 39 | 40 | protected function getClassName($name) 41 | { 42 | return parent::getClassName($name) . (Config::get('controller_suffix') ? ucfirst(Config::get('url_controller_layer')) : ''); 43 | } 44 | 45 | protected function getNamespace($appNamespace, $module) 46 | { 47 | return parent::getNamespace($appNamespace, $module) . '\controller'; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /thinkphp/library/think/exception/ErrorException.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\exception; 13 | 14 | use think\Exception; 15 | 16 | /** 17 | * ThinkPHP错误异常 18 | * 主要用于封装 set_error_handler 和 register_shutdown_function 得到的错误 19 | * 除开从 think\Exception 继承的功能 20 | * 其他和PHP系统\ErrorException功能基本一样 21 | */ 22 | class ErrorException extends Exception 23 | { 24 | /** 25 | * 用于保存错误级别 26 | * @var integer 27 | */ 28 | protected $severity; 29 | 30 | /** 31 | * 错误异常构造函数 32 | * @param integer $severity 错误级别 33 | * @param string $message 错误详细信息 34 | * @param string $file 出错文件路径 35 | * @param integer $line 出错行号 36 | * @param array $context 错误上下文,会包含错误触发处作用域内所有变量的数组 37 | */ 38 | public function __construct($severity, $message, $file, $line, array $context = []) 39 | { 40 | $this->severity = $severity; 41 | $this->message = $message; 42 | $this->file = $file; 43 | $this->line = $line; 44 | $this->code = 0; 45 | 46 | empty($context) || $this->setData('Error Context', $context); 47 | } 48 | 49 | /** 50 | * 获取错误级别 51 | * @return integer 错误级别 52 | */ 53 | final public function getSeverity() 54 | { 55 | return $this->severity; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/output/question/Confirmation.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\output\question; 13 | 14 | use think\console\output\Question; 15 | 16 | class Confirmation extends Question 17 | { 18 | 19 | private $trueAnswerRegex; 20 | 21 | /** 22 | * 构造方法 23 | * @param string $question 问题 24 | * @param bool $default 默认答案 25 | * @param string $trueAnswerRegex 验证正则 26 | */ 27 | public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i') 28 | { 29 | parent::__construct($question, (bool) $default); 30 | 31 | $this->trueAnswerRegex = $trueAnswerRegex; 32 | $this->setNormalizer($this->getDefaultNormalizer()); 33 | } 34 | 35 | /** 36 | * 获取默认的答案回调 37 | * @return callable 38 | */ 39 | private function getDefaultNormalizer() 40 | { 41 | $default = $this->getDefault(); 42 | $regex = $this->trueAnswerRegex; 43 | 44 | return function ($answer) use ($default, $regex) { 45 | if (is_bool($answer)) { 46 | return $answer; 47 | } 48 | 49 | $answerIsTrue = (bool) preg_match($regex, $answer); 50 | if (false === $default) { 51 | return $answer && $answerIsTrue; 52 | } 53 | 54 | return !$answer || $answerIsTrue; 55 | }; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/Build.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command; 13 | 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\input\Option; 17 | use think\console\Output; 18 | 19 | class Build extends Command 20 | { 21 | 22 | /** 23 | * {@inheritdoc} 24 | */ 25 | protected function configure() 26 | { 27 | $this->setName('build') 28 | ->setDefinition([ 29 | new Option('config', null, Option::VALUE_OPTIONAL, "build.php path"), 30 | new Option('module', null, Option::VALUE_OPTIONAL, "module name"), 31 | ]) 32 | ->setDescription('Build Application Dirs'); 33 | } 34 | 35 | protected function execute(Input $input, Output $output) 36 | { 37 | if ($input->hasOption('module')) { 38 | \think\Build::module($input->getOption('module')); 39 | $output->writeln("Successed"); 40 | return; 41 | } 42 | 43 | if ($input->hasOption('config')) { 44 | $build = include $input->getOption('config'); 45 | } else { 46 | $build = include APP_PATH . 'build.php'; 47 | } 48 | if (empty($build)) { 49 | $output->writeln("Build Config Is Empty"); 50 | return; 51 | } 52 | \think\Build::run($build); 53 | $output->writeln("Successed"); 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /public/weixin/example/orderquery.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 微信支付样例-订单查询 6 | 7 | $value){ 20 | echo "$key : $value
"; 21 | } 22 | } 23 | 24 | 25 | if(isset($_REQUEST["transaction_id"]) && $_REQUEST["transaction_id"] != ""){ 26 | $transaction_id = $_REQUEST["transaction_id"]; 27 | $input = new WxPayOrderQuery(); 28 | $input->SetTransaction_id($transaction_id); 29 | printf_info(WxPayApi::orderQuery($input)); 30 | exit(); 31 | } 32 | 33 | if(isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != ""){ 34 | $out_trade_no = $_REQUEST["out_trade_no"]; 35 | $input = new WxPayOrderQuery(); 36 | $input->SetOut_trade_no($out_trade_no); 37 | printf_info(WxPayApi::orderQuery($input)); 38 | exit(); 39 | } 40 | ?> 41 | 42 |
43 |
微信订单号和商户订单号选少填一个,微信订单号优先:

44 |
微信订单号:

45 |

46 |
商户订单号:

47 |

48 |
49 | 50 |
51 |
52 | 53 | -------------------------------------------------------------------------------- /public/weixin/example/native.php: -------------------------------------------------------------------------------- 1 | GetPrePayUrl("123456789"); 21 | 22 | //模式二 23 | /** 24 | * 流程: 25 | * 1、调用统一下单,取得code_url,生成二维码 26 | * 2、用户扫描二维码,进行支付 27 | * 3、支付完成之后,微信服务器会通知支付成功 28 | * 4、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php) 29 | */ 30 | $input = new WxPayUnifiedOrder(); 31 | $input->SetBody("test"); 32 | $input->SetAttach("test"); 33 | $input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis")); 34 | $input->SetTotal_fee("1"); 35 | $input->SetTime_start(date("YmdHis")); 36 | $input->SetTime_expire(date("YmdHis", time() + 600)); 37 | $input->SetGoods_tag("test"); 38 | $input->SetNotify_url("/index.php/index/weixinpay/notify"); 39 | $input->SetTrade_type("NATIVE"); 40 | $input->SetProduct_id("123456789"); 41 | $result = $notify->GetPayUrl($input); 42 | $url2 = $result["code_url"]; 43 | ?> 44 | 45 | 46 | 47 | 48 | 49 | 微信支付样例-退款 50 | 51 | 52 |
扫描支付模式一

53 | 模式一扫码支付 54 |


55 |
扫描支付模式二

56 | 模式二扫码支付 57 | 58 | 59 | -------------------------------------------------------------------------------- /thinkphp/library/think/process/exception/Timeout.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\process\exception; 13 | 14 | use think\Process; 15 | 16 | class Timeout extends \RuntimeException 17 | { 18 | 19 | const TYPE_GENERAL = 1; 20 | const TYPE_IDLE = 2; 21 | 22 | private $process; 23 | private $timeoutType; 24 | 25 | public function __construct(Process $process, $timeoutType) 26 | { 27 | $this->process = $process; 28 | $this->timeoutType = $timeoutType; 29 | 30 | parent::__construct(sprintf('The process "%s" exceeded the timeout of %s seconds.', $process->getCommandLine(), $this->getExceededTimeout())); 31 | } 32 | 33 | public function getProcess() 34 | { 35 | return $this->process; 36 | } 37 | 38 | public function isGeneralTimeout() 39 | { 40 | return $this->timeoutType === self::TYPE_GENERAL; 41 | } 42 | 43 | public function isIdleTimeout() 44 | { 45 | return $this->timeoutType === self::TYPE_IDLE; 46 | } 47 | 48 | public function getExceededTimeout() 49 | { 50 | switch ($this->timeoutType) { 51 | case self::TYPE_GENERAL: 52 | return $this->process->getTimeout(); 53 | 54 | case self::TYPE_IDLE: 55 | return $this->process->getIdleTimeout(); 56 | 57 | default: 58 | throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType)); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /public/weixin/lib/WxPay.Notify.php: -------------------------------------------------------------------------------- 1 | SetReturn_code("FAIL"); 22 | $this->SetReturn_msg($msg); 23 | $this->ReplyNotify(false); 24 | return; 25 | } else { 26 | //该分支在成功回调到NotifyCallBack方法,处理完成之后流程 27 | $this->SetReturn_code("SUCCESS"); 28 | $this->SetReturn_msg("OK"); 29 | } 30 | $this->ReplyNotify($needSign); 31 | } 32 | 33 | /** 34 | * 35 | * 回调方法入口,子类可重写该方法 36 | * 注意: 37 | * 1、微信回调超时时间为2s,建议用户使用异步处理流程,确认成功之后立刻回复微信服务器 38 | * 2、微信服务器在调用失败或者接到回包为非确认包的时候,会发起重试,需确保你的回调是可以重入 39 | * @param array $data 回调解释出的参数 40 | * @param string $msg 如果回调处理失败,可以将错误信息输出到该方法 41 | * @return true回调出来完成不需要继续回调,false回调处理未完成需要继续回调 42 | */ 43 | public function NotifyProcess($data, &$msg) 44 | { 45 | //TODO 用户基础该类之后需要重写该方法,成功的时候返回true,失败返回false 46 | return true; 47 | } 48 | 49 | /** 50 | * 51 | * notify回调方法,该方法中需要赋值需要输出的参数,不可重写 52 | * @param array $data 53 | * @return true回调出来完成不需要继续回调,false回调处理未完成需要继续回调 54 | */ 55 | final public function NotifyCallBack($data) 56 | { 57 | $msg = "OK"; 58 | $result = $this->NotifyProcess($data, $msg); 59 | 60 | if($result == true){ 61 | $this->SetReturn_code("SUCCESS"); 62 | $this->SetReturn_msg("OK"); 63 | } else { 64 | $this->SetReturn_code("FAIL"); 65 | $this->SetReturn_msg($msg); 66 | } 67 | return $result; 68 | } 69 | 70 | /** 71 | * 72 | * 回复通知 73 | * @param bool $needSign 是否需要签名输出 74 | */ 75 | final private function ReplyNotify($needSign = true) 76 | { 77 | //如果需要签名 78 | if($needSign == true && 79 | $this->GetReturn_code($return_code) == "SUCCESS") 80 | { 81 | $this->SetSign(); 82 | } 83 | WxpayApi::replyNotify($this->ToXml()); 84 | } 85 | } -------------------------------------------------------------------------------- /public/weixin/example/micropay.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 微信支付样例-查退款单 6 | 7 | $value){ 20 | echo "$key : $value
"; 21 | } 22 | } 23 | 24 | if(isset($_REQUEST["auth_code"]) && $_REQUEST["auth_code"] != ""){ 25 | $auth_code = $_REQUEST["auth_code"]; 26 | $input = new WxPayMicroPay(); 27 | $input->SetAuth_code($auth_code); 28 | $input->SetBody("刷卡测试样例-支付"); 29 | $input->SetTotal_fee("1"); 30 | $input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis")); 31 | 32 | $microPay = new MicroPay(); 33 | printf_info($microPay->pay($input)); 34 | } 35 | 36 | /** 37 | * 注意: 38 | * 1、提交被扫之后,返回系统繁忙、用户输入密码等错误信息时需要循环查单以确定是否支付成功 39 | * 2、多次(一半10次)确认都未明确成功时需要调用撤单接口撤单,防止用户重复支付 40 | */ 41 | 42 | ?> 43 | 44 |
45 |
商品描述:

46 |

47 |
支付金额:

48 |

49 |
授权码:

50 |

51 |
52 | 53 |
54 |
55 | 56 | -------------------------------------------------------------------------------- /application/admin/view/featured/index.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/header" /} 3 | 4 | 5 |
6 |
7 |
8 | 9 |
10 | 17 | 18 |
19 | 20 | 21 |
22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | {volist name="results" id="vo"} 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | {/volist} 47 | 48 | 49 |
ID标题地址新增时间发布状态操作
{$vo.id}{$vo.title}{$vo.url}{$vo.create_time|date="y-m-d H:i", ###}{$vo.status|status}
50 |
51 | {:pagination($results)} 52 |
53 | 54 | {include file="public/footer" /} 55 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/builder/Mysql.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\builder; 13 | 14 | use think\db\Builder; 15 | 16 | /** 17 | * mysql数据库驱动 18 | */ 19 | class Mysql extends Builder 20 | { 21 | protected $updateSql = 'UPDATE %TABLE% %JOIN% SET %SET% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%'; 22 | 23 | /** 24 | * 字段和表名处理 25 | * @access protected 26 | * @param string $key 27 | * @param array $options 28 | * @return string 29 | */ 30 | protected function parseKey($key, $options = []) 31 | { 32 | $key = trim($key); 33 | if (strpos($key, '$.') && false === strpos($key, '(')) { 34 | // JSON字段支持 35 | list($field, $name) = explode('$.', $key); 36 | $key = 'json_extract(' . $field . ', \'$.' . $name . '\')'; 37 | } elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { 38 | list($table, $key) = explode('.', $key, 2); 39 | if (isset($options['alias'][$table])) { 40 | $table = $options['alias'][$table]; 41 | } 42 | } 43 | if (!preg_match('/[,\'\"\*\(\)`.\s]/', $key)) { 44 | $key = '`' . $key . '`'; 45 | } 46 | if (isset($table)) { 47 | $key = '`' . $table . '`.' . $key; 48 | } 49 | return $key; 50 | } 51 | 52 | /** 53 | * 随机排序 54 | * @access protected 55 | * @return string 56 | */ 57 | protected function parseRand() 58 | { 59 | return 'rand()'; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /thinkphp/library/think/response/Jsonp.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\response; 13 | 14 | use think\Request; 15 | use think\Response; 16 | 17 | class Jsonp extends Response 18 | { 19 | // 输出参数 20 | protected $options = [ 21 | 'var_jsonp_handler' => 'callback', 22 | 'default_jsonp_handler' => 'jsonpReturn', 23 | 'json_encode_param' => JSON_UNESCAPED_UNICODE, 24 | ]; 25 | 26 | protected $contentType = 'application/javascript'; 27 | 28 | /** 29 | * 处理数据 30 | * @access protected 31 | * @param mixed $data 要处理的数据 32 | * @return mixed 33 | * @throws \Exception 34 | */ 35 | protected function output($data) 36 | { 37 | try { 38 | // 返回JSON数据格式到客户端 包含状态信息 [当url_common_param为false时是无法获取到$_GET的数据的,故使用Request来获取] 39 | $var_jsonp_handler = Request::instance()->param($this->options['var_jsonp_handler'], ""); 40 | $handler = !empty($var_jsonp_handler) ? $var_jsonp_handler : $this->options['default_jsonp_handler']; 41 | 42 | $data = json_encode($data, $this->options['json_encode_param']); 43 | 44 | if ($data === false) { 45 | throw new \InvalidArgumentException(json_last_error_msg()); 46 | } 47 | 48 | $data = $handler . '(' . $data . ');'; 49 | return $data; 50 | } catch (\Exception $e) { 51 | if ($e->getPrevious()) { 52 | throw $e->getPrevious(); 53 | } 54 | throw $e; 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/builder/Sqlite.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\builder; 13 | 14 | use think\db\Builder; 15 | 16 | /** 17 | * Sqlite数据库驱动 18 | */ 19 | class Sqlite extends Builder 20 | { 21 | 22 | /** 23 | * limit 24 | * @access public 25 | * @return string 26 | */ 27 | public function parseLimit($limit) 28 | { 29 | $limitStr = ''; 30 | if (!empty($limit)) { 31 | $limit = explode(',', $limit); 32 | if (count($limit) > 1) { 33 | $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; 34 | } else { 35 | $limitStr .= ' LIMIT ' . $limit[0] . ' '; 36 | } 37 | } 38 | return $limitStr; 39 | } 40 | 41 | /** 42 | * 随机排序 43 | * @access protected 44 | * @return string 45 | */ 46 | protected function parseRand() 47 | { 48 | return 'RANDOM()'; 49 | } 50 | 51 | /** 52 | * 字段和表名处理 53 | * @access protected 54 | * @param string $key 55 | * @param array $options 56 | * @return string 57 | */ 58 | protected function parseKey($key, $options = []) 59 | { 60 | $key = trim($key); 61 | if (strpos($key, '.')) { 62 | list($table, $key) = explode('.', $key, 2); 63 | if (isset($options['alias'][$table])) { 64 | $table = $options['alias'][$table]; 65 | } 66 | } 67 | if (isset($table)) { 68 | $key = $table . '.' . $key; 69 | } 70 | return $key; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /thinkphp/tpl/dispatch_jump.tpl: -------------------------------------------------------------------------------- 1 | {__NOLAYOUT__} 2 | 3 | 4 | 5 | 跳转提示 6 | 16 | 17 | 18 |
19 | 20 | 21 |

:)

22 |

23 | 24 | 25 |

:(

26 |

27 | 28 | 29 |

30 |

31 | 页面自动 跳转 等待时间: 32 |

33 |
34 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /runtime/temp/50386a63f26ecd5d0b88b2316bbc34b5.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 跳转提示 7 | 17 | 18 | 19 |
20 | 21 |

:)

22 |

23 | 24 |

:(

25 |

26 | 27 |

28 |

29 | 页面自动 跳转 等待时间: 30 |

31 |
32 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /application/index/controller/Order.php: -------------------------------------------------------------------------------- 1 | getLoginUser(); 10 | if(!$user) { 11 | $this->error('请登录','user/login'); 12 | } 13 | 14 | $id = input('get.id', 0, 'intval'); 15 | if(!$id) { 16 | $this->error('参数不合法'); 17 | } 18 | $dealCount = input('get.deal_count', 0, 'intval'); 19 | $totalPrice = input('get.total_price'); 20 | 21 | $deal = model('Deal')->find($id); 22 | if(!$deal || $deal->status != 1) { 23 | $this->error('商品不存在'); 24 | 25 | } 26 | 27 | if(empty($_SERVER['HTTP_REFERER'])) { 28 | $this->error('请求不合法'); 29 | } 30 | 31 | $orderSn = setOrderSn(); 32 | // 组装入库数据 33 | $data = [ 34 | 'out_trade_no' => $orderSn, 35 | 'user_id' => $user->id, 36 | 'username' => $user->username, 37 | 'deal_id' => $id, 38 | 'deal_count' => $dealCount, 39 | 'total_price' => $totalPrice, 40 | 'referer' => $_SERVER['HTTP_REFERER'] 41 | ]; 42 | try { 43 | $orderId = model('Order')->add($data); 44 | } catch(\Exception $e) { 45 | $this->error('订单处理失败'); 46 | } 47 | 48 | $this->redirect(url('pay/index',['id'=>$orderId])); 49 | 50 | 51 | } 52 | public function confirm() { 53 | if(!$this->getLoginUser()) { 54 | $this->error('请登录','user/login'); 55 | } 56 | // 57 | $id = input('get.id', 0, 'intval'); 58 | if(!$id) { 59 | $this->error('参数不合法'); 60 | } 61 | $count = input('get.count', 1, 'intval'); 62 | 63 | $deal = model('Deal')->find($id); 64 | //echo model('Deal')->getLastSql();exit; 65 | if(!$deal || $deal->status != 1) { 66 | $this->error('商品不存在'); 67 | 68 | } 69 | $deal = $deal->toArray(); 70 | 71 | 72 | return $this->fetch('',[ 73 | 'controler' => 'pay', 74 | 'count' => $count, 75 | 'deal' => $deal, 76 | ]); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /public/weixin/example/native_notify.php: -------------------------------------------------------------------------------- 1 | SetBody("test"); 20 | $input->SetAttach("test"); 21 | $input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis")); 22 | $input->SetTotal_fee("1"); 23 | $input->SetTime_start(date("YmdHis")); 24 | $input->SetTime_expire(date("YmdHis", time() + 600)); 25 | $input->SetGoods_tag("test"); 26 | $input->SetNotify_url("http://paysdk.weixin.qq.com/example/notify.php"); 27 | $input->SetTrade_type("NATIVE"); 28 | $input->SetOpenid($openId); 29 | $input->SetProduct_id($product_id); 30 | $result = WxPayApi::unifiedOrder($input); 31 | Log::DEBUG("unifiedorder:" . json_encode($result)); 32 | return $result; 33 | } 34 | 35 | public function NotifyProcess($data, &$msg) 36 | { 37 | //echo "处理回调"; 38 | Log::DEBUG("call back:" . json_encode($data)); 39 | 40 | if(!array_key_exists("openid", $data) || 41 | !array_key_exists("product_id", $data)) 42 | { 43 | $msg = "回调数据异常"; 44 | return false; 45 | } 46 | 47 | $openid = $data["openid"]; 48 | $product_id = $data["product_id"]; 49 | 50 | //统一下单 51 | $result = $this->unifiedorder($openid, $product_id); 52 | if(!array_key_exists("appid", $result) || 53 | !array_key_exists("mch_id", $result) || 54 | !array_key_exists("prepay_id", $result)) 55 | { 56 | $msg = "统一下单失败"; 57 | return false; 58 | } 59 | 60 | $this->SetData("appid", $result["appid"]); 61 | $this->SetData("mch_id", $result["mch_id"]); 62 | $this->SetData("nonce_str", WxPayApi::getNonceStr()); 63 | $this->SetData("prepay_id", $result["prepay_id"]); 64 | $this->SetData("result_code", "SUCCESS"); 65 | $this->SetData("err_code_des", "OK"); 66 | return true; 67 | } 68 | } 69 | 70 | Log::DEBUG("begin notify!"); 71 | $notify = new NativeNotifyCallBack(); 72 | $notify->Handle(true); 73 | -------------------------------------------------------------------------------- /thinkphp/library/think/template/driver/File.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\template\driver; 13 | 14 | use think\Exception; 15 | 16 | class File 17 | { 18 | /** 19 | * 写入编译缓存 20 | * @param string $cacheFile 缓存的文件名 21 | * @param string $content 缓存的内容 22 | * @return void|array 23 | */ 24 | public function write($cacheFile, $content) 25 | { 26 | // 检测模板目录 27 | $dir = dirname($cacheFile); 28 | if (!is_dir($dir)) { 29 | mkdir($dir, 0755, true); 30 | } 31 | // 生成模板缓存文件 32 | if (false === file_put_contents($cacheFile, $content)) { 33 | throw new Exception('cache write error:' . $cacheFile, 11602); 34 | } 35 | } 36 | 37 | /** 38 | * 读取编译编译 39 | * @param string $cacheFile 缓存的文件名 40 | * @param array $vars 变量数组 41 | * @return void 42 | */ 43 | public function read($cacheFile, $vars = []) 44 | { 45 | if (!empty($vars) && is_array($vars)) { 46 | // 模板阵列变量分解成为独立变量 47 | extract($vars, EXTR_OVERWRITE); 48 | } 49 | //载入模版缓存文件 50 | include $cacheFile; 51 | } 52 | 53 | /** 54 | * 检查编译缓存是否有效 55 | * @param string $cacheFile 缓存的文件名 56 | * @param int $cacheTime 缓存时间 57 | * @return boolean 58 | */ 59 | public function check($cacheFile, $cacheTime) 60 | { 61 | // 缓存文件不存在, 直接返回false 62 | if (!file_exists($cacheFile)) { 63 | return false; 64 | } 65 | if (0 != $cacheTime && $_SERVER['REQUEST_TIME'] > filemtime($cacheFile) + $cacheTime) { 66 | // 缓存是否在有效期 67 | return false; 68 | } 69 | return true; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /application/index/controller/Pay.php: -------------------------------------------------------------------------------- 1 | getLoginUser()) { 15 | $this->error('请登录', 'user/login'); 16 | } 17 | $orderId = input('get.id', 0, 'intval'); 18 | if(empty($orderId)) { 19 | $this->error('请求不合法'); 20 | } 21 | $order = model('Order')->get($orderId); 22 | if(empty($order) || $order->status != 1 || $order->pay_status !=0 ) { 23 | $this->error('无法进行该项操作'); 24 | } 25 | // 严格判定 订单是否 是用户 本人 26 | if($order->username != $this->getLoginUser()->username) { 27 | $this->error('不是你的订单你瞎点个啥,做人要厚道'); 28 | } 29 | $deal = model('Deal')->get($order->deal_id); 30 | 31 | // 生成 二维码 32 | $notify = new NativePay(); 33 | $input = new WxPayUnifiedOrder(); 34 | $input->setBody($deal->name); 35 | $input->setAttach($deal->name); 36 | $input->setOutTradeNo($order->out_trade_no); 37 | $input->setTotalFee($order->total_price*100); 38 | $input->setTimeStart(date("YmdHis")); 39 | $input->setTimeExpire(date("YmdHis", time() + 600)); 40 | $input->setGoodsTag("QRCode"); 41 | $input->setNotifyUrl("http://139.199.7.39/index.php/index/weixinpay/notify"); 42 | $input->setTradeType("NATIVE"); 43 | $input->setProductId($order->deal_id); 44 | $result = $notify->getPayUrl($input); 45 | if(empty($result["code_url"])) { 46 | $url = ''; 47 | }else { 48 | $url = $result["code_url"]; 49 | } 50 | 51 | return $this->fetch('', [ 52 | 'deal' => $deal, 53 | 'order' => $order, 54 | 'url' => $url, 55 | ]); 56 | // 调取微信支付的 二维码 57 | //return '订单处理成功'; 58 | } 59 | 60 | public function paysuccess() 61 | { 62 | 63 | if(!$this->getLoginUser()) { 64 | $this->error('请登录', 'user/login'); 65 | } 66 | 67 | return $this->fetch(); 68 | 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /thinkphp/library/think/db/builder/Pgsql.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\db\builder; 13 | 14 | use think\db\Builder; 15 | 16 | /** 17 | * Pgsql数据库驱动 18 | */ 19 | class Pgsql extends Builder 20 | { 21 | 22 | /** 23 | * limit分析 24 | * @access protected 25 | * @param mixed $limit 26 | * @return string 27 | */ 28 | public function parseLimit($limit) 29 | { 30 | $limitStr = ''; 31 | if (!empty($limit)) { 32 | $limit = explode(',', $limit); 33 | if (count($limit) > 1) { 34 | $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; 35 | } else { 36 | $limitStr .= ' LIMIT ' . $limit[0] . ' '; 37 | } 38 | } 39 | return $limitStr; 40 | } 41 | 42 | /** 43 | * 字段和表名处理 44 | * @access protected 45 | * @param string $key 46 | * @param array $options 47 | * @return string 48 | */ 49 | protected function parseKey($key, $options = []) 50 | { 51 | $key = trim($key); 52 | if (strpos($key, '$.') && false === strpos($key, '(')) { 53 | // JSON字段支持 54 | list($field, $name) = explode('$.', $key); 55 | $key = $field . '->>\'' . $name . '\''; 56 | } elseif (strpos($key, '.')) { 57 | list($table, $key) = explode('.', $key, 2); 58 | if (isset($options['alias'][$table])) { 59 | $table = $options['alias'][$table]; 60 | } 61 | } 62 | if (isset($table)) { 63 | $key = $table . '.' . $key; 64 | } 65 | return $key; 66 | } 67 | 68 | /** 69 | * 随机排序 70 | * @access protected 71 | * @return string 72 | */ 73 | protected function parseRand() 74 | { 75 | return 'RANDOM()'; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/Help.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command; 13 | 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\input\Argument as InputArgument; 17 | use think\console\input\Option as InputOption; 18 | use think\console\Output; 19 | use think\console\helper\Descriptor as DescriptorHelper; 20 | 21 | class Help extends Command 22 | { 23 | 24 | private $command; 25 | 26 | /** 27 | * {@inheritdoc} 28 | */ 29 | protected function configure() 30 | { 31 | $this->ignoreValidationErrors(); 32 | 33 | $this->setName('help')->setDefinition([ 34 | new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), 35 | new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), 36 | ])->setDescription('Displays help for a command')->setHelp(<<%command.name% command displays help for a given command: 38 | 39 | php %command.full_name% list 40 | 41 | To display the list of available commands, please use the list command. 42 | EOF 43 | ); 44 | } 45 | 46 | /** 47 | * Sets the command. 48 | * @param Command $command The command to set 49 | */ 50 | public function setCommand(Command $command) 51 | { 52 | $this->command = $command; 53 | } 54 | 55 | /** 56 | * {@inheritdoc} 57 | */ 58 | protected function execute(Input $input, Output $output) 59 | { 60 | if (null === $this->command) { 61 | $this->command = $this->getConsole()->find($input->getArgument('command_name')); 62 | } 63 | 64 | $output->describe($this->command, [ 65 | 'raw_text' => $input->getOption('raw'), 66 | ]); 67 | 68 | $this->command = null; 69 | } 70 | } -------------------------------------------------------------------------------- /application/common/model/Deal.php: -------------------------------------------------------------------------------- 1 | 'desc']; 12 | 13 | $result = $this->where($data) 14 | ->order($order) 15 | ->paginate(); 16 | 17 | //echo $this->getLastSql(); 18 | return $result; 19 | } 20 | 21 | public function getApplyDeals($data = []) { 22 | $data['status'] = 0; 23 | $order = ['id'=>'desc']; 24 | 25 | $result = $this->where($data) 26 | ->order($order) 27 | ->paginate(); 28 | 29 | //echo $this->getLastSql(); 30 | return $result; 31 | } 32 | 33 | /** 34 | * 根据分类 以及 城市来获取 商品数据 35 | * @param $id 分类 36 | * @param $cityId 城市 37 | * @param int $limit 条数 38 | */ 39 | public function getNormalDealByCategoryCityId($id, $cityId, $limit=10) { 40 | $data = [ 41 | 'end_time' => ['gt', time()], 42 | 'category_id' => $id, 43 | 'city_id' => $cityId, 44 | 'status' => 1, 45 | ]; 46 | 47 | $order = [ 48 | 'listorder'=>'desc', 49 | 'id'=>'desc', 50 | ]; 51 | 52 | $result = $this->where($data) 53 | ->order($order); 54 | if($limit) { 55 | $result = $result->limit($limit); 56 | } 57 | return $result->select(); 58 | } 59 | 60 | public function getDealByConditions($data=[], $orders) { 61 | if(!empty($orders['order_sales'])) { 62 | $order['buy_count'] = 'desc'; 63 | } 64 | if(!empty($orders['order_price'])) { 65 | $order['current_price'] = 'desc'; 66 | } 67 | if(!empty($orders['order_time'])) { 68 | $order['create_time'] = 'desc'; 69 | } 70 | $order['id'] = 'desc'; 71 | 72 | 73 | $datas[] = ' end_time> '.time(); 74 | $datas[] = ' status= 1'; 75 | 76 | if(!empty($data['se_category_id'])) { 77 | 78 | $datas[]="find_in_set(".$data['se_category_id'].",se_category_id)"; 79 | } 80 | if(!empty($data['category_id'])) { 81 | 82 | $datas[]="category_id = ".$data['category_id']; 83 | } 84 | if(!empty($data['city_id'])) { 85 | 86 | $datas[]="city_id = ".$data['city_id']; 87 | } 88 | 89 | $result = $this->where(implode(' AND ',$datas)) 90 | ->order($order) 91 | ->paginate(); 92 | 93 | return $result; 94 | } 95 | 96 | 97 | public function updateBuyCountById($id, $buyCount) { 98 | return $this->where(['id' => $id])->setInc('buy_count', $buyCount); 99 | 100 | } 101 | } -------------------------------------------------------------------------------- /application/admin/view/category/index.html: -------------------------------------------------------------------------------- 1 | 2 | {include file="public/header" /} 3 | 4 | 5 |
6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | {volist name="categorys" id="vo"} 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | {/volist} 34 | 35 |
ID分类排序序号新增时间发布状态操作
{$vo.id}{$vo.name}{$vo.create_time|date="y-m-d h:i", ###}{$vo.status|status}获取子栏目
36 |
37 |
38 | {:pagination($categorys)} 39 | 40 | {include file="public/footer" /} 41 | 46 | 47 | -------------------------------------------------------------------------------- /application/index/view/user/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 注册 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
    18 |
  • logo
  • 19 |
  • 20 |
  • 21 |
22 | 26 |
27 | 28 |
29 |
30 |

31 | 32 | 33 |

34 |

35 | 36 | 37 |

38 | 39 |

40 | 41 | 42 |

43 |

44 | 45 | 46 |

47 |

48 | 49 | 50 |

{:captcha_img()}
51 |

52 | 53 |

54 | 55 |

56 |
57 | 58 |
59 | 60 |
61 |
62 |
2016 ©Baidu
63 |
64 |
65 |
66 | 67 | -------------------------------------------------------------------------------- /thinkphp/library/think/console/command/Lists.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\console\command; 13 | 14 | use think\console\Command; 15 | use think\console\Input; 16 | use think\console\Output; 17 | use think\console\input\Argument as InputArgument; 18 | use think\console\input\Option as InputOption; 19 | use think\console\input\Definition as InputDefinition; 20 | 21 | class Lists extends Command 22 | { 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | protected function configure() 28 | { 29 | $this->setName('list')->setDefinition($this->createDefinition())->setDescription('Lists commands')->setHelp(<<%command.name% command lists all commands: 31 | 32 | php %command.full_name% 33 | 34 | You can also display the commands for a specific namespace: 35 | 36 | php %command.full_name% test 37 | 38 | It's also possible to get raw list of commands (useful for embedding command runner): 39 | 40 | php %command.full_name% --raw 41 | EOF 42 | ); 43 | } 44 | 45 | /** 46 | * {@inheritdoc} 47 | */ 48 | public function getNativeDefinition() 49 | { 50 | return $this->createDefinition(); 51 | } 52 | 53 | /** 54 | * {@inheritdoc} 55 | */ 56 | protected function execute(Input $input, Output $output) 57 | { 58 | $output->describe($this->getConsole(), [ 59 | 'raw_text' => $input->getOption('raw'), 60 | 'namespace' => $input->getArgument('namespace'), 61 | ]); 62 | } 63 | 64 | /** 65 | * {@inheritdoc} 66 | */ 67 | private function createDefinition() 68 | { 69 | return new InputDefinition([ 70 | new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), 71 | new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list') 72 | ]); 73 | } 74 | } -------------------------------------------------------------------------------- /thinkphp/library/think/paginator/Collection.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\paginator; 13 | 14 | use Exception; 15 | use think\Paginator; 16 | 17 | /** 18 | * Class Collection 19 | * @package think\paginator 20 | * @method integer total() 21 | * @method integer listRows() 22 | * @method integer currentPage() 23 | * @method string render() 24 | * @method Paginator fragment($fragment) 25 | * @method Paginator appends($key, $value) 26 | * @method integer lastPage() 27 | * @method boolean hasPages() 28 | */ 29 | class Collection extends \think\Collection 30 | { 31 | 32 | /** @var Paginator */ 33 | protected $paginator; 34 | 35 | public function __construct($items = [], Paginator $paginator = null) 36 | { 37 | $this->paginator = $paginator; 38 | parent::__construct($items); 39 | } 40 | 41 | public static function make($items = [], Paginator $paginator = null) 42 | { 43 | return new static($items, $paginator); 44 | } 45 | 46 | public function toArray() 47 | { 48 | if ($this->paginator) { 49 | try { 50 | $total = $this->total(); 51 | } catch (Exception $e) { 52 | $total = null; 53 | } 54 | 55 | return [ 56 | 'total' => $total, 57 | 'per_page' => $this->listRows(), 58 | 'current_page' => $this->currentPage(), 59 | 'data' => parent::toArray() 60 | ]; 61 | } else { 62 | return parent::toArray(); 63 | } 64 | } 65 | 66 | public function __call($method, $args) 67 | { 68 | if ($this->paginator && method_exists($this->paginator, $method)) { 69 | return call_user_func_array([$this->paginator, $method], $args); 70 | } else { 71 | throw new Exception('method not exists:' . __CLASS__ . '->' . $method); 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /application/admin/controller/Bis.php: -------------------------------------------------------------------------------- 1 | obj = model("Bis"); 9 | } 10 | /** 11 | * 正常的商户列表 12 | * @return mixed 13 | */ 14 | public function index() { 15 | $bis = $this->obj->getBisByStatus(1); 16 | return $this->fetch('', [ 17 | 'bis' => $bis, 18 | ]); 19 | } 20 | /** 21 | * 入驻申请列表 22 | * @return mixed 23 | */ 24 | public function apply() { 25 | $bis = $this->obj->getBisByStatus(); 26 | return $this->fetch('', [ 27 | 'bis' => $bis, 28 | ]); 29 | } 30 | 31 | public function detail() { 32 | $id = input('get.id'); 33 | if(empty($id)) { 34 | return $this->error('ID错误'); 35 | } 36 | //获取一级城市的数据 37 | $citys = model('City')->getNormalCitysByParentId(); 38 | //获取一级栏目的数据 39 | $categorys = model('Category')->getNormalCategoryByParentId(); 40 | // 获取商户数据 41 | $bisData = model('Bis')->get($id); 42 | $locationData = model('BisLocation')->get(['bis_id'=>$id, 'is_main'=>1]); 43 | $accountData = model('BisAccount')->get(['bis_id'=>$id, 'is_main'=>1]); 44 | return $this->fetch('',[ 45 | 'citys' => $citys, 46 | 'categorys' => $categorys, 47 | 'bisData' => $bisData, 48 | 'locationData' => $locationData, 49 | 'accountData' => $accountData, 50 | ]); 51 | } 52 | 53 | // 修改状态 54 | public function status() { 55 | $data = input('get.'); 56 | // 检验小伙伴自行完成 57 | /*$validate = validate('Bis'); 58 | if(!$validate->scene('status')->check($data)) { 59 | $this->error($validate->getError()); 60 | }*/ 61 | 62 | $res = $this->obj->save(['status'=>$data['status']], ['id'=>$data['id']]); 63 | $location = model('BisLocation')->save(['status'=>$data['status']], ['bis_id'=>$data['id'], 'is_main'=>1]); 64 | $account = model('BisAccount')->save(['status'=>$data['status']], ['bis_id'=>$data['id'], 'is_main'=>1]); 65 | if($res && $location && $account) { 66 | // 发送邮件 67 | // status 1 status 2 status -1 68 | // \phpmailer\Email::send($data['email'],$title, $content); 69 | $this->success('状态更新成功'); 70 | }else { 71 | $this->error('状态更新失败'); 72 | } 73 | 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /application/bis/controller/Deal.php: -------------------------------------------------------------------------------- 1 | getLoginUser()->bis_id; 16 | if(request()->isPost()) { 17 | // 走插入逻辑 18 | $data = input('post.'); 19 | // 严格校验提交的数据, tp5 validate 小伙伴自行完成, 20 | 21 | $location = model('BisLocation')->get($data['location_ids'][0]); 22 | $deals = [ 23 | 'bis_id' => $bisId, 24 | 'name' => $data['name'], 25 | 'image' => $data['image'], 26 | 'category_id' => $data['category_id'], 27 | 'se_category_id' => empty($data['se_category_id']) ? '' : implode(',', $data['se_category_id']), 28 | 'city_id' => $data['city_id'], 29 | 'location_ids' => empty($data['location_ids']) ? '' : implode(',', $data['location_ids']), 30 | 'start_time' => strtotime($data['start_time']), 31 | 'end_time' => strtotime($data['end_time']), 32 | 'total_count' => $data['total_count'], 33 | 'origin_price' => $data['origin_price'], 34 | 'current_price' => $data['current_price'], 35 | 'coupons_begin_time' => strtotime($data['coupons_begin_time']), 36 | 'coupons_end_time' => strtotime($data['coupons_end_time']), 37 | 'notes' => $data['notes'], 38 | 'description' => $data['description'], 39 | 'bis_account_id' => $this->getLoginUser()->id, 40 | 'xpoint' => $location->xpoint, 41 | 'ypoint' => $location->ypoint, 42 | 43 | 44 | ]; 45 | 46 | $id = model('Deal')->add($deals); 47 | if($id) { 48 | $this->success('添加成功', url('deal/index')); 49 | }else { 50 | $this->error('添加失败'); 51 | } 52 | 53 | }else { 54 | //获取一级城市的数据 55 | $citys = model('City')->getNormalCitysByParentId(); 56 | //获取一级栏目的数据 57 | $categorys = model('Category')->getNormalCategoryByParentId(); 58 | return $this->fetch('', [ 59 | 'citys' => $citys, 60 | 'categorys' => $categorys, 61 | 'bislocations' => model('BisLocation')->getNormalLocationByBisId($bisId), 62 | ]); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /application/index/controller/Lists.php: -------------------------------------------------------------------------------- 1 | getNormalCategoryByParentId(); 12 | foreach($categorys as $category) { 13 | $firstCatIds[] = $category->id; 14 | } 15 | $id = input('id', 0, 'intval'); 16 | $data = []; 17 | // id=0 一级分类 二级分类 18 | if(in_array($id, $firstCatIds)) { // 一级分类 19 | // todo 20 | $categoryParentId = $id; 21 | $data['category_id'] = $id; 22 | }elseif($id) { // 二级分类 23 | // 获取二级分类的数据 24 | $category = model('Category')->get($id); 25 | if(!$category || $category->status !=1) { 26 | $this->error('数据不合法'); 27 | } 28 | $categoryParentId = $category->parent_id; 29 | $data['se_category_id'] = $id; 30 | }else{ // 0 31 | $categoryParentId = 0; 32 | } 33 | $sedcategorys = []; 34 | //获取父类下的所有 子分类 35 | if($categoryParentId) { 36 | $sedcategorys = model('Category')->getNormalCategoryByParentId($categoryParentId); 37 | } 38 | $orders = []; 39 | // 排序数据获取的逻辑 40 | $order_sales = input('order_sales',''); 41 | $order_price = input('order_price',''); 42 | $order_time = input('order_time',''); 43 | if(!empty($order_sales)) { 44 | $orderflag = 'order_sales'; 45 | $orders['order_sales'] = $order_sales; 46 | }elseif(!empty($order_price)) { 47 | $orderflag = 'order_price'; 48 | $orders['order_price'] = $orderflag;//这个地方默认写错了。注意修改下哦 49 | }elseif(!empty($order_time)) { 50 | $orderflag = 'order_time'; 51 | $orders['order_time'] = $order_time; 52 | }else{ 53 | $orderflag = ''; 54 | } 55 | //Log::write('o2o-log-list-id'.$id, 'log'); 56 | trace('o2o-log-list-id'.$id, 'log'); 57 | $data['city_id'] = $this->city->id; // add 58 | // 根据上面条件来查询商品列表数据 59 | $deals = model('Deal')->getDealByConditions($data, $orders); 60 | return $this->fetch('', [ 61 | 'categorys' => $categorys, 62 | 'sedcategorys' => $sedcategorys, 63 | 'id' => $id, 64 | 'categoryParentId' => $categoryParentId, 65 | 'orderflag' => $orderflag, 66 | 'deals' => $deals, 67 | ]); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /public/weixin/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 微信支付样例 6 | 54 | 55 | 56 |
57 | 66 |
67 | 68 | -------------------------------------------------------------------------------- /thinkphp/library/think/process/Utils.php: -------------------------------------------------------------------------------- 1 | 8 | // +---------------------------------------------------------------------- 9 | 10 | namespace think\process; 11 | 12 | class Utils 13 | { 14 | 15 | /** 16 | * 转义字符串 17 | * @param string $argument 18 | * @return string 19 | */ 20 | public static function escapeArgument($argument) 21 | { 22 | 23 | if ('' === $argument) { 24 | return escapeshellarg($argument); 25 | } 26 | $escapedArgument = ''; 27 | $quote = false; 28 | foreach (preg_split('/(")/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { 29 | if ('"' === $part) { 30 | $escapedArgument .= '\\"'; 31 | } elseif (self::isSurroundedBy($part, '%')) { 32 | // Avoid environment variable expansion 33 | $escapedArgument .= '^%"' . substr($part, 1, -1) . '"^%'; 34 | } else { 35 | // escape trailing backslash 36 | if ('\\' === substr($part, -1)) { 37 | $part .= '\\'; 38 | } 39 | $quote = true; 40 | $escapedArgument .= $part; 41 | } 42 | } 43 | if ($quote) { 44 | $escapedArgument = '"' . $escapedArgument . '"'; 45 | } 46 | return $escapedArgument; 47 | } 48 | 49 | /** 50 | * 验证并进行规范化Process输入。 51 | * @param string $caller 52 | * @param mixed $input 53 | * @return string 54 | * @throws \InvalidArgumentException 55 | */ 56 | public static function validateInput($caller, $input) 57 | { 58 | if (null !== $input) { 59 | if (is_resource($input)) { 60 | return $input; 61 | } 62 | if (is_scalar($input)) { 63 | return (string)$input; 64 | } 65 | throw new \InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller)); 66 | } 67 | return $input; 68 | } 69 | 70 | private static function isSurroundedBy($arg, $char) 71 | { 72 | return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1]; 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /thinkphp/library/think/process/pipes/Pipes.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | namespace think\process\pipes; 13 | 14 | abstract class Pipes 15 | { 16 | 17 | /** @var array */ 18 | public $pipes = []; 19 | 20 | /** @var string */ 21 | protected $inputBuffer = ''; 22 | /** @var resource|null */ 23 | protected $input; 24 | 25 | /** @var bool */ 26 | private $blocked = true; 27 | 28 | const CHUNK_SIZE = 16384; 29 | 30 | /** 31 | * 返回用于 proc_open 描述符的数组 32 | * @return array 33 | */ 34 | abstract public function getDescriptors(); 35 | 36 | /** 37 | * 返回一个数组的索引由其相关的流,以防这些管道使用的临时文件的文件名。 38 | * @return string[] 39 | */ 40 | abstract public function getFiles(); 41 | 42 | /** 43 | * 文件句柄和管道中读取数据。 44 | * @param bool $blocking 是否使用阻塞调用 45 | * @param bool $close 是否要关闭管道,如果他们已经到达 EOF。 46 | * @return string[] 47 | */ 48 | abstract public function readAndWrite($blocking, $close = false); 49 | 50 | /** 51 | * 返回当前状态如果有打开的文件句柄或管道。 52 | * @return bool 53 | */ 54 | abstract public function areOpen(); 55 | 56 | 57 | /** 58 | * {@inheritdoc} 59 | */ 60 | public function close() 61 | { 62 | foreach ($this->pipes as $pipe) { 63 | fclose($pipe); 64 | } 65 | $this->pipes = []; 66 | } 67 | 68 | /** 69 | * 检查系统调用已被中断 70 | * @return bool 71 | */ 72 | protected function hasSystemCallBeenInterrupted() 73 | { 74 | $lastError = error_get_last(); 75 | 76 | return isset($lastError['message']) && false !== stripos($lastError['message'], 'interrupted system call'); 77 | } 78 | 79 | protected function unblock() 80 | { 81 | if (!$this->blocked) { 82 | return; 83 | } 84 | 85 | foreach ($this->pipes as $pipe) { 86 | stream_set_blocking($pipe, 0); 87 | } 88 | if (null !== $this->input) { 89 | stream_set_blocking($this->input, 0); 90 | } 91 | 92 | $this->blocked = false; 93 | } 94 | } -------------------------------------------------------------------------------- /application/index/controller/Base.php: -------------------------------------------------------------------------------- 1 | getNormalCitys(); 13 | //用户数据 14 | 15 | $this->getCity($citys); 16 | // 获取首页分类的数据 17 | $cats = $this->getRecommendCats(); 18 | $this->assign('citys', $citys); 19 | $this->assign('city', $this->city); 20 | $this->assign('cats', $cats); 21 | $this->assign('controler', strtolower(request()->controller())); 22 | $this->assign('user', $this->getLoginUser()); 23 | $this->assign('title', 'o2o团购网'); 24 | } 25 | 26 | public function getCity($citys) { 27 | foreach($citys as $city) { 28 | $city = $city->toArray(); 29 | if($city['is_default'] == 1) { 30 | $defaultuname = $city['uname']; 31 | break; // 终止foreach 32 | } 33 | } 34 | 35 | $defaultuname = $defaultuname ? $defaultuname : 'nanchang'; 36 | if(session('cityuname', '', 'o2o') && !input('get.city')) { 37 | $cityuname = session('cityuname', '', 'o2o'); 38 | }else { 39 | $cityuname = input('get.city', $defaultuname, 'trim'); 40 | session('cityuname', $cityuname, 'o2o'); 41 | } 42 | 43 | $this->city = model('City')->where(['uname'=>$cityuname])->find(); 44 | } 45 | 46 | public function getLoginUser() { 47 | if(!$this->account) { 48 | $this->account = session('o2o_user', '', 'o2o'); 49 | } 50 | return $this->account; 51 | } 52 | 53 | /** 54 | * 获取首页推荐当中中的商品分类数据 55 | */ 56 | public function getRecommendCats() { 57 | $parentIds = $sedcatArr = $recomCats = []; 58 | $cats = model('Category')->getNormalRecommendCategoryByParentId(0,5); 59 | foreach($cats as $cat) { 60 | $parentIds[] = $cat->id; 61 | } 62 | // 获取二级分类的数据 63 | $sedCats = model('Category')->getNormalCategoryIdParentId($parentIds); 64 | 65 | foreach($sedCats as $sedcat) { 66 | $sedcatArr[$sedcat->parent_id][] = [ 67 | 'id' => $sedcat->id, 68 | 'name' => $sedcat->name, 69 | ]; 70 | } 71 | 72 | foreach($cats as $cat) { 73 | // recomCats 代表是一级 和 二级数据, []第一个参数是 一级分类的name, 第二个参数 是 此一级分类下面的所有二级分类数据 74 | $recomCats[$cat->id] = [$cat->name, empty($sedcatArr[$cat->id]) ? [] : $sedcatArr[$cat->id]]; 75 | } 76 | return $recomCats; 77 | } 78 | } 79 | --------------------------------------------------------------------------------