MCashierSettings.Class.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace JinDouYun\Model\Cashier;
  3. use JinDouYun\Dao\Cashier\DCashierSettings;
  4. use Mall\Framework\Core\ErrorCode;
  5. use Mall\Framework\Core\ResultWrapper;
  6. /**
  7. * Description: 收银台设置
  8. * Class MCashierSettings
  9. * @package JinDouYun\Model\Cashier
  10. */
  11. class MCashierSettings
  12. {
  13. /**
  14. * @var DCashierSettings
  15. */
  16. private $objDCashierSettings;
  17. /**
  18. * @var integer
  19. */
  20. private $onlineUserId;
  21. /**
  22. * @var integer
  23. */
  24. private $onlineEnterpriseId;
  25. /**
  26. * MCashierSettings constructor.
  27. * @param $onlineUserId
  28. * @param $onlineEnterpriseId
  29. */
  30. public function __construct($onlineUserId, $onlineEnterpriseId)
  31. {
  32. $this->onlineUserId = $onlineUserId;
  33. $this->onlineEnterpriseId = $onlineEnterpriseId;
  34. $this->objDCashierSettings = new DCashierSettings();
  35. }
  36. /**
  37. * Doc: (des="获取配置")
  38. * User: XMing
  39. * Date: 2020/8/31
  40. * Time: 2:04 下午
  41. */
  42. public function get()
  43. {
  44. $setting = $this->objDCashierSettings->get(['enterpriseId'=>$this->onlineEnterpriseId],'content');
  45. if ($setting === false){
  46. return ResultWrapper::fail($this->objDCashierSettings->error(),ErrorCode::$dberror);
  47. }
  48. $settingData = empty($setting) ? (object)[] : json_decode($setting['content'],true);
  49. return ResultWrapper::success($settingData);
  50. }
  51. /**
  52. * Doc: (des="保存设置")
  53. * User: XMing
  54. * Date: 2020/8/31
  55. * Time: 2:20 下午
  56. * @param array $params
  57. * @return ResultWrapper
  58. */
  59. public function set(array $params)
  60. {
  61. $dbResult = $this->objDCashierSettings->replace($params);
  62. if ($dbResult === false){
  63. return ResultWrapper::fail($this->objDCashierSettings->error(),ErrorCode::$dberror);
  64. }
  65. return ResultWrapper::success('保存成功');
  66. }
  67. }