2020-10-29 10:49:51 +08:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
* @Descripttion:
|
|
|
|
|
* @version:
|
|
|
|
|
* @Author: kangkang
|
|
|
|
|
* @Date: 2020-10-03 18:23:43
|
2020-11-26 11:38:29 +08:00
|
|
|
* @LastEditors: Please set LastEditors
|
2020-11-27 14:16:26 +08:00
|
|
|
* @LastEditTime: 2020-11-27 14:15:04
|
2020-10-29 10:49:51 +08:00
|
|
|
*/
|
|
|
|
|
$is_script = 1;
|
2020-11-27 10:46:39 +08:00
|
|
|
include_once __DIR__ . '/../index.php';
|
2020-10-29 10:49:51 +08:00
|
|
|
|
|
|
|
|
use app\api\model\Finance as FinanceModel;
|
|
|
|
|
use app\api\model\ProductOrder as ProductOrderModel;
|
2020-10-30 16:59:31 +08:00
|
|
|
use app\order\model\FinanceOperation as FinanceOperationModel;
|
2020-10-29 10:49:51 +08:00
|
|
|
use enum\order\ProductOrder as ProductOrderEnum;
|
|
|
|
|
use enum\product\Product as ProductEnum;
|
|
|
|
|
|
|
|
|
|
$finance = new FinanceModel;
|
2020-10-30 16:59:31 +08:00
|
|
|
$finance_operation = new FinanceOperationModel;
|
2020-10-29 10:49:51 +08:00
|
|
|
|
|
|
|
|
$product_order_model = new ProductOrderModel;
|
|
|
|
|
$product_order_enum = new ProductOrderEnum;
|
|
|
|
|
$product_enum = new ProductEnum;
|
|
|
|
|
|
|
|
|
|
$today = date('Y-m-d 00:00:00', time());
|
|
|
|
|
$yesterday = date('Y-m-d 00:00:00', (time() - 86400));
|
|
|
|
|
$where1 = ['UpdateTime' => ['<', $today]];
|
|
|
|
|
$where2 = ['UpdateTime' => ['>', $yesterday]];
|
|
|
|
|
|
|
|
|
|
$yesterday_data = $finance->getNewOne();
|
2020-10-30 16:59:31 +08:00
|
|
|
$buyis = $finance_operation->field('product,sum(money) money')->where(['finance_id' => ['IS', NULL]])->group(['product'])->fetchAll();
|
|
|
|
|
|
|
|
|
|
$buyi_data = [];
|
|
|
|
|
foreach ($buyis as $buyi) {
|
|
|
|
|
$buyi_data[$buyi['product']] = $buyi['money'];
|
|
|
|
|
}
|
2020-10-29 10:49:51 +08:00
|
|
|
|
|
|
|
|
$fields = "
|
|
|
|
|
ProductId, PackageName,
|
2020-10-30 16:59:31 +08:00
|
|
|
sum(
|
2020-10-29 10:49:51 +08:00
|
|
|
CASE OrderType
|
2020-10-30 16:59:31 +08:00
|
|
|
WHEN 1 THEN ConnectCount*AccountCount
|
|
|
|
|
WHEN 2 THEN ConnectCount*AccountCount
|
2020-10-29 10:49:51 +08:00
|
|
|
ELSE 0 END) 'NewBuyCount',
|
|
|
|
|
|
|
|
|
|
sum(
|
2020-10-30 16:59:31 +08:00
|
|
|
CASE OrderType
|
|
|
|
|
WHEN 3 THEN ConnectCount*AccountCount
|
|
|
|
|
WHEN 4 THEN ConnectCount*AccountCount
|
|
|
|
|
ELSE 0 END) 'AgainBuyCount'
|
2020-10-29 10:49:51 +08:00
|
|
|
|
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
$data = $product_order_model->field($fields)->where(array_merge($where2, ['OrderState' => ['in', $product_order_enum::$PayComplete]]))->where($where1)->group(['ProductId', 'PackageName'])->fetchAll();
|
|
|
|
|
|
2021-02-08 17:29:39 +08:00
|
|
|
$qiangzi = $xunlian = $jinqiao = $jinrui = $laoying = $xianfeng = $wujin = $xingxing = $wanmei = $wuxian = $jike = $tiantian = $gongxiang = $shihui = $xigua = $mogu = [];
|
2020-10-29 10:49:51 +08:00
|
|
|
|
|
|
|
|
foreach ($data as $product) {
|
|
|
|
|
switch ($product['ProductId']) {
|
|
|
|
|
case $product_enum::$qiangzi:
|
|
|
|
|
$qiangzi[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$xunlian:
|
|
|
|
|
$xunlian[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$jinqiao:
|
|
|
|
|
$jinqiao[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$jinrui:
|
|
|
|
|
$jinrui[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$laoying:
|
|
|
|
|
$laoying[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$xianfengpptp:
|
|
|
|
|
$xianfeng[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$wujin:
|
|
|
|
|
$wujin[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$xingxing:
|
|
|
|
|
$xingxing[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$wanmei:
|
|
|
|
|
$wanmei[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$wuxian:
|
|
|
|
|
$wuxian[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$jike:
|
|
|
|
|
$jike[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$tiantian:
|
|
|
|
|
$tiantian[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$gongxiang:
|
|
|
|
|
$gongxiang[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$shihui:
|
|
|
|
|
$shihui[] = $product;
|
|
|
|
|
break;
|
2021-02-08 17:29:39 +08:00
|
|
|
case $product_enum::$xigua:
|
|
|
|
|
$xigua[] = $product;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$mogu:
|
|
|
|
|
$mogu[] = $product;
|
|
|
|
|
break;
|
2020-10-29 10:49:51 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//强子讯连专门处理退款
|
2020-11-16 11:36:37 +08:00
|
|
|
$qx_where = array_merge($where2, ['ProductId' => ['in', $product_enum::$qx], 'OrderState' => $product_order_enum::$AutoRefundOver, 'ConnectCount' => 1, 'OrderType' => $product_order_enum::$Refund]);
|
2020-10-29 10:49:51 +08:00
|
|
|
$refund_qx_info = $product_order_model->field('ProductId,PackageName,RefundRestTime')->where($qx_where)->where($where1)->fetchAll();
|
|
|
|
|
$qiangzi_refund = [];
|
|
|
|
|
$xunlian_refund = [];
|
|
|
|
|
foreach ($refund_qx_info as $info) {
|
|
|
|
|
switch ($info['ProductId']) {
|
|
|
|
|
case $product_enum::$qiangzi:
|
|
|
|
|
$qiangzi_refund[] = $info;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$xunlian:
|
|
|
|
|
$xunlian_refund[] = $info;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-29 14:57:42 +08:00
|
|
|
|
2021-02-08 17:29:39 +08:00
|
|
|
//天天老鹰先锋的退款 金瑞 蘑菇
|
2020-11-16 11:36:37 +08:00
|
|
|
$tlx_where = array_merge($where2, ['ProductId' => ['in', $product_enum::$tlxj], 'OrderState' => $product_order_enum::$AutoRefundOver]);
|
2020-10-29 14:57:42 +08:00
|
|
|
$refund_tlx_info = $product_order_model->field('ProductId,PackageName,RefundRestTime,ConnectCount')->where($tlx_where)->where($where1)->fetchAll();
|
2020-10-29 10:49:51 +08:00
|
|
|
$tiantian_refund = [];
|
|
|
|
|
$laoying_refund = [];
|
|
|
|
|
$xianfeng_refund = [];
|
2020-10-29 14:57:42 +08:00
|
|
|
$jinrui_refund = [];
|
2021-02-08 17:29:39 +08:00
|
|
|
$mogu_refund = [];
|
2020-10-29 10:49:51 +08:00
|
|
|
foreach ($refund_tlx_info as $info) {
|
|
|
|
|
switch ($info['ProductId']) {
|
|
|
|
|
case $product_enum::$tiantian:
|
|
|
|
|
$tiantian_refund[] = $info;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$laoying:
|
|
|
|
|
$laoying_refund[] = $info;
|
|
|
|
|
break;
|
|
|
|
|
case $product_enum::$xianfengpptp:
|
|
|
|
|
$xianfeng_refund[] = $info;
|
|
|
|
|
break;
|
2020-10-29 14:57:42 +08:00
|
|
|
case $product_enum::$jinrui:
|
|
|
|
|
$jinrui_refund[] = $info;
|
|
|
|
|
break;
|
2021-02-08 17:29:39 +08:00
|
|
|
case $product_enum::$mogu:
|
|
|
|
|
$mogu_refund[] = $info;
|
|
|
|
|
break;
|
2020-10-29 10:49:51 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$list = [];
|
2020-10-30 16:59:31 +08:00
|
|
|
$list['xingxing'] = $yesterday_data['xingxing'] - no_jike($xingxing) + ($buyi_data['xingxing'] ?? 0);
|
|
|
|
|
$list['jike'] = $yesterday_data['jike'] - jike($jike) + ($buyi_data['jike'] ?? 0);
|
2021-02-08 17:29:39 +08:00
|
|
|
$list['xigua'] = $yesterday_data['xigua'] - xigua($xigua) + ($buyi_data['xigua'] ?? 0);
|
2020-10-30 16:59:31 +08:00
|
|
|
$list['wujin'] = $yesterday_data['wujin'] - no_jike($wujin) + ($buyi_data['wujin'] ?? 0);
|
|
|
|
|
$list['wanmei'] = $yesterday_data['wanmei'] - no_jike($wanmei) + ($buyi_data['wanmei'] ?? 0);
|
|
|
|
|
$list['jinqiao'] = $yesterday_data['jinqiao'] - no_jike($jinqiao) + ($buyi_data['jinqiao'] ?? 0);
|
|
|
|
|
$list['wuxian'] = $yesterday_data['wuxian'] - no_jike($wuxian) + ($buyi_data['wuxian'] ?? 0);
|
|
|
|
|
$list['shihui'] = $yesterday_data['shihui'] - no_jike($shihui) + ($buyi_data['shihui'] ?? 0);
|
|
|
|
|
$list['gongxiang'] = $yesterday_data['gongxiang'] - no_jike($gongxiang) + ($buyi_data['gongxiang'] ?? 0);
|
|
|
|
|
|
|
|
|
|
$qiangzi_rule_result = qx_rule($qiangzi, $qiangzi_refund, false);
|
2020-10-29 14:57:42 +08:00
|
|
|
$xunlian_rule_result = qx_rule($xunlian, $xunlian_refund);
|
2020-10-30 16:59:31 +08:00
|
|
|
$list['qiangzi'] = $yesterday_data['qiangzi'] - $qiangzi_rule_result['cost'] + $qiangzi_rule_result['refund'] + ($buyi_data['qiangzi'] ?? 0);
|
|
|
|
|
$list['xunlian'] = $yesterday_data['xunlian'] - $xunlian_rule_result['cost'] + $xunlian_rule_result['refund'] + ($buyi_data['xunlian'] ?? 0);
|
2020-10-29 14:57:42 +08:00
|
|
|
|
|
|
|
|
$tiantian_rule_result = tl_rule($tiantian, $tiantian_refund);
|
2020-11-04 15:40:58 +08:00
|
|
|
$laoying_rule_result = tl_rule($laoying, $laoying_refund, true);
|
2020-10-30 16:59:31 +08:00
|
|
|
$list['tiantian'] = $yesterday_data['tiantian'] - $tiantian_rule_result['cost'] + $tiantian_rule_result['refund'] + ($buyi_data['tiantian'] ?? 0);
|
|
|
|
|
$list['laoying'] = $yesterday_data['laoying'] - $laoying_rule_result['cost'] + $laoying_rule_result['refund'] + ($buyi_data['laoying'] ?? 0);
|
2020-10-29 14:57:42 +08:00
|
|
|
|
|
|
|
|
$xianfeng_rule_result = xianfeng($xianfeng, $xianfeng_refund);
|
2020-10-30 16:59:31 +08:00
|
|
|
$list['xianfeng'] = $yesterday_data['xianfeng'] - $xianfeng_rule_result['cost'] + $xianfeng_rule_result['refund'] + ($buyi_data['xianfeng'] ?? 0);
|
2020-10-29 14:57:42 +08:00
|
|
|
|
2021-02-08 17:29:39 +08:00
|
|
|
$mogu_rule_result = mogu($mogu, $mogu_refund);
|
|
|
|
|
$list['mogu'] = $yesterday_data['mogu'] - $mogu_rule_result['cost'] + $mogu_rule_result['refund'] + ($buyi_data['mogu'] ?? 0);
|
|
|
|
|
|
2020-10-30 16:59:31 +08:00
|
|
|
$jinrui_rule_result = jinrui($jinrui, $jinrui_refund);
|
2020-11-04 15:40:58 +08:00
|
|
|
$list['jinrui'] = $yesterday_data['jinrui'] - $jinrui_rule_result['cost'] + $jinrui_rule_result['refund'] + ($buyi_data['jinrui'] ?? 0);
|
2020-10-29 14:57:42 +08:00
|
|
|
|
|
|
|
|
$list['riqi'] = date('Y-m-d H:i:s');
|
2020-10-30 16:59:31 +08:00
|
|
|
|
|
|
|
|
$finance->add($list);
|
|
|
|
|
$finance_operation->where('finance_id IS NULL')->update(['finance_id' => ($yesterday_data['id'] + 1)]);
|
2020-10-29 10:49:51 +08:00
|
|
|
|
|
|
|
|
//极客每日消费规则
|
|
|
|
|
function jike($product)
|
|
|
|
|
{
|
|
|
|
|
$count = 0;
|
|
|
|
|
foreach ($product as $package) {
|
|
|
|
|
switch ($package['PackageName']) {
|
|
|
|
|
case '天卡':
|
2021-02-08 16:49:54 +08:00
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 6;
|
2020-10-29 10:49:51 +08:00
|
|
|
break;
|
|
|
|
|
case '周卡':
|
2021-02-08 16:49:54 +08:00
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 24;
|
2020-10-29 10:49:51 +08:00
|
|
|
break;
|
|
|
|
|
case '月卡':
|
2021-02-08 16:49:54 +08:00
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 60;
|
2020-10-29 10:49:51 +08:00
|
|
|
break;
|
|
|
|
|
case '季卡':
|
2021-02-08 16:53:13 +08:00
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 162;
|
2020-10-29 10:49:51 +08:00
|
|
|
break;
|
2021-01-15 15:40:32 +08:00
|
|
|
case '双月卡':
|
2021-02-08 16:53:13 +08:00
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 162;
|
2021-01-15 15:40:32 +08:00
|
|
|
break;
|
2020-10-29 10:49:51 +08:00
|
|
|
case '年卡':
|
2021-02-08 16:53:13 +08:00
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 600;
|
2020-10-29 10:49:51 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $count;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-08 17:29:39 +08:00
|
|
|
//西瓜每日消费规则
|
|
|
|
|
function xigua($product)
|
|
|
|
|
{
|
|
|
|
|
$count = 0;
|
|
|
|
|
foreach ($product as $package) {
|
|
|
|
|
switch ($package['PackageName']) {
|
|
|
|
|
case '天卡':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 5;
|
|
|
|
|
break;
|
|
|
|
|
case '周卡':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 20;
|
|
|
|
|
break;
|
|
|
|
|
case '月卡':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 60;
|
|
|
|
|
break;
|
|
|
|
|
case '季卡':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 155;
|
|
|
|
|
break;
|
|
|
|
|
case '双月卡(送一月)':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 155;
|
|
|
|
|
break;
|
|
|
|
|
case '年卡':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 550;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $count;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-29 10:49:51 +08:00
|
|
|
//星星,无尽,完美,金桥,无限,实惠,共享通用规则
|
|
|
|
|
function no_jike($product)
|
|
|
|
|
{
|
|
|
|
|
$count = 0;
|
|
|
|
|
foreach ($product as $package) {
|
|
|
|
|
switch ($package['PackageName']) {
|
|
|
|
|
case '天卡':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 4;
|
|
|
|
|
break;
|
|
|
|
|
case '周卡':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 28;
|
|
|
|
|
break;
|
|
|
|
|
case '月卡':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 100;
|
|
|
|
|
break;
|
2020-11-10 20:49:12 +08:00
|
|
|
case '双月卡(活动)':
|
2020-10-29 10:49:51 +08:00
|
|
|
case '季卡':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 300;
|
|
|
|
|
break;
|
|
|
|
|
case '年卡':
|
|
|
|
|
$count += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 1200;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//强子,讯连规则
|
2020-10-30 16:59:31 +08:00
|
|
|
function qx_rule($product, $refunds, $product_type = true)
|
2020-10-29 10:49:51 +08:00
|
|
|
{
|
2020-11-04 15:40:58 +08:00
|
|
|
$tian = 12;
|
2020-10-29 10:49:51 +08:00
|
|
|
$cost = 0;
|
|
|
|
|
foreach ($product as $package) {
|
|
|
|
|
switch ($package['PackageName']) {
|
|
|
|
|
case '天卡':
|
2020-10-30 16:59:31 +08:00
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * $tian;
|
2020-10-29 10:49:51 +08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '周卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 60;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '月卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 200;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '季卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 600;
|
|
|
|
|
|
2020-11-10 20:49:12 +08:00
|
|
|
break;
|
|
|
|
|
case '月卡(活动)':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 200;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '季卡(活动)':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 600;
|
|
|
|
|
|
2021-01-15 15:40:32 +08:00
|
|
|
break;
|
|
|
|
|
case '双月卡(活动)':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 400;
|
|
|
|
|
|
2020-10-29 10:49:51 +08:00
|
|
|
break;
|
|
|
|
|
case '年卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 2400;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$refund = 0;
|
2020-11-14 14:42:18 +08:00
|
|
|
foreach ($refunds as $info) {
|
|
|
|
|
switch ($info['PackageName']) {
|
|
|
|
|
case '天卡':
|
|
|
|
|
if ((86400 - handle_time($info['RefundRestTime'])) < 7200) {
|
|
|
|
|
$refund += $tian;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '周卡':
|
2020-11-17 15:55:00 +08:00
|
|
|
if ((86400*7 - handle_time($info['RefundRestTime'])) < 7200) {
|
2020-11-14 14:42:18 +08:00
|
|
|
$refund += 60;
|
2020-11-17 15:55:00 +08:00
|
|
|
} else {
|
2020-11-18 11:25:37 +08:00
|
|
|
$refund += round(60/7*intval(handle_time($info['RefundRestTime'])/86400));
|
2020-11-14 14:42:18 +08:00
|
|
|
}
|
|
|
|
|
break;
|
2021-01-15 15:40:32 +08:00
|
|
|
case '月卡(活动)':
|
2020-11-14 14:42:18 +08:00
|
|
|
case '月卡':
|
2020-11-17 15:55:00 +08:00
|
|
|
if ((86400*30 - handle_time($info['RefundRestTime'])) < 7200) {
|
2020-11-14 14:42:18 +08:00
|
|
|
$refund += 200;
|
2020-11-17 15:55:00 +08:00
|
|
|
} else {
|
2020-11-18 11:25:37 +08:00
|
|
|
$refund += round(200/30*intval(handle_time($info['RefundRestTime'])/86400));
|
2020-11-14 14:42:18 +08:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
// case '季卡(活动)':
|
|
|
|
|
case '季卡':
|
2020-11-17 15:55:00 +08:00
|
|
|
if ((86400*90 - handle_time($info['RefundRestTime'])) < 7200) {
|
2020-11-14 14:42:18 +08:00
|
|
|
$refund += 600;
|
2020-11-17 15:55:00 +08:00
|
|
|
} else {
|
2020-11-18 11:25:37 +08:00
|
|
|
$refund += round(600/90*intval(handle_time($info['RefundRestTime'])/86400));
|
2020-11-14 14:42:18 +08:00
|
|
|
}
|
|
|
|
|
break;
|
2021-01-15 15:40:32 +08:00
|
|
|
case '双月卡(活动)':
|
|
|
|
|
if ((86400*90 - handle_time($info['RefundRestTime'])) < 7200) {
|
|
|
|
|
$refund += 400;
|
|
|
|
|
} else {
|
|
|
|
|
$refund += round(600/90*intval(handle_time($info['RefundRestTime'])/86400));
|
|
|
|
|
}
|
|
|
|
|
break;
|
2020-11-14 14:42:18 +08:00
|
|
|
case '年卡':
|
2020-11-17 15:55:00 +08:00
|
|
|
if ((86400*365 - handle_time($info['RefundRestTime'])) < 7200) {
|
2020-11-14 14:42:18 +08:00
|
|
|
$refund += 2400;
|
2020-11-17 15:55:00 +08:00
|
|
|
} else {
|
2020-11-18 11:25:37 +08:00
|
|
|
$refund += round(2400/365*intval(handle_time($info['RefundRestTime'])/86400));
|
2020-11-14 14:42:18 +08:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-29 10:49:51 +08:00
|
|
|
$count['cost'] = $cost;
|
|
|
|
|
$count['refund'] = $refund;
|
|
|
|
|
return $count;
|
|
|
|
|
}
|
|
|
|
|
//天天,老鹰退款规则
|
2020-11-04 15:40:58 +08:00
|
|
|
function tl_rule($product, $refunds, $product_type = false)
|
2020-10-29 10:49:51 +08:00
|
|
|
{
|
2020-11-26 11:38:29 +08:00
|
|
|
$month = 30;
|
2020-10-29 10:49:51 +08:00
|
|
|
$cost = 0;
|
|
|
|
|
foreach ($product as $package) {
|
|
|
|
|
switch ($package['PackageName']) {
|
|
|
|
|
case '天卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 4;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '周卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 20;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '月卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 60;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '季卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 180;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '年卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 720;
|
|
|
|
|
|
2020-11-02 16:08:25 +08:00
|
|
|
break;
|
|
|
|
|
case '双月卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 120;
|
|
|
|
|
|
2020-10-29 10:49:51 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$refund = 0;
|
|
|
|
|
foreach ($refunds as $info) {
|
|
|
|
|
switch ($info['PackageName']) {
|
|
|
|
|
case '天卡':
|
2020-10-29 14:57:42 +08:00
|
|
|
if ((86400 - handle_time($info['RefundRestTime'])) < 1800) {
|
2020-10-29 10:49:51 +08:00
|
|
|
$refund += $info['ConnectCount'] * 4;
|
|
|
|
|
} else {
|
2020-11-02 16:08:25 +08:00
|
|
|
$refund += $info['ConnectCount'] * 4 - ceil((86400 - handle_time($info['RefundRestTime']))/86400) * $info['ConnectCount'] * 4;
|
2020-10-29 10:49:51 +08:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '周卡':
|
2020-10-29 14:57:42 +08:00
|
|
|
if ((86400 * 7 - handle_time($info['RefundRestTime'])) < 1800) {
|
2020-10-29 10:49:51 +08:00
|
|
|
$refund += $info['ConnectCount'] * 20;
|
|
|
|
|
} else {
|
2020-11-02 16:08:25 +08:00
|
|
|
$refund += $info['ConnectCount'] * 20 - ceil((86400 * 7 - handle_time($info['RefundRestTime']))/86400) * $info['ConnectCount'] * 4;
|
2020-10-29 10:49:51 +08:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '月卡':
|
2020-11-04 15:40:58 +08:00
|
|
|
if ((86400 * $month - handle_time($info['RefundRestTime'])) < 1800) {
|
2020-10-29 10:49:51 +08:00
|
|
|
$refund += $info['ConnectCount'] * 60;
|
|
|
|
|
} else {
|
2020-11-04 15:40:58 +08:00
|
|
|
$refund += $info['ConnectCount'] * 60 - ceil((86400 * $month - handle_time($info['RefundRestTime']))/86400) * $info['ConnectCount'] * 4;
|
2020-10-29 10:49:51 +08:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '季卡':
|
2020-10-29 14:57:42 +08:00
|
|
|
if ((86400 * 90 - handle_time($info['RefundRestTime'])) < 1800) {
|
2020-10-29 10:49:51 +08:00
|
|
|
$refund += $info['ConnectCount'] * 180;
|
|
|
|
|
} else {
|
2020-11-02 16:08:25 +08:00
|
|
|
$refund += $info['ConnectCount'] * 180 - ceil((86400 * 90 - handle_time($info['RefundRestTime']))/86400) * $info['ConnectCount'] * 4;
|
2020-10-29 10:49:51 +08:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '年卡':
|
2020-10-29 14:57:42 +08:00
|
|
|
if ((86400 * 365 - handle_time($info['RefundRestTime'])) < 1800) {
|
2020-10-29 10:49:51 +08:00
|
|
|
$refund += $info['ConnectCount'] * 7200;
|
|
|
|
|
} else {
|
2020-11-02 16:08:25 +08:00
|
|
|
$refund += $info['ConnectCount'] * 720 - ceil((86400 * 365 - handle_time($info['RefundRestTime']))/86400) * $info['ConnectCount'] * 4;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '双月卡':
|
|
|
|
|
if ((86400 * 90 - handle_time($info['RefundRestTime'])) < 1800) {
|
|
|
|
|
$refund += $info['ConnectCount'] * 120;
|
|
|
|
|
} else {
|
2020-11-27 14:16:26 +08:00
|
|
|
$refund += $info['ConnectCount'] * 120 - ceil((86400 * 90 - handle_time($info['RefundRestTime']))/86400) * $info['ConnectCount'] * 4;
|
2020-10-29 10:49:51 +08:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$count['cost'] = $cost;
|
|
|
|
|
$count['refund'] = $refund;
|
|
|
|
|
return $count;
|
|
|
|
|
}
|
|
|
|
|
//先锋规则
|
2020-10-29 14:57:42 +08:00
|
|
|
function xianfeng($product, $refunds)
|
2020-10-29 10:49:51 +08:00
|
|
|
{
|
|
|
|
|
$cost = 0;
|
|
|
|
|
foreach ($product as $package) {
|
|
|
|
|
switch ($package['PackageName']) {
|
|
|
|
|
case '天卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 3;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '周卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 18;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '月卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 60;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '季卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 168;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '年卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 636;
|
|
|
|
|
|
2020-11-12 14:25:48 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '双月卡(活动)':
|
2021-01-15 15:40:32 +08:00
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 108;
|
2020-11-12 14:25:48 +08:00
|
|
|
|
2020-10-29 10:49:51 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$refund = 0;
|
2020-11-14 14:42:18 +08:00
|
|
|
// foreach ($refunds as $info) {
|
|
|
|
|
// switch ($info['PackageName']) {
|
|
|
|
|
// case '天卡':
|
|
|
|
|
// if ((86400 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
// $refund += $info['ConnectCount'] * 3;
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
// case '周卡':
|
|
|
|
|
// if ((86400 * 7 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
// $refund += $info['ConnectCount'] * 18;
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
// case '月卡':
|
|
|
|
|
// if ((86400 * 30 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
// $refund += $info['ConnectCount'] * 60;
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
// case '季卡':
|
|
|
|
|
// if ((86400 * 90 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
// $refund += $info['ConnectCount'] * 168;
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
// case '双月卡(活动)':
|
|
|
|
|
// if ((86400 * 90 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
// $refund += $info['ConnectCount'] * 120;
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
// case '年卡':
|
|
|
|
|
// if ((86400 * 365 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
// $refund += $info['ConnectCount'] * 636;
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2020-10-29 10:49:51 +08:00
|
|
|
$count['cost'] = $cost;
|
|
|
|
|
$count['refund'] = $refund;
|
|
|
|
|
return $count;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-08 17:29:39 +08:00
|
|
|
//蘑菇规则
|
|
|
|
|
function mogu($product, $refunds)
|
|
|
|
|
{
|
|
|
|
|
$cost = 0;
|
|
|
|
|
foreach ($product as $package) {
|
|
|
|
|
switch ($package['PackageName']) {
|
|
|
|
|
case '天卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 3;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '周卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 15;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '月卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 40;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '月卡(活动)':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 40;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '季卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 120;
|
|
|
|
|
|
2021-02-21 18:12:56 +08:00
|
|
|
break;
|
|
|
|
|
case '季卡(活动)':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 120;
|
|
|
|
|
|
2021-02-08 17:29:39 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '双月卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 80;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$refund = 0;
|
|
|
|
|
foreach ($refunds as $info) {
|
|
|
|
|
switch ($info['PackageName']) {
|
|
|
|
|
case '天卡':
|
|
|
|
|
if ((86400 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
$refund += $info['ConnectCount'] * 3;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '周卡':
|
|
|
|
|
if ((86400 * 7 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
$refund += $info['ConnectCount'] * 15;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '月卡':
|
|
|
|
|
if ((86400 * 30 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
$refund += $info['ConnectCount'] * 40;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '月卡(活动)':
|
|
|
|
|
if ((86400 * 30 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
$refund += $info['ConnectCount'] * 40;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '季卡':
|
|
|
|
|
if ((86400 * 90 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
$refund += $info['ConnectCount'] * 120;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2021-02-21 18:12:56 +08:00
|
|
|
case '季卡(活动)':
|
|
|
|
|
if ((86400 * 90 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
$refund += $info['ConnectCount'] * 120;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2021-02-08 17:29:39 +08:00
|
|
|
case '双月卡':
|
|
|
|
|
if ((86400 * 90 - handle_time($info['RefundRestTime'])) < 10800) {
|
|
|
|
|
$refund += $info['ConnectCount'] * 80;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$count['cost'] = $cost;
|
|
|
|
|
$count['refund'] = $refund;
|
|
|
|
|
return $count;
|
|
|
|
|
}
|
2020-10-29 14:57:42 +08:00
|
|
|
//金瑞规则
|
|
|
|
|
function jinrui($product, $refunds)
|
|
|
|
|
{
|
|
|
|
|
$cost = 0;
|
|
|
|
|
foreach ($product as $package) {
|
|
|
|
|
switch ($package['PackageName']) {
|
|
|
|
|
case '天卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 3;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '周卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 20;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '月卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 60;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '季卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 180;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '年卡':
|
|
|
|
|
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 720;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$refund = 0;
|
|
|
|
|
foreach ($refunds as $info) {
|
2020-11-04 15:40:58 +08:00
|
|
|
$refund += intval(handle_time($info['RefundRestTime']) / 86400) * 2 * $info['ConnectCount'];
|
2020-10-29 14:57:42 +08:00
|
|
|
}
|
|
|
|
|
$count['cost'] = $cost;
|
|
|
|
|
$count['refund'] = $refund;
|
|
|
|
|
return $count;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-29 10:49:51 +08:00
|
|
|
//将剩余时间进行处理切割转换为秒
|
|
|
|
|
function handle_time($rest_time)
|
|
|
|
|
{
|
|
|
|
|
$time1 = explode('天', $rest_time);
|
|
|
|
|
$time2 = explode('时', $time1[1]);
|
|
|
|
|
$time3 = explode('分', $time2[1]);
|
2020-10-29 14:57:42 +08:00
|
|
|
|
|
|
|
|
$time = $time1[0] * 86400 + $time2[0] * 3600 + $time3[0] * 60;
|
2020-10-29 10:49:51 +08:00
|
|
|
return $time;
|
|
|
|
|
}
|