元后台
This commit is contained in:
@@ -5,17 +5,19 @@
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-03 18:23:43
|
||||
* @LastEditors: kangkang
|
||||
* @LastEditTime: 2020-10-29 12:08:30
|
||||
* @LastEditTime: 2020-10-30 15:52:27
|
||||
*/
|
||||
$is_script = 1;
|
||||
include __DIR__ . '/../index.php';
|
||||
|
||||
use app\api\model\Finance as FinanceModel;
|
||||
use app\api\model\ProductOrder as ProductOrderModel;
|
||||
use app\order\model\FinanceOperation as FinanceOperationModel;
|
||||
use enum\order\ProductOrder as ProductOrderEnum;
|
||||
use enum\product\Product as ProductEnum;
|
||||
|
||||
$finance = new FinanceModel;
|
||||
$finance_operation = new FinanceOperationModel;
|
||||
|
||||
$product_order_model = new ProductOrderModel;
|
||||
$product_order_enum = new ProductOrderEnum;
|
||||
@@ -27,20 +29,26 @@ $where1 = ['UpdateTime' => ['<', $today]];
|
||||
$where2 = ['UpdateTime' => ['>', $yesterday]];
|
||||
|
||||
$yesterday_data = $finance->getNewOne();
|
||||
$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'];
|
||||
}
|
||||
|
||||
$fields = "
|
||||
ProductId, PackageName,
|
||||
sum(
|
||||
sum(
|
||||
CASE OrderType
|
||||
WHEN 1 THEN ConnectCount
|
||||
WHEN 2 THEN ConnectCount
|
||||
WHEN 1 THEN ConnectCount*AccountCount
|
||||
WHEN 2 THEN ConnectCount*AccountCount
|
||||
ELSE 0 END) 'NewBuyCount',
|
||||
|
||||
sum(
|
||||
CASE OrderType
|
||||
WHEN 3 THEN ConnectCount
|
||||
WHEN 4 THEN ConnectCount
|
||||
ELSE 0 END) 'AgainBuyCount'
|
||||
CASE OrderType
|
||||
WHEN 3 THEN ConnectCount*AccountCount
|
||||
WHEN 4 THEN ConnectCount*AccountCount
|
||||
ELSE 0 END) 'AgainBuyCount'
|
||||
|
||||
";
|
||||
|
||||
@@ -135,33 +143,35 @@ foreach ($refund_tlx_info as $info) {
|
||||
}
|
||||
}
|
||||
$list = [];
|
||||
$list['xingxing'] = $yesterday_data['xingxing'] - no_jike($xingxing);
|
||||
$list['jike'] = $yesterday_data['jike'] - jike($jike);
|
||||
$list['wujin'] = $yesterday_data['wujin'] - no_jike($wujin);
|
||||
$list['wanmei'] = $yesterday_data['wanmei'] - no_jike($wanmei);
|
||||
$list['jinqiao'] = $yesterday_data['jinqiao'] - no_jike($jinqiao);
|
||||
$list['wuxian'] = $yesterday_data['wuxian'] - no_jike($wuxian);
|
||||
$list['shihui'] = $yesterday_data['shihui'] - no_jike($shihui);
|
||||
$list['gongxiang'] = $yesterday_data['gongxiang'] - no_jike($gongxiang);
|
||||
$list['xingxing'] = $yesterday_data['xingxing'] - no_jike($xingxing) + ($buyi_data['xingxing'] ?? 0);
|
||||
$list['jike'] = $yesterday_data['jike'] - jike($jike) + ($buyi_data['jike'] ?? 0);
|
||||
$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);
|
||||
$qiangzi_rule_result = qx_rule($qiangzi, $qiangzi_refund, false);
|
||||
$xunlian_rule_result = qx_rule($xunlian, $xunlian_refund);
|
||||
$list['qiangzi'] = $yesterday_data['qiangzi'] - $qiangzi_rule_result['cost'] + $qiangzi_rule_result['refund'];
|
||||
$list['xunlian'] = $yesterday_data['xunlian'] - $xunlian_rule_result['cost'] + $xunlian_rule_result['refund'];
|
||||
$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);
|
||||
|
||||
$tiantian_rule_result = tl_rule($tiantian, $tiantian_refund);
|
||||
$laoying_rule_result = tl_rule($laoying, $laoying_refund);
|
||||
$list['tiantian'] = $yesterday_data['tiantian'] - $tiantian_rule_result['cost'] + $tiantian_rule_result['refund'];
|
||||
$list['laoying'] = $yesterday_data['laoying'] - $laoying_rule_result['cost'] + $laoying_rule_result['refund'];
|
||||
$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);
|
||||
|
||||
$xianfeng_rule_result = xianfeng($xianfeng, $xianfeng_refund);
|
||||
$list['xianfeng'] = $yesterday_data['xianfeng'] - $xianfeng_rule_result['cost'] + $xianfeng_rule_result['refund'];
|
||||
$list['xianfeng'] = $yesterday_data['xianfeng'] - $xianfeng_rule_result['cost'] + $xianfeng_rule_result['refund'] + ($buyi_data['xianfeng'] ?? 0);
|
||||
|
||||
$jinrui_rule_result = xianfeng($jinrui, $jinrui_refund);
|
||||
$list['jinrui'] = $yesterday_data['jinrui'] - $jinrui_rule_result['cost'] + $xianfeng_rule_result['refund'];
|
||||
$jinrui_rule_result = jinrui($jinrui, $jinrui_refund);
|
||||
$list['jinrui'] = $yesterday_data['jinrui'] - $jinrui_rule_result['cost'] + $xianfeng_rule_result['refund'] + ($buyi_data['jinrui'] ?? 0);
|
||||
|
||||
$list['riqi'] = date('Y-m-d H:i:s');
|
||||
dump($finance->add($list));
|
||||
|
||||
$finance->add($list);
|
||||
$finance_operation->where('finance_id IS NULL')->update(['finance_id' => ($yesterday_data['id'] + 1)]);
|
||||
|
||||
//极客每日消费规则
|
||||
function jike($product)
|
||||
@@ -216,13 +226,14 @@ function no_jike($product)
|
||||
}
|
||||
|
||||
//强子,讯连规则
|
||||
function qx_rule($product, $refunds)
|
||||
function qx_rule($product, $refunds, $product_type = true)
|
||||
{
|
||||
$tian = $product_type ? 10 : 12;
|
||||
$cost = 0;
|
||||
foreach ($product as $package) {
|
||||
switch ($package['PackageName']) {
|
||||
case '天卡':
|
||||
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * 10;
|
||||
$cost += ($package['NewBuyCount'] + $package['AgainBuyCount']) * $tian;
|
||||
|
||||
break;
|
||||
case '周卡':
|
||||
@@ -247,19 +258,29 @@ function qx_rule($product, $refunds)
|
||||
foreach ($refunds as $info) {
|
||||
switch ($info['PackageName']) {
|
||||
case '天卡':
|
||||
$refund += handle_time($info['RefundRestTime']) / 86400 * 10;
|
||||
if ((86400 - handle_time($info['RefundRestTime'])) < 7200) {
|
||||
$refund += $tian;
|
||||
}
|
||||
break;
|
||||
case '周卡':
|
||||
$refund += handle_time($info['RefundRestTime']) / 86400 * (60 / 7);
|
||||
if ((86400 - handle_time($info['RefundRestTime'])) < 7200) {
|
||||
$refund += 60;
|
||||
}
|
||||
break;
|
||||
case '月卡':
|
||||
$refund += handle_time($info['RefundRestTime']) / 86400 * (200 / 30);
|
||||
if ((86400 - handle_time($info['RefundRestTime'])) < 7200) {
|
||||
$refund += 200;
|
||||
}
|
||||
break;
|
||||
case '季卡':
|
||||
$refund += handle_time($info['RefundRestTime']) / 86400 * (600 / 90);
|
||||
if ((86400 - handle_time($info['RefundRestTime'])) < 7200) {
|
||||
$refund += 600;
|
||||
}
|
||||
break;
|
||||
case '年卡':
|
||||
$refund += handle_time($info['RefundRestTime']) / 86400 * (2400 / 365);
|
||||
if ((86400 - handle_time($info['RefundRestTime'])) < 7200) {
|
||||
$refund += 2400;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -432,7 +453,7 @@ function jinrui($product, $refunds)
|
||||
}
|
||||
$refund = 0;
|
||||
foreach ($refunds as $info) {
|
||||
$refund += handle_time($info['RefundRestTime'])/86400*2*$info['ConnectCount'];
|
||||
$refund += handle_time($info['RefundRestTime']) / 86400 * 2 * $info['ConnectCount'];
|
||||
}
|
||||
$count['cost'] = $cost;
|
||||
$count['refund'] = $refund;
|
||||
|
||||
Reference in New Issue
Block a user