verifyParam($param); //参数验证 if ($verifyResult['status'] != 1) { return $verifyResult; } $where = $this->getTerm($param); //查询的条件 try { $InventorySetModel = new InventoryPrintModel(); $info = $InventorySetModel->getFind($where); return $info ? $info : []; } catch (\Exception $e) { return []; } } /** * 采购同时修改售价的设置 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * modify_price_state 1关闭 2开启 * ] * @return mixed */ public function modifyPriceState($param) { $verifyResult = $this->verifyParam($param); //参数验证 if ($verifyResult['status'] != 1) { return $verifyResult; } $where = $this->getTerm($param); //修改的条件 try { $info = $this->getInfo($param); //查询是否有数据 $InventorySetModel = new InventoryPrintModel(); if (!empty($info)) { $state = $InventorySetModel->updateData($where, [ 'modify_price_state' => $param['modify_price_state'] ]); } else { $where['modify_price_state'] = $param['modify_price_state']; $add = $InventorySetModel->addData($where); } if ($add['status'] == 1 || $state) { return callBack(statusCode()['success'], "设置成功"); } else { return callBack(statusCode()['error'], "设置失败"); } } catch (\Exception $e) { return callBack(statusCode()['error'], "设置失败"); } } /** * 获取查询修改的条件 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * ] * @return mixed */ public function getTerm($param) { $where = [ 'merchant_id' => $param['merchant_id'] ]; switch ($param['user_type']) { case 3: //商户 $where['type'] = 1; break; case 4: //门店 $where['store_id'] = $param['store_id']; $where['type'] = 2; break; } return $where; } /** * 参数验证 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * ] * @return mixed */ public function verifyParam($param) { if (!in_array($param['user_type'], ['3', '4']) || empty($param['merchant_id']) || ($param['user_type'] == 4 && empty($param['store_id']))) { return callBack(statusCode()['error'], "登录超时,请重新登录"); } return callBack(statusCode()['success'], "验证成功"); } }