| | |
| | | } |
| | | } |
| | | |
| | | public function actionGetUserAndAddressByMobile() |
| | | { |
| | | if (\Yii::$app->request->isAjax) { |
| | | $form = new CouponForm(); |
| | | $form->attributes = \Yii::$app->request->get(); |
| | | return $this->asJson($form->getUserAndAddressByMobile()); |
| | | } |
| | | } |
| | | |
| | | public function actionSearchCat() |
| | | { |
| | | if (\Yii::$app->request->isAjax) { |
| | |
| | | use app\models\User; |
| | | use app\models\UserIdentity; |
| | | use app\models\UserInfo; |
| | | use app\models\Order; |
| | | |
| | | class CommonUser |
| | | { |
| | |
| | | } |
| | | return $route; |
| | | } |
| | | |
| | | /** |
| | | * 根据电话号获取订单表中取此电话号的最近一条订单地址 |
| | | * @param [type] $keyword [description] |
| | | * @return [type] [description] |
| | | */ |
| | | public static function getUserAndAddressByMobile($keyword) |
| | | { |
| | | $keyword = trim($keyword); |
| | | |
| | | $query = Order::find()->alias('o')->where([ |
| | | 'AND', |
| | | ['o.mobile' => $keyword], |
| | | ['o.mall_id' => \Yii::$app->mall->id], |
| | | ]); |
| | | |
| | | $list = $query->orderBy(['created_at'=>SORT_DESC])->limit(1)->all(); |
| | | |
| | | $newList = []; |
| | | /** @var User[] $list */ |
| | | foreach ($list as $k => $v) { |
| | | $newList[] = [ |
| | | 'name' => $v->name, |
| | | 'address' => $v->address, |
| | | ]; |
| | | } |
| | | return [ |
| | | 'list' => $newList, |
| | | ]; |
| | | } |
| | | |
| | | } |
| | |
| | | ]; |
| | | } |
| | | |
| | | public function getUserAndAddressByMobile() |
| | | { |
| | | if (!$this->validate()) { |
| | | return $this->getErrorResponse(); |
| | | } |
| | | return [ |
| | | 'code' => ApiCode::CODE_SUCCESS, |
| | | 'data' => CommonUser::getUserAndAddressByMobile($this->keyword) |
| | | ]; |
| | | } |
| | | public function searchCat() |
| | | { |
| | | if (!$this->validate()) { |
| | |
| | | ) { |
| | | $downUrl = $this->tempList[$this->code]; |
| | | } else { |
| | | $downUrl = $this->getUrl(['code' => $this->code]); |
| | | //$downUrl = $this->getUrl(['code' => $this->code]); |
| | | $downUrl = $this->getUrl(['code' => '']); |
| | | $this->tempList[$this->code] = $downUrl; |
| | | \Yii::$app->cache->set($key, $this->tempList, 2419200);//存缓存 |
| | | } |