lvhao před 1 dnem
rodič
revize
b04e657df8

+ 106 - 26
core/CoreApp/controllers/Sdzxlist.php

@@ -3,7 +3,9 @@ class Sdzxlist extends Start_Controller {
 	public function __construct(){
 		parent::__construct();
 		$this->load->library('session');
+        $this->load->model('Model_shop','shop');
 		$this->load->_model('Model_sdzxlist','sdzxlist');
+        $this->load->_model('Model_apitt','apitt');
 	}
 
     //定义方法的调用规则 获取URI第二段值
@@ -11,6 +13,12 @@ class Sdzxlist extends Start_Controller {
     {
         if($arg == 'index'){
             $this->_index();
+        }elseif($arg == 'edit'){
+            $this->_edit($arg_array);
+        }elseif($arg == 'delsc'){
+            $this->_delsc();
+        }elseif($arg == 'zczxttznx'){
+            $this->_zczxttznx();
         }else{
             exit('No direct script access allowed');
         }
@@ -20,29 +28,23 @@ class Sdzxlist extends Start_Controller {
         if($this->input->method() == 'post'){
             $page = $this->input->post('page',true);
 		    $perpage = $this->input->post('perpage',true);
-            $sqr = $this->input->post('sqr',true);
-            $sqr = trim($sqr);
-            $shop_id = $this->input->post('shop_id',true);
-            $plat_id = $this->input->post('plat_id',true);
-            $shop_ids = $this->input->post('shop_ids',true);
+            $shop = $this->input->post('shop_id',true);
             $ktime = $this->input->post('ktime',true);
             $jtime = $this->input->post('jtime',true);
             $ktime = strtotime($ktime);
             $jtime = strtotime($jtime);
 
-            $where = "add_time >= ".$ktime."  and add_time  < ".$jtime." ";
+            $where = "create_time >= ".$ktime."  and create_time  < ".$jtime." ";
 
-            if(!empty($sqr)){
-                $where .= " and sqr = ".$sqr." ";
-            }
-            if(!empty($shop_id)){
-                $where .= " and shop_id = ".$shop_id." ";
+           
+            if(!empty($shop)){
+                $where .= " and shop_id = ".$shop." ";
             }else{
-                $where .= " and shop_id in (".$shop_ids.") ";
-            }
-            if(!empty($plat_id)){
-                $where .= " and plat_id = ".$plat_id." ";
+               
+
+                //$where .= " and shop_id in (".$shop_ids.") ";
             }
+
             //数据排序
             $order_str = "id desc";
             if(empty($page))
@@ -55,32 +57,110 @@ class Sdzxlist extends Start_Controller {
                 $start = ($page - 1)*$perpage;
             }
 
-            //$list = $this->bhsq->find_all($where,"id,shop_id,plat_id,title,sku,sqr,sq_num,sq_status,add_time,update_time",$order_str,$start,$perpage);
-            $list = [];
-
+            $list = $this->sdzxlist->find_all($where,"id,shop,number,type,status,err_desc,create_time,update_time",$order_str,$start,$perpage);
             if(empty($list)){
                 $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
                 echo json_encode($rows);exit;
             }
-            $shop_list = $this->shop->find_all("1=1","id,shopname");
-            $shop_list = array_column($shop_list,'shopname','id');
-            $plat_list = $this->typeclass->find_all("classid = 32","id,title");
-            $plat_list = array_column($plat_list,'title','id');
-            $status_list = $this->bhsq->getSqStatus();
+            $type_list = $this->sdzxlist->getType();
+            $status_list = $this->sdzxlist->getStatus();
+            $shop_list = $this->shop->find_all("type = 1514");
+            $shop_id_list = array_column($shop_list,'shopname','id');
             foreach($list as $k=>$v){
-               
-                $list[$k]['update_time'] = "";
+                $list[$k]['type'] = isset($type_list[$v['type']]) ? $type_list[$v['type']] : '无';
+                $list[$k]['status'] = isset($status_list[$v['status']]) ? $status_list[$v['status']] : '无';
+                $list[$k]['shop'] = isset($shop_id_list[$v['shop']]) ? $shop_id_list[$v['shop']] : ' ';
+                $list[$k]['create_time'] = empty($v['create_time']) ? "" : date("Y-m-d H:i",$v['create_time']);
+                $operate_str = "";
+                if(empty($v['status'])){
+                   $operate_str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #1E90FF;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."'  onclick='do_again(this)'>重发</a>";
+                }
+                $operate_str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #DC143C;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."'  onclick='del(this)'>删除</a>";
+                $list[$k]['update_time'] = $operate_str;
             }
 
 
-            $total = $this->bhsq->find_count($where);
+            $total = $this->sdzxlist->find_count($where);
 		    $pagenum = ceil($total/$perpage);
 		    $over = $total-($start+$perpage);
             $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
 		    echo json_encode($rows);exit;
 
         }else{
+            $user = $this->user->get_api($_SESSION['api']);
+            $usersp = explode('|',trim($user['shop'],'|'));
+           
+            $shop_tt_list = $this->shop->find_all("type = 1514");
+            $shop_tt_ids = array_column($shop_tt_list,'id');
+
+            $shop_allow_ids = array_intersect($usersp, $shop_tt_ids);
+            
+            $this->data['usersp'] = implode(",",$shop_allow_ids);
+
             $this->_Template('sdzxlist_index',$this->data);
         }
     }
+
+    private function _edit($arg_array){
+        if($this->input->method() == 'post'){
+            exit("no post");
+        }else{
+            $id = $arg_array[0];
+            $info = $this->sdzxlist->read($id);
+            $shop = $this->shop->read($info['shop']);
+            $info['shopname'] = $shop['shopname'];
+            $info['cont'] = json_decode($info['cont'],true);
+            $this->data['info'] = $info;
+            $this->_Template('sdzxlist_edit',$this->data);
+        }
+    }
+
+    private function _delsc(){
+        if($this->input->method() == 'post'){
+            $id = $this->input->post('id');
+            $info = $this->sdzxlist->read($id);
+            if(empty($info)){
+                echo json_encode([
+                'code'=>-1,
+                'msg'=>'数据不存在'
+                ],JSON_UNESCAPED_UNICODE);
+                exit;
+            }
+            $id = (int)$id;
+            $this->sdzxlist->remove($id);
+            echo json_encode([
+               'code'=>1,
+               'msg'=>'执行成功'
+            ],JSON_UNESCAPED_UNICODE);
+            exit;
+        }else{
+            echo json_encode([
+               'code'=>1,
+               'msg'=>'执行成功'
+            ],JSON_UNESCAPED_UNICODE);
+            exit;
+        }
+
+    }
+
+
+    private function _zczxttznx(){
+        if($this->input->method() == 'post'){
+            $id = $this->input->post('id');
+            $info = $this->sdzxlist->read($id);
+            $params = json_decode($info['cont'],true);
+            $shop = $this->shop->read($info['shop']);
+            $list = [];
+            $list['user_id'] = $params['post']['buyer_user_id'];
+            $res = $this->apitt->openZnxWindow($list,$shop);
+            echo "<pre>";
+            var_dump($res);
+            die;
+        }else{
+            echo json_encode([
+              'code'=>-1,
+              'msg'=>'执行失败'
+            ]);exit;
+        }
+    }
 }

+ 43 - 0
core/CoreApp/models/Model_apitt.php

@@ -729,4 +729,47 @@ function __construct(){
         return $result;
 	}
 
+	/**
+	 * 打开站内信的聊天资源说明
+	 */
+	public function openZnxWindow($list,$shop){
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/customer_service/202309/conversations';
+		$time = time();
+		$post['buyer_user_id'] = $list['user_id'];
+		$queryParams['shop_cipher'] =$shop['shop_cipher'];
+		//$queryParams['shop_id'] =$shop['codeid'];
+		$queryParams['app_key'] =$shop['app_key'];
+		$queryParams['timestamp'] =$time;
+		$link .= '?'.http_build_query($queryParams);
+		$sign = $this->apitt->sign($link,$shop['app_secret'],$post);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
+		$res = $this->apitt->su_curl($post,$url,$headers);
+		$res = json_decode($res,true);
+		return $res;
+	}
+
+	public function sendZnxMessage($shop,$notice,$conversation_id){
+		$url = 'https://open-api.tiktokglobalshop.com';
+		$link = '/customer_service/202309/conversations/'.$conversation_id.'/messages';
+		$time = time();
+		$notice = str_replace('</p>','\n',$notice);
+		$post['type'] = 'TEXT';
+		$post['content'] = '{"content": "'.strip_tags($notice).'"}';
+		//$queryParams['access_token'] = $shop['token'];
+		$queryParams['shop_cipher'] = $shop['shop_cipher'];
+		$queryParams['shop_id'] = $shop['codeid'];
+		$queryParams['app_key'] = $shop['app_key'];
+		$queryParams['version'] = '202309';
+		$queryParams['timestamp'] =$time;
+		$link .= '?'.http_build_query($queryParams);
+		$sign = $this->apitt->sign($link,$shop['app_secret'],$post);
+		$url .= $link.'&sign='.$sign;
+		$headers = array('Content-Type: application/json','x-tts-access-token:'.$shop['token']);
+		$res = $this->apitt->su_curl($post,$url,$headers);
+		$res = json_decode($res,true);
+		return $res;
+	}
+
 }  //end class

+ 25 - 0
template/erp/sdzxlist_edit.html

@@ -0,0 +1,25 @@
+{Template header}
+<body>
+<div class="warp">
+<div class="title winnone">信息展示</div>
+<ul class="setting">
+
+<li class = "length">
+<em>店铺名字:</em>
+{$info['shopname']}
+</select>
+</li>
+<li  class = "length">
+<em>发送信息:</em>
+    <iframe srcdoc="{htmlspecialchars($info['cont']['content'], ENT_QUOTES, 'UTF-8')}" style="width:100%;height:90vh;border:1px solid #ddd;margin-top:5px;" sandbox="allow-same-origin"></iframe>
+</li>
+
+<div style="clear:both;"></div>
+</ul>
+<input  type="hidden" name="id" value="{$shop['id']}" />
+<div class="button"><font class="fh">关 闭</font></div>
+</div>
+<script>var addedit="/shop/edit/";var rowsurl="/shop/rows/";
+
+</script>
+{Template footer}

+ 61 - 8
template/erp/sdzxlist_index.html

@@ -50,9 +50,17 @@
         <select name="shop" class="select" style="width:190px">
             <option value="">请选择</option>
             {loop usershop() as $val}
+            {if ($val['type'] == 1514)}
             <option value="{$val['id']}">{$val['shopname']}</option>
+            {/if}
             {/loop}</select>
     </div>
+
+    <div  class="diysearch">
+        记录时间:<input id="timetk" style="width:200px" value="{date('Y-m-d',time()-29*24*3600)} 0:00" name="ktime" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})">
+        至&nbsp;&nbsp;&nbsp;&nbsp; <input id="timetj" style="width:200px"  value="{date('Y-m-d',time()+24*3600)} 0:00" name="jtime" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})">
+        <input type="hidden" name="shop_ids" value="{$usersp}">
+    </div>
    
 
     <div  class="diysearch">
