hrjy před 2 roky
rodič
revize
94812912d0

+ 85 - 31
app/api/controller/AuthController.php

@@ -6,12 +6,14 @@ namespace app\api\controller;
 
 use app\admin\model\sms\SmsRecord;
 use app\http\validates\user\RegisterValidates;
+use app\http\validates\user\RestValidates;
 use app\models\user\User;
 use app\models\user\UserToken;
 use app\models\user\WechatUser;
 use app\Request;
 use crmeb\jobs\TestJob;
 use crmeb\repositories\ShortLetterRepositories;
+use crmeb\services\blockchain\BlockChianService;
 use crmeb\services\CacheService;
 use crmeb\services\UtilService;
 use think\facade\Cache;
@@ -129,19 +131,37 @@ class AuthController
     {
         list($phone, $type, $key, $code) = UtilService::postMore([['phone', 0], ['type', ''], ['key', ''], ['code', '']], $request, true);
 
-        $keyName = 'sms.key.' . $key;
-        $nowKey = 'sms.' . date('YmdHi');
-
-        if (!Cache::has($keyName))
-            return app('json')->make(401, '发送验证码失败');
+        $temp = function ($item) {
+            switch ($item) {
+                case "register":
+                    return 'REGISTER';
+                case "login":
+                    return 'LOGIN';
+                case "reset":
+                    return 'RESET';
+                case "reset_2":
+                    return 'RESET_2';
+                case "trade":
+                    return 'TRADE';
+                default:
+                    return 'DEFAULT';
+            }
+        };
 
-        if (($num = Cache::get($keyName)) > 2) {
-            if (!$code)
-                return app('json')->make(402, '请输入验证码');
 
-            if (!$this->checkCaptcha($key, $code))
-                return app('json')->fail('验证码输入有误');
-        }
+//        $keyName = 'sms.key.' . $key;
+        $nowKey = 'sms.' . date('YmdHi');
+//
+//        if (!Cache::has($keyName))
+//            return app('json')->make(401, '发送验证码失败');
+//
+//        if (($num = Cache::get($keyName)) > 2) {
+//            if (!$code)
+//                return app('json')->make(402, '请输入验证码');
+//
+//            if (!$this->checkCaptcha($key, $code))
+//                return app('json')->fail('验证码输入有误');
+//        }
 
         $total = 1;
         if ($has = Cache::has($nowKey)) {
@@ -149,7 +169,6 @@ class AuthController
             if ($total > Config::get('sms.maxMinuteCount', 20))
                 return app('json')->success('已发送');
         }
-
         try {
             validate(RegisterValidates::class)->scene('code')->check(['phone' => $phone]);
         } catch (ValidateException $e) {
@@ -162,25 +181,53 @@ class AuthController
         $defaultMaxIpCount = Config::get('sms.maxIpCount', 50);
         $maxPhoneCount = Config::get('sms.stores.' . $default . '.maxPhoneCount', $defaultMaxPhoneCount);
         $maxIpCount = Config::get('sms.stores.' . $default . '.maxIpCount', $defaultMaxIpCount);
-        if (SmsRecord::where('phone', $phone)->where('add_ip', $request->ip())->whereDay('add_time')->count() >= $maxPhoneCount) {
-            return app('json')->fail('您今日发送得短信次数已经达到上限');
-        }
+//        if (SmsRecord::where('phone', $phone)->where('add_ip', $request->ip())->whereDay('add_time')->count() >= $maxPhoneCount) {
+//            return app('json')->fail('您今日发送得短信次数已经达到上限');
+//        }
         if (SmsRecord::where('add_ip', $request->ip())->whereDay('add_time')->count() >= $maxIpCount) {
             return app('json')->fail('此IP今日发送次数已经达到上限');
         }
         $time = 60;
-        if (CacheService::get('code_' . $phone))
-            return app('json')->fail($time . '秒内有效');
+//        if (CacheService::get('code_' . $phone))
+//            return app('json')->fail($time . '秒内有效');
         $code = rand(100000, 999999);
         $data['code'] = $code;
-        $res = ShortLetterRepositories::send(true, $phone, $data, 'VERIFICATION_CODE');
+        $res = self::NewSmsSend($phone, $data, $temp($type));
+//        $res = ShortLetterRepositories::send(true, $phone, $data, 'VERIFICATION_CODE');
         if ($res !== true)
             return app('json')->fail('短信平台验证码发送失败' . $res);
         CacheService::set('code_' . $phone, $code, $time);
-        Cache::set($keyName, $num + 1, 300);
-        Cache::set($nowKey, $total, 61);
+//        Cache::set($keyName, $num + 1, 300);
+//        Cache::set($nowKey, $total, 61);
 
-        return app('json')->success('发送成功');
+        return app('json')->success('短信验证发送成功');
+    }
+
+    /**
+     * 发送短信
+     * @param string $phone 手机号码
+     * @param array $data 模板替换内容
+     * @param string $template 模板编号
+     * @return bool|string
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     */
+    public static function NewSmsSend(string $phone, array $data, string $template)
+    {
+        try {
+            $res = ZjSMSServerService::send($phone, $data);
+//            var_dump($res);
+//            exit;
+            if ($res['status'] != '200') {
+                return $res['msg'];
+            } else {
+                SmsRecord::sendRecord($phone, $data['code'], $template, '');
+            }
+            return true;
+        } catch (Exception $exception) {
+//            Log::info($exception->getMessage());
+            return $exception->getMessage();
+        }
     }
 
     /**
@@ -190,22 +237,22 @@ class AuthController
      */
     public function register(Request $request)
     {
-        list($account, $captcha, $password, $spread) = UtilService::postMore([['account', ''], ['captcha', ''], ['password', ''], ['spread', 0]], $request, true);
+        list($account, $captcha, $password, $spread, $payment_pas) = UtilService::postMore([['account', ''], ['captcha', ''], ['password', ''], ['spread', 0], ['payment_pas']], $request, true);
         try {
-            validate(RegisterValidates::class)->scene('register')->check(['account' => $account, 'captcha' => $captcha, 'password' => $password]);
+            validate(RegisterValidates::class)->scene('register')->check(['account' => $account, 'captcha' => $captcha, 'password' => $password, 'payment_pas' => $payment_pas]);
         } catch (ValidateException $e) {
             return app('json')->fail($e->getError());
         }
-//        $verifyCode = CacheService::get('code_' . $account);
-//        if (!$verifyCode)
-//            return app('json')->fail('请先获取验证码');
-//        $verifyCode = substr($verifyCode, 0, 6);
-//        if ($verifyCode != $captcha)
-//            return app('json')->fail('验证码错误');
+        $verifyCode = CacheService::get('code_' . $account);
+        if (!$verifyCode)
+            return app('json')->fail('请先获取验证码');
+        $verifyCode = substr($verifyCode, 0, 6);
+        if ($verifyCode != $captcha)
+            return app('json')->fail('验证码错误');
         if (strlen(trim($password)) < 6 || strlen(trim($password)) > 16)
             return app('json')->fail('密码必须是在6到16位之间');
         if ($password == '123456') return app('json')->fail('密码太过简单,请输入较为复杂的密码');
-        $registerStatus = User::register($account, $password, $spread);
+        $registerStatus = User::register($account, $password, $spread, $payment_pas);
         if ($registerStatus) return app('json')->success('注册成功');
         return app('json')->fail(User::getErrorInfo('注册失败'));
     }
@@ -219,7 +266,7 @@ class AuthController
     {
         list($account, $captcha, $password) = UtilService::postMore([['account', ''], ['captcha', ''], ['password', '']], $request, true);
         try {
-            validate(RegisterValidates::class)->scene('register')->check(['account' => $account, 'captcha' => $captcha, 'password' => $password]);
+            validate(RestValidates::class)->scene('register')->check(['account' => $account, 'captcha' => $captcha, 'password' => $password]);
         } catch (ValidateException $e) {
             return app('json')->fail($e->getError());
         }
@@ -391,4 +438,11 @@ class AuthController
         else
             return app('json')->fail('绑定失败');
     }
+
+    public function brc()
+    {
+        $data[] = 'TB5UtaMMv9apgcKxxYBLkjqmixab9N7EsR';
+        return app('json')->success($data);
+    }
+
 }

