Salespop.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\monitor\controller;
  3. use think\Cache;
  4. use app\common\service\MailService;
  5. use app\common\service\HelperService;
  6. /**
  7. * 销售数据出队列
  8. * Class RequestPop
  9. */
  10. class Salespop extends Basepop
  11. {
  12. public $_listKey = 'sales_list';
  13. public function start(){
  14. $this->main($this->_listKey, 1000, '销售数据');
  15. }
  16. private function _getBaseUrl($companyNo){
  17. switch($companyNo){
  18. case 106:
  19. return "http://erp.ahamu.cn";
  20. case 117:
  21. return "http://fabld.ahamu.cn";
  22. case 105:
  23. case 898:
  24. return "http://erp_qbb.ahamu.cn";
  25. default :
  26. return false;
  27. }
  28. }
  29. public function mainFunc($requestArr){
  30. try{
  31. HelperService::$_startExecTime = microtime(true);
  32. $baseUrl = $this->_getBaseUrl($requestArr['company_no']);
  33. if(empty($baseUrl)){
  34. return true;
  35. }
  36. $url = $baseUrl."/index/Index/sales";
  37. $returnData = HelperService::httpPost($url, json_encode($requestArr), false);
  38. HelperService::$_sysParams = $requestArr;
  39. HelperService::addLog($returnData,$url,"ERP");
  40. // return @json_decode($returnData,true);
  41. return true;
  42. } catch (\Exception $ex){
  43. $mailService = new MailService();
  44. $mailService->send('leo',"销售数据出队异常","",$ex->getMessage(),[['mail'=>'2990412861@qq.com','name'=>'leo.xie']]);
  45. }
  46. }
  47. public function stop(){
  48. Cache::rm($this->_listKey.'_pop_program');
  49. echo "restart success\n";
  50. }
  51. public function getCache(){
  52. $salesList = Cache::get($this->_listKey.'_pop_program');
  53. var_dump($salesList);
  54. }
  55. }