wesley.chen 7 gadi atpakaļ
vecāks
revīzija
0239028f7b

+ 7 - 0
app/Http/Controllers/Admin/Base/AttachmentController.php

xqd
@@ -107,6 +107,13 @@ class AttachmentController extends Controller
         echo json_encode($data);exit;
     }
 
+    public function fileupload(){
+        $request = request()->all();
+        $data = $this->_serviceAttachment->fileUpload('file', $request, 'files');
+//        return response()->json(array('data' => $data), 200);
+        echo json_encode($data);exit;
+    }
+
 
     /**
      * @api {get} /api/attachment/download/{md5} 下载文件(图片)

+ 0 - 2
app/Http/Controllers/Admin/Order/InfoController.php

xqd
@@ -194,8 +194,6 @@ class InfoController extends Controller
             // 如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书)
             'cert_path' => $settinig->cart_path, // XXX: 绝对路径!!!!
             'key_path' => $settinig->key_path,      // XXX: 绝对路径!!!!
-
-            'notify_url' => '默认的订单回调地址',     // 你也可以在下单时单独设置来想覆盖它
         ];
 
         $app = Factory::payment($config);

+ 7 - 16
app/Http/Controllers/Admin/Setting/InfoController.php

xqd xqd
@@ -38,17 +38,6 @@ class InfoController extends Controller
     }
 
 
-    function check(Request $request) {
-        $request = $request->all();
-        $search['keyword'] = $request->input('keyword');
-        $orderby = array();
-        if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
-            $orderby[$request['sort_field']] = $request['sort_field_by'];
-        }
-        $list = $this->repository->search($search,$orderby);
-        return view('admin.setting.info.check',compact('list'));
-    }
-
 
     /**
      * 添加
@@ -96,13 +85,15 @@ class InfoController extends Controller
      */
     private function _updateSave() {
         $data = (array) request('data');
-        $ok = $this->repository->update(request('id'),$data);
+        $data['cert_path'] = $_SERVER['DOCUMENT_ROOT'].$data['cert_path'];
+        $data['key_path'] = $_SERVER['DOCUMENT_ROOT'].$data['key_path'];
+
+        $settinig = SettingInfoModel::first();
+        $ok = $this->repository->update($settinig->id,$data);
         if($ok) {
-            $url[] = array('url'=>U( 'Setting/Info/index'),'title'=>'返回列表');
-            return $this->showMessage('操作成功',urldecode(request('_referer')));
+            return $this->showMessage('操作成功');
         }else{
-            $url[] = array('url'=>U( 'Setting/Info/index'),'title'=>'返回列表');
-            return $this->showWarning('操作失败',$url);
+            return $this->showWarning('操作失败');
         }
     }
 

+ 1 - 1
app/Http/Controllers/Api/V1/Controller.php

xqd
@@ -21,7 +21,7 @@ class Controller extends BaseController
         $this->middleware('auth:api', [
             'except' => [
                 'upload', 'getCode', 'reset', 'login', 'get', 'register', 'alipayNotify', 'wechatpayNotify',
-                'get', 'area', 'get_province', 'get_city', 'get_county', 'test','getProducts','getProduct','getStores','getSchedule','createOrder','couponList','myCoupon','getCoupon','usableCoupon','refund','myOrders','orderDetail'
+                'get', 'area', 'get_province', 'get_city', 'get_county', 'test','getProducts','getProduct','getStores','getSchedule','createOrder','couponList','myCoupon','getCoupon','usableCoupon','refund','myOrders','orderDetail','pay','notify'
 
             ]
         ]);

+ 17 - 2
app/Http/Controllers/Api/V1/HomeController.php

xqd xqd xqd
@@ -9,6 +9,7 @@ use App\Models\OrderInfoModel;
 use App\Models\ProductCategoryModel;
 use App\Models\ProductInfoModel;
 use App\Models\ProductScheduleModel;
+use App\Models\SettingInfoModel;
 use App\Models\StoreInfoModel;
 use App\Models\UserCouponRelationModel;
 use App\Models\UserScheduleModel;
