Merge branch 'feature/PlatFormCoinData' of wmtx/platform into release

平台币
master
廖金灵 5 years ago committed by Gogs
commit 610e72bdd2

@ -9,6 +9,7 @@ use Base\Tool\Printer;
use Base\Tool\TaskClient;
use Base\Service\PromoteService;
use GuzzleHttp\Client;
use think\Db;
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));
}
$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')
// ->where($map)
// ->page($page,$row)
// ->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';
//设置好告诉浏览器要下载excel文件的headers
@ -2665,7 +2673,7 @@ class ExportController extends Controller
$vlaueDetailData['create_time'] = date('Y-m-d H:i:s', $valueDetailData['create_time']);
if($valueDetailData['pay_type'] == 1) {
$vlaueDetailData['type'] = "消费";
$total -= $valueDetailData['value'];
$total += $valueDetailData['value'];
}
if($valueDetailData['pay_type'] == 2) {
$vlaueDetailData['type'] = "充值";
@ -2686,16 +2694,11 @@ class ExportController extends Controller
ob_flush();
flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
}
if ($total >= 0) {
$fuhao = '+';
}else {
$fuhao = '-';
}
$alldatas['order_number'] = "汇总(检索时间内所有数据的统计)";
$alldatas['create_time'] = "";
$alldatas['type'] = $fuhao;
$alldatas['value'] = $total;
$alldatas['after_value'] = "";
$alldatas['type'] = "";
$alldatas['value'] = $t;
$alldatas['after_value'] = $first;
mb_convert_variables('GBK', 'UTF-8', $alldatas);
fputcsv($fp, $alldatas);

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

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

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

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

Loading…
Cancel
Save