request->get(); $search = $get['search'] ?? ''; $requestType = $get['requestType'] ?? 'kd'; $classId = $get['classId'] ?? 0; $lookStock = $get['lookStock'] ?? 0; $where['mainId'] = $this->mainId; if ($requestType == 'kd') { $where['delStatus'] = 0; $where['status'] = 1; } elseif ($requestType == 'itemList') { $where['delStatus'] = 0; if ($lookStock == 1) { $where['stock>'] = 0; } if ($lookStock == 2) { $where['stock'] = 0; } unset($where['status']); } elseif ($requestType == 'changePrice') { $where['delStatus'] = 0; $where['stock>'] = 0; } elseif ($requestType == 'hasStockList') { $where['delStatus'] = 0; $where['stock>'] = 0; } elseif ($requestType == 'book') { $where['delStatus'] = 0; unset($where['status']); } elseif ($requestType == 'outList') { $where['delStatus'] = 0; $where['status'] = 2; $where['removeStatus'] = 0; } elseif ($requestType == 'stopList') { $where['delStatus'] = 1; unset($where['status']); $where['removeStatus'] = 0; } elseif ($requestType == 'removeList') { $where['delStatus'] = 1; unset($where['status']); $where['removeStatus'] = 1; } elseif ($requestType == 'cg') { $where['delStatus'] = 0; unset($where['status']); } elseif ($requestType == 'changeStock') { $where['delStatus'] = 0; unset($where['status']); } elseif ($requestType == 'check') { $where['delStatus'] = 0; unset($where['status']); } elseif ($requestType == 'stockOut') { $where['delStatus'] = 0; $where['status'] = 1; } elseif ($requestType == 'break') { $where['delStatus'] = 0; $where['status'] = 1; } elseif ($requestType == 'part') { $where['delStatus'] = 0; $where['status'] = 1; } else { util::fail('没有定义的请求方式'); } if (!empty($search)) { if (stringUtil::isLetter($search)) { $search = strtolower($search); $where['py'] = ['like', $search]; } else { $where['name'] = ['like', $search]; } } else { if (!empty($classId)) { if ($classId == -1) { $where['discountPrice>'] = 0; } elseif ($classId == -2) { $where['reachNum>'] = 0; } elseif ($classId == -3) { $where['presell'] = 1; } else { $where['classId'] = $classId; } } } $customId = $get['customId'] ?? 0; $custom = CustomClass::getById($customId, true); if (!empty($custom)) { if ($custom->shopId != $this->shopId) { util::fail('不是你的客户哦,编号55236'); } } $level = $custom->level ?? 1; $field = '*'; $result = ProductClass::getList($field, $where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC]); $list = $result['list'] ?? []; if ($requestType == 'kd') { $list = ProductClass::kdItemGroup($list, $level); } elseif ($requestType == 'itemList') { $list = ProductClass::itemListGroup($list, $level); } elseif ($requestType == 'changePrice') { $list = ProductClass::changePriceGroup($list, $level); } elseif ($requestType == 'break') { $list = ProductClass::breakItemGroup($list, $level); } elseif ($requestType == 'part') { $list = ProductClass::partItemGroup($list, $level); } elseif ($requestType == 'check') { $list = ProductClass::checkItemGroup($list, $level); } elseif ($requestType == 'changeStock') { $list = ProductClass::changeStockGroup($list, $level); } elseif ($requestType == 'stockOut') { $list = ProductClass::stockOutGroup($list, $level); } else { util::fail('没有数据'); } $result['list'] = $list; util::success($result); } //增加和减少半扎 ssh 20250417 public function actionChangeHalf() { util::fail('此功能已停用'); $post = Yii::$app->request->post(); $productId = $post['productId'] ?? ''; $add = $post['add'] ?? 0; $remark = $post['remark'] ?? ''; $product = ProductClass::getLockById($productId); if (empty($product)) { util::fail('没有找到花材'); } if ($product->mainId != $this->mainId) { util::fail('不是你的花材'); } if ($product->ratioType == 1) { util::fail('若干扎的花材不能减半份'); } //避免重复提交 util::checkRepeatCommit($this->adminId, 4); $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $shop = $this->shop; $staff = $this->shopAdmin; $staffName = $staff->name ?? ''; $staffId = $staff->id; $adminId = $this->adminId; $params = [ 'staffId' => $staffId, 'staffName' => $staffName, 'adminId' => $adminId, 'remark' => $remark, ]; ItemClass::modifyHalf($shop, $product, $params, $add); $product = ProductClass::getLockById($productId); $stock = $product->stock; $stock = floatval($stock); $transaction->commit(); util::success(['stock' => $stock]); } catch (\Exception $e) { $transaction->rollBack(); Yii::info("加减半份失败原因:" . $e->getMessage()); util::fail('加减半份失败'); } } //检测是否要刷新 public function actionCheckRefresh() { $mainId = $this->mainId; $staffId = $this->shopAdminId; $respond = Yii::$app->redis->executeCommand('GET', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh']); if ($respond == 'yes') { util::success(['remind' => 1]); } util::complete(); } //列出所有花材,包括特价花材列表 ssh 20220315 public function actionShowList() { $headers = Yii::$app->getRequest()->getHeaders(); $requestVersion = $headers->get('appVersion'); $currentVersion = dict::getDict('appVersion'); if ($requestVersion < $currentVersion) { util::fail('请先升级系统'); } $get = Yii::$app->request->get(); $isCashier = $get['isCashier'] ?? 0; $mainId = $this->mainId; if ($isCashier == 1) { //去掉收银台提示价格更新 $staffId = $this->shopAdminId; Yii::$app->redis->executeCommand('DEL', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh']); } $where['mainId'] = $mainId; $where['delStatus'] = 0; $where['status'] = 1; $list = \bizHd\item\classes\ItemClass::getShowList($where); $productList = []; if (!empty($list)) { foreach ($list as $key => $item) { if (!empty($item)) { $productList = array_merge($productList, $item); } } } util::success(['list' => $list, 'productList' => $productList]); } public function actionAdd() { util::fail('开发中'); } public function actionBatchAdd() { util::fail('开发中'); } public function actionDelete() { util::fail('不能删除哦!'); } //获取平台里的花材信息 public function actionPlatformItem() { $py = Yii::$app->request->get('py', ''); $where = []; if ($py) { $where = ['py' => $py]; } $list = PtItemClass::getItemList($where); util::success($list); } //获取给散客下单的花材海报 ssh 20220111 public function actionGetPoster() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $item = ItemClass::getById($id, true); if (empty($item) || $item->mainId != $this->mainId) { util::fail('获取失败'); } $cover = $item->cover ?? ''; if (empty($cover)) { util::fail('获取失败'); } $merchant = WxOpenClass::getMallWxInfo(); $page = 'pages/item/detail'; $ptStyle = dict::getDict('ptStyle', 'mall'); $shop = $this->shop; $shopId = $shop->id ?? 0; //scene不能超过32个字条 $scene = "id=" . $id . '&a=' . $shopId; $miniCode = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle); $miniCode = $miniCode . '?x-oss-process=image/resize,m_fill,h_200,w_200'; $miniCodeBase64 = stringUtil::ossBase64($miniCode); Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'hd'); $prefix = imgUtil::getPrefix(); $price = $item->skPrice ?? 0; if ($item->discountPrice > 0) { $skMore = $item->skMore ?? 0; $price = bcadd($item->discountPrice, $skMore, 2); } $newPrice = '¥' . floatval($price); $priceBase64 = stringUtil::ossBase64($newPrice); $name = $item->name ?? ''; $nameBase64 = stringUtil::ossBase64($name); $staff = $this->shopAdmin; $staffName = $staff->name ?? ''; $newStaffName = $staffName . ' 为您推荐'; $staffNameBase64 = stringUtil::ossBase64($newStaffName); //花材主图 $itemCover = $cover . '?x-oss-process=image/resize,m_fill,h_750,w_750'; $itemCoverBase64 = stringUtil::ossBase64($itemCover); $logoBase64 = ''; if (in_array($this->mainId, [52, 1459, 13495])) { $logo = 'poster/hyxh_ncd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90'; if ($this->mainId == 1459) { $logo = 'poster/hyxh_gcd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90'; } if ($this->mainId == 13495) { $logo = 'poster/hyxh_hzd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90'; } $logoBase64 = stringUtil::ossBase64($logo); } $url = $prefix . 'poster/1234.jpg?x-oss-process=image'; //花材主图 $url .= '/watermark,image_' . $itemCoverBase64 . ',g_nw,x_0,y_0'; //小程序码 $url .= '/watermark,image_' . $miniCodeBase64 . ',g_se'; if (!empty($logoBase64)) { //logo $url .= '/watermark,image_' . $logoBase64 . ',g_se,x_65,y_65'; } //为你推荐 $url .= '/watermark,text_' . $staffNameBase64 . ',g_sw,x_18,y_235,color_8B8989,type_d3F5LW1pY3JvaGVp,size_30'; //标题 $url .= '/watermark,text_' . $nameBase64 . ',g_sw,x_18,y_145'; //价格 $url .= '/watermark,text_' . $priceBase64 . ',g_sw,x_18,y_50,color_EE2C2C,type_d3F5LW1pY3JvaGVp,size_50'; $respond = ['imgUrl' => $url]; util::success($respond); } }