|
@@ -0,0 +1,211 @@
|
|
|
+<?php
|
|
|
+defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
+/**
|
|
|
+ * 本类是为了处理 erp协同其他系统,通过其他系统传递的条件 返回所需信息
|
|
|
+ */
|
|
|
+class Apipf extends Start_Controller{
|
|
|
+ public function __construct(){
|
|
|
+ parent::__construct();
|
|
|
+ $this->load->_model('Model_logic_order','logic_order');
|
|
|
+ $this->load->_model('Model_logic_tools','logic_tools');
|
|
|
+ $this->load->_model("Model_logic_ding",'logic_ding');
|
|
|
+ $this->load->_model('Model_customer','customer');
|
|
|
+ $this->load->_model('Model_typeclass','typeclass');
|
|
|
+
|
|
|
+ }
|
|
|
+ private $key = "bpng!pjgirv6amnfr"; //加密所需要到的key
|
|
|
+ private $iv = "k4k!94m66oojtm2w";//加密所需要到的iv
|
|
|
+ private $api = "202503121009@ly";
|
|
|
+
|
|
|
+ //定义方法的调用规则 获取URI第二段值
|
|
|
+ public function _remap($arg,$arg_array)
|
|
|
+ {
|
|
|
+ if($arg == 'checkMoreThree')//添加
|
|
|
+ {
|
|
|
+ $this->_checkMoreThree();
|
|
|
+ }
|
|
|
+ elseif($arg == 'customerData')
|
|
|
+ {
|
|
|
+ $this->_customerData();
|
|
|
+ }
|
|
|
+ elseif($arg == 'orderTbAllData')
|
|
|
+ {
|
|
|
+ $this->_orderTbAllData();
|
|
|
+ }
|
|
|
+ elseif($arg == 'orderTbData')
|
|
|
+ {
|
|
|
+ $this->_orderTbData();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ exit('No direct script access allowed');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //检测客户是否超过3次且为传输
|
|
|
+ public function _checkMoreThree(){
|
|
|
+ $api = $this->input->get('api',true);
|
|
|
+ if($api != $this->api){
|
|
|
+ die("No data to be executed");
|
|
|
+ }
|
|
|
+ $hour = date("H");
|
|
|
+ $minute = date("i");
|
|
|
+ if($hour != 20){
|
|
|
+ die("Execution conditions hour do not allow");
|
|
|
+ }
|
|
|
+ if(($minute >= 10)&&($minute <=20)){
|
|
|
+ $this->db->query("update crowd_customer set more_three = 1 where num >= 3 and more_three = 0");
|
|
|
+ die("No executable data available");
|
|
|
+ }else{
|
|
|
+ die("Execution conditions minute do not allow !");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /***
|
|
|
+ * 上传没有给批发站没有传递的客户信息
|
|
|
+ */
|
|
|
+ public function _customerData(){
|
|
|
+ $list = $this->customer->find_all("more_three = 1","id,shop,source,name,email,phone,money,num,country,province,city,street,address,address2,zipcode",'id asc',0,100);
|
|
|
+ $list_ids = [];
|
|
|
+ $send_list = [];
|
|
|
+ foreach($list as $k=>$v){
|
|
|
+ $list_ids[] = $v['id'];
|
|
|
+ $send_list[] = [
|
|
|
+ 'name'=>$v['name'],
|
|
|
+ 'email'=>$v['email'],
|
|
|
+ 'telephone'=>$v['phone'],
|
|
|
+ 'money'=>$v['money'],
|
|
|
+ 'num'=>$v['num'],
|
|
|
+ 'country'=>$v['country'],
|
|
|
+ 'province'=>$v['province'],
|
|
|
+ 'city'=>$v['city'],
|
|
|
+ 'street'=>$v['street'],
|
|
|
+ 'address'=>$v['address'].$v['address2'],
|
|
|
+ 'zipcode'=>$v['zipcode']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $header = [];
|
|
|
+ $url = "";
|
|
|
+ if(empty($send_list)){
|
|
|
+ die("There is no customer data to be synchronized");
|
|
|
+ }
|
|
|
+ die("update crowd_customer set more_three = 2 where id in (".implode(",",$list_ids).")");
|
|
|
+ $this->db->query("update crowd_customer set more_three = 2 where id in (".implode(",",$list_ids).")");
|
|
|
+ // $res = $this->sendHttp($url,$header,$send_list);
|
|
|
+ // if($res){
|
|
|
+ // $this->db->query("update crowd_customer set more_three = 2 where id in (".implode(",",$list_ids).")");
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ public function _orderTbAllData(){
|
|
|
+ $typeclass = $this->typeclass->find_all("classid = 29","id,classtitle,title,spare");
|
|
|
+ $typeclass = array_column($typeclass,null,'id');
|
|
|
+
|
|
|
+ $list = $this->customer->find_all("more_three = 2","id,shop,name,email",'id asc',0,100);
|
|
|
+
|
|
|
+ foreach($list as $k=>$v){
|
|
|
+ $order_list = $this->getOrder($v,$typeclass);
|
|
|
+ if(empty($order_list)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private function getOrder($v,$typeclass){
|
|
|
+ $fdata = $this->fullorder->find_all('email = "'.$customer['email'].'" and shop = "'.$customer['shop'].'" and mergeid = 0 and reviewtime <= ','shop,orderinfo,issku,quantity,fpdata,state,product,name,email,dtime,shouldmoney,shipremarks','id desc');
|
|
|
+ $ret_list = [];
|
|
|
+ foreach ($fdata as $k=>$v)
|
|
|
+ {
|
|
|
+ $sku_list = [];
|
|
|
+ $issku_arr = explode(",",trim($v['issku'],','));
|
|
|
+ $quantity_arr = explode(";",trim($v['quantity'],";"));
|
|
|
+ $product_arr = explode(",",trim($v['product'],";"));
|
|
|
+ foreach($issku_arr as $key => $item){
|
|
|
+ $sku_list[] = [
|
|
|
+ 'sku'=>$item,
|
|
|
+ 'qty'=>isset($quantity_arr[$key])?$quantity_arr[$key]:1,
|
|
|
+ 'product_name'=>isset($product_arr[$key])?$product_arr[$key]:" ",
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $goods_list = [];
|
|
|
+ $fpdata_arr = explode(";",trim($v['quantity'],";"));
|
|
|
+ foreach($fpdata_arr as $key => $item){
|
|
|
+ $tmp_data = explode("|",$item);
|
|
|
+ $goods_list[] = [
|
|
|
+ 'goods_name'=>$tmp_data['1'],
|
|
|
+ 'qty'=>$tmp_data['2']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $ret_list[] = [
|
|
|
+ 'shop'=>$v['shop'],
|
|
|
+ 'orderinfo'=>$v['orderinfo'],
|
|
|
+ 'sku_list'=>$sku_list,
|
|
|
+ 'goods_list'=>$goods_list,
|
|
|
+ 'state'=>isset($typeclass[$v['state']])?$typeclass[$v['state']]['spare']:"",
|
|
|
+ 'dtime'=>date('Y-m-d',$v['dtime']),
|
|
|
+ 'name'=>$v['name'],
|
|
|
+ 'email'=>$v['email'],
|
|
|
+ 'shouldmoney'=>$v['shouldmoney'],
|
|
|
+ 'shipremarks'=>$v['shipremarks']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return $fdata;
|
|
|
+ }
|
|
|
+ public function _orderTbData(){
|
|
|
+ $fdata = $this->fullorder->find_all('id = 1201336','shop,orderinfo,issku,quantity,fpdata,state,product,name,email,dtime,shouldmoney,shipremarks','id desc');
|
|
|
+ $ret_list = [];
|
|
|
+ echo "<pre>";
|
|
|
+ foreach ($fdata as $k=>$v)
|
|
|
+ {
|
|
|
+ var_dump($v);
|
|
|
+ $sku_list = [];
|
|
|
+ $issku_arr = explode(",",trim($v['issku'],','));
|
|
|
+ $quantity_arr = explode(";",trim($v['quantity'],";"));
|
|
|
+ $product_arr = explode(",",trim($v['product'],";"));
|
|
|
+ foreach($issku_arr as $key => $item){
|
|
|
+ $sku_list[] = [
|
|
|
+ 'sku'=>$item,
|
|
|
+ 'qty'=>isset($quantity_arr[$key])?$quantity_arr[$key]:1,
|
|
|
+ 'product_name'=>isset($product_arr[$key])?$product_arr[$key]:"",
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $goods_list = [];
|
|
|
+ $fpdata_arr = explode(";",trim($v['fpdata'],";"));
|
|
|
+
|
|
|
+ foreach($fpdata_arr as $key => $item){
|
|
|
+ $tmp_data = explode("|",$item);
|
|
|
+ $goods_list[] = [
|
|
|
+ 'goods_name'=>$tmp_data['1'],
|
|
|
+ 'qty'=>$tmp_data['2']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $ret_list[] = [
|
|
|
+ 'shop'=>$v['shop'],
|
|
|
+ 'orderinfo'=>$v['orderinfo'],
|
|
|
+ 'sku_list'=>$sku_list,
|
|
|
+ 'goods_list'=>$goods_list,
|
|
|
+ 'state'=>isset($typeclass[$v['state']])?$typeclass[$v['state']]['spare']:"",
|
|
|
+ 'dtime'=>date('Y-m-d',$v['dtime']),
|
|
|
+ 'name'=>$v['name'],
|
|
|
+ 'email'=>$v['email'],
|
|
|
+ 'shouldmoney'=>$v['shouldmoney'],
|
|
|
+ 'shipremarks'=>$v['shipremarks']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ echo "<pre>";
|
|
|
+ var_dump($ret_list);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function sendHttp($url,$header,$list){
|
|
|
+ $ch = curl_init();
|
|
|
+ curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
|
+ curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
|
|
|
+ curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $list);
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
+ $res = curl_exec($ch);
|
|
|
+ $res = json_decode($res,true);
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|