|
@@ -16,6 +16,7 @@ class Apipf extends Start_Controller{
|
|
private $key = "bpng!pjgirv6amnfr"; //加密所需要到的key
|
|
private $key = "bpng!pjgirv6amnfr"; //加密所需要到的key
|
|
private $iv = "k4k!94m66oojtm2w";//加密所需要到的iv
|
|
private $iv = "k4k!94m66oojtm2w";//加密所需要到的iv
|
|
private $api = "202503121009@ly";
|
|
private $api = "202503121009@ly";
|
|
|
|
+ private $filter_words = ['bonus','flashsale','clearance','giftpack'];
|
|
|
|
|
|
//定义方法的调用规则 获取URI第二段值
|
|
//定义方法的调用规则 获取URI第二段值
|
|
public function _remap($arg,$arg_array)
|
|
public function _remap($arg,$arg_array)
|
|
@@ -24,9 +25,9 @@ class Apipf extends Start_Controller{
|
|
{
|
|
{
|
|
$this->_checkMoreThree();
|
|
$this->_checkMoreThree();
|
|
}
|
|
}
|
|
- elseif($arg == 'customerData')
|
|
|
|
|
|
+ elseif($arg == 'customer_all_data')
|
|
{
|
|
{
|
|
- $this->_customerData();
|
|
|
|
|
|
+ $this->_customerAllTbData();
|
|
}
|
|
}
|
|
elseif($arg == 'orderTbAllData')
|
|
elseif($arg == 'orderTbAllData')
|
|
{
|
|
{
|
|
@@ -63,38 +64,181 @@ class Apipf extends Start_Controller{
|
|
/***
|
|
/***
|
|
* 上传没有给批发站没有传递的客户信息
|
|
* 上传没有给批发站没有传递的客户信息
|
|
*/
|
|
*/
|
|
- public function _customerData(){
|
|
|
|
|
|
+ public function _customerAllTbData(){
|
|
|
|
+ $api = $this->input->get('api',true);
|
|
|
|
+ if($api != $this->api){
|
|
|
|
+ die("No data to be executed");
|
|
|
|
+ }
|
|
$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 = $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 = [];
|
|
$send_list = [];
|
|
foreach($list as $k=>$v){
|
|
foreach($list as $k=>$v){
|
|
- $list_ids[] = $v['id'];
|
|
|
|
|
|
+ $orderinfo = $this->getOrderList($v['email'],$v['shop'],1);
|
|
$send_list[] = [
|
|
$send_list[] = [
|
|
|
|
+ 'customer_id'=>$v['id'],
|
|
'name'=>$v['name'],
|
|
'name'=>$v['name'],
|
|
'email'=>$v['email'],
|
|
'email'=>$v['email'],
|
|
'telephone'=>$v['phone'],
|
|
'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']
|
|
|
|
|
|
+ 'ordered_mount'=>$orderinfo['order_mount'],
|
|
|
|
+ 'ordered_num'=>$orderinfo['order_num'],
|
|
|
|
+ 'ordered_qty'=>$orderinfo['order_qty'],
|
|
|
|
+ // 'country'=>$v['country'],
|
|
|
|
+ // 'province'=>$v['province'],
|
|
|
|
+ // 'city'=>$v['city'],
|
|
|
|
+ // 'street'=>$v['street'],
|
|
|
|
+ // 'address'=>$v['address'].$v['address2'],
|
|
|
|
+ // 'zipcode'=>$v['zipcode']
|
|
|
|
+ 'orders'=>$orderinfo['orders'],
|
|
];
|
|
];
|
|
}
|
|
}
|
|
- $header = [];
|
|
|
|
- $url = "";
|
|
|
|
|
|
+
|
|
if(empty($send_list)){
|
|
if(empty($send_list)){
|
|
die("There is no customer data to be synchronized");
|
|
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).")");
|
|
|
|
|
|
+ $header = [];
|
|
|
|
+ $url = "";
|
|
|
|
+ foreach($send_list as $item){
|
|
|
|
+ // $res = $this->sendHttp($url,$header,$item);
|
|
|
|
+ // if($res){
|
|
|
|
+ // $this->customer->save([
|
|
|
|
+ // 'more_three'=>3,
|
|
|
|
+ // 'is_tb'=>1,
|
|
|
|
+ // ],$item['customer_id']);
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+ // die("update crowd_customer set more_three = 2 where id in (".implode(",",$list_ids).")");
|
|
|
|
+ // $this->db->query("update crowd_customer set more_three = 3,is_tb = 1 where id in (".implode(",",$list_ids).")");
|
|
// $res = $this->sendHttp($url,$header,$send_list);
|
|
// $res = $this->sendHttp($url,$header,$send_list);
|
|
// if($res){
|
|
// if($res){
|
|
- // $this->db->query("update crowd_customer set more_three = 2 where id in (".implode(",",$list_ids).")");
|
|
|
|
|
|
+ // $this->db->query("update crowd_customer set more_three = 3,is_tb = 1 where id in (".implode(",",$list_ids).")");
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * $email 邮箱
|
|
|
|
+ * $shop 店铺id
|
|
|
|
+ * $type 1 获取全部订单列表 2 只获取昨天新增的订单列表 一般在凌晨1点执行
|
|
|
|
+ */
|
|
|
|
+ //要求订单必须为线下单,并且为processing或complete
|
|
|
|
+ public function getOrderList($email,$shop,$type = 2){
|
|
|
|
+ $fdata = $this->fullorder->find_all('email = "'.$email.'" and shop = "'.$shop.'" and source in (2,3) and state in (207,216) ','shop,orderinfo,issku,quantity,fpdata,state,product,name,email,dtime,shouldmoney,shipremarks,librarytime','id desc');
|
|
|
|
+ $ret_list = [];
|
|
|
|
+ $order_mount = 0;//订单总金额
|
|
|
|
+ $order_num = 0;//下单次数
|
|
|
|
+ $order_qty = 0;//订单产品总数
|
|
|
|
+ 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'],";"));
|
|
|
|
+ $tmp_type = 0;
|
|
|
|
+ $tmp_qty = 0;
|
|
|
|
+ $jisuan_qty = 0;//需要更新的产品的总数量上
|
|
|
|
+ //货物的种类按照订单的原始sku种类 数量也是
|
|
|
|
+ foreach($issku_arr as $key => $item){
|
|
|
|
+ foreach($this->filter_words as $v){
|
|
|
|
+ //判断sku中是否有这种东西
|
|
|
|
+ if (strpos(strtolower($item),$v ) === false) {
|
|
|
|
+ $tmp_type++;
|
|
|
|
+ if(isset($quantity_arr[$key])){
|
|
|
|
+ $tmp_qty = $quantity_arr[$key] + $tmp_qty;
|
|
|
|
+ }else{
|
|
|
|
+ $tmp_qty = $tmp_qty + 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(isset($quantity_arr[$key])){
|
|
|
|
+ $jisuan_qty = $quantity_arr[$key]*1 + $jisuan_qty;
|
|
|
|
+ }else{
|
|
|
|
+ $jisuan_qty = $jisuan_qty + 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $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'],";"));
|
|
|
|
+ if(!empty($tmp_data[1])){
|
|
|
|
+ foreach($fpdata_arr as $key => $item){
|
|
|
|
+
|
|
|
|
+ $tmp_data = explode("|",$item);
|
|
|
|
+ $goods_list[] = [
|
|
|
|
+ 'goods_name'=>$tmp_data[1],
|
|
|
|
+ 'qty'=>$tmp_data[2]
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //如果产品种类少于2种 且产品数量也小于2 直接排除
|
|
|
|
+ if(($tmp_type <2) && ($tmp_qty < 2)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ $order_mount = $order_mount +$v['shouldmoney']*1;//订单总金额
|
|
|
|
+ $order_num++;//下单次数
|
|
|
|
+ $order_qty = $order_qty + $jisuan_qty;//订单产品总数
|
|
|
|
+
|
|
|
|
+ if($type == 1){
|
|
|
|
+ $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']
|
|
|
|
+ ];
|
|
|
|
+ }else{
|
|
|
|
+ $end_time = strtotime(date("Y-m-d"));
|
|
|
|
+ $start_time = $end_time - 24* 60 *60;
|
|
|
|
+ //这里只按照出库时间算
|
|
|
|
+ if(($v['librarytime'] >= $start_time)&&($v['librarytime'] < $end_time)){
|
|
|
|
+ $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']
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ $final_list = [];
|
|
|
|
+ foreach($ret_list as $k=>$v){
|
|
|
|
+ $final_list[] = [
|
|
|
|
+ 'shop'=>$v['shop'],
|
|
|
|
+ 'orderinfo'=>$v['orderinfo'],
|
|
|
|
+ 'status'=>$v['state'],
|
|
|
|
+ 'grand_total'=>$v['shouldmoney'],
|
|
|
|
+ 'order_created'=>$v['dtime'],
|
|
|
|
+ 'product_name'=>array_column($sku_list,'product_name'),
|
|
|
|
+ 'sku'=>array_column($sku_list,'sku'),
|
|
|
|
+ 'erp_goods_name'=>array_column($goods_list,'goods_name'),
|
|
|
|
+ 'qty'=>array_column($sku_list,'qty'),
|
|
|
|
+ //'price'=>$v['shouldmoney'],
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ return [
|
|
|
|
+ 'ordered_mount'=>$order_mount,
|
|
|
|
+ 'order_num'=>$order_num,
|
|
|
|
+ 'order_qty'=>$order_qty,
|
|
|
|
+ 'orders'=>$final_list,
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
public function _orderTbAllData(){
|
|
public function _orderTbAllData(){
|
|
$typeclass = $this->typeclass->find_all("classid = 29","id,classtitle,title,spare");
|
|
$typeclass = $this->typeclass->find_all("classid = 29","id,classtitle,title,spare");
|
|
$typeclass = array_column($typeclass,null,'id');
|
|
$typeclass = array_column($typeclass,null,'id');
|