西瓜蘑菇元后台财务员

This commit is contained in:
“wanyongkang”
2021-02-08 17:29:39 +08:00
parent ef090243d7
commit f0245a5f19
2 changed files with 131 additions and 12 deletions

View File

@@ -54,7 +54,7 @@ ProductId, PackageName,
$data = $product_order_model->field($fields)->where(array_merge($where2, ['OrderState' => ['in', $product_order_enum::$PayComplete]]))->where($where1)->group(['ProductId', 'PackageName'])->fetchAll();
$qiangzi = $xunlian = $jinqiao = $jinrui = $laoying = $xianfeng = $wujin = $xingxing = $wanmei = $wuxian = $jike = $tiantian = $gongxiang = $shihui = [];
$qiangzi = $xunlian = $jinqiao = $jinrui = $laoying = $xianfeng = $wujin = $xingxing = $wanmei = $wuxian = $jike = $tiantian = $gongxiang = $shihui = $xigua = $mogu = [];
foreach ($data as $product) {
switch ($product['ProductId']) {
@@ -100,6 +100,12 @@ foreach ($data as $product) {
case $product_enum::$shihui:
$shihui[] = $product;
break;
case $product_enum::$xigua:
$xigua[] = $product;
break;
case $product_enum::$mogu:
$mogu[] = $product;
break;
}
}
@@ -119,13 +125,14 @@ foreach ($refund_qx_info as $info) {
}
}
//天天老鹰先锋的退款
//天天老鹰先锋的退款 金瑞 蘑菇
$tlx_where = array_merge($where2, ['ProductId' => ['in', $product_enum::$tlxj], 'OrderState' => $product_order_enum::$AutoRefundOver]);
$refund_tlx_info = $product_order_model->field('ProductId,PackageName,RefundRestTime,ConnectCount')->where($tlx_where)->where($where1)->fetchAll();
$tiantian_refund = [];
$laoying_refund = [];
$xianfeng_refund = [];
$jinrui_refund = [];
$mogu_refund = [];
foreach ($refund_tlx_info as $info) {
switch ($info['ProductId']) {
case $product_enum::$tiantian:
@@ -140,11 +147,15 @@ foreach ($refund_tlx_info as $info) {
case $product_enum::$jinrui:
$jinrui_refund[] = $info;
break;
case $product_enum::$mogu:
$mogu_refund[] = $info;
break;
}
}
$list = [];
$list['xingxing'] = $yesterday_data['xingxing'] - no_jike($xingxing) + ($buyi_data['xingxing'] ?? 0);
$list['jike'] = $yesterday_data['jike'] - jike($jike) + ($buyi_data['jike'] ?? 0);
$list['xigua'] = $yesterday_data['xigua'] - xigua($xigua) + ($buyi_data['xigua'] ?? 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);
@@ -165,6 +176,9 @@ $list['laoying'] = $yesterday_data['laoying'] - $laoying_rule_result['cost'] + $
$xianfeng_rule_result = xianfeng($xianfeng, $xianfeng_refund);
$list['xianfeng'] = $yesterday_data['xianfeng'] - $xianfeng_rule_result['cost'] + $xianfeng_rule_result['refund'] + ($buyi_data['xianfeng'] ?? 0);
$mogu_rule_result = mogu($mogu, $mogu_refund);
$list['mogu'] = $yesterday_data['mogu'] - $mogu_rule_result['cost'] + $mogu_rule_result['refund'] + ($buyi_data['mogu'] ?? 0);
$jinrui_rule_result = jinrui($jinrui, $jinrui_refund);
$list['jinrui'] = $yesterday_data['jinrui'] - $jinrui_rule_result['cost'] + $jinrui_rule_result['refund'] + ($buyi_data['jinrui'] ?? 0);
@@ -202,6 +216,35 @@ function jike($product)
return $count;
}
//西瓜每日消费规则
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;
}
//星星,无尽,完美,金桥,无限,实惠,共享通用规则
function no_jike($product)
{
@@ -478,6 +521,78 @@ function xianfeng($product, $refunds)
return $count;
}
//蘑菇规则
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;
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;
case '双月卡':
if ((86400 * 90 - handle_time($info['RefundRestTime'])) < 10800) {
$refund += $info['ConnectCount'] * 80;
}
break;
}
}
$count['cost'] = $cost;
$count['refund'] = $refund;
return $count;
}
//金瑞规则
function jinrui($product, $refunds)
{