12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace JinDouYun\Model\Cashier;
- use JinDouYun\Dao\Cashier\DCashierSettings;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\ResultWrapper;
- /**
- * Description: 收银台设置
- * Class MCashierSettings
- * @package JinDouYun\Model\Cashier
- */
- class MCashierSettings
- {
- /**
- * @var DCashierSettings
- */
- private $objDCashierSettings;
- /**
- * @var integer
- */
- private $onlineUserId;
- /**
- * @var integer
- */
- private $onlineEnterpriseId;
- /**
- * MCashierSettings constructor.
- * @param $onlineUserId
- * @param $onlineEnterpriseId
- */
- public function __construct($onlineUserId, $onlineEnterpriseId)
- {
- $this->onlineUserId = $onlineUserId;
- $this->onlineEnterpriseId = $onlineEnterpriseId;
- $this->objDCashierSettings = new DCashierSettings();
- }
- /**
- * Doc: (des="获取配置")
- * User: XMing
- * Date: 2020/8/31
- * Time: 2:04 下午
- */
- public function get()
- {
- $setting = $this->objDCashierSettings->get(['enterpriseId'=>$this->onlineEnterpriseId],'content');
- if ($setting === false){
- return ResultWrapper::fail($this->objDCashierSettings->error(),ErrorCode::$dberror);
- }
- $settingData = empty($setting) ? (object)[] : json_decode($setting['content'],true);
- return ResultWrapper::success($settingData);
- }
- /**
- * Doc: (des="保存设置")
- * User: XMing
- * Date: 2020/8/31
- * Time: 2:20 下午
- * @param array $params
- * @return ResultWrapper
- */
- public function set(array $params)
- {
- $dbResult = $this->objDCashierSettings->replace($params);
- if ($dbResult === false){
- return ResultWrapper::fail($this->objDCashierSettings->error(),ErrorCode::$dberror);
- }
- return ResultWrapper::success('保存成功');
- }
- }
|