SupplyConfigModel.class.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author cy 2020.08.01
  12. *
  13. */
  14. namespace Seller\Model;
  15. class SupplyConfigModel{
  16. public function update($data)
  17. {
  18. $supper_info = get_agent_logininfo();
  19. $supply_id = $supper_info['id'];
  20. foreach($data as $name => $value)
  21. {
  22. $info = M('lionfish_comshop_supply_config')->where( array('name' => $name,'supply_id'=>$supply_id) )->find();
  23. $value = htmlspecialchars($value);
  24. if( empty($info) )
  25. {
  26. $ins_data = array();
  27. $ins_data['name'] = $name;
  28. $ins_data['value'] = $value;
  29. $ins_data['supply_id'] = $supply_id;
  30. M('lionfish_comshop_supply_config')->add($ins_data);
  31. }else{
  32. $rs = M('lionfish_comshop_supply_config')->where( array('id' => $info['id']) )->save( array('value' => $value) );
  33. }
  34. }
  35. $this->get_all_config(true);
  36. }
  37. public function get_all_config($is_parse = false)
  38. {
  39. $supper_info = get_agent_logininfo();
  40. $supply_id = $supper_info['id'];
  41. $data = S('_get_all_supply_config_'.$supply_id);
  42. if (empty($data) || $is_parse) {
  43. $all_list = M('lionfish_comshop_supply_config')->where( array('supply_id' => $supply_id) )->select();
  44. if (empty($all_list)) {
  45. $data = array();
  46. }else{
  47. $data = array();
  48. foreach($all_list as $val)
  49. {
  50. $data[$val['name']] = htmlspecialchars_decode( $val['value'] );
  51. }
  52. }
  53. S('_get_all_supply_config_'.$supply_id, $data);
  54. }
  55. return $data;
  56. }
  57. /**
  58. * 删除满减配置项
  59. * @param $data
  60. */
  61. public function delete_config($data){
  62. $supper_info = get_agent_logininfo();
  63. $supply_id = $supper_info['id'];
  64. foreach($data as $name => $value)
  65. {
  66. $info = M('lionfish_comshop_supply_config')->where( array('name' => $name,'supply_id'=>$supply_id) )->find();
  67. $rs = M('lionfish_comshop_supply_config')->where( array('id' => $info['id']) )->delete();
  68. }
  69. $this->get_all_config(true);
  70. }
  71. }
  72. ?>