chenhao 4 years ago
parent
commit
a1a1f54ecf

+ 23 - 2
application/admin/controller/Customer.php

@@ -8,6 +8,8 @@ use app\admin\model\RankingModel;
 use app\admin\model\Types;
 use app\admin\model\UserModel;
 use think\Db;
+use think\Exception;
+use think\exception\ErrorException;
 use think\Request;
 
 class Customer extends Base
@@ -213,7 +215,7 @@ class Customer extends Base
                             $query->whereOr('company',$company);
                         })
                         ->column('id');
-//                    Db::name('customer')->where('id','in',implode(',',$res))->update(['spread_id' => $param['id'], 'status' => 2, 'follow_time' => time()]);
+                    Db::name('customer')->where('id','in',implode(',',$res))->update(['spread_id' => $param['id'], 'status' => 2, 'follow_time' => time()]);
                 } else {
                     $res = CustomerModel::where(function ($query) use ($websiteArr) {
                         foreach ($websiteArr as $v) {
@@ -222,7 +224,7 @@ class Customer extends Base
                     })
                     ->column('id');
 //                    var_dump($res);
-//                    Db::name('customer')->where('id', 'in', implode(',', $res))->update(['spread_id' => $param['id'], 'status' => 2, 'follow_time' => time()]);
+                    Db::name('customer')->where('id', 'in', implode(',', $res))->update(['spread_id' => $param['id'], 'status' => 2, 'follow_time' => time()]);
                 }
                 unset($websiteArr);
                 $ranking = new RankingModel();
@@ -427,6 +429,8 @@ class Customer extends Base
             ->whereOr('a.groupid','5')
             ->field('d.id,d.name')
             ->select();
+        $country = Db::name('countries')->select();
+        $this->assign('countrires',$country);
         $this->assign('type', $typrData);
         return $this->fetch('customer/admin/see');
     }
@@ -1946,4 +1950,21 @@ class Customer extends Base
         $res = $costomer->caozuo_update($param);
         return $res;
     }
+
+    public function customerDel()
+    {
+        $data = $this->request->param();
+        if(!isset($data['id']) || empty($data['id'])) return json(['code' => 100, 'msg' =>'服务错误']);
+        try {
+            Db::startTrans();
+            Db::name('customer')->where('id',$data['id'])->delete();
+            Db::name('ranking')->where('c_id',$data['id'])->delete();
+            Db::commit();
+        } catch (Exception $e) {
+            Db::rollback();
+            $this->error($e);
+            return json(['code' =>100 ,'msg' => '删除失败']);
+        }
+        return json(['code' => 200, 'msg' => '删除成功']);
+    }
 }

+ 9 - 1
application/admin/model/CustomerModel.php

@@ -232,6 +232,14 @@ class CustomerModel extends Model
                 $msg = '修改成功!';
             }
         }
+        if (isset($param['country'])){
+            $upd_company = $this->where('id',$param['id'])->update(['country' => $param['country']]);
+            if ($upd_company) {
+                writelog('操作员'.session('nickname').'修改了客户'.$customer['name'].'的国家',200);
+                $status = 200;
+                $msg = '修改成功!';
+            }
+        }
         if (isset($param['website'])){
             $upd_website = $this->where('id',$param['id'])->update(['website' => $param['website']]);
             if ($upd_website) {
@@ -297,7 +305,7 @@ class CustomerModel extends Model
      */
     public function getStatusAttr($value)
     {
-        $arr = ['0'=>'未联系',1=>'已联系',2=>'已成交',3=>'关联中'];
+        $arr = ['0'=>'未建交客户',1=>'已联系',2=>'已成交',3=>'关联中'];
         return $arr[$value];
     }
 

+ 1 - 1
application/admin/view/customer/admin/admin_user_index.html

@@ -163,7 +163,7 @@
             <!--操作模板-->
             <script type="text/html" id="opeBar">
 
-<!--                <a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('userDel')}')">删除</i></a>-->
+                <a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('customerDel')}')">删除</i></a>
 
                 <a class="layui-btn layui-btn-xs layui-bg-gray" title="查看" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i></a>
             </script>

+ 1 - 1
application/admin/view/customer/admin/admin_user_index_1.html

@@ -151,7 +151,7 @@
 				<!--操作模板-->
 				<script type="text/html" id="opeBar">
 
-					<!--                <a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('userDel')}')">删除</i></a>-->
+					<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('customerDel')}')">删除</i></a>
 
 					<a class="layui-btn layui-btn-xs layui-btn-normal" title="查看" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i>
 					</a>

+ 1 - 1
application/admin/view/customer/admin/admin_user_index_2.html

@@ -149,7 +149,7 @@
             <!--操作模板-->
             <script type="text/html" id="opeBar">
 
