This commit is contained in:
wangjinlei
2021-04-15 09:35:03 +08:00
parent 11da1a782b
commit 15de0ec6e6
4 changed files with 202 additions and 98 deletions

View File

@@ -47,18 +47,6 @@ class Staff extends Controller {
$this->staff_to_journal_obj = Db::name('staff_to_journal');
}
public function mytest(){
$url = self::JURL;
$param = [];
$param['issn'] = '2413-3973';
$res = json_decode(myPost($url,$param));
echo '<pre>';
var_dump($res->data->cites);
echo '</pre>';
die;
}
/**
* 添加工资level
*/
@@ -112,6 +100,7 @@ class Staff extends Controller {
$insert['email'] = $data['email'];
$insert['ident'] = $data['ident'];
$insert['bank'] = $data['bank'];
$insert['type'] = $data['type'];
$insert['password'] = md5($data['password']);
$insert['add_price'] = $data['add_price'];
$insert['add_reason'] = $data['add_reason'];
@@ -141,6 +130,7 @@ class Staff extends Controller {
$update['email'] = $data['email'];
$update['ident'] = $data['ident'];
$update['bank'] = $data['bank'];
$update['type'] = $data['type'];
$update['add_price'] = $data['add_price'];
$update['add_reason'] = $data['add_reason'];
$update['sub_price'] = $data['sub_price'];
@@ -166,6 +156,40 @@ class Staff extends Controller {
$re['count'] = $count;
return jsonSuccess($re);
}
public function test(){
echo strtotime('2021-03-13 22:15:20');
}
/**
* 获取指定期刊一段时间的文章详情
* @return type
*/
public function getStaffArticles(){
$data = $this->request->post();
// $data['staff_id'] = 8;
// $data['date'] = '202104';
// $staff_info = $this->staff_obj->where('staff_id',$data['staff_id'])->find();
$journals = $this->journal_obj->where('staff_id',$data['staff_id'])->select();
if ($data['date'] != date('Ym')) {
$c_time = strtotime("-1 month", strtotime($data['date'] . '26 00:00:00'));
$c_time1 = strtotime($data['date'].'25 23:59:59');
$where['ctime'] = array(['>', $c_time], ['<=', $c_time1]);
}else{
$c_time = strtotime("-1 month", strtotime(date('Y-m') . '-26 00:00:00'));
$c_time1 = strtotime(date('Ym').'25 23:59:59');
$where['ctime'] = array(['>', $c_time], ['<=', $c_time1]);
}
$articles = [];
foreach ($journals as $v){
$where['accept_sn'] = ['like',$v['abbr'].'%'];
$list = $this->article_obj->where($where)->select();
$articles = array_merge($articles,$list);
}
$re['articles'] = $articles;
return jsonSuccess($re);
}
/**
* 获取全部员工
@@ -228,41 +252,43 @@ class Staff extends Controller {
$journals = $this->journal_obj->where('staff_id', $value['staff_id'])->select();
$journal_price = 0;
$cite_price = 0;
foreach ($journals as $v) {
$c_price = 0;
// $where['journal_id'] = $v['journal_id'];
$where['accept_sn'] = ['like',$v['abbr'].'%'];
$cache_articles = $this->article_obj->where($where)->select();
$c_gn = 0;
$c_gw = 0;
foreach ($cache_articles as $vv) {
$c_country = $this->article_author_obj->where('article_id', $vv['article_id'])->where('state', 0)->column('country');
$c_c = 'gn';
foreach ($c_country as $vvv) {
if ($vvv != 'China' && $vvv != '') {
$c_c = 'gw';
if($value['type']==0){
foreach ($journals as $v) {
$c_price = 0;
// $where['journal_id'] = $v['journal_id'];
$where['accept_sn'] = ['like',$v['abbr'].'%'];
$cache_articles = $this->article_obj->where($where)->select();
$c_gn = 0;
$c_gw = 0;
foreach ($cache_articles as $vv) {
$c_country = $this->article_author_obj->where('article_id', $vv['article_id'])->where('state', 0)->column('country');
$c_c = 'gn';
foreach ($c_country as $vvv) {
if ($vvv != 'China' && $vvv != '') {
$c_c = 'gw';
}
}
if ($c_c == 'gn') {
$c_gn++;
} else {
$c_gw++;
}
}
if ($c_c == 'gn') {
$c_gn++;
if ($c_gn - $v['jour_num'] >= 0) {
$c_price = ($c_gn - $v['jour_num']) * 100 + $c_gw * 200;
} else {
$c_gw++;
if (($c_gw - ($v['jour_num'] - $c_gn)) >= 0) {
$c_price = ($c_gn + $c_gw - $v['jour_num']) * 200;
} else {
$c_price = 0 - ($v['jour_num'] - $c_gn - $c_gw) * 50;
}
}
$journal_price += $c_price;
//获取cite提成
$jcites = json_decode(myPost(self::JURL,['issn'=>$v['issn']]));
$jcs = $jcites->data->cites;
$cite_price += count($jcs)*500;
}
if ($c_gn - $v['jour_num'] >= 0) {
$c_price = ($c_gn - $v['jour_num']) * 100 + $c_gw * 200;
} else {
if (($c_gw - ($v['jour_num'] - $c_gn)) >= 0) {
$c_price = ($c_gn + $c_gw - $v['jour_num']) * 200;
} else {
$c_price = 0 - ($v['jour_num'] - $c_gn - $c_gw) * 50;
}
}
$journal_price += $c_price;
//获取cite提成
$jcites = json_decode(myPost(self::JURL,['issn'=>$v['issn']]));
$jcs = $jcites->data->cites;
$cite_price += count($jcs)*500;
}
//添加数据
$ccc = $this->staff_log_obj->where('staff_id',$value['staff_id'])->where('date', date('Ym'))->find();
@@ -351,7 +377,6 @@ class Staff extends Controller {
private function getTomonthPrice($name, $date) {
$staff_info = $this->staff_obj->where('name', $name)->where('state',0)->find();
$baseprice = $this->getBasePrice($name);
if ($date != date('Ym')) {
$log_res = $this->staff_log_obj->where('staff_id', $staff_info['staff_id'])->where('date', $date)->where('state', 0)->find();
if ($log_res) {
@@ -391,41 +416,43 @@ class Staff extends Controller {
$journals = $this->journal_obj->where('staff_id', $staff_info['staff_id'])->select();
$journal_price = 0;
$cite_price = 0;
foreach ($journals as $v) {
$c_price = 0;
$where['accept_sn'] = ['like',$v['abbr'].'%'];
$cache_articles = $this->article_obj->where($where)->select();
$c_gn = 0;
$c_gw = 0;
foreach ($cache_articles as $vv) {
$c_country = $this->article_author_obj->where('article_id', $vv['article_id'])->where('state', 0)->column('country');
$c_c = 'gn';
foreach ($c_country as $vvv) {
if ($vvv != 'China' && $vvv != '') {
$c_c = 'gw';
if($staff_info['type']==0){
foreach ($journals as $v) {
$c_price = 0;
$where['accept_sn'] = ['like',$v['abbr'].'%'];
$cache_articles = $this->article_obj->where($where)->select();
$c_gn = 0;
$c_gw = 0;
foreach ($cache_articles as $vv) {
$c_country = $this->article_author_obj->where('article_id', $vv['article_id'])->where('state', 0)->column('country');
$c_c = 'gn';
foreach ($c_country as $vvv) {
if ($vvv != 'China' && $vvv != '') {
$c_c = 'gw';
}
}
if ($c_c == 'gn') {
$c_gn++;
} else {
$c_gw++;
}
}
if ($c_c == 'gn') {
$c_gn++;
if ($c_gn - $v['jour_num'] >= 0) {
$c_price = ($c_gn - $v['jour_num']) * 100 + $c_gw * 200;
} else {
$c_gw++;
if (($c_gw - ($v['jour_num'] - $c_gn)) >= 0) {
$c_price = ($c_gn + $c_gw - $v['jour_num']) * 200;
} else {
$c_price = 0 - ($v['jour_num'] - $c_gn - $c_gw) * 50;
}
}
$journal_price += $c_price;
//获取cite提成
$jcites = json_decode(myPost(self::JURL,['issn'=>$v['issn']]));
$jcs = $jcites->data->cites;
$cite_price += count($jcs)*500;
}
if ($c_gn - $v['jour_num'] >= 0) {
$c_price = ($c_gn - $v['jour_num']) * 100 + $c_gw * 200;
} else {
if (($c_gw - ($v['jour_num'] - $c_gn)) >= 0) {
$c_price = ($c_gn + $c_gw - $v['jour_num']) * 200;
} else {
$c_price = 0 - ($v['jour_num'] - $c_gn - $c_gw) * 50;
}
}
$journal_price += $c_price;
//获取cite提成
$jcites = json_decode(myPost(self::JURL,['issn'=>$v['issn']]));
$jcs = $jcites->data->cites;
$cite_price += count($jcs)*500;
}
$re['staff_log_id'] = 0;
$re['baseprice'] = $baseprice;