Forráskód Böngészése

后台增加身份证

linwu 1 éve
szülő
commit
86747f5e3b

+ 180 - 179
app/admin/controller/Attachment.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace app\admin\controller;
 
 use think\facade\Session;
@@ -10,190 +11,190 @@ use app\common\model\Attachment as AttachmentModel;
 
 class Attachment
 {
-	
-	// 文件上传
-	public function tplFieldFile()
-	{
-		$file = request()->file("file");
-		$savename = \think\facade\Filesystem::disk('public')->putFile('files',$file);
-		if($file){
-			$filename = str_replace(strrchr($_FILES['file']['name'], "."),"",$_FILES['file']['name']);
-			$attachment = AttachmentModel::create([
-				'filename'  	=> $filename,
-				'atype'     	=> 4,
-				'attachment'    => request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-				'createtime'	=> time() 
-			]);
-			exit(json_encode(array(
-				'code' 	=> 0,
-				'msg'   => "",
-				'data'  => array(
-					'src'	=> request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-					'path'	=> "./attachment/". str_replace("\\","/",$savename),
-					'title'	=> $filename
-				)
-			)));
-		}else{
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'   => "上传失败,请稍后重试"
-			)));
-		}
-	}
-	
-	// 图片上传
-	public function tplFieldImage()
-	{
-        $this->validateExt(['jpg,png,jpeg']);
-		$file = request()->file("file");
-		$savename = \think\facade\Filesystem::disk('public')->putFile('images',$file);
-		if($file){
-			$filename = str_replace(strrchr($_FILES['file']['name'], "."),"",$_FILES['file']['name']);
-			$attachment = AttachmentModel::create([
-				'filename'  	=> $filename,
-				'atype'     	=> 1,
-				'attachment'    => request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-				'createtime'	=> time() 
-			]);
-			exit(json_encode(array(
-				'code' 	=> 0,
-				'msg'   => "",
-				'data'  => array(
-					'src'	=> request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-					'title'	=> $filename
-				)
-			)));
-		}else{
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'   => "上传失败,请稍后重试"
-			)));
-		}
-	}
-	
-	
-	
-	
-	// 图片
-	public function image()
-	{
-		$years = range( date('Y'), date('Y')-9 );
-		$months = array(
-			array('key'=>1, 'val'=>1),
-			array('key'=>2, 'val'=>2),
-			array('key'=>3, 'val'=>3),
-			array('key'=>4, 'val'=>4),
-			array('key'=>5, 'val'=>5),
-			array('key'=>6, 'val'=>6),
-			array('key'=>7, 'val'=>7),
-			array('key'=>8, 'val'=>8),
-			array('key'=>9, 'val'=>9),
-			array('key'=>10, 'val'=>10),
-			array('key'=>11, 'val'=>11),
-			array('key'=>12, 'val'=>12)
-		);
-		$yearmonth = array();
-		foreach ( $years as $key=>$value ){
-			$yearmonth[$key]['key'] = $value;
-			$yearmonth[$key]['val'] = $value;
-			$yearmonth[$key]['month'] = $months;
-		}
-		return view('attachment/image',[
-			'yearmonth' => json_encode($yearmonth)
-		]);
-	}
-	
-	public function listImage()
-	{
-		$limit = input('limit');
-		$page = input('page');
-		$map = array();
-		$map[] = ['atype', '=', 1];
-		$keywords = input('keywords/s');
-		if (!empty($keywords)){
-			$map[] =['filename', 'like', '%'.$keywords.'%'];
-		}
-		$yearmonth = input('yearmonth/s');
-		if (!empty($yearmonth)){
-			$yearmontharr = explode(",", $yearmonth);
-			if (!empty($yearmontharr[1])) {
-				$year = $yearmontharr[0];
-				$month = $yearmontharr[1];
-				$monthday = date("t",strtotime($year."-".$month));
-				$stime = mktime(0,0,0,$month,1,$year);
-				$etime = mktime(23,59,59,$month,$monthday,$year);
-				$map[] = ['createtime', 'between', [$stime,$etime]];
-			}else{
-				$year = $yearmontharr[0];
-				$stime = mktime(0,0,0,1,1,$year);
-				$etime = mktime(23,59,59,12,31,$year);
-				$map[] = ['createtime', 'between', [$stime,$etime]];
-			}
-		}
-		$list = AttachmentModel::where($map)->order(['id'=>'desc'])->limit($limit)->page($page)->select();
-		$count = AttachmentModel::where($map)->count();
-		if ($count==0){
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'	=> "未查询到数据"
-			)));
-		}
-		exit(json_encode(array(
-			'code' 	=> 0,
-			'msg'	=> "",
-			'count' => $count,
-			'data'  => $list
-		)));
-	}
 