+ 85 - 0
app/api/controller/ZjSMSServerService.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace app\api\controller;
+
+use crmeb\services\HttpService;
+use think\facade\Db;
+
+/**
+ * 短信服务
+ * Class SMSService
+ * @package crmeb\services
+ */
+class ZjSMSServerService
+{
+    private static $userid = '15889';
+    private static $username = "yflkj";
+    private static $passwd = 'yfl831**';
+    //验证码
+    const VERIFICATION_CODE = 518076;
+    //支付成功
+    const PAY_SUCCESS_CODE = 520268;
+    //发货提醒
+    const DELIVER_GOODS_CODE = 520269;
+    //确认收货提醒
+    const TAKE_DELIVERY_CODE = 520271;
+    //管理员下单提醒
+    const ADMIN_PLACE_ORDER_CODE = 520272;
+    //管理员退货提醒
+    const ADMIN_RETURN_GOODS_CODE = 520274;
+    //管理员支付成功提醒
+    const ADMIN_PAY_SUCCESS_CODE = 520273;
+    //管理员确认收货
+    const ADMIN_TAKE_DELIVERY_CODE = 520422;
+
+    /**
+     * get: 发送短信验证码
+     * path: sendSmsCode
+     * method: sendSmsCode
+     * param: phone - {string} 手机号
+     */
+    public static function send($phone, array $param, $template = "VERIFICATION_CODE")
+    {
+        $code = $param['code'];
+        $target = "http://sms.izjun.cn/v2sms.aspx";
+        $company = sys_config('site_name', '', true);
+//        $company = "星拼乐";
+        switch ($template) {
+            case 'PAY_SUCCESS_CODE':
+                break;
+            case 'DELIVER_GOODS_CODE':
+                break;
+            case  'TAKE_DELIVERY_CODE':
+                break;
+            case 'ADMIN_PLACE_ORDER_CODE':
+                break;
+            case 'ADMIN_RETURN_GOODS_CODE':
+                break;
+            case 'ADMIN_PAY_SUCCESS_CODE':
+                break;
+            case 'ADMIN_TAKE_DELIVERY_CODE':
+                break;
+            default:
+                $content = sprintf('【%s】您的验证码为:%d 。验证码有效期为%d分钟,请尽快填写!', $company, $code, 5);
+        }
+        $time = date("YmdHis", time());
+        $data = [
+            'action' => 'send',
+            'userid' => self::$userid,
+            'timestamp' => $time,
+            'sign' => md5(self::$username . self::$passwd . $time),
+            'mobile' => $phone,
+            'content' => $content,
+            'sendTime' => '',
+            'extno' => '',
+            'rt' => 'json',
+        ];
+        $gets = json_decode(HttpService::postRequest($target, $data), true);
+        if ($gets) {
+            return ['status' => 200, 'msg' => '短信发送成功'];
+
+        } else {
+            return ['status' => 400, 'msg' => '发送失败'];
+        }
+    }
+}

