| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Skutoysjm extends Lyapi_Controller
- {
- public function __construct()
- {
- parent::__construct();
- $this->load->_model("Model_api","api");
- $this->load->_model('Model_shopsku', 'shopsku');
- $this->load->_model('Model_classid', 'classid');
- $this->load->_model('Model_typeclass', 'typeclass');
- $this->load->_model('Model_productdescribe','productdescribe');
- $this->load->_model('Model_shopsku','shopsku');
- $this->load->_model("Model_shop","shop");
- $this->load->_model("Model_logic_u9tools","logic_u9tools");
- }
- private $key ="xcly!&20260923HN"; //加密所需要到的key
- private $iv ="dlzsmt@260923wdq";//加密所需要到的iv
- private $salt_str = "xcly!skutoyslh&0923";
- public function getlist(){
- $json_str = $this->input->raw_input_stream;
- $data = json_decode($json_str,true);
-
- $token = $data['token'];
- if(empty($token)){
- $this->_json_error("无权访问该方法",404 ,$data = []);
- }
- $jiemi_str = $this->logic_tools->toolsjiemi($token,$this->key,$this->iv);
- $now_time = time();
- $jiemi_arr = explode("+",$jiemi_str);
- $jiemi_key = isset($jiemi_arr[0])?$jiemi_arr[0]:"";
- $jiemi_time = isset($jiemi_arr[1])?$jiemi_arr[1]:"";
-
- // if( $now_time - $jiemi_time > 2){
- // $this->_json_error("请求已超时",404 ,$data = []);
- // }
- if($jiemi_key != $this->salt_str){
- $this->_json_error("凭证不正确",404 ,$data = []);
- }
- if(empty($data['sku_list'])){
- $this->_json_error("请求数据为空",400 ,$data = []);
- }
- $len = count($data['sku_list']);
- if($len > 1){
- $this->_json_error("每次转换不允许超过1个",400 ,$data = []);
- }
- $sku = implode(",",$data['sku_list']);
- $dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32');
- $dtc = array();
- foreach ($dictionaries as $v) {
- if (stripos($v['spare'], '|') !== false) //如果有多个值
- {
- $v['spare'] = explode('|', $v['spare']);
- foreach ($v['spare'] as $k => $vs) {
- if (stripos($v['zh'], '|') !== false) {
- $vzh = explode('|', $v['zh']);
- $dtc[strtolower($vs)] = array('classid' => $v['classid'], 'zh' => $vzh[$k], 'id' => $v['id'], 'jm' => $v['jm'], 'spare' => $vs);
- } else {
- $dtc[strtolower($vs)] = array('classid' => $v['classid'], 'zh' => $v['zh'], 'id' => $v['id'], 'jm' => $v['jm'], 'spare' => $vs);
- }
- }
- } else {
- $dtc[strtolower($v['spare'])] = array('classid' => $v['classid'], 'zh' => $v['zh'], 'id' => $v['id'], 'jm' => $v['jm'], 'spare' => $v['spare']);
- }
- }
- $dtctitle = [];
- $dictionaries2 = $this->typeclass->find_all();
- foreach ($dictionaries2 as $v) {
- $dtctitle[$v['id']] = $v['title'];
- }
- /* 匹配结束 */
- /* 价格加入 */
- $money = array();
- $productdescribe = $this->productdescribe->find_all('1=1');
- foreach ($productdescribe as $v) {
- $money[$v['number']] = array();
- }
- /* 价格加入 */
- /* 匹配ID加入 */
- $int = array();
- $intdata = $this->typeclass->find_all('classid=14', 'id,spare');
- foreach ($intdata as $v) {
- $v['spare'] = explode('|', $v['spare']);
- $int[$v['id']] = $v['spare'][0];
- }
- /* 匹配ID加入 */
- $zjsku = array();
- $shopsku = $this->shopsku->find_all();
- foreach ($shopsku as $val) {
- $ss = explode(',', trim($val['shop'], ','));
- foreach ($ss as $v) {
- if (isset($zjsku[$v])) {
- $zjsku[$v] .= ',' . trim($val['sku'], ',');
- } else {
- $zjsku[$v] = trim($val['sku'], ',');
- }
- }
- }
- /* 匹配ID结束 */
- $q = '';
- $quantity = explode(',', trim($sku, ','));
- foreach ($quantity as $v) {
- $q .= '1;';
- }
- $shop = $this->shop->read(19);
- if (isset($zjsku[$shop['id']])) //判断是否找到店铺SKU
- {
- $sku = rtrim($sku, ',') . ',' . $zjsku[$shop['id']];
- }
- $r = $this->api->matching(trim($q, ';'), $sku, $dtc, $money, $int, $dtctitle, $shop);
- $p = '';
- $product = explode(';', trim($r['product'], ';'));
- if ($r['title'] != '' && $product) {
- foreach ($product as $v) {
- $vc = explode('|', $v);
- if(isset($vc[1])){
- $p .= $vc[1] . '<br>';
- }
-
- }
- $tmp_str = $r['product'];
-
- $tmp_arr = explode(";",$tmp_str);
- $list = [];
- foreach($tmp_arr as $k=>$v){
- $tmp_str1 = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
- $tmp_arr1 = explode('|',trim($tmp_str1,'|'));
- if(stripos($tmp_arr1[0],',') !== false){
- $ft = explode(',',$tmp_arr1[0]);
- $features = explode('-',trim($ft[1],'-'));
- $features[] = $ft[0];
- }else{
- $features = explode('-',trim($tmp_arr1[0],'-'));
- }
- $sku = implode("-",$features);
- if(!empty($sku)){
- $list[] = [
- 'sku2'=>$sku,
- ];
- }
-
- }
-
- $u9_data = $this->logic_u9tools->getU9bm($list,'sku2');
- foreach($u9_data as $k => $v){
- unset($u9_data[$k]['sku2']);
- }
-
- $this->_json_error("获取成功",200 ,$data = [
- "sku"=>$data['sku_list'][0],
- "goods_list"=>$u9_data
- ]);
- } else {
- $this->_json_error("数据异常,请联系技术",400 ,$data = []);
- }
-
- }
- }
|