diff --git a/.gitignore b/.gitignore index 9be8bf4..dac9a40 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ /public/static/home/dev /public/static/home/oa /config/database.php +/public/.htaccess +/public/nginx.htaccess diff --git a/app/admin/common.php b/app/admin/common.php index fd2aa8a..bf740b5 100644 --- a/app/admin/common.php +++ b/app/admin/common.php @@ -9,6 +9,9 @@ use think\facade\Config; use think\facade\Request; use think\facade\Cache; use think\facade\Db; +use app\admin\model\StoreCategory; // 商品分类模型 +use app\admin\model\StoreBrandCategory; // 商品品牌列表模型 + //获取后台模块当前登录用户的信息 function get_login_admin($key = "") { @@ -93,6 +96,7 @@ function set_recursion($result, $pid = 0, $level=-1) static $list = array(); static $space = ['','├─','§§├─','§§§§├─','§§§§§§├─']; $level++; + foreach ($result as $k => $v) { if ($v['pid'] == $pid) { if ($pid != 0) { @@ -103,9 +107,69 @@ function set_recursion($result, $pid = 0, $level=-1) set_recursion($result, $v['id'],$level); } } + return $list; } +//读取商品品牌节点列表 +function get_band_calss() +{ + $result = StoreBrandCategory::where('pid', 0)->order('sort desc')->select()->toArray(); + return $result; +} + +//递归排序,用于分类选择 +function set_band_recursion($result, $pid = 0, $level=-1) +{ + /*记录排序后的类别数组*/ + static $list = array(); + static $space = ['','├─','§§├─','§§§§├─','§§§§§§├─']; + $level++; + + foreach ($result as $k => $v) { + if ($v['pid'] == $pid) { + if ($pid != 0) { + $v['cate_name'] = $space[$level] . $v['cate_name']; + } + /*将该类别的数据放入list中*/ + $list[] = $v; + set_band_recursion($result, $v['store_brand_category_id'],$level); + } + } + + return $list; +} + +//读取商品品牌分类节点列表 +function get_product_calss() +{ + $result = StoreCategory::select()->toArray(); + return $result; +} + +//递归排序,用于分类选择 +function set_product_recursion($result, $pid = 0, $level=-1) +{ + /*记录排序后的类别数组*/ + static $list = array(); + static $space = ['','├─','§§├─','§§§§├─','§§§§§§├─']; + $level++; + + foreach ($result as $k => $v) { + if ($v['pid'] == $pid) { + if ($pid != 0) { + $v['cate_name'] = $space[$level] . $v['cate_name']; + } + /*将该类别的数据放入list中*/ + $list[] = $v; + set_product_recursion($result, $v['store_category_id'],$level); + } + } + + return $list; +} + + /** * 根据id递归返回子数据 * @param $data 数据 diff --git a/app/admin/controller/product/Band.php b/app/admin/controller/product/Band.php new file mode 100644 index 0000000..f3444a8 --- /dev/null +++ b/app/admin/controller/product/Band.php @@ -0,0 +1,208 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.band/index?category_id='.$this->category_id, + '/admin/product.band/add', + '/admin/product.band/edit', + '/admin/product.band/del', + '/admin/product.band/index', + ]; + } + + /** + * + * 商品品牌列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = StoreBrand::where($where)->count(); + + $list = StoreBrand::order('sort desc, brand_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreBrand::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['brand_name'] = $params['brand_name']; // 品牌名称 + $data['is_show'] = isset($params['is_show']); // 状态 + $data['brand_category_id'] = $params['brand_category_id']; // 所属ID + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = StoreBrand::create($data); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $storeBrandCategory = StoreBrandCategory::order('sort desc') + ->where('pid', 0) + ->where('is_show', 1) + ->select(); + + View::assign('storeBrandCategory', $storeBrandCategory); + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['brand_name'] = $params['brand_name']; // 品牌名称 + $data['is_show'] = isset($params['is_show']); // 状态 + $data['brand_category_id'] = $params['brand_category_id']; // 所属ID + $data['sort'] = $params['sort']; // 排序 + + // 数据更新 + $res = StoreBrand::where('brand_id', $params['id'])->update($data); + + if ($res){ + return to_assign(0,'更新成功',['aid'=>$res]); + } + + return to_assign(1, '更新失败,原因:'.$res); + + }else{ + + $supplyChain = StoreBrand::with(['storeBrandCategory'])->find($id); // 取出当前品牌数据 + + $storeBrandCategory = StoreBrandCategory::order('sort desc') + ->where('pid', 0) + ->where('is_show', 1) + ->select(); + + View::assign('storeBrandCategory', $storeBrandCategory); + View::assign('detail', $supplyChain); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + $res = StoreBrand::where('brand_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + + +} \ No newline at end of file diff --git a/app/admin/controller/product/BrandClassify.php b/app/admin/controller/product/BrandClassify.php new file mode 100644 index 0000000..35978c5 --- /dev/null +++ b/app/admin/controller/product/BrandClassify.php @@ -0,0 +1,216 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.brandClassify/index?category_id='.$this->category_id, + '/admin/product.brandClassify/add', + '/admin/product.brandClassify/edit', + '/admin/product.brandClassify/del', + '/admin/product.brandClassify/index', + ]; + } + + /** + * + * 商品品牌列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = StoreBrandCategory::where($where)->count(); + + $list = StoreBrandCategory::order('sort desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreBrandCategory::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = StoreBrandCategory::create($data); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $res = StoreBrandCategory::where('store_brand_category_id', $params['id'])->update($data); + + if ($res){ + return to_assign(0,'更新成功',['aid'=>$res]); + } + + return to_assign(1, '更新失败,原因:'.$res); + + }else{ + + $storeBrandCtegory = StoreBrandCategory::find($id); // 取出当前品牌分类信息 + + View::assign('detail', $storeBrandCtegory); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + // 验证下面是否有子分类 + if(StoreBrandCategory::where('pid', $id)->count()) + { + return to_assign(1, '请先删除子分类!'); + } + + $res = StoreBrandCategory::where('store_brand_category_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + + /** + * + * 子分类 + * + */ + public function street($pcode) + { + $storeBrandCategory = StoreBrandCategory::order('sort desc') + ->where('is_show', 1) + ->where('pid', $pcode) + ->select(); + + return json($storeBrandCategory); + } + +} \ No newline at end of file diff --git a/app/admin/controller/product/Classify.php b/app/admin/controller/product/Classify.php new file mode 100644 index 0000000..343e280 --- /dev/null +++ b/app/admin/controller/product/Classify.php @@ -0,0 +1,226 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.classify/index?category_id='.$this->category_id, + '/admin/product.classify/add', + '/admin/product.classify/edit', + '/admin/product.classify/delete' + ]; + } + + /** + * + * 商城分类列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = StoreCategory::where($where)->count(); + + // $list = StoreCategory::with(['merchant', 'street', 'area'])->order('id desc')->select(); + $list = StoreCategory::order('store_category_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreCategory::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + $param = get_params(); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pic'] = $params['pic']; // 图标 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = StoreCategory::create($data); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } else { + + $id = isset($param['id']) ? $param['id'] : 0; + $pid = isset($param['pid']) ? $param['pid'] : 0; + + if($id > 0){ + $detail = StoreCategory::find($id); // 分类模型 + View::assign('detail', $detail); + } + + $storeCategoryList = StoreCategory::order('store_category_id desc')->where('pid', 0)->select(); + + View::assign('storeCategoryList', $storeCategoryList); + View::assign('url', $this->url); + + View::assign('id', $id); + View::assign('pid', $pid); + return view(); + + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pic'] = $params['pic']; // 图标 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + + // 数据更新 + $res = StoreCategory::where('store_category_id', $params['id'])->update($data); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $category = StoreCategory::with(['storeCategory'])->find($id); // 取出当前供应链数据 + $storeCategoryList = StoreCategory::order('store_category_id desc')->where('pid', 0)->select(); + + View::assign('storeCategoryList', $storeCategoryList); + View::assign('detail', $category); + + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function delete() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + $supplyChain = SupplyChain::with(['linkMerchant'])->find($id); + // 删除关联模型 + $res = $supplyChain->together(['linkMerchant'])->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + + /** + * + * 获取子分类 + * + */ + public function street($pcode) + { + $storeCategory = StoreCategory::order('sort desc') + ->where('is_show', 1) + ->where('pid', $pcode) + ->select(); + + return json($storeCategory); + } +} \ No newline at end of file diff --git a/app/admin/controller/product/Comment.php b/app/admin/controller/product/Comment.php new file mode 100644 index 0000000..a4183ba --- /dev/null +++ b/app/admin/controller/product/Comment.php @@ -0,0 +1,263 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.comment/index?category_id='.$this->category_id, + '/admin/product.comment/add', + '/admin/product.comment/edit', + '/admin/product.comment/del', + '/admin/product.comment/index', + ]; + } + + /** + * + * 商品评论列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = StoreProductReply::where($where)->count(); + + $list = StoreProductReply::with(['product'])->order('reply_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreProductReply::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = json_encode($params['mer_id']); // 已选商户 + + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = SupplyChain::create($data); + + // 关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $res->linkMerchant()->save($dataLink); // 插入关联数据 + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('editor', get_system_config('other','editor')); + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['id'] = $params['id']; // 当前ID + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = isset($params['mer_id']) ? json_encode($params['mer_id']) : null; // 已选商户 + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $supplyChain = SupplyChain::with(['linkMerchant'])->find($data['id']); + $res = $supplyChain->update($data); + + // 获取关联数据一对一---曲线救国 + $linkMerchant = $supplyChain['linkMerchant']; + // $linkMerchantArr = $linkMerchant->column('id'); + + // 先删除关联数据-- 曲线救国 + $linkMerchant->delete(); + + // 关联商户状态 + if($data['mer_id_list']) + { + // 再重新将关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $supplyChain->linkMerchant()->save($dataLink); + } + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $supplyChain = SupplyChain::with(['merchant', 'street', 'area'])->find($id); // 取出当前供应链数据 + + View::assign('detail', $supplyChain); + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + $res = StoreProductReply::where('reply_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + +} \ No newline at end of file diff --git a/app/admin/controller/product/Guarantee.php b/app/admin/controller/product/Guarantee.php new file mode 100644 index 0000000..58c92b3 --- /dev/null +++ b/app/admin/controller/product/Guarantee.php @@ -0,0 +1,196 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.guarantee/index?category_id='.$this->category_id, + '/admin/product.guarantee/add', + '/admin/product.guarantee/edit', + '/admin/product.guarantee/del', + '/admin/product.guarantee/index', + ]; + } + + /** + * + * 商品保障服务列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = GuaranteeModel::where($where)->count(); + + $list = GuaranteeModel::order('guarantee_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = GuaranteeModel::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['guarantee_name'] = $params['guarantee_name']; // 标签名 + $data['status'] = isset($params['status']) && $params['status'] == 'on'? 1:0; // 状态 + $data['guarantee_info'] = $params['guarantee_info']; // 说明 + $data['image'] = $params['image']; // 说明 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = GuaranteeModel::create($data); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['guarantee_name'] = $params['guarantee_name']; // 标签名 + $data['status'] = isset($params['status']) && $params['status'] == 'on'? 1:0; // 状态 + $data['guarantee_info'] = $params['guarantee_info']; // 说明 + $data['image'] = $params['image']; // 说明 + $data['sort'] = $params['sort']; // 排序 + $data['update_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $res = GuaranteeModel::where('guarantee_id', $params['id'])->update($data); + + if ($res){ + return to_assign(0,'更新成功',['aid'=>$res]); + } + + return to_assign(1, '更新失败,原因:'.$res); + + }else{ + + $supplyChain = GuaranteeModel::find($id); // 取出当前保障服务数据 + + View::assign('detail', $supplyChain); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + $res = GuaranteeModel::where('guarantee_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + +} \ No newline at end of file diff --git a/app/admin/controller/product/Label.php b/app/admin/controller/product/Label.php new file mode 100644 index 0000000..e2643a0 --- /dev/null +++ b/app/admin/controller/product/Label.php @@ -0,0 +1,194 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.label/index?category_id='.$this->category_id, + '/admin/product.label/add', + '/admin/product.label/edit', + '/admin/product.label/del', + '/admin/product.label/index', + ]; + } + + /** + * + * 商品评论列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = StoreProductLabel::where($where)->count(); + + $list = StoreProductLabel::with(['product'])->order('product_label_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreProductLabel::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['label_name'] = $params['label_name']; // 标签名 + $data['status'] = isset($params['status']) && $params['status'] == 'on'? 1:0; // 状态 + $data['info'] = $params['info']; // 说明 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = StoreProductLabel::create($data); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['label_name'] = $params['label_name']; // 标签名 + $data['status'] = isset($params['status']) && $params['status'] == 'on'? 1:0; // 状态 + $data['info'] = $params['info']; // 说明 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $res = StoreProductLabel::where('product_label_id', $params['id'])->update($data); + + if ($res){ + return to_assign(0,'更新成功',['aid'=>$res]); + } + + return to_assign(1, '更新失败,原因:'.$res); + + }else{ + + $supplyChain = StoreProductLabel::find($id); // 取出当前供应链数据 + + View::assign('detail', $supplyChain); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + $res = StoreProductLabel::where('product_label_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + +} \ No newline at end of file diff --git a/app/admin/controller/product/MerSpecs.php b/app/admin/controller/product/MerSpecs.php new file mode 100644 index 0000000..d65079e --- /dev/null +++ b/app/admin/controller/product/MerSpecs.php @@ -0,0 +1,216 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.priceDescription/index?category_id='.$this->category_id, + '/admin/product.priceDescription/add', + '/admin/product.priceDescription/edit', + '/admin/product.priceDescription/del', + '/admin/product.priceDescription/index', + ]; + } + + /** + * + * 商品价格列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = StoreBrandCategory::where($where)->count(); + + $list = StoreBrandCategory::order('sort desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreBrandCategory::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = StoreBrandCategory::create($data); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $res = StoreBrandCategory::where('store_brand_category_id', $params['id'])->update($data); + + if ($res){ + return to_assign(0,'更新成功',['aid'=>$res]); + } + + return to_assign(1, '更新失败,原因:'.$res); + + }else{ + + $storeBrandCtegory = StoreBrandCategory::find($id); // 取出当前品牌分类信息 + + View::assign('detail', $storeBrandCtegory); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + // 验证下面是否有子分类 + if(StoreBrandCategory::where('pid', $id)->count()) + { + return to_assign(1, '请先删除子分类!'); + } + + $res = StoreBrandCategory::where('store_brand_category_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + + /** + * + * 子分类 + * + */ + public function street($pcode) + { + $storeBrandCategory = StoreBrandCategory::order('sort desc') + ->where('is_show', 1) + ->where('pid', $pcode) + ->select(); + + return json($storeBrandCategory); + } + +} \ No newline at end of file diff --git a/app/admin/controller/product/PriceDescription.php b/app/admin/controller/product/PriceDescription.php new file mode 100644 index 0000000..e298bdf --- /dev/null +++ b/app/admin/controller/product/PriceDescription.php @@ -0,0 +1,216 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.priceDescription/index?category_id='.$this->category_id, + '/admin/product.priceDescription/add', + '/admin/product.priceDescription/edit', + '/admin/product.priceDescription/del', + '/admin/product.priceDescription/index', + ]; + } + + /** + * + * 商品价格列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = StoreBrandCategory::where($where)->count(); + + $list = StoreBrandCategory::order('sort desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreBrandCategory::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = StoreBrandCategory::create($data); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $res = StoreBrandCategory::where('store_brand_category_id', $params['id'])->update($data); + + if ($res){ + return to_assign(0,'更新成功',['aid'=>$res]); + } + + return to_assign(1, '更新失败,原因:'.$res); + + }else{ + + $storeBrandCtegory = StoreBrandCategory::find($id); // 取出当前品牌分类信息 + + View::assign('detail', $storeBrandCtegory); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + // 验证下面是否有子分类 + if(StoreBrandCategory::where('pid', $id)->count()) + { + return to_assign(1, '请先删除子分类!'); + } + + $res = StoreBrandCategory::where('store_brand_category_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + + /** + * + * 子分类 + * + */ + public function street($pcode) + { + $storeBrandCategory = StoreBrandCategory::order('sort desc') + ->where('is_show', 1) + ->where('pid', $pcode) + ->select(); + + return json($storeBrandCategory); + } + +} \ No newline at end of file diff --git a/app/admin/controller/product/Product.php b/app/admin/controller/product/Product.php new file mode 100644 index 0000000..0d3466a --- /dev/null +++ b/app/admin/controller/product/Product.php @@ -0,0 +1,262 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.product/index?category_id='.$this->category_id, + '/admin/product.product/add', + '/admin/product.product/edit', + '/admin/product.product/delete', + '/admin/product.product/index', + ]; + } + + /** + * + * 供应链团队列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = EbStoreProduct::where($where)->count(); + + $list = EbStoreProduct::with(['merchant' => ['merchantType', 'category']])->order('product_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = SupplyChain::with(['merchant' => ['merchantType', 'category']])->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = json_encode($params['mer_id']); // 已选商户 + + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = SupplyChain::create($data); + + // 关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $res->linkMerchant()->save($dataLink); // 插入关联数据 + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('editor', get_system_config('other','editor')); + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['id'] = $params['id']; // 当前ID + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = isset($params['mer_id']) ? json_encode($params['mer_id']) : null; // 已选商户 + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $supplyChain = SupplyChain::with(['linkMerchant'])->find($data['id']); + $res = $supplyChain->update($data); + + // 获取关联数据一对一---曲线救国 + $linkMerchant = $supplyChain['linkMerchant']; + // $linkMerchantArr = $linkMerchant->column('id'); + + // 先删除关联数据-- 曲线救国 + $linkMerchant->delete(); + + // 关联商户状态 + if($data['mer_id_list']) + { + // 再重新将关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $supplyChain->linkMerchant()->save($dataLink); + } + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $supplyChain = SupplyChain::with(['merchant', 'street', 'area'])->find($id); // 取出当前供应链数据 + + View::assign('detail', $supplyChain); + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function delete() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + $supplyChain = SupplyChain::with(['linkMerchant'])->find($id); + // 删除关联模型 + $res = $supplyChain->together(['linkMerchant'])->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + +} \ No newline at end of file diff --git a/app/admin/controller/product/Specs.php b/app/admin/controller/product/Specs.php new file mode 100644 index 0000000..c421474 --- /dev/null +++ b/app/admin/controller/product/Specs.php @@ -0,0 +1,216 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.priceDescription/index?category_id='.$this->category_id, + '/admin/product.priceDescription/add', + '/admin/product.priceDescription/edit', + '/admin/product.priceDescription/del', + '/admin/product.priceDescription/index', + ]; + } + + /** + * + * 商品价格列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = StoreBrandCategory::where($where)->count(); + + $list = StoreBrandCategory::order('sort desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreBrandCategory::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = StoreBrandCategory::create($data); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $res = StoreBrandCategory::where('store_brand_category_id', $params['id'])->update($data); + + if ($res){ + return to_assign(0,'更新成功',['aid'=>$res]); + } + + return to_assign(1, '更新失败,原因:'.$res); + + }else{ + + $storeBrandCtegory = StoreBrandCategory::find($id); // 取出当前品牌分类信息 + + View::assign('detail', $storeBrandCtegory); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + // 验证下面是否有子分类 + if(StoreBrandCategory::where('pid', $id)->count()) + { + return to_assign(1, '请先删除子分类!'); + } + + $res = StoreBrandCategory::where('store_brand_category_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + + /** + * + * 子分类 + * + */ + public function street($pcode) + { + $storeBrandCategory = StoreBrandCategory::order('sort desc') + ->where('is_show', 1) + ->where('pid', $pcode) + ->select(); + + return json($storeBrandCategory); + } + +} \ No newline at end of file diff --git a/app/admin/controller/supplychain/Index.php b/app/admin/controller/supplychain/Index.php new file mode 100644 index 0000000..38a0fec --- /dev/null +++ b/app/admin/controller/supplychain/Index.php @@ -0,0 +1,259 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/supplychain.index/index?category_id='.$this->category_id, + '/admin/supplychain.index/add', + '/admin/supplychain.index/edit', + '/admin/supplychain.index/delete', + '/admin/supplychain.merchant/index', + '/admin/supplychain.merchant/bill', + ]; + } + + /** + * + * 供应链团队列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where[]= ['status','=',0]; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = SupplyChain::where($where)->count(); + + $list = SupplyChain::with(['merchant', 'street', 'area'])->order('id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = SupplyChain::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['shareRate'] = $params['shareRate']; // 分润比例 + $data['mer_id_list'] = json_encode($params['mer_id']); // 已选商户 + + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = SupplyChain::create($data); + + // 关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $res->linkMerchant()->save($dataLink); // 插入关联数据 + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('editor', get_system_config('other','editor')); + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['id'] = $params['id']; // 当前ID + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['shareRate'] = $params['shareRate']; // 分润比例 + $data['mer_id_list'] = isset($params['mer_id']) ? json_encode($params['mer_id']) : null; // 已选商户 + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $supplyChain = SupplyChain::with(['linkMerchant'])->find($data['id']); + $res = $supplyChain->update($data); + + // 获取关联数据一对一---曲线救国 + $linkMerchant = $supplyChain['linkMerchant']; + // $linkMerchantArr = $linkMerchant->column('id'); + + // 先删除关联数据-- 曲线救国 + $linkMerchant->delete(); + + // 关联商户状态 + if($data['mer_id_list']) + { + // 再重新将关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $supplyChain->linkMerchant()->save($dataLink); + } + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $supplyChain = SupplyChain::with(['merchant', 'street', 'area'])->find($id); // 取出当前供应链数据 + + View::assign('detail', $supplyChain); + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function delete() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + $supplyChain = SupplyChain::with(['linkMerchant'])->find($id); + // 删除关联模型 + $res = $supplyChain->together(['linkMerchant'])->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + +} \ No newline at end of file diff --git a/app/admin/controller/supplychain/Merchant.php b/app/admin/controller/supplychain/Merchant.php new file mode 100644 index 0000000..d77e5f8 --- /dev/null +++ b/app/admin/controller/supplychain/Merchant.php @@ -0,0 +1,185 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/supplychain.index/index?category_id='.$this->category_id, + '/admin/supplychain.index/add', + '/admin/supplychain.index/edit', + '/admin/supplychain.index/delete', + '/admin/supplychain.merchant/index', + '/admin/supplychain.merchant/bill', + ]; + } + + /** + * + * 供应链团队列表 + * + */ + public function index() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = SupplyChainLinkMerchant::where($where)->count(); + + $list = SupplyChainLinkMerchant::with(['supplyChain', 'merchant'])->order('id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $total = SupplyChainLinkMerchant::count(); + $list = SupplyChainLinkMerchant::with(['merchant', 'supplyChain'])->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + return view(); + } + } + + /** + * + * 交易订单 + * + */ + public function bill() + { + if (request()->isAjax()) { + + $params= get_params(); + + $where = []; + + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + $total = StoreOrderModel::where($where)->count(); + + $list = StoreOrderModel::with(['merchant'])->order('order_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $total = StoreOrderModel::count(); + $list = StoreOrderModel::with(['merchant'])->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + return view(); + } + + } + + /** + * + * 新增 + * + */ + public function add() + { + return view(); + } + + /** + * + * 编辑 + * + */ + public function edit() + { + return view(); + } + + /** + * + * 删除 + * + */ + public function delete() + { + return view(); + } + +} \ No newline at end of file diff --git a/app/admin/model/EbStoreProduct.php b/app/admin/model/EbStoreProduct.php new file mode 100644 index 0000000..b5a873b --- /dev/null +++ b/app/admin/model/EbStoreProduct.php @@ -0,0 +1,31 @@ +hasOne(Merchant::class, 'mer_id', 'mer_id'); + } + } \ No newline at end of file diff --git a/app/admin/model/GeoArea.php b/app/admin/model/GeoArea.php new file mode 100644 index 0000000..3ac0060 --- /dev/null +++ b/app/admin/model/GeoArea.php @@ -0,0 +1,26 @@ +hasOne(GeoArea::class, 'area_code', 'area_code'); + } + } \ No newline at end of file diff --git a/app/admin/model/GeoCity.php b/app/admin/model/GeoCity.php new file mode 100644 index 0000000..ea24176 --- /dev/null +++ b/app/admin/model/GeoCity.php @@ -0,0 +1,19 @@ +hasOne(GeoArea::class, 'area_code', 'area_code'); + } + } \ No newline at end of file diff --git a/app/admin/model/Guarantee.php b/app/admin/model/Guarantee.php new file mode 100644 index 0000000..22dd3b8 --- /dev/null +++ b/app/admin/model/Guarantee.php @@ -0,0 +1,23 @@ +hasOneThrough(SupplyChainLinkMerchant::class, SupplyChain::class); + } + + /** + * + * 关联商户类型 + * + */ + public function merchantType() + { + return $this->hasOne(MerchantType::class, 'mer_type_id', 'type_id'); + } + + /** + * + * 关联商户类别 + * + */ + public function category() + { + return $this->hasOne(MerchantCategory::class, 'merchant_category_id', 'category_id'); + } + + } \ No newline at end of file diff --git a/app/admin/model/MerchantCategory.php b/app/admin/model/MerchantCategory.php new file mode 100644 index 0000000..b486efa --- /dev/null +++ b/app/admin/model/MerchantCategory.php @@ -0,0 +1,22 @@ +hasOne(StoreBrandCategory::class, 'store_brand_category_id', 'brand_category_id'); + } + } \ No newline at end of file diff --git a/app/admin/model/StoreBrandCategory.php b/app/admin/model/StoreBrandCategory.php new file mode 100644 index 0000000..e9e09c2 --- /dev/null +++ b/app/admin/model/StoreBrandCategory.php @@ -0,0 +1,33 @@ +hasOne(StoreBrandCategory::class, 'store_brand_category_id', 'brand_category_id'); + } + + } \ No newline at end of file diff --git a/app/admin/model/StoreCart.php b/app/admin/model/StoreCart.php new file mode 100644 index 0000000..be58d51 --- /dev/null +++ b/app/admin/model/StoreCart.php @@ -0,0 +1,40 @@ +hasOne(EbStoreProduct::class, 'product_id', 'product_id'); + } + + /** + * + * 所属用户 + * + */ + public function user() + { + return $this->hasOne(Merchant::class, 'mer_id', 'mer_id'); + } + } \ No newline at end of file diff --git a/app/admin/model/StoreCategory.php b/app/admin/model/StoreCategory.php new file mode 100644 index 0000000..44807b6 --- /dev/null +++ b/app/admin/model/StoreCategory.php @@ -0,0 +1,30 @@ +hasOne(StoreCategory::class, 'store_category_id', 'pid'); + } + + } \ No newline at end of file diff --git a/app/admin/model/StoreOrder.php b/app/admin/model/StoreOrder.php new file mode 100644 index 0000000..0fbfa00 --- /dev/null +++ b/app/admin/model/StoreOrder.php @@ -0,0 +1,64 @@ +hasOne(Merchant::class, 'mer_id', 'mer_id'); + } + + /** + * 所属商品 + * + */ + public function cart() + { + return $this->hasOne(StoreCart::class, 'cart_id', 'cart_id'); + } + + /** + * 获取购物车商品 + * + */ + public function getCartIdAttr($value) + { + // 分割为数组 + $cartId = explode(',', $value); + // 购物车ID + $scartList = StoreCart::whereIn('cart_id', $cartId)->with(['product'])->select(); + + return $scartList; + } + + /** + * + * 所属用户 + * + */ + public function user() + { + return $this->hasOne(Merchant::class, 'mer_id', 'mer_id'); + } + } \ No newline at end of file diff --git a/app/admin/model/StoreProductLabel.php b/app/admin/model/StoreProductLabel.php new file mode 100644 index 0000000..881f58a --- /dev/null +++ b/app/admin/model/StoreProductLabel.php @@ -0,0 +1,51 @@ +hasOne(EbStoreProduct::class, 'product_id', 'product_id'); + } + } \ No newline at end of file diff --git a/app/admin/model/StoreProductReply.php b/app/admin/model/StoreProductReply.php new file mode 100644 index 0000000..e4fcbb3 --- /dev/null +++ b/app/admin/model/StoreProductReply.php @@ -0,0 +1,51 @@ +hasOne(EbStoreProduct::class, 'product_id', 'product_id'); + } + } \ No newline at end of file diff --git a/app/admin/model/SupplyChain.php b/app/admin/model/SupplyChain.php new file mode 100644 index 0000000..2b6762a --- /dev/null +++ b/app/admin/model/SupplyChain.php @@ -0,0 +1,60 @@ +hasManyThrough(Merchant::class, SupplyChainLinkMerchant::class, 'fa_supply_chain_id', 'mer_id', 'id', 'eb_merchant_id'); + } + + /** + * + * 关联中间表 + * + */ + public function linkMerchant() + { + return $this->hasMany(SupplyChainLinkMerchant::class, 'fa_supply_chain_id'); + } + + /** + * 关联街道 + * + * + */ + public function street() + { + return $this->hasOne(GeoStreet::class, 'street_id', 'street_id'); + } + + /** + * 关联区县 + * + * + */ + public function area() + { + return $this->hasOne(GeoArea::class, 'area_id', 'area_id'); + } + } \ No newline at end of file diff --git a/app/admin/model/SupplyChainLinkMerchant.php b/app/admin/model/SupplyChainLinkMerchant.php new file mode 100644 index 0000000..b2cf046 --- /dev/null +++ b/app/admin/model/SupplyChainLinkMerchant.php @@ -0,0 +1,44 @@ +hasOne(SupplyChain::class, 'id', 'fa_supply_chain_id'); + } + + /** + * + * 所属商户 + * 一对一 + * + */ + public function merchant() + { + return $this->hasOne(Merchant::class, 'mer_id', 'eb_merchant_id'); + } + } \ No newline at end of file diff --git a/app/admin/view/product/Label/add.html b/app/admin/view/product/Label/add.html new file mode 100644 index 0000000..4465a02 --- /dev/null +++ b/app/admin/view/product/Label/add.html @@ -0,0 +1,102 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

