ContactWay.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php namespace App\Servers\WechatWork;
  2. /**
  3. * 联系方式 联系我
  4. *
  5. */
  6. class ContactWay extends Work {
  7. /**
  8. * 获取列表
  9. *
  10. * @param string $cursor 分页查询使用的游标,为上次请求返回的 next_cursor
  11. * @param int $limit 每页条数
  12. */
  13. public function getList($cursor,$limit=10){
  14. // 获取部门列表
  15. $result = $this->work->contact_way->list($cursor,$limit);
  16. // 返回列表
  17. if( $result['errcode'] == 0 ) return ['contact_way'=>$result['contact_way'],'next_cursor'=>empty($result['next_cursor'])?'':$result['next_cursor']];
  18. // 如果请求失败,返回空数据
  19. return ['contact_way'=>[],'next_cursor'=>''];
  20. }
  21. /**
  22. * 获取详情
  23. *
  24. * @param string $configId 配置ID
  25. *
  26. */
  27. public function getOne($configId){
  28. // 获取部门列表
  29. $result = $this->work->contact_way->get($configId);
  30. // 返回列表
  31. if( $result['errcode'] == 0 ) return $result['contact_way'];
  32. // 如果请求失败,返回空数据
  33. return [];
  34. }
  35. /**
  36. * 添加
  37. *
  38. * @param int $type 联系方式类型,1-单人, 2-多人
  39. * @param int $scene 场景,1-在小程序中联系,2-通过二维码联系
  40. * @param array $config 配置信息
  41. * array party 使用该联系方式的部门id列表,只在type为2时有效
  42. * array user 使用该联系方式的用户userID列表,在type为1时为必填,且只能有一个
  43. * bool skip_verify 外部客户添加时是否无需验证,默认为true
  44. * string remark 联系方式的备注信息,用于助记,不超过30个字符
  45. * string state 企业自定义的state参数,用于区分不同的添加渠道 不超过30个字符
  46. */
  47. public function add($config,$type=2,$scene=2){
  48. // 获取部门列表
  49. $result = $this->work->contact_way->create($type,$scene,$config);
  50. // 返回列表
  51. if( $result['errcode'] == 0 ) return ['config_id'=>$result['config_id'],'qr_code'=>(empty($result['qr_code'])?'':$result['qr_code'])];
  52. // 如果请求失败,返回空数据
  53. return [];
  54. }
  55. /**
  56. * 修改
  57. *
  58. * @param string $configId 配置ID
  59. * @param array $config 配置信息
  60. * array party 使用该联系方式的部门id列表,只在type为2时有效
  61. * array user 使用该联系方式的用户userID列表,在type为1时为必填,且只能有一个
  62. * bool skip_verify 外部客户添加时是否无需验证,默认为true
  63. * string remark 联系方式的备注信息,用于助记,不超过30个字符
  64. * string state 企业自定义的state参数,用于区分不同的添加渠道 不超过30个字符
  65. *
  66. */
  67. public function edit($configId,$config){
  68. // 获取部门列表
  69. $result = $this->work->contact_way->update($configId,$config);
  70. // 返回列表
  71. if( $result['errcode'] == 0 ) return $configId;
  72. // 如果请求失败,返回空数据
  73. return '';
  74. }
  75. /**
  76. * 删除
  77. *
  78. * @param string $configId 配置ID
  79. *
  80. */
  81. public function del($configId){
  82. // 获取部门列表
  83. $result = $this->work->contact_way->delete($configId);
  84. // 返回列表
  85. if( $result['errcode'] == 0 ) return $configId;
  86. // 如果请求失败,返回空数据
  87. return '';
  88. }
  89. }