123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697 |
- <?php
- namespace JinDouYun\Controller\Goods;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Dao\GoodsCategory\DGoodsCategory;
- use JinDouYun\Dao\GoodsManage\DGoodsBrand;
- use JinDouYun\Dao\GoodsManage\DUnits;
- use JinDouYun\Dao\Merchant\DMerchantApply;
- use JinDouYun\Model\Goods\MQuickGoods;
- use JinDouYun\Model\Shop\MShop;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use Util\Common\ChineseCharacter;
- /**
- * 单店铺快速发布商品
- * 单位和规格的组合完全由前端进行生成
- * 单位(主/辅)
- * 单位+属性+价格(index unitId+specValueId...)
- * Class QuickGoods
- * @package JinDouYun\Controller\Goods
- */
- class QuickGoods extends BaseController
- {
- private $objMQuickGoods;
- public $shopId;
- public $shopName;
- private $isStore = false;//商户发布=>TRUE
- /**
- * QuickGoods constructor.
- * @param bool $isCheckAcl
- * @param bool $isMustLogin
- * @throws \Exception
- */
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMQuickGoods = new MQuickGoods($this->onlineEnterpriseId,$this->onlineUserId);
- }
- /**
- * 但店铺,查询默认店铺id,name
- */
- public function _initShop()
- {
- if ($this->isStore){
- $objMShop = new MShop($this->onlineEnterpriseId,$this->onlineUserId);
- $shopName = $objMShop->getShopNameById($this->shopId);
- $this->shopName = $shopName;
- }else{
- $shopResult = $this->objMQuickGoods->getShopData();
- if (!$shopResult->isSuccess()){
- parent::sendOutput($shopResult->getData(), ErrorCode::$dberror);
- }
- $shopData = $shopResult->getData();
- if (empty($shopData)){
- parent::sendOutput('请先创建店铺',ErrorCode::$paramError);
- }
- $this->shopId = isset($shopData['id']) ? $shopData['id'] : 0;
- $this->shopName = isset($shopData['name']) ? $shopData['name'] : '';
- return $shopData;
- }
- }
- /**
- * 公共字段
- *
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- ( isset($params['isStore']) && $params['isStore'] == true ) && $this->isStore = true;
- self::_initShop();
- $data = [
- 'title' => isset($params['title']) ? $params['title'] : null,
- 'categoryId' => isset($params['categoryId']) ? $params['categoryId'] : null,
- 'categoryPath' => isset($params['categoryPath']) ? $params['categoryPath'] : null,
- 'images' => isset($params['images']) ? json_encode($params['images']) : null,//商品图册json
- 'unitData' => isset($params['unitData']) ? $params['unitData'] : null,//商品单位
- 'specType' => isset($params['specType']) ? $params['specType'] : null,
- 'specMultiple' => isset($params['specMultiple']) ? $params['specMultiple'] : null,
- 'shopId' => $this->shopId,//商铺id
- 'shopName' => $this->shopName,//商铺名称
- ];
- foreach ($data as $key => $value) {
- if (empty($value)) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- foreach ($data['specMultiple'] as $item){
- if ($item['isMaster']==StatusCode::$delete){
- if (empty((int) $item['conversion'])){
- parent::sendOutput('辅单位换算比例有误', ErrorCode::$paramError);
- }
- }
- }
- //商品名称转换搜索条件
- if(isset($data['title'])){
- $objChineseCharacter = new ChineseCharacter();
- $data['condition'] = $objChineseCharacter->getInitials(trim($data['title']));
- }
- $data['isStore'] = $this->isStore;
- $data['specGroup'] = isset($params['specGroup']) ? json_encode($params['specGroup']) : [];//规格组
- $data['brandId'] = isset($params['brandId']) ? $params['brandId'] : 0;
- $data['description'] = isset($params['description']) ? $params['description'] : '';
- $data['describe'] = isset($params['describe']) ? $params['describe'] : '';
- $data['expireTime'] = isset($params['expireTime']) ? $params['expireTime'] : 0;
- $data['tag'] = isset($params['tag']) ? $params['tag'] : '';
- $data['barCode'] = isset($params['barCode']) ? $params['barCode'] : '';//条码
- $data['link'] = isset($params['link']) ? $params['link'] : '';
- $data['noSalesShop'] = isset($params['noSalesShop']) ? $params['noSalesShop'] : ''; //禁止销售店铺
- $data['assistCategoryId'] = isset($params['assistCategoryId']) ? $params['assistCategoryId'] : '';
- $data['assistCategoryPath'] = isset($params['assistCategoryPath']) ? json_encode($params['assistCategoryPath']) : [];
- //商品
- $data['sort'] = isset($params['sort']) ? $params['sort'] : 9999;//商品排序
- $data['enableStatus'] = isset($params['enableStatus']) ? $params['enableStatus'] : StatusCode::$delete;
- $data['createUserName'] = isset($params['createUserName']) ? $params['createUserName'] : '';
- $storage = isset($params['storage']) ? $params['storage'] : '';//货架编码
- $data['extends'] = json_encode(['storage'=>$storage]);//货架编码
- isset($params['deliverySupIds']) && $data['deliverySupIds'] = $params['deliverySupIds'];
- isset($params['expressType']) && $data['expressType'] = $params['expressType'];
- isset($params['ruleId']) && $data['ruleId'] = $params['ruleId'];
- isset($params['expressFee']) && $data['expressFee'] = $params['expressFee'];
- isset($params['showExpress']) && $data['showExpress'] = $params['showExpress'];
- (isset($this->supplierId) && !empty($this->supplierId)) && $data['supplierId'] = $this->supplierId;
- $data['isEq'] = isset($params['isEq']) ? $params['isEq'] : null;
- $data['merchantId'] = getArrayItem($params, 'merchantId', 0);
- $data['isShield'] = getArrayItem($params,'isShield',StatusCode::$delete);
- $data['notArea'] = json_encode(getArrayItem($params,'notArea',null));
- $data['notCustomerType'] = getArrayItem($params,'notCustomerType','');
- $data['notCustomer'] = getArrayItem($params,'notCustomer','');
- $data['isDistribution'] = getArrayItem($params,'isDistribution',StatusCode::$delete);
- $data['createUserName'] = getArrayItem($params,'createUserName','');
- return $data;
- }
- /**
- * 添加商品基础资料
- * @throws \Exception
- */
- public function addBasicAndPublishGoods()
- {
- $data = self::commonFieldFilter();
- //添加商品基础资料
- $result = $this->objMQuickGoods->addBasicAndPublishGoods($data);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 商品及商品基础资料详情
- * @throws \Exception
- */
- public function getQuickGoodsInfo()
- {
- $goodsId = $this->request->param('request_id');
- if (!$goodsId) {
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMQuickGoods->getQuickGoodsInfo($goodsId);
- if ($result->isSuccess()) {
- $resultData = $result->getData();
- $this->sendOutput($resultData);
- }
- $this->sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 编辑
- * @throws \Exception
- */
- public function editQuickGoods()
- {
- $data = self::commonFieldFilter();
- $params = $this->request->getRawJson();
- if (!isset($params['id']) || empty($params['id'])){
- parent::sendOutput('id参数错误', ErrorCode::$paramError);
- }
- if (!isset($params['basicGoodsId']) || empty($params['basicGoodsId'])){
- parent::sendOutput('basicGoodsId参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMQuickGoods->editQuickGoods($data,$params['id'],$params['basicGoodsId']);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
-
-
- /**
- * 接收导入数据参数
- * @throws \Exception
- */
- public function getGoodsQuickImportParams()
- {
- //获取数据文件
- $params = $this->request->getRawJson();
-
- //企业id
- $enterpriseId = $this->onlineEnterpriseId;
-
- //商品图片
- $images = [];
-
- //多单位
- $twoUnit = true;
-
- //引用dao
- $objDGoodsCategory = new DGoodsCategory();
- $objDGoodsCategory->setTable('qianniao_goods_category_' . $enterpriseId);
-
- $objDGoodsBrand = new DGoodsBrand();
- $objDGoodsBrand->setTable('qianniao_goods_brand_' . $enterpriseId);
-
- $objDUnits = new DUnits();
- $objDUnits->setTable('qianniao_units_' . $enterpriseId);
-
- $objDMerchantApply = new DMerchantApply();
- //获取数据
- $postArray = [];
- foreach ($params as $value) {
- $goodsArray = $value;
- //商品信息
- $goodsName = isset($goodsArray['goodsName']) ? trim($goodsArray['goodsName']) : '';//商品名称
- $describe = isset($goodsArray['describe']) ? trim($goodsArray['describe']) : '';//商品卖点
- $categoryName = isset($goodsArray['categoryName']) ? trim($goodsArray['categoryName']) : ''; //分类名称
- $categoryTwo = isset($goodsArray['categoryTwo']) ? trim($goodsArray['categoryTwo']) : '';//二级分类名称
- $categoryThree = isset($goodsArray['categoryThree']) ? trim($goodsArray['categoryThree']) : '';//三级分类名称
-
- // //商户名称
- $merchantName = isset($goodsArray['merchantName']) ? trim($goodsArray['merchantName']) : '';//商户名称
- // $brandName = isset($goodsArray['brandName']) ? trim($goodsArray['brandName']) : '';//品牌名称
-
- $isEq = isset($goodsArray['isEq']) ? trim($goodsArray['isEq']) : 4;//是否抄码
- $description = isset($goodsArray['description']) ? '<p>' . trim($goodsArray['description']) . '</p>' : '';//商品详情
-
- //主单位信息
- $skuName = isset($goodsArray['skuName']) ? trim($goodsArray['skuName']) : '无';//单位名称
- $salePrice = isset($goodsArray['salePrice']) ? trim($goodsArray['salePrice']) : 1;//销售价
- $memberPrice = isset($goodsArray['memberPrice']) ? trim($goodsArray['memberPrice']) : 1;//会员价
- $barCode = isset($goodsArray['barCode']) ? trim($goodsArray['barCode']) : '';//主单位条码
- $salePriceTrue = isset($goodsArray['salePriceTrue']) ? trim($goodsArray['salePriceTrue']) : bcmul($salePrice, 1.2, 2);//市场价格
-
- //辅单位信息
- if ($twoUnit) {
- $skuNameTwo = isset($goodsArray['skuNameTwo']) ? trim($goodsArray['skuNameTwo']) : '';//辅单位
- $barCodeTwo = isset($goodsArray['barCodeTwo']) ? trim($goodsArray['barCodeTwo']) : '';//辅单位条码
- $salePriceTwo = isset($goodsArray['salePriceTwo']) ? trim($goodsArray['salePriceTwo']) : 1;//辅单位销售价格
- $conversion = isset($goodsArray['conversion']) ? trim($goodsArray['conversion']) : 0;//辅单位换算比例
- $salePriceTwoTrue = isset($goodsArray['salePriceTwoTrue']) ? trim($goodsArray['salePriceTwoTrue']) : bcmul($salePriceTwo, 1.2, 2);//辅单位市场价格
- }
-
- if (empty($goodsName)) {
- continue;
- }
-
- /***商户数据***/
- if (!empty($merchantName)) {
- //查询商户是否存在
- $merchantSelect = [
- 'name' => $merchantName,
- ];
- $dbResult = $objDMerchantApply->get($merchantSelect);
- if ($dbResult === false) {
- exit($objDGoodsCategory->error());
- }
- $merchantId = !empty($dbResult['id']) ? empty($dbResult['id']) : 0 ;
- unset($dbResult);
- } else {
- $merchantId = 0;
- }
-
- /***首分类数据***/
- $categoryId = 1;
- $categoryPath = 1;
- if (!empty($categoryName)) {
- //查询分类是否存在
- $categorySelect = [
- 'title' => $categoryName,
- ];
- $dbResult = $objDGoodsCategory->get($categorySelect);
- if ($dbResult === false) {
- exit($objDGoodsCategory->error());
- }
- $category = $dbResult;
- unset($dbResult);
- if (empty($category)) {
- $categoryInsert = [
- 'sort' => 0,
- 'title' => $categoryName,
- 'pid' => 0,
- 'enableStatus' => StatusCode::$standard,
- 'deleteStatus' => StatusCode::$standard,
- 'createTime' => time(),
- 'updateTime' => time(),
- ];
- $dbResult = $objDGoodsCategory->insert($categoryInsert);
- if ($dbResult === false) {
- exit($objDGoodsCategory->error());
- }
- $categoryId = $dbResult;
- $categoryPath = $dbResult;
- unset($dbResult);
- } else {
- $categoryId = ['id'];
- if(!empty($category['link'])){
- $categoryPath = $category['link'] . ',' . $category['id'];
- }else{
- $categoryPath = $category['id'];
- }
- }
-
- /***二级分类数据***/
- if (!empty($categoryTwo)) {
- //查询分类是否存在
- $categorySelect = [
- 'title' => $categoryTwo,
- ];
- $dbResult = $objDGoodsCategory->get($categorySelect);
- if ($dbResult === false) {
- exit($objDGoodsCategory->error());
- }
- $category = $dbResult;
- unset($dbResult);
- if (empty($category)) {
- $categoryInsert = [
- 'sort' => 0,
- 'title' => $categoryTwo,
- 'pid' => $categoryId,
- 'link' => $categoryPath,
- 'enableStatus' => StatusCode::$standard,
- 'deleteStatus' => StatusCode::$standard,
- 'createTime' => time(),
- 'updateTime' => time(),
- ];
- $dbResult = $objDGoodsCategory->insert($categoryInsert);
- if ($dbResult === false) {
- exit($objDGoodsCategory->error());
- }
- $categoryId = $dbResult;
- $categoryPath = $categoryId . ',' . $dbResult;
- unset($dbResult);
- } else {
- $categoryId = $category['id'];
- if(!empty($category['link'])){
- $categoryPath = $category['link'] . ',' . $category['id'];
- }else{
- $categoryPath = $category['id'];
- }
- }
- /***三级分类数据***/
- if (!empty($categoryThree)) {
- //查询分类是否存在
- $categorySelect = [
- 'title' => $categoryThree,
- ];
- $dbResult = $objDGoodsCategory->get($categorySelect);
- if ($dbResult === false) {
- exit($objDGoodsCategory->error());
- }
- $category = $dbResult;
- unset($dbResult);
- if (empty($category)) {
- $categoryInsert = [
- 'sort' => 0,
- 'title' => $categoryThree,
- 'pid' => $categoryId,
- 'link' => $categoryPath,
- 'enableStatus' => StatusCode::$standard,
- 'deleteStatus' => StatusCode::$standard,
- 'createTime' => time(),
- 'updateTime' => time(),
- ];
- $dbResult = $objDGoodsCategory->insert($categoryInsert);
- if ($dbResult === false) {
- exit($objDGoodsCategory->error());
- }
- $categoryId = $dbResult;
- $categoryPath = $categoryId . ',' . $categoryId . ',' . $dbResult;
- unset($dbResult);
- } else {
- $categoryId = $category['id'];
- if(!empty($category['link'])){
- $categoryPath = $category['link'] . ',' . $category['id'];
- }else{
- $categoryPath = $category['id'];
- }
- }
- }
- }
- }
- $categoryPath = trim($categoryPath, ',');
-
- /***品牌数据***/
- if (!empty($brandName)) {
- //查询品牌是否存在
- $brandSelect = [
- 'title' => $brandName
- ];
- $dbResult = $objDGoodsBrand->get($brandSelect);
- if ($dbResult === false) {
- exit($objDGoodsBrand->error());
- }
- $brand = $dbResult;
- unset($dbResult);
- if (empty($brand)) {
- $brandInsert = [
- 'title' => $brandName,
- 'images' => null,
- 'sort' => 0,
- 'enableStatus' => StatusCode::$standard,
- 'createTime' => time(),
- 'updateTime' => time(),
- ];
- $dbResult = $objDGoodsBrand->insert($brandInsert);
- if ($dbResult === false) {
- exit($objDGoodsBrand->error());
- }
- $brandId = $dbResult;
- unset($dbResult);
- } else {
- $brandId = $brand['id'];
- }
- } else {
- $brandId = 1;
- }
-
- /***单位数据***/
- $skuId = NULL;
- if (!empty($skuName)) {
- //查询单位是否存在
- $skuSelect = [
- 'unitName' => $skuName
- ];
- $dbResult = $objDUnits->get($skuSelect);
- if ($dbResult === false) {
- exit($objDUnits->error());
- }
- $sku = $dbResult;
- unset($dbResult);
- if (empty($sku)) {
- $skuInsert = [
- 'unitName' => $skuName,
- 'enableStatus' => StatusCode::$standard,
- 'createTime' => time(),
- 'updateTime' => time(),
- ];
- $dbResult = $objDUnits->insert($skuInsert);
- if ($dbResult === false) {
- exit($objDUnits->error());
- }
- $skuId = $dbResult;
- unset($dbResult);
- } else {
- $skuId = $sku['id'];
- }
- }
- $skuIdTwo = NULL;
- if (!empty($skuNameTwo)) {
- //查询单位是否存在
- $skuSelect = [
- 'unitName' => $skuNameTwo
- ];
- $dbResult = $objDUnits->get($skuSelect);
- if ($dbResult === false) {
- exit($objDUnits->error());
- }
- $sku = $dbResult;
- unset($dbResult);
- if (empty($sku)) {
- $skuInsert = [
- 'unitName' => $skuNameTwo,
- 'enableStatus' => StatusCode::$standard,
- 'createTime' => time(),
- 'updateTime' => time(),
- ];
- $dbResult = $objDUnits->insert($skuInsert);
- if ($dbResult === false) {
- exit($objDUnits->error());
- }
- $skuIdTwo = $dbResult;
- unset($dbResult);
- } else {
- $skuIdTwo = $sku['id'];
- }
- }
-
- $postData = [
-
- 'merchantId' => $merchantId,
- 'categoryPath' => $categoryPath,
- 'categoryId' => $categoryId,
- 'assistCategoryPath' =>[],//商品辅助的单位
- 'assistCategoryId' => '',//商品辅助的单位id
- 'title' => $goodsName,
- 'storage' => '',
- 'delUnitIds' =>[],
- 'delSpecSkuIds' =>[],
- 'specType' => 1,
- 'createUserName' => '',
- 'specGroup' =>[],
- 'specMultiple' =>
- [
- [
- 'barCode' => $barCode,
- 'weight' => '',
- 'isDefault' => 5,
- 'unitId' =>$skuIdTwo,
- 'unitName' => $skuName,
- 'isMaster' => 5,
- 'conversion' => $conversion,
- 'specImage' => '',
- 'specGroup' =>[],
- 'salePrice' =>
- [
- 'conversion' => $conversion,
- 'unitName' => $skuName,
- 'unitId' => $skuId,
- 'isMaster' => 5,
- 'deleteStatus' => 4,
- 'enabledLadder' => 0,
- 'salePriceAreaType' => 1,
- 'salePrice' => $salePrice,
- 'memberPrice'=> $memberPrice,
- 'ladderPrice' =>[],
- 'marketPrice' =>$salePriceTrue,
- 'setNum' => 1,
- ],
- 'customerTypePrice' =>[],
- 'customerPrice' =>[],
- ],
- ],
- 'unitData' =>
- [
- [
- 'barCode' => $barCode,
- 'weight' => '',
- 'isMaster' => 5,
- 'isDefault' => 5,
- 'unitName' => $skuName,
- 'unitId' => $skuId,
- ],
- ],
- 'describe' => $describe,
- 'code' => '',
- 'barCode' => $barCode,
- 'weight' => '',
- 'expireTime' => '',
- 'brandId' => $brandId,
- 'tag' => '',
- 'description' => $description,
- 'noSalesShop' => '',
- 'images' =>$images,
- 'enableStatus' => 5,
- 'isEq' => $isEq,
- 'isDistribution' => 4,
- 'isShield' => 4,
- 'deliverySupIds' => '',
- 'expressType' => 1,
- 'expressFee' => '',
- 'showExpress' => '',
- 'ruleId' => '',
- 'notArea' =>[],
- 'notCustomerType' => '',
- 'notCustomer' => '',
- 'isStore' => '',
- ];
-
- $postArray[] = $postData;
- }
- return $postArray;
- }
-
-
- /**
- * 单商铺导入商品基础数据
- * @throws \Exception
- */
- public function goodsQuickImport()
- {
- //把页面传来的参数对应到符合的字段中全部传递过来;
- $paramsArray = self::getGoodsQuickImportParams();
-
- if (empty($paramsArray)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $goodsBasic = [];
- foreach ($paramsArray as $params) {
-
- ( isset($params['isStore']) && $params['isStore'] == true ) && $this->isStore = true;
- self::_initShop();
- $goodsBasicData = [
- 'title' => isset($params['title']) ? $params['title'] : null,
- 'categoryId' => isset($params['categoryId']) ? $params['categoryId'] : null,
- 'categoryPath' => isset($params['categoryPath']) ? $params['categoryPath'] : null,
- 'images' => isset($params['images']) ? json_encode($params['images']) : null,//商品图册json
- 'unitData' => isset($params['unitData']) ? $params['unitData'] : null,//商品单位
- 'specType' => isset($params['specType']) ? $params['specType'] : null,
- 'specMultiple' => isset($params['specMultiple']) ? $params['specMultiple'] : null,
- 'shopId' => $this->shopId,//商铺id
- 'shopName' => $this->shopName,//商铺名称
- ];
-
- foreach ($goodsBasicData as $key => $value) {
- if (empty($value)) {
- parent::sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
-
- foreach ($goodsBasicData['specMultiple'] as $item){
- if ($item['isMaster']==StatusCode::$delete){
- if (empty((int) $item['conversion'])){
- parent::sendOutput('辅单位换算比例有误', ErrorCode::$paramError);
- }
- }
- }
-
- //商品名称转换搜索条件
- if(isset($goodsBasicData['title'])){
- $objChineseCharacter = new ChineseCharacter();
- $goodsBasicData['condition'] = $objChineseCharacter->getInitials(trim($goodsBasicData['title']));
- }
-
- $goodsBasicData['isStore'] = $this->isStore;
- $goodsBasicData['specGroup'] = isset($params['specGroup']) ? json_encode($params['specGroup']) : [];//规格组
- $goodsBasicData['brandId'] = isset($params['brandId']) ? $params['brandId'] : 0;
- $goodsBasicData['description'] = isset($params['description']) ? $params['description'] : '';
- $goodsBasicData['describe'] = isset($params['describe']) ? $params['describe'] : '';
- $goodsBasicData['expireTime'] = isset($params['expireTime']) ? $params['expireTime'] : 0;
- $goodsBasicData['memberPrice'] = isset($params['memberPrice']) ? $params['memberPrice'] : 0;
- $goodsBasicData['tag'] = isset($params['tag']) ? $params['tag'] : '';
- $goodsBasicData['barCode'] = isset($params['barCode']) ? $params['barCode'] : '';//条码
- $goodsBasicData['link'] = isset($params['link']) ? $params['link'] : '';
- $goodsBasicData['noSalesShop'] = isset($params['noSalesShop']) ? $params['noSalesShop'] : ''; //禁止销售店铺
- $goodsBasicData['assistCategoryId'] = isset($params['assistCategoryId']) ? $params['assistCategoryId'] : '';
- $goodsBasicData['assistCategoryPath'] = isset($params['assistCategoryPath']) ? json_encode($params['assistCategoryPath']) : [];
-
- //商品
- $goodsBasicData['sort'] = isset($params['sort']) ? $params['sort'] : 9999;//商品排序
- $goodsBasicData['enableStatus'] = isset($params['enableStatus']) ? $params['enableStatus'] : StatusCode::$delete;
- $goodsBasicData['createUserName'] = isset($params['createUserName']) ? $params['createUserName'] : '';
- $storage = isset($params['storage']) ? $params['storage'] : '';//货架编码
- $goodsBasicData['extends'] = json_encode(['storage'=>$storage]);//货架编码
- isset($params['deliverySupIds']) && $goodsBasicData['deliverySupIds'] = $params['deliverySupIds'];
- isset($params['expressType']) && $goodsBasicData['expressType'] = $params['expressType'];
- isset($params['ruleId']) && $goodsBasicData['ruleId'] = $params['ruleId'];
- isset($params['expressFee']) && $goodsBasicData['expressFee'] = $params['expressFee'];
- isset($params['showExpress']) && $goodsBasicData['showExpress'] = $params['showExpress'];
- (isset($this->supplierId) && !empty($this->supplierId)) && $goodsBasicData['supplierId'] = $this->supplierId;
- $goodsBasicData['isEq'] = isset($params['isEq']) ? $params['isEq'] : null;
-
- $goodsBasicData['merchantId'] = getArrayItem($params, 'merchantId', 0);
- $goodsBasicData['isShield'] = getArrayItem($params,'isShield',StatusCode::$delete);
- $goodsBasicData['notArea'] = json_encode(getArrayItem($params,'notArea',null));
- $goodsBasicData['notCustomerType'] = getArrayItem($params,'notCustomerType','');
- $goodsBasicData['notCustomer'] = getArrayItem($params,'notCustomer','');
- $goodsBasicData['isDistribution'] = getArrayItem($params,'isDistribution',StatusCode::$delete);
- $goodsBasicData['createUserName'] = getArrayItem($params,'createUserName','');
-
- $goodsBasic[] = $goodsBasicData;
- }
- unset($goodsBasicData);
- $total = 0;
- $true = 0;
- $false = 0;
- foreach ($goodsBasic as $key => $goodsBasicData) {
- $result = $this->objMQuickGoods->addBasicAndPublishGoods($goodsBasicData);
- if (!$result->isSuccess()) {
- $false++;
- } else {
- $true++;
- }
- $total++;
- }
- $return = "共导入'$total'条商品,成功'$true'条商品,失败'$false'条商品";
- parent::sendOutput($return);
- }
- }
|