添加

+ + + + + + + + + + + + + + + +
标签名称* + +
说明 + +
排序 + + +
+ +
+ +
+
+
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/Label/edit.html b/app/admin/view/product/Label/edit.html new file mode 100644 index 0000000..cf1d79e --- /dev/null +++ b/app/admin/view/product/Label/edit.html @@ -0,0 +1,97 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + +
标签名称* + +
说明 + +
排序 + + +
+ +
+ +
+
+
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/Label/index.html b/app/admin/view/product/Label/index.html new file mode 100644 index 0000000..f764ee9 --- /dev/null +++ b/app/admin/view/product/Label/index.html @@ -0,0 +1,157 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/band/add.html b/app/admin/view/product/band/add.html new file mode 100644 index 0000000..cd6974f --- /dev/null +++ b/app/admin/view/product/band/add.html @@ -0,0 +1,167 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

添加

+ + + + + + + + + + + + + + + + + +
上级分类* + + + +
+ +
+
+
+
+
品牌名称* + +
+
+ +
+ +
+
+
排序 + +
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/band/edit.html b/app/admin/view/product/band/edit.html new file mode 100644 index 0000000..e764766 --- /dev/null +++ b/app/admin/view/product/band/edit.html @@ -0,0 +1,165 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + + +
上级分类* + + + +
+ +
+
+
+
+
品牌名称* + +
+
+ +
+ +
+
+
排序 + +
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/band/index.html b/app/admin/view/product/band/index.html new file mode 100644 index 0000000..4c48c45 --- /dev/null +++ b/app/admin/view/product/band/index.html @@ -0,0 +1,152 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/brand_classify/add.html b/app/admin/view/product/brand_classify/add.html new file mode 100644 index 0000000..d452070 --- /dev/null +++ b/app/admin/view/product/brand_classify/add.html @@ -0,0 +1,122 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