-	
-	
-	// 附件公共操作
-	public function fieldAttachment()
-	{
-		$id = input('id/d');
-		$attachment = AttachmentModel::findOrEmpty($id);
-		if ($attachment->isEmpty()){
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'	=> "附件信息不存在"
-			)));
-		}else{
-			$attachment->save([
-				input('field/s')  => input('value')
-			]);
-		}
-		exit(json_encode(array(
-			'code' 	=> 0
-		)));
-	}
-	
-	public function delAttachment()
-	{
-		$idarr = input('idarr/a');
-		$attachment = AttachmentModel::whereIn('id',$idarr)->select();
-		foreach($attachment as $v){
-			$attachmenturl = str_replace( request()->domain(), ".", $v['attachment']);
-			@unlink( $attachmenturl );
-		}
-		$result = $attachment->delete();
-		if ($result){
-			exit(json_encode(array(
-				'code' 	=> 0,
-				'msg'	=> ""
-			)));
-		}
-		exit(json_encode(array(
-			'code' 	=> 1,
-			'msg'	=> "删除失败,请稍后重试"
-		)));
-	}
+    // 文件上传
+    public function tplFieldFile()
+    {
+        $file     = request()->file("file");
+        $savename = \think\facade\Filesystem::disk('public')->putFile('files', $file);
+        if ($file) {
+            $filename   = str_replace(strrchr($_FILES['file']['name'], "."), "", $_FILES['file']['name']);
+            $attachment = AttachmentModel::create([
+                'filename'   => $filename,
+                'atype'      => 4,
+                'attachment' => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                'createtime' => time(),
+            ]);
+            exit(json_encode([
+                'code' => 0,
+                'msg'  => "",
+                'data' => [
+                    'src'   => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                    'path'  => "./attachment/" . str_replace("\\", "/", $savename),
+                    'title' => $filename,
+                ],
+            ]));
+        } else {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "上传失败,请稍后重试",
+            ]));
+        }
+    }
+
+    // 图片上传
+    public function tplFieldImage()
+    {
+        $this->validateExt(['jpg', 'png', 'jpeg']);
+        $file     = request()->file("file");
+        $savename = \think\facade\Filesystem::disk('public')->putFile('images', $file);
+        if ($file) {
+            $filename   = str_replace(strrchr($_FILES['file']['name'], "."), "", $_FILES['file']['name']);
+            $attachment = AttachmentModel::create([
+                'filename'   => $filename,
+                'atype'      => 1,
+                'attachment' => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                'createtime' => time(),
+            ]);
+            exit(json_encode([
+                'code' => 0,
+                'msg'  => "",
+                'data' => [
+                    'src'   => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                    'title' => $filename,
+                ],
+            ]));
+        } else {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "上传失败,请稍后重试",
+            ]));
+        }
+    }
+
+
+    // 图片
+    public function image()
+    {
+        $years     = range(date('Y'), date('Y') - 9);
+        $months    = [
+            ['key' => 1, 'val' => 1],
+            ['key' => 2, 'val' => 2],
+            ['key' => 3, 'val' => 3],
+            ['key' => 4, 'val' => 4],
+            ['key' => 5, 'val' => 5],
+            ['key' => 6, 'val' => 6],
+            ['key' => 7, 'val' => 7],
+            ['key' => 8, 'val' => 8],
+            ['key' => 9, 'val' => 9],
+            ['key' => 10, 'val' => 10],
+            ['key' => 11, 'val' => 11],
+            ['key' => 12, 'val' => 12],
+        ];
+        $yearmonth = [];
+        foreach ($years as $key => $value) {
+            $yearmonth[$key]['key']   = $value;
+            $yearmonth[$key]['val']   = $value;
+            $yearmonth[$key]['month'] = $months;
+        }
+        return view('attachment/image', [
+            'yearmonth' => json_encode($yearmonth),
+        ]);
+    }
+
+    public function listImage()
+    {
+        $limit    = input('limit');
+        $page     = input('page');
+        $map      = [];
+        $map[]    = ['atype', '=', 1];
+        $keywords = input('keywords/s');
+        if (!empty($keywords)) {
+            $map[] = ['filename', 'like', '%' . $keywords . '%'];
+        }
+        $yearmonth = input('yearmonth/s');
+        if (!empty($yearmonth)) {
+            $yearmontharr = explode(",", $yearmonth);
+            if (!empty($yearmontharr[1])) {
+                $year     = $yearmontharr[0];
+                $month    = $yearmontharr[1];
+                $monthday = date("t", strtotime($year . "-" . $month));
+                $stime    = mktime(0, 0, 0, $month, 1, $year);
+                $etime    = mktime(23, 59, 59, $month, $monthday, $year);
+                $map[]    = ['createtime', 'between', [$stime, $etime]];
+            } else {
+                $year  = $yearmontharr[0];
+                $stime = mktime(0, 0, 0, 1, 1, $year);
+                $etime = mktime(23, 59, 59, 12, 31, $year);
+                $map[] = ['createtime', 'between', [$stime, $etime]];
+            }
+        }
+        $list  = AttachmentModel::where($map)->order(['id' => 'desc'])->limit($limit)->page($page)->select();
+        $count = AttachmentModel::where($map)->count();
+        if ($count == 0) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "未查询到数据",
+            ]));
+        }
+        exit(json_encode([
+            'code'  => 0,
+            'msg'   => "",
+            'count' => $count,
+            'data'  => $list,
+        ]));
+    }
+
+
+    // 附件公共操作
+    public function fieldAttachment()
+    {
+        $id         = input('id/d');
+        $attachment = AttachmentModel::findOrEmpty($id);
+        if ($attachment->isEmpty()) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "附件信息不存在",
+            ]));
+        } else {
+            $attachment->save([
+                input('field/s') => input('value'),
+            ]);
+        }
+        exit(json_encode([
+            'code' => 0,
+        ]));
+    }
+
+    public function delAttachment()
+    {
+        $idarr      = input('idarr/a');
+        $attachment = AttachmentModel::whereIn('id', $idarr)->select();
+        foreach ($attachment as $v) {
+            $attachmenturl = str_replace(request()->domain(), ".", $v['attachment']);
+            @unlink($attachmenturl);
+        }
+        $result = $attachment->delete();
+        if ($result) {
+            exit(json_encode([
+                'code' => 0,
+                'msg'  => "",
+            ]));
+        }
+        exit(json_encode([
+            'code' => 1,
+            'msg'  => "删除失败,请稍后重试",
+        ]));
+    }
 
     public function validateExt($ext_arr)
     {
         $ext = pathinfo($_FILES['file']['name'])['extension'];
-        if (!in_array($ext,$ext_arr)) {
-            page_result(1, "文件格式不正确");
+        if (!in_array($ext, $ext_arr)) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "文件格式不正确",
+            ]));
         }
     }
 }

