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; $lsShopId = $shop->lsShopId ?? 0; //scene不能超过32个字条 $scene = "id=" . $id . '&a=' . $lsShopId; $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 ?? ''; if ($item->presell == 1) { $name = '【预售】' . $name; } else { if ($item->discountPrice > 0) { $name = '【特价】' . $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); $logo = 'poster/hyxh_ncd_logo.png?x-oss-process=image/resize,m_fill,h_98,w_98'; $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'; //logo $url .= '/watermark,image_' . $logoBase64 . ',g_se'; //为你推荐 $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); } //获取给花店下单的花材海报 ssh 20220111 public function actionGetHdPoster() { $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::getWxInfo(); $page = 'admin/ghsProduct/detail'; $ptStyle = dict::getDict('ptStyle', 'hd'); //小程序码,scene不能超过32个字条 $scene = "id=" . $id . '&sId=' . $this->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', 'ghs'); $prefix = imgUtil::getPrefix(); $price = $item->price ?? 0; if ($item->discountPrice > 0) { $price = $item->discountPrice; } $newPrice = '¥' . floatval($price); $priceBase64 = stringUtil::ossBase64($newPrice); $name = $item->name ?? ''; if ($item->presell == 1) { $name = '【预售】' . $name; } else { if ($item->discountPrice > 0) { $name = '【特价】' . $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); $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'; //为你推荐 $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); } //是否有C级价格大于B级的 ssh 20221204 public function actionGetErrorPrice() { $shop = $this->shop; $list = ItemClass::errorPrice($shop); util::success(['list' => $list]); } //列出所有花材,包括特价花材列表 ssh 20220315 public function actionShowList() { $where['mainId'] = $this->mainId; $where['delStatus'] = 0; $list = ItemClass::getShowList($where); util::success(['list' => $list]); } public function actionAdd() { $post = Yii::$app->request->post(); $post['adminId'] = $this->adminId; $post['sjId'] = $this->sjId; $connection = Yii::$app->db;//事务处理 $transaction = $connection->beginTransaction(); try { ItemService::addGhsItem($post); $transaction->commit(); util::complete('添加成功'); } catch (Exception $e) { $transaction->rollBack(); util::fail('添加失败'); } } //批量添加花材 public function actionBatchAdd() { $shopAdmin = $this->shopAdmin; if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) { util::fail('超管才能操作'); } $post = Yii::$app->request->post(); //[{itemId:1000,classId:2,price:1,stockWarning:1}] $data = $post['data']; if (empty($data)) { util::fail("请选花材"); } $data = json_decode($data, true); if (!is_array($data) || empty($data)) { util::fail("请选花材"); } $sjId = $this->sjId; $ids = array_column($data, 'itemId'); $ids = array_unique(array_filter($ids)); $has = ProductClass::getByCondition(['sjId' => $sjId, 'itemId' => ['in', $ids]]); if (!empty($has)) { util::fail("有花材已经添加过了"); } $connection = Yii::$app->db;//事务处理 $transaction = $connection->beginTransaction(); try { foreach ($data as $v) { $v['adminId'] = $this->adminId; $v['sjId'] = $sjId; ItemService::addGhsItem($v); } $transaction->commit(); util::complete('添加成功'); } catch (Exception $e) { $transaction->rollBack(); 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 20220820 public function actionColorList() { $mainId = $this->mainId ?? 0; $list = ItemClass::getAllByCondition(['mainId' => $mainId, 'variety' => 1], null, '*'); util::success(['list' => $list]); } //多颜色管理启用与停用 ssh 20221229 public function actionChangeVariety() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $variety = $get['variety'] ?? 0; $info = ItemClass::getById($id, true); if (empty($info) || $info->mainId != $this->mainId) { util::fail('操作失败'); } $info->variety = $variety; $info->save(); util::complete('操作成功'); } //拆散花材 ssh 20221229 public function actionBreakItem() { util::fail('开发中'); util::complete(); } }