|
|
|
|
@ -9,6 +9,7 @@
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
use App\Customer;
|
|
|
|
|
use App\Libs\WxMicroPay;
|
|
|
|
|
use App\Models\Balance;
|
|
|
|
|
use App\Models\Factor;
|
|
|
|
|
use App\Models\FactorItems;
|
|
|
|
|
@ -197,55 +198,6 @@ class StatisticsController extends CommonController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function fixMonthLastDayCheckout(Request $request)
|
|
|
|
|
{
|
|
|
|
|
$day = $request->day;
|
|
|
|
|
if (!$day) {
|
|
|
|
|
dd("日期不正确");
|
|
|
|
|
}
|
|
|
|
|
DB::enableQueryLog();
|
|
|
|
|
$orders = Orders::whereIn("serial", ["20201130000003", "20201130000005", "20201128000004", "20201126000006", "20201127000005", "20201126000003", "20201130000004", "20201127000008", "20201130000001", "20201126000008"])->get();
|
|
|
|
|
$orderItems = OrderItems::with(["balance", "order"])
|
|
|
|
|
->whereNotNull("paid_at")
|
|
|
|
|
->whereRaw("UNIX_TIMESTAMP(`paid_at`) > " . strtotime("2020-12-01"))
|
|
|
|
|
->whereRaw("UNIX_TIMESTAMP(`paid_at`) < " . strtotime("2020-12-04"))
|
|
|
|
|
->whereIn("order_id", $orders->pluck("id")->toArray())
|
|
|
|
|
->limit(100)->get();
|
|
|
|
|
try {
|
|
|
|
|
foreach ($orderItems as $orderItem) {
|
|
|
|
|
$new_paid_at = "{$day} 22:00:01";
|
|
|
|
|
$orderItem->update([
|
|
|
|
|
"paid_at" => $new_paid_at
|
|
|
|
|
]);
|
|
|
|
|
$orderItem->balance->update([
|
|
|
|
|
"created_at" => $new_paid_at,
|
|
|
|
|
"remark" => "本条经过时间校准处理。原始创建时间为:" . $orderItem->balance->created_at
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
DB::commit();
|
|
|
|
|
dd("处理完毕");
|
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
dd($exception->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function fixBalanceOrderId()
|
|
|
|
|
{
|
|
|
|
|
$balances = Balance::whereNull("order_id")->with("belongs")->limit("100")->get();
|
|
|
|
|
if (!$balances->count()) {
|
|
|
|
|
return $this->success("处理完毕", url($this->urlPrefix . "/overview"));
|
|
|
|
|
}
|
|
|
|
|
foreach ($balances as $balance) {
|
|
|
|
|
$balance->timestamps = false;
|
|
|
|
|
$balance->update([
|
|
|
|
|
"order_id" => $balance->belongs->order_id
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->success("处理完毕" . $balances->count() . "条数据,正在进入下一批数据。", url($this->urlPrefix . "/finance/fix-balance-order-id?timer=" . time()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function finance(Request $request)
|
|
|
|
|
{
|
|
|
|
|
$projects = $this->_checkProjects();
|
|
|
|
|
@ -298,4 +250,59 @@ class StatisticsController extends CommonController
|
|
|
|
|
|
|
|
|
|
return view($this->bladePath . ".customer-balance", compact("customers", "before_datetime"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function fixMonthLastDayCheckout(Request $request)
|
|
|
|
|
{
|
|
|
|
|
$day = $request->day;
|
|
|
|
|
if (!$day) {
|
|
|
|
|
dd("日期不正确");
|
|
|
|
|
}
|
|
|
|
|
DB::enableQueryLog();
|
|
|
|
|
$orders = Orders::whereIn("serial", ["20201130000003", "20201130000005", "20201128000004", "20201126000006", "20201127000005", "20201126000003", "20201130000004", "20201127000008", "20201130000001", "20201126000008"])->get();
|
|
|
|
|
$orderItems = OrderItems::with(["balance", "order"])
|
|
|
|
|
->whereNotNull("paid_at")
|
|
|
|
|
->whereRaw("UNIX_TIMESTAMP(`paid_at`) > " . strtotime("2020-12-01"))
|
|
|
|
|
->whereRaw("UNIX_TIMESTAMP(`paid_at`) < " . strtotime("2020-12-04"))
|
|
|
|
|
->whereIn("order_id", $orders->pluck("id")->toArray())
|
|
|
|
|
->limit(100)->get();
|
|
|
|
|
try {
|
|
|
|
|
foreach ($orderItems as $orderItem) {
|
|
|
|
|
$new_paid_at = "{$day} 22:00:01";
|
|
|
|
|
$orderItem->update([
|
|
|
|
|
"paid_at" => $new_paid_at
|
|
|
|
|
]);
|
|
|
|
|
$orderItem->balance->update([
|
|
|
|
|
"created_at" => $new_paid_at,
|
|
|
|
|
"remark" => "本条经过时间校准处理。原始创建时间为:" . $orderItem->balance->created_at
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
DB::commit();
|
|
|
|
|
dd("处理完毕");
|
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
dd($exception->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function fixBalanceOrderId()
|
|
|
|
|
{
|
|
|
|
|
$balances = Balance::whereNull("order_id")->with("belongs")->limit("100")->get();
|
|
|
|
|
if (!$balances->count()) {
|
|
|
|
|
return $this->success("处理完毕", url($this->urlPrefix . "/overview"));
|
|
|
|
|
}
|
|
|
|
|
foreach ($balances as $balance) {
|
|
|
|
|
$balance->timestamps = false;
|
|
|
|
|
$balance->update([
|
|
|
|
|
"order_id" => $balance->belongs->order_id
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->success("处理完毕" . $balances->count() . "条数据,正在进入下一批数据。", url($this->urlPrefix . "/finance/fix-balance-order-id?timer=" . time()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function manualQueryRecharge($id) {
|
|
|
|
|
$recharge = Recharge::find($id);
|
|
|
|
|
$res = (new WxMicroPay())->manualQuery($recharge);
|
|
|
|
|
dd($res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|