+ 27 - 25
app/admin/controller/Worker.php

@@ -314,27 +314,29 @@ class Worker extends BaseController
             ]));
         }
         $data     = [
-            'userid'    => $muser->id,
-            'wtype'     => input('wtype/d', 1),
-            'title'     => input('title/s', ""),
-            'ftitle'    => input('ftitle/s', ""),
-            'tilpic'    => input('tilpic/s', ""),
-            'realname'  => input('realname/s', ""),
-            'mobile'    => input('mobile/s', ""),
-            'weixin'    => input('weixin/s', ""),
-            'latitude'  => input('latitude/f'),
-            'longitude' => input('longitude/f'),
-            'province'  => input('province/s'),
-            'city'      => input('city/s'),
-            'district'  => input('district/s'),
-            'address'   => input('address/s'),
-            'picone'    => input('picone/s', ""),
-            'pictwo'    => input('pictwo/s', ""),
-            'picthr'    => input('picthr/s', ""),
-            'details'   => input('details/s'),
-            'priority'  => input('priority/d', 0),
-            'remark'    => input('remark/s', ""),
-            'status'    => input('status/d', 1),
+            'userid'     => $muser->id,
+            'wtype'      => input('wtype/d', 1),
+            'title'      => input('title/s', ""),
+            'ftitle'     => input('ftitle/s', ""),
+            'tilpic'     => input('tilpic/s', ""),
+            'realname'   => input('realname/s', ""),
+            'mobile'     => input('mobile/s', ""),
+            'weixin'     => input('weixin/s', ""),
+            'latitude'   => input('latitude/f'),
+            'longitude'  => input('longitude/f'),
+            'province'   => input('province/s'),
+            'city'       => input('city/s'),
+            'district'   => input('district/s'),
+            'address'    => input('address/s'),
+            'picone'     => input('picone/s', ""),
+            'pictwo'     => input('pictwo/s', ""),
+            'picthr'     => input('picthr/s', ""),
+            'details'    => input('details/s'),
+            'priority'   => input('priority/d', 0),
+            'remark'     => input('remark/s', ""),
+            'status'     => input('status/d', 1),
+            'idcardzpic' => input('idcardzpic/s', ""),
+            'idcardfpic' => input('idcardfpic/s', ""),
         ];
         $password = input('password/s', "");
         if (empty($id)) {
@@ -449,10 +451,10 @@ class Worker extends BaseController
             ]));
         }
 
