Config.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\model\member;
  11. use app\model\system\Document;
  12. use app\model\system\Config as ConfigModel;
  13. use app\model\BaseModel;
  14. /**
  15. * 会员设置
  16. */
  17. class Config extends BaseModel
  18. {
  19. /**
  20. * 注册协议
  21. * @param unknown $site_id
  22. * @param unknown $name
  23. * @param unknown $value
  24. */
  25. public function setRegisterDocument($title, $content, $site_id, $app_module = 'shop')
  26. {
  27. $document = new Document();
  28. $res = $document->setDocument($title, $content, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['document_key', '=', 'REGISTER_AGREEMENT']]);
  29. return $res;
  30. }
  31. /**
  32. * 查询注册协议
  33. * @param unknown $where
  34. * @param unknown $field
  35. * @param unknown $value
  36. */
  37. public function getRegisterDocument($site_id, $app_module = 'shop')
  38. {
  39. $document = new Document();
  40. $info = $document->getDocument([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['document_key', '=', 'REGISTER_AGREEMENT']]);
  41. return $info;
  42. }
  43. /**
  44. * 注册规则
  45. * array $data
  46. */
  47. public function setRegisterConfig($data, $site_id, $app_module = 'shop')
  48. {
  49. $config = new ConfigModel();
  50. $res = $config->setConfig($data, '注册规则', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'REGISTER_CONFIG']]);
  51. return $res;
  52. }
  53. /**
  54. * 查询注册规则
  55. */
  56. public function getRegisterConfig($site_id, $app_module = 'shop')
  57. {
  58. $config = new ConfigModel();
  59. $res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'REGISTER_CONFIG']]);
  60. if (empty($res['data']['value'])) {
  61. //默认值设置
  62. $res['data']['value'] = [
  63. 'login' => 'username,mobile',
  64. 'register' => 'username,mobile',
  65. 'third_party' => 1,
  66. 'bind_mobile' => 0,
  67. 'pwd_len' => 6,
  68. 'pwd_complexity' => ''
  69. ];
  70. } else {
  71. $value = $res['data']['value'];
  72. $value['login'] = $value['login'] ?? 'username,mobile';
  73. $value['register'] = $value['register'] ?? 'username,mobile';
  74. $value['third_party'] = $value['third_party'] ?? 0;
  75. $value['bind_mobile'] = $value['bind_mobile'] ?? 0;
  76. $res['data']['value'] = $value;
  77. }
  78. return $res;
  79. }
  80. /**
  81. * 注销协议
  82. * @param unknown $site_id
  83. * @param unknown $name
  84. * @param unknown $value
  85. */
  86. public function setCancelDocument($title, $content, $site_id, $app_module = 'shop')
  87. {
  88. $document = new Document();
  89. $res = $document->setDocument($title, $content, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['document_key', '=', 'CANCEL_AGREEMENT']]);
  90. return $res;
  91. }
  92. /**
  93. * 查询注销协议
  94. * @param unknown $where
  95. * @param unknown $field
  96. * @param unknown $value
  97. */
  98. public function getCancelDocument($site_id, $app_module = 'shop')
  99. {
  100. $document = new Document();
  101. $info = $document->getDocument([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['document_key', '=', 'CANCEL_AGREEMENT']]);
  102. return $info;
  103. }
  104. /**
  105. * 注销规则
  106. * array $data
  107. */
  108. public function setCancelConfig($data, $site_id, $app_module = 'shop')
  109. {
  110. $config = new ConfigModel();
  111. $res = $config->setConfig($data, '注销规则', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'CANCEL_CONFIG']]);
  112. return $res;
  113. }
  114. /**
  115. * 查询注销规则
  116. */
  117. public function getCancelConfig($site_id, $app_module = 'shop')
  118. {
  119. $config = new ConfigModel();
  120. $res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'CANCEL_CONFIG']]);
  121. if (empty($res['data']['value'])) {
  122. //默认值设置
  123. $res['data']['value'] = [
  124. 'is_enable' => 0, //注销开关
  125. 'is_audit' => 1, //审核开关
  126. ];
  127. }
  128. return $res;
  129. }
  130. /**
  131. * 查询会员配置
  132. * @param unknown $where
  133. * @param unknown $field
  134. * @param unknown $value
  135. */
  136. public function getMemberConfig($site_id, $app_module = 'shop')
  137. {
  138. $config = new ConfigModel();
  139. $res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'MEMBER_LEVEL_CONFIG']]);
  140. if (empty($res['data']['value'])) {
  141. //默认值设置
  142. $res['data']['value'] = [
  143. 'is_update' => 1,
  144. ];
  145. } else {
  146. $value = $res['data']['value'];
  147. $value['is_update'] = $value['is_update'] ?? 1;
  148. $res['data']['value'] = $value;
  149. }
  150. return $res;
  151. }
  152. /**
  153. * 会员配置
  154. * array $data
  155. */
  156. public function setMemberConfig($data, $site_id, $app_module = 'shop')
  157. {
  158. $config = new ConfigModel();
  159. $res = $config->setConfig($data, '会员等级更新配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'MEMBER_LEVEL_CONFIG']]);
  160. return $res;
  161. }
  162. }