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

128 lines
5.9 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()
{
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'];
$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:8084/api/SN/', $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['supplier'];
$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");
$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['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 {
$sn = https_request('http://mes.orico.com.cn:8084/api/values/', $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['supplier'];
$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");
$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();
}
}