From dade6896f7da903b323a6d750ab03b5d50afb5db Mon Sep 17 00:00:00 2001 From: ljl Date: Tue, 30 Jan 2024 11:21:13 +0800 Subject: [PATCH] yh --- .../order/class.GoodsShortController.php | 44 +++++++++++++++++++ .../order/class.WaybillBillController.php | 1 + app/libs/services/Goods/GoodsShortService.php | 42 ++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/app/libs/controller/order/class.GoodsShortController.php b/app/libs/controller/order/class.GoodsShortController.php index 89bcd04..8d56275 100644 --- a/app/libs/controller/order/class.GoodsShortController.php +++ b/app/libs/controller/order/class.GoodsShortController.php @@ -63,6 +63,37 @@ class GoodsShortController extends AbstractApiController { return $this->renderSuccess(); } + /** + * @api POST 保存商品简称 + * @param object goodsShort * 商品简称map,key为itemId,示例:goodsShort[64be430447d6440001ab6350][shortTitle]=shortTitle + * @param string goodsShort.shortTitle 商品简称 + * @param string goodsShort.weight 商品重量 + * @param string goodsShort.warehouse 仓库/市场 + * @param string goodsShort.shelves 货架/档口 + */ + public function saveGoodsShort(){ + $this->goodsShortService->saveGoodsShort($_POST['goodsShort'], CommonTool::getOperatorInfo()); + $this->renderSuccess(); + } + + /** + * @api POST 还原商品简称 + * @param string goodsId * 商品ID + */ + public function revertGoodsShort() { + $this->goodsShortService->revertGoodsShort($this->mallId, $_POST['goodsId']); + return $this->renderSuccess(); + } + + /** + * @api POST 还原SKU简称 + * @param string skuId * SKU ID + */ + public function revertSkuShort() { + $this->goodsShortService->revertSkuShort($this->mallId, $_POST['skuId']); + return $this->renderSuccess(); + } + /** * @api GET 获取商品SKU列表 * @param array goodsIdAndMallIdMap 商品ID和店铺ID的map @@ -79,9 +110,22 @@ class GoodsShortController extends AbstractApiController { * @param string SkuShort.goodsId 商品ID * @param string SkuShort.skuId SKUID * @param string SkuShort.title 简称 + * @param string SkuShort.weight 重量 */ public function batchSaveSkuShort() { $this->goodsShortService->batchSaveSkuShort($this->mallId, $_POST['skuShortList']); return $this->renderSuccess(); } + + /** + * @api POST 保存SKU字段信息 + * @param string skuId * SKU ID + * @param string goodsId * 商品ID + * @param string field * 字段名,示例:shortTitle、weight + * @param string value * 字段值 + */ + public function saveSkuShortFieldValue() { + $this->goodsShortService->batchSaveSkuShort($this->mallId, $_POST); + return $this->renderSuccess(); + } } \ No newline at end of file diff --git a/app/libs/controller/order/class.WaybillBillController.php b/app/libs/controller/order/class.WaybillBillController.php index 3ef17e4..5822c96 100644 --- a/app/libs/controller/order/class.WaybillBillController.php +++ b/app/libs/controller/order/class.WaybillBillController.php @@ -19,6 +19,7 @@ class WaybillBillController extends AbstractApiController { /** * @api POST 快递对账 + * @param file file * 对账文件 * @param string logisticsCode * 快递编码 * @param string printTimeStart * 打印开始时间 * @param string printTimeStart * 打印结束时间 diff --git a/app/libs/services/Goods/GoodsShortService.php b/app/libs/services/Goods/GoodsShortService.php index 6b8de8c..d14ed83 100644 --- a/app/libs/services/Goods/GoodsShortService.php +++ b/app/libs/services/Goods/GoodsShortService.php @@ -2,6 +2,7 @@ namespace Service\Goods; use BizConst; +use CheckClient; use CommonTool; use Dao\Goods\GoodsDao; use Dao\Goods\OpGoodsShortDao; @@ -171,6 +172,17 @@ class GoodsShortService extends AbstractService { return $affRow; } + public function revertSkuShort($mallId, $skuId) { + $skuShort = $this->opSkuShortDao->getBySkuId($mallId, $skuId); + if (empty($skuShort)) { + return; + } + $ret = $this->opSkuShortDao->delete('sku_id = %i and mall_id = %s', $skuId, $mallId); + if ($ret === false) { + throw new BizException('商品简称还原失败'); + } + } + public function revertGoodsShort($mallId, $goodsId) { $goodsInfo = $this->goodsDao->getById($goodsId); if (empty($goodsInfo)) { @@ -526,7 +538,37 @@ class GoodsShortService extends AbstractService { 'short_title' => $skuShortInfo['title'], 'short_title_source' => OrderPrintConst::shortTitleSourceEdit ]; + if (isset($skuShortInfo['weight'])) { + $insertData['weight'] = $skuShortInfo['weight'] ?: null; + } $this->opSkuShortDao->save($skuShortInfo['mallId'], $skuShortInfo['skuId'], $skuShortInfo['goodsId'], $insertData); } } + + public function saveSkuShortFieldValue($mallId, $params) { + $skuId = $params['skuId'] ?: null; + $goodsId = $params['goodsId'] ?: null; + $field = $params['field']; + $value = trim($params['value']); + if (CommonTool::anyEmpty($skuId, $goodsId) || !in_array($field, array('shortTitle', 'weight'))) { + throw new CheckClientException('参数错误'); + } + if ($field == 'weight') { + $value = ZcNumberHelper::numFormat($value, 2); + } + $data = []; + if ($field == 'shortTitle') { + $data['short_title'] = $value; + $data['short_title_source'] = OrderPrintConst::shortTitleSourceEdit; + } + if ($field == 'weight') { + $data['weight'] = $value ?: null; + } + $goodsInfo = $this->goodsDao->getById($goodsId); + CheckClient::checkEmpty($goodsInfo, null, '商品信息错误'); + PermissionTool::checkMultiShopValid($mallId, $goodsInfo); + $authMallId = $goodsInfo['mallId']; + $aff = $this->opSkuShortDao->save($authMallId, $skuId, $goodsId, $data); + CheckClient::checkIsFalse($aff, '保存SKU信息失败'); + } } \ No newline at end of file