Files
orico-official-website-old/app/us/controller/Antifake.php
2024-10-29 14:04:59 +08:00

186 lines
8.7 KiB
PHP
Executable File

<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2019-07-23
* Time: 15:40
*/
namespace app\us\controller;
use think\Loader;
class Antifake extends BaseController
{
public function index()
{
$this->redirect("https://anti-fake-checking.com/index");
return $this->view->fetch();
}
public function sn_result()
{
if ($_POST) {
$post = $this->request->post();
//$this->verify_check($post['captcha'], 'authcode') || $this->error('验证码有误', url('antifake/index'));
$snnum = $post['sn'];
$snnum = str_replace('-','',$snnum);
$ssd = Loader::model('Ssd');
$where = ['sn' => $post['sn']];
$arr = $ssd->where($where)->find();//dump($arr);die;
if ($arr) {
$data = $arr;//dump($data['sn']);die;
$data['result'] = 1;
$this->assign('data', $data);
} else {
$postdata = ['sn'=>$snnum];
$postdata = http_build_query($postdata);
$sn = CurlRequest('http://mes.orico.com.cn:8081/content/mes/web/api/fwm.aspx', $postdata);
//echo "<pre>=="; print_r($sn);die;
$sn = json_decode($sn, true);
if ($sn['result'] == 1) {
$data['sn'] = $post['sn'];
$data['fake'] = '';
$data['specifications_and_models'] = $sn['specifications_and_models'];
$data['69_code'] = $sn['69_code'];
$data['production_date'] = $sn['production_date'];
$data['Customer_name'] = $sn['Customer_name'];
//$data['department'] = $sn['B2B_B2C'];
$data['made_up_articles_name'] = $sn['made_up_articles_name'];
if (strpos($data['made_up_articles_name'], 'NGFF') !== false) {
$data['aditmend'] = 5;
if($sn['delivery_time']){
$data['delivery_time'] = $sn['delivery_time'];
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
}
else{
$data['delivery_time'] = '';
}
}
elseif(strpos($data['made_up_articles_name'], 'NVME') !== false){
$data['aditmend'] = 3;
if($sn['delivery_time']){
$data['delivery_time'] = $sn['delivery_time'];
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+3year", $time));
}
else{
$data['delivery_time'] = '';
}
}
$data['chicktime'] = date("Y-m-d H:i:s");
//if($data['department']=='B2B'){
//$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+1 month",strtotime($data['mendtime'])));
//}
$data['material_ID'] = $sn['material_ID'];
$where = ['sku'=>$data['specifications_and_models']];
$productid = Loader::model('ProductSku')->where($where)->find();
$img = Loader::model('product_two_img')->where(['product_id'=>$productid['product_id']])->find();
$img = $img['image_url'];
$data['img']=$img;
$add = $ssd->save($data);
$data['result'] = $sn['result'];
$this->assign('data',$data);
} else {
$data['sn']=$snnum;
$data['result'] = $sn['result'];
$this->assign('data',$data);
}
}
}
return $this->fetch();
}
public function anti_fake_result()
{
if ($_POST) {
$post = $this->request->post();
//$this->verify_check($post['captcha'], 'authcode') || $this->error('验证码有误', url('antifake/index'));
$fake = $post['fake'];
$ssd = Loader::model('Ssd');
$where = ['fake' => $fake];
$arr = $ssd->where($where)->find();
if ($arr) {
$data = $arr;//dump($data['sn']);die;
$data['result'] = 1;
$this->assign('data', $data);
} else {
$postdata = ['fwm'=>$fake];
$postdata = http_build_query($postdata);
$sn = CurlRequest('http://mes.orico.com.cn:8081/content/mes/web/api/fwm.aspx', $postdata);//dump($sn);die;
$sn = json_decode($sn, true);
if ($sn['result'] == 1) {
$data['sn'] = $sn['serial_number'];
$data['fake'] = $fake;
$data['specifications_and_models'] = $sn['specifications_and_models'];
$data['69_code'] = $sn['69_code'];
$data['production_date'] = $sn['production_date'];
$data['Customer_name'] = $sn['Customer_name'];
$data['delivery_time'] = $sn['delivery_time'];
//$data['department'] = $sn['B2B_B2C'];
$data['made_up_articles_name'] = $sn['made_up_articles_name'];
$data['chicktime'] = date("Y-m-d H:i:s");
if (strpos($data['made_up_articles_name'], 'NGFF') !== false) {
$data['aditmend'] = 5;
if($sn['delivery_time']){
$data['delivery_time'] = $sn['delivery_time'];
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
}
else{
$data['delivery_time'] = '';
}
}
elseif(strpos($data['made_up_articles_name'], 'NVME') !== false){
$data['aditmend'] = 3;
if($sn['delivery_time']){
$data['delivery_time'] = $sn['delivery_time'];
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+3year", $time));
}
else{
$data['delivery_time'] = '';
}
}
/* $time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
//if($data['department']=='B2B'){
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+1 month",strtotime($data['mendtime'])));*/
// }
$data['material_ID'] = $sn['material_ID'];
$where = ['sku'=>$data['specifications_and_models']];
$productid = Loader::model('product_sku')->where($where)->find();
$img = Loader::model('product_two_img')->where(['product_id'=>$productid['product_id']])->find();
$img = $img['image_url'];
$data['img']=$img;
$add = $ssd->save($data);
$data['result'] = $sn['result'];
$this->assign('data',$data);
} else {
$data['fake']=$fake;
$data['result'] = $sn['result'];
$this->assign('data',$data);
}
}
}
return $this->fetch();
}
}