平台币

master
sunke 5 years ago
parent 21bf9744fb
commit 7194cd49ae

@ -9,6 +9,7 @@ use Base\Tool\Printer;
use Base\Tool\TaskClient; use Base\Tool\TaskClient;
use Base\Service\PromoteService; use Base\Service\PromoteService;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use think\Db;
class ConsoleController extends Think { class ConsoleController extends Think {
@ -366,4 +367,66 @@ class ConsoleController extends Think {
} }
} }
} }
public function coinRecords() {
$deposit = M('deposit', 'tab_')->field('pay_order_number,user_id,user_account,pay_status,pay_way,pay_amount,create_time as pay_time,2 as record_type')->where(['pay_status'=>1])->select(false);
// $agent = M('agent', 'tab_')->field('pay_order_number,user_id,user_account,pay_status,pay_way,real_amount as pay_amount,create_time as pay_time,3 as record_type')->where(['pay_status'=>1])->select(false);
// $spend = M('spend', 'tab_')->field('pay_order_number,user_id,user_account,pay_status,pay_way,pay_amount,pay_time,1 as record_type')->where(['pay_status' => 1,'pay_way'=>0])->select(false);
$query = M('spend', 'tab_')->field('pay_order_number,user_id,user_account,pay_status,pay_way,pay_amount,pay_time,record_type')->where(['pay_status' => 1,'pay_way'=>0])->union($deposit,'pay_time')->select(false);
$model = new \Think\Model();
$datas = $model->table('(' . $query . ') a ')->order('pay_time asc')->select();
foreach ($datas as $key => $data) {
if(empty($data['pay_order_number'])) {
$order = 0;
}else {
$order = $data['pay_order_number'];
}
$data['order_number'] = $order;
$data['user_id'] = $data['user_id'];
$data['value'] = $data['pay_amount'];
$data['before_value'] = 0;
$data['after_value'] = 0;
$data['create_time'] = $data['pay_time'];
if ($data['record_type'] == 1) {
$data['type'] = 'spend';
$data['remark'] ='历史消费spend';
$data['pay_type'] = 1;
$data['value'] = -$data['pay_amount'];
}
if ($data['record_type'] == 2) {
$data['type'] = 'deposit';
$data['remark'] ='历史充值deposit';
$data['pay_type'] = 2;
$data['value'] = $data['pay_amount'];
}
M('value_detail_log', 'tab_')->add($data);
}
echo "success";
}
public function updateValue() {
//$map['type'] = ['neq', '2'];
$valueDetails = M('value_detail_log', 'tab_')->field('user_id')->where($map)->group('user_id')->select();
foreach ($valueDetails as $key => $valueDetail) {
$user_id = $valueDetail['user_id'];
$map['user_id'] = $user_id;
$userValues = M('value_detail_log', 'tab_')->where($map)->select();
$currentValue = 0;
foreach ($userValues as $userValue) {
$id = $userValue['id'];
$userValue['before_value'] = $currentValue;
$userValue['after_value'] = $currentValue + $userValue['value'];
M('value_detail_log', 'tab_')->where(['id' => $id])->save($userValue);
$after_update = M('value_detail_log', 'tab_')->where(['id'=>$id])->find();
$currentValue = $after_update['after_value'];
}
}
}
} }