-        $limit    = input('limit/d', 20);
-        $page     = input('page/d', 1);
-        $map = [
-            ['workerid','=',$workerid]
+        $limit = input('limit/d', 20);
+        $page  = input('page/d', 1);
+        $map   = [
+            ['workerid', '=', $workerid],
         ];
         $list  = WorkerIncomeModel::where($map)->order('id', 'DESC')->limit($limit)->page($page)->select();
         $count = WorkerIncomeModel::where($map)->count();

+ 38 - 4
app/admin/view/worker/workerform.html

@@ -30,8 +30,8 @@
 						<div class="layui-form-item" pane>
 							<label class="layui-form-label">公司类型</label>
 							<div class="layui-input-block">
-								<input type="radio" name="wtype" value="1" title="普通公司" {eq name="worker.wtype|default=1" value="1" }checked{/eq} />
-								<input type="radio" name="wtype" value="2" title="派遣公司" {eq name="worker.wtype" value="2" }checked{/eq} />
+								<input type="radio" name="wtype" value="1" title="个人雇主" {eq name="worker.wtype|default=1" value="1" }checked{/eq} />
+								<input type="radio" name="wtype" value="2" title="企业雇主" {eq name="worker.wtype" value="2" }checked{/eq} />
 							</div>
 						</div>
 						<div class="layui-form-item">
@@ -179,6 +179,40 @@
 								</div>
 							</div>
 						</div>
+						<div class="layui-form-item">
+							<label class="layui-form-label">身份证正面</label>
+							<div class="layui-input-block">
+								<div class="layui-upload">
+									<button type="button" class="layui-btn attachment-upload-images" data-input="idcardzpic" data-amount="1">上传图片</button>
+									<div class="layui-inline layui-word-aux"></div>
+									<div class="layui-upload-list echo-attachment-image-list" id="idcardzpic">
+										{notempty name="worker.idcardzpic"}
+										<div>
+											<input type="hidden" name="idcardzpic" value="{$worker.idcardzpic}">
+											<img src="{$worker.idcardzpic}" class="idcard">
+										</div>
+										{/notempty}
+									</div>
+								</div>
+							</div>
+						</div>
+						<div class="layui-form-item">
+							<label class="layui-form-label">身份证反面</label>
+							<div class="layui-input-block">
+								<div class="layui-upload">
+									<button type="button" class="layui-btn attachment-upload-images" data-input="idcardfpic" data-amount="1">上传图片</button>
+									<div class="layui-inline layui-word-aux"></div>
+									<div class="layui-upload-list echo-attachment-image-list" id="idcardfpic">
+										{notempty name="worker.idcardfpic"}
+										<div>
+											<input type="hidden" name="idcardfpic" value="{$worker.idcardfpic}">
+											<img src="{$worker.idcardfpic}" class="idcard">
+										</div>
+										{/notempty}
+									</div>
+								</div>
+							</div>
+						</div>
 						<div class="layui-form-item" id="formdetails">
 							<label class="layui-form-label">门店介绍</label>
 							<div class="layui-input-block">
@@ -335,11 +369,11 @@
 				var html = "";
 				if (upload_amount == 1) {
 					html += '<div> <input type="hidden" name="' + upload_input + '" value="' + res.data.src + '"> ';
-					html += '<img src="' + res.data.src + '"></div>';
+					html += '<img class="idcard" src="' + res.data.src + '"></div>';
 					$("#" + upload_input).html(html);
 				} else {
 					html += '<div> <input type="hidden" name="' + upload_input + '[]" value="' + res.data.src + '"> ';
-					html += '<img src="' + res.data.src +
+					html += '<img class="idcard" src="' + res.data.src +
 						'"> <button type="button" class="attachmentdel layui-btn layui-btn-primary layui-btn-xs layui-btn-fluid">删除</button></div>';
 					$("#" + upload_input).append(html);
 				}

+ 2 - 2
app/admin/view/worker/workerlist.html

@@ -13,8 +13,8 @@
 					<div class="layui-input-block">
 						<select name="status">
 							<option value="">全部类型</option>
-							<option value="1">普通公司</option>
-							<option value="2">派遣公司</option>
+							<option value="1">个人雇主</option>
+							<option value="2">企业雇主</option>
 						</select>
 					</div>
 				</div>

+ 68 - 64
app/agent/controller/Attachment.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace app\agent\controller;
 
 use think\facade\Session;
@@ -10,74 +11,77 @@ use app\common\model\Attachment as AttachmentModel;
 
 class Attachment
 {
-	
-	
-	// 文件上传
-	public function tplFieldFile()
-	{
-		$file = request()->file("file");
-		$savename = \think\facade\Filesystem::disk('public')->putFile('files',$file);
-		if($file){
-			$filename = str_replace(strrchr($_FILES['file']['name'], "."),"",$_FILES['file']['name']);
-			$attachment = AttachmentModel::create([
-				'filename'  	=> $filename,
-				'atype'     	=> 4,
-				'attachment'    => request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-				'createtime'	=> time() 
-			]);
-			exit(json_encode(array(
-				'code' 	=> 0,
-				'msg'   => "",
-				'data'  => array(
-					'src'	=> request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-					'path'	=> "./attachment/". str_replace("\\","/",$savename),
-					'title'	=> $filename
-				)
-			)));
-		}else{
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'   => "上传失败,请稍后重试"
-			)));
-		}
-	}
-	
-	// 图片上传
-	public function tplFieldImage()
-	{
-        $this->validateExt(['jpg,png,jpeg']);
-		$file = request()->file("file");
-		$savename = \think\facade\Filesystem::disk('public')->putFile('images',$file);
-		if($file){
-			$filename = str_replace(strrchr($_FILES['file']['name'], "."),"",$_FILES['file']['name']);
-			$attachment = AttachmentModel::create([
-				'filename'  	=> $filename,
-				'atype'     	=> 1,
-				'attachment'    => request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-				'createtime'	=> time() 
-			]);
-			exit(json_encode(array(
-				'code' 	=> 0,
-				'msg'   => "",
-				'data'  => array(
-					'src'	=> request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-					'title'	=> $filename
-				)
-			)));
-		}else{
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'   => "上传失败,请稍后重试"
-			)));
-		}
-	}
+
+
+    // 文件上传
+    public function tplFieldFile()
+    {
+        $file     = request()->file("file");
+        $savename = \think\facade\Filesystem::disk('public')->putFile('files', $file);
+        if ($file) {
+            $filename   = str_replace(strrchr($_FILES['file']['name'], "."), "", $_FILES['file']['name']);
+            $attachment = AttachmentModel::create([
+                'filename'   => $filename,
+                'atype'      => 4,
+                'attachment' => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                'createtime' => time(),
+            ]);
+            exit(json_encode([
+                'code' => 0,
+                'msg'  => "",
+                'data' => [
+                    'src'   => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                    'path'  => "./attachment/" . str_replace("\\", "/", $savename),
+                    'title' => $filename,
+                ],
+            ]));
+        } else {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "上传失败,请稍后重试",
+            ]));
+        }
+    }
+
+    // 图片上传
+    public function tplFieldImage()
+    {
+        $this->validateExt(['jpg', 'png', 'jpeg']);
+        $file     = request()->file("file");
+        $savename = \think\facade\Filesystem::disk('public')->putFile('images', $file);
+        if ($file) {
+            $filename   = str_replace(strrchr($_FILES['file']['name'], "."), "", $_FILES['file']['name']);
+            $attachment = AttachmentModel::create([
+                'filename'   => $filename,
+                'atype'      => 1,
+                'attachment' => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                'createtime' => time(),
+            ]);
+            exit(json_encode([
+                'code' => 0,
+                'msg'  => "",
+                'data' => [
+                    'src'   => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                    'title' => $filename,
+                ],
+            ]));
+        } else {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "上传失败,请稍后重试",
+            ]));
+        }
+    }
 
     public function validateExt($ext_arr)
     {
         $ext = pathinfo($_FILES['file']['name'])['extension'];
-        if (!in_array($ext,$ext_arr)) {
-            page_result(1, "文件格式不正确");
+        if (!in_array($ext, $ext_arr)) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "文件格式不正确",
+            ]));
         }
     }
