Option.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use app\constants\OptionSetting;
  9. use app\jobs\storeSync\DiyCommon;
  10. use app\utils\Validator;
  11. use yii\behaviors\TimestampBehavior;
  12. use yii\db\ActiveRecord;
  13. use yii\helpers\Json;
  14. use yii\validators\StringValidator;
  15. /**
  16. * class Option
  17. * @package app\modules\common\models
  18. * @property integer $store_id
  19. * @property string $name
  20. * @property string $value
  21. * @property integer $updated_at
  22. * @property string $group
  23. */
  24. class Option extends ActiveRecord
  25. {
  26. CONST OPTOPN_KEY = 'alipay_config';
  27. CONST ALIPAY_CONFIG_CERT = 'alipay_config_cert';
  28. CONST CLOUD_STORE_KEY = -2;
  29. CONST PROMOTER_GROUP_NAME = 'promoter';
  30. CONST PROMOTER_SETTING_NAME = 'promoter_setting';
  31. CONST SHARER_SETTING_NAME = 'sharer_setting';
  32. public static function takeName()
  33. {
  34. return "{%option}";
  35. }
  36. public function behaviors()
  37. {
  38. return [
  39. [
  40. // 自动更新更新时间
  41. 'class' => TimestampBehavior::class,
  42. 'value' => time()
  43. ]
  44. ];
  45. }
  46. public function rules()
  47. {
  48. return [
  49. [['store_id'], 'integer'],
  50. [['name',], 'required'],
  51. [['value'], 'string'],
  52. [['name','group'], 'string', 'max' => 255],
  53. [['updated_at','created_at'], 'safe']
  54. ];
  55. }
  56. public function attributeLabels()
  57. {
  58. return [
  59. 'store_id' => 'store ID',
  60. 'name' => '设置名称',
  61. 'value' => '值',
  62. 'group' => '类型',
  63. 'updated_at' => '更新时间'
  64. ];
  65. }
  66. /**
  67. * 获取配置数据
  68. * @param $name
  69. * @param int $store_id
  70. * @param string $group
  71. * @param null $default
  72. * @return array|ActiveRecord|ActiveRecord[]|null
  73. */
  74. public static function get ($name, $store_id = null, $group = '', $default = null)
  75. {
  76. if ($store_id === null) {
  77. $store_id = get_store_id();
  78. }
  79. $key = $name.'_'.$store_id.'_'.$group.'_option';
  80. /*if (\Yii::$app->cache->exists($key)) {
  81. return \Yii::$app->cache->get($key);
  82. }*/
  83. $query = self::find()->where([
  84. 'name' => $name,
  85. 'store_id' => $store_id,
  86. ])->select(['name','group','value','updated_at']);
  87. if ($group) {
  88. $query->andWhere(['group' => $group]);
  89. }
  90. if (is_array($name)) {
  91. $data = $query->asArray()->all();
  92. $res = $data ?: [];
  93. } else {
  94. $data = $query->asArray()->one();
  95. $res = $data ?: ['value' => $default];
  96. }
  97. \Yii::$app->cache->set($key,$res,3);
  98. return $res;
  99. }
  100. /**
  101. * 设置配置数据
  102. * @param $name | sting or array // 配置名称
  103. * @param $value | string or array // 配置数据
  104. * @param int $store_id // storeId
  105. * @param string $group // 配置类型
  106. * @return bool
  107. * @throws \yii\db\Exception
  108. */
  109. public static function set ($name, $value, $store_id = null, $group = '')
  110. {
  111. if ($store_id === null) {
  112. $store_id = get_store_id();
  113. }
  114. if (is_array($name) || is_array($value)) {
  115. if (!is_array($name) || !is_array($value) || count($name) != count($value) || count($name) == 0) {
  116. return false;
  117. }
  118. $t = \Yii::$app->db->beginTransaction();
  119. foreach ($name as $k => $v) {
  120. $option = self::findOne(['name' => $v, 'store_id' => $store_id, 'group' => $group]);
  121. if (!$option) {
  122. $option = new self();
  123. $option->group = $group;
  124. $option->store_id = $store_id;
  125. }
  126. $option->name = $v;
  127. $option->value = is_array($value[$k]) ? Json::encode($value[$k]) : '' . $value[$k];
  128. if (!$option->save()) {
  129. $t->rollBack();
  130. return false;
  131. }
  132. }
  133. $t->commit();
  134. return true;
  135. } else {
  136. $option = self::findOne(['name' => $name, 'store_id' => $store_id, 'group' => $group]);
  137. if (!$option) {
  138. $option = new self();
  139. $option->group = $group;
  140. $option->store_id = $store_id;
  141. }
  142. $option->name = $name;
  143. $option->value = '' . $value;
  144. if (!$option->save()) {
  145. \Yii::error($option->errors);
  146. return false;
  147. }
  148. return true;
  149. }
  150. }
  151. public function afterSave($insert, $changedAttributes)
  152. {
  153. parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
  154. if (!$insert) {
  155. if (in_array($this->name, ['share_basic_setting', 'share_money_setting'])) {
  156. (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_SHARE_CONFIG, [$this->name]);
  157. }
  158. }
  159. }
  160. /**
  161. * 根据类获取数据
  162. * @param $group
  163. * @param $store_id
  164. * @return array
  165. */
  166. public static function getGroup ($group, $store_id = null)
  167. {
  168. if ($store_id === null) {
  169. $store_id = get_store_id();
  170. }
  171. $group_setting = OptionSetting::getOptionSetting();
  172. $group_arr = $group_setting[$group]['list'] ?: [];
  173. $data = [];
  174. foreach ($group_arr as $val) {
  175. $group_data = self::findOne(['store_id' => $store_id, 'group' => $group, 'name' => $val['name']]);
  176. if ($val['type'] == 'checkbox') {
  177. if ($group_data) {
  178. $attr = $val['default'];
  179. $data_val = Json::decode($group_data->value,true);
  180. foreach ($attr as $k => &$v) {
  181. $v = isset($data_val[$k]) ? $data_val[$k] : $v;
  182. }
  183. }
  184. }
  185. if ($val['type'] == 'address_info') {
  186. if ($group_data) {
  187. $attr = Json::decode($group_data->value,true);
  188. }
  189. }
  190. $data[] = [
  191. 'name' => $group_data ? $group_data->name : $val['name'],
  192. 'text' => $val['text'],
  193. 'group' => $group_data ? $group_data->group : $group,
  194. 'type' => $val['type'],
  195. 'size' => isset($val['size']) ? $val['size'] : '',
  196. 'title' => isset($val['title']) ? $val['title'] : '',
  197. 'required' => $val['required'],
  198. 'muted' => isset($val['muted']) ? $val['muted'] : '',
  199. 'value' => $group_data ? (($val['type'] == 'checkbox' || $val['type'] == 'address_info') ? $attr : $group_data->value ) : (is_int($val['default']) ? "$val[default]" : $val['default'] ),
  200. 'updated_at' => $group_data ? $group_data->updated_at : 0,
  201. 'unit' => isset($val['unit']) ? $val['unit'] : '',
  202. 'select_list' => isset($val['select_list']) ? $val['select_list'] : []
  203. ];
  204. }
  205. return $data;
  206. }
  207. /**
  208. * 根据类型批量设置数据
  209. * @param $group
  210. * @param $set_data
  211. * @param int $store_id
  212. * @return bool
  213. */
  214. public static function setGroup ($group, $set_data, $store_id = null)
  215. {
  216. if ($store_id === null) {
  217. $store_id = get_store_id();
  218. }
  219. foreach ($set_data as $val) {
  220. if ($val['name']) {
  221. $group_data = self::findOne(['store_id' => $store_id, 'group' => $group, 'name' => $val['name']]);
  222. if (!$group_data) {
  223. $group_data = new self();
  224. $group_data->store_id = $store_id;
  225. $group_data->group = $group;
  226. }
  227. $group_data->name = $val['name'];
  228. if ($val['type'] == 'checkbox' || $val['type'] == 'address_info') {
  229. $group_data->value = Json::encode($val['value']);
  230. }else {
  231. $group_data->value = "{$val['value']}";
  232. }
  233. if (!$group_data->save()) {
  234. return false;
  235. }
  236. }
  237. }
  238. return true;
  239. }
  240. /**
  241. * 验证保存信息
  242. * @param $data
  243. * @param $group
  244. * @return array
  245. */
  246. public static function verifyData ($data, $group)
  247. {
  248. $default = OptionSetting::getOptionSetting();
  249. if (empty($data) || empty($group) || empty($default[$group])) {
  250. return [
  251. 'code' => 1,
  252. 'msg' => '数据格式错误:'.Json::encode(['data' => $data ,'group' => $group,'default_group' =>$default[$group]])
  253. ];
  254. }
  255. $validArr = [];
  256. foreach ($default[$group]['list'] as $val) {
  257. foreach ($data as $v) {
  258. if ($v['name'] == $val['name']) {
  259. if ($val['required'] && empty($v['value'])) {
  260. return [
  261. 'code' => 1,
  262. 'msg' => $val['text'].'为必填'
  263. ];
  264. }
  265. switch ($val['type']) {
  266. case 'text':
  267. $validArr[] = ['string', $v['value'], [ 'max' => 255 ], $v['text'].'最大长度255' ];
  268. break;
  269. case 'number':
  270. $validArr[] = ['number', $v['value'], [ 'max' => 9999999999,'min' => 0 ], $v['text'].'请填写0~9999999999范围数字'];
  271. break;
  272. case 'checkbox':
  273. break;
  274. case 'radio':
  275. $redio_arr = [0, 1];
  276. $v['select_list'] = isset($v['select_list']) && is_array($v['select_list']) ? $v['select_list'] : [];
  277. if (count($v['select_list']) > 0) {
  278. $select_arr = [];
  279. foreach($v['select_list'] as $select_val) {
  280. $select_arr[] = $select_val['value'];
  281. }
  282. $redio_arr = $select_arr;
  283. }
  284. $validArr[] = ['radio', $v['value'], $redio_arr, $v['text'].'参数错误'];
  285. break;
  286. case 'textarea':
  287. $validArr[] = ['string', $v['value'], [ 'max' => 2000 ], $v['text'].'最大长度2000' ];
  288. break;
  289. case 'image':
  290. break;
  291. case 'mobile':
  292. $validArr[] = ['phone', $v['value'], [], $v['text'].'格式错误'];
  293. break;
  294. default:
  295. break;
  296. }
  297. }
  298. }
  299. }
  300. if ($group == 'share') {
  301. return ['code' => 0, 'msg' => 'success'];
  302. }
  303. if ($validArr) {
  304. $valid = new Validator($validArr);
  305. }
  306. if (!$valid->success && $validArr) {
  307. $text = $valid->success !== true ? $valid->error : '';
  308. return [
  309. 'code' => 1,
  310. 'msg' => $text ? $text : '数据格式错误',
  311. 'validArr' => $default[$group]['list']
  312. ];
  313. }
  314. }
  315. /**
  316. * 获取充值设置
  317. * @return array
  318. */
  319. public static function getRechargeOption() {
  320. $name = [
  321. 'recharge_wallet_status',
  322. 'recharge_custom_status',
  323. 'recharge_pic_url',
  324. 'recharge_ad_pic_url',
  325. 'recharge_page_url',
  326. 'recharge_p_pic_url',
  327. 'recharge_help',
  328. ];
  329. $data = self::get($name, get_store_id(), 'recharge');
  330. $data = array_column($data, null, 'name');
  331. $balance = [
  332. 'status' => $data['recharge_wallet_status']['value'],
  333. 'pic_url' => $data['recharge_pic_url']['value'],
  334. 'ad_pic_url' => $data['recharge_ad_pic_url']['value'],
  335. 'page_url' => $data['recharge_page_url']['value'],
  336. 'p_pic_url' => $data['recharge_p_pic_url']['value'],
  337. 'help' => $data['recharge_help']['value'],
  338. 'type' => $data['recharge_custom_status']['value'],
  339. ];
  340. return $balance;
  341. }
  342. /**
  343. * 获取saas微信设置
  344. * @return array
  345. */
  346. public static function getSaasWechat2() {
  347. $name = [
  348. 'sp_appid',
  349. 'sp_mch_id',
  350. 'sp_key',
  351. 'platform_appid',
  352. 'platform_mch_id',
  353. 'platform_apiclient_cert',
  354. 'platform_apiclient_key',
  355. 'sp_name'
  356. ];
  357. $data = self::get($name, 0, 'saas');
  358. $data = array_column($data, null, 'name');
  359. $result = [
  360. 'sp_appid' => $data['sp_appid']['value'],
  361. 'sp_mch_id' => $data['sp_mch_id']['value'],
  362. 'sp_key' => $data['sp_key']['value'],
  363. 'sub_appid' => $data['platform_appid']['value'],
  364. 'mch_id' => $data['platform_mch_id']['value'],
  365. 'sp_apiclient_cert' => $data['platform_apiclient_cert']['value'],
  366. 'sp_apiclient_key' => $data['platform_apiclient_key']['value'],
  367. 'sp_name' => $data['sp_name']['value']
  368. ];
  369. return $result;
  370. }
  371. /**
  372. * 获取saas微信设置
  373. * @return array
  374. */
  375. public static function getSaasWechat() {
  376. $name = [
  377. 'sp_appid',
  378. 'sp_mch_id',
  379. 'sp_key',
  380. 'sp_apiclient_cert',
  381. 'sp_apiclient_key',
  382. 'sp_name'
  383. ];
  384. $data = self::get($name, 0, 'saas');
  385. $data = array_column($data, null, 'name');
  386. $result = [
  387. 'sp_appid' => $data['sp_appid']['value'],
  388. 'sp_mch_id' => $data['sp_mch_id']['value'],
  389. 'sp_key' => $data['sp_key']['value'],
  390. 'sp_apiclient_cert' => $data['sp_apiclient_cert']['value'],
  391. 'sp_apiclient_key' => $data['sp_apiclient_key']['value'],
  392. 'sp_name' => $data['sp_name']['value']
  393. ];
  394. return $result;
  395. }
  396. /**
  397. * 获取saas微信设置
  398. * @return array
  399. */
  400. public static function getStoreShare() {
  401. $store_share = self::get('store_share', 0, 'saas')['value'];
  402. if (empty($store_share)) {
  403. return [];
  404. }
  405. $store_share = Json::decode($store_share);
  406. return $store_share;
  407. }
  408. /**
  409. * 获取支付宝第三方应用配置
  410. * @return array
  411. */
  412. public static function getSaasAlipay() {
  413. $name = [
  414. 'alipay_appid',
  415. 'alipay_public_key',
  416. 'alipay_app_public_key',
  417. 'alipay_app_private_key',
  418. 'alipay_user_id',
  419. 'alipay_name'
  420. ];
  421. $data = self::get($name, 0, 'saas');
  422. $data = array_column($data, null, 'name');
  423. $result = [
  424. 'app_id' => $data['alipay_appid']['value'],
  425. 'alipay_public_key' => $data['alipay_public_key']['value'],
  426. 'app_public_key' => $data['alipay_app_public_key']['value'],
  427. 'app_private_key' => $data['alipay_app_private_key']['value'],
  428. 'user_id' => $data['alipay_user_id']['value'],
  429. 'name' => $data['alipay_name']['value']
  430. ];
  431. return $result;
  432. }
  433. /**
  434. * 获取配置数据
  435. * @param $name
  436. * @param int $store_id
  437. * @param string $group
  438. * @param null $default
  439. * @return array
  440. */
  441. public static function getAlipayConfig ()
  442. {
  443. $res = self::findOne([
  444. 'name' => 'alipay_config',
  445. 'group' => 'alipay',
  446. 'store_id' => get_store_id()
  447. ]);
  448. if ($res) {
  449. return Json::decode($res->value);
  450. }
  451. return [];
  452. }
  453. public static function getFoodBookConfig($store_id = null) {
  454. $store_id = $store_id ?: get_store_id();
  455. $key = 'food_book_info_' . $store_id;
  456. if ($res = cache()->get($key)) {
  457. return $res;
  458. }
  459. $food_book = self::get('food_book', $store_id, 'store')['value'];
  460. if (empty($food_book)) {
  461. return [];
  462. }
  463. $food_book = Json::decode($food_book);
  464. cache()->set($key, $food_book, 3600);
  465. return $food_book;
  466. }
  467. /**
  468. * 获取saas微信设置
  469. * @return array
  470. */
  471. public static function getSaasPlatformWechat() {
  472. $name = [
  473. 'platform_key',
  474. 'platform_appid',
  475. ];
  476. $data = self::get($name, 0, 'saas');
  477. $data = array_column($data, null, 'name');
  478. $result = [
  479. 'key' => $data['platform_key']['value'],
  480. 'appid' => $data['platform_appid']['value'],
  481. ];
  482. return $result;
  483. }
  484. public static function getSaasPlatformWechat2() {
  485. $name = [
  486. 'platform_key',
  487. 'platform_appid',
  488. ];
  489. $data = self::get($name, UserStringCodePlus::Serial_Code_Collaboration, 'saas');
  490. $data = array_column($data, null, 'name');
  491. $result = [
  492. 'key' => $data['platform_key']['value'],
  493. 'appid' => $data['platform_appid']['value'],
  494. ];
  495. return $result;
  496. }
  497. /**
  498. * 获取saas微信设置
  499. * @return array
  500. */
  501. public static function getSaasPlatformMchWechat() {
  502. $name = [
  503. 'platform_mch_key',
  504. 'platform_mch_appid',
  505. ];
  506. $data = self::get($name, 0, 'saas');
  507. $data = array_column($data, null, 'name');
  508. $result = [
  509. 'key' => $data['platform_mch_key']['value'],
  510. 'appid' => $data['platform_mch_appid']['value'],
  511. ];
  512. return $result;
  513. }
  514. /**
  515. * 获取联盟端服务号微信设置
  516. * @return array
  517. */
  518. public static function getSaasPlatformMchWechatFuwu() {
  519. $name = [
  520. 'platform_mch_wechat_appid',
  521. 'platform_mch_wechat_secret',
  522. ];
  523. $data = self::get($name, 0, 'saas');
  524. $data = array_column($data, null, 'name');
  525. $result = [
  526. 'key' => $data['platform_mch_wechat_secret']['value'],
  527. 'appid' => $data['platform_mch_wechat_appid']['value'],
  528. ];
  529. return $result;
  530. }
  531. /**
  532. * 获取saas抖音设置
  533. * @return array
  534. */
  535. public static function getSaasPlatformBytedance() {
  536. $name = [
  537. 'bytedance_platform_key',
  538. 'bytedance_platform_appid',
  539. 'bytedance_platform_salt',
  540. 'bytedance_platform_token',
  541. ];
  542. $data = self::get($name, 0, 'saas');
  543. $data = array_column($data, null, 'name');
  544. $result = [
  545. 'key' => $data['bytedance_platform_key']['value'],
  546. 'appid' => $data['bytedance_platform_appid']['value'],
  547. 'salt' => $data['bytedance_platform_salt']['value'],
  548. 'token' => $data['bytedance_platform_token']['value'],
  549. ];
  550. return $result;
  551. }
  552. /**
  553. * 获取saas抖音设置
  554. * @return array
  555. */
  556. public static function getDeliveryConfig() {
  557. $res = [
  558. 'sf' => [
  559. 'sf_app_key' => '',
  560. 'sf_app_secret' => '',
  561. 'sf_shop_no' => '',
  562. ],
  563. 'dd' => [
  564. 'dd_app_key' => '',
  565. 'dd_app_secret' => '',
  566. 'dd_shop_no' => '',
  567. ],
  568. 'ss' => [
  569. 'ss_app_key' => '',
  570. 'ss_app_secret' => '',
  571. 'ss_shop_no' => '',
  572. ],
  573. 'mt' => [
  574. 'mt_app_key' => '',
  575. 'mt_app_secret' => '',
  576. 'mt_shop_no' => '',
  577. ],
  578. 'uu' => [
  579. 'uu_app_key' => '',
  580. 'uu_app_secret' => '',
  581. 'uu_shop_no' => '',
  582. ]
  583. ];
  584. $sf_data = self::get(['sf_app_key', 'sf_app_secret', 'sf_shop_no'], get_store_id(), 'store');
  585. $dd_data = self::get(['dd_app_key', 'dd_app_secret', 'dd_shop_no'], get_store_id(), 'store');
  586. $ss_data = self::get(['ss_app_key', 'ss_app_secret', 'ss_shop_no'], get_store_id(), 'store');
  587. $mt_data = self::get(['mt_app_key', 'mt_app_secret', 'mt_shop_no'], get_store_id(), 'store');
  588. $uu_data = self::get(['uu_app_key', 'uu_app_secret', 'uu_shop_no'], get_store_id(), 'store');
  589. if (!empty($sf_data)) {
  590. $sf_data = array_column($sf_data, null, 'name');
  591. $res['sf'] = [
  592. 'sf_app_key' => $sf_data['sf_app_key']['value'],
  593. 'sf_app_secret' => $sf_data['sf_app_secret']['value'],
  594. 'sf_shop_no' => $sf_data['sf_shop_no']['value'],
  595. ];
  596. }
  597. if (!empty($dd_data)) {
  598. $dd_data = array_column($dd_data, null, 'name');
  599. $res['dd'] = [
  600. 'dd_app_key' => $dd_data['dd_app_key']['value'],
  601. 'dd_app_secret' => $dd_data['dd_app_secret']['value'],
  602. 'dd_shop_no' => $dd_data['dd_shop_no']['value'],
  603. ];
  604. }
  605. if (!empty($ss_data)) {
  606. $ss_data = array_column($ss_data, null, 'name');
  607. $res['ss'] = [
  608. 'ss_app_key' => $ss_data['ss_app_key']['value'],
  609. 'ss_app_secret' => $ss_data['ss_app_secret']['value'],
  610. 'ss_shop_no' => $ss_data['ss_shop_no']['value'],
  611. ];
  612. }
  613. if (!empty($mt_data)) {
  614. $mt_data = array_column($mt_data, null, 'name');
  615. $res['mt'] = [
  616. 'mt_app_key' => $mt_data['mt_app_key']['value'],
  617. 'mt_app_secret' => $mt_data['mt_app_secret']['value'],
  618. 'mt_shop_no' => $mt_data['mt_shop_no']['value'],
  619. ];
  620. }
  621. if (!empty($uu_data)) {
  622. $uu_data = array_column($uu_data, null, 'name');
  623. $res['uu'] = [
  624. 'uu_app_key' => $uu_data['uu_app_key']['value'],
  625. 'uu_app_secret' => $uu_data['uu_app_secret']['value'],
  626. 'uu_shop_no' => $uu_data['uu_shop_no']['value'],
  627. ];
  628. }
  629. return $res;
  630. }
  631. public static function getPrintOrderSetting(){
  632. $res = [
  633. 'note_show' => 0,
  634. 'note' => '',
  635. 'qrcode_show' => 0,
  636. 'not_pay_notice' => '',
  637. 'pay_notice' => ''
  638. ];
  639. $result = self::get(['note_show', 'note', 'qrcode_show','not_pay_notice','pay_notice'], get_store_id(), 'store');
  640. $result = array_column($result, null, 'name');
  641. if(!empty($result)){
  642. $res['note_show'] = (int)$result['note_show']['value'];
  643. $res['note'] = $result['note']['value'];
  644. $res['qrcode_show'] = (int)$result['qrcode_show']['value'];
  645. $res['not_pay_notice'] = $result['not_pay_notice']['value'];
  646. $res['pay_notice'] = $result['pay_notice']['value'];
  647. }
  648. return $res;
  649. }
  650. public static function getShareSaleSetting($store_id){
  651. $setting = self::get(OptionSetting::SHARE_STRING_CODE_SALE_SETTING, $store_id, OptionSetting::SHARE_GROUP_NAME, '{}');
  652. $setting = $setting ? Json::decode($setting['value']) : [];
  653. return $setting;
  654. }
  655. public static function getShareDefaultSetting($store_id){
  656. $setting = self::get(OptionSetting::SHARE_STRING_CODE_DEFAULT_SETTING, $store_id, OptionSetting::SHARE_GROUP_NAME, '{}');
  657. $setting = $setting ? Json::decode($setting['value']) : [];
  658. return $setting;
  659. }
  660. public static function getDecode($name,$store_id,$group){
  661. $setting = self::get($name, $store_id, $group, '{}');
  662. $setting = $setting ? Json::decode($setting['value']) : [];
  663. return $setting;
  664. }
  665. }