From 1093db06f58c1091638ab79dd07fc4ea97dce6c9 Mon Sep 17 00:00:00 2001 From: wangxinglong <2371974647@qq.com> Date: Tue, 30 Nov 2021 15:26:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=95=86=E5=AE=B6?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/User.php | 1 - app/controller/manager/Agency.php | 20 ++- app/controller/manager/Area.php | 40 +++++ app/controller/manager/Business.php | 48 ++++-- app/controller/manager/BusinessCircle.php | 15 +- app/controller/manager/Coupon.php | 33 +++- app/controller/manager/Index.php | 4 +- app/controller/manager/Login.php | 1 + app/controller/manager/Member.php | 4 +- app/model/Account.php | 13 +- app/model/CouponMain.php | 7 + app/model/Member.php | 46 ++++-- app/repository/BillRepository.php | 44 +++--- app/repository/BusinessRepository.php | 23 ++- app/traits/CouponBillTrait.php | 5 + app/traits/cms/MenuTrait.php | 3 + public/static/manager/js/area.js | 22 ++- public/static/manager/js/bill.js | 21 +-- public/static/manager/js/business/business.js | 1 + view/manager/agency/add.html | 8 +- view/manager/agency/edit.html | 23 +-- view/manager/area/index.html | 9 ++ view/manager/business/business_detail.html | 14 +- view/manager/business_circle/add.html | 144 ++++++++++++++++- view/manager/business_circle/edit.html | 145 +++++++++++++++++- view/manager/coupon/edit.html | 8 + view/manager/member/edit.html | 2 +- 27 files changed, 583 insertions(+), 121 deletions(-) diff --git a/app/controller/api/User.php b/app/controller/api/User.php index b743d18..7d77d31 100644 --- a/app/controller/api/User.php +++ b/app/controller/api/User.php @@ -74,7 +74,6 @@ class User extends Base 'create_time' => $nowDate, 'login_time' => $nowDate, 'type' => Account::type_consumer, // 默认为普通消费者 - 'state' => Account::state_default, 'nick_name' => $params['nick_name'] ?: generateDefaultNickName(), 'avatar_url' => $params['avatar_url'] ?: Account::DEFAULT_AVATAR, 'gender' => $params['gender'], diff --git a/app/controller/manager/Agency.php b/app/controller/manager/Agency.php index 4cdd530..173a115 100644 --- a/app/controller/manager/Agency.php +++ b/app/controller/manager/Agency.php @@ -4,7 +4,6 @@ namespace app\controller\manager; use app\model\Business as BusinessModel; use app\model\Log; -use app\model\Member; use app\model\Member as MemberModel; use app\repository\BusinessRepository; use Exception; @@ -49,8 +48,10 @@ class Agency extends Base return $this->json(4002, '请输入正确的手机号码'); } - $item['roles'] = [Member::ANENT_ROLE_ID]; - $item['status'] = Member::COMMON_ON; + $item['roles'] = [MemberModel::STAFF_ROLE_ID]; + $item['status'] = MemberModel::COMMON_ON; + $item['pid'] = $this->auth["user_id"]; + $item['business_code'] = $this->auth["business_code"]; $roles = []; if ($item['roles']) { @@ -124,7 +125,7 @@ class Agency extends Base if (!checkMobile($item['mobile'])) { return $this->json(4002, '请输入正确的手机号码'); } - $item['roles'] = [Member::ANENT_ROLE_ID]; + $item['roles'] = [MemberModel::STAFF_ROLE_ID]; $roles = []; if ($item['roles']) { $roles = $item['roles']; @@ -178,7 +179,7 @@ class Agency extends Base /** - * 轮播图列表 + * 列表 * * @return Json|View * @throws Exception @@ -191,10 +192,15 @@ class Agency extends Base $size = $this->request->param('size/d', 30); //只查询拥有渠道商的账号 - $whereMap = [['roles', "=", Member::ANENT_ROLE_ID], ['id', "<>", 1]]; + $whereMap = [['roles', "=", MemberModel::STAFF_ROLE_ID], ['id', "<>", 1]]; $orders = ['id' => 'asc']; - $list = Member::findList($whereMap, [], $page, $size, null, $orders); + //如果是渠道商或者工作人员 只查看自己的商家 + if (MemberModel::is_agency($this->auth['roles'])){ + $whereMap[] = ["pid", "=", $this->auth['user_id']]; + } + + $list = MemberModel::findList($whereMap, [], $page, $size, null, $orders); return $this->json(0, 'success', $list); } diff --git a/app/controller/manager/Area.php b/app/controller/manager/Area.php index ab6ca8c..932d13e 100644 --- a/app/controller/manager/Area.php +++ b/app/controller/manager/Area.php @@ -6,6 +6,7 @@ use app\repository\CmsRepository; use app\model\Area as AreaModel; +use think\exception\ValidateException; use think\response\Json; use think\response\View; @@ -36,4 +37,43 @@ class Area extends Base } return $this->view(); } + + /** + * 单个字段编辑 + * + * @return Json + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + * @throws Exception + */ + public function modify(): Json + { + if ($this->request->isPost()) { + $item = input('post.'); + $validate = $this->validateByApi($item, [ + 'field' => 'require', + 'value' => 'require', + ]); + + if ($validate !== true) { + return $validate; + } + + if (!$info = AreaModel::findById($item['id'])) { + return $this->json(4001, '记录不存在'); + } + + $update = [$item['field'] => $item['value']]; + + try { + $info->save($update); + return $this->json(); + } catch (ValidateException $e) { + return $this->json(4001, $e->getError()); + } + } + return $this->json(4000, '非法请求'); + } + } \ No newline at end of file diff --git a/app/controller/manager/Business.php b/app/controller/manager/Business.php index bcb8c7d..faf1126 100644 --- a/app/controller/manager/Business.php +++ b/app/controller/manager/Business.php @@ -3,14 +3,16 @@ namespace app\controller\manager; use app\exception\RepositoryException; -use app\model\BusinessFlow; +use app\model\Account; use app\model\Coupon; use app\model\CouponMain; use app\model\Category as CategoryModel; use app\model\Business as BusinessModel; use app\model\Member; use app\model\BusinessCircle as BusinessCircleModel ; +use app\repository\AccountRepository; use app\repository\BusinessRepository; +use app\repository\CouponRepository; use app\repository\RechargeRepository; use app\service\wx\WechatPay; use Exception; @@ -33,18 +35,20 @@ class Business extends Base public function index() { if ($this->request->isPost()) { - $model = new BusinessFlow(); - $repo = BusinessRepository::getInstance($model); + $repo = BusinessRepository::getInstance(); $keyword = $this->request->param('keyword/s', ''); $page = $this->request->param('page/d', 1); $size = $this->request->param('size/d', 30); - $whereMap = [["c.state", "=", BusinessModel::state_on]]; + $whereMap = [["a.state", "=", BusinessModel::state_on]]; $orders = ['a.id' => 'desc']; if (!empty($keyword)) { - $whereMap[] = ['b.nick_name|c.business_name', 'like', "%$keyword%"]; + $whereMap[] = ['b.nick_name|a.business_name', 'like', "%$keyword%"]; + } + //如果是渠道商或者工作人员 只查看自己的下级商家 + if(Member::is_agency($this->auth['roles'])){ + $whereMap[] = ['a.agency_code', '=', $this->auth['business_code']]; } - $list = $repo->businessList($whereMap, $page, $size, $orders); $list["list"]->each(function ($item) { //得到当前商家的所有优惠券 @@ -74,6 +78,9 @@ class Business extends Base ->where("is_verificated", "=", Coupon::is_verificated_on) ->count(); + //产生的总收益数 + $item->coupon_profit_count = BusinessRepository::getInstance()->businessProfitTotal( $item->business_code); + //商家充值总额 $item->recharge_total_money = $item->total_recharge; }); @@ -185,7 +192,7 @@ class Business extends Base public function businessDetail() { $businessCode = input("business_code/s", ""); - $business = $repo = BusinessRepository::getInstance()->findOneByWhere(['code' => $businessCode]); + $business = BusinessRepository::getInstance()->findOneByWhere(['code' => $businessCode]); if ($this->request->isPost()) { if(empty($business)){ return $this->json(4001,"商家不存在"); @@ -248,16 +255,22 @@ class Business extends Base public function businessWaitList() { if ($this->request->isPost()) { - $model = new BusinessFlow(); - $repo = BusinessRepository::getInstance($model); + + $repo = BusinessRepository::getInstance(); $keyword = $this->request->param('keyword/s', ''); $page = $this->request->param('page/d', 1); $size = $this->request->param('size/d', 30); - $whereMap = [["business.state", "in", [BusinessModel::state_reviewing, BusinessModel::state_off]]]; - $orders = ['business.id' => 'desc']; + + + $whereMap = [["a.state", "in", [BusinessModel::state_reviewing, BusinessModel::state_off]]]; + //如果是渠道商或者工作人员 只查看自己的下级商家 + if(Member::is_agency($this->auth['roles'])){ + $whereMap[] = ['a.agency_code', '=', $this->auth['business_code']]; + } + $orders = ['a.id' => 'desc']; if (!empty($keyword)) { - $whereMap[] = ['account.nick_name|business.business_name', 'like', "%$keyword%"]; + $whereMap[] = ['b.nick_name|a.business_name', 'like', "%$keyword%"]; } $list = $repo->businessList($whereMap, $page, $size, $orders); @@ -280,6 +293,10 @@ class Business extends Base $businessCode = input("business_code/s", ""); $state = input("state/d", 0); $reason = input("reason/s", ''); + if (!in_array($state, [BusinessModel::state_off, BusinessModel::state_on])) { + return $this->json(4001, "错误的审核状态"); + } + $business = BusinessRepository::getInstance()->findOneByWhere(["code" => $businessCode]); if (empty($business)) { return $this->json(4001, "商家不存在"); @@ -287,12 +304,15 @@ class Business extends Base if ($business['state'] != BusinessModel::state_reviewing) { return $this->json(4001, "商家当前状态不可审核"); } - if (!in_array($state, [BusinessModel::state_off, BusinessModel::state_on])) { - return $this->json(4001, "错误的审核状态"); + $account = AccountRepository::getInstance()->findOneByWhere(["business_code" => $businessCode]); + if (empty($account)) { + return $this->json(4001, "关联用户不存在"); } + Db::startTrans(); try { $business->save(["state" => $state, "reason" => $reason]); + $account->save(["type" => Account::type_business]); Db::commit(); return $this->json(); } catch (RepositoryException $e) { diff --git a/app/controller/manager/BusinessCircle.php b/app/controller/manager/BusinessCircle.php index 2ca16dd..9b37231 100644 --- a/app/controller/manager/BusinessCircle.php +++ b/app/controller/manager/BusinessCircle.php @@ -4,6 +4,7 @@ namespace app\controller\manager; use app\model\BusinessCircle as BusinessCircleModel; +use app\repository\BusinessRepository; use Exception; use think\facade\Db; use think\db\exception\DataNotFoundException; @@ -41,8 +42,14 @@ class BusinessCircle extends Base if ($this->request->isPost()) { $item = input('post.'); $validate = $this->validateByApi($item, [ - 'sort|标题' => 'require|number', + 'sort|排序' => 'require|number', 'name|标题' => 'require|max:100', + 'province|省市区' => 'require', + 'city|省市区' => 'require', + 'county|省市区' => 'require', + 'business_address|详细地址' => 'require', + 'lng|经度' => 'require', + 'lat|纬度' => 'require', ]); if ($validate !== true) { @@ -82,6 +89,7 @@ class BusinessCircle extends Base if ($validate !== true) { return $validate; } + $item['create_time'] = date("Y-m-d H:i:s"); try { BusinessCircleModel::create($item); return $this->json(); @@ -104,6 +112,11 @@ class BusinessCircle extends Base return $this->json(4000, '非法请求'); } $ids = $this->request->param('ids/a', []); + foreach ($ids as $item){ + if(count(BusinessRepository::getInstance()->getByCircleId($item)->toArray())){ + return $this->json("4002","该商圈存在绑定商家 不能删除"); + } + } BusinessCircleModel::destroy($ids); return $this->json(); } diff --git a/app/controller/manager/Coupon.php b/app/controller/manager/Coupon.php index c253fe7..e7e8ca8 100644 --- a/app/controller/manager/Coupon.php +++ b/app/controller/manager/Coupon.php @@ -5,6 +5,7 @@ namespace app\controller\manager; use app\exception\RepositoryException; use app\model\CouponMain; +use app\model\Member; use app\repository\BusinessRepository; use app\repository\CouponRepository; use app\validate\CouponRelease; @@ -47,7 +48,7 @@ class Coupon extends Base $size = $this->request->param('size/d', 30); $whereMap = []; - $orders = ['id' => 'desc']; + $orders = ['sort' => 'desc',"id"=>"desc"]; if (!empty($on_shelf) && in_array($on_shelf, [CouponMain::COMMON_ON, CouponMain::COMMON_OFF])) { $whereMap[] = ['on_shelf', '=', $on_shelf]; } @@ -60,18 +61,35 @@ class Coupon extends Base if (!empty($keyword)) { $whereMap[] = ['name', 'like', "%" . $keyword . "%"]; } + $list = $repo->findList($whereMap, [], $page, $size, function ($q) { if (!empty($keyword)) { return $q::hasWhere('business', function ($q) use ($keyword) { - $q->where('business_name', 'like', "%" . $keyword . "%")->field("code,business_name,business_subtitle,type") + $q->where('business_name', 'like', "%" . $keyword . "%") + //如果是渠道商或者工作人员 只查看自己的下级商家 + ->when(Member::is_agency($this->auth['roles']),function ($q){ + $q->where( 'agency_code', '=', $this->auth['business_code']); + }) + ->field("code,business_name,business_subtitle,type") ->with('category'); }); } - return $q->with(["business" => function ($query) { - $query->field("code,business_name,business_subtitle,type") - ->with('category'); - }]); + + if(Member::is_agency($this->auth['roles'])){ + return $q::hasWhere('business', function ($q) { + $q//如果是渠道商或者工作人员 只查看自己的下级商家 + ->where( 'agency_code', '=', $this->auth['business_code']) + ->field("code,business_name,business_subtitle,type") + ->with('category'); + }); + }else{ + return $q->with(["business" => function ($query) { + $query->field("code,business_name,business_subtitle,type") + ->with('category'); + }]); + } + }, $orders); $time = time(); $list['list']->each(function ($item) use ($time) { @@ -88,6 +106,9 @@ class Coupon extends Base return $this->view(); } + /** + * 上架状态 0上架 1下架 + * */ public function shelf() { $id = input("id/d", 0); diff --git a/app/controller/manager/Index.php b/app/controller/manager/Index.php index 77a74a2..bb6b670 100644 --- a/app/controller/manager/Index.php +++ b/app/controller/manager/Index.php @@ -65,7 +65,9 @@ class Index extends Base $menus[$k]['icon'] = !empty($m['icon']) ? 'fa '.$m['icon'] : ''; $menus[$k]['href'] = ltrim($m['href'], '/'); } - $menus = CmsRepository::getInstance()->buildMenuChild(0, $menus, 'child'); + + $menus = CmsRepository::getInstance()->buildMenuChild(0, $menus, 'child',); + $res['menuInfo'] = $menus; return json($res); diff --git a/app/controller/manager/Login.php b/app/controller/manager/Login.php index 7525433..f4b5988 100644 --- a/app/controller/manager/Login.php +++ b/app/controller/manager/Login.php @@ -47,6 +47,7 @@ class Login extends BaseController 'username' => $member['username'], 'nickname' => $member['nickname'], 'business_code' => $member['business_code'], + 'roles' => $member['roles'], ]; $jwtToken = Jwt::generate($userInfo, env('app.expire', 7200)); diff --git a/app/controller/manager/Member.php b/app/controller/manager/Member.php index 11b3c00..80c8670 100644 --- a/app/controller/manager/Member.php +++ b/app/controller/manager/Member.php @@ -143,14 +143,14 @@ class Member extends Base try { //之前关联的商家不为空 并且已经改变 吧之前的商家 从代理商变成普通商家 if ($info['business_code'] != $item['business_code']) { - if(!empty($info['business_code']) ){ + if($info['business_code']!="_" ){ $oldBusiness = BusinessRepository::getInstance()->findOneByWhere(["code" => $info['business_code']]); if (!empty($oldBusiness)) { $oldBusiness->save(["is_agency" => BusinessModel::COMMON_OFF]); } } //如果改变了关联商家 - if(!empty($item['business_code'])){ + if($item['business_code']!="_"){ $Business = BusinessRepository::getInstance()->findOneByWhere(["code" => $item['business_code']]); if (empty($Business)) { Db::rollback(); diff --git a/app/model/Account.php b/app/model/Account.php index b1f494c..8650038 100644 --- a/app/model/Account.php +++ b/app/model/Account.php @@ -13,22 +13,11 @@ class Account extends Base public const type_business = 1;//商家 public const type_staff = 2;//员工 - public const state_default = 0;// 未提交 - public const state_examineing = 1 ;// 1审核中 - public const state_fail = 2;// 2拒绝 - public const state_success = 3;// 3审核通过 // 默认头像 public const DEFAULT_AVATAR = '/static/images/default-avatar.png'; - public static function allState(){ - return [ - self::state_default=>"未提交", - self::state_examineing=>"审核中", - self::state_fail=>"拒绝", - self::state_success=>"审核通过", - ]; - } + public static function accountTypeDescList(): array { diff --git a/app/model/CouponMain.php b/app/model/CouponMain.php index 9333cd2..f5a07a9 100644 --- a/app/model/CouponMain.php +++ b/app/model/CouponMain.php @@ -6,6 +6,7 @@ use think\Collection; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; +use think\Model; /** * 优惠券主表 @@ -27,4 +28,10 @@ class CouponMain extends Base { return $this->hasOne(CouponType::class, 'id',"type_id"); } + + public static function onAfterInsert( $obj) + { + $obj->sort = $obj->id; + $obj->save(); + } } \ No newline at end of file diff --git a/app/model/Member.php b/app/model/Member.php index a626080..e90e849 100644 --- a/app/model/Member.php +++ b/app/model/Member.php @@ -6,11 +6,12 @@ use think\facade\Db; class Member extends Base { - public const STATUS_NORMAL = 1;//正常 + public const STATUS_NORMAL = 1;//正常 public const STATUS_DISABLE = 0;//禁用 + public const MANAGER_ROLE_ID = 1;//角色id 2 为管理员 public const ANENT_ROLE_ID = 2;//角色id 2 为代理商 - + public const STAFF_ROLE_ID = 3;//角色id 2 为工作人员 public static function getList($limit = 40) @@ -25,23 +26,25 @@ class Member extends Base /** * 获取所有代理商 * */ - public static function getAgentAll(){ + public static function getAgentAll() + { $subQuery = Db::name('member') ->field('id,business_code,nickname') - ->whereRaw('(find_in_set("'.Member::ANENT_ROLE_ID .'", roles))') + ->whereRaw('(find_in_set("' . Member::ANENT_ROLE_ID . '", roles))') ->buildSql(); - return Db::table($subQuery . ' a') - ->join("business b" ,"a.business_code = b.code") - ->field("a.*") + return Db::table($subQuery . ' a') + ->join("business b", "a.business_code = b.code") + ->field("a.*") ->order('a.id', 'desc') ->select(); } + /** * 根据角色分组返回用户 - * @param int $groupId 角色分组ID - * @param int $limit 每页数量 + * @param int $groupId 角色分组ID + * @param int $limit 每页数量 */ public static function getListByGroup($groupId, $limit = 40) { @@ -75,7 +78,30 @@ class Member extends Base public static function updateCates($id, $cates) { $cates = implode(',', $cates); - $data = ['cates' => $cates]; + $data = ['cates' => $cates]; self::updateById($id, $data); } + + /** + * 验证当前用户是否是渠道商 + * @param string $roles + */ + public static function is_agency(string $roles) + { + if (empty($roles)) { + return true; + } + + $roles = explode(",", $roles); + + //包含管理员就返回false + if (in_array(self::MANAGER_ROLE_ID, $roles)) { + return false; + } + + if (in_array(self::STAFF_ROLE_ID, $roles) || in_array(self::ANENT_ROLE_ID, $roles)) { + return true; + } + return false; + } } \ No newline at end of file diff --git a/app/repository/BillRepository.php b/app/repository/BillRepository.php index c319c98..1f10845 100644 --- a/app/repository/BillRepository.php +++ b/app/repository/BillRepository.php @@ -8,6 +8,7 @@ use app\model\BusinessFlow; use app\model\CouponBill; use app\model\CouponMain; use app\model\Deduction; +use app\model\Member as MemberModel; use app\model\Recharge; use app\service\Repository; use think\Collection; @@ -44,25 +45,28 @@ class BillRepository extends Repository 'size' => $size, 'list' => new Collection(), ]; - $rep = CouponBill::with([ - "business" => function ($query) use ($keyword) { - $query->field(["code", "business_name"])->when(empty($keyword), function ($q) use ($keyword) { - $q->where("business_name", "like", "%$keyword%"); - }); - }, - "account" => function ($q) { - $q->field(["user_code", "nick_name"]); - }, - "couponMain" => function ($q) { - $q->field(["id", "name"]); - }, - ]) + $rep = CouponBill::alias("a") + ->join("business b","a.business_code = b.code") + ->join("account c","a.user_code = c.user_code") + ->join("coupon_main d","a.coupon_main_id = d.id") + + ->when(!empty($keyword),function ($q) use($keyword){ + $q->where("b.business_name|c.nick_name|d.name", "like", "%$keyword%"); + }) + ->when(MemberModel::is_agency(session("auth")['roles']),function ($q) { + $q->where("b.agency_code", "=", session("auth")['business_code']); + }) ->when(!empty($startTime), function ($q) use ($startTime) { - $q->whereTime("create_time", ">=", $startTime); + $q->whereTime("a.create_time", ">=", $startTime); }) ->when(!empty($endTime), function ($q) use ($endTime) { - $q->whereTime("create_time", "<=", $endTime); - }); + $q->whereTime("a.create_time", "<=", $endTime); + }) + ->field("a.*,b.business_name,c.nick_name,c.avatar_url,d.name as coupon_main_name") + ; + + + $failData ['total'] = $rep->count(); $failData ['list'] = $rep @@ -84,9 +88,13 @@ class BillRepository extends Repository { return CouponBill::when(!empty($start_time), function ($q) use ($start_time) { $q->whereTime("create_time", ">=", $start_time); - })->when(!empty($end_time), function ($q) use ($end_time) { + }) + ->when(!empty($end_time), function ($q) use ($end_time) { $q->whereTime("create_time", "<=", $end_time); - }) + }) + ->when(MemberModel::is_agency(session("auth")['roles']),function ($q) { + $q->where("agency_code", "=", session("auth")['business_code']); + }) ->sum($field); } diff --git a/app/repository/BusinessRepository.php b/app/repository/BusinessRepository.php index 951d76e..77b2a14 100644 --- a/app/repository/BusinessRepository.php +++ b/app/repository/BusinessRepository.php @@ -9,6 +9,7 @@ use app\model\CouponMain; use app\model\Deduction; use app\model\Recharge; use app\service\Repository; +use app\traits\CouponBillTrait; use think\Collection; use think\Model; @@ -21,6 +22,7 @@ use think\Model; */ class BusinessRepository extends Repository { + use CouponBillTrait; /** * 根据条件查询列表 * @@ -34,9 +36,15 @@ class BusinessRepository extends Repository public function businessList(array $where = [], int $page = 1, int $limit = 0, array $order = []) { $q = $this->model->alias("a") - ->join("account b","a.user_code = b.user_code") - ->join("business c","a.business_code = c.code") - ->field(["c.code as business_code","b.avatar_url", "b.nick_name as account_nick_name","c.business_name","c.total_recharge","c.id as basiness_id","c.balance"]); + ->join("account b","a.code = b.business_code") + ->field(["a.code as business_code", + "b.avatar_url", + "b.nick_name as account_nick_name", + "a.business_name", + "a.total_recharge", + "a.id as basiness_id", + "a.balance"]) + ->group("a.id"); $data = [ 'total' => 0, 'current' => $page, @@ -144,4 +152,13 @@ class BusinessRepository extends Repository return $Flow; } + /** + * 查看指定商圈下的商家 + * @param $businessCircleId + * @return Business + */ + public function getByCircleId($businessCircleId) + { + return Business::where("business_circle_id",$businessCircleId)->select(); + } } \ No newline at end of file diff --git a/app/traits/CouponBillTrait.php b/app/traits/CouponBillTrait.php index 1b3432f..caeacb8 100644 --- a/app/traits/CouponBillTrait.php +++ b/app/traits/CouponBillTrait.php @@ -14,5 +14,10 @@ trait CouponBillTrait return CouponBill::where("user_code",$userCode)->sum("consumer_money"); } + //商家 提供的总收益数 + public function businessProfitTotal($businessCode) + { + return CouponBill::where("business_code",$businessCode)->sum("admin_money"); + } } \ No newline at end of file diff --git a/app/traits/cms/MenuTrait.php b/app/traits/cms/MenuTrait.php index e52b5db..7a0acb0 100644 --- a/app/traits/cms/MenuTrait.php +++ b/app/traits/cms/MenuTrait.php @@ -3,6 +3,7 @@ namespace app\traits\cms; use app\model\Menu; +use tauthz\facade\Enforcer; use think\Collection; trait MenuTrait @@ -36,7 +37,9 @@ trait MenuTrait $node[$childName] = $child; $node['has_children'] = true; } + // todo 后续此处加上用户的权限判断 + $treeList[] = $node; } } diff --git a/public/static/manager/js/area.js b/public/static/manager/js/area.js index baa0c99..6d2d4d9 100644 --- a/public/static/manager/js/area.js +++ b/public/static/manager/js/area.js @@ -32,17 +32,27 @@ layui.use(['laytpl', 'treeTable', 'jquery', 'iconPickerFa', 'form', 'miniTab', ' }, cols: [[ {type: 'checkbox'}, - {field: 'title', title: '菜单名称', minWidth: 150, singleLine: true}, - {title: '图标', width: 50, templet: '
',align: 'center'}, - {field: 'name', title: '路由标识'}, - - {templet: '#menu-operate', minWidth: 250, fixed: 'right', align: 'center', title: '操作'} + {field: 'name', title: '名称', minWidth: 150, singleLine: true}, + {field: 'name', title: '状态'}, + {templet: '#row-status',field: 'status', minWidth: 180,align: 'center', title: '状态'}, ]], done: function () { } }); + let modifyUrl = $('#row-modify').data('url'); - + //监听状态改变 + form.on('switch(changeStatus)', function(obj){ + let val = obj.elem.checked ? 1 : 0; + $.post(modifyUrl, {id: this.value, field: this.name, value: val}, function (res) { + layer.msg(res.msg) + if (res.code === 0) { + setTimeout(function () { + //insTb.reload(); + }, 1000) + } + }) + }); //监听工具条 注意区别toolbar和tool toolbar是表头上的工具条 tool是行中的工具条 treeTable.on('toolbar(menu-table)', function (obj) { diff --git a/public/static/manager/js/bill.js b/public/static/manager/js/bill.js index 4104672..357ad71 100644 --- a/public/static/manager/js/bill.js +++ b/public/static/manager/js/bill.js @@ -45,24 +45,9 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect',"laydate"] page: true, cols: [[ {type: 'checkbox'}, - {templet:function(d){ - if( d.account != undefined &&d.account){ - return d.account.nick_name - } - return ''; - }, title: '用户昵称'}, - {templet:function(d){ - if( d.business != undefined &&d.business){ - return d.business.business_name - } - return ''; - }, title: '商家名称'}, - {templet:function(d){ - if( d.couponMain != undefined &&d.couponMain){ - return d.couponMain.name - } - return ''; - }, title: '优惠券名称'}, + {field: "nick_name",title: '用户昵称'}, + {field: "business_name", title: '商家名称'}, + {field: "coupon_main_name", title: '优惠券名称'}, {templet:"#row-commission", title: '持有比例(渠道商:平台:消费者)'}, {field: 'money', minWidth: 200, title: '金额'}, {field: 'create_time', minWidth: 200, title: '时间'}, diff --git a/public/static/manager/js/business/business.js b/public/static/manager/js/business/business.js index 5791c7b..749f016 100644 --- a/public/static/manager/js/business/business.js +++ b/public/static/manager/js/business/business.js @@ -49,6 +49,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function {field: 'coupon_receive_count', title: '已领取优惠券数量'}, {field: 'coupon_be_overdue_count', title: '过期未使用优惠券数量'}, {field: 'coupon_used_count', title: '已使用优惠数量'}, + {field: 'coupon_profit_count', title: '为平台提供的总收益'}, {field: 'balance',title: '商家余额'}, {field: 'recharge_total_money', title: '充值总额'}, diff --git a/view/manager/agency/add.html b/view/manager/agency/add.html index d31d49b..8d12f10 100644 --- a/view/manager/agency/add.html +++ b/view/manager/agency/add.html @@ -34,14 +34,14 @@ -
+ diff --git a/view/manager/agency/edit.html b/view/manager/agency/edit.html index 492a78e..4b8c107 100644 --- a/view/manager/agency/edit.html +++ b/view/manager/agency/edit.html @@ -28,17 +28,18 @@
-
- -
- -
-
+ + + + + + + + + + + +
diff --git a/view/manager/area/index.html b/view/manager/area/index.html index 0dd4563..fbc3c1e 100644 --- a/view/manager/area/index.html +++ b/view/manager/area/index.html @@ -15,6 +15,15 @@ 开启 + + + + + + + - \ No newline at end of file + + + + + + + + + \ No newline at end of file diff --git a/view/manager/business_circle/edit.html b/view/manager/business_circle/edit.html index cce9822..dd4b8b2 100644 --- a/view/manager/business_circle/edit.html +++ b/view/manager/business_circle/edit.html @@ -19,6 +19,43 @@
+ +
+ +
+ + + + + + +
+
+
+ +
+ +
+ +
+
+ + +
+ +
+
+ +
+
+ +
+
+
+
+ + +
@@ -27,4 +64,110 @@
- \ No newline at end of file + + + + + + + + + \ No newline at end of file diff --git a/view/manager/coupon/edit.html b/view/manager/coupon/edit.html index 265d35d..c94b2d5 100644 --- a/view/manager/coupon/edit.html +++ b/view/manager/coupon/edit.html @@ -129,6 +129,14 @@ + +
+ +
+ +
+
+
请填写完整整数 总和为100
diff --git a/view/manager/member/edit.html b/view/manager/member/edit.html index a9d6b93..efd789e 100644 --- a/view/manager/member/edit.html +++ b/view/manager/member/edit.html @@ -36,7 +36,7 @@
- - - - - -
- -
diff --git a/view/manager/agency/add_channel.html b/view/manager/agency/add_channel.html new file mode 100644 index 0000000..9274ddc --- /dev/null +++ b/view/manager/agency/add_channel.html @@ -0,0 +1,58 @@ +{layout name="manager/layout" /} +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+
+ +
+
+
+
+
+ \ No newline at end of file diff --git a/view/manager/agency/channel_list.html b/view/manager/agency/channel_list.html new file mode 100644 index 0000000..f866cd3 --- /dev/null +++ b/view/manager/agency/channel_list.html @@ -0,0 +1,58 @@ +{layout name="manager/layout" /} + + +
+
+
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/view/manager/agency/edit.html b/view/manager/agency/edit.html index 4b8c107..96097f2 100644 --- a/view/manager/agency/edit.html +++ b/view/manager/agency/edit.html @@ -28,18 +28,6 @@
- - - - - - - - - - - -
diff --git a/view/manager/agency/edit_channel.html b/view/manager/agency/edit_channel.html new file mode 100644 index 0000000..18c1e48 --- /dev/null +++ b/view/manager/agency/edit_channel.html @@ -0,0 +1,53 @@ +{layout name="manager/layout" /} +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+
+ +
+
+
+
+
+ \ No newline at end of file diff --git a/view/manager/business/business_deduction_list.html b/view/manager/business/business_deduction_list.html index 89576b6..7a26863 100644 --- a/view/manager/business/business_deduction_list.html +++ b/view/manager/business/business_deduction_list.html @@ -69,4 +69,9 @@
+ + + \ No newline at end of file diff --git a/view/manager/consumer/blank_list.html b/view/manager/consumer/blank_list.html index e47da67..81084d3 100644 --- a/view/manager/consumer/blank_list.html +++ b/view/manager/consumer/blank_list.html @@ -31,15 +31,6 @@
- -
- -
diff --git a/view/manager/consumer/index.html b/view/manager/consumer/index.html index 2e5ccd0..4888298 100644 --- a/view/manager/consumer/index.html +++ b/view/manager/consumer/index.html @@ -34,19 +34,6 @@
-
- -
- -
-
- -