Setting.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\supplier\model\settings;
  3. use think\facade\Cache;
  4. use app\common\model\settings\Setting as SettingModel;
  5. use app\common\enum\settings\SettingEnum;
  6. class Setting extends SettingModel
  7. {
  8. /**
  9. * 更新系统设置
  10. */
  11. public function edit($key, $values,$shop_supplier_id=0)
  12. {
  13. $model = self::detail($key,$shop_supplier_id) ?: $this;
  14. // 删除系统设置缓存
  15. Cache::delete('setting_' . self::$app_id. '_'.$shop_supplier_id);
  16. return $model->save([
  17. 'key' => $key,
  18. 'describe' => SettingEnum::data()[$key]['describe'],
  19. 'values' => $values,
  20. 'app_id' => self::$app_id,
  21. 'shop_supplier_id' => $shop_supplier_id
  22. ]) !== false;
  23. }
  24. /**
  25. * 验证商城设置
  26. */
  27. private function validStore($values)
  28. {
  29. if (!isset($values['delivery_type']) || empty($values['delivery_type'])) {
  30. $this->error = '配送方式至少选择一个';
  31. return false;
  32. }
  33. return true;
  34. }
  35. /**
  36. * 验证小票打印机设置
  37. */
  38. private function validPrinter($values)
  39. {
  40. if ($values['is_open'] == false) {
  41. return true;
  42. }
  43. if (!$values['printer_id']) {
  44. $this->error = '请选择订单打印机';
  45. return false;
  46. }
  47. if (empty($values['order_status'])) {
  48. $this->error = '请选择订单打印方式';
  49. return false;
  50. }
  51. return true;
  52. }
  53. }