@@ -69,6 +77,7 @@
 <td><label onClick="swapCheck()"><input name="checkbox" type="checkbox" class="regular-checkbox"></label></td>
 <td>店铺名字</td>
 <td>订单号</td>
+<td>类型</td>
 <td>状态</td>
 <td>错误原因</td>
 <td>记录时间</td>
@@ -85,7 +94,7 @@
 var dataurl = "/sdzxlist/index";
 var editurl = "/sdzxlist/edit/";
 var editpx = "/sdzxlist/pxsort"
-var editdj = 3;
+var editdj = 2;
 var editt = "店铺管理 - 修改";
 var customon = 1;
 function custom(){
@@ -93,23 +102,20 @@ $(".data tr").each(function() {
     $(this).find('td:eq(0)').css("width","1%");
     $(this).find('td:eq(1)').css("width","6%");
     $(this).find('td:eq(2)').css("width","6%");
-    $(this).find('td:eq(3)').css("width","12%");
+    $(this).find('td:eq(3)').css("width","6%");
     $(this).find('td:eq(4)').css("width","6%");
-    $(this).find('td:eq(5)').css("width","6%");
+    $(this).find('td:eq(5)').css("width","25%");
     $(this).find('td:eq(6)').css("width","6%");
     $(this).find('td:eq(7)').css("width","12%");
     $(this).find('td:eq(8)').css("width","6%");
-    $(this).find('td:eq(9)').css("width","6%");
-    $(this).find('td:eq(10)').css("width","6%");
-    $(this).find('td:eq(11)').css("width","6%");
-    $(this).find('td:eq(12)').css("width","20%");
+  
    
 
 // $(this).find('td:eq(11)').css("width","5%");
 });
 }
 
