StoreService.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\model\wechat;
  12. use app\admin\model\wechat\StoreServiceLog as ServiceLogModel;
  13. use app\admin\model\wechat\WechatUser;
  14. use traits\ModelTrait;
  15. use basic\ModelBasic;
  16. /**
  17. * 客服管理 model
  18. * Class StoreProduct
  19. * @package app\admin\model\store
  20. */
  21. class StoreService extends ModelBasic
  22. {
  23. use ModelTrait;
  24. /**
  25. * @return array
  26. */
  27. public static function getList($mer_id){
  28. return self::page(self::where('mer_id',$mer_id)->order('id desc'),function($item){
  29. $item['wx_name']=WechatUser::where(['uid'=>$item['uid']])->value('nickname');
  30. });
  31. }
  32. /**
  33. * @return array
  34. */
  35. public static function getChatUser($now_service,$mer_id){
  36. $where = 'mer_id = '.$mer_id.' AND (uid = '.$now_service["uid"].' OR to_uid='.$now_service["uid"].')';
  37. $chat_list = ServiceLogModel::field("uid,to_uid")->where($where)->group("uid,to_uid")->select();
  38. if(count($chat_list) > 0){
  39. $arr_user = $arr_to_user = [];
  40. foreach ($chat_list as $key => $value) {
  41. array_push($arr_user,$value["uid"]);
  42. array_push($arr_to_user,$value["to_uid"]);
  43. }
  44. $uids = array_merge($arr_user,$arr_to_user);
  45. $list = WechatUser::field("uid,nickname,headimgurl")->where(array("uid"=>array(array("in",$uids),array("neq",$now_service["uid"]))))->select();
  46. foreach ($list as $index => $user) {
  47. $service = self::field("uid,nickname,avatar as headimgurl")->where(array("uid"=>$user["uid"]))->find();
  48. if($service)$list[$index] = $service;
  49. }
  50. }else{
  51. $list = null;
  52. }
  53. return $list;
  54. }
  55. }