+ 4 - 4
app/api/controller/user/UserBillController.php

@@ -292,12 +292,12 @@ class UserBillController
                             array(
                                 'url' => $urlCode,     //二维码资源
                                 'stream' => 0,
-                                'left' => 114,
-                                'top' => 790,
+                                'left' => 225,
+                                'top' => 913,
                                 'right' => 0,
                                 'bottom' => 0,
-                                'width' => 120,
-                                'height' => 120,
+                                'width' => 300,
+                                'height' => 300,
                                 'opacity' => 100
                             )
                         ),

+ 2 - 0
app/models/store/StoreOrder.php

@@ -458,6 +458,8 @@ class StoreOrder extends BaseModel
                 'add_time' => time(),
                 'unique' => $key,
                 'shipping_type' => $shipping_type,
+                'freight_price' => 0,
+                'refund_price' => 0
             ];
             if ($shipping_type === 2) {
                 $orderInfo['verify_code'] = self::getStoreCode();

+ 10 - 1
app/models/user/User.php

@@ -619,11 +619,20 @@ class User extends BaseModel
         $data['province'] = '';
         $data['country'] = '';
         $data['is_promoter'] = $storeBrokerageStatu != 1 ? 1 : 0;
+        $data['now_money'] = 0;
+        $data['brokerage_price'] = 0;
+        $data['integral'] = 0;
+        $data['white_integral'] = 0;
+        $data['purple_integral'] = 0;
+        $data['green_integral'] = 0;
+        $data['business_integral'] = 0;
+        $data['paper_ticket'] = 0;
+        $data['spread_uid'] = $spread;
         self::beginTrans();
         $res2 = WechatUser::create($data);
         $data['uid'] = $res2->uid;
         $res1 = self::create($data);
-        $res = $res1 && $res2 && UserSpread::setSpread($data['uid'], $spread);
+        $res = $res1 && $res2;
         self::checkTrans($res);
         return $res;
     }

