ERP.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\models\erp;
  8. use app\models\ErpInventory;
  9. use app\models\ErpInventoryLog;
  10. use app\models\ErpSupplier;
  11. use app\models\Goods;
  12. use app\models\Option;
  13. use app\constants\OptionSetting;
  14. class ERP extends Model
  15. {
  16. public static function conf($store_id){
  17. $conf = json_decode(Option::get(OptionSetting::ERP, $store_id, 'store', '{}')['value'], true);
  18. return [
  19. 'code'=>0,
  20. 'data' => $conf,
  21. ];
  22. }
  23. public static function confSave($store_id, $conf){
  24. $oldConf = self::conf($store_id)['data'];
  25. $data = array_merge($oldConf, $conf);
  26. $set = Option::set(OptionSetting::ERP, json_encode($data), $store_id, 'store');
  27. return [
  28. 'code'=>$set ? 0 : 1,
  29. 'msg'=>$set ? '保存成功' : '保存失败',
  30. ];
  31. }
  32. public static function getWarningNum($store_id){
  33. $conf = self::conf($store_id)['data'];
  34. return $conf ? $conf['warning_num'] : null;
  35. }
  36. public static function saveWarningNum($store_id, $warning_num){
  37. $conf = ['warning_num' => $warning_num];
  38. return self::confSave($store_id, $conf);
  39. }
  40. }