@@ -24,12 +25,15 @@ class HomeController extends Controller
 {
 
     protected $app;
+    protected $setting;
 
     public function __construct()
     {
+        $this->setting = SettingInfoModel::first();
+
         $config = [
-            'app_id' => 'wxdeff0d78ebe3e744',
-            'secret' => '44cf7fc6e0d4012f180c7f04d47d344d',
+            'app_id' => $this->setting->app_id,
+            'secret' => $this->setting->app_secret,
 
             // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
             'response_type' => 'array',
@@ -1160,5 +1164,16 @@ class HomeController extends Controller
         return $arr;
     }
 
+    public function options()
+    {
+        return [
+            'app_id' => $this->setting->app_id,
+            'mch_id' => $this->setting->mch_id,
+            'key' => $this->setting->api_key,
+            'notify_url' => url('/api/home/notify'),
+            'sandbox' => false,
+        ];
+    }
+
 
 }

+ 4 - 2
app/Models/ProductScheduleModel.php

xqd
@@ -34,8 +34,10 @@ class ProductScheduleModel extends BaseModel
      * @var string
      */
     protected $fillable = [
-        'am_time',
-        'pm_time',
+        'am_start',
+        'pm_start',
+        'am_end',
+        'pm_end',
         'interval',
         'max'
     ];

+ 18 - 15
app/Models/SettingInfoModel.php

xqd xqd xqd
@@ -1,11 +1,14 @@
 <?php
+
 namespace App\Models;
+
 use App\Models\BaseModel;
+
 /**
- *  @description 基础设置
- *  @author  system;
- *  @version    1.0
- *  @date 2018-07-22 14:05:49
+ * @description 基础设置
+ * @author  system;
+ * @version    1.0
+ * @date 2018-07-22 14:05:49
  *
  */
 class SettingInfoModel extends BaseModel
@@ -18,7 +21,7 @@ class SettingInfoModel extends BaseModel
      */
     protected $table = 'setting_info';
     /**
-    主键
+     * 主键
      */
     protected $primaryKey = 'id';
 
@@ -31,15 +34,15 @@ class SettingInfoModel extends BaseModel
      * @var string
      */
     protected $fillable = [
-                           'app_id',
-                           'app_secret',
-                           'mch_id',
-                           'api_key',
-                           'cert_path',
-                           'key_path',
-                           'free_refund_time',
-                           'refund_poundage_in',
-                           'refund_poundage_out'
-                          ];
+        'app_id',
+        'app_secret',
+        'mch_id',
+        'api_key',
+        'cert_path',
+        'key_path',
+        'free_refund_time',
+        'refund_poundage_in',
+        'refund_poundage_out'
+    ];
 
 }

+ 83 - 1
app/Services/Base/Attachment.php

xqd xqd xqd
@@ -142,7 +142,7 @@ class Attachment
      */
 
 
-    public function localUpload($field, $request, $tag = 'files', $size = 10 * 1024 * 1024, array $mimeType = ['image/jpeg', 'image/png', 'image/gif','video/mp4','video/quicktime'])
+    public function localUpload($field, $request, $tag = 'files', $size = 10 * 1024 * 1024, array $mimeType = ['image/jpeg', 'image/png', 'image/gif','video/mp4','video/quicktime','text/plain'])
     {
 
         $tag = $request['folder'];
@@ -173,6 +173,7 @@ class Attachment
             return $this->_jsonMessage(500,  ['message' => '文件大小超过限制']);
         }
         $fileMimeType = $file->getMimeType();
+
         if (!empty($mimeType) && !in_array($fileMimeType, $mimeType)) {
             return $this->_jsonMessage(500,  ['message' => '文件格式不被允许']);
         }
@@ -238,6 +239,87 @@ class Attachment
         }
     }
 