添加

+ + + + + + + + + + + + + + + +
上级分类* + + +
分类名称 + +
+
+ +
+ +
+
+
排序 + +
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/brand_classify/edit.html b/app/admin/view/product/brand_classify/edit.html new file mode 100644 index 0000000..abc9fed --- /dev/null +++ b/app/admin/view/product/brand_classify/edit.html @@ -0,0 +1,119 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + +
上级分类* + + +
分类名称 + +
+
+ +
+ +
+
+
排序 + +
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/brand_classify/index.html b/app/admin/view/product/brand_classify/index.html new file mode 100644 index 0000000..d31b0cc --- /dev/null +++ b/app/admin/view/product/brand_classify/index.html @@ -0,0 +1,126 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+ +
+
+
+
+
+ + + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/classify/add.html b/app/admin/view/product/classify/add.html new file mode 100644 index 0000000..8468a58 --- /dev/null +++ b/app/admin/view/product/classify/add.html @@ -0,0 +1,108 @@ +{extend name="common/base" /} + +{block name="body"} +
+

添加分类

+ + + + + + + + + + + + + + + + + + + + + +
上级分类* + +
分类名称* + + +
分类图片 +
+ +
+ + +
+
+
排序 + + +
+ +
+ +
+
+
+ +
+ + + +
+
+{/block} + + + +{block name="script"} + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/classify/edit.html b/app/admin/view/product/classify/edit.html new file mode 100644 index 0000000..5e4547b --- /dev/null +++ b/app/admin/view/product/classify/edit.html @@ -0,0 +1,144 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + + + + + + + + +
上级分类* + +
+
+
+
+ +
+ +
+
+
分类图片 +
+ +
+ + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/classify/index.html b/app/admin/view/product/classify/index.html new file mode 100644 index 0000000..3d8837c --- /dev/null +++ b/app/admin/view/product/classify/index.html @@ -0,0 +1,143 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+ +
+
+
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/comment/add.html b/app/admin/view/product/comment/add.html new file mode 100644 index 0000000..b4b9888 --- /dev/null +++ b/app/admin/view/product/comment/add.html @@ -0,0 +1,200 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

