老数据副表
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class PostOld extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'post_old';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'user_id', 'category_id', 'sku_id', 'content', 'shop_name', 'location_name', 'latitude', 'longitude', 'geo', 'status', 'sort', 'like', 'favorite', 'comment', 'is_free', 'model', 'browse', 'created_at', 'updated_at', 'price', 'age'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\logic\AuthLogic;
|
||||
use app\common\model\Post;
|
||||
use app\common\model\PostOld;
|
||||
use app\common\model\UserOld;
|
||||
use app\common\validate\UserValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
@@ -300,6 +302,28 @@ class UserService
|
||||
$uinfo->mobile = $mobile;
|
||||
$uinfo->save();
|
||||
|
||||
$postOld = PostOld::where('mobile', $mobile)->get();
|
||||
if (!empty($postOld)) {
|
||||
foreach ($postOld as $item) {
|
||||
$post = [
|
||||
"id" => $item->id,
|
||||
"user_id" => $uinfo->id,
|
||||
"category_id" => $item->id,
|
||||
"sku_id" => $item->sku_id,
|
||||
"content" => $item->content,
|
||||
"shop_name" => $item->shop_name,
|
||||
"location_name" => $item->location_name,
|
||||
"status" => 1,
|
||||
"is_free" => $item->is_free,
|
||||
"model" => $item->model,
|
||||
"browse" => $item->browse,
|
||||
"price" => $item->price,
|
||||
"age" => $item->age,
|
||||
];
|
||||
Post::firstOrCreate($post);
|
||||
}
|
||||
}
|
||||
|
||||
return $wxinfo;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user