From 67b37169a5e9c06c910e167d824c4dbb2d0e2c42 Mon Sep 17 00:00:00 2001 From: wangxinglong <2371974647@qq.com> Date: Thu, 20 Jan 2022 13:56:21 +0800 Subject: [PATCH] setter --- app/common.php | 2 +- app/controller/api/Business.php | 6 +- app/controller/api/Consumer.php | 2 +- app/controller/api/Coupon.php | 82 ++++++++++--------- app/controller/api/Dictionary.php | 25 +++++- app/controller/manager/Agency.php | 2 +- app/controller/manager/Business.php | 14 ++-- app/controller/manager/Consumer.php | 14 ++-- app/controller/manager/Coupon.php | 20 ++--- app/controller/manager/CouponType.php | 4 +- app/controller/manager/Statistical.php | 2 +- app/model/Coupon.php | 2 +- app/model/CouponBill.php | 2 +- app/model/CouponMain.php | 4 +- app/model/CouponType.php | 2 +- app/model/Score.php | 2 +- app/model/UsingRule.php | 2 +- app/repository/BusinessRepository.php | 4 +- app/repository/CouponRepository.php | 12 +-- app/repository/DictionaryRepository.php | 12 +-- app/subscribe/Coupon.php | 4 +- app/traits/CouponMainTrait.php | 53 ++++++++---- app/traits/CouponTrait.php | 14 ++-- app/validate/CouponRelease.php | 15 +++- public/static/manager/js/bill.js | 4 +- public/static/manager/js/business/business.js | 8 +- .../js/business/business_deduction_list.js | 2 +- public/static/manager/js/channel.js | 2 +- public/static/manager/js/consumer/index.js | 6 +- public/static/manager/js/consumer/info.js | 4 +- route/api.php | 6 +- view/manager/bill/deduction.html | 2 +- view/manager/bill/index.html | 2 +- .../business/business_coupon_list.html | 2 +- view/manager/business/index.html | 2 +- view/manager/config/wechat.html | 35 ++++++-- view/manager/consumer/info.html | 6 +- view/manager/coupon/add.html | 19 +++-- view/manager/coupon/edit.html | 13 ++- view/manager/coupon/index.html | 4 +- view/manager/coupon/info.html | 6 +- view/manager/login/index.html | 2 +- view/manager/slide/edit.html | 2 +- view/page/screen.html | 17 ++++ 44 files changed, 283 insertions(+), 162 deletions(-) create mode 100644 view/page/screen.html diff --git a/app/common.php b/app/common.php index 9b95936..a6e78bc 100644 --- a/app/common.php +++ b/app/common.php @@ -846,7 +846,7 @@ if (!function_exists('get_distance')) { } /** - * 格式化商圈码的使用周期 + * 格式化优惠券的使用周期 * */ if (!function_exists('encodeCouponCycle')) { function encodeCouponCycle(array $week) diff --git a/app/controller/api/Business.php b/app/controller/api/Business.php index 95e4d0e..f20d27c 100644 --- a/app/controller/api/Business.php +++ b/app/controller/api/Business.php @@ -345,7 +345,7 @@ class Business extends Base } /** - * 商家商圈码详情 + * 商家优惠券详情 * */ public function couponDetail() { @@ -357,10 +357,10 @@ class Business extends Base $couponMainId = input("id/d"); $couponMain = CouponMain::findOne(["id"=>$couponMainId]); if(empty($couponMain)){ - return $this->json(4001,"商圈码不存在"); + return $this->json(4001,"优惠券不存在"); } if(!$business = BusinessRepository::getInstance()->findOneByWhere(["code"=>$couponMain["business_code"]])){ - return $this->json(4001,"商圈码商家信息不存在"); + return $this->json(4001,"优惠券商家信息不存在"); } $list = $business->toArray(); diff --git a/app/controller/api/Consumer.php b/app/controller/api/Consumer.php index a493398..0f32fff 100644 --- a/app/controller/api/Consumer.php +++ b/app/controller/api/Consumer.php @@ -123,7 +123,7 @@ class Consumer extends Base $item->distance_text = $distance . "m"; } - //是否收藏了该商圈码的商家 + //是否收藏了该优惠券的商家 $item->isFlow = in_array($item->business_code,$flowArray); $item->couponId = $item->id; diff --git a/app/controller/api/Coupon.php b/app/controller/api/Coupon.php index 52c1b08..13f2446 100644 --- a/app/controller/api/Coupon.php +++ b/app/controller/api/Coupon.php @@ -69,7 +69,7 @@ class Coupon extends Base $whereMap[] = ['consumer_code', '=', $accountCode]; switch ($type) { case 'all': - // 全部持有商圈码 + // 全部持有优惠券 $sortOrder = ['sort_weight' => 'desc', 'end_time' => 'asc']; break; case 'notUsed': @@ -94,7 +94,7 @@ class Coupon extends Base }, $sortOrder); $time = time(); $res['list'] ->each(function ($item) use($time){ - //重置商圈码名称 + //重置优惠券名称 if(isset($item->couponMain) && $item->couponMain){ $item->couponName = $item->couponMain->name; $item->image_url = $this->request->domain() . $item->couponMain->image_url; @@ -186,7 +186,7 @@ class Coupon extends Base }, $sortOrder); $res['list'] ->each(function ($item){ - //重置商圈码名称 + //重置优惠券名称 if(isset($item->couponMain) && $item->couponMain){ $item->couponName = $item->couponMain->name; } @@ -202,7 +202,7 @@ class Coupon extends Base } /** - * 领取商圈码 + * 领取优惠券 * */ public function receiveCoupon() { @@ -226,7 +226,7 @@ class Coupon extends Base return $q->with("business")->lock(true); }); if(!isset($couponMain->business)||empty($couponMain->business)){ - return $this->json(4001, "商圈码所属商家不存在"); + return $this->json(4001, "优惠券所属商家不存在"); } if($couponMain->business->enable != BusinessModel::COMMON_OFF){ @@ -234,7 +234,7 @@ class Coupon extends Base } try { - //检查商圈码状态 + //检查优惠券状态 CouponRepository::getInstance()->checkCouponMainReceiveStatus($couponMain); }catch (RepositoryException $e){ return $this->json(4001,$e->getMessage()); @@ -277,11 +277,11 @@ class Coupon extends Base Db::commit(); return $this->json(); }catch (RepositoryException $e){ - Log::error("商圈码领取失败RepositoryException:".$e->getMessage()); + Log::error("优惠券领取失败RepositoryException:".$e->getMessage()); Db::rollback(); return $this->json(5001,"领取失败"); }catch (Exception $e){ - Log::error("商圈码领取失败:".$e->getMessage()); + Log::error("优惠券领取失败:".$e->getMessage()); Db::rollback(); return $this->json(5001,"领取失败"); } @@ -289,7 +289,7 @@ class Coupon extends Base } /** - * 核验商圈码 程序----核心操作---- + * 核验优惠券 程序----核心操作---- * */ public function verification() { @@ -315,31 +315,31 @@ class Coupon extends Base }); if(empty($coupon)){ - return $this->json(4001, "商圈码不存在"); + return $this->json(4001, "优惠券不存在"); } if($coupon->consumer_code != $account->user_code ){ return $this->json(4001, "参数错误"); } if($coupon->is_verificated != CouponModel::is_verificated_off){ - return $this->json(4001, "商圈码验证"); + return $this->json(4001, "优惠券验证"); } if($coupon->status != CouponMain::status_on){ - return $this->json(4001, "商圈码已停用"); + return $this->json(4001, "优惠券已停用"); } if($coupon->on_shelf != CouponMain::on_shelf_on){ - return $this->json(4001, "商圈码下架"); + return $this->json(4001, "优惠券下架"); } if(!isset($coupon->couponMain) || empty($coupon->couponMain)){ - return $this->json(4001, "商家商圈码信息错误"); + return $this->json(4001, "商家优惠券信息错误"); } if(strtotime($coupon->couponMain->end_time) < $time){ - return $this->json(4001, "商圈码已过期"); + return $this->json(4001, "优惠券已过期"); } //$usingRule = UsingRule::findOne(["coupon_id"=>$coupon->couponMain->id]); //if(empty($usingRule)){ - // return $this->json(4001, "商家商圈码使用规则信息错误"); + // return $this->json(4001, "商家优惠券使用规则信息错误"); //} //一天的开始时间 @@ -402,7 +402,7 @@ class Coupon extends Base //开始数据操作 Db::startTrans(); try { - // 1. 修改商圈码状态 + // 1. 修改优惠券状态 $coupon->save([ "is_verificated" => CouponModel::is_verificated_on, "used_time" => date("Y-m-d H:i:s" ,$time), @@ -430,7 +430,7 @@ class Coupon extends Base $agencyMoney = 0; //四舍五入 精确到分 } - // 2. 写入商圈码流水 + // 2. 写入优惠券流水 $couponBillData = [ "coupon_main_id" => $coupon->couponMain->id, "coupon_id" => $coupon->id, @@ -457,7 +457,7 @@ class Coupon extends Base "business_code" => $business->code, "business_name" => $business->business_name, "balance" => $business->balance - $deductionMoney, - "reason" => sprintf("[%s]验证商圈码[%s]扣除[%s]",$account->nick_name, $coupon->couponMain->name,$deductionMoney), + "reason" => sprintf("[%s]验证优惠券[%s]扣除[%s]",$account->nick_name, $coupon->couponMain->name,$deductionMoney), "coupon_main_id" => $coupon->couponMain->id, "coupon_id" => $coupon->id, "bill_id" => $couponBill->id, @@ -484,7 +484,7 @@ class Coupon extends Base //企业付款成功 if(isset($result["status"]) && $result["status"]=="SUCCESS"){ Db::commit(); - return $this->json(0,"商圈码签到使用成功,您获得{$consumerMoney}元红包,已存入您的零钱"); + return $this->json(0,"优惠券签到使用成功,您获得{$consumerMoney}元红包,已存入您的零钱"); } Log::info("查询企业付款失败:".json_encode($result,JSON_UNESCAPED_UNICODE)); }else{ @@ -495,7 +495,7 @@ class Coupon extends Base 'openid' => $account->open_id, 'check_name' => 'NO_CHECK',// NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名 'amount' => $amount, //单位为分,不小于100 - 'desc' => '验证商圈码签到', + 'desc' => '验证优惠券签到', ]; //不发起支付 //$result = $payment->transfer->toBalance($toBalanceData); @@ -505,7 +505,7 @@ class Coupon extends Base //付款成功才提交!!!!!伪装成功 if(true||isset($result['payment_no']) ){ Db::commit(); - return $this->json(0,"商圈码签到使用成功,您获得{$consumerMoney}元红包,已存入您的零钱"); + return $this->json(0,"优惠券签到使用成功,您获得{$consumerMoney}元红包,已存入您的零钱"); } //Log::info("企业发起付款失败:" . json_encode($result,JSON_UNESCAPED_UNICODE)); } @@ -529,7 +529,7 @@ class Coupon extends Base } /** - * 发布商圈码 + * 发布优惠券 * */ public function add() { @@ -568,13 +568,13 @@ class Coupon extends Base if ($hasCouponMax > 0) { $hasCouponCount = CouponRepository::getInstance()->getBusinessOnShelfOnCount($account->business->code); if ($hasCouponCount > $hasCouponMax) { - return $this->json(4001, "商家持有商家商圈码不能超过{$hasCouponMax}"); + return $this->json(4001, "商家持有商家优惠券不能超过{$hasCouponMax}"); } } - //验证通过 不管是商家还是工作人员 都可以发布商圈码 + //验证通过 不管是商家还是工作人员 都可以发布优惠券 $couponMain = [ "name" => $data['name'] ?? '', "business_code" => $account->business->code, @@ -591,6 +591,7 @@ class Coupon extends Base "white_list" => $data['white_list'] ?? '', "status" => CouponMain::status_on, "on_shelf" => CouponMain::on_shelf_off,//默认下架 后台审核上架 + "on_screen" => $data['on_screen'] ?? 1, "commission_agency" => $distributionProportion['agency'], "commission_admin" => $distributionProportion['admin'], "commission_consumer" => $distributionProportion['consumer'], @@ -613,7 +614,7 @@ class Coupon extends Base //检查类型 if(CouponTypeModel::checkType($couponMain['type']) !== true){ - return $this->json(4001, '商圈码类型不存在'); + return $this->json(4001, '优惠券类型不存在'); } @@ -629,7 +630,7 @@ class Coupon extends Base $couponMain['money'] = floor($couponMain['money'] * 100) / 100; $totalMoney = $couponMain['money'] * $couponMain['count']; - //未领取的商圈码 + //未领取的优惠券 $NotClaimedMoney = CouponRepository::getInstance()->getBusinessNotClaimedCoupon($account->business["code"]); if($account->business["model"] == BusinessModel::model_ordinary) { if ($account->business["balance"] < ($totalMoney + $NotClaimedMoney)) { @@ -653,7 +654,7 @@ class Coupon extends Base } /** - * 修改商圈码 + * 修改优惠券 * */ public function edit() { @@ -677,14 +678,14 @@ class Coupon extends Base $couponMain = CouponMain::findById($couponMainId,[]); if (empty($couponMain)) { - return $this->json(4001, "商圈码不存在"); + return $this->json(4001, "优惠券不存在"); } //if (!isset($couponMain->usingRule)||empty($couponMain->usingRule)) { - // return $this->json(4001, "商圈码信息错误"); + // return $this->json(4001, "优惠券信息错误"); //} $data = input(); - //验证通过 不管是商家还是工作人员 都可以修改商圈码 只能修改指定字段 + //验证通过 不管是商家还是工作人员 都可以修改优惠券 只能修改指定字段 $couponMainData = [ "name" => $data['name'] ?? '', "type" => $data['type'] ?? 0, @@ -695,6 +696,7 @@ class Coupon extends Base "intro" => $data['intro'] ?? '', "content" => $data['content'] ?? '', "white_list" => $data['white_list'] ?? '', + "on_screen" => $data['on_screen'] ?? 1, ]; //$usingRule = input("using_rule/a"); @@ -711,7 +713,7 @@ class Coupon extends Base //检查类型 if(CouponTypeModel::checkType($couponMainData['type']) !== true){ - return $this->json(4001, '商圈码类型不存在'); + return $this->json(4001, '优惠券类型不存在'); } //验证通过 @@ -732,7 +734,7 @@ class Coupon extends Base } /** - * 商家管理商圈码 + * 商家管理优惠券 * */ public function getPageList() { @@ -788,7 +790,7 @@ class Coupon extends Base } /** - * 商圈码的领取 使用记录列表 + * 优惠券的领取 使用记录列表 * */ public function getShopCouponList() { @@ -813,10 +815,10 @@ class Coupon extends Base $couponMain = CouponMain::findById($couponMainId); if(empty($couponMain)){ - return $this->json(4001, "商圈码不存在"); + return $this->json(4001, "优惠券不存在"); } if($couponMain->business_code != $account->business->code){ - return $this->json(4001, "商圈码参数信息错误"); + return $this->json(4001, "优惠券参数信息错误"); } $page = $this->request->param('page/d', 1); @@ -833,7 +835,7 @@ class Coupon extends Base } switch ($type) { case 'all': - // 全部持有商圈码 + // 全部持有优惠券 $sortOrder = [ 'end_time' => 'asc']; break; case 'notUsed': @@ -872,7 +874,7 @@ class Coupon extends Base } /** - * 获取商圈码详情 + * 获取优惠券详情 * */ public function getCouponMainInfo() { @@ -883,14 +885,14 @@ class Coupon extends Base }]); }); if(empty($couponMain)){ - return $this->json(4001,"商圈码不存在"); + return $this->json(4001,"优惠券不存在"); } return $this->json(0,"success",$couponMain->toArray()); } /** - * 已使用商圈码 评分 + * 已使用优惠券 评分 * */ public function score() { diff --git a/app/controller/api/Dictionary.php b/app/controller/api/Dictionary.php index 492e970..f5fee28 100644 --- a/app/controller/api/Dictionary.php +++ b/app/controller/api/Dictionary.php @@ -5,8 +5,9 @@ use app\exception\RepositoryException; use app\repository\BusinessRepository; use app\repository\CouponRepository; use app\repository\DictionaryRepository; +use think\facade\Config as CConfig; use think\response\Json; -use app\model\{Business as BusinessModel, Member}; +use app\model\{Business as BusinessModel, BusinessCircle, Member}; /** * APP 数据字典 @@ -22,6 +23,7 @@ class Dictionary extends Base 'getAgencyList', 'getBusinessTypeList', 'getCouponTypeList', + 'screen', ]; /** @@ -118,5 +120,26 @@ class Dictionary extends Base } + /** + * 商圈大屏 + * */ + public function screen() + { + $id = input("id/d",0); + $business_circle = BusinessCircle::findOne([["id","=",$id]]); + if(empty($business_circle)){ + return $this->json(4001,"商圈不存在"); + } + + $couponMain = CouponRepository::getInstance()->screen($id); + + + + CConfig::load('extra/wechat', 'wechat'); + $screenTopBanner = config('wechat')['screenTopBanner']??"/static/images/screenTopBanner.jpg"; + + return view('/page/screen')->assign(["couponMain"=>$couponMain,"screenTopBanner"=>$screenTopBanner]); + + } } \ No newline at end of file diff --git a/app/controller/manager/Agency.php b/app/controller/manager/Agency.php index 6d4f0d6..62ee95e 100644 --- a/app/controller/manager/Agency.php +++ b/app/controller/manager/Agency.php @@ -306,7 +306,7 @@ class Agency extends Base $list["list"]->each(function ($item) { //管理的商家数 $item->business_count = BusinessRepository::getInstance()->agencyHasBusinessCount($item['business_code']); - //管理的商家的商圈码数 + //管理的商家的优惠券数 $item->coupon_count = BusinessRepository::getInstance()->agencyHasCouponCount($item['business_code']); }); return $this->json(0, 'success', $list); diff --git a/app/controller/manager/Business.php b/app/controller/manager/Business.php index dc7466c..65d31b3 100644 --- a/app/controller/manager/Business.php +++ b/app/controller/manager/Business.php @@ -60,12 +60,12 @@ class Business extends Base } $list = $repo->businessList($whereMap, $page, $size, $orders); $list["list"]->each(function ($item) { - //得到当前商家的所有商圈码 + //得到当前商家的所有优惠券 $date = date("Y-m-d H:i:s"); - //商圈码总数 + //优惠券总数 $item->coupon_total_count = CouponMain::where(["business_code" => $item->business_code])->sum("count"); - //进行中商圈码总数 + //进行中优惠券总数 $item->coupon_doing_count = CouponMain::where(["business_code" => $item->business_code]) ->whereTime("start_time", "<", $date) ->whereTime("end_time", ">", $date) @@ -73,16 +73,16 @@ class Business extends Base ->where("on_shelf", CouponMain::on_shelf_on) ->sum("count"); - //进行中商圈码总数 + //进行中优惠券总数 $item->coupon_receive_count = CouponMain::where(["business_code" => $item->business_code])->sum("received_count"); - //过期未使用商圈码总数 + //过期未使用优惠券总数 $item->coupon_be_overdue_count = Coupon::where(["business_code" => $item->business_code]) ->where("is_verificated", "=", Coupon::is_verificated_off) ->whereTime("end_time", "<", $date) ->count(); - //已使用商圈码总数 + //已使用优惠券总数 $item->coupon_used_count = Coupon::where(["business_code" => $item->business_code]) ->where("is_verificated", "=", Coupon::is_verificated_on) ->count(); @@ -107,7 +107,7 @@ class Business extends Base /** - * 商家商圈码列表 + * 商家优惠券列表 * * @return Json|View * @throws Exception diff --git a/app/controller/manager/Consumer.php b/app/controller/manager/Consumer.php index 71fd2ea..bed8e79 100644 --- a/app/controller/manager/Consumer.php +++ b/app/controller/manager/Consumer.php @@ -41,11 +41,11 @@ class Consumer extends Base return $q->with("tag"); }, $orders); $list["list"]->each(function ($item) { - //商圈码领取总数 + //优惠券领取总数 $item->coupon_total_count = Coupon::where(["consumer_code" => $item->user_code])->count("id"); - //商圈码使用总数 + //优惠券使用总数 $item->coupon_used_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_on)->count("id"); - //商圈码未使用总数 + //优惠券未使用总数 $item->coupon_not_use_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_off)->count("id"); //优惠红包总金额 @@ -72,7 +72,7 @@ class Consumer extends Base $consumer = Account::findOne(["id" => $id], [], function ($q) { return $q->with("tag"); }); - //只查询商圈码持有 + //只查询优惠券持有 if ($this->request->isPost()) { $repo = AccountRepository::getInstance(); $page = $this->request->param('page/d', 1); @@ -103,12 +103,12 @@ class Consumer extends Base //评论总数数 $this->data["totalTheMonthComment"] = $rep->consumerTheMonthTotalComment($consumer["user_code"]); - //商圈码领取总数 + //优惠券领取总数 $this->data["couponTotalCount"] = $rep->consumerTotalCoupon($consumer["user_code"]); - //商圈码使用总数 + //优惠券使用总数 $this->data["couponUsedTotalCount"] = $rep->consumerUsedTotalCoupon($consumer["user_code"]); - //商圈码未使用总数 + //优惠券未使用总数 $this->data["couponNotUsedTotalCount"] = $rep->consumerNotUsedTotalCoupon($consumer["user_code"]); $this->data["consumer"] = $consumer->toArray(); diff --git a/app/controller/manager/Coupon.php b/app/controller/manager/Coupon.php index 0134762..1ec0d92 100644 --- a/app/controller/manager/Coupon.php +++ b/app/controller/manager/Coupon.php @@ -20,7 +20,7 @@ use think\response\View; use think\facade\Config as CConfig; /** - * 商圈码相关 + * 优惠券相关 **/ class Coupon extends Base { @@ -102,7 +102,7 @@ class Coupon extends Base $coupon = $repo->findById($id); if (empty($coupon)) { - return $this->json(4001, "商圈码不存在"); + return $this->json(4001, "优惠券不存在"); } if (!in_array($on_shelf, [CouponMain::COMMON_OFF, CouponMain::COMMON_ON])) { @@ -149,14 +149,14 @@ class Coupon extends Base ->with('category'); }, "couponType"])->where("id", $id)->find(); if (empty($coupon)) { - return $this->error("商圈码不存在"); + return $this->error("优惠券不存在"); } $this->data["coupon"] = $coupon; return $this->view(); } /** - * 发布商圈码 + * 发布优惠券 * * @return Json|View * @throws Exception @@ -194,13 +194,13 @@ class Coupon extends Base if ($hasCouponMax > 0) { $hasCouponCount = CouponRepository::getInstance()->getBusinessOnShelfOnCount($business->code); if ($hasCouponCount > $hasCouponMax) { - return $this->json(4001, "商家持有商家商圈码不能超过{$hasCouponMax}"); + return $this->json(4001, "商家持有商家优惠券不能超过{$hasCouponMax}"); } } //检查类型 if(CouponTypeModel::checkType($data['type']) !== true){ - return $this->json(4001, '商圈码类型不存在'); + return $this->json(4001, '优惠券类型不存在'); } $type = CouponRepository::getInstance()->getCouponTypeAll(); $data['type_name'] = $type[$data['type']]['name']; @@ -228,7 +228,7 @@ class Coupon extends Base $totalMoney = $data['money'] * $data['count']; - //未领取的商圈码 + //未领取的优惠券 $NotClaimedMoney = CouponRepository::getInstance()->getBusinessNotClaimedCoupon($business["code"]); if($business["model"] == BusinessModel::model_ordinary){ @@ -280,7 +280,7 @@ class Coupon extends Base $data = input("item/a", []); //$usingRule = input("using_rule/a", []); if (empty($couponMain)) { - return $this->json(4001, "商圈码不存在"); + return $this->json(4001, "优惠券不存在"); } $validate = new CouponRelease(); if (!$validate->scene("edit")->check($data)) { @@ -299,7 +299,7 @@ class Coupon extends Base //检查类型 if(CouponTypeModel::checkType($data['type']) !== true){ - return $this->json(4001, '商圈码类型不存在'); + return $this->json(4001, '优惠券类型不存在'); } //更新经纬度 @@ -337,7 +337,7 @@ class Coupon extends Base } if (empty($couponMain)) { - return $this->error("商圈码不存在"); + return $this->error("优惠券不存在"); } $this->data['business'] = BusinessRepository::getInstance()->getBusinessAll(); $this->data['type'] = CouponRepository::getInstance()->getCouponTypeAll(); diff --git a/app/controller/manager/CouponType.php b/app/controller/manager/CouponType.php index 79d52d1..7e86e62 100644 --- a/app/controller/manager/CouponType.php +++ b/app/controller/manager/CouponType.php @@ -17,7 +17,7 @@ use think\response\Json; use think\response\View; /** - * 商圈码类型 + * 优惠券类型 * * Class CouponType * @package app\controller\manager @@ -110,7 +110,7 @@ class CouponType extends Base $couponMain = CouponMain::findOne([["type","in",$ids]]); if(!empty($couponMain)){ - return $this->json(4001,"该商圈码绑定了该类型,不能删除"); + return $this->json(4001,"该优惠券绑定了该类型,不能删除"); } CouponTypeModel::destroy($ids); diff --git a/app/controller/manager/Statistical.php b/app/controller/manager/Statistical.php index b6df7cb..e425deb 100644 --- a/app/controller/manager/Statistical.php +++ b/app/controller/manager/Statistical.php @@ -99,7 +99,7 @@ class Statistical extends Base } /** - * 领取商圈码位置 + * 领取优惠券位置 * */ public function receive(){ if($this->request->isPost()){ diff --git a/app/model/Coupon.php b/app/model/Coupon.php index 5c90b37..e94324b 100644 --- a/app/model/Coupon.php +++ b/app/model/Coupon.php @@ -8,7 +8,7 @@ use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; /** - * 商圈码 + * 优惠券 * Class Coupon * @package app\model */ diff --git a/app/model/CouponBill.php b/app/model/CouponBill.php index 6be8aa1..660514b 100644 --- a/app/model/CouponBill.php +++ b/app/model/CouponBill.php @@ -8,7 +8,7 @@ use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; /** - * 商圈码验证记录 各个角色的提成 + * 优惠券验证记录 各个角色的提成 * Class Coupon * @package app\model */ diff --git a/app/model/CouponMain.php b/app/model/CouponMain.php index 39b673b..88a4e7f 100644 --- a/app/model/CouponMain.php +++ b/app/model/CouponMain.php @@ -9,7 +9,7 @@ use think\db\exception\ModelNotFoundException; use think\Model; /** - * 商圈码主表 + * 优惠券主表 * Class CouponMain * @package app\model */ @@ -20,6 +20,8 @@ class CouponMain extends Base const on_shelf_on = 0;//上架状态 const on_shelf_off = 1;//下架状态 + const on_screen_yes = 1;//展示到商圈大屏 + public function business() { return $this->hasOne(Business::class, 'code',"business_code"); diff --git a/app/model/CouponType.php b/app/model/CouponType.php index 91104c1..85d3db6 100644 --- a/app/model/CouponType.php +++ b/app/model/CouponType.php @@ -9,7 +9,7 @@ use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; /** - * 商圈码类型 + * 优惠券类型 * Class CouponType * @package app\model */ diff --git a/app/model/Score.php b/app/model/Score.php index 0a6c863..7c7ad23 100644 --- a/app/model/Score.php +++ b/app/model/Score.php @@ -2,7 +2,7 @@ namespace app\model; /** - * 商圈码使用后商家打分 + * 优惠券使用后商家打分 * Class Score * @package app\model */ diff --git a/app/model/UsingRule.php b/app/model/UsingRule.php index 3c7de60..b56b7ff 100644 --- a/app/model/UsingRule.php +++ b/app/model/UsingRule.php @@ -1,7 +1,7 @@ id; //UsingRule::create($usingRule); //Business::where("code", $data["business_code"])->dec("balance", $totalMoney)->update(); @@ -102,7 +102,7 @@ class CouponRepository extends Repository } /** - * 写入一个领取商圈码 + * 写入一个领取优惠券 * @param array $data * @return Coupon|Model */ diff --git a/app/repository/DictionaryRepository.php b/app/repository/DictionaryRepository.php index 63d16ff..7e9cb1a 100644 --- a/app/repository/DictionaryRepository.php +++ b/app/repository/DictionaryRepository.php @@ -159,7 +159,7 @@ class DictionaryRepository extends Repository } /** - * 获取一个商圈码的使用规则 + * 获取一个优惠券的使用规则 * @param int $couponMainId * @return string * @throws \think\db\exception\DataNotFoundException @@ -172,10 +172,10 @@ class DictionaryRepository extends Repository if(empty($usingRule)){ return ''; } - return "
该商圈码可以在" . encodeCouponCycle($usingRule->cycle) . "进行使用
-
该商圈码可以在每天的" . $usingRule->day_start_time ."到" .$usingRule->day_end_time ."进行使用
-
该商圈码每天一共可以领取". $usingRule->day_total ."张
-
该商圈码每天每人可以领取". $usingRule->person_day_total ."张
-
该商圈码每人总共可以领取". $usingRule->person_total ."张
"; + return "
该优惠券可以在" . encodeCouponCycle($usingRule->cycle) . "进行使用
+
该优惠券可以在每天的" . $usingRule->day_start_time ."到" .$usingRule->day_end_time ."进行使用
+
该优惠券每天一共可以领取". $usingRule->day_total ."张
+
该优惠券每天每人可以领取". $usingRule->person_day_total ."张
+
该优惠券每人总共可以领取". $usingRule->person_total ."张
"; } } \ No newline at end of file diff --git a/app/subscribe/Coupon.php b/app/subscribe/Coupon.php index 274b726..8e800b9 100644 --- a/app/subscribe/Coupon.php +++ b/app/subscribe/Coupon.php @@ -9,13 +9,13 @@ use think\facade\Log; class Coupon { /** - * 检查过期的商圈码修改状态 + * 检查过期的优惠券修改状态 * */ public function onCouponStatusCheck() { $count = CouponMain::whereTime("end_time", "<", date("Y-m-d"))->where(["status" => CouponMain::status_on])->count(); if ($count) { - Log::info("修改了商圈码状态" . $count); + Log::info("修改了优惠券状态" . $count); CouponMain::whereTime("end_time", "<", date("Y-m-d"))->update(["status" => CouponMain::status_off]); } } diff --git a/app/traits/CouponMainTrait.php b/app/traits/CouponMainTrait.php index 8b47b9f..9cafbc4 100644 --- a/app/traits/CouponMainTrait.php +++ b/app/traits/CouponMainTrait.php @@ -13,37 +13,37 @@ use think\facade\Db; trait CouponMainTrait { /** - * 检查商圈码状态是否可以领取 + * 检查优惠券状态是否可以领取 * @param CouponMain $couponMain * @return bool */ public function checkCouponMainReceiveStatus(CouponMain $couponMain){ if (empty($couponMain)) { - throw new RepositoryException("商圈码不存在"); + throw new RepositoryException("优惠券不存在"); } if ($couponMain->status != CouponMain::status_on) { - throw new RepositoryException("商圈码已停用"); + throw new RepositoryException("优惠券已停用"); } if ($couponMain->on_shelf != CouponMain::on_shelf_on) { - throw new RepositoryException("商圈码已下架"); + throw new RepositoryException("优惠券已下架"); } $time = time(); if (strtotime($couponMain->start_time) > $time) { - throw new RepositoryException("商圈码还未到开始使用时间"); + throw new RepositoryException("优惠券还未到开始使用时间"); } if (strtotime($couponMain->end_time) < $time) { - throw new RepositoryException("商圈码已结束使用"); + throw new RepositoryException("优惠券已结束使用"); } if ($couponMain->using_count <= 0) { - throw new RepositoryException("商圈码已经被领完了"); + throw new RepositoryException("优惠券已经被领完了"); } return true; } /** - * 统计这个商圈码已经使用了多少张了 + * 统计这个优惠券已经使用了多少张了 * @param $couponMainId * @return int */ @@ -55,7 +55,7 @@ trait CouponMainTrait } /** - * 获取商户没有被领取的商圈码 需要扣除多少钱 + * 获取商户没有被领取的优惠券 需要扣除多少钱 * */ public function getBusinessNotClaimedCoupon($businessCode) { @@ -78,7 +78,7 @@ trait CouponMainTrait } /** - * 获取 发布商圈码的统计 + * 获取 发布优惠券的统计 * 每条数据都走一遍 * * */ @@ -102,7 +102,7 @@ trait CouponMainTrait } /** - * 获取 验证商圈码的统计 + * 获取 验证优惠券的统计 * 每条数据都走一遍 * * */ @@ -126,7 +126,7 @@ trait CouponMainTrait ; } /** - * 获取 验证商圈码的统计 + * 获取 验证优惠券的统计 * 每条数据都走一遍 * * */ @@ -150,7 +150,7 @@ trait CouponMainTrait } /** - * 获取商家商家的商圈码 + * 获取商家商家的优惠券 * */ public function getBusinessOnShelfOnCount($businessCode) { @@ -217,7 +217,7 @@ trait CouponMainTrait /** - * 商圈码列表 + * 优惠券列表 * @param $whereMap * @param $page * @param $size @@ -246,4 +246,29 @@ trait CouponMainTrait $data["list"] = $rep->order($orders)->select(); return $data; } + + /** + * 获取指定商圈的优惠券 大屏使用 + * */ + + public function screen($circle_id) + { + $whereMap = []; + $nowDate = date('Y-m-d H:i:s'); + $whereMap[] = ['a.status', '=', CouponMain::status_on]; + $whereMap[] = ['a.on_shelf', '=', CouponMain::on_shelf_on]; + //$whereMap[] = ['start_time', '< TIME', $nowDate]; + $whereMap[] = ['a.end_time', '> TIME', $nowDate]; + $whereMap[] = ['a.using_count', '>', 0]; + $whereMap[] = ['a.on_screen', '=', CouponMain::on_screen_yes]; + + return CouponMain::alias("a") + ->join("business b" ,"a.business_code = b.code") + ->where("b.business_circle_id",$circle_id) + ->where($whereMap) + ->field("a.business_code,a.id,a.image_url") + ->order("a.id desc") + ->select() + ->toArray(); + } } \ No newline at end of file diff --git a/app/traits/CouponTrait.php b/app/traits/CouponTrait.php index 554b9d3..261145b 100644 --- a/app/traits/CouponTrait.php +++ b/app/traits/CouponTrait.php @@ -12,7 +12,7 @@ use app\model\Coupon; trait CouponTrait { - /**消费者持有商圈码总数 + /**消费者持有优惠券总数 * @param string $userCode * * @@ -23,7 +23,7 @@ trait CouponTrait return Coupon::where("consumer_code", $userCode)->count("id"); } - /**消费者已使用商圈码总数 + /**消费者已使用优惠券总数 * @param string $userCode * @return int */ @@ -33,7 +33,7 @@ trait CouponTrait } /** - * 消费者已使用商圈码总数 + * 消费者已使用优惠券总数 * @param string $userCode * @return int */ @@ -43,7 +43,7 @@ trait CouponTrait } /** - * 消费者已使用商圈码总数 + * 消费者已使用优惠券总数 * @param string $userCode * @return array * @throws \Exception @@ -56,7 +56,7 @@ trait CouponTrait } /** - * 查看某个商圈码的是否可以领取 0 可以领取 1 已领取不能再领取 + * 查看某个优惠券的是否可以领取 0 可以领取 1 已领取不能再领取 * @param $accountCode * @param CouponMain $couponMain * @return int @@ -102,7 +102,7 @@ trait CouponTrait /** - * 查看某个商圈码的是否可以领取 0 可以领取 1 已领取不能再领取 + * 查看某个优惠券的是否可以领取 0 可以领取 1 已领取不能再领取 * @param Account $account * @param CouponMain $couponMain * @return void @@ -157,7 +157,7 @@ trait CouponTrait throw new RepositoryException("请先授权手机号和真实姓名"); } if (false === strpos($couponMain->white_list, $account->mobile . "-" . $account->real_name)) { - throw new RepositoryException("您没有在该商圈码白名单内"); + throw new RepositoryException("您没有在该优惠券白名单内"); } } diff --git a/app/validate/CouponRelease.php b/app/validate/CouponRelease.php index db62f64..2c60433 100644 --- a/app/validate/CouponRelease.php +++ b/app/validate/CouponRelease.php @@ -12,7 +12,7 @@ class CouponRelease extends Validate //'lng|经度' => 'require', //'lat|纬度' => 'require', 'count|总数' => 'require|number|>:0', - 'type|商圈码类型' => 'require', + 'type|优惠券类型' => 'require|>:0', 'start_time|开始时间' => 'require|date', 'end_time|结束时间' => 'require|date|checkEndTime', 'name|优惠券名称' => 'require|chsAlphaNum|length:3,32', @@ -26,14 +26,23 @@ class CouponRelease extends Validate //'edition|发布的版本' => '', 'status|状态' => 'require|in:1,0', 'on_shelf|上架状态' => 'require|in:1,0', + 'on_screen|展示到商圈大屏' => 'require|in:1,0', //'intro|详情' => '', //'content|详情' => '', //'white_list|白名单' => '', ]; + protected $message = [ + 'business_code.require' => '商家信息错误', + 'type' => '优惠券类型错误', + 'status' => '状态错误', + 'on_shelf' => '上架状态错误', + 'on_screen' => '展示到商圈大屏状态错误', + ]; + protected $scene = [ - 'edit' => ['start_time', 'end_time', 'name',"status","on_shelf",'image_url'], - 'api_edit' => ['name', 'type', 'start_time',"end_time","image_url"], + 'edit' => ['type','start_time', 'end_time', 'name',"status","on_shelf",'image_url'], + 'api_edit' => ['type','name', 'type', 'start_time',"end_time","image_url"], ]; // edit 验证场景定义 diff --git a/public/static/manager/js/bill.js b/public/static/manager/js/bill.js index d63c3be..c13a534 100644 --- a/public/static/manager/js/bill.js +++ b/public/static/manager/js/bill.js @@ -12,7 +12,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect',"laydate"] if ($('.location-index-page').length > 0) { miniTab.listen(); var exportDataTitle= - ["用户昵称","商家昵称","商圈码名称","持有比例(渠道商:平台:消费者)","金额","时间"] + ["用户昵称","商家昵称","优惠券名称","持有比例(渠道商:平台:消费者)","金额","时间"] ; var exportData =[]; // 渲染表格 @@ -50,7 +50,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect',"laydate"] {type: 'checkbox'}, {field: "nick_name",title: '用户昵称'}, {field: "business_name", title: '商家名称'}, - {field: "coupon_main_name", title: '商圈码名称'}, + {field: "coupon_main_name", title: '优惠券名称'}, {templet:"#row-commission", title: '持有比例(渠道商:平台:消费者)'}, {field: 'deduction_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 d0c3b08..dbaca6f 100644 --- a/public/static/manager/js/business/business.js +++ b/public/static/manager/js/business/business.js @@ -44,10 +44,10 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function {templet: '#row-cover', title: '头像', style: 'height: 90px;'}, {field:"account_nick_name", title: '昵称'}, {field: "business_name" ,title: '商家名称'}, - {field: 'coupon_total_count', title: '商圈码总数量'}, - {field: 'coupon_doing_count', title: '进行中商圈码数量'}, - {field: 'coupon_receive_count', title: '已领取商圈码数量'}, - {field: 'coupon_be_overdue_count', title: '过期未使用商圈码数量'}, + {field: 'coupon_total_count', title: '优惠券总数量'}, + {field: 'coupon_doing_count', title: '进行中优惠券数量'}, + {field: 'coupon_receive_count', title: '已领取优惠券数量'}, + {field: 'coupon_be_overdue_count', title: '过期未使用优惠券数量'}, {field: 'coupon_used_count', title: '已使用优惠数量'}, {field: 'coupon_profit_count', title: '为平台提供的总收益'}, diff --git a/public/static/manager/js/business/business_deduction_list.js b/public/static/manager/js/business/business_deduction_list.js index f6d252f..33bc024 100644 --- a/public/static/manager/js/business/business_deduction_list.js +++ b/public/static/manager/js/business/business_deduction_list.js @@ -57,7 +57,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function return d.couponMain.name; } return ''; - }, title: '商圈码名称'}, + }, title: '优惠券名称'}, {field: 'balance' , title: '当前余额'}, ]], done: function () { diff --git a/public/static/manager/js/channel.js b/public/static/manager/js/channel.js index a094356..15e3341 100644 --- a/public/static/manager/js/channel.js +++ b/public/static/manager/js/channel.js @@ -40,7 +40,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function {field: 'id', width: 80, title: 'ID'}, {field: 'nickname', title: '昵称'}, {field: 'business_count', title: '下属商家数'}, - {field: 'coupon_count', title: '下属商圈码数'}, + {field: 'coupon_count', title: '下属优惠券数'}, {field: 'create_time', title: '注册时间'}, {templet: '#row-status', title: '状态'}, diff --git a/public/static/manager/js/consumer/index.js b/public/static/manager/js/consumer/index.js index abe9d18..74dbf34 100644 --- a/public/static/manager/js/consumer/index.js +++ b/public/static/manager/js/consumer/index.js @@ -44,9 +44,9 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function {templet: '#row-cover', title: '头像', style: 'height: 90px;'}, {field: 'nick_name', title: '昵称'}, {templet: '#row-gender', title: '性别'}, - {field: 'coupon_total_count', title: '商圈码领取数'}, - {field: 'coupon_used_count', title: '商圈码使用数'}, - {field: 'coupon_not_use_count', title: '商圈码未使用数'}, + {field: 'coupon_total_count', title: '优惠券领取数'}, + {field: 'coupon_used_count', title: '优惠券使用数'}, + {field: 'coupon_not_use_count', title: '优惠券未使用数'}, {field: 'consumer_coupon_bill_total', title: '红包总收入'}, {field: 'login_time', title: '最近登录'}, diff --git a/public/static/manager/js/consumer/info.js b/public/static/manager/js/consumer/info.js index c66f2d8..9c1b9eb 100644 --- a/public/static/manager/js/consumer/info.js +++ b/public/static/manager/js/consumer/info.js @@ -38,10 +38,10 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function // {type: 'checkbox'}, {field: 'id' , width: 80, title: 'ID'}, {field: 'name', title: '名称'}, - {field: 'type_name', title: '商圈码类型'}, + {field: 'type_name', title: '优惠券类型'}, {templet: '#row-received_map', title: '领取位置'}, {field: 'received_time', title: '领取时间'}, - // {field: 'money', title: '商圈码金额'}, + // {field: 'money', title: '优惠券金额'}, {templet: function (d) { if(d.couponBill!=undefined&&d.couponBill){ return d.couponBill.consumer_money; diff --git a/route/api.php b/route/api.php index 7ff3a48..606bd99 100644 --- a/route/api.php +++ b/route/api.php @@ -11,11 +11,11 @@ use think\facade\Route; //Route::rule('account/loginByCode', "\\app\\controller\\api\\user@login");//用户登录 -//Route::rule('consumer/home', "\\app\\controller\\api\\consumer@home");//首页列表(商圈码列表) -//Route::rule('consumer/bannerList', "\\app\\controller\\api\\consumer@bannerList");//首页列表(商圈码列表) +//Route::rule('consumer/home', "\\app\\controller\\api\\consumer@home");//首页列表(优惠券列表) +//Route::rule('consumer/bannerList', "\\app\\controller\\api\\consumer@bannerList");//首页列表(优惠券列表) //Route::rule('dic/getDisList', "\\app\\controller\\api\\dictionary@getDisList");//距离选项列表 //Route::rule('dic/getBusinessTypeListByPid', "\\app\\controller\\api\\dictionary@getBusinessTypeList");//首页获取商家类型 -//Route::rule('dic/getCouponTypeList', "\\app\\controller\\api\\dictionary@getCouponTypeList");//首页获取商圈码类型 +//Route::rule('dic/getCouponTypeList', "\\app\\controller\\api\\dictionary@getCouponTypeList");//首页获取优惠券类型 //Route::rule('dic/getBusinessTypeList', "\\app\\controller\\api\\business@getBusinessTypeList");//首页获取商家类型 //Route::rule('dic/getBusinessCircle', "\\app\\controller\\api\\business@getBusinessCircle");//首页获取商家商圈 //Route::rule('consumer/flowBusiness', "\\app\\controller\\api\\consumer@flowBusiness");//首页获取商家商圈 diff --git a/view/manager/bill/deduction.html b/view/manager/bill/deduction.html index 5bbcdd5..4e4901a 100644 --- a/view/manager/bill/deduction.html +++ b/view/manager/bill/deduction.html @@ -101,7 +101,7 @@
- +
diff --git a/view/manager/bill/index.html b/view/manager/bill/index.html index 0ed1ae5..e2bb028 100644 --- a/view/manager/bill/index.html +++ b/view/manager/bill/index.html @@ -115,7 +115,7 @@
- +
diff --git a/view/manager/business/business_coupon_list.html b/view/manager/business/business_coupon_list.html index dac0e10..79539bd 100644 --- a/view/manager/business/business_coupon_list.html +++ b/view/manager/business/business_coupon_list.html @@ -29,7 +29,7 @@
- +
diff --git a/view/manager/business/index.html b/view/manager/business/index.html index a22d053..c38a881 100644 --- a/view/manager/business/index.html +++ b/view/manager/business/index.html @@ -51,7 +51,7 @@