+    public function fileUpload($field, $request, $tag = 'files', $size = 10 * 1024 * 1024, array $mimeType = ['image/jpeg', 'image/png', 'image/gif','video/mp4','video/quicktime','text/plain']){
+        $tag = $request['folder'];
+        $class = isset($request['class']) ? $request['class'] : '未分类';
+        $sizex = isset($request['sizex']) ? $request['sizex'] : 0;
+        $sizey = isset($request['sizey']) ? $request['sizey'] : 0;
+        $rel_path = $tag . '/' . date('Ymd');
+        $path = public_path() . $rel_path;
+        // dd($request);
+        if (!file_exists($path)) {
+            if (!@mkdir($path, 0755, true)) {
+//              return ErrorCode::ATTACHMENT_MKDIR_FAILED;
+                return $this->_jsonMessage(500,  ['message' => '目录创建失败']);
+            }
+        }
+
+        $file = $request[$field];
+        if ($file === null) {
+            return $this->_jsonMessage(500,  ['message' => '没有文件被上传']);
+        }
+        if (!$file->isValid()) {
+            return $this->_jsonMessage(500,  ['message' => '不允许上传']);
+        }
+
+        $fileSize = $file->getSize();
+        if ($fileSize > $size) {
+//            $result[$idx] = ErrorCode::ATTACHMENT_SIZE_EXCEEDED;
+            return $this->_jsonMessage(500,  ['message' => '文件大小超过限制']);
+        }
+        $fileMimeType = $file->getMimeType();
+
+        if (!empty($mimeType) && !in_array($fileMimeType, $mimeType)) {
+            return $this->_jsonMessage(500,  ['message' => '文件格式不被允许']);
+        }
+        $clientName = $file->getClientOriginalName();
+        $md5 = md5($clientName . time());
+        $md5_filename = $md5 . '.' . $file->getClientOriginalExtension();
+
+        if(isset($request['from']) && $request['from'] == 'crop') {
+            $clientName = isset($request['name']) ? $request['name'] : '裁剪.png';
+            $md5_filename = $md5_filename . 'png';
+        }
+
+        try {
+            if(!$file->move($path, $md5_filename)){
+                return $this->_jsonMessage(500,  ['message' => '上传失败']);
+            }
+
+//            $quality = 75;
+//            $modal = null;
+//            if(($modal = BaseSettingsModel::where('key', env('PHOTO_COMPRESS_QUALITY_KEY'))->first()) != null) {
+//                $quality = $modal->value;
+//            }
+
+            $real_path = $path . '/' . $md5_filename;
+            $url_path = $rel_path . '/' . $md5_filename;
+
+            $source_info = null;
+            if(($source_info = getimagesize($real_path)) != null) {
+                $source_width = $source_info[0];
+                $source_height = $source_info[1];
+                \Log::info('$source_width'.$source_width.'$source_height'.$source_height);
+                if($sizex || $sizey){
+                    if($sizex==0){
+                        $sizex = $source_width*($sizey/$source_height);
+                    }
+                    if($sizey==0){
+                        $sizey = $source_height*($sizex/$source_width);
+                    }
+                    \Log::info('$sizex'.$sizex.'$sizey'.$sizey);
+                    Image::make($real_path)->resize($sizex, $sizey)->save($real_path);
+                }
+            }
+
+                return $this->_jsonMessage(200,  ['message' => "上传成功", 'fileurl' => $url_path,'name'=>$md5_filename]);
+
+        } catch (FileException $e) {
+            return $this->_jsonMessage(500,  ['message' => '上传失败']);
+//            $result = ErrorCode::ATTACHMENT_MOVE_FAILED;
+        }
+    }
+
     /**
      * 删除附件
      *

+ 3 - 2
app/Widget/Tools/FileUpload.php

xqd xqd
@@ -19,7 +19,7 @@ class FileUpload {
      */
     public function single($folder, $id, $name = "data[file]", $file = "", $option = [], $param = [])
     {
-        $file_types = 'jpg|jpeg|gif|png|bmp|doc|docx|xls|xlsx|ppt|htm|html|php|txt|zip|rar|gz|bz2|cart|key|txt';
+        $file_types = 'jpg|jpeg|gif|png|bmp|doc|docx|xls|xlsx|ppt|htm|html|php|txt|zip|rar|gz|bz2|crt|key|txt|pem';
         $option['position'] = isset($option['position']) ? $option['position'] : "alioss";
         $option['placeholder'] = isset($option['placeholder']) ? $option['placeholder'] : "";
         $option['button_class'] = isset($option['button_class']) ? $option['button_class'] : "";
@@ -58,9 +58,10 @@ class FileUpload {
                         accept: {
                             title: 'Files',
                             extensions: "{$file_types}",
+                            mimeTypes:'*/*'
                         },
                         swf: "/base/plugins/webuploader/uploader.swf",
-                        server: "/api/attachment/webupload",
+                        server: "/admin/Base/Attachment/fileupload?folder=$folder",
                         fileNumLimit: 300,
                         fileSizeLimit: 20 * 1024 * 1024,
                         fileSingleSizeLimit: 10 * 1024 * 1024,

+ 114 - 69
resources/views/admin/product/schedule/edit.blade.php

xqd
@@ -2,94 +2,139 @@
 
 @section('content')
 
-<?php
-    if(!isset($data)) $data = array();
-    if(!$data && session("data")){
+    <?php
+    if (!isset($data)) $data = array();
+    if (!$data && session("data")) {
         $data = session("data");
     }
-    if(!$data && session('_old_input')){
+    if (!$data && session('_old_input')) {
         $data = session("_old_input");
     }
-?>
-	<div class="row">
-		<div class="col-sm-12">
-			<div class="ibox float-e-margins">
-				<div class="ibox-title">
-					<h5>排期设置</h5>
-					<div class="ibox-tools">
-						<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
-						</a>
-					</div>
-				</div>
-				<div class="ibox-content">
+    ?>
+    <div class="row">
+        <div class="col-sm-12">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>排期设置</h5>
+                    <div class="ibox-tools">
+                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+                        </a>
+                    </div>
+                </div>
+                <div class="ibox-content">
                     @if(role('Product/Schedule/index'))
-				    <div class="row">
-    					<div class="col-sm-3 pull-right">
-    					   <a href="{{ U('Product/Schedule/index')}}" class="btn btn-sm btn-primary pull-right">返回列表</a>
-    					</div>
-					</div>
+                        <div class="row">
+                            <div class="col-sm-3 pull-right">
+                                <a href="{{ U('Product/Schedule/index')}}" class="btn btn-sm btn-primary pull-right">返回列表</a>
+                            </div>
+                        </div>
                     @endif
 
-		            <div class="row">
+                    <div class="row">
                         <div class="col-lg-10">
-                            <form name="form_product" id="form-validation" action="" class="form-horizontal form-validation" accept-charset="UTF-8" method="post">
-
-                                    
-                <div class="form-group">
-                                    
-                 <label class="control-label col-sm-3">营业时间:上午</label>
-                                    
-                   <div class="col-sm-9">
-                     <input id="data_am_time" name="data[am_time]" class="form-control" value="{{ $data['am_time'] or ''}}" required="" aria-required="true"  placeholder=""> 
-                    </div>
-                                
-                </div>    
-                <div class="form-group">
-                                    
-                 <label class="control-label col-sm-3">营业时间:下午</label>
-                                    
-                   <div class="col-sm-9">
-                     <input id="data_pm_time" name="data[pm_time]" class="form-control" value="{{ $data['pm_time'] or ''}}" required="" aria-required="true"  placeholder=""> 
-                    </div>
-                                
-                </div>    
-                <div class="form-group">
-                                    
-                 <label class="control-label col-sm-3">时间间隔:分钟</label>
-                                    
-                   <div class="col-sm-9">
-                     <input id="data_interval" name="data[interval]" class="form-control" value="{{ $data['interval'] or ''}}" required="" aria-required="true"  placeholder=""> 
-                    </div>
-                                
-                </div>    
-                <div class="form-group">
-                                    
-                 <label class="control-label col-sm-3">人数上限</label>
-                                    
-                   <div class="col-sm-9">
-                     <input id="data_max" name="data[max]" class="form-control" value="{{ $data['max'] or ''}}" required="" aria-required="true"  placeholder=""> 
-                    </div>
-                                
-                </div>
-                                
+                            <form name="form_product" id="form-validation" action=""
+                                  class="form-horizontal form-validation" accept-charset="UTF-8" method="post">
+
+
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">营业时间:上午</label>
+
+                                    <div class="col-sm-9">
+                                        <div class="row">
+                                            <div class="col-sm-3">
+                                                <input id="data_am_start" type="time"
+                                                       name="data[am_start]"
+                                                       class="form-control col-sm-3"
+                                                       value="{{ $data['am_start'] or ''}}"
+                                                       required="" aria-required="true"
+                                                       placeholder="">
+                                            </div>
+                                            <div class="col-sm-3">
+                                                <input id="data_am_end" type="time"
+                                                       name="data[am_end]"
+                                                       class="form-control col-sm-3"
+                                                       value="{{ $data['am_end'] or ''}}"
+                                                       required="" aria-required="true"
+                                                       placeholder="">
+                                            </div>
+                                        </div>
+
+
+                                    </div>
+
+                                </div>
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">营业时间:下午</label>
+
+
+                                    <div class="col-sm-9">
+                                        <div class="row">
+                                            <div class="col-sm-3">
+                                                <input id="data_pm_start" type="time"
+                                                       name="data[pm_start]"
+                                                       class="form-control col-sm-3"
+                                                       value="{{ $data['pm_start'] or ''}}"
+                                                       required="" aria-required="true"
+                                                       placeholder="">
+                                            </div>
+                                            <div class="col-sm-3">
+                                                <input id="data_pm_end" type="time"
+                                                       name="data[pm_end]"
+                                                       class="form-control col-sm-3"
+                                                       value="{{ $data['pm_end'] or ''}}"
+                                                       required="" aria-required="true"
+                                                       placeholder="">
+                                            </div>
+                                        </div>
+
+
+                                    </div>
+
+                                </div>
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">时间间隔:分钟</label>
+
+                                    <div class="col-sm-9">
+                                        <input id="data_interval" name="data[interval]" class="form-control"
+                                               value="{{ $data['interval'] or ''}}" required="" aria-required="true"
+                                               placeholder="">
+                                    </div>
+
+                                </div>
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">人数上限</label>
+
+                                    <div class="col-sm-9">
+                                        <input id="data_max" name="data[max]" class="form-control"
+                                               value="{{ $data['max'] or ''}}" required="" aria-required="true"
+                                               placeholder="">
+                                    </div>
+
+                                </div>
+
                                 <div class="form-group">
                                     <label class="control-label col-sm-3">&nbsp;</label>
                                     <div class="col-sm-9">
-                                        <input type="hidden" name="_referer" value="<?php echo urlencode(request()->server('HTTP_REFERER'));?>"/>
+                                        <input type="hidden" name="_referer"
+                                               value="<?php echo urlencode(request()->server('HTTP_REFERER'));?>"/>
                                         <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
                                         <input type="submit" class="btn btn-success" style="margin-right:20px;">
-                                        <input type="reset" class="btn btn-default" >
+                                        <input type="reset" class="btn btn-default">
                                     </div>
                                 </div>
-        
+
                             </form>
                         </div>
                         <!-- /.col-lg-10 -->
                     </div>
                     <!-- /.row -->
-				</div>
-			</div>
-		</div>
-	</div>
+                </div>
+            </div>
+        </div>
+    </div>
 
 @endsection

+ 8 - 10
resources/views/admin/product/schedule/index.blade.php

xqd xqd
@@ -26,18 +26,18 @@
                             </div>
                         </form>
                         @if(role('Product/Schedule/create'))
-                            <div class="col-sm-3 pull-right">
-                                <a href="{{ U('Product/Schedule/create')}}"
-                                   class="btn btn-sm btn-primary pull-right">添加</a>
-                            </div>
+                            @if(!count($list))
+                                <div class="col-sm-3 pull-right">
+                                    <a href="{{ U('Product/Schedule/create')}}"
+                                       class="btn btn-sm btn-primary pull-right">添加</a>
+                                </div>
+                            @endif
                         @endif
                     </div>
 
                     <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                         <thead>
                         <tr>
-
-                            <th class="sorting" data-sort="id"> ID</th>
                             <th class="sorting" data-sort="am_time"> 营业时间:上午</th>
                             <th class="sorting" data-sort="pm_time"> 营业时间:下午</th>
                             <th class="sorting" data-sort="interval"> 时间间隔:分钟</th>
@@ -51,10 +51,8 @@
                         @if(isset($list))
                             @foreach($list as $key => $item)
                                 <tr>
-
-                                    <td>{{ $item->id }}</td>
-                                    <td>{{ $item->am_time }}</td>
-                                    <td>{{ $item->pm_time }}</td>
+                                    <td>{{ $item->am_start.'--'.$item->am_end }}</td>
+                                    <td>{{ $item->pm_start.'--'.$item->pm_end }}</td>
                                     <td>{{ $item->interval }}</td>
                                     <td>{{ $item->max }}</td>
                                     <td>{{ $item->created_at }}</td>

+ 2 - 2
resources/views/admin/product/schedule/view.blade.php

xqd
@@ -16,14 +16,14 @@
                                                   
                    <h3 class="list-group-item-heading">营业时间:上午</h3>
                                                    
-                   <p class="list-group-item-text"> {{ $data['am_time'] or ''}}</p>
+                   <p class="list-group-item-text"> {{ $data['am_start'].'--'.$data['am_end']}}</p>
                                                  
                </div>                     
                <div class="list-group-item">
                                                   
                    <h3 class="list-group-item-heading">营业时间:下午</h3>
                                                    
-                   <p class="list-group-item-text"> {{ $data['pm_time'] or ''}}</p>
+                   <p class="list-group-item-text"> {{ $data['pm_start'].'--'.$data['pm_end']}}</p>
                                                  
                </div>                     
                <div class="list-group-item">

+ 3 - 3
resources/views/admin/setting/info/edit.blade.php

xqd xqd
@@ -76,8 +76,7 @@
                  <label class="control-label col-sm-3">支付cart路径</label>
                                     
                    <div class="col-sm-9">
-                     <input id="data_cert_path" name="data[cert_path]" class="form-control" value="{{ $data['cert_path'] or ''}}" required="" aria-required="true"  placeholder="">
-                       {!!  widget('Tools.FileUpload')->single('/upload/wechat/','cert_path',"data[cert_path]", isset($data['cert_path']) ? $data['cert_path'] : "") !!}
+                       {!!  widget('Tools.FileUpload')->single('/upload/wechat','cert_path',"data[cert_path]", isset($data['cert_path']) ? $data['cert_path'] : "") !!}
                     </div>
                                 
                 </div>    
@@ -86,7 +85,8 @@
                  <label class="control-label col-sm-3">支付key路径</label>
                                     
                    <div class="col-sm-9">
-                     <input id="data_key_path" name="data[key_path]" class="form-control" value="{{ $data['key_path'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                       {!!  widget('Tools.FileUpload')->single('/upload/wechat','key_path',"data[key_path]", isset($data['key_path']) ? $data['key_path'] : "") !!}
+
                     </div>
                                 
                 </div>    

+ 8 - 0
routes/api.php

xqd
@@ -78,6 +78,14 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'home.orderdetail',
         'uses' => 'HomeController@orderDetail',
     ]);
+    $api->any('home/notify', [
+        'as' => 'home.notify',
+        'uses' => 'HomeController@notify',
+    ]);
+    $api->any('home/pay', [
+        'as' => 'home.notify',
+        'uses' => 'HomeController@pay',
+    ]);