关联商户

+ + + + + + + + + + + + + + + + + + + + + + + + +
选择商户 +
+ +
+
+
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
请选择所在地址* +
+ +
+
+ +
+
+
+
+
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/comment/edit.html b/app/admin/view/product/comment/edit.html new file mode 100644 index 0000000..2ebf4e4 --- /dev/null +++ b/app/admin/view/product/comment/edit.html @@ -0,0 +1,188 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + + + + +
选择商户 +
+ +
+
+
+
+
+ +
+ +
+
+
+
+ +
+ + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/comment/index.html b/app/admin/view/product/comment/index.html new file mode 100644 index 0000000..b369315 --- /dev/null +++ b/app/admin/view/product/comment/index.html @@ -0,0 +1,200 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/guarantee/add.html b/app/admin/view/product/guarantee/add.html new file mode 100644 index 0000000..00125f1 --- /dev/null +++ b/app/admin/view/product/guarantee/add.html @@ -0,0 +1,129 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

添加

+ + + + + + + + + + + + + + + + + + + +
服务条款* + +
服务内容描述 + +
服务条款图标 +
+ +
+ + +
+
+
+
+ +
+ +
+
+
排序 + +
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/guarantee/edit.html b/app/admin/view/product/guarantee/edit.html new file mode 100644 index 0000000..a3386d0 --- /dev/null +++ b/app/admin/view/product/guarantee/edit.html @@ -0,0 +1,122 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + + + + + +
服务条款* + +
服务内容描述 + +
服务条款图标 +
+ +
+ + +
+
+
+
+ +
+ +
+
+
排序 + +
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/guarantee/index.html b/app/admin/view/product/guarantee/index.html new file mode 100644 index 0000000..876d6e5 --- /dev/null +++ b/app/admin/view/product/guarantee/index.html @@ -0,0 +1,182 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/mer_specs/add.html b/app/admin/view/product/mer_specs/add.html new file mode 100644 index 0000000..cd6974f --- /dev/null +++ b/app/admin/view/product/mer_specs/add.html @@ -0,0 +1,167 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

