From 13682f80c8f8dfe33f6e28fa2e6f430ab6ac412b Mon Sep 17 00:00:00 2001 From: wangxinglong <2371974647@qq.com> Date: Mon, 17 Jan 2022 10:38:53 +0800 Subject: [PATCH] setter --- app/common.php | 48 ++++++++++++++---- app/controller/api/Coupon.php | 29 ++++++++--- app/controller/api/User.php | 2 +- app/controller/manager/Bill.php | 18 ++++++- app/repository/BillRepository.php | 83 ++++++++++++++++++++++++++++++- public/.htaccess | 2 +- view/manager/bill/deduction.html | 52 ++++++++++++++++--- view/manager/config/wechat.html | 7 +++ 8 files changed, 212 insertions(+), 29 deletions(-) diff --git a/app/common.php b/app/common.php index 74a2cb2..a6e78bc 100644 --- a/app/common.php +++ b/app/common.php @@ -890,15 +890,43 @@ if (!function_exists('is_mobile')) { * @param string $day2 * @return number */ -function diffBetweenTwoDays ($day1, $day2) -{ - $second1 = strtotime($day1); - $second2 = strtotime($day2); +if (!function_exists('diffBetweenTwoDays')) { + function diffBetweenTwoDays ($day1, $day2) + { + $second1 = strtotime($day1); + $second2 = strtotime($day2); - if ($second1 < $second2) { - $tmp = $second2; - $second2 = $second1; - $second1 = $tmp; + if ($second1 < $second2) { + $tmp = $second2; + $second2 = $second1; + $second1 = $tmp; + } + return ($second1 - $second2) / 86400; } - return ($second1 - $second2) / 86400; -} \ No newline at end of file +} + +/** + * 获取当前毫秒数 + * */ +if (!function_exists('msectime')) { + function msectime() { + list($msec, $sec) = explode(' ', microtime()); + $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); + return $msectime; + } +} + + +if (!function_exists('filterEmoji')) { + function filterEmoji($str) + { + $str = preg_replace_callback( + '/./u', + function (array $match) { + return strlen($match[0]) >= 4 ? '' : $match[0]; + }, + $str); + + return $str; + } +} diff --git a/app/controller/api/Coupon.php b/app/controller/api/Coupon.php index 94471e2..9047eef 100644 --- a/app/controller/api/Coupon.php +++ b/app/controller/api/Coupon.php @@ -293,11 +293,13 @@ class Coupon extends Base * */ public function verification() { - $accountId = $this->request->user['user_id'] ?? 0; - $lat = input("lat/f",0); - $lng = input("lng/f",0); - $couponId = input("couponId/d",0); - $account = AccountRepository::getInstance()->findById($accountId, [], function ($q) { + + $accountId = $this->request->user['user_id'] ?? 0; + $lat = input("lat/f",0); + $lng = input("lng/f",0); + $couponId = input("couponId/d",0); + $userTimeStamp = input("userTimeStamp/d",0); + $account = AccountRepository::getInstance()->findById($accountId, [], function ($q) { return $q->with(['business', 'parent']); }); $time = time(); @@ -357,10 +359,13 @@ class Coupon extends Base } - //签到距离 - Config::load('extra/wechat', 'wechat'); - $signDistance = config('wechat.signDistance') ?? 0; + Config::load('extra/wechat', 'wechat'); + $signDistance = config('wechat.signDistance') ?? 0; + $signTimeStamp = config('wechat.signTimeStamp') ?? 0; + $msectime = msectime();//毫秒时间戳 + + //签到距离 if($signDistance > 0 ){ $distance = get_distance($coupon->couponMain->lat,$coupon->couponMain->lng,$lat,$lng); if($distance > $signDistance){ @@ -373,6 +378,14 @@ class Coupon extends Base } } + //签到时间戳 + if($signTimeStamp > 0 ){ + if(abs($userTimeStamp - $msectime) > $signTimeStamp){ + //.abs($userTimeStamp - $msectime) + return $this->json(4001, "时间戳验证失败"); + } + } + $business = BusinessRepository::getInstance()->getModel()->with(["agency"])->where(["code"=>$coupon->couponMain->business_code])->lock(true)->find(); if(empty($business)){ diff --git a/app/controller/api/User.php b/app/controller/api/User.php index b2eeedc..652418e 100644 --- a/app/controller/api/User.php +++ b/app/controller/api/User.php @@ -88,7 +88,7 @@ class User extends Base 'create_time' => $nowDate, 'login_time' => $nowDate, 'type' => Account::type_consumer, // 默认为普通消费者 - 'nick_name' => $params['nick_name'] ?: generateDefaultNickName(), + 'nick_name' => filterEmoji($params['nick_name']) ?: generateDefaultNickName(), 'avatar_url' => $params['avatar_url'] ?: Account::DEFAULT_AVATAR, 'gender' => $params['gender'], 'real_name' => $params['real_name'], diff --git a/app/controller/manager/Bill.php b/app/controller/manager/Bill.php index 94dda25..481ec84 100644 --- a/app/controller/manager/Bill.php +++ b/app/controller/manager/Bill.php @@ -89,12 +89,26 @@ class Bill extends Base $size = $this->request->param('size/d', 30); $orders = ['a.id' => 'desc']; $list = $repo->deductionBillList($page, $size, $keyword, $startTime, $endTime, $orders); - $list['deduction_money_sum'] = BillRepository::getInstance()->getDeductionMoneySum($keyword,$startTime, $endTime); + $list['deduction_money_sum'] = BillRepository::getInstance() + ->getDeductionMoneySum($keyword,$startTime, $endTime);//总流水 + $list['deduction_money_sum_red_pack'] = BillRepository::getInstance() + ->getDeductionMoneySumRedPack($keyword,$startTime, $endTime);//消费者红包流水 + $list['deduction_money_sum_agency'] = BillRepository::getInstance() + ->getDeductionMoneySumAgency($keyword,$startTime, $endTime);//平台商收益 + $list['deduction_money_sum_taigu'] = BillRepository::getInstance() + ->getDeductionMoneySumTaigu($keyword,$startTime, $endTime);//太古收益 return $this->json(0, 'success', $list); } - $this->data["deduction_money_sum"] = BillRepository::getInstance()->getDeductionMoneySum(); + $this->data["deduction_money_sum"] = BillRepository::getInstance() + ->getDeductionMoneySum();//当前总流水 + $this->data["deduction_money_sum_red_pack"] = BillRepository::getInstance() + ->getDeductionMoneySumRedPack();//消费者红包流水 + $this->data["deduction_money_sum_agency"] = BillRepository::getInstance() + ->getDeductionMoneySumAgency();//平台商收益 + $this->data["deduction_money_sum_taigu"] = BillRepository::getInstance() + ->getDeductionMoneySumTaigu();//太古收益 $this->data["startTime"] = $startTime; $this->data["endTime"] = $endTime; diff --git a/app/repository/BillRepository.php b/app/repository/BillRepository.php index c2eec3a..34a6cb3 100644 --- a/app/repository/BillRepository.php +++ b/app/repository/BillRepository.php @@ -328,7 +328,7 @@ class BillRepository extends Repository ->join("coupon_bill d", "a.bill_id = d.id") ->join("account b", "d.user_code = b.user_code", "left") ->when(!empty($keyword), function ($q) use ($keyword) { - $q->where("c.business_name|f.business_name", "like", "%" . $keyword . "%"); + $q->where("e.name|c.business_name|f.business_name", "like", "%" . $keyword . "%"); }) ->when(!empty($start_time), function ($q) use ($start_time) { $q->whereTime("a.create_time", ">=", $start_time); @@ -338,5 +338,86 @@ class BillRepository extends Repository }) ->sum("a.money"); } + /** + * 总扣款流水-消费者红包 + * @param null $keyword + * @param null $start_time + * @param null $end_time + * @return float + */ + public function getDeductionMoneySumRedPack($keyword = null,$start_time = null, $end_time = null) + { + return Deduction::alias("a") + ->join("business c", "a.business_code = c.code") + ->join("business f", "f.code = c.agency_code", "left") + ->join("coupon_main e", "a.coupon_main_id = e.id") + ->join("coupon_bill d", "a.bill_id = d.id") + ->join("account b", "d.user_code = b.user_code", "left") + ->when(!empty($keyword), function ($q) use ($keyword) { + $q->where("e.name|c.business_name|f.business_name", "like", "%" . $keyword . "%"); + }) + ->when(!empty($start_time), function ($q) use ($start_time) { + $q->whereTime("a.create_time", ">=", $start_time); + }) + ->when(!empty($end_time), function ($q) use ($end_time) { + $q->whereTime("a.create_time", "<=", $end_time); + }) + ->sum("d.consumer_money"); + } + + /** + * 总扣款流水-平台商收益 + * @param null $keyword + * @param null $start_time + * @param null $end_time + * @return float + */ + public function getDeductionMoneySumAgency($keyword = null,$start_time = null, $end_time = null) + { + return Deduction::alias("a") + ->join("business c", "a.business_code = c.code") + ->join("business f", "f.code = c.agency_code", "left") + ->join("coupon_main e", "a.coupon_main_id = e.id") + ->join("coupon_bill d", "a.bill_id = d.id") + ->join("account b", "d.user_code = b.user_code", "left") + ->when(!empty($keyword), function ($q) use ($keyword) { + $q->where("e.name|c.business_name|f.business_name", "like", "%" . $keyword . "%"); + }) + ->when(!empty($start_time), function ($q) use ($start_time) { + $q->whereTime("a.create_time", ">=", $start_time); + }) + ->when(!empty($end_time), function ($q) use ($end_time) { + $q->whereTime("a.create_time", "<=", $end_time); + }) + ->sum("d.agency_money"); + } + + /** + * 总扣款流水-太古收益 + * @param null $keyword + * @param null $start_time + * @param null $end_time + * @return float + */ + public function getDeductionMoneySumTaigu($keyword = null,$start_time = null, $end_time = null) + { + return Deduction::alias("a") + ->join("business c", "a.business_code = c.code") + ->join("business f", "f.code = c.agency_code", "left") + ->join("coupon_main e", "a.coupon_main_id = e.id") + ->join("coupon_bill d", "a.bill_id = d.id") + ->join("account b", "d.user_code = b.user_code", "left") + ->when(!empty($keyword), function ($q) use ($keyword) { + $q->where("e.name|c.business_name|f.business_name", "like", "%" . $keyword . "%"); + }) + ->when(!empty($start_time), function ($q) use ($start_time) { + $q->whereTime("a.create_time", ">=", $start_time); + }) + ->when(!empty($end_time), function ($q) use ($end_time) { + $q->whereTime("a.create_time", "<=", $end_time); + }) + ->sum("d.admin_money"); + } + } \ No newline at end of file diff --git a/public/.htaccess b/public/.htaccess index 0228a66..856616a 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -6,6 +6,6 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^(.*)\.(gif|jpg|jpeg|png|swf|mp4)$ [NC] RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L] - #增加如下内容 + # SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0 \ No newline at end of file diff --git a/view/manager/bill/deduction.html b/view/manager/bill/deduction.html index 8a4b51a..b0af8f8 100644 --- a/view/manager/bill/deduction.html +++ b/view/manager/bill/deduction.html @@ -24,23 +24,63 @@
-
+
+ + + + +
-

总扣款流水:

- {$deduction_money_sum ?? 0} +
+

总扣款流水:

+ {$deduction_money_sum ?? 0} +
+
+

总消费者红包:

+ {$deduction_money_sum_red_pack ?? 0} +
+
+

总平台佣金:

+ {$deduction_money_sum_agency ?? 0} +
+
+

总太古佣金:

+ {$deduction_money_sum_taigu ?? 0} +
+
+ + + + +
-

当前扣款流水:

-   +
+

当前扣款流水:

+ {$deduction_money_sum ?? 0} +
+
+

当前消费者红包:

+ {$deduction_money_sum ?? 0} +
+
+

当前平台佣金:

+ {$deduction_money_sum ?? 0} +
+
+

当前太古佣金:

+ {$deduction_money_sum ?? 0} +
+
@@ -61,7 +101,7 @@
- +
diff --git a/view/manager/config/wechat.html b/view/manager/config/wechat.html index e9044d5..4c40d61 100644 --- a/view/manager/config/wechat.html +++ b/view/manager/config/wechat.html @@ -157,6 +157,13 @@
单位:米,设置签到时用户的位置和商家的地理位置最大不能超过多少米(0表示不限 不可为负数
+
+ +
+ +
+
单位:毫秒,设置签到时用户上传的时间戳只差不能大于多少毫秒(0表示不限 不可为负数 1000毫秒=1秒
+