+ 25 - 0
app/register/config/route.php

@@ -0,0 +1,25 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+
+// +----------------------------------------------------------------------
+// | 应用设置
+// +----------------------------------------------------------------------
+
+return [
+    // 是否强制使用路由
+    'url_route_must'        => false,
+    // 合并路由规则
+    'route_rule_merge'      => true,
+    // 路由是否完全匹配
+    'route_complete_match'  => false,
+    // 是否自动转换URL中的控制器和操作名
+    'url_convert'           => true,
+];

+ 20 - 0
app/register/config/view.php

@@ -0,0 +1,20 @@
+<?php
+// +----------------------------------------------------------------------
+// | 模板设置
+// +----------------------------------------------------------------------
+
+return [
+    // 模板后缀
+    'view_suffix'  => 'html',
+    // 模板路径
+    'view_path'    => app_path('view'),
+    // 视图输出字符串内容替换
+    'tpl_replace_string'       => [
+        '{__PUBLIC_PATH}' =>  '/',              //public 目录
+        '{__STATIC_PATH}' =>  '/static/',       //全局静态目录
+        '{__PLUG_PATH}'   =>  '/static/plug/',  //全局静态插件
+        '{__ADMIN_PATH}'  =>  '/system/',        //后台目录
+        '{__FRAME_PATH}'  =>  '/system/frame/',  //后台框架
+        '{__MODULE_PATH}' =>  '/system/module/', //后台模块
+    ]
+];

+ 25 - 0
app/register/controller/Index.php

@@ -0,0 +1,25 @@
+<?php
+
+
+namespace app\register\controller;
+
+
+use app\models\system\Site;
+use crmeb\basic\BaseController;
+
+class Index extends BaseController
+{
+    public function index()
+    {
+        $apk = sys_config('apk', '');
+        $this->assign('apk', $apk);
+        return $this->fetch();
+    }
+
+    public function down()
+    {
+        $apk = sys_config('apk', '');
+        $this->assign('apk', $apk);
+        return $this->fetch();
+    }
+}

+ 3 - 0
app/register/view/index/.vscode/settings.json

@@ -0,0 +1,3 @@
+{
+    "liveServer.settings.port": 5501
+}

+ 99 - 0
app/register/view/index/down.html

