ProgramTemplateService.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. namespace service;
  3. use app\admin\model\wechat\WechatUser;
  4. use app\admin\model\routine\RoutineTemplate as RoutineTemplateModel;
  5. use app\admin\model\routine\RoutineFormId as RoutineFormIdModel;
  6. use app\admin\model\wechat\StoreService as ServiceModel;
  7. /**
  8. * 小程序模板消息
  9. * Class RoutineTemplate
  10. * @package app\routine\model\routine
  11. */
  12. class ProgramTemplateService{
  13. //订单支付成功
  14. const ORDER_PAY_SUCCESS = 'AT0009';
  15. //砍价成功
  16. const BARGAIN_SUCCESS = 'AT1173';
  17. //申请退款通知
  18. const ORDER_REFUND_STATUS = 'AT0036';
  19. //退款成功
  20. const ORDER_REFUND_SUCCESS = 'AT0787';
  21. //订单发货提醒(快递)
  22. const ORDER_POSTAGE_SUCCESS = 'AT0007';
  23. //订单发货提醒(送货)
  24. const ORDER_DELIVER_SUCCESS = 'AT0177';
  25. public static function sendTemplate($openid,$tempkey,array $data,$form_id = '',$link = null,$defaultColor = '')
  26. {
  27. $tempid = RoutineTemplateModel::getTempid($tempkey);
  28. if(!$tempid) return false;
  29. try{
  30. return MiniProgramService::sendTemplate($openid,$tempid,$data,$form_id,$link,$defaultColor);
  31. }catch (\Exception $e){
  32. return false;
  33. }
  34. }
  35. /**服务进度通知
  36. * @param array $data
  37. * @param null $url
  38. * @param string $defaultColor
  39. * @return bool
  40. */
  41. public static function sendAdminNoticeTemplate(array $data,$url = null,$defaultColor = '')
  42. {
  43. $adminIds = explode(',',trim(SystemConfigService::get('site_store_admin_uids')));
  44. $kefuIds = ServiceModel::where('notify',1)->column('uid');
  45. if(empty($adminIds[0])){
  46. $adminList = array_unique($kefuIds);
  47. }else{
  48. $adminList = array_unique(array_merge($adminIds,$kefuIds));
  49. }
  50. if(!is_array($adminList) || empty($adminList)) return false;
  51. foreach ($adminList as $uid){
  52. try{
  53. $openid = WechatUser::uidToRoutineOpenid($uid);
  54. }catch (\Exception $e){
  55. continue;
  56. }
  57. // self::sendTemplate($openid,self::ADMIN_NOTICE,$data,$url,$defaultColor);
  58. }
  59. }
  60. /**
  61. * 返回所有支持的行业列表
  62. * @return \EasyWeChat\Support\Collection
  63. */
  64. public static function getIndustry()
  65. {
  66. return MiniProgramService::noticeService()->getIndustry();
  67. }
  68. /**
  69. * 修改账号所属行业
  70. * 主行业 副行业 代码
  71. * IT科技 互联网/电子商务 1
  72. * IT科技 IT软件与服务 2
  73. * IT科技 IT硬件与设备 3
  74. * IT科技 电子技术 4
  75. * IT科技 通信与运营商 5
  76. * IT科技 网络游戏 6
  77. * 金融业 银行 7
  78. * 金融业 基金|理财|信托 8
  79. * 金融业 保险 9
  80. * 餐饮 餐饮 10
  81. * 酒店旅游 酒店 11
  82. * 酒店旅游 旅游 12
  83. * 运输与仓储 快递 13
  84. * 运输与仓储 物流 14
  85. * 运输与仓储 仓储 15
  86. * 教育 培训 16
  87. * 教育 院校 17
  88. * 政府与公共事业 学术科研 18
  89. * 政府与公共事业 交警 19
  90. * 政府与公共事业 博物馆 20
  91. * 政府与公共事业 公共事业|非盈利机构 21
  92. * 医药护理 医药医疗 22
  93. * 医药护理 护理美容 23
  94. * 医药护理 保健与卫生 24
  95. * 交通工具 汽车相关 25
  96. * 交通工具 摩托车相关 26
  97. * 交通工具 火车相关 27
  98. * 交通工具 飞机相关 28
  99. * 房地产 建筑 29
  100. * 房地产 物业 30
  101. * 消费品 消费品 31
  102. * 商业服务 法律 32
  103. * 商业服务 会展 33
  104. * 商业服务 中介服务 34
  105. * 商业服务 认证 35
  106. * 商业服务 审计 36
  107. * 文体娱乐 传媒 37
  108. * 文体娱乐 体育 38
  109. * 文体娱乐 娱乐休闲 39
  110. * 印刷 印刷 40
  111. * 其它 其它 41
  112. * @param $industryId1
  113. * @param $industryId2
  114. * @return \EasyWeChat\Support\Collection
  115. */
  116. public static function setIndustry($industryId1, $industryId2)
  117. {
  118. return MiniProgramService::noticeService()->setIndustry($industryId1, $industryId2);
  119. }
  120. /**
  121. * 获取所有模板列表
  122. * @return \EasyWeChat\Support\Collection
  123. */
  124. public static function getPrivateTemplates()
  125. {
  126. return MiniProgramService::noticeService()->getPrivateTemplates();
  127. }
  128. /**
  129. * 删除指定ID的模板
  130. * @param $templateId
  131. * @return \EasyWeChat\Support\Collection
  132. */
  133. public static function deletePrivateTemplate($templateId)
  134. {
  135. return MiniProgramService::noticeService()->deletePrivateTemplate($templateId);
  136. }
  137. /**
  138. * 添加模板并获取模板ID
  139. * @param $shortId
  140. * @return \EasyWeChat\Support\Collection
  141. */
  142. public static function addTemplate($shortId)
  143. {
  144. return MiniProgramService::noticeService()->addTemplate($shortId);
  145. }
  146. }