/** * 获取产品信息 */ public function actionIndex() { //3SCJEJSEZB $prdouctId = \Yii::$app->request->get('code', 0); if (!intval($prdouctId)) { return ['code' => 4, 'msg' => 'undefine parameter', 'data' => []]; } $prdouctId = EasyHelpers::pidDecrypt($prdouctId); $product = Product::getProductById($prdouctId); if (!$product) { return ['code' => 3, 'msg' => 'data is not exist', 'data' => []]; } $mcoin = MiaoCoin::getMiaoCoin($product['ownid']); // if($mcoin<1) return ['code'=>4,'msg'=>'balance is insufficient','data'=>[]]; // if($product['status']!='online') return ['code'=>5,'msg'=>'This product had down shelf','data'=>[]]; $store = Store::getStoreInfo($product['ownid']); $res = ['seller' => $store->storeName, 'storePhone' => $store->tel, 'storeMobile' => $store->mobile, 'storeAddress' => $store->address, 'storeLogo' => EasyHelpers::getStoreLogoUrl($store->logo)]; $exclude = ['sku', 'hiddenBrand', 'ownid', 'from', 'createTime', 'updateTime', 'qrImage', 'originName']; foreach ($product as $key => $value) { if (!$value || in_array($key, $exclude)) { continue; } if ($key == "size") { $tempSize = []; $tempSize = explode('*', $value); $res['productLength'] = $tempSize[0]; $res['productWidth'] = $tempSize[1]; $res['productHeight'] = $tempSize[2]; continue; } if ($key == 'productId') { $res['productId'] = EasyHelpers::pidEncrypt($value); continue; } if ($key == 'newName') { $res['productImageName'] = $value; continue; } if ('status' == $key) { $res['hasComplete'] = 'offline' == $value || 'online' == $value ? true : false; continue; } if ('material' == $key) { $res['productMaterial'] = $value; continue; } $res[$key] = $value; } if ($product['type'] == 'virtual') { $res['productDescript'] = $product['re_product']['productDescript']; $res['productImage'] = \Yii::$app->sysConfig->getConfig()->default['imageDomain'] . 'product/thumb/' . $product['re_product']['newName']; $productFlie = Product::getFileName($product['re_product']['productId']); } else { $res['productImage'] = \Yii::$app->sysConfig->getConfig()->default['imageDomain'] . 'product/thumb/' . $product['newName']; $productFlie = Product::getFileName($prdouctId); } $res['favorite'] = Favorite::getCount($prdouctId); $res['hasView'] = $productFlie ? true : false; return ['code' => 0, 'msg' => 'success', 'data' => $res]; }
/** * 产品详情 * @return type */ public function actionDetail() { $pid = \YIi::$app->request->get('pid', 0); $product = []; if ($pid) { $product = \master\models\Product::getProductById($pid); $product['fileName'] = \master\models\Product::getFileName($pid); $product['clicks'] = ProductClick::getClickNum($pid); } if (!$product) { return $this->redirect('/product/index'); } $data['product'] = $product; $data['changestatusdetailIdentity'] = EasyHelpers::dataEncrypt('changestatusdetail,' . \Yii::$app->user->id); $data['setmodelnameIdentity'] = EasyHelpers::dataEncrypt('setmodelname,' . \Yii::$app->user->id); $data['token'] = Token::getToken(); return $this->render('detail', $data); }
/** * 查看产品点击详情 * @return type */ public function actionClickdetail() { $view = \Yii::$app->view; $view->params['moduleName'] = '模型点击'; $pid = \YIi::$app->request->get('pid', 0); $product = []; if ($pid) { $product = Product::getProductById($pid); $product['fileName'] = Product::getFileName($pid); $product['clicks'] = \master\models\ProductClick::getClickNum($pid); $product['lastClick'] = \master\models\ProductClick::getLastClick($pid); } if (!$product) { return $this->redirect('/finance/modenclick'); } $data['product'] = $product; $data['token'] = Token::getToken(); return $this->render('clickdetail', $data); }