zm
2021-03-26 1e985cc3a92e7fac527d1f2b7e08e9cb627cc640
提货功能开发,后台功能
4 files modified
54 ■■■■■ changed files
controllers/mall/CouponController.php 9 ●●●●● patch | view | raw | blame | history
forms/common/CommonUser.php 32 ●●●●● patch | view | raw | blame | history
forms/mall/coupon/CouponForm.php 10 ●●●●● patch | view | raw | blame | history
plugins/exchange/forms/mall/QrcodeForm.php 3 ●●●● patch | view | raw | blame | history
controllers/mall/CouponController.php
@@ -117,6 +117,15 @@
        }
    }
    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) {
forms/common/CommonUser.php
@@ -13,6 +13,7 @@
use app\models\User;
use app\models\UserIdentity;
use app\models\UserInfo;
use app\models\Order;
class CommonUser
{
@@ -206,4 +207,35 @@
        }
        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,
        ];
    }
}
forms/mall/coupon/CouponForm.php
@@ -539,6 +539,16 @@
        ];
    }
    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()) {
plugins/exchange/forms/mall/QrcodeForm.php
@@ -62,7 +62,8 @@
            ) {
                $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);//存缓存
            }