|
|
@@ -4,9 +4,13 @@
|
|
|
namespace app\admin\controller\mall;
|
|
|
|
|
|
use app\admin\logic\ShopGoodsLogic;
|
|
|
+use app\admin\logic\ShopGoodsSpecLogic;
|
|
|
+use app\admin\logic\ShopGoodsSpecTypeLogic;
|
|
|
use app\admin\logic\ShopGoodsTypeLogic;
|
|
|
use app\admin\logic\ShopHotKeywordsLogic;
|
|
|
use app\admin\logic\ShopSupplierLogic;
|
|
|
+use app\admin\model\dao\ShopGoodsSpecRelation;
|
|
|
+use app\admin\model\dao\ShopGoodsSpecType;
|
|
|
use app\common\model\ShopGoods as ShopGoods;
|
|
|
use app\common\model\ShopGoodsSpec;
|
|
|
use app\admin\traits\Curd;
|
|
|
@@ -64,7 +68,7 @@ class Goods extends AdminController
|
|
|
|
|
|
public function goodsBase($id)
|
|
|
{
|
|
|
- list($data, $hot_keywords, $shop_goods_type, $shop_supplier,$specAttrId) = ShopGoodsLogic::getGoodsBase($id);
|
|
|
+ list($data, $hot_keywords, $shop_goods_type, $shop_supplier, $specAttrId) = ShopGoodsLogic::getGoodsBase($id);
|
|
|
|
|
|
$this->assign('shop_goods_type', $shop_goods_type);
|
|
|
$this->assign('box_type', system_box_typesetting());
|
|
|
@@ -87,11 +91,12 @@ class Goods extends AdminController
|
|
|
public function getGoodsSpecData($goodsId, $attriId)
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
- $specRelation = Db::name('shop_goods_spec_relation')->where(['goods_id' => $goodsId])->select()->toArray();
|
|
|
- $specAttrId = Db::name('shop_goods_spec_type')->where(['id' => $specRelation[0]['spec_id']])->value('pid');
|
|
|
- $specType = Db::name('shop_goods_spec_type')->select()->toArray();
|
|
|
- $specType = app()->make(Tree::class)->DeepTree($specType, 'child');
|
|
|
- $specTypeArr = [];
|
|
|
+ $specRelation = ShopGoodsSpecRelation::getArrListByGoodsId($goodsId);
|
|
|
+ $specAttrId = ShopGoodsSpecType::getPidById($specRelation[0]['spec_id']);
|
|
|
+ $specType = ShopGoodsSpecTypeLogic::getCacheList();
|
|
|
+
|
|
|
+ $specType = app()->make(Tree::class)->DeepTree($specType, 'child');
|
|
|
+ $specTypeArr = [];
|
|
|
foreach ($specType as $k => $v) {
|
|
|
if ($v['id'] == $specAttrId) {
|
|
|
if (isset($v['child']))
|
|
|
@@ -118,7 +123,7 @@ class Goods extends AdminController
|
|
|
}
|
|
|
|
|
|
$goodsSkuArr = [];
|
|
|
- $goodsSku = Db::name('shop_goods_spec')->where(['goods_id' => $goodsId])->select()->toArray();
|
|
|
+ $goodsSku = ShopGoodsSpecLogic::getGoodsSpecByGoodId($goodsId);
|
|
|
foreach ($goodsSku as $sk => $sv) {
|
|
|
$goodsSkuArr['skus[' . $sv['spec_ids'] . '][picture]'] = $sv['picture'];
|
|
|
$goodsSkuArr['skus[' . $sv['spec_ids'] . '][price]'] = $sv['price'];
|
|
|
@@ -148,9 +153,9 @@ class Goods extends AdminController
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
if (!isset($goods['is_exist_many_spec'])) {
|
|
|
- $flag = ShopGoods::singleSpecGoods($goods);
|
|
|
+ ShopGoods::singleSpecGoods($goods);
|
|
|
} else {
|
|
|
- $flag = ShopGoods::manySpecGoods($goods);
|
|
|
+ ShopGoods::manySpecGoods($goods);
|
|
|
}
|
|
|
Db::commit();
|
|
|
|
|
|
@@ -160,11 +165,9 @@ class Goods extends AdminController
|
|
|
}
|
|
|
|
|
|
$this->success('成功');
|
|
|
-// return $flag ? json(['code' => 1, 'msg' => '发布成功']) :
|
|
|
-// json(['code' => 0, 'msg' => '发布失败']);
|
|
|
}
|
|
|
- $hot_keywords = Db::name('shop_hot_keywords')->select()->toArray();
|
|
|
- $shop_supplier = Db::name('shop_supplier')->select()->toArray();
|
|
|
+ $hot_keywords = ShopHotKeywordsLogic::getCacheList();
|
|
|
+ $shop_supplier = ShopSupplierLogic::getCacheList();
|
|
|
$this->assign('hot_keywords', $hot_keywords);
|
|
|
$this->assign('shop_supplier', $shop_supplier);
|
|
|
return $this->fetch();
|
|
|
@@ -204,9 +207,9 @@ class Goods extends AdminController
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
if (!isset($goods['is_exist_many_spec'])) {
|
|
|
- $flag = ShopGoods::singleSpecGoods($goods);
|
|
|
+ ShopGoods::singleSpecGoods($goods);
|
|
|
} else {
|
|
|
- $flag = ShopGoods::manySpecGoods($goods);
|
|
|
+ ShopGoods::manySpecGoods($goods);
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -215,8 +218,6 @@ class Goods extends AdminController
|
|
|
}
|
|
|
|
|
|
$this->success('保存成功');
|
|
|
-// return $flag ? json(['code' => 1, 'msg' => '保存成功']) :
|
|
|
-// json(['code' => 0, 'msg' => '保存失败']);
|
|
|
}
|
|
|
$this->goodsBase($id);
|
|
|
return $this->fetch();
|
|
|
@@ -227,7 +228,7 @@ class Goods extends AdminController
|
|
|
*/
|
|
|
public function stock($id)
|
|
|
{
|
|
|
- $sku = Db::name('shop_goods_spec')->where(['goods_id' => $id])->select()->toArray();
|
|
|
+ $sku = ShopGoodsSpecLogic::getGoodsSpecByGoodId($id);
|
|
|
$this->assign('sku', $sku);
|
|
|
|
|
|
if ($this->request->isAjax()) {
|