-
+$(function () { $("#ktime").calendar();$("#jtime").calendar();});
 
 function edit_px(that){
    
@@ -134,5 +140,52 @@ $(document).ready(function(){
    
 })
 
+function do_again(that){
+    let do_id = $(that).data('id')
+    layx.confirm('提示','确定要重发吗?',null,{
+        buttons:[
+            {
+                label:'确定',
+                callback:function(id, button, event){
+                    chongfa(do_id)
+                    layx.destroy(id);
+                }
+            },
+            {
+                label:'取消',
+                callback:function(id, button, event){
+                    layx.destroy(id);
+                }
+            }
+        ]
+    });
+}
+function chongfa(do_id){
+    $.post("/sdzxlist/zczxttznx",{id:do_id},function(res){
+        console.log(res);
+        if(res.code==1){
+            searchspan(1);
+        }else{
+            layx.alert('重发失败');
+        }
+    },"json");
+}
+
+function  del(that){
+    let id = $(that).data('id')
+    layx.load('loadId','请求中。。。',{shadable:0.6});
+    $.post("/sdzxlist/delsc",{id:id},function(res){
+        console.log(res);
+        layx.destroy('loadId');
+        if(res.code==1){
+            searchspan(1);
+        }else{
+            layx.alert('删除失败');
+        }
+    },"json");
+}
+
 </script>
+
+<script type="text/javascript" src="{$theme}js/laydate.js"></script>
 {Template footer}