init
This commit is contained in:
81
app/controller/Order/ChargeOrder.php
Normal file
81
app/controller/Order/ChargeOrder.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\order;
|
||||
use Overtrue\Pinyin\Pinyin;
|
||||
use think\facade\Db;
|
||||
use think\Request;
|
||||
class ChargeOrder
|
||||
{
|
||||
|
||||
public function charge_order(Request $request)
|
||||
{
|
||||
|
||||
$params = $request->param();
|
||||
$page = $params['page'] ?? 1;
|
||||
$pageSize = $params['pageSize'] ?? 10;
|
||||
$where = [];
|
||||
if(isset($params['phone']) && !empty($params['phone'])){
|
||||
$where[] = ['u.phone','=',$params['phone']];
|
||||
}
|
||||
$list = Db::table('zxc_charge_order o')
|
||||
->leftJoin('zxc_user u', 'o.openid = u.openid')
|
||||
->leftJoin('charge_station s', 's.charge_station_id = o.charge_station_id')
|
||||
->field('o.*, u.phone,s.charge_station_name')
|
||||
->where($where)
|
||||
->order('o.order_id desc')
|
||||
->paginate([
|
||||
'list_rows' => $pageSize,
|
||||
'page' => $page,
|
||||
'query' =>$params
|
||||
]);
|
||||
$list->each(function($item, $key) {
|
||||
$item['type_text'] = $item['type'] == 1 ? '即充即退' : '个人钱包';
|
||||
return $item;
|
||||
});
|
||||
return json($list);
|
||||
}
|
||||
|
||||
public function recharge_order(Request $request){
|
||||
$params = $request->param();
|
||||
$page = $params['page'] ?? 1;
|
||||
$pageSize = $params['pageSize'] ?? 10;
|
||||
$where = [];
|
||||
$list = Db::table('zxc_recharge o')
|
||||
->leftJoin('zxc_user u', 'o.openid = u.openid')
|
||||
->field('o.*, u.phone')
|
||||
->order('o.id desc')
|
||||
->paginate([
|
||||
'list_rows' => $pageSize,
|
||||
'page' => $page,
|
||||
'query' =>$params
|
||||
]);
|
||||
$list->each(function($item, $key) {
|
||||
$item['trade_state'] = '成功';
|
||||
return $item;
|
||||
});
|
||||
return json($list);
|
||||
}
|
||||
|
||||
public function refund_order(Request $request){
|
||||
$params = $request->param();
|
||||
$page = $params['page'] ?? 1;
|
||||
$pageSize = $params['pageSize'] ?? 10;
|
||||
$where = [];
|
||||
$list = Db::table('zxc_refund o')
|
||||
->leftJoin('zxc_user u', 'o.openid = u.openid')
|
||||
->field('o.*, u.phone')
|
||||
->order('o.id desc')
|
||||
->paginate([
|
||||
'list_rows' => $pageSize,
|
||||
'page' => $page,
|
||||
'query' =>$params
|
||||
]);
|
||||
$list->each(function($item, $key) {
|
||||
$item['status'] = '成功';
|
||||
$item['refund_total'] = $item['refund_total']/100;
|
||||
return $item;
|
||||
});
|
||||
return json($list);
|
||||
}
|
||||
|
||||
}
|
||||
104
app/controller/Order/CountExcel.php
Normal file
104
app/controller/Order/CountExcel.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\Order;
|
||||
|
||||
use Overtrue\Pinyin\Pinyin;
|
||||
use think\facade\Db;
|
||||
|
||||
class CountExcel
|
||||
{
|
||||
public function AmountExcel($start_time,$end_time){
|
||||
$end_time = date("Y-m-d",strtotime("+1day",strtotime($end_time)));
|
||||
$date = $this->getDateFromRange($start_time,$end_time);
|
||||
$RechargeAmountTotal = 0;
|
||||
$RefundAmountTotal = 0;
|
||||
$RechargeNumTotal = 0;
|
||||
$RefundNumTotal = 0;
|
||||
$OrderAmountTotal = 0;
|
||||
$OrderNumTotal = 0;
|
||||
$ServiceAmountTotal = 0;
|
||||
$mess =array();
|
||||
foreach ($date as $d){
|
||||
$area = Db::table('area_three')->column('area');
|
||||
$RechargeAmount = 0;
|
||||
$RefundAmount = 0;
|
||||
$RechargeNum = 0;
|
||||
$RefundNum = 0;
|
||||
$OrderAmount = 0;
|
||||
$OrderNum = 0;
|
||||
$ServiceAmount = 0;
|
||||
$degree_pri = 0;
|
||||
foreach ($area as $a){
|
||||
$s = $this->GetArea($a);
|
||||
$table_refund = 'refund_'.$s;
|
||||
$table_order = 'charge_order_'.$s;
|
||||
$table_recharge = 'recharge_'.$s;
|
||||
$recharge = Db::table($table_recharge);
|
||||
$RechargeAmount += $recharge->whereDay('success_time',$d)->sum('total');
|
||||
$RechargeNum += $recharge->whereDay('success_time',$d)->count();
|
||||
$order = Db::table($table_order);
|
||||
$OrderAmount += $order->whereDay('charge_date',$d)->sum('TotalMoney');
|
||||
$OrderNum += $order->whereDay('charge_date',$d)->count();
|
||||
$refund = Db::table($table_refund);
|
||||
$RefundAmount += $refund->whereDay('create_time',$d)->sum('refund_total');
|
||||
$RefundNum += $refund->whereDay('create_time',$d)->count();
|
||||
if (strtotime($d)<strtotime('2023-02-03 00:00:00')){
|
||||
$degree_pri += $order->whereDay('charge_date',$d)->sum('TotalPower');
|
||||
$ServiceAmount += round($degree_pri*0.2,2);
|
||||
}else{
|
||||
$ServiceAmount += $order->whereDay('charge_date',$d)->sum('SeviceMoney');
|
||||
}
|
||||
}
|
||||
$kk['RechargeAmount'] = round($RechargeAmount/100,2);
|
||||
$kk['RechargeNum'] = $RechargeNum;
|
||||
$kk['OrderAmount'] = round($OrderAmount,2);
|
||||
$kk['OrderNum'] = $OrderNum;
|
||||
$kk['RefundAmount'] = round($RefundAmount/100,2);
|
||||
$kk['RefundNum'] = $RefundNum;
|
||||
$kk['ServiceAmount'] = round($ServiceAmount,2);
|
||||
$kk['Time'] = $d;
|
||||
$mess['per'][] = $kk;
|
||||
//['time'=>$d,'data' => $kk];
|
||||
$RechargeAmountTotal += $RechargeAmount;
|
||||
$RefundAmountTotal += $RefundAmount;
|
||||
$RechargeNumTotal += $RechargeNum;
|
||||
$RefundNumTotal += $RefundNum;
|
||||
$OrderAmountTotal += $OrderAmount;
|
||||
$OrderNumTotal += $OrderNum;
|
||||
$ServiceAmountTotal += $ServiceAmount;
|
||||
}
|
||||
$ss['RechargeAmountTotal']=round($RechargeAmountTotal/100,2);
|
||||
$ss['RefundAmountTotal']=round($RefundAmountTotal/100,2);
|
||||
$ss['RechargeNumTotal']=$RechargeNumTotal;
|
||||
$ss['RefundNumTotal']=$RefundNumTotal;
|
||||
$ss['OrderAmountTotal']=round($OrderAmountTotal,2);
|
||||
$ss['OrderNumTotal']=$OrderNumTotal;
|
||||
$ss['ServiceAmountTotal'] = round($ServiceAmountTotal,2);
|
||||
$mess['total'] = [$ss];
|
||||
return json($mess);
|
||||
}
|
||||
|
||||
private function GetArea($area){
|
||||
$pinyin = new Pinyin();
|
||||
$s = $pinyin->sentence($area);
|
||||
$s = strtr($s,array(' '=>''));
|
||||
return $s;
|
||||
}
|
||||
|
||||
private function getDateFromRange($startdate, $enddate): array
|
||||
{
|
||||
|
||||
$stimestamp = strtotime($startdate);
|
||||
$etimestamp = strtotime($enddate);
|
||||
// 计算日期段内有多少天
|
||||
$days = ($etimestamp-$stimestamp)/86400;
|
||||
// 保存每天日期
|
||||
$date = array();
|
||||
for($i=0; $i<$days; $i++){
|
||||
|
||||
$date[] = date('Y-m-d', $stimestamp+(86400*$i));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
}
|
||||
27
app/controller/Order/RechargeRecord.php
Normal file
27
app/controller/Order/RechargeRecord.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\Order;
|
||||
|
||||
use Overtrue\Pinyin\Pinyin;
|
||||
use think\facade\Db;
|
||||
|
||||
class RechargeRecord
|
||||
{
|
||||
public function RechargeRecord($openid){
|
||||
$area = Db::table('user')->where('openid',$openid)->value('area');
|
||||
$pinyin = new Pinyin();
|
||||
$s = $pinyin->sentence($area);
|
||||
$s = strtr($s,array(' '=>''));
|
||||
$table = 'recharge_'.$s;
|
||||
$list = Db::table($table)->where('openid',$openid)->order('id desc')->select()->toArray();
|
||||
$i = 0;
|
||||
foreach ($list as $l){
|
||||
$list[$i]['total'] /= 100;
|
||||
$list[$i]['payer_total']/= 100;
|
||||
$i+=1;
|
||||
}
|
||||
return json($list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
31
app/controller/Order/RefundRecord.php
Normal file
31
app/controller/Order/RefundRecord.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\Order;
|
||||
|
||||
use Overtrue\Pinyin\Pinyin;
|
||||
use think\facade\Db;
|
||||
|
||||
class RefundRecord
|
||||
{
|
||||
public function RefundRecord($openid){
|
||||
$area = Db::table('user')->where('openid',$openid)->value('area');
|
||||
$pinyin = new Pinyin();
|
||||
$s = $pinyin->sentence($area);
|
||||
$s = strtr($s,array(' '=>''));
|
||||
$table_refund = 'refund_'.$s;
|
||||
$message = Db::table($table_refund)->where('openid',$openid)->order('create_time desc')->select()->toArray();
|
||||
for($i=0;$i<count($message);$i++){
|
||||
$message[$i]['refund_total'] = round($message[$i]['refund_total']/100,2);
|
||||
if ($message[$i]['status']=='SUCCESS'){
|
||||
$message[$i]['status'] = '退款成功';
|
||||
}elseif ($message[$i]['status']=='PROCESSING'){
|
||||
$message[$i]['status'] = '退款处理中';
|
||||
}elseif ($message[$i]['status']=='ABNORMAL'){
|
||||
$message[$i]['status'] = '退款异常';
|
||||
}elseif ($message[$i]['status']=='CLOSED'){
|
||||
$message[$i]['status'] = '退款关闭';
|
||||
}
|
||||
}
|
||||
return json($message);
|
||||
}
|
||||
}
|
||||
37
app/controller/Order/TimeTask.php
Normal file
37
app/controller/Order/TimeTask.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\Order;
|
||||
|
||||
use app\controller\ChargeOrder;
|
||||
use think\facade\Db;
|
||||
|
||||
class TimeTask
|
||||
{
|
||||
/**
|
||||
* @throws \RedisException
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$redis = new \Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
}
|
||||
|
||||
public function AdmenAmont(): \think\response\Json
|
||||
{
|
||||
$list = Db::table("charge_order_longshuizhen")->whereBetweenTime("start_time", "2023-06-01", "2023-07-01")->select()->toArray();
|
||||
// return json($list);
|
||||
$jj = [];
|
||||
foreach ($list as $l) {
|
||||
if (round($l['SeviceMoney'] + $l['ElecMoney'], 2) != round($l["TotalMoney"], 2)) {
|
||||
$jj[] = $l['StartChargeSeq'];
|
||||
}
|
||||
}
|
||||
// foreach ($jj as $j) {
|
||||
// $order = new ChargeOrder();
|
||||
// $order->AmendmentAccount('charge_order_longshuizhen', $j);
|
||||
// }
|
||||
$list = Db::table("charge_order_longshuizhen")->whereBetweenTime("start_time", "2023-06-01", "2023-07-01")->select()->toArray();
|
||||
return json($jj);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user