Commit 5504f6cd by 孙龙

up

parent 3052565b
......@@ -5,6 +5,8 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
use DB;
use Log;
use Illuminate\Support\Facades\Redis;
class JingDiaoUser extends Command
{
/**
......@@ -21,14 +23,411 @@ class JingDiaoUser extends Command
*/
protected $description = '清除静调用户是手机号的';
public function userids(){
return [
67483,
63302,
63226,
63060,
61626,
48191,
48138,
47988,
47609,
47135,
46989,
46751,
46416,
46397,
46004,
45545,
45072,
45015,
44946,
44836,
44817,
44740,
43794,
43774,
42750,
42226,
42149,
42077,
40962,
40442,
40270,
40193,
40181,
39816,
39583,
39367,
38481,
38408,
36793,
36309,
35664,
35619,
35450,
33633,
33606,
33176,
32802,
29621,
29458,
26923,
19816,
19811,
19801,
19616,
19563,
19540,
18755,
8936 ,
4745 ,
4469 ,
4355 ,
4291 ,
4289 ,
4200 ,
4171 ,
4063 ,
4054 ,
4044 ,
4024 ,
4011 ,
3962 ,
3961 ,
3924 ,
3812 ,
3783 ,
3759 ,
3752 ,
3624 ,
3623 ,
3546 ,
3495 ,
3491 ,
3489 ,
3460 ,
3394 ,
3268 ,
3260 ,
3249 ,
10
];
}
/*
* 修改用户总积分
*/
public function handle(){
$userids = $this->userids();
$users = DB::Connection("order")->table("lie_user_main")->whereIn("user_id",$userids)->where("is_type","=",1)->pluck("user_id");
try{
DB::Connection("order")->beginTransaction();
foreach($users as $user_id){
DB::Connection("order")->table("lie_user_main")->where(["user_id"=>$user_id])->update([
"is_type"=>0,
]);
continue;
$zjf_z = DB::Connection("order")->table("lie_point_log")->where("user_id",$user_id)->where("flow_type",1)->sum("flow_point");
$zjf_f = DB::Connection("order")->table("lie_point_log")->where("user_id",$user_id)->where("flow_type",2)->sum("flow_point");
$jifen = intval($zjf_z - $zjf_f);
dump(sprintf("userid:%s 的积分为:%s",$user_id,$jifen));
$userInfo = DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->select("cur_user_point","cur_total_point")->first();
$bk = DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->update([
"cur_user_point"=>$jifen,
"cur_total_point"=>$jifen,
]);
dump($bk);
}
DB::Connection("order")->commit();
}catch(\Exception $e){
dump($e->getMessage());
DB::Connection("order")->rollBack();
}
}
/**
* Execute the console command.
*
* @return mixed
* is_type=1 假用户
* 给下过单的静调用户 增加订单积分
*/
public function handle_addorder_JIFEN()
{
$userids = $this->userids();
$users = DB::Connection("order")->table("lie_user_main")->whereIn("user_id",$userids)->where("is_type","=",1)->pluck("user_id");
try{
DB::Connection("order")->beginTransaction();
foreach($users as $user_id){
// $a = DB::Connection("order")->table("lie_point_log")->where("user_id",$user_id)->where("flow_reason_type",3)->delete();
// dump($a);
// continue;
$orders = DB::Connection("order")->table("lie_order")->where(["user_id"=>$user_id,"is_type"=>0])
->where("status",">=",10)
->where("create_time",">",1540656000)
->select("order_amount","order_goods_type","is_type","order_pay_type","integral","status","order_id","create_time")->get();
// dump($orders);
$zong_jifen = 0;
$userMobile = DB::Connection("order")->table("lie_user_main")->where("user_id",$user_id)->select("mobile")->first();
foreach($orders as $k=>$order){
$jifen = 0;
if($order->order_pay_type == 3){
$jifen += intval($order->order_amount)*0.7;
}else{
if($order->order_goods_type == 1){
$jifen += intval($order->order_amount);
}elseif($order->order_goods_type == 2){
$jifen += intval($order->order_amount)*2;
}
}
$jifen = intval($jifen);
//增加积分
$jifenData = [
"user_id"=>$user_id,
"user_account"=>$userMobile->mobile,
"flow_type"=>1,
"flow_point"=>$jifen,
"flow_time"=>$order->create_time,
"flow_reason_type"=>3,
"flow_extra_id"=>$order->order_id,
"flow_pf"=>4,
"operator_uid"=>1000,
"operator_name"=>"",
"remark"=>"",
];
// dump($jifenData);
$bk = DB::Connection("order")->table("lie_point_log")->insert($jifenData);
if(!$bk){
throw new \Exception("添加数据失败");
}
$zong_jifen += $jifen;
}
$zong_jifen = intval($zong_jifen);
$userInfo = DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->select("cur_user_point","cur_total_point")->first();
if(!$userInfo){
$userInfo = DB::Connection("order")->table("lie_user_info")->insert([
"user_id"=>$user_id,
"cur_user_point"=>$zong_jifen,
"cur_total_point"=>$zong_jifen,
]);
}
DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->update([
"cur_user_point"=>$userInfo->cur_user_point,
"cur_total_point"=>$userInfo->cur_total_point,
]);
if($zong_jifen > 0){
dump(sprintf("user_id:%s 积分:%s", $user_id,$zong_jifen));
}
}
DB::Connection("order")->commit();
}catch(\Exception $e){
dump($e->getMessage());
DB::Connection("order")->rollBack();
}
}
function randMobile($type=0){
//手机号2-3为数组
$yidong = [
"34",
"35",
"36",
"37",
"38",
"39",
"47",
"50",
"51",
"52",
"57",
"58",
"59",
"78",
"82",
"83",
"84",
"87",
"88",
"98",
];
$liantong =[
"30",
"31",
"32",
"45",
"55",
"56",
"66",
"71",
"75",
"76",
"85",
"86"];
$dianxin = [
"33",
"49",
"53",
"73",
"77",
"80",
"81",
"89",
"99",
];
$mobileType = [$yidong,$liantong,$dianxin];
$mobile = 1;
$mobile .= $mobileType[$type][rand(0,count($mobileType[$type])-1)];
$mobile .= str_pad(rand(0,99999999),8,0,STR_PAD_LEFT);
$result = $mobile;
return $result;
}
protected function getOtherEmail($type=0){
$hz = ["@139.com","@wo.com.cn","@189.cn"];
$mobile = $this->randMobile($type);
$email = $mobile.$hz[$type];
return $email;
}
protected function getQQEmail(){
$strs="123456789012345678901234567890";
$name=substr(str_shuffle($strs),mt_rand(0,23),mt_rand(7,11));
$name = $name."@qq.com";
return $name;
}
protected function getEmail($type=0){
if(in_array($type,[0,1,2])){
$emial = $this->getOtherEmail($type);
}else{
$emial = $this->getQQEmail();
}
$count = DB::connection('order')
->table('lie_user_main')
->where(["email"=>$emial])->count();
if($count){
$this->getEmail($type);
}
return $emial;
}
/**
* 静调用户手机号转邮箱
*/
public function handle()
public function handle_mobila_email()
{
$list = DB::Connection("order")->table("lie_user_main")->whereRaw(" is_type = 1 and mobile != '' ")->count();
dump($list);
$countN=0;
$userJD = [];
DB::Connection("order")->table("lie_user_main")->select("user_id","mobile","is_type")->OrderBy("user_id","desc")->whereRaw(" is_type = 1 and mobile != '' ")
->chunk(100, function($users) use(&$countN,&$userJD) {
foreach ($users as $user) {
$user_id = $user->user_id;
$logs = null;
$orders = null;
$logs = DB::Connection("order")->table("lie_user_login")->where(["user_id"=>$user_id])->count("id");
$orders = DB::Connection("order")->table("lie_order")->where(["user_id"=>$user_id,"is_type"=>0])->count("order_id");
if(!$logs && !$orders){
dump($user->user_id);
Log::info(sprintf("user_id:%s,mobile:%s,is_type:%s",$user->user_id,$user->mobile,$user->is_type));
$email = $this->getEmail(mt_rand(0,3));
dump($email);
$redis = Redis::connection('userssssss');
$tmp = $redis->hget("api_user",$user->user_id);
if($tmp){
$tmp_arr = json_decode($tmp,true);
if(!empty($tmp_arr)){
$tmp_arr["mobile"]="";
$tmp_arr["email"]=$email;
$redis->hset("api_user",$user->user_id,json_encode($tmp_arr));
}
}
$redis->hdel("api_mobile",$user->mobile);
$redis->hset("api_email",$email,$user->user_id);
DB::Connection("order")->table("lie_user_main")->where(["user_id"=>$user->user_id])->update([
"mobile"=>"",
"email"=>$email
]);
}
}
});
dump($countN);
dump($userJD);
}
}
<?php
return [
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'tableconfig' => [
'driver' => 'mysql',
'host' => env('DB_HOST', ''),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', ''),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'order' => [
'driver' => 'mysql',
'host' => env('DB_HOST', ''),
'database' => env('DB_DATABASE_ORDER', ''),
'username' => env('DB_USERNAME_ORDER', ''),
'password' => env('DB_PASSWORD_ORDER', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'crm' => [
'driver' => 'mysql',
'host' => env('DB_HOST_CRM', ''),
'database' => env('DB_DATABASE_CRM', ''),
'username' => env('DB_USERNAME_CRM', ''),
'password' => env('DB_PASSWORD_CRM', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => env('DB_PREFIX_CRM', ''),
'strict' => false,
],
'pcb' => [
'driver' => 'mysql',
'host' => env('DB_HOST_PCB', ''),
'database' => env('DB_DATABASE_PCB', ''),
'username' => env('DB_USERNAME_PCB', ''),
'password' => env('DB_PASSWORD_PCB', ''),
'port' => env('DB_PORT_PCB', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sqlite' => [
'driver' => 'sqlite',
'database' => database_path('database.sqlite'),
'prefix' => '',
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', ''),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
'read' => [
'host' => env('REDIS_READ_HOST', ''),
'password' => env('REDIS_READ_PASSWORD', null),
'port' => env('REDIS_READ_PORT', 6379),
'database' => 0,
],
],
];
<?php
return [
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'tableconfig' => [
'driver' => 'mysql',
'host' => env('DB_HOST', ''),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', ''),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'order' => [
'driver' => 'mysql',
'host' => env('DB_HOST', ''),
'database' => env('DB_DATABASE_ORDER', ''),
'username' => env('DB_USERNAME_ORDER', ''),
'password' => env('DB_PASSWORD_ORDER', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'crm' => [
'driver' => 'mysql',
'host' => env('DB_HOST_CRM', ''),
'database' => env('DB_DATABASE_CRM', ''),
'username' => env('DB_USERNAME_CRM', ''),
'password' => env('DB_PASSWORD_CRM', ''),
'port' => env('DB_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => env('DB_PREFIX_CRM', ''),
'strict' => false,
],
'pcb' => [
'driver' => 'mysql',
'host' => env('DB_HOST_PCB', ''),
'database' => env('DB_DATABASE_PCB', ''),
'username' => env('DB_USERNAME_PCB', ''),
'password' => env('DB_PASSWORD_PCB', ''),
'port' => env('DB_PORT_PCB', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sqlite' => [
'driver' => 'sqlite',
'database' => database_path('database.sqlite'),
'prefix' => '',
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', ''),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
'read' => [
'host' => env('REDIS_READ_HOST', ''),
'password' => env('REDIS_READ_PASSWORD', null),
'port' => env('REDIS_READ_PORT', 6379),
'database' => 0,
],
'userssssss' => [
'host' => "172.18.137.21",
'password' => "icDb29mLy2s",
'port' => 6379,
'database' => 0,
],
],
];
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
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 sign in to comment