diff --git a/application/admin/controller/Dashboard.php b/application/admin/controller/Dashboard.php index 01f2baa..5200948 100644 --- a/application/admin/controller/Dashboard.php +++ b/application/admin/controller/Dashboard.php @@ -78,7 +78,7 @@ class Dashboard extends Backend ); $visit = Visit::where($visit_where)->where('status',0)->count(); //var_dump(Visit::getlastsql()); - $this->view->assign([ + $index_data = [ 'totaluser' => User::count(), 'totalvipuser' => User::where('level_id','>','1')->count(), 'todayprice' => Log::where('state','=','0')->whereTime('createtime', 'today')->where('end','exp',' > start')->sum('end-start'), @@ -102,10 +102,11 @@ class Dashboard extends Backend 'attachmentsize' => Attachment::sum('filesize'), 'picturenums' => Attachment::where('mimetype', 'like', 'image/%')->count(), 'picturesize' => Attachment::where('mimetype', 'like', 'image/%')->sum('filesize'), - ]); - - + ]; + + $this->assignconfig('index_data', $index_data); + $this->view->assign($index_data); return $this->view->fetch(); } diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index 862c224..d6e86a8 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -41,10 +41,10 @@ class Index extends Backend } //左侧菜单 list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar([ - 'dashboard' => 'hot', - 'addon' => ['new', 'red', 'badge'], - 'auth/rule' => __('Menu'), - 'general' => ['new', 'purple'], + // 'dashboard' => 'hot', + // 'addon' => ['new', 'red', 'badge'], + // 'auth/rule' => __('Menu'), + // 'general' => ['new', 'purple'], ], $this->view->site['fixedpage']); $action = $this->request->request('action'); if ($this->request->isPost()) { diff --git a/application/admin/controller/user4s/Category.php b/application/admin/controller/user4s/Category.php index 47766d4..6ef095a 100644 --- a/application/admin/controller/user4s/Category.php +++ b/application/admin/controller/user4s/Category.php @@ -17,6 +17,7 @@ class Category extends Backend * @var \app\common\model\user4s\Category */ protected $model = null; + protected $searchFields = 'id,name,description'; public function _initialize() { diff --git a/application/admin/controller/user4s/Goodlog.php b/application/admin/controller/user4s/Goodlog.php new file mode 100644 index 0000000..3462d99 --- /dev/null +++ b/application/admin/controller/user4s/Goodlog.php @@ -0,0 +1,175 @@ +model = new \app\common\model\user4s\Goodlog; + + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['user','admin']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + + + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + // public function add() + // { + // if (!$this->request->isPost()) { + // $user4s_id = $this->request->get("user4s_id/d"); + // if ($user4s_id > 0) { + // $user4s=$this->user_model->get($user4s_id); + // if(isset($user4s->id)){ + // $this->view->assign("user4s", $user4s); + // } + // } + // } + // if ($this->request->isPost()) { + // $params = $this->request->post("row/a"); + // } + // return parent::add(); + // } + public function add() + { + if (!$this->request->isPost()) { + $user4s_id = $this->request->get("user4s_id/d"); + if ($user4s_id > 0) { + $user4s=$this->user_model->get($user4s_id); + if(isset($user4s->id)){ + $this->view->assign("user4s", $user4s); + } + } + } + if ($this->request->isPost()) { + $params = $this->request->post("row/a"); + if ($params) { + //写兑换记录 + $this->user = new User(); + $this->log = new Log(); + $user = $this->user->get($params['user4s_id']); + $good = Goods::get($params['good_id']); + $num = intval($params['good_num']); + if(!$user){ + $this->error('用户不存在'); + } + if(!$good){ + $this->error('商品不存在'); + } + if(!$good){ + $this->error('商品不存在'); + } + if($good->inventory < $num){ + $this->error('商品库存不足,当前只有'.$good->inventory.'件'); + } + $need_price = $good->price * $num; + $need_integral = $good->integral * $num; + if($user->integral < $need_integral){ + $this->error('用户积分不足,用户只有'.$good->integral); + } + if($user->balance < $need_price){ + $this->error('用户余额不足,用户只有'.$good->balance.'元'); + } + $this->user->startTrans(); + try { + if($need_integral > 0 ){ + $this->user->where('id', $user->id)->setDec('integral', $need_integral); + } + if($need_price > 0 ){ + $this->user->where('id', $user->id)->setDec('balance', $need_price); + } + $good->where('id', $good->id)->setDec('inventory', $num); + $good->where('id', $good->id)->setInc('sales', $num); + $logok = $this->log->addLog($user->id,$this->auth->id,$need_price,$need_integral, '兑换商品'.$good->title.' x '.$num.'件'); + if(!$logok){ + $this->user->rollback(); + $this->error('兑换失败'); + } + $params['admin_id'] = $this->auth->id; + $params['good_name'] = $good->title; + $params['user_name'] = $user->name; + $params['integral'] = $need_integral; + $params['price'] = $need_price; + + $result = $this->model->allowField(true)->save($params); + if($result !== false && $logok){ + $this->user->commit(); + $this->success('兑换成功'); + }else{ + $this->user->rollback(); + $this->error('兑换失败'); + } + } catch (ValidateException $e) { + $this->user->rollback(); + $this->error($e->getMessage()); + } catch (PDOException $e) { + $this->user->rollback(); + $this->error($e->getMessage()); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + return $this->view->fetch(); + } +} diff --git a/application/admin/controller/user4s/Goods.php b/application/admin/controller/user4s/Goods.php new file mode 100644 index 0000000..834a97d --- /dev/null +++ b/application/admin/controller/user4s/Goods.php @@ -0,0 +1,91 @@ +model = new \app\common\model\user4s\Goods; + $this->view->assign("stateList", $this->model->getStateList()); + } + public function selectpage() + { + $custom = ['starttime'=>['ELT',date('Y-m-d H:i:s')],'endtime'=>['EGT',date('Y-m-d H:i:s')]]; + $this->request->request(['custom' => $custom]); + return parent::selectpage(); + } + public function check() + { + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + $id = $this->request->param('id'); + $num = $this->request->param('num'); + $user4s_id = $this->request->param('user4s_id'); + if(empty($id)){ + $result = array("code" => 1, "msg" => '商品ID为空'); + return json($result); + } + if(empty($num)){ + $result = array("code" => 1, "msg" => '数量为空'); + return json($result); + } + if(empty($user4s_id)){ + $result = array("code" => 1, "msg" => '用户ID为空'); + return json($result); + } + $user = User::get($user4s_id); + if(!$user){ + $result = array("code" => 1, "msg" => '用户为空'); + return json($result); + } + $row = $this->model->get($id); + if (!$row) { + $result = array("code" => 1, "msg" => __('No Results were found')); + return json($result); + }else{ + $need_price = $row->price * $num; + $need_integral = $row->integral * $num; + if($user->integral < $need_integral){ + $result = array("code" => 2, "msg" => '客户的积分不足',"data" => $row,"need_integral"=>$need_integral,"need_price"=>$need_price,"user_integral"=>$user->integral,"user_price"=>$user->balance,'num'=>$num); + return json($result); + } + if($user->balance < $need_price){ + $result = array("code" => 2, "msg" => '客户的余额不足',"data" => $row,"need_integral"=>$need_integral,"need_price"=>$need_price,"user_integral"=>$user->integral,"user_price"=>$user->balance,'num'=>$num); + return json($result); + } + //$row->getRelation('category')->visible(['name']); + //$row->getRelation('level')->visible(['name']); + $result = array("code" => 0, "msg" => '可以兑换', "data" => $row,"need_integral"=>$need_integral,"need_price"=>$need_price,"user_integral"=>$user->integral,"user_price"=>$user->balance,'num'=>$num); + return json($result); + } + } + $result = array("code" => 1, "msg" => '出现错误,请重试!'); + return json($result); + } + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + +} diff --git a/application/admin/controller/user4s/Inslog.php b/application/admin/controller/user4s/Inslog.php index b4d2fed..5366141 100644 --- a/application/admin/controller/user4s/Inslog.php +++ b/application/admin/controller/user4s/Inslog.php @@ -17,6 +17,7 @@ class Inslog extends Backend * @var \app\common\model\user4s\Inslog */ protected $model = null; + protected $searchFields = 'id,description'; public function _initialize() { diff --git a/application/admin/controller/user4s/Levellog.php b/application/admin/controller/user4s/Levellog.php index 4d918ff..be3db8a 100644 --- a/application/admin/controller/user4s/Levellog.php +++ b/application/admin/controller/user4s/Levellog.php @@ -17,6 +17,7 @@ class Levellog extends Backend * @var \app\common\model\user4s\Levellog */ protected $model = null; + protected $searchFields = 'id,description'; public function _initialize() { diff --git a/application/admin/controller/user4s/Log.php b/application/admin/controller/user4s/Log.php index 7b12095..2c58585 100644 --- a/application/admin/controller/user4s/Log.php +++ b/application/admin/controller/user4s/Log.php @@ -17,6 +17,7 @@ class Log extends Backend * @var \app\common\model\user4s\Log */ protected $model = null; + protected $searchFields = 'id,description'; public function _initialize() { diff --git a/application/admin/controller/user4s/User.php b/application/admin/controller/user4s/User.php index fe298aa..e5cd421 100644 --- a/application/admin/controller/user4s/User.php +++ b/application/admin/controller/user4s/User.php @@ -94,12 +94,28 @@ class User extends Backend } return $this->view->fetch(); } - public function add2() + public function info($id = null) { - if ($this->request->isPost()) { - //$this->token(); + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + $id = $this->request->param('id'); + if(empty($id)){ + $result = array("code" => 1, "msg" => '用户ID为空'); + return json($result); + }; + $row = $this->model->get($id); + if (!$row) { + $result = array("code" => 1, "msg" => __('No Results were found')); + return json($result); + }else{ + //$row->getRelation('category')->visible(['name']); + //$row->getRelation('level')->visible(['name']); + $result = array("code" => 0, "msg" => 'success', "data" => $row); + return json($result); + } } - return parent::add(); + $result = array("code" => 1, "msg" => '出现错误,请重试!'); + return json($result); } public function add() { @@ -209,6 +225,8 @@ class User extends Backend // try { // foreach ($list as $k => $v) { // $count += $v->delete(); + // //删除用户记录 + // //$log_res = $this->model->afterlog($this->auth->id,$this->model,$v->id,'',false); // } // $this->model->commit(); // } catch (PDOException $e) { diff --git a/application/admin/controller/user4s/Visit.php b/application/admin/controller/user4s/Visit.php index d8db6d0..a88b589 100644 --- a/application/admin/controller/user4s/Visit.php +++ b/application/admin/controller/user4s/Visit.php @@ -21,6 +21,7 @@ class Visit extends Backend * @var \app\common\model\user4s\Visit */ protected $model = null; + protected $searchFields = 'id,name,description'; public function _initialize() { diff --git a/application/admin/controller/user4s/Visitlog.php b/application/admin/controller/user4s/Visitlog.php index 8811de6..d5446b9 100644 --- a/application/admin/controller/user4s/Visitlog.php +++ b/application/admin/controller/user4s/Visitlog.php @@ -21,6 +21,7 @@ class Visitlog extends Backend * @var \app\common\model\user4s\Visitlog */ protected $model = null; + protected $searchFields = 'id,description'; public function _initialize() { diff --git a/application/admin/controller/user4s/Visittype.php b/application/admin/controller/user4s/Visittype.php index c616784..979557c 100644 --- a/application/admin/controller/user4s/Visittype.php +++ b/application/admin/controller/user4s/Visittype.php @@ -17,6 +17,7 @@ class Visittype extends Backend * @var \app\common\model\user4s\Visittype */ protected $model = null; + protected $searchFields = 'id,name,description'; public function _initialize() { diff --git a/application/admin/lang/zh-cn/user4s/goodlog.php b/application/admin/lang/zh-cn/user4s/goodlog.php new file mode 100644 index 0000000..5b4d2f0 --- /dev/null +++ b/application/admin/lang/zh-cn/user4s/goodlog.php @@ -0,0 +1,55 @@ + 'ID', + 'Admin_id' => '操作员', + 'User4s_id' => '会员', + 'User_name' => '客户名称', + 'Orderno' => '订单号', + 'Goodsjson' => '商品列表', + 'Integral' => '积分', + 'Price' => '价格', + 'Createtime' => '创建时间', + 'Description' => '备注', + 'Deletetime' => '删除时间', + 'User.id' => 'ID', + 'User.category_id' => '用户分组', + 'User.level_id' => '用户等级', + 'User.name' => '姓名', + 'User.tel' => '联系方式', + 'User.balance' => '余额', + 'User.integral' => '积分', + 'User.genderdata' => '性别', + 'User.genderdata male' => '男', + 'User.genderdata female' => '女', + 'User.city' => '省市', + 'User.buydate' => '购车日期', + 'User.carno' => '车牌号码', + 'User.model' => '车型', + 'User.color' => '颜色', + 'User.inscom' => '保险类型', + 'User.insdate' => '保险日期', + 'User.tags' => '标签', + 'User.description' => '备注', + 'User.admin_id' => '销售顾问', + 'User.createtime' => '创建时间', + 'User.updatetime' => '更新时间', + 'User.deletetime' => '删除时间', + 'User.status' => '状态值', + 'User.status 0' => '禁用', + 'User.status 1' => '正常', + 'Admin.id' => 'ID', + 'Admin.username' => '用户名', + 'Admin.nickname' => '昵称', + 'Admin.password' => '密码', + 'Admin.salt' => '密码盐', + 'Admin.avatar' => '头像', + 'Admin.email' => '电子邮箱', + 'Admin.loginfailure' => '失败次数', + 'Admin.logintime' => '登录时间', + 'Admin.loginip' => '登录IP', + 'Admin.createtime' => '创建时间', + 'Admin.updatetime' => '更新时间', + 'Admin.token' => 'Session标识', + 'Admin.status' => '状态' +]; diff --git a/application/admin/lang/zh-cn/user4s/goods.php b/application/admin/lang/zh-cn/user4s/goods.php new file mode 100644 index 0000000..e9074d6 --- /dev/null +++ b/application/admin/lang/zh-cn/user4s/goods.php @@ -0,0 +1,23 @@ + 'ID', + 'Title' => '标题', + 'Content' => '内容', + 'Image' => '图片', + 'Images' => '图片组', + 'Keywords' => '关键字', + 'Price' => '价格', + 'Integral' => '积分', + 'Inventory' => '库存', + 'Sales' => '销量', + 'Starttime' => '开始时间', + 'Endtime' => '结束时间', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Deletetime' => '删除时间', + 'Weigh' => '权重', + 'State' => '状态', + 'State 0' => '下架', + 'State 1' => '上架' +]; diff --git a/application/admin/view/common/control.html b/application/admin/view/common/control.html index 69bc449..b8cf544 100644 --- a/application/admin/view/common/control.html +++ b/application/admin/view/common/control.html @@ -23,7 +23,7 @@
@@ -64,13 +64,36 @@
-

{:__('Home')}

+

技术支持:微果网络

+

联系方式:

+
-
+
diff --git a/application/admin/view/common/header.html b/application/admin/view/common/header.html index 5efa6b0..e92ca98 100644 --- a/application/admin/view/common/header.html +++ b/application/admin/view/common/header.html @@ -24,9 +24,9 @@