|
@@ -10,6 +10,7 @@ use App\Model\Employee;
|
|
|
use App\Model\FollowUpRecord;
|
|
|
use App\Model\Product;
|
|
|
use App\Model\SeeRange;
|
|
|
+use App\Model\WxEmployeeOfficial;
|
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
@@ -534,6 +535,10 @@ class CustomerService extends Service
|
|
|
->orWhereIn('id', $id);
|
|
|
}
|
|
|
if(! empty($data['id'])) $model->where('id', $data['id']);
|
|
|
+ if(! empty($data['customer_id'])){
|
|
|
+ $customer_id = explode(',',$data['customer_id']);
|
|
|
+ $model->whereIn('id', $customer_id);
|
|
|
+ }
|
|
|
if(! empty($data['my_fz']) || ! empty($data['my_xt'])){
|
|
|
$id = $this->getCustomerId($data,$user);
|
|
|
$model->whereIn('id',$id);
|
|
@@ -673,6 +678,10 @@ class CustomerService extends Service
|
|
|
->select('title','id','model_type','customer_intention','customer_from','customer_type','car_type','consulting_product','intention_product','progress_stage','address1','address2','crt_id','crt_time','mark','importance','company','company_short_name','depart_id','state_type','customer_state','pond_state','top_depart_id','fp_time','fp_top_depart_id','enter_time')
|
|
|
->orderby('fp_time', 'desc');
|
|
|
|
|
|
+ if(! empty($data['customer_id'])){
|
|
|
+ $customer_id = explode(',',$data['customer_id']);
|
|
|
+ $model->whereIn('id', $customer_id);
|
|
|
+ }
|
|
|
if(! empty($data['my_fz']) || ! empty($data['my_xt'])){
|
|
|
$id = $this->getCustomerId($data,$user);
|
|
|
$model->whereIn('id',$id);
|
|
@@ -1215,23 +1224,9 @@ class CustomerService extends Service
|
|
|
list($status,$msg) = $this->customerSendWxRule($data);
|
|
|
if(! $status) return [false,$msg];
|
|
|
|
|
|
- try {
|
|
|
- DB::beginTransaction();
|
|
|
- $time = time();
|
|
|
-
|
|
|
- $insert = [];
|
|
|
-
|
|
|
- //负责人获取 改为前负责人
|
|
|
- $man = CustomerInfo::where('del_time',0)
|
|
|
- ->where('customer_id',$data['customer_id'])
|
|
|
- ->where('type', CustomerInfo::type_two)
|
|
|
- ->get()->toArray();
|
|
|
-
|
|
|
- DB::commit();
|
|
|
- }catch (\Exception $exception){
|
|
|
- DB::rollBack();
|
|
|
- return [false,$exception->getMessage()];
|
|
|
- }
|
|
|
+ //发送消息
|
|
|
+ $send_data = $msg;
|
|
|
+ (new OaService())->sendWxOaCheckMessage($send_data);
|
|
|
|
|
|
return [true, ''];
|
|
|
}
|
|
@@ -1243,13 +1238,52 @@ class CustomerService extends Service
|
|
|
->whereIn('id',$data['id'])
|
|
|
->get()->toArray();
|
|
|
if(empty($customer)) return [false,'客户不存在或已被删除'];
|
|
|
- $map = array_column($customer,'title', 'id');
|
|
|
|
|
|
$man = CustomerInfo::where('del_time',0)
|
|
|
- ->where('customer_id',$data['customer_id'])
|
|
|
+ ->whereIn('customer_id',$data['id'])
|
|
|
->where('type', CustomerInfo::type_two)
|
|
|
->get()->toArray();
|
|
|
+ if(empty($man)) return [true, '客户暂无负责人信息,公众号消息发送结束'];
|
|
|
+ $customer_map = [];
|
|
|
+ foreach ($man as $value){
|
|
|
+ $customer_map[$value['data_id']][] = $value['customer_id'];
|
|
|
+ }
|
|
|
+ $employee_id = array_unique(array_column($man,'data_id'));
|
|
|
|
|
|
- return [true,''];
|
|
|
+ $wx_map = WxEmployeeOfficial::whereIn('employee_id', $employee_id)
|
|
|
+ ->pluck('openid','employee_id')
|
|
|
+ ->toArray();
|
|
|
+ $emp = Employee::whereIn('id', $employee_id)
|
|
|
+ ->pluck('emp_name','id')
|
|
|
+ ->toArray();
|
|
|
+ $send_data = [];
|
|
|
+ foreach ($employee_id as $value){
|
|
|
+ $tmp = $emp[$value] ?? "";
|
|
|
+ $open_id = $wx_map[$value] ?? "";
|
|
|
+// if(empty($open_id)) return [false, $tmp . "暂未关注微信公众号,公众号消息发送失败"];
|
|
|
+ if(empty($open_id)) continue;
|
|
|
+
|
|
|
+ $customer_id = $customer_map[$value] ?? [];
|
|
|
+ $customer_id = implode(',', $customer_id);
|
|
|
+
|
|
|
+ //提醒创建人
|
|
|
+ $send_data[] = [
|
|
|
+ 'employee_id' => $value,
|
|
|
+ 'type' => 2,
|
|
|
+ 'state' => 0,
|
|
|
+ 'menu_id' => "16|list",
|
|
|
+ 'openid' => $open_id,
|
|
|
+ 'order_number' => $customer_id,
|
|
|
+ 'tmp_data' => [
|
|
|
+ time(),
|
|
|
+ "客户消息提醒",
|
|
|
+ "已发送",
|
|
|
+ $tmp,
|
|
|
+ date('Y-m-d H:i:s'),
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, $send_data];
|
|
|
}
|
|
|
}
|