@@ -0,0 +1,99 @@
+<!doctype html>
+<html>
+<head>
+    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
+    <style>
+        .div {
+            width: 100%;
+            height: 100%;
+            position: relative;
+        }
+
+        .button {
+            margin-left: 10%;
+            position: absolute;
+            bottom: 40px;
+            width: 80%;
+            text-align: center;
+            z-index: 999;
+            height: 140px;
+            font-size: 32px;
+            line-height: 140px;
+            letter-spacing: 5px;
+            background-color: #32baff;
+            border-radius: 5px;
+            color: white;
+
+        }
+
+        .img {
+            position: relative;
+            width: 100%;
+        }
+
+        img {
+            max-width: 100%;
+            height: auto;
+        }
+
+        .weixin-tip {
+            display: none;
+            position: fixed;
+            left: 0;
+            top: 0;
+            bottom: 0;
+            background: rgba(0, 0, 0, 0.8);
+            filter: alpha(opacity=80);
+            height: 100%;
+            width: 100%;
+            z-index: 100;
+        }
+
+        .weixin-tip p {
+            text-align: center;
+            margin-top: 10%;
+            padding: 0 5%;
+        }
+
+        * {
+            padding: 0;
+            margin: 0;
+            box-sizing: border-box
+        }
+
+    </style>
+</head>
+<body>
+<div class="div">
+    <img class="img" src="/static/img/down.jpg"/>
+    <a href="{$apk}" downLoad="duoli.apk">
+        <div class="button">Android版本下载</div>
+    </a>
+</div>
+<div class="weixin-tip">
+    <p>
+        <img src="/static/img/live_weixin.png" alt="微信打开"/>
+    </p>
+</div>
+</body>
+<script>
+    $(window).on("load", function () {
+        var winHeight = $(window).height();
+
+        function is_weixin() {
+            var ua = navigator.userAgent.toLowerCase();
+            if (ua.match(/MicroMessenger/i) == "micromessenger") {
+                return true;
+            } else {
+                return false;
+            }
+        }
+
+        var isWeixin = is_weixin();
+        if (isWeixin) {
+            $(".weixin-tip").css("height", winHeight);
+            $(".weixin-tip").show();
+        }
+    })
+</script>
+</html>

+ 211 - 0
app/register/view/index/index.html

