123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?php
- namespace App\Http\Logics\Admin;
- use Illuminate\Support\Facades\DB;
- class SiteSyncLogic
- {
- public function insertGetId(array $data)
- {
- return DB::connection('rank')->table('project')->insertGetId($data + ['create_time' => time()]);
- }
- public function update($oldId, array $data)
- {
- if ($oldId) {
- DB::connection('rank')->table('project')->where(['id' => $oldId])->update($data);
- }
- }
-
- public function delete($ids)
- {
- $filter = is_array($ids) ? $ids : [$ids];
- DB::connection('rank')->table('project')->whereIn('id', $filter)->update([
- 'is_enabled' => 0,
- 'allow_googlerank' => 0
- ]);
- }
-
- public function fieldMap(array $origins)
- {
- $map = [
- 'identifier' => 'code',
- 'cn_title' => 'name',
- 'domain' => 'domain',
- 'report_day' => 'report_day',
- 'webmaster_domain' => 'webmaster_domain',
- 'server_ip' => 'cloud_ip',
- 'keyword_goal' => 'reach_num',
- 'online_at' => 'start_time'
- ];
- $result = [];
- foreach ($origins as $key => $item) {
- if (empty($map[$key]))
- continue;
- if (empty($item))
- continue;
- $result[$map[$key]] = $item;
- if (in_array($key, ['online_at'])) {
- $result[$map[$key]] = strtotime($item);
- }
- }
- return $result;
- }
- }
|