@ -2631,10 +2631,18 @@ class ExportController extends Controller
$map['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); $map['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399));
} }
$total = 0; $total = 0;
$t = M('value_detail_log', 'tab_')->where($map)->sum('value');
// $valueDetailDatas = M('value_detail_log', 'tab_')->field('order_number, user_id, before_value, value, after_value, create_time, type, remark, pay_type') // $valueDetailDatas = M('value_detail_log', 'tab_')->field('order_number, user_id, before_value, value, after_value, create_time, type, remark, pay_type')
// ->where($map) // ->where($map)
// ->page($page,$row) // ->page($page,$row)
// ->select(); // ->select();
$first = M('value_detail_log', 'tab_')->field('after_value')->where($map)->limit(1)->order('create_time')->select();
if (!empty($first[0]['after_value'])) {
$first = number_format($first[0]['after_value'],2,'.','');
}else {
$first = '0.00';
}
$csvFileName = '平台币明细'.'.csv'; $csvFileName = '平台币明细'.'.csv';
//设置好告诉浏览器要下载excel文件的headers //设置好告诉浏览器要下载excel文件的headers
@ -2665,7 +2673,7 @@ class ExportController extends Controller
$vlaueDetailData['create_time'] = date('Y-m-d H:i:s', $valueDetailData['create_time']); $vlaueDetailData['create_time'] = date('Y-m-d H:i:s', $valueDetailData['create_time']);
if($valueDetailData['pay_type'] == 1) { if($valueDetailData['pay_type'] == 1) {
$vlaueDetailData['type'] = "消费"; $vlaueDetailData['type'] = "消费";
$total -= $valueDetailData['value']; $total += $valueDetailData['value'];
} }
if($valueDetailData['pay_type'] == 2) { if($valueDetailData['pay_type'] == 2) {
$vlaueDetailData['type'] = "充值"; $vlaueDetailData['type'] = "充值";
@ -2686,16 +2694,11 @@ class ExportController extends Controller
ob_flush(); ob_flush();
flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
} }
if ($total >= 0) {
$fuhao = '+';
}else {
$fuhao = '-';
}
$alldatas['order_number'] = "汇总(检索时间内所有数据的统计)"; $alldatas['order_number'] = "汇总(检索时间内所有数据的统计)";
$alldatas['create_time'] = ""; $alldatas['create_time'] = "";
$alldatas['type'] = $fuhao; $alldatas['type'] = "";
$alldatas['value'] = $total; $alldatas['value'] = $t;
$alldatas['after_value'] = ""; $alldatas['after_value'] = $first;
mb_convert_variables('GBK', 'UTF-8', $alldatas); mb_convert_variables('GBK', 'UTF-8', $alldatas);
fputcsv($fp, $alldatas); fputcsv($fp, $alldatas);