添加

+ + + + + + + + + + + + + + + + + +
上级分类* + + + +
+ +
+
+
+
+
品牌名称* + +
+
+ +
+ +
+
+
排序 + +
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/mer_specs/edit.html b/app/admin/view/product/mer_specs/edit.html new file mode 100644 index 0000000..e764766 --- /dev/null +++ b/app/admin/view/product/mer_specs/edit.html @@ -0,0 +1,165 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + + +
上级分类* + + + +
+ +
+
+
+
+
品牌名称* + +
+
+ +
+ +
+
+
排序 + +
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/mer_specs/index.html b/app/admin/view/product/mer_specs/index.html new file mode 100644 index 0000000..4c48c45 --- /dev/null +++ b/app/admin/view/product/mer_specs/index.html @@ -0,0 +1,152 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/price_description/add.html b/app/admin/view/product/price_description/add.html new file mode 100644 index 0000000..cd6974f --- /dev/null +++ b/app/admin/view/product/price_description/add.html @@ -0,0 +1,167 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

添加

+ + + + + + + + + + + + + + + + + +
上级分类* + + + +
+ +
+
+
+
+
品牌名称* + +
+
+ +
+ +
+
+
排序 + +
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/price_description/edit.html b/app/admin/view/product/price_description/edit.html new file mode 100644 index 0000000..e764766 --- /dev/null +++ b/app/admin/view/product/price_description/edit.html @@ -0,0 +1,165 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + + +
上级分类* + + + +
+ +
+
+
+
+
品牌名称* + +
+
+ +
+ +
+
+
排序 + +
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/price_description/index.html b/app/admin/view/product/price_description/index.html new file mode 100644 index 0000000..4c48c45 --- /dev/null +++ b/app/admin/view/product/price_description/index.html @@ -0,0 +1,152 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/product/add.html b/app/admin/view/product/product/add.html new file mode 100644 index 0000000..b4b9888 --- /dev/null +++ b/app/admin/view/product/product/add.html @@ -0,0 +1,200 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

关联商户

+ + + + + + + + + + + + + + + + + + + + + + + + +
选择商户 +
+ +
+
+
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
请选择所在地址* +
+ +
+
+ +
+
+
+
+
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/product/edit.html b/app/admin/view/product/product/edit.html new file mode 100644 index 0000000..2ebf4e4 --- /dev/null +++ b/app/admin/view/product/product/edit.html @@ -0,0 +1,188 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + + + + +
选择商户 +
+ +
+
+
+
+
+ +
+ +
+
+
+
+ +
+ + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/product/index.html b/app/admin/view/product/product/index.html new file mode 100644 index 0000000..57343c8 --- /dev/null +++ b/app/admin/view/product/product/index.html @@ -0,0 +1,236 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/specs/add.html b/app/admin/view/product/specs/add.html new file mode 100644 index 0000000..cd6974f --- /dev/null +++ b/app/admin/view/product/specs/add.html @@ -0,0 +1,167 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

添加

+ + + + + + + + + + + + + + + + + +
上级分类* + + + +
+ +
+
+
+
+
品牌名称* + +
+
+ +
+ +
+
+
排序 + +
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/specs/edit.html b/app/admin/view/product/specs/edit.html new file mode 100644 index 0000000..e764766 --- /dev/null +++ b/app/admin/view/product/specs/edit.html @@ -0,0 +1,165 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + + +
上级分类* + + + +
+ +
+
+
+
+
品牌名称* + +
+
+ +
+ +
+
+
排序 + +
+
+ + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/specs/index.html b/app/admin/view/product/specs/index.html new file mode 100644 index 0000000..4c48c45 --- /dev/null +++ b/app/admin/view/product/specs/index.html @@ -0,0 +1,152 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/index/add.html b/app/admin/view/supplychain/index/add.html new file mode 100644 index 0000000..0e5787b --- /dev/null +++ b/app/admin/view/supplychain/index/add.html @@ -0,0 +1,210 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

关联商户

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
选择商户 +
+ +
+
+
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
请选择所在地址* +
+ +
+
+ +
+
+
+
+
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/index/edit.html b/app/admin/view/supplychain/index/edit.html new file mode 100644 index 0000000..0ed608a --- /dev/null +++ b/app/admin/view/supplychain/index/edit.html @@ -0,0 +1,218 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+ +

编辑

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
选择商户 +
+ +
+
+
+ +
+ {volist name='detail.merchant' id='vo'} + + {/volist} +
+
+
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
请选择所在地址* +
+ +
+
+ +
+
+
+
+
+
+ + + +
+
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/index/index.html b/app/admin/view/supplychain/index/index.html new file mode 100644 index 0000000..ac0d49c --- /dev/null +++ b/app/admin/view/supplychain/index/index.html @@ -0,0 +1,208 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/index/read.html b/app/admin/view/supplychain/index/read.html new file mode 100644 index 0000000..3fffad9 --- /dev/null +++ b/app/admin/view/supplychain/index/read.html @@ -0,0 +1,67 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

详情

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
标题*
简介* + +
内容 + +
坐标 +

经度:{$detail.lng}

+

纬度:{$detail.lat}

+ +
运输距离 + {volist name='farmers' id='vo'} +

距离 {$vo.title} {$vo.juli} 公里

+ {/volist} +
+
+{/block} + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/merchant/add.html b/app/admin/view/supplychain/merchant/add.html new file mode 100644 index 0000000..a408038 --- /dev/null +++ b/app/admin/view/supplychain/merchant/add.html @@ -0,0 +1,138 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

添加

+ + + + + + + + + + + + + + + + + + + +
所属区域* +
+ +
+
姓名* + + 负责人头像 +
+ +
+ + +
+
+
职务* + + 电话* + +
+
+ + +
+ +
+{/block} + + + +{block name="script"} + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/merchant/bill.html b/app/admin/view/supplychain/merchant/bill.html new file mode 100644 index 0000000..d1e1ab5 --- /dev/null +++ b/app/admin/view/supplychain/merchant/bill.html @@ -0,0 +1,280 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/merchant/edit.html b/app/admin/view/supplychain/merchant/edit.html new file mode 100644 index 0000000..a27228d --- /dev/null +++ b/app/admin/view/supplychain/merchant/edit.html @@ -0,0 +1,133 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

编辑

+ + + + + + + + + + + + + + + + + + +
所属区域* +
+ +
+
姓名* + + 负责人头像 +
+ +
+ + +
+
+
职务* + + 电话* + +
+
+ + + +
+
+{/block} + + + +{block name="script"} + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/merchant/index.html b/app/admin/view/supplychain/merchant/index.html new file mode 100644 index 0000000..0ec5f85 --- /dev/null +++ b/app/admin/view/supplychain/merchant/index.html @@ -0,0 +1,259 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/merchant/read.html b/app/admin/view/supplychain/merchant/read.html new file mode 100644 index 0000000..3fffad9 --- /dev/null +++ b/app/admin/view/supplychain/merchant/read.html @@ -0,0 +1,67 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

详情

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
标题*
简介* + +
内容 + +
坐标 +

经度:{$detail.lng}

+

纬度:{$detail.lat}

+ +
运输距离 + {volist name='farmers' id='vo'} +

距离 {$vo.title} {$vo.juli} 公里

