diff --git a/service/Application/Admin/Controller/AlipayLifeCategoryController.class.php b/service/Application/Admin/Controller/AlipayLifeCategoryController.class.php new file mode 100755 index 000000000..25de30945 --- /dev/null +++ b/service/Application/Admin/Controller/AlipayLifeCategoryController.class.php @@ -0,0 +1,185 @@ +Is_Login(); + + // 权限校验 + $this->Is_Power(); + } + + /** + * [Index 生活号分类列表] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-06T21:31:53+0800 + */ + public function Index() + { + $this->assign('common_is_enable_list', L('common_is_enable_list')); + $this->display('Index'); + } + + /** + * [GetNodeSon 获取节点子列表] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-25T15:19:45+0800 + */ + public function GetNodeSon() + { + // 是否ajax请求 + if(!IS_AJAX) + { + $this->error(L('common_unauthorized_access')); + } + + // 获取数据 + $field = array('id', 'name', 'sort', 'is_enable'); + $data = M('AlipayLifeCategory')->field($field)->where(array('pid'=>intval(I('id', 0))))->select(); + if(!empty($data)) + { + foreach($data as $k=>$v) + { + $data[$k]['is_son'] = $this->IsExistSon($v['id']); + $data[$k]['ajax_url'] = U('Admin/AlipayLifeCategory/GetNodeSon', array('id'=>$v['id'])); + $data[$k]['delete_url'] = U('Admin/AlipayLifeCategory/Delete'); + $data[$k]['json'] = json_encode($v); + } + } + $msg = empty($data) ? L('common_not_data_tips') : L('common_operation_success'); + $this->ajaxReturn($msg, 0, $data); + } + + /** + * [IsExistSon 节点是否存在子数据] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-25T15:22:47+0800 + * @param [int] $id [节点id] + * @return [string] [有数据ok, 则no] + */ + private function IsExistSon($id) + { + if(!empty($id)) + { + return (M('AlipayLifeCategory')->where(array('pid'=>$id))->count() > 0) ? 'ok' : 'no'; + } + return 'no'; + } + + /** + * [Save 生活号分类保存] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-25T22:36:12+0800 + */ + public function Save() + { + // 是否ajax请求 + if(!IS_AJAX) + { + $this->error(L('common_unauthorized_access')); + } + + // id为空则表示是新增 + $m = D('AlipayLifeCategory'); + + // 公共额外数据处理 + $m->sort = intval(I('sort')); + + // 添加 + if(empty($_POST['id'])) + { + if($m->create($_POST, 1)) + { + // 额外数据处理 + $m->add_time = time(); + $m->name = I('name'); + + // 写入数据库 + if($m->add()) + { + $this->ajaxReturn(L('common_operation_add_success')); + } else { + $this->ajaxReturn(L('common_operation_add_error'), -100); + } + } + } else { + // 编辑 + if($m->create($_POST, 2)) + { + // 额外数据处理 + $m->name = I('name'); + $m->upd_time = time(); + + // 移除 id + unset($m->id); + + // 更新数据库 + if($m->where(array('id'=>I('id')))->save()) + { + $this->ajaxReturn(L('common_operation_edit_success')); + } else { + $this->ajaxReturn(L('common_operation_edit_error'), -100); + } + } + } + $this->ajaxReturn($m->getError(), -1); + } + + /** + * [Delete 生活号分类删除] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-25T22:36:12+0800 + */ + public function Delete() + { + if(!IS_AJAX) + { + $this->error(L('common_unauthorized_access')); + } + + $m = D('AlipayLifeCategory'); + if($m->create($_POST, 5)) + { + if($m->delete(I('id'))) + { + $this->ajaxReturn(L('common_operation_delete_success')); + } else { + $this->ajaxReturn(L('common_operation_delete_error'), -100); + } + } else { + $this->ajaxReturn($m->getError(), -1); + } + } +} +?> \ No newline at end of file diff --git a/service/Application/Admin/Controller/AlipayLifeController.class.php b/service/Application/Admin/Controller/AlipayLifeController.class.php new file mode 100644 index 000000000..27f6ad26a --- /dev/null +++ b/service/Application/Admin/Controller/AlipayLifeController.class.php @@ -0,0 +1,348 @@ +Is_Login(); + + // 权限校验 + $this->Is_Power(); + } + + /** + * [Index 生活号列表] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-06T21:31:53+0800 + */ + public function Index() + { + // 参数 + $param = array_merge($_POST, $_GET); + + // 模型对象 + $m = M('AlipayLife'); + + // 条件 + $where = $this->GetIndexWhere(); + + // 分页 + $number = MyC('admin_page_number'); + $page_param = array( + 'number' => $number, + 'total' => $m->alias('a')->join('INNER JOIN __ALIPAY_LIFE_CATEGORY_JOIN__ AS cj ON a.id=cj.alipay_life_id')->where($where)->count('DISTINCT a.id'), + 'where' => $param, + 'url' => U('Admin/AlipayLife/Index'), + ); + $page = new \Library\Page($page_param); + + // 获取列表 + $list = $m->alias('a')->field('a.*')->join('INNER JOIN __ALIPAY_LIFE_CATEGORY_JOIN__ AS cj ON a.id=cj.alipay_life_id')->where($where)->limit($page->GetPageStarNumber(), $number)->order('a.id desc')->group('a.id')->select(); + $list = $this->SetDataHandle($list); + + // 参数 + $this->assign('param', $param); + + // 分页 + $this->assign('page_html', $page->GetPageHtml()); + + // 是否上下架 + $this->assign('common_goods_is_shelves_list', L('common_goods_is_shelves_list')); + + // 生活号分类 + $alipay_life_category = M('AlipayLifeCategory')->where(['is_enable'=>1])->field('id,name')->select(); + $this->assign('alipay_life_category', $alipay_life_category); + + // 数据列表 + $this->assign('list', $list); + $this->display('Index'); + } + + /** + * [SetDataHandle 数据处理] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-29T21:27:15+0800 + * @param [array] $data [轮播图片数据] + * @return [array] [处理好的数据] + */ + private function SetDataHandle($data) + { + if(!empty($data)) + { + $common_is_enable_tips = L('common_is_enable_tips'); + foreach($data as &$v) + { + // 分类名称 + $category_all = M('AlipayLifeCategoryJoin')->where(['alipay_life_id'=>$v['id']])->getField('alipay_life_category_id', true); + $v['alipay_life_category_text'] = M('AlipayLifeCategory')->where(['id'=>['in', $category_all]])->getField('name', true); + + // logo + $v['logo'] = empty($v['logo']) ? '' : C('IMAGE_HOST').$v['logo']; + + // 添加时间 + $v['add_time_text'] = date('Y-m-d H:i:s', $v['add_time']); + + // 更新时间 + $v['upd_time_text'] = date('Y-m-d H:i:s', $v['upd_time']); + } + } + return $data; + } + + /** + * [GetIndexWhere 列表条件] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-10T22:16:29+0800 + */ + private function GetIndexWhere() + { + $where = array(); + + // 模糊 + if(!empty($_REQUEST['keyword'])) + { + $where['a.name'] = array('like', '%'.I('keyword').'%'); + } + + // 是否更多条件 + if(I('is_more', 0) == 1) + { + if(I('is_shelves', -1) > -1) + { + $where['a.is_shelves'] = intval(I('is_shelves', 0)); + } + if(I('alipay_life_category_id', -1) > -1) + { + $where['cj.alipay_life_category_id'] = intval(I('alipay_life_category_id', 0)); + } + + // 表达式 + if(!empty($_REQUEST['time_start'])) + { + $where['a.add_time'][] = array('gt', strtotime(I('time_start'))); + } + if(!empty($_REQUEST['time_end'])) + { + $where['a.add_time'][] = array('lt', strtotime(I('time_end'))); + } + } + return $where; + } + + /** + * [SaveInfo 添加/编辑页面] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-14T21:37:02+0800 + */ + public function SaveInfo() + { + // 轮播图片信息 + $data = empty($_REQUEST['id']) ? array() : M('AlipayLife')->find(I('id')); + + // 获取分类关联数据 + $data['category_all'] = M('AlipayLifeCategoryJoin')->where(['alipay_life_id'=>$data['id']])->getField('alipay_life_category_id', true); + $this->assign('data', $data); + + // 是否上下架 + $this->assign('common_goods_is_shelves_list', L('common_goods_is_shelves_list')); + + // 生活号分类 + $alipay_life_category = M('AlipayLifeCategory')->where(['is_enable'=>1])->field('id,name')->select(); + $this->assign('alipay_life_category', $alipay_life_category); + + // 参数 + $this->assign('param', array_merge($_POST, $_GET)); + + $this->display('SaveInfo'); + } + + /** + * [Save 生活号保存] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-25T22:36:12+0800 + */ + public function Save() + { + // 是否ajax请求 + if(!IS_AJAX) + { + $this->error(L('common_unauthorized_access')); + } + + // 图片 + $this->ImagesSave('logo', 'file_logo', 'alipay_life'); + + // id为空则表示是新增 + $m = D('AlipayLife'); + + // 公共额外数据处理 + $_POST['is_shelves'] = intval(I('is_shelves', 0)); + + // 开启事务 + $m->startTrans(); + + // 分类 + $category_m = M('AlipayLifeCategoryJoin'); + if(empty($_POST['id'])) + { + $type = 1; + } else { + $type = 2; + $category_m->where(['id'=>I('id')])->delete(); + } + + $status = false; + $msg = ''; + $alipay_life_id = I('id', 0); + if($m->create($_POST, $type)) + { + // 额外数据处理 + $m->upd_time = time(); + $m->name = I('name'); + $m->appid = I('appid'); + $m->rsa_public = I('rsa_public'); + $m->rsa_private = I('rsa_private'); + $m->out_rsa_public = I('out_rsa_public'); + + if($type == 1) + { + // 写入数据库 + $m->add_time = time(); + $alipay_life_id = $m->add(); + if($alipay_life_id) + { + $status = true; + $msg = L('common_operation_add_success'); + } else { + $msg = L('common_operation_add_error'); + } + } else { + // 更新数据库 + if($m->where(array('id'=>$alipay_life_id))->save()) + { + $status = true; + $msg = L('common_operation_edit_success'); + } else { + $msg = L('common_operation_edit_error'); + } + } + } else { + $msg = $m->getError(); + } + + // 分类处理 + if($status === true) + { + $count = 0; + $all = explode(',', I('alipay_life_category_id')); + foreach($all as $v) + { + if($category_m->add(['alipay_life_id'=>$alipay_life_id, 'alipay_life_category_id'=>$v, 'add_time'=>time()])) + { + $count++; + } + } + if($count < count($all)) + { + // 回滚事务 + $m->rollback(); + + $this->ajaxReturn(L('alipay_life_save_category_error'), -10); + } + } else { + // 回滚事务 + $m->rollback(); + $this->ajaxReturn($msg, -100); + } + + // 回滚事务 + $m->commit(); + $this->ajaxReturn($msg, 0); + } + + /** + * [Delete 生活号删除] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-25T22:36:12+0800 + */ + public function Delete() + { + if(!IS_AJAX) + { + $this->error(L('common_unauthorized_access')); + } + + $m = D('AlipayLife'); + if($m->create($_POST, 5)) + { + $id = I('id'); + + // 删除 + if($m->delete($id)) + { + $this->ajaxReturn(L('common_operation_delete_success')); + } else { + $this->ajaxReturn(L('common_operation_delete_error'), -100); + } + } else { + $this->ajaxReturn($m->getError(), -1); + } + } + + /** + * [StatusUpdate 状态更新] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2017-01-12T22:23:06+0800 + */ + public function StatusUpdate() + { + // 参数 + if(empty($_POST['id']) || !isset($_POST['state'])) + { + $this->ajaxReturn(L('common_param_error'), -1); + } + + // 数据更新 + if(M('AlipayLife')->where(array('id'=>I('id')))->save(array('is_shelves'=>I('state')))) + { + $this->ajaxReturn(L('common_operation_edit_success')); + } else { + $this->ajaxReturn(L('common_operation_edit_error'), -100); + } + } +} +?> \ No newline at end of file diff --git a/service/Application/Admin/Lang/zh-cn/alipaylife.php b/service/Application/Admin/Lang/zh-cn/alipaylife.php new file mode 100755 index 000000000..83f7752f9 --- /dev/null +++ b/service/Application/Admin/Lang/zh-cn/alipaylife.php @@ -0,0 +1,39 @@ + '生活号添加', + 'alipay_life_edit_name' => '生活号编辑', + + 'alipay_life_category_id_text' => '生活号分类', + 'alipay_life_category_id_format' => '请选择生活号分类', + + 'alipay_life_name_text' => '名称', + 'alipay_life_name_format' => '名称格式 2~30 个字符', + + 'alipay_life_appid_text' => 'appid', + 'alipay_life_appid_format' => 'appid格式 1~60 个字符', + + 'alipay_life_rsa_public_text' => '应用公钥', + 'alipay_life_rsa_public_format' => '应用公钥格式 1~2000 个字符', + + 'alipay_life_rsa_private_text' => '应用私钥', + 'alipay_life_rsa_private_format' => '应用私钥格式 1~2000 个字符', + + 'alipay_life_out_rsa_public_text' => '支付宝公钥', + 'alipay_life_out_rsa_public_format' => '支付宝公钥格式 1~2000 个字符', + + 'alipay_life_logo_text' => 'LOGO', + 'alipay_life_logo_format' => '请上传LOGO图片', + + 'alipay_life_is_shelves_text' => '上下架', + 'alipay_life_save_category_error' => '分类添加失败', +); +?> \ No newline at end of file diff --git a/service/Application/Admin/Lang/zh-cn/alipaylifecategory.php b/service/Application/Admin/Lang/zh-cn/alipaylifecategory.php new file mode 100755 index 000000000..c5ba9288a --- /dev/null +++ b/service/Application/Admin/Lang/zh-cn/alipaylifecategory.php @@ -0,0 +1,15 @@ + '生活号分类添加', + 'alipay_life_category_edit_name' => '生活号分类编辑', +); +?> \ No newline at end of file diff --git a/service/Application/Admin/Model/AlipayLifeCategoryModel.class.php b/service/Application/Admin/Model/AlipayLifeCategoryModel.class.php new file mode 100755 index 000000000..cf141224e --- /dev/null +++ b/service/Application/Admin/Model/AlipayLifeCategoryModel.class.php @@ -0,0 +1,38 @@ +db(0)->where(array('pid'=>I('id')))->count() == 0); + } +} +?> \ No newline at end of file diff --git a/service/Application/Admin/Model/AlipayLifeModel.class.php b/service/Application/Admin/Model/AlipayLifeModel.class.php new file mode 100755 index 000000000..8a82af380 --- /dev/null +++ b/service/Application/Admin/Model/AlipayLifeModel.class.php @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/service/Application/Admin/View/Default/AlipayLife/Index.html b/service/Application/Admin/View/Default/AlipayLife/Index.html new file mode 100755 index 000000000..c30cdfa58 --- /dev/null +++ b/service/Application/Admin/View/Default/AlipayLife/Index.html @@ -0,0 +1,107 @@ + + + +
+
+ +
+
+ value="{{$param.keyword}}" /> + + + +
none"> + + +
+ value="{{$param.time_start}}"/> + ~ + value="{{$param.time_end}}"/> +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + class="am-active"> + + + + + + + + + + + + + +
{{:L('alipay_life_name_text')}}{{:L('alipay_life_logo_text')}}{{:L('alipay_life_appid_text')}}{{:L('alipay_life_category_id_text')}}{{:L('alipay_life_is_shelves_text')}}{{:L('common_create_time_name')}}{{:L('common_operation_name')}}
{{$v.name}} + + + + + + {{:L('common_on_fill_in_images')}} + + {{$v.appid}}{{:implode(',', $v['alipay_life_category_text'])}} + am-successam-default" data-url="{{:U('Admin/AlipayLife/StatusUpdate')}}" data-id="{{$v.id}}" data-state="{{$v['is_shelves']}}" data-is-update-status="1"> + {{$v.add_time_text}} + + + + + + +
{{:L('common_not_data_tips')}}
+ + + + + {{$page_html}} + + +
+
+ + + + + \ No newline at end of file diff --git a/service/Application/Admin/View/Default/AlipayLife/SaveInfo.html b/service/Application/Admin/View/Default/AlipayLife/SaveInfo.html new file mode 100755 index 000000000..f8837063c --- /dev/null +++ b/service/Application/Admin/View/Default/AlipayLife/SaveInfo.html @@ -0,0 +1,77 @@ + + + +
+
+ +
+ + + + + {{:L('alipay_life_add_name')}} + + {{:L('alipay_life_edit_name')}} + + + {{:L('common_operation_back')}} + +
+ + value="{{$data.name}}" required /> +
+
+ + +
+ +
+ + value="{{$data.appid}}" required /> +
+ +
+ + + value="{{$data.logo}}"" data-validation-message="{{:L('common_select_images_tips')}}" readonly="readonly" /> + + +
+ {{$image_host}}{{$data.logo}}{{$image_host}}/Public/Admin/Default/Images/default-images.png" id="form-img-icon" class="block m-t-5 am-img-thumbnail am-radius" width="100" height="100" data-default="{{$image_host}}/Public/Admin/Default/Images/default-images.png" /> +
+ +
+ + +
+
+ + +
+
+ + +
+ +
+ + checked="true" /> +
+
+ value="{{$data.id}}" /> + +
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/service/Application/Admin/View/Default/AlipayLifeCategory/Index.html b/service/Application/Admin/View/Default/AlipayLifeCategory/Index.html new file mode 100755 index 000000000..4e9751ab1 --- /dev/null +++ b/service/Application/Admin/View/Default/AlipayLifeCategory/Index.html @@ -0,0 +1,59 @@ + + + +
+
+ +
+ +
+ + + +
+
+
+

{{:L('alipay_life_category_add_name')}}

+ × +
+
+ +
+
+ + +
+
+ + +
+ +
+ + +
+ + +
+
+
+ + + +
+
+ +

{{:L('common_form_loading_tips')}}

+
+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/service/Application/Admin/View/Default/Brand/Index.html b/service/Application/Admin/View/Default/Brand/Index.html index b4a1cece5..a0bf3b527 100755 --- a/service/Application/Admin/View/Default/Brand/Index.html +++ b/service/Application/Admin/View/Default/Brand/Index.html @@ -94,7 +94,7 @@ - {{:L('common_not_data_tips')}} + {{:L('common_not_data_tips')}} diff --git a/service/Application/Admin/View/Default/GoodsCategory/Index.html b/service/Application/Admin/View/Default/GoodsCategory/Index.html index 523b37a24..d7d9d786b 100755 --- a/service/Application/Admin/View/Default/GoodsCategory/Index.html +++ b/service/Application/Admin/View/Default/GoodsCategory/Index.html @@ -23,7 +23,7 @@ - value="{{$data.images_url}}"" data-validation-message="{{:L('common_select_images_tips')}}" readonly="readonly" /> +
@@ -33,7 +33,7 @@ - value="{{$data.big_images}}"" data-validation-message="{{:L('common_select_images_tips')}}" readonly="readonly" /> +
diff --git a/service/Application/Runtime/Temp/8cde93cbd070139d84f31d26f8ea8f4d.php b/service/Application/Runtime/Temp/8cde93cbd070139d84f31d26f8ea8f4d.php index 94bf88abd..73bb9eefb 100644 --- a/service/Application/Runtime/Temp/8cde93cbd070139d84f31d26f8ea8f4d.php +++ b/service/Application/Runtime/Temp/8cde93cbd070139d84f31d26f8ea8f4d.php @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/service/Application/Runtime/Temp/a58f8070835be94249ea77f3601c6647.php b/service/Application/Runtime/Temp/a58f8070835be94249ea77f3601c6647.php index 88eac595a..488fc9a71 100644 --- a/service/Application/Runtime/Temp/a58f8070835be94249ea77f3601c6647.php +++ b/service/Application/Runtime/Temp/a58f8070835be94249ea77f3601c6647.php @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/service/Public/Admin/Default/Css/AlipayLife.css b/service/Public/Admin/Default/Css/AlipayLife.css new file mode 100755 index 000000000..f7a0912b2 --- /dev/null +++ b/service/Public/Admin/Default/Css/AlipayLife.css @@ -0,0 +1,19 @@ +/** + * 列表 + */ +.form-keyword { width: 55% !important; display: initial !important; } +.more-submit input { display: none; } +.category-row { width: 30%; } +.param-where, .param-date input { display: initial !important; } +@media only screen and (max-width: 641px) { + .param-where { width: 100% !important; margin-left: 0px !important; } + .param-date input { width: 47% !important; } +} +@media only screen and (min-width: 641px) { + .param-where { width: 32% !important; float: left; } + .param-date input { width: 45% !important; } + .param-where:nth-child(1), .param-where:nth-child(4) { margin-left: 0px !important; } +} +@media only screen and (max-width: 321px) { + .view-operation button { margin: 2px 0px; } +} \ No newline at end of file diff --git a/service/Public/Admin/Default/Css/Common.css b/service/Public/Admin/Default/Css/Common.css index 998fce571..5a3bebedb 100755 --- a/service/Public/Admin/Default/Css/Common.css +++ b/service/Public/Admin/Default/Css/Common.css @@ -376,7 +376,7 @@ ul {margin-top:0;} .admin-sidebar-sub li:first-child {border-top:1px solid #dedede;} .admin-sidebar {height:100%;overflow-x:hidden;overflow-y:scroll;-webkit-overflow-scrolling:touch;} @media only screen and (min-width:641px) { - .admin-sidebar {display:block;position:static;background:none;width:180px;z-index:1;} + .admin-sidebar {display:block;position:static;background:none;width:200px;z-index:1;} .admin-offcanvas-bar {position:static;width:auto;background:none;-webkit-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0);transform:translate3d(0,0,0);overflow-y:visible;min-height:100%;} .admin-offcanvas-bar:after {content:none;} } diff --git a/service/alipay_life_notify.php b/service/alipay_life_notify.php new file mode 100644 index 000000000..a5f0d198f --- /dev/null +++ b/service/alipay_life_notify.php @@ -0,0 +1,4 @@ +