MOem.Class.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: kang
  5. * Date: 2021/3/15
  6. * Time: 12:25
  7. */
  8. namespace JinDouYun\Model\Oem;
  9. use Mall\Framework\Core\ErrorCode;
  10. use Mall\Framework\Core\StatusCode;
  11. use Mall\Framework\Core\ResultWrapper;
  12. use JinDouYun\Model\MBaseModel;
  13. use JinDouYun\Dao\Oem\DOem;
  14. use JinDouYun\Dao\Enterprise\DEnterprise;
  15. class MOem extends MBaseModel
  16. {
  17. private $objDOem;
  18. private $enterpriseId;
  19. private $userCenterId;
  20. private $objDEnterprise;
  21. public function __construct($enterpriseId = 0, $userCenterId = 0)
  22. {
  23. $this->enterpriseId = $enterpriseId;
  24. $this->userCenterId = $userCenterId;
  25. parent::__construct($this->enterpriseId, $this->userCenterId);
  26. $this->objDOem = new DOem('default');
  27. $this->objDEnterprise = new DEnterprise('default');
  28. }
  29. /**
  30. * 获取指定logo贴牌
  31. */
  32. public function getOemInfo($oemId)
  33. {
  34. $dbResult = $this->objDOem->get($oemId);
  35. if($dbResult === false){
  36. return ResultWrapper::fail($this->objDOem->error(), ErrorCode::$dberror);
  37. } else {
  38. return ResultWrapper::success( $dbResult );
  39. }
  40. }
  41. /**
  42. * 通过域名获取指定ome数据
  43. */
  44. public function getOemInfoByDomain($domain)
  45. {
  46. $dbResult = $this->objDOem->get(['domain'=>$domain]);
  47. if($dbResult === false){
  48. return ResultWrapper::fail($this->objDOem->error(), ErrorCode::$dberror);
  49. } else {
  50. return ResultWrapper::success( $dbResult );
  51. }
  52. }
  53. /**
  54. * 通过api域名获取指定ome数据
  55. */
  56. public function getOemInfoByApiDomain($apiDomain)
  57. {
  58. $dbResult = $this->objDOem->get(['apiDomain'=>$apiDomain]);
  59. if($dbResult === false){
  60. return ResultWrapper::fail($this->objDOem->error(), ErrorCode::$dberror);
  61. } else {
  62. return ResultWrapper::success( $dbResult );
  63. }
  64. }
  65. /**
  66. * 通过微信开发平台appid获取指定oem数据
  67. */
  68. public function getOemInfoByWeiXinOpenAppId($appid)
  69. {
  70. $dbResult = $this->objDOem->get(['weixinOpenAppid'=>$appid]);
  71. if($dbResult === false){
  72. return ResultWrapper::fail($this->objDOem->error(), ErrorCode::$dberror);
  73. } else {
  74. return ResultWrapper::success( $dbResult );
  75. }
  76. }
  77. /**
  78. * 通过企业id获取指定ome数据
  79. */
  80. public function getOemInfoByenterpriseId($enterpriseId)
  81. {
  82. $this->objDEnterprise->setTable('qianniao_enterprise_1');
  83. $enterpriseIdDbResult = $this->objDEnterprise->get(['id'=>$enterpriseId]);
  84. if($enterpriseIdDbResult === false){
  85. return ResultWrapper::fail($this->objDEnterprise->error(), ErrorCode::$dberror);
  86. }
  87. if(empty($enterpriseIdDbResult)){
  88. return ResultWrapper::fail('查询数据为空', ErrorCode::$dberror);
  89. }
  90. if($enterpriseIdDbResult['isoem'] == StatusCode::$delete){
  91. $dbResult = $this->objDOem->get(['enterpriseId'=> 4]);
  92. }else{
  93. $dbResult = $this->objDOem->get(['enterpriseId'=>$enterpriseIdDbResult['oemId']]);
  94. }
  95. if($dbResult === false){
  96. return ResultWrapper::fail($this->objDOem->error(), ErrorCode::$dberror);
  97. }
  98. if(empty($dbResult)){
  99. return ResultWrapper::fail('oem配置项为空', ErrorCode::$dberror);
  100. }
  101. return ResultWrapper::success( $dbResult );
  102. }
  103. }