@ -1255,16 +1255,17 @@ class FinanceController extends ThinkController
$map1['pay_type'] = 1; $map1['pay_type'] = 1;
$totalSpend = M('value_detail_log', 'tab_')->where($map1)->sum('value'); $totalSpend = M('value_detail_log', 'tab_')->where($map1)->sum('value');
$totalSpend = empty($totalSpend) ? '0.00' : $totalSpend; $totalSpend = empty($totalSpend) ? '0.00' : $totalSpend;
$totalSpend = number_format(abs($totalSpend),2,'.','');
$map2['create_time'] = $map['create_time']; $map2['create_time'] = $map['create_time'];
$map2['pay_type'] = 2; $map2['pay_type'] = 2;
$deposit = M('value_detail_log', 'tab_')->where($map2)->sum('value'); $deposit = M('value_detail_log', 'tab_')->where($map2)->sum('value');
$deposit= empty($deposit) ? '0.00' : $deposit; $deposit= empty($deposit) ? '0.00' : number_format($deposit,2,'.','');
$map3['create_time'] = $map['create_time']; $map3['create_time'] = $map['create_time'];
$map3['pay_type'] = 3; $map3['pay_type'] = 3;
$allpromoteCoin = M('value_detail_log', 'tab_')->where($map3)->sum('value'); $allpromoteCoin = M('value_detail_log', 'tab_')->where($map3)->sum('value');
$allpromoteCoin = empty($promoteCoin) ? '0.00' : $promoteCoin; $allpromoteCoin = empty($promoteCoin) ? '0.00' : number_format($allpromoteCoin,2,'.','');
$map4['create_time'] = $map['create_time']; $map4['create_time'] = $map['create_time'];
$banlace = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map4)->group('user_id')->select(); $banlace = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map4)->group('user_id')->select();
@ -1272,7 +1273,7 @@ class FinanceController extends ThinkController
foreach($banlace as $k222 => $vvv) { foreach($banlace as $k222 => $vvv) {
$banlaceTotal += $vvv['after_value']; $banlaceTotal += $vvv['after_value'];
} }
$banlaceTotal = number_format($banlaceTotal,2,'.','');
$map['user_id'] = ['in', $ids]; $map['user_id'] = ['in', $ids];
$newValueByTimeDatas = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map)->group('user_id')->select(); $newValueByTimeDatas = M('value_detail_log', 'tab_')->field('user_id, after_value')->where($map)->group('user_id')->select();
// var_dump($newValueByTimeDatas);die(); // var_dump($newValueByTimeDatas);die();
@ -1309,7 +1310,7 @@ class FinanceController extends ThinkController
$this->display(); $this->display();
} }
public function definiteDetaile() { public function definiteDetaile($p=1) {
$page = intval($p); $page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据 $page = $page ? $page : 1; //默认显示第一页数据
$row=10; $row=10;
@ -1328,10 +1329,12 @@ class FinanceController extends ThinkController
} elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) {
$map['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399)); $map['create_time'] = array('elt', (strtotime($_REQUEST['timeend']) + 86399));
} }
$total = 0; $total = '0.00';
$t = M('value_detail_log', 'tab_')->where($map)->sum('value');
$valueDetailDatas = M('value_detail_log', 'tab_')->field('order_number, user_id, before_value, value, after_value, create_time, type, remark, pay_type') $valueDetailDatas = M('value_detail_log', 'tab_')->field('order_number, user_id, before_value, value, after_value, create_time, type, remark, pay_type')
->where($map) ->where($map)
->page($page,$row) ->page($page,$row)
->order('create_time desc')
->select(); ->select();
$counts = M('value_detail_log', 'tab_')->field('id') $counts = M('value_detail_log', 'tab_')->field('id')
->where($map) ->where($map)
@ -1344,7 +1347,7 @@ class FinanceController extends ThinkController
$vlaueDetailDatas[$key]['pay_type'] = $valueDetailData['pay_type']; $vlaueDetailDatas[$key]['pay_type'] = $valueDetailData['pay_type'];
if($valueDetailData['pay_type'] == 1) { if($valueDetailData['pay_type'] == 1) {
$vlaueDetailDatas[$key]['type'] = "消费"; $vlaueDetailDatas[$key]['type'] = "消费";
$total -= $valueDetailData['value']; $total += $valueDetailData['value'];
} }
if($valueDetailData['pay_type'] == 2) { if($valueDetailData['pay_type'] == 2) {
$vlaueDetailDatas[$key]['type'] = "充值"; $vlaueDetailDatas[$key]['type'] = "充值";
@ -1355,17 +1358,24 @@ class FinanceController extends ThinkController
$total += $valueDetailData['value']; $total += $valueDetailData['value'];
} }
} }
if($total >= 0 ) { if (!empty($vlaueDetailDatas[0]['after_value'])) {
$fuhao = '+'; $totalAfterValue = number_format($vlaueDetailDatas[0]['after_value'],2,'.','');
}else { }else {
$fuhao = '-'; $totalAfterValue = '0.00';
} }
$total = number_format($total,2,'.','');
// if($total >= 0 ) {
// $fuhao = '+';
// }else {
// $fuhao = '-';
// }
$page = set_pagination($counts,$row); $page = set_pagination($counts,$row);
if($page) {$this->assign('_page', $page);} if($page) {$this->assign('_page', $page);}
$this->assign('fuhao', $fuhao); $this->assign('fuhao', $fuhao);
$this->assign('total', $total); $this->assign('total', $t);
$this->assign('listdata', $vlaueDetailDatas); $this->assign('listdata', $vlaueDetailDatas);
$this->assign('totalAfterValue', $totalAfterValue);
$this->display(); $this->display();
} }

@ -149,7 +149,8 @@ class RepairController extends ThinkController {
'pay_order_number' => $orderNo, 'pay_order_number' => $orderNo,
'pay_status' => 0 'pay_status' => 0
])->save([ ])->save([
'pay_status' => 1 'pay_status' => 1,
'payed_time' => time()
]); ]);
if ($r) { if ($r) {

@ -118,7 +118,7 @@
<th>充值方式</th> <th>充值方式</th>
<th> <th>
<a class="paixu" data-order='create_time'> <a class="paixu" data-order='create_time'>
充值时间 支付时间
</a> </a>
</th> </th>
<th>订单状态</th> <th>订单状态</th>

@ -101,10 +101,12 @@
</empty> </empty>
<tr> <tr>
<td>汇总(检索时间内所有数据的统计)</td> <td>汇总(检索时间内所有数据的统计)</td>
<td colspan="8"> <td colspan="3">
<if condition="$total egt 0"><span style="color:red">{$fuhao}</span><else/><span style="color:green">{$fuhao}</span></if>
<if condition="$total egt 0"><span style="color:red">{$total}</span><else/><span style="color:green">{$total}</span></if> <if condition="$total egt 0"><span style="color:red">{$total}</span><else/><span style="color:green">{$total}</span></if>
</td> </td>
<td colspan="1">
<span >{$totalAfterValue}</span>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

Loading…
Cancel
Save