-                <!--                <a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('userDel')}')">删除</i></a>-->
+				<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('customerDel')}')">删除</i></a>
 
                 <a class="layui-btn layui-btn-xs layui-bg-gray" title="" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i></a>
             </script>

+ 1 - 1
application/admin/view/customer/admin/admin_user_index_3.html

@@ -150,7 +150,7 @@
             <!--操作模板-->
             <script type="text/html" id="opeBar">
 
-                <!--                <a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('userDel')}')">删除</i></a>-->
+				<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('customerDel')}')">删除</i></a>
 
                 <a class="layui-btn layui-btn-xs layui-bg-gray" title="" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i></a>
             </script>

+ 1 - 1
application/admin/view/customer/admin/admin_user_index_4.html

@@ -161,7 +161,7 @@
             <!--操作模板-->
             <script type="text/html" id="opeBar">
 
-                <!--                <a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('userDel')}')">删除</i></a>-->
+				<a class="layui-btn layui-btn-danger layui-btn-xs layui-bg-gray" title="删除" onclick="wk.confirm('{{d.id}}','{:url('customerDel')}')">删除</i></a>
 
                 <a class="layui-btn layui-btn-xs layui-bg-gray" title="查看" onclick="wk.layer_show('','{:url('see')}?id={{d.id}}')">查看</i></a>
             </script>

+ 25 - 6
application/admin/view/customer/admin/see.html

@@ -6,14 +6,14 @@
             <div class="layui-row layui-col-space10 layui-form-item ">
                 {if $groupid == 5}
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
-                    <label class="layui-form-label"><strong>用户名:</strong></label>
+                    <label class="layui-form-label"><strong>联系人:</strong></label>
                     <div class="layui-input-block">
-                        <input type="text" name="name"  placeholder="请输入用户名" class="layui-input " value="{$see.name}">
+                        <input type="text" name="name"  placeholder="客户联系人姓名" class="layui-input " value="{$see.name}">
                     </div>
                 </div>
                 {else}
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
-                    <label class="layui-form-label"><strong>用户名:</strong></label>
+                    <label class="layui-form-label"><strong>联系人:</strong></label>
                     <div class="layui-input-block">
                         <div style="margin-top: 1%"><strong>{$see.name}</strong></div>
                     </div>
@@ -48,13 +48,32 @@
                     </div>
                 </div>
                 {/if}
+<!--                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
+<!--                    <label class="layui-form-label"><strong>国家:</strong></label>-->
+<!--                    <div class="layui-input-block">-->
+<!--                        <div style="margin-top: 1%"><strong>{$see.c_name}</strong></div>-->
+<!--                    </div>-->
+<!--                </div>-->
+                {if $groupid == 5}
+                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
+                    <label class="layui-form-label"><strong>国家:</strong></label>
+                    <div class="layui-input-block">
+<!--                        <div style="margin-top: 1%"><strong>{$see.c_name}</strong></div>-->
+                        <select name="country">
+                            {foreach name='countrires' item='vo'}
+                                  <option value="{$vo.id}" {if $see.country== $vo.id} selected {/if}>{$vo.country}</option>
+                            {/foreach}
+                        </select>
+                    </div>
+                </div>
+                {else}
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                     <label class="layui-form-label"><strong>国家:</strong></label>
                     <div class="layui-input-block">
                         <div style="margin-top: 1%"><strong>{$see.c_name}</strong></div>
                     </div>
                 </div>
-
+                {/if}
                 {if $groupid == 5}
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                     <label class="layui-form-label"><strong>公司:</strong></label>
@@ -101,7 +120,7 @@
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                     <label class="layui-form-label"><strong>行业:</strong></label>
                     <div class="layui-input-block">
-                        <div style="margin-top: 1%"><strong>{$see.type}</strong></div>
+<!--                        <div style="margin-top: 1%"><strong>{$see.type}</strong></div>-->
                         {foreach name="type" item="vo"}
                         <input type="checkbox" name="type[]" lay-filter="like" title="{$vo.name}" value="{$vo.id}" {foreach name="typeid" item="v"} {if $vo.id==$v} checked {/if} {/foreach}>
                         {/foreach}
@@ -110,7 +129,7 @@
                 <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                     <label class="layui-form-label"><strong>主营产品:</strong></label>
                     <div class="layui-input-block">
-                        <div style="margin-top: 1%"><strong>{$see.product}</strong></div>
+<!--                        <div style="margin-top: 1%"><strong>{$see.product}</strong></div>-->
                         {foreach name="product" item="vo"}
                         <input type="checkbox" name="product[]" lay-filter="like" title="{$vo.product_name}" value="{$vo.id}" {foreach name="productid" item="v"} {if $vo.id ==$v} checked {/if} {/foreach}>
                         {/foreach}