12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- /**
- * 小梦科技资源nanodreamtech.com
- *
- * ==========================================================================
- * @link https://www.nanodreamtech.com/
- * @copyright Copyright (c) 2015 liofis.com.
- * @license https://www.nanodreamtech.com/license.html License
- * ==========================================================================
- *
- * @author fish
- *
- */
- namespace Seller\Model;
- class ConfigModel{
-
-
- public function update($data)
- {
- foreach($data as $name => $value)
- {
-
- $info = M('lionfish_comshop_config')->where( array('name' => $name) )->find();
-
- $value = htmlspecialchars($value);
- if( empty($info) )
- {
- $ins_data = array();
- $ins_data['name'] = $name;
- $ins_data['value'] = $value;
- M('lionfish_comshop_config')->add($ins_data);
- }else{
-
- $rs = M('lionfish_comshop_config')->where( array('id' => $info['id']) )->save( array('value' => $value) );
-
- }
-
- }
- $this->get_all_config(true);
- }
-
- public function get_all_config($is_parse = false)
- {
-
- $data = S('_get_all_config');
-
- if (empty($data) || $is_parse) {
-
- $all_list = M('lionfish_comshop_config')->select();
- if (empty($all_list)) {
- $data = array();
- }else{
- $data = array();
- foreach($all_list as $val)
- {
- $data[$val['name']] = htmlspecialchars_decode( $val['value'] );
- }
- }
-
- S('_get_all_config', $data);
- }
- return $data;
- }
- /**
- * 删除满减配置项
- * @param $data
- */
- public function delete_config($data){
- foreach($data as $name => $value)
- {
- $info = M('lionfish_comshop_config')->where( array('name' => $name) )->find();
- $rs = M('lionfish_comshop_config')->where( array('id' => $info['id']) )->delete();
- }
- $this->get_all_config(true);
- }
-
- }
- ?>
|