1234567891011121314151617181920212223242526272829303132 |
- <?php
- use app\common\model\User;
- use think\migration\Seeder;
- class UpdateSellerGradeSeeder extends Seeder
- {
- /**
- * Run Method.
- *
- * Write your database seeder using this method.
- *
- * More information on writing seeders is available here:
- * http://docs.phinx.org/en/latest/seeding.html
- */
- public function run()
- {
- $users = User::where('role',99)->select();
- if (count($users)){
- foreach ($users as $user){
- $applyRec = \app\common\model\ApplySeller::where('user_id',$user->user_id)
- ->where('state',1)->find();
- if ($applyRec){
- $expire = intval(strtotime('+1 year',strtotime($applyRec->update_time)));
- }else{
- $expire = intval(strtotime('+1 year',strtotime($user->create_time)));
- }
- User::where('user_id',$user->user_id)->update(['seller_grade'=>1,'seller_expire'=>$expire]);
- }
- }
- }
- }
|