public function addDiscount($data) { $user_id = $data['user_id']; //查询merchant_id $merchant = Merchant::find()->where(['user_id' => $user_id])->one(); $merchant_id = $merchant['merchant_id']; $this->merchant_id = $merchant_id; $this->start_time = microtime($data['start_time']); $this->end_time = microtime($data['end_time']); $this->discount_type = $data['discount_type']; if ($data['discount_type'] == '1') { $this->discount_explain = "满一百减" . $data['discount_explain']; } else { $this->discount_explain = $data['discount_explain'] / 10; } $this->addtime = time(); $this->discount_status = 1; return $this->save(false); }
public function updateMerchant($data) { $user_id = $data['user_id']; $merchantInfo = $data['Merchant']; $merchant = Merchant::find()->where(['user_id' => $user_id])->one(); $merchant->merchant_name = $merchantInfo['merchant_name']; $merchant->merchant_linkman = $merchantInfo['merchant_linkman']; $merchant->merchant_tel = $merchantInfo['merchant_tel']; $merchant->merchant_position = $merchantInfo['merchant_position']; $merchant->merchant_province = $merchantInfo['merchant_province']; $merchant->merchant_city = $merchantInfo['merchant_city']; $merchant->merchant_district = $merchantInfo['merchant_district']; $merchant->merchant_address = $merchantInfo['merchant_address']; $merchant->merchant_categoryparent = $merchantInfo['merchant_categoryparent']; $merchant->merchant_categorychild = $merchantInfo['merchant_categorychild']; $merchant->merchant_desc = $merchantInfo['merchant_desc']; $merchant->addtime = time(); $merchant->merchant_sort = 50; $merchant->merchant_status = 1; return $merchant->save(false); }
public function actionBusinessData() { $model = new Merchant(); $discount = new Discount(); $user_id = yii::$app->session->get('user_id'); $merchantInfo = $model->find()->where(['user_id' => $user_id])->one(); $aptitude = new Aptitude(); $merchant_id = $merchantInfo['merchant_id']; //获得商家开店牌照 $aptitudeInfo = $aptitude->find()->where(['merchant_id' => $merchant_id])->asArray()->all(); //获得商家店铺照片 $garllery = new MerchantGarllery(); $garlleryInfo = $garllery->find()->where(['merchant_id' => $merchant_id])->asArray()->all(); $category = new MerchantCategory(); $region = new Region(); //修改时候获得市 和 区 $merchant_province = $merchantInfo['merchant_province']; $merchant_city = $merchantInfo['merchant_city']; $city = $region->find()->where(['pid' => $merchant_province])->asArray()->all(); $areas = $region->find()->where(['pid' => $merchant_city])->asArray()->all(); $parentOne = $region->getParentOne(); $categoryOne = $category->getCategoryOne(); //修改时获得二级分类 $category_id = $merchantInfo['merchant_categoryparent']; $categoryTwo = $category->find()->where(['Parent_id' => $category_id])->asArray()->all(); return $this->render('business-data', ['model' => $merchantInfo, 'parentOne' => $parentOne, 'areas' => $areas, 'city' => $city, 'aptitude' => $aptitudeInfo, 'garllery' => $garlleryInfo, 'categoryOne' => $categoryOne, 'categoryTwo' => $categoryTwo, 'discount' => $discount]); }