Setting.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <?php
  2. namespace app\common\model\plus\agent;
  3. use app\common\model\BaseModel;
  4. use think\facade\Cache;
  5. /**
  6. * 分销商设置模型
  7. */
  8. class Setting extends BaseModel
  9. {
  10. protected $name = 'agent_setting';
  11. protected $createTime = false;
  12. /**
  13. * 转义数组格式
  14. * @param $value
  15. * @return mixed
  16. */
  17. public function getValuesAttr($value)
  18. {
  19. return json_decode($value, true);
  20. }
  21. /**
  22. * 转义成json格式
  23. * @param $value
  24. * @return false|string
  25. */
  26. public function setValuesAttr($value)
  27. {
  28. return json_encode($value);
  29. }
  30. /**
  31. * 获取指定项设置
  32. * @param $key
  33. * @param null $app_id
  34. * @return array|mixed
  35. */
  36. public static function getItem($key, $app_id = null)
  37. {
  38. $data = static::getAll($app_id);
  39. return isset($data[$key]) ? $data[$key]['values'] : [];
  40. }
  41. /**
  42. * 获取分销商设置
  43. * @param null $app_id
  44. * @return array
  45. * @throws \think\db\exception\DataNotFoundException
  46. * @throws \think\db\exception\DbException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. */
  49. public static function getAll($app_id = null)
  50. {
  51. $self = new static;
  52. is_null($app_id) && $app_id = $self::$app_id;
  53. if (!$data = Cache::get('agent_setting_' . $app_id)) {
  54. $data = array_column($self->select()->toArray(), null, 'key');
  55. Cache::tag('cache')->set('agent_setting_' . $app_id, $data);
  56. }
  57. return array_merge_multiple($self->defaultData(), $data);
  58. }
  59. /**
  60. * 获取设置项信息
  61. * @param $key
  62. * @return array|\think\Model|null
  63. * @throws \think\db\exception\DataNotFoundException
  64. * @throws \think\db\exception\DbException
  65. * @throws \think\db\exception\ModelNotFoundException
  66. */
  67. public static function detail($key)
  68. {
  69. return (new static())->find(compact('key'));
  70. }
  71. /**
  72. * 是否开启分销功能
  73. * @param null $app_id
  74. * @return mixed
  75. */
  76. public static function isOpen($app_id = null)
  77. {
  78. return static::getItem('basic', $app_id)['is_open'];
  79. }
  80. /**
  81. * 分销中心页面名称
  82. * @param null $app_id
  83. * @return mixed
  84. */
  85. public static function getAgentTitle($app_id = null)
  86. {
  87. return static::getItem('words', $app_id)['index']['title']['value'];
  88. }
  89. /**
  90. * 默认配置
  91. * @return array[]
  92. */
  93. public function defaultData()
  94. {
  95. return [
  96. 'basic' => [
  97. 'key' => 'basic',
  98. 'describe' => '基础设置',
  99. 'values' => [
  100. // 是否开启分销功能
  101. 'is_open' => '0', // 参数值:1开启 0关闭
  102. // 分销层级
  103. 'level' => '3', // 参数值:1一级 2二级 3三级
  104. // 分销商内购
  105. 'self_buy' => '0' // 参数值:1开启 0关闭
  106. ],
  107. ],
  108. 'condition' => [
  109. 'key' => 'condition',
  110. 'describe' => '分销商条件',
  111. 'values' => [
  112. // 成为分销商条件
  113. 'become' => '10', // 参数值:10填写申请信息(需后台审核) 20填写申请信息(无需审核)
  114. // 购买指定商品成为分销商 0关闭 1开启
  115. 'become__buy_product' => '0',
  116. // 购买指定商品的id集
  117. 'become__buy_product_ids' => [],
  118. // 成为下线条件
  119. 'downline' => '10', // 参数值:10首次点击分享链接 20首次下单 30首次付款
  120. ]
  121. ],
  122. 'commission' => [
  123. 'key' => 'commission',
  124. 'describe' => '佣金设置',
  125. 'values' => [
  126. // 一级佣金
  127. 'first_money' => '0',
  128. // 一级佣金
  129. 'second_money' => '0',
  130. // 一级佣金
  131. 'third_money' => '0',
  132. ]
  133. ],
  134. 'settlement' => [
  135. 'key' => 'settlement',
  136. 'describe' => '结算',
  137. 'values' => [
  138. // 提现方式
  139. 'pay_type' => [], // 参数值:10微信支付 20支付宝支付 30银行卡支付
  140. // 微信支付自动打款
  141. 'wechat_pay_auto' => '0', // 微信支付自动打款:1开启 0关闭
  142. // 最低提现额度
  143. 'min_money' => '10.00',
  144. // 佣金结算天数
  145. 'settle_days' => '10',
  146. ]
  147. ],
  148. 'words' => [
  149. 'key' => 'words',
  150. 'describe' => '自定义文字',
  151. 'values' => [
  152. 'index' => [
  153. 'title' => [
  154. 'default' => '分销中心',
  155. 'value' => '分销中心'
  156. ],
  157. 'words' => [
  158. 'not_agent' => [
  159. 'default' => '您还不是分销商,请先提交申请',
  160. 'value' => '您还不是分销商,请先提交申请'
  161. ],
  162. 'apply_now' => [
  163. 'default' => '立即加入',
  164. 'value' => '立即加入'
  165. ],
  166. 'referee' => [
  167. 'default' => '推荐人',
  168. 'value' => '推荐人'
  169. ],
  170. 'money' => [
  171. 'default' => '可提现佣金',
  172. 'value' => '可提现'
  173. ],
  174. 'freeze_money' => [
  175. 'default' => '待提现佣金',
  176. 'value' => '待提现'
  177. ],
  178. 'total_money' => [
  179. 'default' => '已提现金额',
  180. 'value' => '已提现金额'
  181. ],
  182. 'cash' => [
  183. 'default' => '去提现',
  184. 'value' => '去提现'
  185. ],
  186. ]
  187. ],
  188. 'apply' => [
  189. 'title' => [
  190. 'default' => '申请成为分销商',
  191. 'value' => '申请成为分销商'
  192. ],
  193. 'words' => [
  194. 'title' => [
  195. 'default' => '请填写申请信息',
  196. 'value' => '请填写申请信息'
  197. ],
  198. 'license' => [
  199. 'default' => '分销商申请协议',
  200. 'value' => '分销商申请协议'
  201. ],
  202. 'submit' => [
  203. 'default' => '申请成为经销商',
  204. 'value' => '申请成为经销商'
  205. ],
  206. 'wait_audit' => [
  207. 'default' => '您的申请已受理,正在进行信息核验,请耐心等待。',
  208. 'value' => '您的申请已受理,正在进行信息核验,请耐心等待。'
  209. ],
  210. 'goto_mall' => [
  211. 'default' => '去商城逛逛',
  212. 'value' => '去商城逛逛'
  213. ],
  214. ]
  215. ],
  216. 'order' => [
  217. 'title' => [
  218. 'default' => '分销订单',
  219. 'value' => '分销订单'
  220. ],
  221. 'words' => [
  222. 'all' => [
  223. 'default' => '全部',
  224. 'value' => '全部'
  225. ],
  226. 'unsettled' => [
  227. 'default' => '未结算',
  228. 'value' => '未结算'
  229. ],
  230. 'settled' => [
  231. 'default' => '已结算',
  232. 'value' => '已结算'
  233. ],
  234. ]
  235. ],
  236. 'team' => [
  237. 'title' => [
  238. 'default' => '我的团队',
  239. 'value' => '我的团队'
  240. ],
  241. 'words' => [
  242. 'total_team' => [
  243. 'default' => '团队总人数',
  244. 'value' => '团队总人数'
  245. ],
  246. 'first' => [
  247. 'default' => '一级团队',
  248. 'value' => '一级团队'
  249. ],
  250. 'second' => [
  251. 'default' => '二级团队',
  252. 'value' => '二级团队'
  253. ],
  254. 'third' => [
  255. 'default' => '三级团队',
  256. 'value' => '三级团队'
  257. ],
  258. ]
  259. ],
  260. 'cash_list' => [
  261. 'title' => [
  262. 'default' => '提现明细',
  263. 'value' => '提现明细'
  264. ],
  265. 'words' => [
  266. 'all' => [
  267. 'default' => '全部',
  268. 'value' => '全部'
  269. ],
  270. 'apply_10' => [
  271. 'default' => '审核中',
  272. 'value' => '审核中'
  273. ],
  274. 'apply_20' => [
  275. 'default' => '审核通过',
  276. 'value' => '审核通过'
  277. ],
  278. 'apply_40' => [
  279. 'default' => '已打款',
  280. 'value' => '已打款'
  281. ],
  282. 'apply_30' => [
  283. 'default' => '驳回',
  284. 'value' => '驳回'
  285. ],
  286. ]
  287. ],
  288. 'cash_apply' => [
  289. 'title' => [
  290. 'default' => '申请提现',
  291. 'value' => '申请提现'
  292. ],
  293. 'words' => [
  294. 'capital' => [
  295. 'default' => '可提现佣金',
  296. 'value' => '可提现佣金'
  297. ],
  298. 'money' => [
  299. 'default' => '提现金额',
  300. 'value' => '提现金额'
  301. ],
  302. 'money_placeholder' => [
  303. 'default' => '请输入要提取的金额',
  304. 'value' => '请输入要提取的金额'
  305. ],
  306. 'min_money' => [
  307. 'default' => '最低提现佣金',
  308. 'value' => '最低提现佣金'
  309. ],
  310. 'submit' => [
  311. 'default' => '提交申请',
  312. 'value' => '提交申请'
  313. ],
  314. ]
  315. ],
  316. 'qrcode' => [
  317. 'title' => [
  318. 'default' => '推广二维码',
  319. 'value' => '推广二维码'
  320. ]
  321. ],
  322. ]
  323. ],
  324. 'license' => [
  325. 'key' => 'license',
  326. 'describe' => '申请协议',
  327. 'values' => [
  328. 'license' => ''
  329. ]
  330. ],
  331. 'background' => [
  332. 'key' => 'background',
  333. 'describe' => '页面背景图',
  334. 'values' => [
  335. // 分销中心首页
  336. 'index' => self::$base_url . 'image/agent/agent-bg.jpg',
  337. // 申请成为分销商页
  338. 'apply' => self::$base_url . 'image/agent/agent-bg.jpg',
  339. // 申请提现页
  340. 'cash_apply' => self::$base_url . 'image/agent/agent-bg.jpg',
  341. ],
  342. ],
  343. 'template_msg' => [
  344. 'key' => 'template_msg',
  345. 'describe' => '模板消息',
  346. 'values' => [
  347. 'apply_tpl' => '', // 分销商审核通知
  348. 'cash_tpl' => '', // 提现状态通知
  349. ]
  350. ],
  351. 'qrcode' => [
  352. 'key' => 'template_msg',
  353. 'describe' => '分销海报',
  354. 'values' => [
  355. 'backdrop' => [
  356. 'src' => self::$base_url . 'image/agent/backdrop.jpg',
  357. ],
  358. 'nickName' => [
  359. 'fontSize' => 14,
  360. 'color' => '#000000',
  361. 'left' => 150,
  362. 'top' => 99
  363. ],
  364. 'avatar' => [
  365. 'width' => 70,
  366. 'style' => 'circle',
  367. 'left' => 150,
  368. 'top' => 18
  369. ],
  370. 'qrcode' => [
  371. 'width' => 100,
  372. 'style' => 'circle',
  373. 'left' => 136,
  374. 'top' => 128
  375. ]
  376. ],
  377. ]
  378. ];
  379. }
  380. }