/**
  * 获取产品信息
  */
 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];
 }
Beispiel #2
0
 /**
  * 获取店铺消费数据
  */
 public function actionGetconsume()
 {
     $request = \Yii::$app->request;
     $storeId = intval($request->get('storeId', 0));
     $year = intval($request->get('year', 0));
     if (!$storeId || !$year) {
         return ['code' => 2, 'msg' => '非法数据'];
     }
     $month = intval($request->get('month', 0));
     $day = intval($request->get('day', 0));
     $rechargeData = \master\models\Recharge::getRechargeData($storeId, $year, $month, $day);
     $store_user = Store::findOne(['storeId' => $storeId]);
     $clickData = \master\models\ProductClick::getClick('', $store_user['userId'], $year, $month, $day);
     $extData = \master\models\StoreStorage::getStoreStorageData($storeId, $year, $month, $day);
     $type = 'year';
     if ($month) {
         if ($day) {
             $type = 'day';
         } else {
             $type = 'month';
         }
     }
     if ($rechargeData || $clickData || $extData) {
         return ['code' => 0, 'msg' => '操作成功', 'data' => ['rechargeData' => $rechargeData, 'clickData' => $clickData, 'extData' => $extData, 'type' => $type]];
     } else {
         return ['code' => 2, 'msg' => '没有消费记录'];
     }
 }