@@ -0,0 +1,211 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
+    <meta name="misapplication-tap-highlight" content="no"/>
+    <meta name="HandheldFriendly" content="true"/>
+    <meta name="MobileOptimized" content="320"/>
+    <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>
+    <script typet="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
+</head>
+<body>
+<div class="container">
+    <div class="loginTitle">欢迎注册喜嗨购</div>
+    <div class="loginText">请认真填写个人信息</div>
+    <div class="login-box">
+        <div class="username">账号</div>
+        <input class="input-box" type="email" id="phone" name="phone" placeholder="请输入手机号"/>
+    </div>
+    <div class="login-box">
+        <div class="username">验证码</div>
+        <div class="flex">
+            <input class="input-box" style="width: 50%" id="code" type="number" name="code" placeholder="请输入验证码">
+            <div class="code" id="daojishi" onclick="verification()">发送验证码</div>
+        </div>
+    </div>
+    <div class="login-box">
+        <div class="username">登录密码</div>
+        <input class="input-box" id="loginPass" type="password" name="loginPass" placeholder="请输入登录密码">
+    </div>
+    <div class="login-box">
+        <div class="username">邀请码</div>
+        <input class="input-box" id="invitation" type="text" disabled="disabled" name="invitation" placeholder="请输入邀请码">
+    </div>
+    <div class="flex">
+        <div class="login" onclick="fnLogin()">注册</div>
+        <div class="login"><a href="{:url('down')}">下载APP</a></div>
+    </div>
+</div>
+</body>
+<script type="text/javascript">
+    var url = location.search;
+    if (url.indexOf("?") != -1) {
+        var str = url.substr(1);
+        strs = str.split("=");
+        var invitation = strs[1];
+        document.getElementById('invitation').value = invitation;
+    }
+
+    function fnLogin() {
+        var phone = document.getElementById("phone").value;
+        var loginPass = document.getElementById("loginPass").value;
+        var code = document.getElementById("code").value;
+        var invitation = document.getElementById("invitation").value;
+        var payment_pas = document.getElementById("payment_pas").value;
+        if (phone == '') {
+            window.alert("请输入账号");
+            return false;
+        }
+        if (code == '') {
+            window.alert("请输入验证码");
+            return false;
+        }
+        if (loginPass == '') {
+            window.alert("请输入登录密码");
+            return false;
+        }
+        if (invitation == '') {
+            window.alert("请输入邀请码");
+            return false;
+        }
+        $.ajax({
+            type: "post",
+            url: "http://xhg.duolio.cn/api/register",
+            data: {account: phone, captcha: code, password: loginPass, spread: invitation,payment_pas:payment_pas},
+            dataType: "json",
+            success: function (data) {
+                window.alert(data.msg);
+                if (data.msg === '注册成功')
+                    window.location.href = "{:url('down')}"
+            }
+        });
+    }
+
+    function verification() {
+        var phone = document.getElementById("phone").value;
+        if (phone == '') {
+            window.alert("请输入手机号");
+            return false;
+        }
+        if (!/^1[3|4|5|6|7|8|9]\d{9}$/.test(phone)) {
+            window.alert('请输入正确的手机号');
+            return;
+        }
+
+        var timer = null;
+        var count = 60;
+        var codeText = $('#daojishi').text();
+
+        if (codeText == '发送验证码') {
+            timer = setInterval(function () {
+                count--;
+                $('#daojishi').text(count);
+                if (count <= 0) {
+                    clearInterval(timer);
+                    $('#daojishi').text('发送验证码');
+                }
+            }, 1000);
+        }
+        if (codeText != '发送验证码') {
+            return
+        }
+        $.ajax({
+            type: "post",
+            url: "http://xhg.duolio.cn/api/register/verify",
+            data: {phone: phone, type: 'register'},
+            dataType: "json",
+            success: function (data) {
+                window.alert(data.msg);
+
+            }
+        });
+    }
+</script>
+<style type="text/css">
+    * {
+        margin: 0;
+        padding: 0;
+        font-family: 微软雅黑;
+        font-size: 12px;
+        min-height: 100%;
+    }
+
+    .container {
+        padding: 10% 30px 0px 30px;
+    }
+
+    .loginTitle {
+        font-weight: bold;
+        color: #32baff;
+        font-size: 29px;
+        padding-bottom: 25px;
+    }
+
+    .loginText {
+        font-weight: 500;
+        color: #333333;
+        font-size: 17px;
+        margin-bottom: 15px;
+    }
+
+    .login-box {
+        width: 100%;
+        font-size: 16px;
+        padding-top: 15px;
+    }
+
+    .username {
+        display: block;
+        padding-bottom: 12px;
+        font-weight: 500;
+        color: #333333;
+        font-size: 16px;
+
+    }
+
+    .input-box {
+        border: none;
+        padding: 10px 8px;
+        outline: none;
+        width: 100%;
+        background-color: #F5F5F5;
+        border-radius: 9px;
+        color: #32baff;
+    }
+
+    .input-box::placeholder {
+        color: #bbbbbb;
+    }
+
+    .code {
+        background-color: #32baff;
+        border-radius: 5px;
+        font-weight: 500;
+        color: #FFFFFF;
+        font-size: 13px;
+        padding: 6px 8px;
+    }
+
+    .login {
+        background-color: #32baff;
+        color: #FFFFFF;
+        text-align: center;
+        width: 130px;
+        line-height: 40px;
+        border-radius: 25px;
+        margin-top: 30px;
+    }
+
+    .login > a {
+        color: #FFFFFF;
+        text-decoration: none;
+    }
+
+    .flex {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+    }
+</style>
+</html>

+ 1 - 1
config/app.php

@@ -27,7 +27,7 @@ return [
     // 自动多应用模式
     'auto_multi_app'   => true,
     // 应用映射(自动多应用模式有效)
-    'app_map'          => ['*'=>'', 'api'=>'api', 'admin'=>'admin','wap'=>'wap'],
+    'app_map'          => ['*'=>'', 'api'=>'api', 'admin'=>'admin','wap'=>'wap', 'register' => 'register'],
     // 域名绑定(自动多应用模式有效)
     'domain_bind'      => [],
     // 禁止URL访问的应用列表(自动多应用模式有效)