verify($param); if ($verifyResult['status'] != 1) { return $verifyResult; } if (!empty($param['sku_id'])) { $where = [ 'id' => $param['sku_id'] ]; $goodsModel = new RetailSkuGoodsModel(); } else { $where = [ 'id' => $param['goods_id'] ]; $goodsModel = new RetailGoodsModel(); } $state = $goodsModel->updateOrder($where, [ 'plu_code' => $param['plu_code'] ]); if ($state) { return callBack(statusCode()['success'], "修改成功"); } else { return callBack(statusCode()['success'], "暂无修改"); } } /** * 修改Plus码 * @param $param * [ * store_id * merchant_id * modify_type 1修改plus码 2修改价格 * goods_id * sku_id * plu_code * retail_price * ] * @return mixed */ public function modifyGoods($param) { $verifyResult = $this->verify($param); if ($verifyResult['status'] != 1) { return $verifyResult; } if (!empty($param['sku_id'])) { $where = [ 'id' => $param['sku_id'] ]; $goodsModel = new RetailSkuGoodsModel(); } else { $where = [ 'id' => $param['goods_id'] ]; $goodsModel = new RetailGoodsModel(); } $param['modify_type'] = $param['modify_type'] ? $param['modify_type'] : 1; switch ($param['modify_type']) { case 1: $data = [ 'plu_code' => $param['plu_code'] ]; break; case 2: $data = [ 'retail_price' => $param['retail_price'] ]; break; } $state = $goodsModel->updateOrder($where, $data); if ($state) { return callBack(statusCode()['success'], "修改成功"); } else { return callBack(statusCode()['success'], "暂无修改"); } } /** * 修改plus码验证 * @param $param * [ * store_id * merchant_id * modify_type 1修改plus码 2修改价格 * goods_id * sku_id * plu_code * retail_price 价格 * ] * @return mixed */ public function verify($param) { $param['modify_type'] = $param['modify_type'] ? $param['modify_type'] : 1; if (empty($param['merchant_id']) || empty($param['store_id'])) { return callBack(statusCode()['error'], "登录超时"); } if (!in_array($param['modify_type'], ['1', '2'])) { return callBack(statusCode()['error'], '修改类型有误'); } switch ($param['modify_type']) { case 1: if (empty($param['plu_code']) || !preg_match("/^[1-9]\d{0,3}$/", $param['plu_code'])) { return callBack(statusCode()['error'], "请输入正确的Plu码"); } break; case 2: if (empty($param['retail_price']) || !preg_match("/^[0-9]+(.[0-9]{1,2})?$/", $param['retail_price'])) { return callBack(statusCode()['error'], "请输入正确的价格"); } break; } return callBack(statusCode()['success'], "验证成功"); } }