This commit is contained in:
wangjinlei
2023-05-25 18:29:38 +08:00
parent 72f58ae072
commit c803f2748b
6 changed files with 466 additions and 218 deletions

View File

@@ -2156,7 +2156,12 @@ class Article extends Base
foreach ($reviewers as $v) {
$this->addRecommentReviewer($v, $journal_info['journal_id'], $user_res['user_id'], $data['article_id']);
}
$this->article_obj->where('article_id', $data['article_id'])->update(['state' => 0,'ctime'=>time()]);
$update_l['state'] = 0;
$update_l['ctime'] = time();
if(isset($data['code'])&&$data['code']!=''){
$update_l['code'] = trim($data['code']);
}
$this->article_obj->where('article_id', $data['article_id'])->update($update_l);
$this->ai_scor($data['article_id']);
return json(['code' => 0]);
}

View File

@@ -1,8 +1,10 @@
<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
use hashids\hashids;
class Base extends Controller
{
@@ -63,6 +65,7 @@ class Base extends Controller
protected $production_article_author_to_organ_obj = '';
protected $production_article_frag_obj = '';
protected $production_article_main_obj = '';
protected $production_article_main_img_obj = '';
protected $apply_reviewer_obj = '';
protected $promotion_obj = '';
protected $promotion_email_obj = '';
@@ -128,13 +131,13 @@ class Base extends Controller
$this->production_article_author_to_organ_obj = Db::name('production_article_author_to_organ');
$this->production_article_frag_obj = Db::name('production_article_frag');
$this->production_article_main_obj = Db::name('production_article_main');
$this->production_article_main_img_obj = Db::name("production_article_main_img");
$this->apply_reviewer_obj = Db::name("apply_reviewer");
$this->promotion_obj = Db::name("promotion");
$this->promotion_email_obj = Db::name("promotion_email");
}
public function pdfAddProof($article_id)
{
$p_info = $this->production_article_obj->where('article_id', $article_id)->where('state', 0)->find();
@@ -168,46 +171,49 @@ class Base extends Controller
}
}
public function createYboardCert($user_info,$journal_info,$start_time,$year){
if(!is_dir(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id'])){
mkdir(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id']);
public function createYboardCert($user_info, $journal_info, $start_time, $year)
{
if (!is_dir(ROOT_PATH . 'public' . DS . 'cert' . DS . $journal_info['journal_id'])) {
mkdir(ROOT_PATH . 'public' . DS . 'cert' . DS . $journal_info['journal_id']);
}
$sj_num = rand(1000,9999);
$sj_num = rand(1000, 9999);
$template = ROOT_PATH . 'public' . DS . 'cert' . DS . 'yboard_template.png';
$ziti = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'siyuan.ttf';
$ziti1 = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'Georgia0.ttf';
$image = \think\Image::open($template);
$ys = date("F Y",$start_time)." to ".date("F Y",strtotime("+ ".$year." year",$start_time));
$ys = date("F Y", $start_time) . " to " . date("F Y", strtotime("+ " . $year . " year", $start_time));
$image->text($user_info['realname'], $ziti, 45, '#000000', [1060, 750])
->text($ys, $ziti1, 32, '#C49A6C', [1370, 1015])
->text(date("Y.m.d",$start_time), $ziti, 25, '#000000', [500, 1280])
->text($journal_info['title'], $ziti1, 36, '#C49A6C', [860, 930])
->save(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id'].DS. $user_info['user_id'].'_yboard_'.date('Y',$start_time).$sj_num . '.png');
return $journal_info['journal_id'].DS.$user_info['user_id'].'_yboard_'.date('Y',$start_time).$sj_num . '.png';
->text($ys, $ziti1, 32, '#C49A6C', [1370, 1015])
->text(date("Y.m.d", $start_time), $ziti, 25, '#000000', [500, 1280])
->text($journal_info['title'], $ziti1, 36, '#C49A6C', [860, 930])
->save(ROOT_PATH . 'public' . DS . 'cert' . DS . $journal_info['journal_id'] . DS . $user_info['user_id'] . '_yboard_' . date('Y', $start_time) . $sj_num . '.png');
return $journal_info['journal_id'] . DS . $user_info['user_id'] . '_yboard_' . date('Y', $start_time) . $sj_num . '.png';
}
public function majorids($major_id){
$frag[]=$major_id;
$list = $this->major_obj->where('pid',$major_id)->select();
foreach($list as $v){
public function majorids($major_id)
{
$frag[] = $major_id;
$list = $this->major_obj->where('pid', $major_id)->select();
foreach ($list as $v) {
$cache = self::majorids($v['major_id']);
$frag = array_merge($frag,$cache);
$frag = array_merge($frag, $cache);
}
return $frag;
}
public function getMajorShu($major){
if($major==0){
public function getMajorShu($major)
{
if ($major == 0) {
return '';
}
$res = $this->major_obj->where('major_id',$major)->find();
if($res['pid']==1){
$res = $this->major_obj->where('major_id', $major)->find();
if ($res['pid'] == 1) {
return $res['major_id'];
}
$p = self::getMajorShu($res['pid']);
return $p.','.$res['major_id'];
return $p . ',' . $res['major_id'];
}
public function getMajorStr($major_id)
@@ -225,6 +231,11 @@ class Base extends Controller
return $frag;
}
public function getMajorOne($major_id){
$major_info = $this->major_obj->where('major_id', $major_id)->find();
return $major_info['major_title'];
}
public function save_article_file($article_id, $user_id, $username, $url, $type_name)
{
@@ -238,6 +249,8 @@ class Base extends Controller
return true;
} else if ($type_name == 'totalpage' && trim($url) == '') {
return true;
} else if ($type_name == "supplementary" && trim($url) == '') {
return true;
}
$insert_data['article_id'] = $article_id;
$insert_data['user_id'] = $user_id;
@@ -260,101 +273,126 @@ class Base extends Controller
}
public function getCvs($user_id){
$list = $this->user_cv_obj->where('user_id',$user_id)->where('state',0)->select();
public function getCvs($user_id)
{
$list = $this->user_cv_obj->where('user_id', $user_id)->where('state', 0)->select();
return $list;
}
/**获取标准化用户库的人
* @return void
*/
public function getLibraryList($lib,$type,$body,$pageIndex,$pageSize){
public function getLibraryList($lib, $type, $body, $china_type, $pageIndex, $pageSize)
{
$frag = [];
if($lib=="user"){//正式库
$list = [];
if($type=='major'){
$list = $this->user_obj
->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')
->where("t_user_reviewer_info.major",'in',$this->majorids($body))
->where('t_user.no_email',0)
->where('t_user.state',0)
->page($pageIndex,$pageSize)
->select();
}else{
$list = $this->user_obj
->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')
->where("t_user_reviewer_info.field","like","%".$body."%")
->where('t_user.no_email',0)
->where('t_user.state',0)
->page($pageIndex,$pageSize)
->select();
if ($lib == "user") {//正式库
$where["t_user.state"] = 0;
$where["t_user.no_email"] = 0;
if ($type == "major") {
$where['t_user_reviewer_info.major'] = ["in", $this->majorids($body)];
} else {
$where['t_user_reviewer_info.field'] = ["like", "%" . $body . "%"];
}
if($china_type==1){
$where['t_user_reviewer_info.country'] = "China";
}elseif ($china_type==2){
$where['t_user_reviewer_info.country'] = ["<>","China"];
}
$list = $this->user_obj
->join("t_user_reviewer_info", "t_user_reviewer_info.reviewer_id = t_user.user_id", 'left')
->where($where)
->page($pageIndex, $pageSize)
->select();
//规整化数据整理
foreach ($list as $v){
foreach ($list as $v) {
$ca['email'] = $v['email'];
$ca['name'] = $v['realname']==""?$v['account']:$v['realname'];
$ca['name'] = $v['realname'] == "" ? $v['account'] : $v['realname'];
$ca['type'] = "user";
$ca['id'] = $v['user_id'];
$ca['major'] = $v['major'];
$frag[] = $ca;
}
}elseif($lib == 'author'){//作者库
$list = [];
} elseif ($lib == 'author') {//作者库
$exist = "select * from t_user_author where user_id = t_user.user_id";
if($type=='major'){
$list = $this->user_obj
->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')
->where("t_user_reviewer_info.major",'in',$this->majorids($body))
->where('t_user.no_email',0)
->where('t_user.state',0)
->whereExists($exist)
->page($pageIndex,$pageSize)
->select();
}else{
$list = $this->user_obj
->join("t_user_reviewer_info","t_user_reviewer_info.reviewer_id = t_user.user_id",'left')
->where("t_user_reviewer_info.field","like","%".$body."%")
->where('t_user.no_email',0)
->where('t_user.state',0)
->whereExists($exist)
->page($pageIndex,$pageSize)
->select();
$where["t_user.state"] = 0;
$where["t_user.no_email"] = 0;
if ($type == "major") {
$where['t_user_reviewer_info.major'] = ["in", $this->majorids($body)];
} else {
$where['t_user_reviewer_info.field'] = ["like", "%" . $body . "%"];
}
if($china_type==1){
$where['t_user_reviewer_info.country'] = "China";
}elseif ($china_type==2){
$where['t_user_reviewer_info.country'] = ["<>","China"];
}
$list = $this->user_obj
->join("t_user_reviewer_info", "t_user_reviewer_info.reviewer_id = t_user.user_id", 'left')
->where($where)
->whereExists($exist)
->page($pageIndex, $pageSize)
->select();
//规整化数据整理
foreach ($list as $v){
foreach ($list as $v) {
$ca['email'] = $v['email'];
$ca['name'] = $v['realname']==""?$v['account']:$v['realname'];
$ca['name'] = $v['realname'] == "" ? $v['account'] : $v['realname'];
$ca['type'] = "user";
$ca['id'] = $v['user_id'];
$ca['major'] = $v['major'];
$frag[] = $ca;
}
}else{//灰库
} else {//灰库
$list = [];
if($type=='major'){
$list = $this->user_ash_obj
->where('major','in',$this->majorids($body))
->where('no_email',0)
->where('state',0)
->page($pageIndex,$pageSize)
->select();
}else{
$list = $this->user_ash_obj
->where('major',$body)
->where('field',"like","%".$body."%")
->where('state',0)
->page($pageIndex,$pageSize)
->select();
$where['state'] = 0;
$where['no_email'] = 0;
if ($type == "major") {
$where['major'] = ["in", $this->majorids($body)];
} else {
$where['field'] = ["like", "%" . $body . "%"];
}
if($china_type==1){
$where['country'] = "China";
}elseif ($china_type==2){
$where['country'] = ["<>","China"];
}
$list = $this->user_ash_obj
->where($where)
->page($pageIndex, $pageSize)
->select();
//规整化数据整理
foreach ($list as $v){
foreach ($list as $v) {
$ca['email'] = $v['email'];
$ca['name'] = $v['name'];
$ca['type'] = "ash";
$ca['id'] = $v['ash_id'];
$ca['major'] = $v['major'];
$frag[] = $ca;
}
}
return $frag;
}
public function getJournalCycle($journal_id)
{
$journal_info = $this->journal_obj->where('journal_id', $journal_id)->find();
$frag = "";
if ($journal_info['cycle'] == 1) {
$frag = "Monthly";
} elseif ($journal_info['cycle'] == 2) {
$frag = "Bimonthly";
} elseif ($journal_info['cycle'] == 3) {
$frag = "Quarterly";
} else {
$frag = "Continuities";
}
return $frag;
}
public function creatUserCode($str){
$hashids = hashids::instance(8,"tmrjournals");
return $hashids->encode($str);
}
}
?>

View File

@@ -122,7 +122,25 @@ class Production extends Base
}
$p_info = $this->production_article_obj->where('p_article_id',$data['p_article_id'])->find();
$mains = $this->production_article_main_obj->where('p_article_id',$data['p_article_id'])->where('state',0)->select();
$re['mains'] = $mains;
$frag = [];
foreach ($mains as $v){
$frag[] = $v;
$ca = $this->production_article_main_img_obj->where('p_main_id',$v['p_main_id'])->where("state",0)->find();
if($ca){
$frag[] = $ca;
$pre_id = $ca['p_main_img_id'];
while ($pre_id!=0){
$cac = $this->production_article_main_img_obj->where('pre_id',$pre_id)->where('state',0)->find();
if($cac){
$frag[] = $cac;
$pre_id = $cac['p_main_img_id'];
}else{
$pre_id = 0;
}
}
}
}
$re['mains'] = $frag;
$re['production'] = $p_info;
return jsonSuccess($re);
}
@@ -144,6 +162,80 @@ class Production extends Base
return jsonSuccess([]);
}
/**添加主体文章图片
* @return void
*/
public function addProductionMainImg(){
$data = $this->request->post();
$rule = new Validate([
'p_article_id'=>'require',
"pre_type"=>"require",
"body"=>"require",
"content"=>"require",
"width"=>"require",
"note"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$insert['p_article_id'] = $data['p_article_id'];
if($data['pre_type']=="main"){
$insert['p_main_id'] = $data['body'];
}else{
$insert['pre_id'] = $data['body'];
}
$insert['content'] = $data['content'];
$insert['width'] = $data['width'];
$insert['note'] = $data['note'];
$this->production_article_main_img_obj->insert($insert);
return jsonSuccess([]);
}
/**删除mainimg
* @return void
*/
public function delProductionMainImg(){
$data = $this->request->post();
$rule = new Validate([
'p_main_img_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$p_img_info = $this->production_article_main_img_obj->where('p_main_img_id',$data['p_main_img_id'])->find();
$next_info = $this->production_article_main_img_obj->where('pre_id',$p_img_info['p_main_img_id'])->find();
if($next_info){
if($p_img_info['p_main_id']==0){
$this->production_article_main_img_obj->where('p_main_img_id',$next_info['p_main_img_id'])->update(['pre_id'=>$p_img_info['pre_id']]);
}else{
$this->production_article_main_img_obj->where('p_main_img_id',$next_info['p_main_img_id'])->update(['p_main_id'=>$p_img_info['p_main_id']]);
}
}
$this->production_article_main_img_obj->where('p_main_img_id',$data['p_main_img_id'])->update(['state'=>1]);
return jsonSuccess([]);
}
/**编辑mainimg
* @return void
*/
public function editProductionMainImg(){
$data = $this->request->post();
$rule = new Validate([
'p_main_img_id'=>'require',
"width"=>"require",
"content"=>"require",
"note"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$update['width']=$data['width'];
$update['content']=$data['content'];
$update['note'] = $data['note'];
$this->production_article_main_img_obj->where('p_main_img_id',$data['p_main_img_id'])->update($update);
return jsonSuccess([]);
}
/**
* 编辑main内容
* @return \think\response\Json|void
@@ -1614,4 +1706,21 @@ class Production extends Base
}
}
}
/**
* 上传pdf文件
*/
public function up_mainimg_file()
{
$file = request()->file('mainimg');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'mainimg');
if ($info) {
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
}

View File

@@ -7,6 +7,7 @@ use think\Db;
use think\Exception;
use think\Queue;
use think\Validate;
class Promotion extends Base
{
@@ -18,35 +19,43 @@ class Promotion extends Base
/**获取推广任务列表
* @return \think\response\Json|void
*/
public function getPromotions(){
public function getPromotions()
{
$data = $this->request->post();
$rule = new Validate([
'user_id'=>'require'
'user_id' => 'require'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$list = $this->promotion_obj->where('user_id',$data['user_id'])->where('state',0)->select();
foreach ($list as $k => $v){
$list[$k]['journal'] = $this->journal_obj->where('journal_id',$v['journal_id'])->find();
if($v['category']=="major"){
$list = $this->promotion_obj->where('user_id', $data['user_id'])->where('state', 0)->select();
foreach ($list as $k => $v) {
$list[$k]['journal'] = $this->journal_obj->where('journal_id', $v['journal_id'])->find();
if ($v['category'] == "major") {
$list[$k]['major_str'] = $this->getMajorStr($v['major']);
}else{
} else {
$list[$k]['major_str'] = '';
}
$list[$k]['user_count'] = $this->getLibUserCount($v['library'],$v['category'],$v['category']=="major"?$v['major']:$v['keyword']);
$list[$k]['pushed_num'] =$v['pushed']==""?0:count(json_decode($v['pushed']))*$v['pagesize'];
$list[$k]['user_count'] = $this->getLibUserCount($v['library'], $v['category'], $v['category'] == "major" ? $v['major'] : $v['keyword'], $v['china_type']);
$list[$k]['pushed_num'] = $v['pushed'] == "" ? 0 : count(json_decode($v['pushed'])) * $v['pagesize'];
}
$re['list'] = $list;
return jsonSuccess($re);
}
public function mmm()
{
$str = 'Zh1o31IM' . '29698073wjl' . '01c12fc0c47b4fd58dd5ce3b72cb3af2';
echo md5($str);
}
/**获取用户库列表
* @return void
*/
public function getHumenLib(){
public function getHumenLib()
{
$lib[] = "user";
$lib[] = "author";
$lib[] = "ash";
@@ -58,51 +67,69 @@ class Promotion extends Base
* @return void
* @throws Exception
*/
public function getLibUsers(){
public function getLibUsers()
{
$data = $this->request->post();
$rule = new Validate([
"lib"=>"require",
'category'=>"require",
"body"=>"require"
"lib" => "require",
'category' => "require",
"china_type" => "require",
"body" => "require"
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$count = $this->getLibUserCount($data['lib'],$data['category'],$data['body']);
$count = $this->getLibUserCount($data['lib'], $data['category'], $data['body'], $data['china_type']);
$re['count'] = $count;
return jsonSuccess($re);
}
private function getLibUserCount($lib,$category,$body){
private function getLibUserCount($lib, $category, $body, $china_type)
{
$count = 0;
if($lib=="user"){//用户库选择为正式库
if ($lib == "user") {//用户库选择为正式库
$where['t_user.state'] = 0;
$where['t_user.no_email'] = 0;
if($category=="major"){
$where['t_user_reviewer_info.major'] = ['in',$this->majorids($body)];
}else{
$where["t_user_reviewer_info.field"] = ["like","%".$body."%"];
if ($china_type == "1") {
$where['t_user_reviewer_info.country'] = "China";
} elseif ($china_type == "2") {
$where['t_user_reviewer_info.country'] = ["<>", "China"];
}
$count=$this->user_obj->join("t_user_reviewer_info","t_user.user_id = t_user_reviewer_info.reviewer_id","left")->where($where)->count();
}elseif($lib=="author"){//用户库选择为作者库
if ($category == "major") {
$where['t_user_reviewer_info.major'] = ['in', $this->majorids($body)];
} else {
$where["t_user_reviewer_info.field"] = ["like", "%" . $body . "%"];
}
$count = $this->user_obj->join("t_user_reviewer_info", "t_user.user_id = t_user_reviewer_info.reviewer_id", "left")->where($where)->count();
} elseif ($lib == "author") {//用户库选择为作者库
$where['t_user.state'] = 0;
$where['t_user.no_email'] = 0;
if($category=="major"){
$where['t_user_reviewer_info.major'] = ['in',$this->majorids($body)];
}else{
$where["t_user_reviewer_info.field"] = ["like","%".$body."%"];
if ($china_type == "1") {
$where['t_user_reviewer_info.country'] = "China";
} elseif ($china_type == "2") {
$where['t_user_reviewer_info.country'] = ["<>", "China"];
}
if ($category == "major") {
$where['t_user_reviewer_info.major'] = ['in', $this->majorids($body)];
} else {
$where["t_user_reviewer_info.field"] = ["like", "%" . $body . "%"];
}
$exist = "select * from t_user_author where user_id = t_user.user_id";
$count=$this->user_obj->join("t_user_reviewer_info","t_user.user_id = t_user_reviewer_info.reviewer_id","left")->where($where)->whereExists($exist)->count();
}else{//灰库
$where["t_user_ash.state"] = 0 ;
$count = $this->user_obj->join("t_user_reviewer_info", "t_user.user_id = t_user_reviewer_info.reviewer_id", "left")->where($where)->whereExists($exist)->count();
} else {//灰库
$where["t_user_ash.state"] = 0;
$where['t_user_ash.no_email'] = 0;
if($category=="major"){
$where['t_user_ash.major'] = ['in',$this->majorids($body)];
}else {
$where['t_user_ash.field'] = ['like',"%".$body."%"];
if ($china_type == "1") {
$where['t_user_ash.country'] = "China";
} elseif ($china_type == "2") {
$where['t_user_ash.country'] = ["<>", "China"];
}
$count=$this->user_ash_obj->where($where)->count();
if ($category == "major") {
$where['t_user_ash.major'] = ['in', $this->majorids($body)];
} else {
$where['t_user_ash.field'] = ['like', "%" . $body . "%"];
}
$count = $this->user_ash_obj->where($where)->count();
}
return $count;
}
@@ -110,19 +137,20 @@ class Promotion extends Base
/**退订推广邮件
* @return void
*/
public function NoEmail(){
public function NoEmail()
{
$data = $this->request->get();
$rule = new Validate([
'lib'=>"require",
"id"=>"require"
'lib' => "require",
"id" => "require"
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
if($data['lib']=="ash"){
$this->user_ash_obj->where('ash_id',$data['id'])->update(['no_email'=>1]);
}else{
$this->user_obj->where('user_id',$data['id'])->update(['no_email'=>1]);
if ($data['lib'] == "ash") {
$this->user_ash_obj->where('ash_id', $data['id'])->update(['no_email' => 1]);
} else {
$this->user_obj->where('user_id', $data['id'])->update(['no_email' => 1]);
}
echo "Unsubscribed successfully";
}
@@ -130,8 +158,17 @@ class Promotion extends Base
/**获取邮件模版列表
* @return void
*/
public function getEmailModel(){
$list = $this->promotion_email_obj->where('state',0)->select();
public function getEmailModel()
{
$data = $this->request->post();
$rule = new Validate([
"type" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$list = $this->promotion_email_obj->where("type", $data['type'])->where('state', 0)->select();
$re['list'] = $list;
return jsonSuccess($re);
}
@@ -139,34 +176,37 @@ class Promotion extends Base
/**添加推广任务主体
* @return void
*/
public function addPromotion(){
public function addPromotion()
{
$data = $this->request->post();
$rule = new Validate([
'user_id'=>"require",
'journal_id'=>"require",
"library"=>"require",
"category"=>"require",
"pagesize"=>"require",
"email_title"=>"require",
"template"=>"require",
"has_hb"=>"require",
"frequency"=>"require"
'user_id' => "require",
'journal_id' => "require",
"library" => "require",
"category" => "require",
"pagesize" => "require",
"email_title" => "require",
"china_type" => "require",
"template" => "require",
"has_hb" => "require",
"frequency" => "require"
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$insert['user_id'] = $data['user_id'];
$insert['journal_id'] = $data['journal_id'];
$insert['library'] = $data['library'];
$insert['category'] = $data['category'];
if($data['category']=="major"){
if ($data['category'] == "major") {
$insert['major'] = $data['major'];
}else{
} else {
$insert['keyword'] = trim($data['keyword']);
}
$insert['pagesize'] = $data['pagesize'];
$insert['email_title'] = $data['email_title'];
$insert['template']=$data['template'];
$insert['template'] = $data['template'];
$insert["china_type"] = $data['china_type'];
$insert['has_hb'] = $data['has_hb'];
$insert['frequency'] = $data['frequency'];
$insert['is_end'] = 1;
@@ -178,45 +218,48 @@ class Promotion extends Base
/**开启任务
* @return void
*/
public function startPromotion(){
public function startPromotion()
{
$data = $this->request->post();
$rule = new Validate([
"pro_id"=>"require"
"pro_id" => "require"
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->promotion_obj->where('pro_id',$data['pro_id'])->update(['is_end'=>0]);
$this->promotion_obj->where('pro_id', $data['pro_id'])->update(['is_end' => 0]);
return jsonSuccess([]);
}
/**关闭任务
* @return void
*/
public function stopPromotion(){
public function stopPromotion()
{
$data = $this->request->post();
$rule = new Validate([
"pro_id"=>"require"
"pro_id" => "require"
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->promotion_obj->where('pro_id',$data['pro_id'])->update(['is_end'=>1]);
$this->promotion_obj->where('pro_id', $data['pro_id'])->update(['is_end' => 1]);
return jsonSuccess([]);
}
/**获取推广任务详情
* @return void
*/
public function getPromotionDetail(){
public function getPromotionDetail()
{
$data = $this->request->post();
$rule = new Validate([
"pro_id"=>"require"
"pro_id" => "require"
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$pro_info = $this->promotion_obj->where('pro_id',$data['pro_id'])->find();
$pro_info = $this->promotion_obj->where('pro_id', $data['pro_id'])->find();
$re['promotion'] = $pro_info;
return jsonSuccess($re);
}
@@ -227,9 +270,10 @@ class Promotion extends Base
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function doPromotionDay(){
$list = $this->promotion_obj->where('frequency',"day")->where('state',0)->where('is_end',0)->select();
foreach ($list as $v){
public function doPromotionDay()
{
$list = $this->promotion_obj->where('frequency', "day")->where('state', 0)->where('is_end', 0)->select();
foreach ($list as $v) {
$this->autoPushPromotion($v['pro_id']);
}
}
@@ -240,9 +284,10 @@ class Promotion extends Base
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function doPromotionWeek(){
$list = $this->promotion_obj->where('frequency',"week")->where('state',0)->where('is_end',0)->select();
foreach ($list as $v){
public function doPromotionWeek()
{
$list = $this->promotion_obj->where('frequency', "week")->where('state', 0)->where('is_end', 0)->select();
foreach ($list as $v) {
$this->autoPushPromotion($v['pro_id']);
}
}
@@ -252,24 +297,26 @@ class Promotion extends Base
* @throws Exception
* @throws \think\exception\PDOException
*/
public function delPromotion(){
public function delPromotion()
{
$data = $this->request->post();
$rule = new Validate([
"pro_id"=>"require"
"pro_id" => "require"
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->promotion_obj->where('pro_id',$data['pro_id'])->update(['state'=>1]);
$this->promotion_obj->where('pro_id', $data['pro_id'])->update(['state' => 1]);
return jsonSuccess([]);
}
/**自动执行month推广
* @return void
*/
public function doPromotionMonth(){
$list = $this->promotion_obj->where('frequency',"month")->where('state',0)->where('is_end',0)->select();
foreach ($list as $v){
public function doPromotionMonth()
{
$list = $this->promotion_obj->where('frequency', "month")->where('state', 0)->where('is_end', 0)->select();
foreach ($list as $v) {
$this->autoPushPromotion($v['pro_id']);
}
}
@@ -277,58 +324,69 @@ class Promotion extends Base
/**发送测试邮件
* @return void
*/
public function pushTestEmail(){
public function pushTestEmail()
{
$data = $this->request->post();
$rule = new Validate([
'pro_id'=>"require",
'email'=>"require"
'pro_id' => "require",
'email' => "require"
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$pro_info = $this->promotion_obj->where('pro_id',$data['pro_id'])->find();
$journal_info = $this->journal_obj->where("journal_id",$pro_info['journal_id'])->find();
$pro_info = $this->promotion_obj->where('pro_id', $data['pro_id'])->find();
$journal_info = $this->journal_obj->where("journal_id", $pro_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id',$journal_info['editor_id'])->find();
$email_title = $pro_info['email_title'];
$email_title = str_replace("{{journal_title}}",$journal_info['title'],$email_title);
$email_title = str_replace("{{journal_title}}", $journal_info['title'], $email_title);
$email_title = str_replace("{{journal_issn}}", $journal_info['issn'], $email_title);
$template = $pro_info['template'];
$template = str_replace("{{journal_title}}",$journal_info['title'],$template);
$template = str_replace("{{journal_abbr}}",$journal_info['abbr'],$template);
$template = str_replace("{{journal_email}}",$journal_info['email'],$template);
$template = str_replace("{{journal_jabbr}}",$journal_info['jabbr'],$template);
$template = str_replace("{{journal_issn}}",$journal_info['issn'],$template);
$template = str_replace("{{journal_website}}",$journal_info['website'],$template);
$template = str_replace("{{journal_title}}", $journal_info['title'], $template);
$template = str_replace("{{journal_abbr}}", $journal_info['abbr'], $template);
$template = str_replace("{{journal_email}}", $journal_info['email'], $template);
$template = str_replace("{{journal_jabbr}}", $journal_info['jabbr'], $template);
$template = str_replace("{{journal_issn}}", $journal_info['issn'], $template);
$template = str_replace("{{journal_website}}", $journal_info['website'], $template);
$template = str_replace("{{journal_scope}}", $journal_info['scope'], $template);
$template = str_replace("{{journal_editorinchief}}", $journal_info['editorinchief'], $template);
$template = str_replace("{{journal_frequency}}", $this->getJournalCycle($journal_info['journal_id']), $template);
$template = str_replace("{{editor_name}}",$editor_info['realname'],$template);
$template = str_replace("{{user_name}}","emailTestName",$template);
$template = str_replace("{{unsubscribe}}","http://journalapi.tmrjournals.com/public/index.php/api/Promotion/NoEmail?lib=ash&id=35",$template);
aliemail($data['email'],$email_title,$template,$pro_info['has_hb']);
$template = str_replace("{{user_major}}", $this->getMajorOne(52), $template);
$template = str_replace("{{user_name}}", "emailTestName", $template);
$template = str_replace("{{unsubscribe}}", "https://submission.tmrjournals.com/api/Promotion/NoEmail?lib=ash&id=35", $template);
aliemail($data['email'], $email_title, $template, $pro_info['has_hb']);
return jsonSuccess([]);
}
public function mytest(){
public function mytest()
{
$this->autoPushPromotion(6);
}
public function mytest1(){
aliemail("751475802@qq.com","test","testcontent");
public function mytest1()
{
aliemail("751475802@qq.com", "test", "testcontent");
}
/**执行推广任务主方法
* @return void
*/
private function autoPushPromotion($pro_id){
$pro_info = $this->promotion_obj->where('pro_id',$pro_id)->find();
$journal_info = $this->journal_obj->where('journal_id',$pro_info['journal_id'])->find();
if(!$pro_info||$pro_info['is_end']==1){
private function autoPushPromotion($pro_id)
{
$pro_info = $this->promotion_obj->where('pro_id', $pro_id)->find();
$journal_info = $this->journal_obj->where('journal_id', $pro_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id',$journal_info['editor_id'])->find();
if (!$pro_info || $pro_info['is_end'] == 1) {
return jsonError('ended');
}
$push_arr = json_decode($pro_info['pushed']);
$pageIndex = $pro_info['pushed']==""?1:end($push_arr)+1;
$pageIndex = $pro_info['pushed'] == "" ? 1 : end($push_arr) + 1;
//选择人员
$list = $this->getLibraryList($pro_info['library'],$pro_info['category'],$pro_info['category']=="major"?$pro_info['major']:$pro_info['keyword'],$pageIndex,$pro_info['pagesize']);
$list = $this->getLibraryList($pro_info['library'], $pro_info['category'], $pro_info['category'] == "major" ? $pro_info['major'] : $pro_info['keyword'],$pro_info['china_type'], $pageIndex, $pro_info['pagesize']);
// $l['email'] = "751475802@qq.com";
// $l['name'] = "wangjinlei";
// $l['type'] = "ash";
@@ -342,37 +400,61 @@ class Promotion extends Base
//组合模版
$template = $pro_info['template'];
$template = str_replace("{{journal_title}}",$journal_info['title'],$template);
$template = str_replace("{{journal_abbr}}",$journal_info['abbr'],$template);
$template = str_replace("{{journal_email}}",$journal_info['email'],$template);
$template = str_replace("{{journal_jabbr}}",$journal_info['jabbr'],$template);
$template = str_replace("{{journal_issn}}",$journal_info['issn'],$template);
$template = str_replace("{{journal_website}}",$journal_info['website'],$template);
$template = str_replace("{{journal_title}}", $journal_info['title'], $template);
$template = str_replace("{{journal_abbr}}", $journal_info['abbr'], $template);
$template = str_replace("{{journal_email}}", $journal_info['email'], $template);
$template = str_replace("{{journal_jabbr}}", $journal_info['jabbr'], $template);
$template = str_replace("{{journal_issn}}", $journal_info['issn'], $template);
$template = str_replace("{{journal_website}}", $journal_info['website'], $template);
$template = str_replace("{{journal_scope}}", $journal_info['scope'], $template);
$template = str_replace("{{journal_editorinchief}}", $journal_info['editorinchief'], $template);
$template = str_replace("{{journal_frequency}}", $this->getJournalCycle($journal_info['journal_id']), $template);
$template = str_replace("{{editor_name}}",$editor_info['realname'],$template);
//发送邮件
foreach ($list as $v){
$template = str_replace("{{user_name}}",$v['name'],$template);
$template = str_replace("{{unsubscribe}}","http://journalapi.tmrjournals.com/public/index.php/api/Promotion/NoEmail?lib=".$v['type']."&id=".$v['id'],$template);
foreach ($list as $v) {
$template = str_replace("{{user_major}}", $this->getMajorOne($v['major']), $template);
$template = str_replace("{{user_name}}", $v['name'], $template);
$template = str_replace("{{unsubscribe}}", "https://submission.tmrjournals.com/api/Promotion/NoEmail?lib=" . $v['type'] . "&id=" . $v['id'], $template);
$email_title = $pro_info['email_title'];
$email_title = str_replace("{{journal_title}}", $journal_info['title'], $email_title);
$email_title = str_replace("{{journal_issn}}", $journal_info['issn'], $email_title);
$ali['email'] = $v['email'];
$ali['title'] = $pro_info['email_title'];
$ali['title'] = $email_title;
$ali['content'] = $template;
$ali['has_hb'] = $pro_info['has_hb'];
// aliemail($v['email'],$pro_info['email_title'],$template,$pro_info['has_hb']);
Queue::push('app\api\job\mail@promotion', $ali, "tmail");
}
//更改各种状态
//如果后续没有待发数据,要关闭此推广项目
$check_next = $this->getLibraryList($pro_info['library'],$pro_info['category'],$pro_info['category']=="major"?$pro_info['major']:$pro_info['keyword'],$pageIndex+1,$pro_info['pagesize']);
if(count($check_next)==0){
$this->promotion_obj->where('pro_id',$pro_id)->update(['is_end'=>1]);
$check_next = $this->getLibraryList($pro_info['library'], $pro_info['category'], $pro_info['category'] == "major" ? $pro_info['major'] : $pro_info['keyword'],$pro_info['china_type'] ,$pageIndex + 1, $pro_info['pagesize']);
if (count($check_next) == 0) {
$this->promotion_obj->where('pro_id', $pro_id)->update(['is_end' => 1]);
}
//发送过的数据加一页
$push_arr[] = $pageIndex;
$this->promotion_obj->where('pro_id',$pro_id)->update(["pushed"=>json_encode($push_arr)]);
$this->promotion_obj->where('pro_id', $pro_id)->update(["pushed" => json_encode($push_arr)]);
return "push email :".count($list);
return "push email :" . count($list);
}
/**
* 上传pdf文件
*/
public function up_promotion_file()
{
$file = request()->file('promotion');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'promotion');
if ($info) {
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
}

View File

@@ -787,7 +787,7 @@ class Reviewer extends Base
}else{
$score = 0.1;
}
addUserScoreLog($art_rev_info['reviewer_id'],$score,"add score ".$score." for submit article",time());
addUserScoreLog($art_rev_info['reviewer_id'],$score,"add score ".$score." for review article",time());
$this->user_obj->where('user_id',$art_rev_info['reviewer_id'])->setInc('score',$score);
$sendReviewer = [

View File

@@ -3,6 +3,7 @@
namespace app\api\controller;
use app\api\controller\Base;
use hashids\hashids;
use think\Db;
use think\captcha;
use think\Cache;
@@ -23,8 +24,21 @@ class User extends Base
parent::__construct($request);
}
public function pstest(){
echo md5('mtrsuper999');
public function cusercode(){
$data = $this->request->post();
$rule = new Validate([
"num"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$list = $this->user_obj->where('state',0)->page($data['num'],1000)->select();
foreach ($list as $v){
$d['code'] = $this->creatUserCode($v['user_id']);
$this->user_obj->where('user_id',$v['user_id'])->update($d);
}
echo 'done';
}
/**