-	
+
 }

+ 3 - 1
app/common/model/Worker.php

@@ -41,6 +41,8 @@ class Worker extends Model
         'is_public'    => 'int',
         'income'       => 'decimal',
         'income_total' => 'decimal',
+        'idcardzpic'   => 'string',
+        'idcardfpic'   => 'string',
     ];
 
     // 设置字段自动转换类型
@@ -50,7 +52,7 @@ class Worker extends Model
 
     public function getWtypeTextAttr($value, $data)
     {
-        $wtype = [1 => '普通公司', 2 => '派遣公司'];
+        $wtype = [1 => '个人雇主', 2 => '企业雇主'];
         return $wtype[$data['wtype']];
     }
 

+ 1 - 7
app/common/service/BalanceService.php

@@ -2,7 +2,6 @@
 
 namespace app\common\service;
 
-use app\common\model\Config;
 use app\common\model\UserBalance;
 use app\common\model\UserParam as UserParamModel;
 use app\common\model\User as UserModel;
@@ -59,13 +58,8 @@ class BalanceService extends BaseService
 
         //经济人收益
         if (!empty($commission[$field['broker']])) {
-            $broker_id = $user['broker_id'];
-            if (empty($broker_id)) {
-                $broker_id = Config::getConfigValue('default_broker');
-            }
-
             $incomeService = new IncomeService();
-            $incomeService->add($broker_id, $commission[$field['broker']], $type['title'], $type['remark']);
+            $incomeService->add($user['broker_id'], $commission[$field['broker']], $type['title'], $type['remark']);
         }
     }
 }

