Commit 6f911298 authored by 顾敏's avatar 顾敏

优化代码

parent 3ab97af2
<?php
namespace App\Aldzn;
use Illuminate\Database\Eloquent\Model;
class UserCoupon extends Model
{
protected $connection = 'aldzn_data';
protected $table = "game_user_coupon";
public $timestamps = false;
}
<?php
namespace App\Aldzn;
use Illuminate\Database\Eloquent\Model;
class UserForbid extends Model
{
protected $connection = 'aldzn_data';
protected $table = "forbid_users";
public $timestamps = false;
}
<?php
namespace App\Aldzn;
use Illuminate\Database\Eloquent\Model;
class UserRefund extends Model
{
protected $connection = 'aldzn_data';
protected $table = "game_user_refund";
public $timestamps = false;
}
<?php
namespace App\Aldzn;
use Illuminate\Database\Eloquent\Model;
class UserTotalPay extends Model
{
protected $connection = 'aldzn_data';
protected $table = "game_user_total_pay";
public $timestamps = false;
}
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Aldzn\UserTotalPay;
use App\Aldzn\UserCoupon;
use App\Aldzn\UserRefund;
use App\Aldzn\UserForbid;
class Calculate_refund extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'calc:refund';
/**
* The console command description.
*
* @var string
*/
protected $description = '计算阿拉德之怒玩家退款';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info("start processing");
UserTotalPay::orderBy("ouid")->chunk(100, function ($payRows) {
foreach ($payRows as $payRow) {
$channel = $payRow['channel_id'];
$ouid = $payRow['ouid'];
$refund = UserRefund::where('channel_id', $channel)->where("ouid", $ouid)->first(['id']);
if (!empty($refund)) {
continue;
}
$this->line($channel ." -> " . $ouid);
$totalPay = UserTotalPay::where("channel_id", $channel)->where("ouid", $ouid)->sum('total_payamount');
$coupon = UserCoupon::where("channel_id", $channel)->where("ouid", $ouid)->sum('coupon');
$unblock = UserForbid::where("channel", $channel)->where("accid", $ouid)->value('unblock');
$isBlock = 0;
if ($unblock === 0) {
$isBlock = 1;
}
$oCoin = 0;
if ($coupon > 0) {
$oCoin = ceil($coupon / 10);
}
if ($oCoin > $totalPay) {
$oCoin = ceil($totalPay);
}
if ($isBlock == 1) {
$oCoin = 0;
}
$userRefund = new UserRefund();
$userRefund->platform_id = $payRow['platform_id'];
$userRefund->channel_id = $channel;
$userRefund->ouid = $ouid;
$userRefund->coupon = $coupon;
$userRefund->total_pay = $totalPay;
$userRefund->is_block = $isBlock;
$userRefund->o_coin = $oCoin;
$userRefund->save();
}
});
$this->info("All done");
}
}
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Aldzn\UserTotalPay;
use App\Aldzn\UserCoupon;
use App\Aldzn\UserRefund;
use App\Aldzn\UserForbid;
class SearchRefund extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'search:refund {channel : 渠道ID} {ouid : 账号ID}';
/**
* The console command description.
*
* @var string
*/
protected $description = '查询阿拉德玩家退款';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$channel = $this->argument('channel');
$ouid = $this->argument('ouid');
$refund = UserRefund::where('channel_id', $channel)->where("ouid", $ouid)->first(['id']);
if (!empty($refund)) {
$this->line("历史数据");
$this->info(json_encode($refund, JSON_PRETTY_PRINT));
return;
}
$payRow = UserTotalPay::where("channel_id", $channel)->where("ouid", $ouid)->first();
$this->line($channel ." -> " . $ouid);
$totalPay = UserTotalPay::where("channel_id", $channel)->where("ouid", $ouid)->sum('total_payamount');
$coupon = UserCoupon::where("channel_id", $channel)->where("ouid", $ouid)->sum('coupon');
$unblock = UserForbid::where("channel", $channel)->where("accid", $ouid)->value('unblock');
$isBlock = 0;
if ($unblock === 0) {
$isBlock = 1;
}
$oCoin = 0;
if ($coupon > 0) {
$oCoin = ceil($coupon / 10);
}
if ($oCoin > $totalPay) {
$oCoin = ceil($totalPay);
}
if ($isBlock == 1) {
$oCoin = 0;
}
$userRefund = new UserRefund();
$userRefund->platform_id = $payRow['platform_id'] ?? '';
$userRefund->channel_id = $channel;
$userRefund->ouid = $ouid;
$userRefund->coupon = $coupon;
$userRefund->total_pay = $totalPay;
$userRefund->is_block = $isBlock;
$userRefund->o_coin = $oCoin;
$userRefund->save();
$this->info(json_encode($userRefund, JSON_PRETTY_PRINT));
}
}
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Illuminate\Console\Command;
use App\Models\WxUserImg;
use App\Services\UploadServer;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class UploadOOSImg extends Command
{
......@@ -29,8 +27,6 @@ class UploadOOSImg extends Command
/**
* Create a new command instance.
* @param ProductOrder $productOrder
* @param ScoreDetail $scoreDetail
*/
public function __construct()
{
......
......@@ -28,8 +28,6 @@ class HomeController extends Controller
*/
public function getHome(Request $request)
{
$isWx = UtilService::getIsWx($_SERVER['HTTP_USER_AGENT']);
if(!$isWx) return redirect(route('wxIndex'));
$data = [];
$isWx = UtilService::getIsWx($_SERVER['HTTP_USER_AGENT']);
if(!$isWx) return redirect(route("wxIndex"));
......
......@@ -4,12 +4,8 @@ namespace App\Http\Controllers\Platform;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Redis;
use App\Services\UtilService;
use App\Models\AldGift;
use App\Models\User;
use App\Models\UserExtra;
class HomeController extends Controller
{
......
......@@ -6,15 +6,11 @@ use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Validator;
use App\Models\AldGift;
use App\Models\User;
use App\Models\UserExtra;
use App\Services\RealnameAuthService;
use Illuminate\Support\Facades\Log;
use App\Services\UtilService;
use App\Services\AldGmService;
use Illuminate\Support\Facades\Artisan;
use App\Aldzn\UserRefund;
class UserController extends Controller
{
......@@ -239,8 +235,8 @@ class UserController extends Controller
Cache::put($errTimesKey, $errTimes+1, $expire);
return $this->jsonReturn(1017, "该Orange识别码不存在请重新输入");
}
$channel = $codeInfo['channel'] ?? '';
$ouid = $codeInfo['userId'] ?? '';
// $channel = $codeInfo['channel'] ?? '';
// $ouid = $codeInfo['userId'] ?? '';
// if (!empty($channel) && !empty($ouid) && $channel != "mg") {
// //Artisan::call("search:refund", ['channel' => $channel, 'ouid' => $ouid]);
// //$oCoin = UserRefund::where('channel_id', $codeInfo['channel'])
......
......@@ -4,15 +4,9 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Redis;
use App\Services\Aliyunsms;
use App\Services\RealnameAuthService;
use Illuminate\Support\Facades\Log;
use App\Services\UtilService;
use App\Models\User;
use App\Models\UserExtra;
use App\Models\AldGift;
use Illuminate\Support\Facades\Validator;
class ToolController extends Controller
{
......@@ -42,9 +36,9 @@ class ToolController extends Controller
return $this->jsonReturn(4003, "当天手机发送短信达上限");
}
//$authcode = $this->genAuthCode(6);
$authcode = $this->genAuthCode(6);
$authcode = 666666;
// $authcode = 666666;
Cache::put("sms_auth_code:" . $mobile, $authcode, $expireSeconds);
Cache::put("sms:limit_mobile:" . $mobile, 1, 60);
......@@ -53,9 +47,9 @@ class ToolController extends Controller
Cache::put("sms:limit_mobile_daily:" . $mobile . ":" . $todayDate, $mobileDayLimit +1, 3600*24);
//$aliyunsms = new Aliyunsms();
//$ret = $aliyunsms->send($mobile, $authcode);
$ret = 1;
$aliyunsms = new Aliyunsms();
$ret = $aliyunsms->send($mobile, $authcode);
// $ret = 1;
if ($ret == 1) {
return $this->jsonReturn(0, "验证码发送成功");
}else {
......
......@@ -2,13 +2,9 @@
namespace App\Http\Controllers\WX;
use App\Http\Controllers\Controller;
use App\Models\WxSignModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Throwable;
use Exception;
use Carbon\Carbon;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Redis;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
......
......@@ -52,12 +52,12 @@ class Kernel extends HttpKernel
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
// 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
// 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
......
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class AldGift extends Model
{
protected $primaryKey = "uid";
protected $table = "ald_gift";
public $timestamps = FALSE;
}
......@@ -66,50 +66,6 @@ class UtilService
return $prefix . "****" . $posfix;
}
public static function getKefuURL($openid=0)
{
$uid = $openid;
$time = time();
$level = 0;
$user_id = 0;
if ($uid) {
$signInfo = md5('platform=mg&openid=' . $uid . '&time=' . $time . '&GV49_4=HXjJpd|b6');
$url = 'http://39.108.116.227:59365/query_account?platform=mg&openid=' . $uid . '&time=' . $time . '&sign=' . $signInfo;
$result = self::get_http_request($url);
Log::info("查询MG账号信息: " . $result, ['url' => $url]);
$result = json_decode($result, true);
if (isset($result['result']) && $result['result'] == 0) {
$user_id = $result['accid'];
$level = 1;
}
}
if (empty($user_id)) {
$user_id = 'visitor_' . base_convert(uniqid(), 16, 10) . mt_rand(10000, 99999);
}
$data = array(
'app_id'=>138,
'jobs_id'=>2,
'level'=>$level,
'plat_id'=>3,
'plat_name'=>'橙橙用户中心',
'server_id'=>1,
'server_name'=>'用户中心',
'channel_id'=>-1,
'channel_name'=>'d',
'timestamp'=>time(),
'user_id'=>$user_id,
'user_name'=>'游客',
'ouid'=>$user_id
);
$customer_key = 'WUYO49KqmE$fia*L3g*W1Sdt8hmo5ygQV';
$sign_info = self::getSign($data,$customer_key);
return "https://kefu.srccwl.com/?" . $sign_info['str'].'&sign='.$sign_info['sign'];
}
public static function getSign($data,$key)
{
ksort($data);
......@@ -201,7 +157,7 @@ class UtilService
}
}
public static function postCurlJson($url, $data,$headers = [], $timeout = 30){
public static function postCurlJson($url, $data,$headers = [], $timeout = 5){
try {
$requestHeader[] = "API-RemoteIP: ";
$requestHeader[] = "Content-type: application/json";
......@@ -220,8 +176,8 @@ class UtilService
$result = curl_exec($curl);
curl_close($curl);
return $result;
} catch (exception $e) {
throw new Exception($e->getMessage());
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment