Files
2024-10-29 14:04:59 +08:00

362 lines
17 KiB
PHP
Executable File

<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2019-07-25
* Time: 11:43
*/
namespace app\mobile\controller;
use think\Loader;
use think\Cookie;
use think\Config;
use think\validate;
class Antifake extends BaseController
{
// public function anti_fake_inlet()
// {
// echo '系统维护中,请稍后再试!';exit;
// }
public function anti_fake_inlet()
{
$this->redirect("https://anti-fake-checking.com/index");
// $jssdk=new \JsSdk\JsSdk('wx0d4ac6d59abca442','489aaf23cf26f63346e1b456cb264099');
// $jssdk=new \JsSdk\JsSdk('wx0d4ac6d59abca442','c482b3f5d1354533e9e14ad294016551');
$jssdk=new \JsSdk\JsSdk('wxc0d2e35e015dd0fc','fe931c45ce3513d195c689de9ec1696f');
$signPackage = $jssdk->getSignPackage();
$this->assign('singpackage',$signPackage);
return $this->view->fetch('anti_fake_inlet');
}
public function index()
{
$this->redirect("https://anti-fake-checking.com/index");
return $this->view->fetch();
}
public function anti_fake_sninput()
{
$this->redirect("https://anti-fake-checking.com/index");
return $this->view->fetch();
}
public function anti_fake_input()
{
$this->redirect("https://anti-fake-checking.com/index");
return $this->view->fetch();
}
public function anti_fake_scan_snresult()
{
if(!request()->isAjax()){
$this->assign('sn',$this->request->get('qrresult'));
//return $this->fetch();
}
$post = $this->request->get();
// dump($post);
$fake = $post['qrresult'];
$fake = substr($fake,strripos($fake,",")+1);
$fake = str_replace('-','',$fake);
$ssd = Loader::model('Ssd');
$where = ['sn' => $fake];
$arr = $ssd->where($where)->find();
if ($arr) {
$data = $arr;//dump($data['sn']);die;
$data['result'] = 1;
$this->assign('data', $data);
//return json($data);
} else {
$postdata = ['sn'=>$fake];
$postdata = http_build_query($postdata);
$sn = CurlRequest('http://mes.orico.com.cn:8081/content/mes/web/api/fwm.aspx', $postdata);
$sn = json_decode($sn, true);
// $sn = json_decode($sn, true);//dump($sn);die;
if ($sn['result'] == 1) {
$data['sn'] = $fake;
$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['delivery_time'] = $sn['delivery_time'];
$data['department'] = $sn['department'];
$data['made_up_articles_name'] = $sn['made_up_articles_name'];
$data['chicktime'] = date("Y-m-d H:i:s");
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
$bm = ['速卖通运营部','速卖通运营部','美国新蛋','海外亚马逊','ODM项目部','子品牌事业部','B2B营销中心','海外渠道部'];
// if(in_array($data['department'],$bm)){
$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);
//return json($data);
} else {
$data['sn']=$fake;
$data['result'] = $sn['result'];
$this->assign('data',$data);
// return json($data);
}
}
return $this->fetch();
}
public function anti_fake_scan_result()
{
if(!request()->isAjax()){
$this->assign('sn',$this->request->get('qrresult'));
//return $this->fetch();
}
$post = $this->request->get();
$fake = $post['qrresult'];
$ssd = Loader::model('Ssd');
$where = ['fake' => $fake];
$arr = $ssd->where($where)->find();
if ($arr) {
$data = $arr;//dump($data['sn']);die;
$data['result'] = 1;
$data['first'] = 0;
$this->assign('data', $data);
//return json($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);
$sn = json_decode($sn, true);
// $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['department'];
$data['made_up_articles_name'] = $sn['made_up_articles_name'];
$data['chicktime'] = date("Y-m-d H:i:s");
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
$bm = ['速卖通运营部','速卖通运营部','美国新蛋','海外亚马逊','ODM项目部','子品牌事业部','B2B营销中心','海外渠道部'];
if(in_array($data['department'],$bm)){
$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'];
$data['first'] = 1;
$this->assign('data',$data);
//return json($data);
} else {
$data['fake']=$fake;
$data['first'] = 0;
$data['result'] = $sn['result'];
$this->assign('data',$data);
// return json($data);
}
}
return $this->fetch();
}
public function anti_fake_snresult()
{
if ($_POST) {
$post = $this->request->post();
if($post['sn']==''){
$this->error('请输入SN码');
}
//$this->verify_check($post['captcha'], 'authcode') || $this->error('验证码有误', url('fake/index'));
$snnum = $post['sn'];
$ssd = Loader::model('Ssd');
$where = ['sn' => $post['sn']];
$arr = $ssd->where($where)->find();
if ($arr) {
$data = $arr;//dump($data['sn']);die;
$data['result'] = 1;
$this->assign('data', $data);
} else {
$sn = https_request('http://mes.orico.com.cn:8081/content/mes/web/api/fwm.aspx', $snnum);
$sn = json_decode($sn, true);
//$sn = json_decode($sn, true);
if ($sn['result'] == 1) {
$data['sn'] = $sn['serial_number'];
$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['delivery_time'] = $sn['delivery_time'];
$data['department'] = $sn['department'];
$data['made_up_articles_name'] = $sn['made_up_articles_name'];
$data['chicktime'] = date("Y-m-d H:i:s");
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
$bm = ['速卖通运营部','速卖通运营部','美国新蛋','海外亚马逊','ODM项目部','子品牌事业部','B2B营销中心','海外渠道部'];
if(in_array($data['department'],$bm)){
$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['sn']=$snnum;
$data['result'] = $sn['result'];
$this->assign('data',$data);
}
}
}
return $this->fetch();
}
public function anti_fake_result()
{
if ($_POST) {
$post = $this->request->post();
if($post['fake']==''){
$this->error('请输入防伪码');
}
//$this->verify_check($post['captcha'], 'authcode') || $this->error('验证码有误', url('fake/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 {
$sn = https_request('http://mes.orico.com.cn:8081/content/mes/web/api/fwm.aspx', $fake);
$sn = json_decode($sn, true);
//$sn = json_decode($sn, true);//dump($sn);die;
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['department'];
$data['made_up_articles_name'] = $sn['made_up_articles_name'];
$data['chicktime'] = date("Y-m-d H:i:s");
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
$bm = ['速卖通运营部','速卖通运营部','美国新蛋','海外亚马逊','ODM项目部','子品牌事业部','B2B营销中心','海外渠道部'];
if(in_array($data['department'],$bm)){
$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();
}
public function anti_fake_sn()
{
//if ($_POST) {
//$post = $this->request->post();
//if($post['sn']==''){
// $this->error('请输入SN码');
//}
//$this->verify_check($post['captcha'], 'authcode') || $this->error('验证码有误', url('fake/index'));
$fake = 'Q929T1Y3';
$postdata = ['sn'=>$fake];
$postdata = http_build_query($postdata);
$sn = https_request('http://mes.orico.com.cn:8081/content/mes/web/api/fwm.aspx', $fake);
//$sn = CurlRequest('http://mes.orico.com.cn:8081/content/mes/web/api/fwm.aspx', $postdata);
$sn = json_decode($sn, true);
echo "<pre>=="; print_r($sn);die;
//$sn = json_decode($sn, true);
if ($sn['result'] == 1) {
$data['sn'] = $sn['serial_number'];
$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['delivery_time'] = $sn['delivery_time'];
$data['department'] = $sn['department'];
$data['made_up_articles_name'] = $sn['made_up_articles_name'];
$data['chicktime'] = date("Y-m-d H:i:s");
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
$bm = ['速卖通运营部','速卖通运营部','美国新蛋','海外亚马逊','ODM项目部','子品牌事业部','B2B营销中心','海外渠道部'];
if(in_array($data['department'],$bm)){
$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['sn']=$snnum;
$data['result'] = $sn['result'];
$this->assign('data',$data);
}
//}
return $this->fetch();
}
}