123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739 |
- <?php
- /**
- * 商品管理模块
- * Created by PhpStorm.
- * User: wxj
- * Date: 2019/10/30
- * Time: 13:54
- */
- namespace JinDouYun\Controller\Goods;
- use JinDouYun\Controller\Common\Logger;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\ResultWrapper;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Goods\MGoods;
- use Monolog\Handler\IFTTTHandler;
- /**
- * Class Goods
- * @package JinDouYun\Controller\Goods
- */
- class Goods extends BaseController
- {
- /**
- * @var MGoods
- */
- private $objMGoods;
- /**
- * Goods constructor.
- * @param bool $isCheckAcl
- * @param bool $isMustLogin
- * @throws \Exception
- */
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMGoods = new MGoods($this->onlineEnterpriseId, false, $this->onlineUserId);
- }
- /**
- * 添加和编辑商品管理公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $goodsData = [
- 'basicGoodsId' => isset($params['goodsBasicId']) ? $params['goodsBasicId'] : '',//基本资料id
- 'goodsName' => isset($params['goodsName']) ? $params['goodsName'] : '',//基本资料商品名称
- 'shopId' => isset($params['shopId']) ? $params['shopId'] : '',//商铺id
- 'shopName' => isset($params['shopName']) ? $params['shopName'] : '',//商铺名称
- 'images' => isset($params['images']) ? json_encode($params['images']) : '',
- 'specType' => isset($params['specType']) ? $params['specType'] : null,//规格类型
- 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : StatusCode::$delete,
- //'serviceInfo' => isset($params['serviceInfo']) ? $params['serviceInfo'] : '',
- 'priceData' => isset($params['price']) ? $params['price'] : '',//接json值
- //'specification' => isset($params['specification']) ? json_encode($params['specification']) : '',//接json值
- 'createUserName' => isset($params['createUserName']) ? $params['createUserName'] : '',//添加商品人名称
- ];
- foreach ($goodsData as $key => $value) {
- if (empty($value) && $value !== 0) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- isset($params['deliverySupIds']) && $goodsData['deliverySupIds'] = $params['deliverySupIds'];
- isset($params['expressType']) && $goodsData['expressType'] = $params['expressType'];
- isset($params['ruleId']) && $goodsData['ruleId'] = $params['ruleId'];
- isset($params['expressFee']) && $goodsData['expressFee'] = $params['expressFee'];
- isset($params['showExpress']) && $goodsData['showExpress'] = $params['showExpress'];
- $goodsData['content'] = isset($params['content']) ? $params['content'] : '';
- $goodsData['isRecommend'] = isset($params['isRecommend']) ? $params['isRecommend'] : StatusCode::$standard;
- $goodsData['createTime'] = time();
- $goodsData['updateTime'] = time();
- $goodsData['deleteStatus'] = StatusCode::$standard;
- $goodsData['sort'] = isset($params['sort']) ? $params['sort'] : 0;
- $goodsData['isShield'] = getArrayItem($params,'isShield',StatusCode::$delete);
- $goodsData['notArea'] = json_encode(getArrayItem($params,'notArea',null));
- $goodsData['notCustomerType'] = getArrayItem($params,'notCustomerType','');
- $goodsData['notCustomer'] = getArrayItem($params,'notCustomer','');
- $goodsData['isDistribution'] = getArrayItem($params,'isDistribution',StatusCode::$delete);
- $goodsData['support'] = getArrayItem($params,'support',[]);
- $goodsData['support'] = implode(',',$goodsData['support'] );
- $goodsData['goodsGroups'] = getArrayItem($params,'goodsGroups');//商品分组
- $goodsData['showMinUnitPrice'] = getArrayItem($params,'showMinUnitPrice',4);//属性最小单位价格是否展示 默认 4 不展示
- if ( !empty($goodsData['goodsGroups']) ){
- $goodsData['goodsGroups'] = implode(',', $goodsData['goodsGroups']);
- }
- return $goodsData;
- }
- /**
- * 添加商品
- * @throws \Exception
- */
- public function addGoods()
- {
- $goodsData = $this->commonFieldFilter();
- $result = $this->objMGoods->addGoods($goodsData);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * @throws \Exception
- */
- public function getGoodsInfo()
- {
- $goodsId = $this->request->param('request_id');
- if (!$goodsId) {
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $params = $this->request->getRawJson();
- $userCenterId = 0;
- if (isset($params['userCenterId']) && !empty($params['userCenterId'])) {
- //后台选择了客户
- $this->objMGoods = new MGoods($this->onlineEnterpriseId, false, $params['userCenterId']);
- $userCenterId = $params['userCenterId'];
- }
- $result = $this->objMGoods->getGoodsInfo($goodsId,$userCenterId);
- if ($result->isSuccess()) {
- $resultData = $result->getData();
- $this->sendOutput($resultData);
- }
- $this->sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 更新商品上下架
- * @throws \Exception
- */
- public function updateEnableStatus()
- {
- $params = $this->request->getRawJson();
- if (empty($params['id']) && empty($params['enableStatus'])) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $result = $this->objMGoods->updateEnableStatus($params);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 编辑商品
- */
- public function editGoods()
- {
- $goodsId = $this->request->param('request_id');
- if (empty($goodsId)) {
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $goodsData = $this->commonFieldFilter();
- $goodsData['id'] = $goodsId;
- unset($goodsData['createTime']);
- $result = $this->objMGoods->editGoods($goodsData);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * Doc: (des="审核商品")
- * User: XMing
- * Date: 2020/12/7
- * Time: 11:31 上午
- */
- public function audit()
- {
- $goodsId = $this->request->param('request_id');
- if (empty($goodsId)) {
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMGoods->audit($goodsId);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 删除商品
- */
- public function delGoods()
- {
- $goodsId = $this->request->param('request_id');
- if (!$goodsId) {
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMGoods->delGoods($goodsId);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 后台所有商品列表
- * @throws \Exception
- */
- public function getAllGoods()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- if (isset($this->shopId) && !empty($this->shopId)) {
- $selectParams['shopId'] = $this->shopId;
- }
-
- if (isset($params['shopId']) && !empty($params['shopId'])) {
- $selectParams['shopId'] = $params['shopId'];
- }
- if (isset($params['isOption']) && !empty($params['isOption'])){
- $selectParams['isOption'] = $params['isOption'];
- }
- //ifMerchant (4 采购单 5商户入库单)
- if( isset($params['ifMerchant']) && !empty($params['ifMerchant']) ){
- $selectParams['ifMerchant'] = $params['ifMerchant'];
- }
- if( isset($params['merchantId']) && !empty($params['merchantId']) ){
- $selectParams['merchantId'] = $params['merchantId'];
- }
- //销售中 页面显示有库存,已上架,的商品。
- if (isset($params['inSales']) && !empty($params['inSales'])) {
- $selectParams['enableStatus'] = StatusCode::$standard;
- $selectParams['inStock'] = StatusCode::$standard;
- }
- //有无库存 inStock 5仓库中 4已售空
- if (isset($params['inStock']) && !empty($params['inStock'])) {
- if ($params['inStock'] == StatusCode::$standard) {
- //仓库中:有库存,未上架的商品列表
- $selectParams['enableStatus'] = StatusCode::$delete;
- $selectParams['inStock'] = $params['inStock'];
- } else {
- //已售罄:库存为0,自动下架的商品列表
- $selectParams['inStock'] = $params['inStock'];
- }
- }
- // 分页
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- if (isset($params['enableStatus'])) {
- $selectParams['enableStatus'] = $params['enableStatus'];
- }
- // 导出
- $is_export = false;
- if (isset($params['export']) && $params['export'] == 1) $is_export = true;
- $selectParams['auditStatus'] = StatusCode::$auditStatus['auditPass'];
- if (isset($params['auditStatus']) && !empty($params['auditStatus'])){
- $selectParams['auditStatus'] = $params['auditStatus'];
- }
- $selectParams['supplierId'] = $this->supplierId;
- $result = $this->objMGoods->getAllGoods($selectParams, '*', 'topTime desc, sort desc,createTime desc', $is_export);
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
-
- /**
- * 商品列表页
- */
- public function getAllGoodsList()
- {
- $paramsData = $this->request->getRawJson();
- $params = [
- 'pageSize' => isset($paramsData['pageSize']) ? $paramsData['pageSize'] : 10,
- 'page' => isset($paramsData['page']) ? $paramsData['page'] : 1,
- ];
- $offset = ($params['page'] - 1) * $params['pageSize'];
- $selectParams = [
- 'limit' => $params['pageSize'],
- 'offset' => $offset,
- ];
- foreach ($selectParams as $key => $value) {
- if (empty($value) && $value !== 0) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- // keywordType 1全部商品 2(销售中 上架且有库存) 3(已售罄 上架无库存) 4(仓库中 下架)
- $selectParams['keywordType'] = getArrayItem($paramsData,'keywordType',1);
- $selectParams['keyword'] = getArrayItem($paramsData,'keyword'); // 商品名称或商品编码
- $selectParams['categoryId'] = getArrayItem($paramsData,'categoryId'); // 商品分类
- $selectParams['brandId'] = getArrayItem($paramsData,'brandId'); //商品品牌
- $selectParams['enableStatus']= getArrayItem($paramsData,'enableStatus'); // 上下架(5上架 4下架)
- $selectParams['ifMerchant']= getArrayItem($paramsData,'ifMerchant'); //ifMerchant (4 采购单 5商户入库单)
- $selectParams['merchantId']= getArrayItem($paramsData,'merchantId'); //
-
- $export = getArrayItem($paramsData,'export',''); // 导出
- if(isset($this->shopId) && !empty($this->shopId)){
- $selectParams['shopId'] = $this->shopId ;
- }else{
- $selectParams['shopId'] = getArrayItem($paramsData,'shopId',0); //销售店铺
- }
- $selectParams['categoryPath']= getArrayItem($paramsData,'categoryPath');
- $goodsData = $this->objMGoods->getAllGoodsList($selectParams,$export);
- if ($goodsData->isSuccess()) {
- $returnData = $goodsData->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }
- parent::sendOutput($goodsData->getData(), ErrorCode::$dberror);
- }
- /**
- * 格式化所有商品搜索条件
- * @throws \Exception
- */
- public function formatGoodsCondition()
- {
- $params = $this->request->param('request_id');
- if (empty($params)) {
- parent::sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMGoods->formatGoodsCondition($params);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- /**
- * 创建订单搜索商品
- * @throws \Exception
- */
- public function getGoodsByCondition()
- {
- $params = $this->request->getRawJson();
- $type = isset($params['type']) ? $params['type'] : false;
- $data['condition'] = isset($params['condition']) ? trim($params['condition']) : '';
- $data['enableStatus'] = isset($params['enableStatus']) ? $params['enableStatus'] : 0;
- if (isset($this->shopId) && !empty($this->shopId)) $data['shopId'] = $this->shopId;
- $data['shopId'] = isset($params['shopId']) ? $params['shopId'] : [];
- $modelResult = $this->objMGoods->getGoodsByCondition($data, $type);
- if (!$modelResult->isSuccess()) {
- parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
- }
- parent::sendOutput($modelResult->getData());
- }
- /**
- * Doc: (des="es-商品搜索")
- * @example
- * 销售中 = 上架有库存
- * 已售罄 = 上下架没库存的
- * 仓库中 = 下架有库存
- * User: XMing
- * Date: 2020/11/30
- * Time: 10:43 上午
- * @throws \Exception
- */
- public function search()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $selectParams = [
- 'categoryPath' => isset($params['categoryPath']) ? $params['categoryPath'] : '',
- 'categoryId' => isset($params['categoryId']) ? $params['categoryId'] : '',
- 'brandId' => isset($params['brandId']) ? $params['brandId'] : '',
- 'keyword' => isset($params['keyword']) ? $params['keyword'] : '',
- 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : '',//销售状态
- 'shopId' => isset($params['shopId']) ? $params['shopId'] : '',
- ];
- //销售中 页面显示有库存,已上架,的商品。
- if (isset($params['inSales']) && !empty($params['inSales'])) {
- $selectParams['enableStatus'] = StatusCode::$standard;
- $selectParams['inStock'] = StatusCode::$standard;
- }
- //有无库存 inStock 5仓库中 4已售空
- if (isset($params['inStock']) && !empty($params['inStock'])) {
- if ($params['inStock'] == StatusCode::$standard) {
- //仓库中:有库存,未上架的商品列表
- $selectParams['enableStatus'] = StatusCode::$delete;
- $selectParams['inStock'] = $params['inStock'];
- } else {
- //已售罄:库存为0,自动下架的商品列表
- $selectParams['inStock'] = $params['inStock'];
- }
- }
- if (isset($this->shopId) && !empty($this->shopId)) $selectParams['shopId'] = $this->shopId;
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- $is_export = false;
- if (isset($params['export']) && $params['export'] == 1) $is_export = true;
- $selectParams['auditStatus'] = StatusCode::$auditStatus['auditPass'];
- if (isset($params['auditStatus']) && !empty($params['auditStatus'])){
- $selectParams['auditStatus'] = $params['auditStatus'];
- }
-
- //ifMerchant (4 采购单 5商户入库单)
- if( isset($params['ifMerchant']) && !empty($params['ifMerchant']) ){
- $selectParams['ifMerchant'] = $params['ifMerchant'];
- }
- if( isset($params['merchantId']) && !empty($params['merchantId']) ){
- $selectParams['merchantId'] = $params['merchantId'];
- }
- $result = $this->objMGoods->search($selectParams, $is_export);
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- //修补es数据
- public function fixEsData()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- isset($params['id']) && $selectParams['id'] = $params['id'];
- $pageParams = pageToOffset(1, 4000);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- $this->objMGoods->fixEsData($selectParams);
- }
- /**
- *
- * @throws \Exception
- */
- public function getGoodsByBarCode()
- {
- $params = $this->request->getRawJson();
- if (empty($params['barCode'])) {
- $this->sendOutput('barCode参数为空', ErrorCode::$paramError);
- }
- $result = $this->objMGoods->getGoodsByBarCode($params['barCode']);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- /**
- *
- * @throws \Exception
- */
- public function getAllGoodsBySku()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $pageParams = pageToOffset(isset($params['page']) ? $params['page'] : 1, isset($params['pageSize']) ? $params['pageSize'] : 10);
- $data['limit'] = $pageParams['limit'];
- $data['offset'] = $pageParams['offset'];
- $data['keyword'] = isset($params['keyword']) ? $params['keyword'] : '';
- $data['shopId'] = isset($params['shopId']) ? $params['shopId'] : '';
- $data['categoryId'] = isset($params['categoryId']) ? $params['categoryId'] : '';
- $data['isRevealSku'] = getArrayItem($params,'isRevealSku','');
- if (isset($this->shopId) && !empty($this->shopId)) $data['shopId'] = $this->shopId;
- $data['userCenterId'] = getArrayItem($params,'userCenterId',0);
- $result = $this->objMGoods->getAllGoodsBySku($data);
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => isset($params['page']) ? $params['page'] : 1,
- 'pageSize' => isset($params['pageSize']) ? $params['pageSize'] : 10,
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 获取所有sku
- */
- public function getAllSku()
- {
- $params = $this->request->getRawJson();
- $result = $this->objMGoods->getAllSku($params);
- if(!$result->isSuccess()){
- parent::sendOutput($result->getData(),$result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- /**
- * Doc: (des="设置商品置顶/取消商品置顶")
- * User: XMing
- * Date: 2020/8/28
- * Time: 11:04 上午
- */
- public function setTop()
- {
- $goodsId = $this->request->param('request_id');
- if (empty($goodsId)) {
- parent::sendOutput('id参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMGoods->setTop($goodsId);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
-
- /**
- * Doc: (des="修改排序字段")
- */
- public function setSort()
- {
- $params = $this->request->getRawJson();
- $params['id'] = getArrayItem($params,'id');
- $params['sort'] = getArrayItem($params,'sort',0);
- foreach ($params as $key => $value) {
- if (empty($value)) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $result = $this->objMGoods->setSort($params);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- /**
- * Doc: (des="批量设置虚拟销量")
- * User: XMing
- * Date: 2020/9/3
- * Time: 9:10 上午
- * @throws \Exception
- */
- public function setSalesNumBatch()
- {
- $params = $this->request->getRawJson();
- $data = [
- 'ids' => isset($params['ids']) ? $params['ids'] : null,
- 'minVal' => isset($params['minVal']) ? $params['minVal'] : null,
- 'maxVal' => isset($params['maxVal']) ? $params['maxVal'] : null,
- ];
- foreach ($data as $key => $value) {
- if (empty($value) && $value != 0) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- if ($data['minVal'] > $data['maxVal']) {
- parent::sendOutput('阀值设置有误', ErrorCode::$paramError);
- }
- $result = $this->objMGoods->setSalesNumBatch($data);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- /**
- * Doc: (des="")
- * User: XMing
- * Date: 2020/9/10
- * Time: 3:07 下午
- */
- public function batchGoodsExpress()
- {
- $params = $this->request->getRawJson();
- $data = [
- 'ids' => isset($params['ids']) ? $params['ids'] : null,
- 'expressType' => isset($params['expressType']) ? $params['expressType'] : null,
- ];
- foreach ($data as $key => $value) {
- if (empty($value)) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- if ($data['expressType'] == StatusCode::$expressType['rule']) {
- if (!isset($params['ruleId']) || empty($params['ruleId'])) {
- parent::sendOutput('ruleId参数错误', ErrorCode::$paramError);
- }
- $data['ruleId'] = $params['ruleId'];
- }
- if ($data['expressType'] == StatusCode::$expressType['unify']) {
- if (!isset($params['expressFee']) || (empty($params['expressFee']) && $params['expressFee'] != 0)) {
- parent::sendOutput('expressFee参数错误', ErrorCode::$paramError);
- }
- $data['expressFee'] = $params['expressFee'];
- }
- $result = $this->objMGoods->batchGoodsExpress($data);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- /**
- * Doc: (des="批量设置运费")
- * User: XMing
- * Date: 2020/9/3
- * Time: 10:41 上午
- */
- public function setSalesNum()
- {
- $params = $this->request->getRawJson();
- $data = [
- 'id' => isset($params['id']) ? $params['id'] : null,
- 'val' => isset($params['val']) ? $params['val'] : null,
- ];
- foreach ($data as $key => $value) {
- if (empty($value) && $value != 0) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- if ($data['minVal'] > $data['maxVal']) {
- parent::sendOutput('阀值设置有误', ErrorCode::$paramError);
- }
- $result = $this->objMGoods->setSalesNum($data);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- /**
- * Doc: (des="根据基础物料id及店铺id,获取物料id对应商品id")
- * User: XMing
- * Date: 2020/12/25
- * Time: 3:57 下午
- */
- public function getRelMap()
- {
- $params = $this->request->getRawJson();
- $data = [
- 'shopId' => getArrayItem($params,'shopId',null),
- 'materielIds' => getArrayItem($params,'materielIds',null),
- ];
- foreach ($data as $key => $val){
- if (is_null($val) || empty($val)) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $result = $this->objMGoods->getRelMap($data);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- /**
- * Doc: (des="获取价格走势")
- * User: XMing
- * Date: 2021/3/10
- * Time: 6:45 下午
- * @throws \Exception
- */
- public function getPriceTrend()
- {
- $goodsId = $this->request->param('request_id');
- if (empty($goodsId)) {
- parent::sendOutput('goodsId参数错误', ErrorCode::$paramError);
- }
- $params = (array)$this->request->getRawJson();
- $params['startTime'] = isset($params['startTime']) && !empty($params['startTime']) ? $params['startTime'] : strtotime(date('Y-m-d 00:00:00',strtotime('-10 day')));
- $params['endTime'] = isset($params['endTime']) && !empty($params['endTime']) ? $params['endTime'] :strtotime(date('Y-m-d 00:00:00'));
- $params['type'] = getArrayItem($params,'type',StatusCode::$standard);//5销售价格 4采购价格
- $result = $this->objMGoods->getPriceTrend($goodsId,$params);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- /**
- * Doc: (des="批量设置负库存销售")
- * User: XMing
- * Date: 2021/3/13
- * Time: 10:11 上午
- */
- public function batchSetDistribution()
- {
- $params = $this->request->getRawJson();
- $data = [
- 'ids' => getArrayItem($params,'ids',null),
- 'isDistribution' => getArrayItem($params,'isDistribution',null),
- ];
- foreach ($data as $key => $val){
- if (is_null($val) || empty($val)) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $result = $this->objMGoods->batchSetDistribution($data);
- if (!$result->isSuccess()) {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- parent::sendOutput($result->getData());
- }
- }
|