+ {/volist} +
+
+{/block} + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/api/BaseController.php b/app/api/BaseController.php index bea59e9..823bf71 100644 --- a/app/api/BaseController.php +++ b/app/api/BaseController.php @@ -83,52 +83,62 @@ abstract class BaseController //每页显示数据量 $this->pageSize = Request::param('page_size', \think\facade\Config::get('app.page_size')); - $token = Request::header('x-Token'); - if ($token) { - if (strpos($token, 'Bearer') === 0){ - $token = trim(substr($token, 6)); - } - if (count(explode('.', $token)) != 3) { - return json(['code'=>404,'msg'=>'非法请求']); - } - $config = get_system_config('token'); - //var_dump($config);exit; - try { - JWT::$leeway = 60;//当前时间减去60,把时间留点余地 - $decoded = JWT::decode($token, new Key('ae47e94a7dcd1fdfacb499b60e361a8d', 'HS256')); //HS256方式,这里要和签发的时候对应 +// 暂时去除 ----------------------------------------------------- +// $token = Request::header('x-Token'); +// if ($token) { +// if (strpos($token, 'Bearer') === 0){ +// $token = trim(substr($token, 6)); +// } +// if (count(explode('.', $token)) != 3) { +// return json(['code'=>404,'msg'=>'非法请求']); +// } +// $config = get_system_config('token'); - //return (array)$decoded; -// $decoded_array = json_decode(json_encode($decoded),TRUE); -// $jwt_data = $decoded_array['data']; +// return json($token); +// JWT::$leeway = 60;//当前时间减去60,把时间留点余地 +// $decoded = JWT::decode($token, new Key('ae47e94a7dcd1fdfacb499b60e361a8d', 'HS256')); //HS256方式,这里要和签发的时候对应 - $user=Db::connect('shop')->name('nk_user')->where('user_id',$decoded->jti[0])->find(); - if (!$user){ - return json(['code'=>403,'msg'=>'签名错误']); - return false; - } - $user = Db::table('fa_user')->where('id',$user['n_user_id'])->find(); - //$request->uid = $jwt_data['userid']; - define('JWT_UID', $user['id']); -// $response = $next($request); -// return $response; - //return $next($request); - } catch(\Firebase\JWT\SignatureInvalidException $e) { //签名不正确 - return json(['code'=>403,'msg'=>'签名错误']); - }catch(\Firebase\JWT\BeforeValidException $e) { // 签名在某个时间点之后才能用 - return json(['code'=>401,'msg'=>'token失效']); - }catch(\Firebase\JWT\ExpiredException $e) { // token过期 - return json(['code'=>401,'msg'=>'token已过期']); - }catch(Exception $e) { //其他错误 - return json(['code'=>404,'msg'=>'非法请求']); - }catch(\UnexpectedValueException $e) { //其他错误 - return json(['code'=>404,'msg'=>'非法请求']); - } catch(\DomainException $e) { //其他错误 - return json(['code'=>404,'msg'=>'非法请求']); - } - }else{ - define('JWT_UID', ''); - } +// return $decoded->jti[0]; +// exit; +// //var_dump($config);exit; +// try { +// JWT::$leeway = 60;//当前时间减去60,把时间留点余地 +// $decoded = JWT::decode($token, new Key('ae47e94a7dcd1fdfacb499b60e361a8d', 'HS256')); //HS256方式,这里要和签发的时候对应 + +// //return (array)$decoded; +// // $decoded_array = json_decode(json_encode($decoded),TRUE); +// // $jwt_data = $decoded_array['data']; + +// $user=Db::connect('shop')->name('nk_user')->where('user_id',$decoded->jti[0])->find(); +// if (!$user){ +// return json(['code'=>403,'msg'=>'签名错误']); +// return false; +// } +// $user = Db::table('fa_user')->where('id',$user['n_user_id'])->find(); +// //$request->uid = $jwt_data['userid']; +// define('JWT_UID', $user['id']); +// // $response = $next($request); +// // return $response; +// //return $next($request); +// } catch(\Firebase\JWT\SignatureInvalidException $e) { //签名不正确 +// return json(['code'=>403,'msg'=>'签名错误']); +// }catch(\Firebase\JWT\BeforeValidException $e) { // 签名在某个时间点之后才能用 +// return json(['code'=>401,'msg'=>'token失效']); +// }catch(\Firebase\JWT\ExpiredException $e) { // token过期 +// return json(['code'=>401,'msg'=>'token已过期']); +// }catch(Exception $e) { //其他错误 +// return json(['code'=>404,'msg'=>'非法请求']); +// }catch(\UnexpectedValueException $e) { //其他错误 +// return json(['code'=>404,'msg'=>'非法请求']); +// } catch(\DomainException $e) { //其他错误 +// return json(['code'=>404,'msg'=>'非法请求']); +// } +// }else{ +// define('JWT_UID', ''); +// } + +// 暂时去除 ----------------------------------------------------- } /** diff --git a/app/api/controller/Article.php b/app/api/controller/Article.php index 5659497..f3fe1f4 100644 --- a/app/api/controller/Article.php +++ b/app/api/controller/Article.php @@ -41,8 +41,8 @@ class Article extends BaseController unset($where[1]); } //根据个人村id进行查询 - if (JWT_UID) { - $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find(); + if ($this->request->uid) { + $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find(); if ($find) { if ($find['auth_range']==1){ $where[] = ['village', '=', $find['village_id']]; @@ -54,7 +54,7 @@ class Article extends BaseController } // 登录返回村名和村地址 $cun_arr['cun_name'] = Db::table('fa_geo_village')->where('village_id', $find['village_id'])->value('village_name'); - $cun_arr['cun_address'] = Db::table('fa_szxc_information_usermsg')->where('user_id', JWT_UID)->value('address_name'); + $cun_arr['cun_address'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $this->request->uid)->value('address_name'); }else{ $cun_arr = []; } @@ -183,8 +183,8 @@ class Article extends BaseController unset($where[1]); } // 如果登录 - if (JWT_UID) { - $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find(); + if ($this->request->uid) { + $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find(); if ($find) { if ($find['auth_range']==1){ $where[] = ['village', '=', $find['village_id']]; @@ -312,8 +312,8 @@ class Article extends BaseController ['status', '=', 1], ]; //根据个人村id进行查询 - if (JWT_UID) { - $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find(); + if ($this->request->uid) { + $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find(); if ($find) { if ($find['auth_range']==1){ $where[] = ['village', '=', $find['village_id']]; @@ -497,7 +497,7 @@ class Article extends BaseController // if (!$res) { // return $this->apiError($valdate->getError()); // } - $useraddress = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->where('status', 1)->find(); + $useraddress = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->where('status', 1)->find(); $data = []; if ($useraddress) { @@ -507,7 +507,7 @@ class Article extends BaseController } $data['end_time'] = date('Y-m-d H:i:s', strtotime('+1 day')); $data['view_time'] = date('Y-m-d H:i:s'); - $data['user_id'] = JWT_UID;//添加用户的id + $data['user_id'] = $this->request->uid;//添加用户的id $data['category_id'] = $input['category_id'];//大分类id $data['category_type'] = $input['category_type'];//小分类id $data['title'] = $input['title'];//标题 @@ -518,7 +518,7 @@ class Article extends BaseController $data['image'] = $input['image'];//封面 $data['is_vote'] =empty($input['is_vote'])?0:$input['is_vote'];//是否投票 if ($input['category_id']==150){ - $name=Db::table('fa_szxc_information_usermsg')->where('user_id',JWT_UID)->value('name'); + $name=Db::table('fa_szxc_information_usermsg')->where('user_id',$this->request->uid)->value('name'); $data['title'] = '来自于'.$name.'的一键求救'; } $res = Db::table('fa_article')->insertGetId($data); @@ -575,7 +575,7 @@ class Article extends BaseController $data['describe'] = empty($input['describe'])?'':$input['describe'];//简介 $data['image'] = $input['image'];//封面 $data['is_vote'] = $input['is_vote'];//是否投票 - $input['update_user_id'] = JWT_UID;//更新用户的id + $input['update_user_id'] = $this->request->uid;//更新用户的id $res = Db::table('fa_article')->where('id', $id)->update($data); if ($input['is_vote'] == 1) { @@ -596,8 +596,8 @@ class Article extends BaseController { // $model = Db::table('fa_article'); //根据个人村id进行查询 - if (JWT_UID) { - $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find(); + if ($this->request->uid) { + $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find(); if ($find) { if ($find['auth_range']==1){ $where[] = ['village', '=', $find['village_id']]; @@ -650,12 +650,12 @@ class Article extends BaseController { // $model = Db::table('fa_article'); //根据个人id进行查询 - $where[] = ['a.user_id','=',JWT_UID]; + $where[] = ['a.user_id','=',$this->request->uid]; $where[] = ['b.is_read','=','0']; $which = []; //根据个人村id进行查询 - if (JWT_UID) { - $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find(); + if ($this->request->uid) { + $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find(); if ($find) { if ($find['auth_range']==1){ $www[] = ['a.village', '=', $find['village_id']]; @@ -665,7 +665,7 @@ class Article extends BaseController $www[] = ['a.county', '=', $find['area_id']]; } } - $which['user_id'] = JWT_UID; + $which['user_id'] = $this->request->uid; } $yishi = Db::table('fa_article')->alias('a')->join(['fa_article_vote_side_tables' => 'b'],'a.id=b.article_id')->where($www)->where('a.category_id',162)->whereTime('b.end_time', '>', date('Y-m-d H:i:s'))->count(); $maodun = Db::table('fa_article')->alias('a')->join(['fa_article_comment' => 'b'],'a.id=b.vote_id')->where('a.is_solve', 1)->where($where)->where('a.category_id',147)->count(); @@ -708,8 +708,8 @@ class Article extends BaseController } //根据个人村id进行查询 - if (JWT_UID) { - $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find(); + if ($this->request->uid) { + $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find(); if ($find) { if ($find['auth_range']==1){ $where[] = ['village', '=', $find['village_id']]; @@ -721,7 +721,7 @@ class Article extends BaseController } // 登录返回村名和村地址 $cun_arr['cun_name'] = Db::table('fa_geo_village')->where('village_id', $find['village_id'])->value('village_name'); - $cun_arr['cun_address'] = Db::table('fa_szxc_information_usermsg')->where('user_id', JWT_UID)->value('address_name'); + $cun_arr['cun_address'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $this->request->uid)->value('address_name'); }else{ $cun_arr = []; } diff --git a/app/api/controller/User.php b/app/api/controller/User.php index 513804a..aa4346b 100644 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -29,9 +29,9 @@ class User extends BaseController * 会员中心. */ public function index() - { - $user = Db::table('fa_user')->where('id',JWT_UID)->find(); - $user_msg = Db::table('fa_szxc_information_usermsg')->where('user_id',JWT_UID)->field('id,name,address_name,phone')->find(); + { + $user = Db::table('fa_user')->where('id', $this->request->uid)->find(); + $user_msg = Db::table('fa_szxc_information_usermsg')->where('user_id', $this->request->uid)->field('id,name,address_name,phone')->find(); $this->apiSuccess('', [ 'nickname' => $user['nickname'], 'phone'=>$user_msg['phone'], @@ -472,7 +472,7 @@ class User extends BaseController // 获取实名认证信息 public function get_shiming(){ - $uid = JWT_UID; + $uid = $this->request->uid; $is_have = Db::table('cms_szxc_user_authentication')->where('user_id',$uid)->find(); if($is_have){ $this->apiSuccess('获取成功',$is_have); @@ -483,7 +483,7 @@ class User extends BaseController // 获取后台账号信息 public function get_backstage(){ - $uid = JWT_UID; + $uid = $this->request->uid; $admin = Db::table('cms_admin')->where('user_id',$uid)->find(); if($admin){ $data['url'] = 'https://nk.lihaink.cn'; diff --git a/app/api/controller/Userinfo.php b/app/api/controller/Userinfo.php index a3da625..7617a8b 100644 --- a/app/api/controller/Userinfo.php +++ b/app/api/controller/Userinfo.php @@ -94,16 +94,17 @@ class Userinfo extends BaseController public function Binding() { $post = get_params(); - if(!$post['idcard'] || !$post['area_id'] || !$post['street_id'] || !$post['village_id'] || !$post['name']){ $this->apiError('缺少参数'); } if($post['phone'] == 'undefined'){ $this->apiError('手机号错误'); } + $where['id'] = $this->request->uid; $post['user_id'] = $this->request->uid; $user = Db::table('fa_user')->where($where)->field('id,nickname,group_id,mobile,avatar,username,createtime,score')->find(); + // 已绑定 if ($user) { Db::startTrans(); diff --git a/app/api/controller/Village.php b/app/api/controller/Village.php index 27cd03d..f0981ec 100644 --- a/app/api/controller/Village.php +++ b/app/api/controller/Village.php @@ -664,7 +664,7 @@ class Village extends BaseController }) ->withAttr('is_dz', function ($value, $data) { // 判断redis - $user_id = JWT_UID; + $user_id = $this->request->uid; if($user_id){ $name = $user_id . $data['id']; $is_zan = Cache::store('redis')->get($name); diff --git a/app/api/middleware.php b/app/api/middleware.php index 91dea02..e695fbe 100644 --- a/app/api/middleware.php +++ b/app/api/middleware.php @@ -6,4 +6,6 @@ return [ //验证勾股cms是否完成安装 \app\home\middleware\Install::class, \app\api\middleware\AllowOriginMiddleware::class, + \app\api\middleware\Auth::class, + ]; \ No newline at end of file diff --git a/app/api/middleware/Auth.php b/app/api/middleware/Auth.php index 6b55e8c..bfe148d 100644 --- a/app/api/middleware/Auth.php +++ b/app/api/middleware/Auth.php @@ -27,11 +27,12 @@ class Auth if (count(explode('.', $token)) != 3) { return json(['code'=>404,'msg'=>'非法请求']); } + try { JWT::$leeway = 60;//当前时间减去60,把时间留点余地 $decoded = JWT::decode($token, new Key('ae47e94a7dcd1fdfacb499b60e361a8d', 'HS256')); //HS256方式,这里要和签发的时候对应 $user=Db::connect('shop')->name('nk_user')->where('user_id',$decoded->jti[0])->find(); - if ($user &&$user['n_user_id']!=0){ + if ($user && $user['n_user_id']!=0){ $request->uid=$user['n_user_id']; }else{ $request->uid=$this->addUser($decoded->jti[0],$user); @@ -61,41 +62,41 @@ class Auth $msg=Db::table('fa_szxc_information_usermsg')->where('phone',$user['account'])->find(); Db::startTrans(); try { - if ($msg){ - $users=Db::table('fa_user')->where('id',$msg['user_id'])->find(); - if (!$nk_user){ + if ($msg){ + $users=Db::table('fa_user')->where('id',$msg['user_id'])->find(); + if (!$nk_user){ + $datas=[ + 'user_id'=>$user['uid'], + 'n_user_id'=>$msg['user_id'], + 'group_id'=>$users['group_id'] + ]; + Db::connect('shop')->name('nk_user')->insert($datas); + }else{ + Db::connect('shop')->name('nk_user')->where('id',$nk_user['id'])->update(['user_id'=>$user['uid'],'group_id'=>$users['group_id']]); + } + }else{ + $time=time(); + $user_data=[ + 'openid'=>'wx'.$time, + 'group_id'=>1, + 'username'=>'wx'.$time, + 'nickname'=>'微信用户'.$time, + 'avatar'=>'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230104/32a639be4ee32349705e947fbbd1e114.png', + 'level'=>1, + 'prevtime'=>$time, + 'jointime'=>$time, + 'createtime'=>$time, + 'updatetime'=>$time, + 'status'=>'normal' + ]; + $n_user_id= Db::table('fa_user')->insertGetId($user_data); $datas=[ 'user_id'=>$user['uid'], - 'n_user_id'=>$msg['user_id'], - 'group_id'=>$users['group_id'] + 'n_user_id'=>$n_user_id, + 'group_id'=>1 ]; Db::connect('shop')->name('nk_user')->insert($datas); - }else{ - Db::connect('shop')->name('nk_user')->where('id',$nk_user['id'])->update(['user_id'=>$user['uid'],'group_id'=>$users['group_id']]); - } - }else{ - $time=time(); - $user_data=[ - 'openid'=>'wx'.$time, - 'group_id'=>1, - 'username'=>'wx'.$time, - 'nickname'=>'微信用户'.$time, - 'avatar'=>'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230104/32a639be4ee32349705e947fbbd1e114.png', - 'level'=>1, - 'prevtime'=>$time, - 'jointime'=>$time, - 'createtime'=>$time, - 'updatetime'=>$time, - 'status'=>'normal' - ]; - $n_user_id= Db::table('fa_user')->insertGetId($user_data); - $datas=[ - 'user_id'=>$user['uid'], - 'n_user_id'=>$n_user_id, - 'group_id'=>1 - ]; - Db::connect('shop')->name('nk_user')->insert($datas); - return $n_user_id; + return $n_user_id; } Db::commit(); } catch (\Exception $e) { diff --git a/public/.htaccess b/public/.htaccess deleted file mode 100644 index cbc7868..0000000 --- a/public/.htaccess +++ /dev/null @@ -1,8 +0,0 @@ - - Options +FollowSymlinks -Multiviews - RewriteEngine On - - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] - diff --git a/public/nginx.htaccess b/public/nginx.htaccess deleted file mode 100644 index a9942c4..0000000 --- a/public/nginx.htaccess +++ /dev/null @@ -1,51 +0,0 @@ -#ļΪNginxα̬ļ PHPCUSTOMٷַhttp://www.phpcustom.com http://www.lccee.com - - - - - -# 301תãԶ޸Ϊ - if ($Host = 'xxx.com'){ - rewrite ^/(.*)$ http://www.phpcustom.com/$1 permanent; - } - - - - - - -#Ϊphpwind9.0α̬,ȥ#Ч -#------------------------------------------------------------------------------------------------ - -# if (-f $request_filename) { -# break; -# } -# if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") { -# break; -# } -# if (!-e $request_filename) { -# rewrite . /index.php last; -# } - - - - - -# ThinkPHP V5α̬ʾ ȥ´ǰߵ#żЧ - -#------------------------------------------------------------------------------------------------ -#if (!-e $request_filename) { -# rewrite ^(.*)$ /index.php?s=/$1 last; -# break; -# } - -#------------------------------------------------------------------------------------------------ - - - - - - - - -