|
@@ -8,8 +8,16 @@
|
|
|
|
|
|
namespace App\Modules\User\Services;
|
|
|
|
|
|
+use App\Modules\Book\Models\BookGiftsSend;
|
|
|
+use App\Modules\Book\Models\UserShelfBooks;
|
|
|
+use App\Modules\Book\Services\UserShelfBooksService;
|
|
|
+use App\Modules\Subscribe\Models\BookOrder;
|
|
|
+use App\Modules\Subscribe\Models\ChapterOrder;
|
|
|
+use App\Modules\Subscribe\Services\BookOrderService;
|
|
|
+use App\Modules\Subscribe\Services\ChapterOrderService;
|
|
|
use App\Modules\User\Models\User;
|
|
|
use App\Modules\User\Models\UserEnv;
|
|
|
+use App\Modules\User\Models\UserSign;
|
|
|
use DB;
|
|
|
use App\Jobs\ActionTrigger;
|
|
|
use App\Modules\OfficialAccount\Models\DistributionSelfDefineConfig;
|
|
@@ -359,4 +367,111 @@ WHERE u.openid in (SELECT openid from users WHERE id = %s)";
|
|
|
{
|
|
|
return UserEnv::recordUA($ua,$uid);
|
|
|
}
|
|
|
+
|
|
|
+ public static function transfer(int $from,int $to,int $distribution_channel_id){
|
|
|
+ //阅读记录迁移***************************************
|
|
|
+ $record = Redis::hgetall('book_read:'.$from);
|
|
|
+ $not_uid_key = ['last_read','sign_counts','sign_info','sign_day'];
|
|
|
+ $data = [];
|
|
|
+ foreach ($record as $k=>$item){
|
|
|
+ if(is_numeric($k) || in_array($k,$not_uid_key)){
|
|
|
+ $data[$k] = $item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if($data) Redis::hmset('book_read:'.$to,$data);
|
|
|
+ //签到记录
|
|
|
+ $user_sign_model = new UserSign();
|
|
|
+ $user_sign_model->setCurrentTable(date('Ym'));
|
|
|
+ $sign_record = $user_sign_model->where('uid',$from)->select('price','sign_time','day','created_at')->orderBy('sign_time','desc')->get();
|
|
|
+ $temp = [];
|
|
|
+ if($sign_record){
|
|
|
+ foreach ($sign_record as $item){
|
|
|
+ $temp[] = [
|
|
|
+ 'uid'=>$to,
|
|
|
+ 'price'=>$item->price,
|
|
|
+ 'day'=>$item->day,
|
|
|
+ 'sign_time'=>$item->sign_time,
|
|
|
+ 'created_at'=>$item->created_at,
|
|
|
+ 'updated_at'=>date('Y-m-d H:i:s'),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ DB::table('user_sign'.date('Ym'))->insert($temp);
|
|
|
+ }
|
|
|
+ //订阅记录(按本)
|
|
|
+ $book_order = BookOrder::where('uid',$from)->where('bid','>',0)->get();
|
|
|
+ if($book_order){
|
|
|
+ $temp = [];
|
|
|
+ foreach ($book_order as $book){
|
|
|
+ $temp[] = [
|
|
|
+ 'distribution_channel_id'=>$distribution_channel_id,
|
|
|
+ 'bid'=>$book->bid,
|
|
|
+ 'book_name'=>$book->book_name,
|
|
|
+ 'uid'=>$to,
|
|
|
+ 'u'=>$book->u,
|
|
|
+ 'fee'=>0,
|
|
|
+ 'created_at'=>$book->created_at,
|
|
|
+ 'updated_at'=>date('Y-m-d H:i:s'),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ DB::table('book_orders')->insert($temp);
|
|
|
+ }
|
|
|
+ //订阅记录(按章)
|
|
|
+ $chapter_order_record = ChapterOrderService::getRecordByUid($from,'','',true);
|
|
|
+ if($chapter_order_record){
|
|
|
+ $temp = [];
|
|
|
+ $i = 1;
|
|
|
+ $chapter_model = new ChapterOrder();
|
|
|
+ $chapter_model->setCurrentTable($to);
|
|
|
+ foreach ($chapter_order_record as $chapter_order){
|
|
|
+ $temp[] = [
|
|
|
+ 'distribution_channel_id'=>$distribution_channel_id,
|
|
|
+ 'bid'=>$chapter_order->bid,
|
|
|
+ 'cid'=>$chapter_order->cid,
|
|
|
+ 'chapter_name'=>$chapter_order->chapter_name,
|
|
|
+ 'book_name'=>$chapter_order->book_name,
|
|
|
+ 'uid'=>$to,
|
|
|
+ 'send_order_id'=>0,
|
|
|
+ 'fee'=>0,
|
|
|
+ 'created_at'=>$chapter_order->created_at,
|
|
|
+ 'updated_at'=>date('Y-m-d H:i:s')
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $chapter_model->insert($temp);
|
|
|
+ }
|
|
|
+ //打赏记录
|
|
|
+ $gift_result = BookGiftsSend::where('uid',$from)->get();
|
|
|
+ if($gift_result){
|
|
|
+ $tmp = [];
|
|
|
+ foreach ($gift_result as $g){
|
|
|
+ $tmp[] = [
|
|
|
+ 'uid'=>$to,
|
|
|
+ 'gift_id'=>$g->gift_id,
|
|
|
+ 'bid'=>$g->bid,
|
|
|
+ 'icon'=>$g->icon,
|
|
|
+ 'name_desc'=>$g->name_desc,
|
|
|
+ 'cost'=>$g->cost,
|
|
|
+ 'cost_reward'=>$g->cost_reward,
|
|
|
+ 'cost_recharge'=>$g->cost_recharge,
|
|
|
+ 'created_at'=>$g->created_at,
|
|
|
+ 'updated_at'=>date('Y-m-d H:i:s')
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ DB::table('book_gifts_send')->insert($tmp);
|
|
|
+ }
|
|
|
+ //书架
|
|
|
+ $result = UserShelfBooks::where('uid',$from)->get();
|
|
|
+ if($result){
|
|
|
+ $tmp = [];
|
|
|
+ foreach ($result as $s){
|
|
|
+ $tmp[] = [
|
|
|
+ 'uid'=>$to,
|
|
|
+ 'distribution_channel_id'=>$distribution_channel_id,
|
|
|
+ 'bid'=>$s->bid,
|
|
|
+ 'created_at'=>$s->created_at,
|
|
|
+ 'updated_at'=>date('Y-m-d H:i:s')
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ DB::table('user_shelf_books')->insert($tmp);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|