+ 5 - 0
app/common/service/IncomeService.php

@@ -4,6 +4,7 @@ namespace app\common\service;
 
 use app\common\model\BrokerIncome as BrokerIncomeModel;
 use app\common\model\Broker as BrokerModel;
+use app\common\model\Config;
 use app\common\model\Worker as WorkerModel;
 use app\common\model\Agent as AgentModel;
 
@@ -15,6 +16,10 @@ class IncomeService extends BaseService
             return false;
         }
 
+        if (empty($broker_id)) {
+            $broker_id = Config::getConfigValue('default_broker');
+        }
+
         $broker   = BrokerModel::where('id', $broker_id)->find();
         $income = new BrokerIncomeModel();
         $income->save([

+ 1 - 1
app/dataTable.sql

@@ -93,7 +93,7 @@ CREATE TABLE IF NOT EXISTS `echo_worker` (
 	`userid` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '关联用户ID',
 	`loginname` varchar(255) NOT NULL COMMENT '登录账号',
 	`password` varchar(255) NOT NULL COMMENT '登录密码',
-	`wtype` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态:1普通公司,2派遣公司,3企业工厂',
+	`wtype` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态:1个人雇主,2企业雇主,3企业工厂',
 	`title` varchar(255) NOT NULL COMMENT '公司名称',
 	`ftitle` varchar(255) NOT NULL COMMENT '微店名称',
 	`tilpic` varchar(255) NOT NULL COMMENT '微店图标',

+ 51 - 52
app/mainapp/controller/Attachment.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace app\mainapp\controller;
 
 use think\facade\Session;
@@ -10,61 +11,59 @@ use app\common\model\Attachment as AttachmentModel;
 
 class Attachment
 {
-	// 单个图片上传
-	public function tplFieldImage()
-	{
-        $this->validateExt(['jpg,png,jpeg']);
-		$file = request()->file("file");
-		$savename = \think\facade\Filesystem::disk('public')->putFile('images',$file);
-		if($file){
-			$filename = str_replace(strrchr($_FILES['file']['name'], "."),"",$_FILES['file']['name']);
-			$attachment = AttachmentModel::create([
-				'filename'  	=> $filename,
-				'atype'     	=> 1,
-				'attachment'    => str_replace("\\","/",$savename),
-				'createtime'	=> time() 
-			]);
-			page_result(0, "", array(
-				'src'	=> request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-				'path'	=> "/attachment/". str_replace("\\","/",$savename),
-				'title'	=> $filename
-			));
-		}else{
-			page_result(1, "上传失败,请稍后重试");
-		}
-	}
-	
-	
-	
-	
-	// 视频文件上传
-	public function tplFieldVideo()
-	{
-        $this->validateExt(['mp4,avi,wmv,mpg,mpeg']);
-		$file = request()->file("file");
-		$savename = \think\facade\Filesystem::disk('public')->putFile('videos',$file);
-		if($file){
-			$filename = str_replace(strrchr($_FILES['file']['name'], "."),"",$_FILES['file']['name']);
-			$attachment = AttachmentModel::create([
-				'filename'  	=> $filename,
-				'atype'     	=> 3,
-				'attachment'    => str_replace("\\","/",$savename),
-				'createtime'	=> time() 
-			]);
-			page_result(0, "", array(
-				'src'	=> request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-				'path'	=> "/attachment/". str_replace("\\","/",$savename),
-				'title'	=> $filename
-			));
-		}else{
-			page_result(1, "上传失败,请稍后重试");
-		}
-	}
+    // 单个图片上传
+    public function tplFieldImage()
+    {
+        $this->validateExt(['jpg', 'png', 'jpeg']);
+        $file     = request()->file("file");
+        $savename = \think\facade\Filesystem::disk('public')->putFile('images', $file);
+        if ($file) {
+            $filename   = str_replace(strrchr($_FILES['file']['name'], "."), "", $_FILES['file']['name']);
+            $attachment = AttachmentModel::create([
+                'filename'   => $filename,
+                'atype'      => 1,
+                'attachment' => str_replace("\\", "/", $savename),
+                'createtime' => time(),
+            ]);
+            page_result(0, "", [
+                'src'   => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                'path'  => "/attachment/" . str_replace("\\", "/", $savename),
+                'title' => $filename,
+            ]);
+        } else {
+            page_result(1, "上传失败,请稍后重试");
+        }
+    }
+
+
+    // 视频文件上传
+    public function tplFieldVideo()
+    {
+        $this->validateExt(['mp4', 'avi', 'wmv', 'mpg', 'mpeg']);
+        $file     = request()->file("file");
+        $savename = \think\facade\Filesystem::disk('public')->putFile('videos', $file);
+        if ($file) {
+            $filename   = str_replace(strrchr($_FILES['file']['name'], "."), "", $_FILES['file']['name']);
+            $attachment = AttachmentModel::create([
+                'filename'   => $filename,
+                'atype'      => 3,
+                'attachment' => str_replace("\\", "/", $savename),
+                'createtime' => time(),
+            ]);
+            page_result(0, "", [
+                'src'   => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                'path'  => "/attachment/" . str_replace("\\", "/", $savename),
+                'title' => $filename,
+            ]);
+        } else {
+            page_result(1, "上传失败,请稍后重试");
+        }
+    }
 
-	public function validateExt($ext_arr)
+    public function validateExt($ext_arr)
     {
         $ext = pathinfo($_FILES['file']['name'])['extension'];
-        if (!in_array($ext,$ext_arr)) {
+        if (!in_array($ext, $ext_arr)) {
             page_result(1, "文件格式不正确");
         }
     }

+ 68 - 64
app/worker/controller/Attachment.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace app\worker\controller;
 
 use think\facade\Session;
@@ -10,74 +11,77 @@ use app\common\model\Attachment as AttachmentModel;
 
 class Attachment
 {
-	
-	
-	// 文件上传
-	public function tplFieldFile()
-	{
-		$file = request()->file("file");
-		$savename = \think\facade\Filesystem::disk('public')->putFile('files',$file);
-		if($file){
-			$filename = str_replace(strrchr($_FILES['file']['name'], "."),"",$_FILES['file']['name']);
-			$attachment = AttachmentModel::create([
-				'filename'  	=> $filename,
-				'atype'     	=> 4,
-				'attachment'    => request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-				'createtime'	=> time() 
-			]);
-			exit(json_encode(array(
-				'code' 	=> 0,
-				'msg'   => "",
-				'data'  => array(
-					'src'	=> request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-					'path'	=> "./attachment/". str_replace("\\","/",$savename),
-					'title'	=> $filename
-				)
-			)));
-		}else{
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'   => "上传失败,请稍后重试"
-			)));
-		}
-	}
-	
-	// 图片上传
-	public function tplFieldImage()
-	{
-        $this->validateExt(['jpg,png,jpeg']);
-		$file = request()->file("file");
-		$savename = \think\facade\Filesystem::disk('public')->putFile('images',$file);
-		if($file){
-			$filename = str_replace(strrchr($_FILES['file']['name'], "."),"",$_FILES['file']['name']);
-			$attachment = AttachmentModel::create([
-				'filename'  	=> $filename,
-				'atype'     	=> 1,
-				'attachment'    => request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-				'createtime'	=> time() 
-			]);
-			exit(json_encode(array(
-				'code' 	=> 0,
-				'msg'   => "",
-				'data'  => array(
-					'src'	=> request()->domain() ."/attachment/". str_replace("\\","/",$savename),
-					'title'	=> $filename
-				)
-			)));
-		}else{
-			exit(json_encode(array(
-				'code' 	=> 1,
-				'msg'   => "上传失败,请稍后重试"
-			)));
-		}
-	}
+
+
+    // 文件上传
+    public function tplFieldFile()
+    {
+        $file     = request()->file("file");
+        $savename = \think\facade\Filesystem::disk('public')->putFile('files', $file);
+        if ($file) {
+            $filename   = str_replace(strrchr($_FILES['file']['name'], "."), "", $_FILES['file']['name']);
+            $attachment = AttachmentModel::create([
+                'filename'   => $filename,
+                'atype'      => 4,
+                'attachment' => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                'createtime' => time(),
+            ]);
+            exit(json_encode([
+                'code' => 0,
+                'msg'  => "",
+                'data' => [
+                    'src'   => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                    'path'  => "./attachment/" . str_replace("\\", "/", $savename),
+                    'title' => $filename,
+                ],
+            ]));
+        } else {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "上传失败,请稍后重试",
+            ]));
+        }
+    }
+
+    // 图片上传
+    public function tplFieldImage()
+    {
+        $this->validateExt(['jpg', 'png', 'jpeg']);
+        $file     = request()->file("file");
+        $savename = \think\facade\Filesystem::disk('public')->putFile('images', $file);
+        if ($file) {
+            $filename   = str_replace(strrchr($_FILES['file']['name'], "."), "", $_FILES['file']['name']);
+            $attachment = AttachmentModel::create([
+                'filename'   => $filename,
+                'atype'      => 1,
+                'attachment' => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                'createtime' => time(),
+            ]);
+            exit(json_encode([
+                'code' => 0,
+                'msg'  => "",
+                'data' => [
+                    'src'   => request()->domain() . "/attachment/" . str_replace("\\", "/", $savename),
+                    'title' => $filename,
+                ],
+            ]));
+        } else {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "上传失败,请稍后重试",
+            ]));
+        }
+    }
 
     public function validateExt($ext_arr)
     {
         $ext = pathinfo($_FILES['file']['name'])['extension'];
-        if (!in_array($ext,$ext_arr)) {
-            page_result(1, "文件格式不正确");
+        if (!in_array($ext, $ext_arr)) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => "文件格式不正确",
+            ]));
         }
     }
-	
+
 }