| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- namespace mall\controllers;
- use bizGhs\item\classes\ItemClassClass;
- use bizGhs\product\classes\ProductClass;
- use bizGhs\product\services\ProductService;
- use bizHd\custom\classes\CustomClass;
- use bizMall\pictext\classes\PicTextGhsItemClass;
- use bizMall\item\classes\ItemClass;
- use common\components\imgUtil;
- use common\components\util;
- use Yii;
- class ItemController extends BaseController
- {
- public $guestAccess = ['show-info', 'index'];
- public function actionAll()
- {
- $where = [];
- $where['mainId'] = $this->mainId;
- $classId = Yii::$app->request->get('classId', 0);
- if (!empty($classId)) {
- $where['classId'] = $classId;
- }
- $status = Yii::$app->request->get('status', 0);
- if (!empty($status)) {
- $where['status'] = $status;
- }
- $delStatus = Yii::$app->request->get('delStatus', 0);
- if ($delStatus != 2) {
- $where['delStatus'] = $delStatus;
- }
- //输出标准会员价,即批发价,默认显示的是批发价
- $level = 0;
- $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
- $data = ProductClass::groupProductInfo($data, $level);
- util::success(['list' => $data]);
- }
- //散客查看花材详情 ssh 20230109
- public function actionGetMallItemInfo()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $item = ItemClass::getById($id);
- $discountPrice = $item['discountPrice'] ?? 0;
- if ($discountPrice > 0) {
- $skDiscountPrice = $item['skDiscountPrice'] ?? 0;
- $item['skPrice'] = $skDiscountPrice;
- }
- $presell = $item['presell'] ?? 0;
- if ($presell == 1) {
- $preSellDate = $item['presellDate'] ?? '';
- $preSellDateShow = [];
- if (!empty($preSellDate)) {
- $dateArr = explode(',', trim($preSellDate));
- if (!empty($dateArr)) {
- foreach ($dateArr as $sellTime) {
- $showDate = date("n月j日", $sellTime);
- $preSellDateShow[] = $showDate;
- }
- }
- }
- $item['presellDateShow'] = $preSellDateShow;
- }
- $shortCover = $item['cover'] ?? '';
- $cover = imgUtil::groupImg($shortCover);
- $item['shortCover'] = $shortCover;
- $item['bigCover'] = $cover . "?x-oss-process=image/resize,m_fill,h_700,w_700";
- $item['cover'] = $cover . "?x-oss-process=image/resize,m_fill,h_100,w_100";
- $pixTextGoods = PicTextGhsItemClass::getByCondition(['mainId' => $item['mainId'], 'ghsItemId' => $id], true);
- $item['picTextGoods'] = $pixTextGoods;
- // 封面图与多花材图片的兼容处理
- if ($item['images'] == '' && $item['shortCover'] != '') {
- $item['images'] = $item['shortCover'];
- }
- util::success(['info' => $item]);
- }
- //扫码看价格 ssh 20221008
- public function actionShowInfo()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $item = ItemClass::getById($id, true);
- if (empty($item)) {
- util::stop('');
- }
- if (isset($item->skDiscountPrice) && $item->skDiscountPrice > 0) {
- $skPrice = $item->skDiscountPrice;
- } else {
- $skPrice = $item->skPrice ?? 0;
- }
- $skPrice = floatval($skPrice);
- $name = $item->name ?? '';
- $classId = $item->classId ?? 0;
- $class = ItemClassClass::getById($classId, true);
- $className = $class->name ?? '';
- echo '<div style="font-size:80px;margin-top:80px;margin-left:60px;">' . $name . '</div>';
- echo '<div style="font-size:80px;margin-top:30px;margin-left:60px;color:red;">' . $skPrice . '元</div>';
- echo '<div style="font-size:60px;margin-top:50px;margin-left:60px;">' . $className . '</div>';
- }
- public function actionIndex()
- {
- $py = Yii::$app->request->get('py', '');
- //默认显示上架商品
- $status = Yii::$app->request->get('status', 1);
- //默认显示未删除商品
- $delStatus = Yii::$app->request->get('delStatus', 0);
- $shop = $this->shop;
- if (!isset($shop->ptStyle) || $shop->ptStyle != 1) {
- util::fail('访问门店出错了');
- }
- $user = $this->user;
- if (empty($user)) {
- util::success([]);
- }
- //普莲花艺、叶上花、丰行、小武鲜花、九江云朵、源花汇、紫荆不能在花卉宝下单,多处要同步修改,关键词ls_mall_not_open
- $mainId = $this->mainId;
- if (getenv('YII_ENV') == 'production') {
- if (in_array($mainId, [40057, 7779, 42940, 26374, 10536, 65381])) {
- util::fail('暂时无法访问');
- }
- } else {
- if (in_array($mainId, [0, 1])) {
- util::fail('暂时无法访问');
- }
- }
- //获取所有当前供货商的分类 (全部、常用)
- //根据分类组装分类下的花材信息
- //中央ID
- $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
- $where['mainId'] = $this->mainId;
- if ($py) {
- $pyName = strtolower($py);
- $where['py'] = $pyName;
- }
- if (!empty($status)) {
- $where['status'] = $status;
- }
- $where['delStatus'] = $delStatus;
- //批发端没有隐藏
- //$where['frontHide'] = 0;
- //零售端没有隐藏
- $where['frontUse'] = 0;
- $level = 0;
- $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
- $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
- $respond = ProductService::assembleData($classIds, $itemInfoData, true);
- $data = $respond['classItem'] ?? [];
- CustomClass::buildRelation($this->shop, $this->user);
- util::success($data);
- }
- }
|