master
ljl 10 months ago
parent c2fd98250b
commit dade6896f7

@ -63,6 +63,37 @@ class GoodsShortController extends AbstractApiController {
return $this->renderSuccess();
}
/**
* @api POST 保存商品简称
* @param object goodsShort * 商品简称mapkey为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();
}
}

@ -19,6 +19,7 @@ class WaybillBillController extends AbstractApiController {
/**
* @api POST 快递对账
* @param file file * 对账文件
* @param string logisticsCode * 快递编码
* @param string printTimeStart * 打印开始时间
* @param string printTimeStart * 打印结束时间

@ -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信息失败');
}
}
Loading…
Cancel
Save