hrjy 3 tahun lalu
induk
melakukan
2f28951a08

+ 4 - 0
app/admin/controller/auction/Auction.php

@@ -5,7 +5,11 @@ use app\admin\controller\AuthController;
 use app\admin\controller\Union;
 use app\admin\model\auction\AuctionGu;
 use app\admin\model\auction\AuctionProduct as model;
+use app\admin\model\store\StoreProductAttrResult;
+use app\admin\model\store\StoreProductAttrValue;
 use app\admin\model\User;
+use app\models\store\StoreProduct;
+use app\models\store\StoreProductAttr;
 use crmeb\services\{ExpressService,
     JsonService,
     JsonService as Json,

+ 1 - 0
app/admin/controller/store/StoreProduct.php

@@ -271,6 +271,7 @@ class StoreProduct extends AuthController
             ['attrs', []],
             ['activity', []]
         ]);
+        pr($data['attrs']);
         foreach ($data['activity'] as $k => $v) {
             if ($v == '秒杀') {
                 $data['activity'][$k] = 1;

+ 1 - 1
app/admin/model/order/StoreOrder.php

@@ -634,7 +634,7 @@ HTML;
                 'col' => 2
             ],
             [
-                'name' => '退回积分',
+                'name' => '退回趣豆',
                 'field' => '元',
                 'count' => $price['back_integral'],
                 'background_color' => 'layui-bg-blue',

+ 66 - 21
app/api/controller/AuthController.php

@@ -128,19 +128,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)) {
@@ -148,7 +166,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) {
@@ -161,25 +178,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();
+        }
     }
 
     /**

+ 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' => '发送失败'];
+        }
+    }
+}

+ 1 - 0
app/http/middleware/AllowOriginMiddleware.php

@@ -8,6 +8,7 @@ use app\models\auction\Auction;
 use app\models\auction\AuctionOrder;
 use app\models\auction\AuctionProduct;
 use app\models\auction\AuctionTime;
+use app\models\store\StoreOrder;
 use app\Request;
 use crmeb\interfaces\MiddlewareInterface;
 use think\facade\Config;