SupplyConfigModel.class.php 1.9 KB

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