liaofei vor 6 Jahren
Ursprung
Commit
3d1fa194aa
53 geänderte Dateien mit 486 neuen und 370 gelöschten Zeilen
  1. 3 3
      app/admin/controller/agent/AgentManage.php
  2. 1 1
      app/admin/controller/finance/UserRecharge.php
  3. 5 4
      app/admin/controller/order/StoreOrder.php
  4. 17 17
      app/admin/controller/record/Record.php
  5. 2 0
      app/admin/controller/setting/SystemAdmin.php
  6. 2 2
      app/admin/controller/setting/SystemConfig.php
  7. 26 12
      app/admin/controller/sms/SmsAdmin.php
  8. 193 171
      app/admin/controller/system/SystemFile.php
  9. 1 1
      app/admin/controller/ump/StoreSeckill.php
  10. 1 1
      app/admin/controller/ump/UserPoint.php
  11. 1 1
      app/admin/controller/user/User.php
  12. 6 6
      app/admin/model/order/StoreOrder.php
  13. 36 3
      app/admin/model/store/StoreProduct.php
  14. 1 1
      app/admin/model/system/SystemGroup.php
  15. 25 11
      app/admin/model/system/SystemLog.php
  16. 3 3
      app/admin/model/user/User.php
  17. 3 1
      app/admin/model/wechat/WechatMessage.php
  18. 1 1
      app/admin/model/wechat/WechatReply.php
  19. 4 1
      app/admin/model/wechat/WechatUser.php
  20. 10 0
      app/admin/view/article/article/create.php
  21. 4 4
      app/admin/view/index/main.php
  22. 26 0
      app/admin/view/order/store_order/index.php
  23. 0 48
      app/admin/view/record/record/chart_product.php
  24. 6 10
      app/admin/view/sms/sms_admin/index.php
  25. 10 2
      app/admin/view/store/store_product/index.php
  26. 2 2
      app/admin/view/system/system_file/opendir.php
  27. 2 2
      app/admin/view/wechat/store_service/create.php
  28. 1 1
      app/admin/view/widget/images.php
  29. 6 1
      app/api/controller/AuthController.php
  30. 10 6
      app/api/controller/PublicController.php
  31. 1 1
      app/api/controller/activity/StoreBargainController.php
  32. 4 0
      app/api/controller/order/StoreOrderController.php
  33. 1 1
      app/api/controller/store/CategoryController.php
  34. 2 2
      app/api/controller/store/StoreProductController.php
  35. 1 2
      app/common.php
  36. 8 0
      app/event.php
  37. 4 1
      app/models/store/StoreOrder.php
  38. 1 1
      app/models/store/StoreProduct.php
  39. 1 1
      app/models/system/SystemUserLevel.php
  40. 5 4
      app/models/user/User.php
  41. 1 1
      app/models/user/UserExtract.php
  42. 4 0
      app/models/user/UserRecharge.php
  43. 1 1
      app/models/user/WechatUser.php
  44. 1 1
      crmeb/services/HttpService.php
  45. 2 2
      crmeb/services/SMSService.php
  46. 2 2
      crmeb/services/UploadService.php
  47. 26 21
      crmeb/services/UtilService.php
  48. 2 2
      crmeb/services/WechatService.php
  49. 6 6
      crmeb/services/storage/COS.php
  50. 1 1
      crmeb/services/storage/OSS.php
  51. 2 2
      crmeb/services/storage/Qiniu.php
  52. 1 1
      crmeb/traits/ModelTrait.php
  53. 1 1
      route/api/route.php

+ 3 - 3
app/admin/controller/agent/AgentManage.php

@@ -26,7 +26,7 @@ class AgentManage extends AuthController
      */
     public function index()
     {
-        $this->assign( 'year',getMonth('y'));
+        $this->assign( 'year',getMonth());
         $this->assign('store_brokerage_statu',\crmeb\services\SystemConfigService::get('store_brokerage_statu'));
         return $this->fetch();
     }
@@ -64,7 +64,7 @@ class AgentManage extends AuthController
     public function stair($uid = ''){
         if($uid == '') return $this->failed('参数错误');
         $this->assign('uid',$uid ? : 0);
-        $this->assign( 'year',getMonth('y'));
+        $this->assign( 'year',getMonth());
         return $this->fetch();
     }
     /*
@@ -75,7 +75,7 @@ class AgentManage extends AuthController
     {
         if($uid == '') return $this->failed('参数错误');
         $this->assign('uid',$uid ? : 0);
-        $this->assign( 'year',getMonth('y'));
+        $this->assign( 'year',getMonth());
         return $this->fetch();
     }
 

+ 1 - 1
app/admin/controller/finance/UserRecharge.php

@@ -26,7 +26,7 @@ class UserRecharge extends AuthController
      * 显示操作记录
      */
     public function index(){
-        $this->assign( 'year',getMonth('y'));
+        $this->assign( 'year',getMonth());
         return $this->fetch();
     }
 

+ 5 - 4
app/admin/controller/order/StoreOrder.php

@@ -11,6 +11,7 @@ use app\admin\model\system\Express;
 use crmeb\repositories\OrderRepository;
 use crmeb\services\ExpressService;
 use crmeb\services\MiniProgramService;
+use crmeb\services\UtilService;
 use crmeb\services\WechatService;
 use crmeb\services\FormBuilder as Form;
 use crmeb\services\HookService;
@@ -40,7 +41,7 @@ class StoreOrder extends AuthController
     public function index()
     {
         $this->assign([
-            'year'=>getMonth('y'),
+            'year'=>getMonth(),
             'real_name'=>$this->request->get('real_name',''),
             'status'=>$this->request->param('status',''),
             'orderCount'=>StoreOrderModel::orderCount(),
@@ -205,8 +206,9 @@ class StoreOrder extends AuthController
     /*
      * 删除订单
      * */
-    public function del_order($ids=[])
+    public function del_order()
     {
+        $ids = UtilService::postMore(['ids'])['ids'];
         if(!count($ids)) return JsonService::fail('请选择需要删除的订单');
         if(StoreOrderModel::where('is_del',0)->where('id','in',$ids)->count()) return JsonService::fail('您选择的的订单存在用户未删除的订单,无法删除用户未删除的订单');
         $res=StoreOrderModel::where('id','in',$ids)->update(['is_system_del'=>1]);
@@ -261,7 +263,6 @@ class StoreOrder extends AuthController
                 StoreOrderModel::edit($data,$id);
                 event('StoreProductOrderDeliveryAfter',[$data,$id]);
                 StoreOrderStatus::setStatus($id,'delivery_fictitious','已虚拟发货');
-                StoreOrderStatus::setStatus($id,'take_delivery','虚拟物品已收货');
                 break;
             default:
                 return Json::fail('暂时不支持其他发货类型');
@@ -497,7 +498,7 @@ class StoreOrder extends AuthController
         if($order['delivery_type'] != 'express' || !$order['delivery_id']) return $this->failed('该订单不存在快递单号!');
         $cacheName = $order['order_id'].$order['delivery_id'];
         $result = CacheService::get($cacheName,null);
-        if($result === null || 1==1){
+        if($result === null){
             $result = ExpressService::query($order['delivery_id']);
             if(is_array($result) &&
                 isset($result['result']) &&

+ 17 - 17
app/admin/controller/record/Record.php

@@ -41,7 +41,7 @@ class Record extends AuthController
     public function chart_order(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -59,7 +59,7 @@ class Record extends AuthController
     public function chart_product(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -129,7 +129,7 @@ class Record extends AuthController
     public function chart_score(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -151,7 +151,7 @@ class Record extends AuthController
     public function chart_coupon(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -173,7 +173,7 @@ class Record extends AuthController
     public function chart_combination(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -183,7 +183,7 @@ class Record extends AuthController
     public function chart_bargain(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -193,7 +193,7 @@ class Record extends AuthController
     public function chart_seckill(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -204,7 +204,7 @@ class Record extends AuthController
     public function chart_rebate(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -230,7 +230,7 @@ class Record extends AuthController
     public function chart_recharge(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -246,7 +246,7 @@ class Record extends AuthController
     public function chart_cash(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -261,7 +261,7 @@ class Record extends AuthController
     public function user_chart(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -297,7 +297,7 @@ class Record extends AuthController
         $this->assign([
             'is_layui'=>true,
             'limit'=>$limit,
-            'year'=>getMonth('y'),
+            'year'=>getMonth(),
             'commissionList'=>$top10list['commission'],
             'extractList'=>$top10list['extract'],
         ]);
@@ -328,7 +328,7 @@ class Record extends AuthController
         $this->assign([
             'is_layui'=>true,
             'limit'=>$limit,
-            'year'=>getMonth('y'),
+            'year'=>getMonth(),
             'integralList'=>$top10list['integral'],
             'moneyList'=>$top10list['now_money'],
             'shopcountList'=>$top10list['shopcount'],
@@ -365,7 +365,7 @@ class Record extends AuthController
     public function user_attr(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -405,7 +405,7 @@ class Record extends AuthController
         if(!StoreProduct::be(['id'=>$id])) return $this->failed('商品不存在!');
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y'),
+            'year'=>getMonth(),
             'id'=>$id,
         ]);
         return $this->fetch();
@@ -444,7 +444,7 @@ class Record extends AuthController
     public function ranking_commission(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }
@@ -477,7 +477,7 @@ class Record extends AuthController
     public function ranking_point(){
         $this->assign([
             'is_layui'=>true,
-            'year'=>getMonth('y')
+            'year'=>getMonth()
         ]);
         return $this->fetch();
     }

+ 2 - 0
app/admin/controller/setting/SystemAdmin.php

@@ -87,8 +87,10 @@ class SystemAdmin extends AuthController
         if($data['pwd'] != $data['conf_pwd']) return Json::fail('两次输入密码不想同');
         if(AdminModel::be($data['account'],'account')) return Json::fail('管理员账号已存在');
         $data['pwd'] = md5($data['pwd']);
+        $data['add_time'] = time();
         unset($data['conf_pwd']);
         $data['level'] = $this->adminInfo['level'] + 1;
+        $data['add_time'] =time();
         if(!AdminModel::create($data)) return Json::fail('添加管理员失败');
         return Json::successful('添加管理员成功!');
     }

+ 2 - 2
app/admin/controller/setting/SystemConfig.php

@@ -83,11 +83,11 @@ class SystemConfig extends AuthController
                    switch ($data['upload_type']){
                        case 1:
                            $data['value'] = json_decode($data['value'],true)?:'';
-                           $formbuider[] = Form::frameImageOne($data['menu_name'],$data['info'],Url::buildUrl('admin/widget.images/index',array('fodder'=>$data['menu_name'])),$data['value'])->icon('image')->width('100%')->height('500px')->info($data['desc'])->col(13);
+                           $formbuider[] = Form::frameImageOne($data['menu_name'],$data['info'],Url::buildUrl('admin/widget.images/index',array('fodder'=>$data['menu_name'])),$data['value'])->icon('image')->width('70%')->height('500px')->info($data['desc'])->col(13);
                            break;
                        case 2:
                            $data['value'] = json_decode($data['value'],true)?:[];
-                           $formbuider[] = Form::frameImages($data['menu_name'],$data['info'],Url::buildUrl('admin/widget.images/index',array('fodder'=>$data['menu_name'])),$data['value'])->maxLength(5)->icon('image')->width('100%')->height('500px')->info($data['desc'])->col(13);
+                           $formbuider[] = Form::frameImages($data['menu_name'],$data['info'],Url::buildUrl('admin/widget.images/index',array('fodder'=>$data['menu_name'])),$data['value'])->maxLength(5)->icon('image')->width('70%')->height('500px')->info($data['desc'])->col(13);
                            break;
                        case 3:
                            $data['value'] = json_decode($data['value'],true);

+ 26 - 12
app/admin/controller/sms/SmsAdmin.php

@@ -1,8 +1,10 @@
 <?php
+
 namespace app\admin\controller\sms;
 
 use app\admin\controller\AuthController;
 use app\admin\model\system\SystemConfig;
+use crmeb\services\HttpService;
 use crmeb\services\JsonService;
 use crmeb\services\SMSService;
 use crmeb\services\UtilService;
@@ -19,14 +21,26 @@ class SmsAdmin extends AuthController
      */
     public function index()
     {
-        $this->assign('url', SMSService::code());
         return $this->fetch();
     }
 
+    public function captcha()
+    {
+        if (!request()->isPost()) return JsonService::fail('发生失败');
+        $phone = request()->param('phone');
+        if (!trim($phone)) return JsonService::fail('请填写手机号');
+
+        $res = json_decode(HttpService::getRequest(SMSService::code(), compact('phone')), true);
+        if (!isset($res['status']) && $res['status'] !== 200)
+            return JsonService::fail(isset($res['data']['message']) ? $res['data']['message'] : $res['msg']);
+        return JsonService::success(isset($res['data']['message']) ? $res['data']['message'] : $res['msg']);
+    }
+
     /**
      * 修改/注册短信平台账号
      */
-    public function save(){
+    public function save()
+    {
         list($account, $password, $phone, $code, $url, $sign) = UtilService::postMore([
             ['account', ''],
             ['password', ''],
@@ -34,17 +48,17 @@ class SmsAdmin extends AuthController
             ['code', ''],
             ['url', ''],
             ['sign', ''],
-        ], null ,true);
-        $signLen = strlen(trim($sign));
-        if(!strlen(trim($account))) return JsonService::fail('请填写账号');
-        if(!strlen(trim($password))) return JsonService::fail('请填写密码');
-        if(!$signLen) return JsonService::fail('请填写短信签名');
-        if($signLen > 8) return JsonService::fail('短信签名最长为8');
-        if(!strlen(trim($code))) return JsonService::fail('请填写验证码');
-        if(!strlen(trim($url))) return JsonService::fail('请填写域名');
+        ], null, true);
+        $signLen = mb_strlen(trim($sign));
+        if (!strlen(trim($account))) return JsonService::fail('请填写账号');
+        if (!strlen(trim($password))) return JsonService::fail('请填写密码');
+        if (!$signLen) return JsonService::fail('请填写短信签名');
+        if ($signLen > 8) return JsonService::fail('短信签名最长为8');
+        if (!strlen(trim($code))) return JsonService::fail('请填写验证码');
+        if (!strlen(trim($url))) return JsonService::fail('请填写域名');
         $status = SMSService::register($account, md5(trim($password)), $url, $phone, $code, $sign);
-        if($status['status'] == 400) return JsonService::fail('短信平台:'.$status['msg']);
+        if ($status['status'] == 400) return JsonService::fail('短信平台:' . $status['msg']);
         SystemConfig::setConfigSmsInfo($account, $password);
-        return JsonService::success('短信平台:'.$status['msg']);
+        return JsonService::success('短信平台:' . $status['msg']);
     }
 }

+ 193 - 171
app/admin/controller/system/SystemFile.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace app\admin\controller\system;
 
 use app\admin\model\system\SystemFile as SystemFileModel;
@@ -16,159 +17,175 @@ use crmeb\services\JsonService as Json;
 class SystemFile extends AuthController
 {
     //打开目录
-    public function opendir($filedir=''){
-        $fileAll = array('dir'=>[],'file'=>[]);
-        $request_dir = str_replace('../', '', app('request')->param('dir'));
+    public function opendir($filedir = '')
+    {
+        $fileAll = array('dir' => [], 'file' => []);
+        //根目录
+        $rootdir = app()->getRootPath();
+        //当前目录
+        $request_dir = app('request')->param('dir');
+        //防止查看站点以外的目录
+        if(strpos($request_dir,$rootdir) === false){
+            $request_dir = $rootdir;
+        }
+        //判断是否是返回上级
+        if (app('request')->param('superior') && !empty($request_dir)) {
+            if(strpos(dirname($request_dir),$rootdir) !== false){
+                $dir = dirname($request_dir);
+            }else{
+                $dir = $rootdir;
+            }
 
-        if(app('request')->param('superior') && !empty($request_dir)){
-            $path = '..'.DS.app('request')->param('dir');
-            $path = dirname($path);
-        }else{
-            $path = !empty($request_dir) ? $request_dir : '..';
-            $path = $path.DS.app('request')->param('filedir');
+        } else {
+            $dir = !empty($request_dir) ? $request_dir : $rootdir;
+            $dir = rtrim($dir,DS) .DS. app('request')->param('filedir');
         }
-        $list = scandir($path);
-        foreach($list as $key=>$v) {
-            if($v !='.' && $v !='..'){
-                if (is_dir($path.'/'.$v)) {
-                    $fileAll['dir'][] = FileClass::list_info($path.'/'.$v);
+        $list = scandir($dir);
+        foreach ($list as $key => $v) {
+            if ($v != '.' && $v != '..') {
+                if (is_dir($dir . DS . $v)) {
+                    $fileAll['dir'][] = FileClass::list_info($dir .DS. $v);
                 }
-                if(is_file($path.'/'.$v)){
-                    $fileAll['file'][] = FileClass::list_info($path.'/'.$v);
+                if (is_file($dir . DS . $v)) {
+                    $fileAll['file'][] = FileClass::list_info($dir .DS. $v);
                 }
             }
         }
-//        var_dump($fileAll['file']);
+        //var_dump($fileAll['dir']);
         //兼容windows
         $uname = php_uname('s');
-        if(strstr($uname,'Windows')!==false) $path = ltrim($path,'\\');
-        $dir = ltrim($path,'./');
-        $this->assign(compact('fileAll','dir'));
+        if (strstr($uname, 'Windows') !== false) $dir = ltrim($dir, '\\');
+        $this->assign(compact('fileAll', 'dir'));
         return $this->fetch();
     }
+
     //读取文件
-    public function openfile($file='')
+    public function openfile($file = '')
     {
         $file = $this->request->param('file');
-        if(empty($file))return Json::fail('出现错误');
-        $filepath  = '.'.$file;
+        if (empty($file)) return Json::fail('出现错误');
+        $filepath = $file;
         $content = FileClass::read_file($filepath);//防止页面内嵌textarea标签
         $ext = FileClass::get_ext($filepath);
         $extarray = [
-            'js'=>'text/javascript'
-            ,'php'=>'text/x-php'
-            ,'html'=>'text/html'
-            ,'sql'=>'text/x-mysql'
-            ,'css'=>'text/x-scss'];
-        $mode = empty($extarray[$ext])?'':$extarray[$ext];
-        $this->assign(compact('content','mode','filepath'));
+            'js' => 'text/javascript'
+            , 'php' => 'text/x-php'
+            , 'html' => 'text/html'
+            , 'sql' => 'text/x-mysql'
+            , 'css' => 'text/x-scss'];
+        $mode = empty($extarray[$ext]) ? '' : $extarray[$ext];
+        $this->assign(compact('content', 'mode', 'filepath'));
         return $this->fetch();
     }
+
     //保存文件
-    public function savefile(){
+    public function savefile()
+    {
         $comment = $this->request->post('comment');
         $filepath = $this->request->post('filepath');
-        if(!empty($comment) && !empty($filepath)){
+        if (!empty($comment) && !empty($filepath)) {
             //兼容windows
             $uname = php_uname('s');
-            if(strstr($uname,'Windows')!==false)
-            $filepath = ltrim(str_replace('/', DS, $filepath),'.');
-            if(FileClass::isWritable($filepath)){
-                $res = FileClass::write_file($filepath,$comment);
-                if($res){
+            if (strstr($uname, 'Windows') !== false)
+                $filepath = ltrim(str_replace('/', DS, $filepath), '.');
+            if (FileClass::isWritable($filepath)) {
+                $res = FileClass::write_file($filepath, $comment);
+                if ($res) {
                     return Json::successful('保存成功!');
-                }else{
+                } else {
                     return Json::fail('保存失败');
                 }
-            }else{
+            } else {
                 return Json::fail('没有权限!');
             }
 
-        }else{
+        } else {
             return Json::fail('出现错误');
         }
 
     }
-    public function index(){
-       $app = $this->getDir('./application');
-       $extend = $this->getDir('./extend');
-       $public = $this->getDir('./public');
-       $arr = array();
-       $arr = array_merge($app,$extend);
-       $arr = array_merge($arr,$public);
-       $fileAll = array();//本地文件
-       $cha = array();//不同的文件
-       foreach ($arr as $k=>$v) {
-           $fp = fopen($v, 'r');
-           if (filesize($v))  $ct = fread($fp, filesize($v));
-           else $ct = null;
-           fclose($fp);
-           $cthash = md5($ct);
-                   $update_time = stat($v);
-           $fileAll[$k]['cthash'] = $cthash;
-           $fileAll[$k]['filename'] = $v;
-           $fileAll[$k]['atime'] = $update_time['atime'];
-           $fileAll[$k]['mtime'] = $update_time['mtime'];
-           $fileAll[$k]['ctime'] = $update_time['ctime'];
-       }
-       $file = SystemFileModel::all(function($query){
-           $query->order('atime', 'desc');
-       })->toArray();//数据库中的文件
-       if(empty($file)){
-           $data_num = array_chunk($fileAll,10);
-           SystemFileModel::beginTrans();
-           $res = true;
-           foreach ($data_num as $k=>$v){
-               $res = $res && SystemFileModel::insertAll($v);
-           }
-           SystemFileModel::checkTrans($res);
-           if($res){
-               $cha = array();//不同的文件
-           }else{
-               $cha = $fileAll;
-           }
-       }else{
-           $cha = array();//差异文件
-           foreach ($file as $k=>$v){
-               foreach ($fileAll as $ko=>$vo){
-                   if($v['filename'] == $vo['filename']){
-                       if($v['cthash'] != $vo['cthash']){
-                           $cha[$k]['filename'] = $v['filename'];
-                           $cha[$k]['cthash'] = $v['cthash'];
-                           $cha[$k]['atime'] = $v['atime'];
-                           $cha[$k]['mtime'] = $v['mtime'];
-                           $cha[$k]['ctime'] = $v['ctime'];
-                           $cha[$k]['type'] =  '已修改';
-                       }
-                       unset($fileAll[$ko]);
-                       unset($file[$k]);
-                   }
-               }
 
-           }
-           foreach ($file as $k=>$v){
-               $cha[$k]['filename'] = $v['filename'];
-               $cha[$k]['cthash'] = $v['cthash'];
-               $cha[$k]['atime'] = $v['atime'];
-               $cha[$k]['mtime'] = $v['mtime'];
-               $cha[$k]['ctime'] = $v['ctime'];
-               $cha[$k]['type'] =  '已删除';
-           }
-           foreach ($fileAll as $k=>$v){
-               $cha[$k]['filename'] = $v['filename'];
-               $cha[$k]['cthash'] = $v['cthash'];
-               $cha[$k]['atime'] = $v['atime'];
-               $cha[$k]['mtime'] = $v['mtime'];
-               $cha[$k]['ctime'] = $v['ctime'];
-               $cha[$k]['type'] =  '新增的';
-           }
+    public function index()
+    {
+        $app = $this->getDir('./application');
+        $extend = $this->getDir('./extend');
+        $public = $this->getDir('./public');
+        $arr = array();
+        $arr = array_merge($app, $extend);
+        $arr = array_merge($arr, $public);
+        $fileAll = array();//本地文件
+        $cha = array();//不同的文件
+        foreach ($arr as $k => $v) {
+            $fp = fopen($v, 'r');
+            if (filesize($v)) $ct = fread($fp, filesize($v));
+            else $ct = null;
+            fclose($fp);
+            $cthash = md5($ct);
+            $update_time = stat($v);
+            $fileAll[$k]['cthash'] = $cthash;
+            $fileAll[$k]['filename'] = $v;
+            $fileAll[$k]['atime'] = $update_time['atime'];
+            $fileAll[$k]['mtime'] = $update_time['mtime'];
+            $fileAll[$k]['ctime'] = $update_time['ctime'];
+        }
+        $file = SystemFileModel::all(function ($query) {
+            $query->order('atime', 'desc');
+        })->toArray();//数据库中的文件
+        if (empty($file)) {
+            $data_num = array_chunk($fileAll, 10);
+            SystemFileModel::beginTrans();
+            $res = true;
+            foreach ($data_num as $k => $v) {
+                $res = $res && SystemFileModel::insertAll($v);
+            }
+            SystemFileModel::checkTrans($res);
+            if ($res) {
+                $cha = array();//不同的文件
+            } else {
+                $cha = $fileAll;
+            }
+        } else {
+            $cha = array();//差异文件
+            foreach ($file as $k => $v) {
+                foreach ($fileAll as $ko => $vo) {
+                    if ($v['filename'] == $vo['filename']) {
+                        if ($v['cthash'] != $vo['cthash']) {
+                            $cha[$k]['filename'] = $v['filename'];
+                            $cha[$k]['cthash'] = $v['cthash'];
+                            $cha[$k]['atime'] = $v['atime'];
+                            $cha[$k]['mtime'] = $v['mtime'];
+                            $cha[$k]['ctime'] = $v['ctime'];
+                            $cha[$k]['type'] = '已修改';
+                        }
+                        unset($fileAll[$ko]);
+                        unset($file[$k]);
+                    }
+                }
 
-       }
+            }
+            foreach ($file as $k => $v) {
+                $cha[$k]['filename'] = $v['filename'];
+                $cha[$k]['cthash'] = $v['cthash'];
+                $cha[$k]['atime'] = $v['atime'];
+                $cha[$k]['mtime'] = $v['mtime'];
+                $cha[$k]['ctime'] = $v['ctime'];
+                $cha[$k]['type'] = '已删除';
+            }
+            foreach ($fileAll as $k => $v) {
+                $cha[$k]['filename'] = $v['filename'];
+                $cha[$k]['cthash'] = $v['cthash'];
+                $cha[$k]['atime'] = $v['atime'];
+                $cha[$k]['mtime'] = $v['mtime'];
+                $cha[$k]['ctime'] = $v['ctime'];
+                $cha[$k]['type'] = '新增的';
+            }
+
+        }
 //   dump($file);
 //   dump($fileAll);
-       $this->assign('cha',$cha);
-       return $this->fetch();
-   }
+        $this->assign('cha', $cha);
+        return $this->fetch();
+    }
 
 
     /**
@@ -176,41 +193,44 @@ class SystemFile extends AuthController
      * @param $dir
      * @return array
      */
-    public function getNextDir(){
+    public function getNextDir()
+    {
         $dir = './';
         $list = scandir($dir);
         $dirlist = array();
         $filelist = array();
-        foreach($list as $key=>$v) {
-            if($v !='.' && $v !='..'){
-                if (is_dir($dir.'/'.$v)) {
+        foreach ($list as $key => $v) {
+            if ($v != '.' && $v != '..') {
+                if (is_dir($dir . '/' . $v)) {
                     $dirlist['dir'][$key] = $v;
                 }
-                if(is_file($dir.'/'.$v)){
+                if (is_file($dir . '/' . $v)) {
                     $filelist['file'][$key] = $v;
                 }
             }
         }
-        $filesarr = array_merge($dirlist,$filelist);
+        $filesarr = array_merge($dirlist, $filelist);
         print_r($filesarr);
     }
+
     /**
      * 获取文件夹中的文件 包括子文件 不能直接用  直接使用  $this->getDir()方法 P156
      * @param $path
      * @param $data
      */
-    public function searchDir($path,&$data){
-        if(is_dir($path) && !strpos($path,'uploads')){
-            $dp=dir($path);
-            while($file=$dp->read()){
-                if($file!='.'&& $file!='..'){
-                    $this->searchDir($path.'/'.$file,$data);
+    public function searchDir($path, &$data)
+    {
+        if (is_dir($path) && !strpos($path, 'uploads')) {
+            $dp = dir($path);
+            while ($file = $dp->read()) {
+                if ($file != '.' && $file != '..') {
+                    $this->searchDir($path . '/' . $file, $data);
                 }
             }
             $dp->close();
         }
-        if(is_file($path)){
-           $data[]=$path;
+        if (is_file($path)) {
+            $data[] = $path;
         }
     }
 
@@ -219,57 +239,59 @@ class SystemFile extends AuthController
      * @param $dir
      * @return array
      */
-    public function getDir($dir){
-        $data=array();
-        $this->searchDir($dir,$data);
+    public function getDir($dir)
+    {
+        $data = array();
+        $this->searchDir($dir, $data);
         return $data;
     }
 
     //测试
-    public function ceshi(){
+    public function ceshi()
+    {
         //创建form
-        $form = Form::create('/save.php',[
-            Form::input('goods_name','商品名称')
-            ,Form::input('goods_name1','password')->type('password')
-            ,Form::input('goods_name2','textarea')->type('textarea')
-            ,Form::input('goods_name3','email')->type('email')
-            ,Form::input('goods_name4','date')->type('date')
-            ,Form::city('address','cityArea',
-                '陕西省','西安市'
+        $form = Form::create('/save.php', [
+            Form::input('goods_name', '商品名称')
+            , Form::input('goods_name1', 'password')->type('password')
+            , Form::input('goods_name2', 'textarea')->type('textarea')
+            , Form::input('goods_name3', 'email')->type('email')
+            , Form::input('goods_name4', 'date')->type('date')
+            , Form::city('address', 'cityArea',
+                '陕西省', '西安市'
             )
-            ,Form::dateRange('limit_time','dateRange',
+            , Form::dateRange('limit_time', 'dateRange',
                 strtotime('- 10 day'),
                 time()
             )
-            ,Form::dateTime('add_time','dateTime')
-            ,Form::color('color','color','#ff0000')
-            ,Form::checkbox('checkbox','checkbox',[1])->options([['value'=>1,'label'=>'白色'],['value'=>2,'label'=>'红色'],['value'=>31,'label'=>'黑色']])
-            ,Form::date('riqi','date','2018-03-1')
-            ,Form::dateTimeRange('dateTimeRange','区间时间段')
-            ,Form::year('year','year')
-            ,Form::month('month','month')
-            ,Form::frame('frame','frame','/admin/system.system_attachment/index.html?fodder=frame')
-            ,Form::frameInputs('frameInputs','frameInputs','/admin/system.system_attachment/index.html?fodder=frameInputs')
-            ,Form::frameFiles('month1','frameFiles','/admin/system.system_attachment/index.html?fodder=month1')
-            ,Form::frameImages('fodder1','frameImages','/admin/system.system_attachment/index.html?fodder=fodder1')->maxLength(3)->width('800px')->height('400px')
-            ,Form::frameImages('fodder11','frameImages','/admin/system.system_attachment/index.html?fodder=fodder11')->icon('images')
-            ,Form::frameInputOne('month3','frameInputOne','/admin/system.system_attachment/index.html?fodder=month3')->icon('ionic')
-            ,Form::frameFileOne('month4','frameFileOne','/admin/system.system_attachment/index.html?fodder=month4')
-            ,Form::frameImageOne('month5','frameImageOne','/admin/system.system_attachment/index.html?fodder=month5')->icon('image')
-            ,Form::hidden('month6','hidden')
-            ,Form::number('month7','number')
+            , Form::dateTime('add_time', 'dateTime')
+            , Form::color('color', 'color', '#ff0000')
+            , Form::checkbox('checkbox', 'checkbox', [1])->options([['value' => 1, 'label' => '白色'], ['value' => 2, 'label' => '红色'], ['value' => 31, 'label' => '黑色']])
+            , Form::date('riqi', 'date', '2018-03-1')
+            , Form::dateTimeRange('dateTimeRange', '区间时间段')
+            , Form::year('year', 'year')
+            , Form::month('month', 'month')
+            , Form::frame('frame', 'frame', '/admin/system.system_attachment/index.html?fodder=frame')
+            , Form::frameInputs('frameInputs', 'frameInputs', '/admin/system.system_attachment/index.html?fodder=frameInputs')
+            , Form::frameFiles('month1', 'frameFiles', '/admin/system.system_attachment/index.html?fodder=month1')
+            , Form::frameImages('fodder1', 'frameImages', '/admin/system.system_attachment/index.html?fodder=fodder1')->maxLength(3)->width('800px')->height('400px')
+            , Form::frameImages('fodder11', 'frameImages', '/admin/system.system_attachment/index.html?fodder=fodder11')->icon('images')
+            , Form::frameInputOne('month3', 'frameInputOne', '/admin/system.system_attachment/index.html?fodder=month3')->icon('ionic')
+            , Form::frameFileOne('month4', 'frameFileOne', '/admin/system.system_attachment/index.html?fodder=month4')
+            , Form::frameImageOne('month5', 'frameImageOne', '/admin/system.system_attachment/index.html?fodder=month5')->icon('image')
+            , Form::hidden('month6', 'hidden')
+            , Form::number('month7', 'number')
 //            ,Form::input input输入框,其他type: text类型Form::text,password类型Form::password,textarea类型Form::textarea,url类型Form::url,email类型Form::email,date类型Form::idate
-            ,Form::radio('month8','radio')->options([['value'=>1,'label'=>'白色'],['value'=>2,'label'=>'红色'],['value'=>31,'label'=>'黑色']])
-            ,Form::rate('month9','rate')
-            ,Form::select('month10','select')->options([['value'=>1,'label'=>'白色'],['value'=>2,'label'=>'红色'],['value'=>31,'label'=>'黑色']])
-            ,Form::selectMultiple('month11','selectMultiple')
-            ,Form::selectOne('month12','selectOne')
-            ,Form::slider('month13','slider',2)
-            ,Form::sliderRange('month23','sliderRange',2,13)
-            ,Form::switches('month14','区间时间段')
-            ,Form::timePicker('month15','区间时间段')
-            ,Form::time('month16','区间时间段')
-            ,Form::timeRange('month17','区间时间段')
+            , Form::radio('month8', 'radio')->options([['value' => 1, 'label' => '白色'], ['value' => 2, 'label' => '红色'], ['value' => 31, 'label' => '黑色']])
+            , Form::rate('month9', 'rate')
+            , Form::select('month10', 'select')->options([['value' => 1, 'label' => '白色'], ['value' => 2, 'label' => '红色'], ['value' => 31, 'label' => '黑色']])
+            , Form::selectMultiple('month11', 'selectMultiple')
+            , Form::selectOne('month12', 'selectOne')
+            , Form::slider('month13', 'slider', 2)
+            , Form::sliderRange('month23', 'sliderRange', 2, 13)
+            , Form::switches('month14', '区间时间段')
+            , Form::timePicker('month15', '区间时间段')
+            , Form::time('month16', '区间时间段')
+            , Form::timeRange('month17', '区间时间段')
 //            ,Form::upload('month','区间时间段')
 //            ,Form::uploadImages('month','区间时间段')
 //            ,Form::uploadFiles('month','区间时间段')

+ 1 - 1
app/admin/controller/ump/StoreSeckill.php

@@ -216,7 +216,7 @@ class StoreSeckill extends AuthController
         $f[] = Form::input('title','产品标题',$product->getData('title'));
         $f[] = Form::input('info','秒杀活动简介',$product->getData('info'))->type('textarea');
         $f[] = Form::input('unit_name','单位',$product->getData('unit_name'))->placeholder('个、位');
-        $f[] = Form::dateTimeRange('section_time','活动时间',date('Y-m-d H:i:s', $product->getData('start_time')),date('Y-m-d H:i:s', $product->getData('stop_time')));
+        $f[] = Form::dateTimeRange('section_time','活动时间',date('Y-m-d H:i:s', (int)$product->getData('start_time')),date('Y-m-d H:i:s', (int)$product->getData('stop_time')));
         $f[] = Form::frameImageOne('image','产品主图片(305*305px)',Url::buildUrl('admin/widget.images/index',array('fodder'=>'image')),$product->getData('image'))->icon('image')->width('100%')->height('500px');
         $f[] = Form::frameImages('images','产品轮播图(640*640px)',Url::buildUrl('admin/widget.images/index',array('fodder'=>'images')),json_decode($product->getData('images')))->maxLength(5)->icon('images')->width('100%')->height('500px');
         $f[] = Form::number('price','秒杀价',$product->getData('price'))->min(0)->col(12);

+ 1 - 1
app/admin/controller/ump/UserPoint.php

@@ -25,7 +25,7 @@ class UserPoint extends AuthController
 //            'count'=>UserBill::where(['category'=>'integral','type'=>'sign'])->group('uid')->count(),
 //            'song_point'=>UserBill::where(['category'=>'integral','type'=>'sign'])->group('uid')->sum('number'),
             'is_layui'=>true,
-            'year'=>getMonth('y'),
+            'year'=>getMonth(),
         ]);
         return $this->fetch();
     }

+ 1 - 1
app/admin/controller/user/User.php

@@ -198,7 +198,7 @@ class User extends AuthController
             foreach ($taskIds as $id){
                 $inserValue[]=['uid'=>$uid,'task_id'=>$id,'status'=>1,'add_time'=>time()];
             }
-            $res=$res && Db::name('user_task_finish')->insertAll($inserValue);
+            $res=$res && Db::name('user_task_finish')->insertAll($inserValue) && UserModel::where('uid',$uid)->update(['level'=>$level_id]);
             if($res){
                 UserModel::commitTrans();
                 return JsonService::successful('赠送成功');

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

@@ -150,11 +150,13 @@ class StoreOrder extends BaseModel
             }else if($item['paid']==1 && $item['refund_status']==1){
                 $refundReasonTime = date('Y-m-d H:i', $item['refund_reason_time']);
                 $refundReasonWapImg = json_decode($item['refund_reason_wap_img'], true);
-                $refundReasonWapImg = $refundReasonWapImg && is_array($refundReasonWapImg) ? $refundReasonWapImg : [];
+                $refundReasonWapImg = $refundReasonWapImg ? $refundReasonWapImg : [];
                 $img = '';
-                foreach ($refundReasonWapImg as $itemImg){
-                    if(strlen(trim($itemImg)))
-                        $img .='<img style="height:50px;" src="'.$itemImg.'" />';
+                if(count($refundReasonWapImg)){
+                    foreach ($refundReasonWapImg as $itemImg){
+                        if(strlen(trim($itemImg)))
+                            $img .='<img style="height:50px;" src="'.$itemImg.'" />';
+                    }
                 }
                 if(!strlen(trim($img)))  $img = '无';
                 $item['status_name']=<<<HTML
@@ -438,8 +440,6 @@ HTML;
         $model = $model->where('is_system_del',0);
         if(isset($where['status']) && $where['status'] != '') {
             $model =  self::statusByWhere($where['status'],$model,$aler);
-        }else{
-            $model = $model->where('paid',1);
         }
         if(isset($where['is_del']) && $where['is_del'] != '' && $where['is_del'] != -1) $model = $model->where($aler.'is_del',$where['is_del']);
         if(isset($where['combination_id'])){

+ 36 - 3
app/admin/model/store/StoreProduct.php

@@ -245,6 +245,32 @@ class StoreProduct extends BaseModel
         }
         unset($stk,$sum_stock,$stock1);
 
+        //获取砍价缺货产品
+        $stock1 = self::getModelTime($where,new StoreBargain())->where('stock','<',$replenishment_num)->column('stock','id');
+        $sum_stock = StoreBargain::where('stock','<',$replenishment_num)->column('stock','id');
+        $stk = [];
+        foreach ($stock1 as $item){
+            $stk[] = $replenishment_num-$item;
+        }
+        $lack = bcadd($lack,array_sum($stk),0);
+        foreach ($sum_stock as $val){
+            $sum[] = $replenishment_num-$val;
+        }
+        unset($stk,$sum_stock,$stock1);
+
+        //获取拼团缺货产品
+        $stock1 = self::getModelTime($where,new StoreCombination())->where('stock','<',$replenishment_num)->column('stock','id');
+        $sum_stock = StoreCombination::where('stock','<',$replenishment_num)->column('stock','id');
+        $stk = [];
+        foreach ($stock1 as $item){
+            $stk[] = $replenishment_num - $item;
+        }
+        $lack = bcadd($lack,array_sum($stk),0);
+        foreach ($sum_stock as $val){
+            $sum[] = $replenishment_num - $val;
+        }
+        unset($stk,$sum_stock,$stock1);
+
         return [
             [
                 'name'=>'商品种类',
@@ -292,12 +318,15 @@ class StoreProduct extends BaseModel
     public static function getActivityProductSum($where=false)
     {
         if($where){
+            $bargain=self::getModelTime($where,new StoreBargain())->sum('stock');
+            $pink=self::getModelTime($where,new StoreCombination())->sum('stock');
             $seckill=self::getModelTime($where,new StoreSeckill())->sum('stock');
         }else{
-        
+            $bargain=StoreBargain::sum('stock');
+            $pink=StoreCombination::sum('stock');
             $seckill=StoreSeckill::sum('stock');
         }
-        return $seckill;
+        return bcadd(bcadd($bargain,$pink,0),$seckill,0);
     }
 
     public static function setWhereType($model,$type){
@@ -355,7 +384,11 @@ class StoreProduct extends BaseModel
     //获取利润
     public static function ProfityTop10($where){
         $classs=['layui-bg-red','layui-bg-orange','layui-bg-green','layui-bg-blue','layui-bg-cyan'];
-        $model=StoreOrder::alias('a')->join('StoreOrderCartInfo c','a.id=c.oid')->join('__store_product__ b','b.id=c.product_id');
+        $model=StoreOrder::alias('a')
+            ->join('StoreOrderCartInfo c','a.id=c.oid')
+            ->join('__store_product__ b','b.id=c.product_id')
+            ->where('b.is_show',1)
+            ->where('b.is_del',0);
         $list=self::getModelTime($where,$model,'a.add_time')->group('c.product_id')->order('profity desc')->limit(10)
             ->field(['count(c.product_id) as p_count','b.store_name','sum(b.price) as sum_price','(b.price-b.cost) as profity'])
             ->select();

+ 1 - 1
app/admin/model/system/SystemGroup.php

@@ -37,7 +37,7 @@ class SystemGroup extends BaseModel
      * @return array
      */
     public static function getField($id){
-        $fields = json_decode(self::where('id',$id)->value("fields"),true);
+        $fields = json_decode(self::where('id',$id)->value("fields"),true)?:[];
         return compact('fields');
     }
 }

+ 25 - 11
app/admin/model/system/SystemLog.php

@@ -54,17 +54,31 @@ class SystemLog extends BaseModel
         $controller = $request->controller();
         $action = $request->action();
         $route = $request->route();
-        $data = [
-            'method'=>$request->app(),
-            'admin_id'=>$adminId,
-            'add_time'=>time(),
-            'admin_name'=>$adminName,
-            'path'=>SystemMenus::getAuthName($action,$controller,$module,$route),
-            'page'=>SystemMenus::getVisitName($action,$controller,$module,$route)?:'未知',
-            'ip'=>$request->ip(),
-            'type'=>$type
-        ];
-        return self::create($data);
+        self::startTrans();
+        try{
+            $data = [
+                'method'=>$request->app(),
+                'admin_id'=>$adminId,
+                'add_time'=>time(),
+                'admin_name'=>$adminName,
+                'path'=>SystemMenus::getAuthName($action,$controller,$module,$route),
+                'page'=>SystemMenus::getVisitName($action,$controller,$module,$route)?:'未知',
+                'ip'=>$request->ip(),
+                'type'=>$type
+            ];
+            $res = self::create($data);
+            if($res){
+                self::commit();
+                return true;
+            }else{
+                self::rollback();
+                return false;
+            }
+        }catch (\Exception $e){
+            self::rollback();
+            return self::setErrorInfo($e->getMessage());
+        }
+
     }
 
     /**

+ 3 - 3
app/admin/model/user/User.php

@@ -258,7 +258,7 @@ class User extends BaseModel
                     //自定义时间
                     if(strstr($where['date'],'-')!==FALSE){
                         list($startTime,$endTime)=explode('-',$where['date']);
-                        $model = $model->where('add_time','>',strtotime($startTime))->where('add_time','<',strtotime($endTime));
+                        $model = $model->where('add_time','>',strtotime($startTime))->where('add_time','<',bcadd(strtotime($endTime),86400,0));
                     }else{
                         $model=$model->whereTime('add_time','month');
                     }
@@ -337,12 +337,12 @@ class User extends BaseModel
             case 'quarter':
                 list($startTime,$endTime)=User::getMonth('n');
                 $model = $model->where('A.add_time','>',strtotime($startTime));
-                $model = $model->where('A.add_time','<',strtotime($endTime));
+                $model = $model->where('A.add_time','<',bcadd(strtotime($endTime),86400,0));
                 break;
             default:
                 list($startTime,$endTime)=explode('-',$date);
                 $model = $model->where('A.add_time','>',strtotime($startTime));
-                $model = $model->where('A.add_time','<',strtotime($endTime));
+                $model = $model->where('A.add_time','<',bcadd(strtotime($endTime),86400,0));
                 break;
         }
         if($status===true){

+ 3 - 1
app/admin/model/wechat/WechatMessage.php

@@ -64,7 +64,9 @@ class WechatMessage extends BaseModel
     }
     public static function setMessage($result,$openid,$type)
     {
-        $data = compact('result','openid','type');
+        if(is_object($result) || is_array($result)) $result = json_encode($result);
+        $add_time = time();
+        $data = compact('result','openid','type','add_time');
         return self::create($data);
     }
 

+ 1 - 1
app/admin/model/wechat/WechatReply.php

@@ -178,7 +178,7 @@ class WechatReply extends BaseModel
             return self::setErrorInfo('请选择图文消息');
         $siteUrl = SystemConfig::getConfigValue('site_url');
         foreach ($data as $k=>$v){
-            if(empty($v['url'])) $data[$k]['url'] = $siteUrl.Url::buildUrl('wap/article/visit',['id'=>$v['id']]);
+            if(empty($v['url'])) $data[$k]['url'] = $siteUrl.'/news_detail/'.$v['id'];
             if($v['image']) $data[$k]['image'] = $v['image'];
         }
         return $data;

+ 4 - 1
app/admin/model/wechat/WechatUser.php

@@ -17,6 +17,7 @@ use crmeb\basic\BaseModel;
 use crmeb\services\WechatService;
 use crmeb\services\PHPExcelService;
 use crmeb\services\SystemConfigService;
+use app\admin\model\order\StoreOrderStatus;
 
 /**
  * 微信用户 model
@@ -157,7 +158,9 @@ use crmeb\services\SystemConfigService;
                 ->setExcelContent($export)
                 ->ExcelSave();
         }
-        return self::page($model,$where);
+        return self::page($model,function($item){
+            $item['time'] = $item['add_time'] ? date('Y-m-d H:i',$item['add_time']) : '暂无';
+        },$where);
     }
 
      public static function setSpreadWhere($where=[],$alias='a',$model=null)

+ 10 - 0
app/admin/view/article/article/create.php

@@ -135,6 +135,7 @@
        </div>
    </div>
 </div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
 {/block}
 {block name="script"}
 <script>
@@ -265,23 +266,32 @@
                     }
                 }
                 var data = {};
+                var index = layList.layer.load(1, {
+                    shade: [0.5,'#fff'] //0.1透明度的白色背景
+                });;
                 $.ajax({
                     url:"{:Url('add_new')}",
                     data:list,
                     type:'post',
                     dataType:'json',
                     success:function(re){
+                        layer.close(index);
                         if(re.code == 200){
                             data[re.data] = list;
                             $('.type-all>.active>.new-id').val(re.data);
                             $eb.message('success',re.msg);
+                            location.reload();
                             setTimeout(function (e) {
                                 parent.$(".J_iframe:visible")[0].contentWindow.location.reload();
+
 //                                parent.layer.close(parent.layer.getFrameIndex(window.name));
                             },600)
                         }else{
                             $eb.message('error',re.msg);
                         }
+                    },
+                    error:function () {
+                        layer.close(index);
                     }
                 })
             });

+ 4 - 4
app/admin/view/index/main.php

@@ -67,7 +67,7 @@
                         {$first_line.d_num.percent}%
                         {if condition='$first_line.d_num.is_plus egt 0'}<i class="fa {if condition='$first_line.d_num.is_plus eq 1'}fa-level-up{else /}fa-level-down{/if}"></i>{/if}
                     </div>
-                    <small><a href="javascript:;" class="opFrames" data-name="订单管理" data-href="{:Url('order.store_order/index')}?data=yesterday">昨日订单数</a></small>
+                    <small><a href="javascript:;" class="opFrames" data-name="订单管理" data-href="{:Url('order.store_order/index')}?data=yesterday">昨日支付订单数</a></small>
                 </div>
             </div>
         </div>
@@ -274,7 +274,7 @@
                                     break;
                             }
                             var data=res.data.data;
-                            if(data.length) {
+                            if(data) {
                                 that.cyclecount = data.cycle.count.data;
                                 that.cyclecount_percent = data.cycle.count.percent;
                                 that.cyclecount_is_plus = data.cycle.count.is_plus;
@@ -287,7 +287,7 @@
                     });
                 },
                 orderchartsetoption:function(data){
-
+                    data = data == undefined ? {} : data;
                         this.option = {
                             tooltip: {
                                 trigger: 'axis',
@@ -307,7 +307,7 @@
                                 }
                             },
                             legend: {
-                                data:data.legend
+                                data: data.legend || []
                             },
                             grid: {
                                 x: 70,

+ 26 - 0
app/admin/view/order/store_order/index.php

@@ -431,6 +431,32 @@
                 break;
         }
     })
+    var action={
+        del_order:function () {
+            var ids=layList.getCheckData().getIds('id');
+            if(ids.length){
+                var url =layList.U({c:'order.store_order',a:'del_order'});
+                $eb.$swal('delete',function(){
+                    $eb.axios.post(url,{ids:ids}).then(function(res){
+                        if(res.status == 200 && res.data.code == 200) {
+                            $eb.$swal('success',res.data.msg);
+                        }else
+                            return Promise.reject(res.data.msg || '删除失败')
+                    }).catch(function(err){
+                        $eb.$swal('error',err);
+                    });
+                },{'title':'您确定要修删除订单吗?','text':'删除后将无法恢复,请谨慎操作!','confirm':'是的,我要删除'})
+            }else{
+                layList.msg('请选择要删除的订单');
+            }
+        }
+    };
+    $('#container-action').find('button').each(function () {
+        $(this).on('click',function(){
+            var act = $(this).data('type');
+            action[act] && action[act]();
+        });
+    })
     //下拉框
     $(document).click(function (e) {
         $('.layui-nav-child').hide();

+ 0 - 48
app/admin/view/record/record/chart_product.php

@@ -1,53 +1,5 @@
 {extend name="public/container"}
 {block name="head_top"}
-<style>
-    .layui-input-block button{
-        border: 1px solid rgba(0,0,0,0.1);
-    }
-    .layui-card-body{
-        padding-left: 10px;
-        padding-right: 10px;
-    }
-    .layui-card-body p.layuiadmin-big-font {
-        font-size: 36px;
-        color: #666;
-        line-height: 36px;
-        padding: 5px 0 10px;
-        overflow: hidden;
-        text-overflow: ellipsis;
-        word-break: break-all;
-        white-space: nowrap;
-    }
-    .layuiadmin-badge, .layuiadmin-btn-group, .layuiadmin-span-color {
-        position: absolute;
-        right: 15px;
-    }
-    .layuiadmin-badge {
-        top: 50%;
-        margin-top: -9px;
-        color: #01AAED;
-    }
-    .layuiadmin-span-color i {
-        padding-left: 5px;
-    }
-    .block-rigit{
-        text-align: right;
-    }
-    .block-rigit button{
-        width: 100px;
-        letter-spacing: .5em;
-        line-height: 28px;
-    }
-    .layuiadmin-card-list{
-        padding: 1.6px;
-    }
-    .layuiadmin-card-list p.layuiadmin-normal-font {
-        padding-bottom: 10px;
-        font-size: 20px;
-        color: #666;
-        line-height: 24px;
-    }
-</style>
 <script src="{__PLUG_PATH}echarts.common.min.js"></script>
 {/block}
 {block name="content"}

+ 6 - 10
app/admin/view/sms/sms_admin/index.php

@@ -57,7 +57,7 @@
         <div class="col-sm-12">
             <div class="ibox float-e-margins">
                 <div class="ibox-title">
-                    <h5>短信账号注册/修改</h5>
+                    <h5>短信账号注册</h5>
                 </div><div id="store-attr" class="mp-form" v-cloak="">
                     <i-Form :label-width="80" style="width: 100%">
                         <template >
@@ -128,7 +128,7 @@
         new Vue({
             data () {
                 return {
-                    codeUrl : "{$url}",
+                    codeUrl : "{:Url('captcha')}",
                     codeMsg : "发送验证码",
                     form:{
                         account:'',
@@ -157,17 +157,13 @@
                         $eb.message('error','请填写短信签名');
                         return false;
                     }
-                    if(that.form.sign.length > 20){
-                        $eb.message('error','短信签名最大长度为20个字符');
-                        return false;
-                    }
                     if(!that.isPhone(that.form.phone)){
                         $eb.message('error','手机号格式错误');
                         return false;
                     }
                     that.isSend = false;
-                    $eb.axios.get(that.codeUrl + '?phone=' + that.form.phone).then(function(res){
-                        if(res.status == 200){
+                    $eb.axios.post(that.codeUrl,{phone:that.form.phone}).then(function(res){
+                        if(res.data.code == 200){
                             var cd = 60;
                             var timeClone = setInterval(function () {
                                 cd--;
@@ -180,9 +176,9 @@
                                     that.codeMsg = '剩余'+cd+'s';
                                 }
                             },1000);
-                            $eb.message('success','验证码发送成功');
+                            $eb.message('success',res.data.msg || '发送成功');
                         }else{
-                            $eb.message('error',res.msg);
+                            $eb.message('error',res.data.msg || '发送失败');
                         }
                         return false;
                     }).catch(function(err){

+ 10 - 2
app/admin/view/store/store_product/index.php

@@ -124,6 +124,14 @@
                                 <a href="javascript:void(0);" onclick="$eb.createModalFrame(this.innerText,'{:Url('ump.store_seckill/seckill')}?id={{d.id}}')"">
                                 <i class="fa fa-gavel"></i> 开启秒杀</a>
                             </li>
+                            <li>
+                                <a href="javascript:void(0);" onclick="$eb.createModalFrame(this.innerText,'{:Url('ump.store_bargain/bargain')}?id={{d.id}}')">
+                                    <i class="fa fa-sort-amount-asc"></i> 开启砍价</a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);" onclick="$eb.createModalFrame(this.innerText,'{:Url('ump.store_combination/combination')}?id={{d.id}}')">
+                                    <i class="fa fa-hand-lizard-o"></i> 开启拼团</a>
+                            </li>
                             {{# if(d.is_del){ }}
                             <li>
                                 <a href="javascript:void(0);" lay-event='delstor'>
@@ -264,13 +272,13 @@
         if(odj.elem.checked==true){
             layList.baseGet(layList.Url({c:'store.store_product',a:'set_show',p:{is_show:1,id:value}}),function (res) {
                 layList.msg(res.msg, function () {
-                    location.reload();
+                    layList.reload();
                 });
             });
         }else{
             layList.baseGet(layList.Url({c:'store.store_product',a:'set_show',p:{is_show:0,id:value}}),function (res) {
                 layList.msg(res.msg, function () {
-                    location.reload();
+                    layList.reload();
                 });
             });
         }

+ 2 - 2
app/admin/view/system/system_file/opendir.php

@@ -50,7 +50,7 @@
                         {volist name="fileAll['file']" id="vo"}
                         <tr>
                             <td class="text-left">
-                                <span onclick="$eb.createModalFrame('{$vo.filename}','{:Url('openfile')}?file={$dir}/{$vo.filename}',{w:1260,h:600})"> <i class="fa fa-file-text-o"></i> {$vo.filename}</span>
+                                <span onclick="$eb.createModalFrame('{$vo.filename}','{:Url('openfile')}?file={$vo.pathname}',{w:1260,h:600})"> <i class="fa fa-file-text-o"></i> {$vo.filename}</span>
                             </td>
                             <td class="text-left">
                                 <span> {$vo.size}</span>
@@ -63,7 +63,7 @@
                             </td>
 
                             <td class="text-center">
-                                <button class="btn btn-info btn-xs" type="button"  onclick="$eb.createModalFrame('{$vo.filename}','{:Url('openfile')}?file={$dir}/{$vo.filename}',{w:1260,h:660})"><i class="fa fa-paste"></i> 编辑</button>
+                                <button class="btn btn-info btn-xs" type="button"  onclick="$eb.createModalFrame('{$vo.filename}','{:Url('openfile')}?file={$vo.pathname}',{w:1260,h:660})"><i class="fa fa-paste"></i> 编辑</button>
 <!--                                <button class="btn btn-info btn-xs" type="button"  onclick="$eb.createModalFrame('{$vo.filename}','{:Url('openfile')}?file={$vo.filename}&dir={$dir}',{w:1260,h:600})"><i class="fa fa-paste"></i> 重命名</button>-->
 <!--                                <button class="btn btn-info btn-xs" type="button"  onclick="$eb.createModalFrame('{$vo.filename}','{:Url('openfile')}?file={$vo.filename}&dir={$dir}',{w:1260,h:600})"><i class="fa fa-paste"></i> 删除</button>-->
 <!--                                <button class="btn btn-info btn-xs" type="button"  onclick="$eb.createModalFrame('{$vo.filename}','{:Url('openfile')}?file={$vo.filename}&dir={$dir}',{w:1260,h:600})"><i class="fa fa-paste"></i> 下载</button>-->

+ 2 - 2
app/admin/view/wechat/store_service/create.php

@@ -75,11 +75,11 @@
                                         {if condition="$vo['subscribe']"}
                                         关注
                                         {else/}
-                                        取消
+                                        未关注
                                         {/if}
                                     </td>
                                     <td class="text-center">
-                                        {$vo.add_time|date="Y-m-d H:i:s"}
+                                        {$vo.time}
                                     </td>
                                 </tr>
                                 {/volist}

+ 1 - 1
app/admin/view/widget/images.php

@@ -124,7 +124,7 @@
                             </div>
                         </div>
                     </div>
-                    <div class="layui-card-body clearfix image-box" style="padding: 10px;">
+                    <div class="layui-card-body clearfix image-box" style="padding: 10px;height: 360px;z-index:10;">
                         <div class="layui-col-md2 layui-col-xs2 layui-col-sm2 image" v-for="(item,index) in imageList">
                             <div class="layui-img-box"  :class="item.isSelect ? 'on': '' ">
                                 <img :src="item.att_dir" v-if="small == 1" @click="changImage(item,index)">

+ 6 - 1
app/api/controller/AuthController.php

@@ -17,6 +17,11 @@ use think\exception\ValidateException;
 use think\facade\Queue;
 use think\facade\Session;
 
+/**微信小程序授权类
+ * Class AuthController
+ * @package app\api\controller
+ */
+
 class AuthController
 {
     public function login(Request $request)
@@ -80,7 +85,7 @@ class AuthController
         $res = SMSService::send($phone,SMSService::VERIFICATION_CODE,$data);
         if($res['status'] == 400) return app('json')->fail('短信平台验证码发送失败'.$res['msg']);
         CacheService::set('code_'.$phone, $code, $time);
-        return app('json')->success($res['msg']);
+        return app('json')->success($res['msg'] ?? '发送失败');
     }
 
     /**

+ 10 - 6
app/api/controller/PublicController.php

@@ -36,6 +36,7 @@ class PublicController
         $menus = GroupDataService::getData('routine_home_menus') ?: [];//TODO 首页按钮
         $roll = GroupDataService::getData('routine_home_roll_news') ?: [];//TODO 首页滚动新闻
         $activity = GroupDataService::getData('routine_home_activity', 3) ?: [];//TODO 首页活动区域图片
+        $site_name = SystemConfigService::get('site_name');
         $routine_index_page = GroupDataService::getData('routine_index_page');
         $info['fastInfo'] = $routine_index_page[0]['fast_info'] ?? '';//SystemConfigService::get('fast_info');//TODO 快速选择简介
         $info['bastInfo'] = $routine_index_page[0]['bast_info'] ?? '';//SystemConfigService::get('bast_info');//TODO 精品推荐简介
@@ -49,14 +50,13 @@ class PublicController
         $firstNumber = $routine_index_page[0]['first_number'] ?? 6;//SystemConfigService::get('first_number');//TODO 首发新品个数
         $info['fastList'] = StoreCategory::byIndexList((int)$fastNumber);//TODO 快速选择分类个数
         $info['bastList'] = StoreProduct::getBestProduct('id,image,store_name,cate_id,price,ot_price,IFNULL(sales,0) + IFNULL(ficti,0) as sales,unit_name', (int)$bastNumber, $request->uid());//TODO 精品推荐个数
-        $info['firstList'] = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,unit_name', (int)$firstNumber);//TODO 首发新品个数
+        $info['firstList'] = StoreProduct::getNewProduct('id,image,store_name,cate_id,price,unit_name,IFNULL(sales,0) + IFNULL(ficti,0) as sales', (int)$firstNumber,$request->uid());//TODO 首发新品个数
         $info['bastBanner'] = GroupDataService::getData('routine_home_bast_banner') ?? [];//TODO 首页精品推荐图片
         $benefit = StoreProduct::getBenefitProduct('id,image,store_name,cate_id,price,ot_price,stock,unit_name', 3);//TODO 首页促销单品
         $lovely = GroupDataService::getData('routine_home_new_banner') ?: [];//TODO 首发新品顶部图
         $likeInfo = StoreProduct::getHotProduct('id,image,store_name,cate_id,price,unit_name', 3);//TODO 热门榜单 猜你喜欢
         $couponList = StoreCouponIssue::getIssueCouponList($request->uid(), 3);
-
-        return app('json')->successful(compact('banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'couponList'));
+        return app('json')->successful(compact('banner', 'menus', 'roll', 'info', 'activity', 'lovely', 'benefit', 'likeInfo', 'logoUrl', 'couponList','site_name'));
     }
 
     /**
@@ -132,11 +132,15 @@ class PublicController
         $res = UploadService::image($data['filename'],'store/comment');
         if(!is_array($res)) return app('json')->fail($res);
         SystemAttachment::attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'],1, $res['image_type'], $res['time'], 2);
-        if(Cache::has('start_uploads_'.$request->uid())) $start_uploads=(int)Cache::get('start_uploads_'.$request->uid());
-        else $start_uploads = 0;
+        if(Cache::has('start_uploads_'.$request->uid()))
+            $start_uploads=(int)Cache::get('start_uploads_'.$request->uid());
+        else
+            $start_uploads = 0;
         $start_uploads++;
         Cache::set('start_uploads_'.$request->uid(),$start_uploads,86400);
-        return app('json')->successful('图片上传成功!', ['name' => $res['name'], 'url' => $request->domain() . UploadService::pathToUrl($res['dir'])]);
+        $res['dir'] = UploadService::pathToUrl($res['dir']);
+        if(strpos($res['dir'],'http') === false) $res['dir'] = $request->domain().$res['dir'];
+        return app('json')->successful('图片上传成功!', ['name' => $res['name'], 'url' => $res['dir']]);
     }
 
     /**

+ 1 - 1
app/api/controller/activity/StoreBargainController.php

@@ -141,7 +141,7 @@ class StoreBargainController
                 $openid = WechatUser::uidToOpenid($bargainUserUid, 'openid');
                 $routineOpenid = WechatUser::uidToOpenid($bargainUserUid, 'routine_openid');
                 if($openid){//公众号
-                    $urlWeChat = Route::buildUrl('activity/dargain_detail/'.$bargainId.'/'.$bargainUserUid,[],true,true);
+                    $urlWeChat = Route::buildUrl('activity/dargain_detail/'.$bargainId.'/'.$bargainUserUid)->suffix('')->domain(true)->build();
                     WechatTemplateService::sendTemplate($openid,WechatTemplateService::BARGAIN_SUCCESS,[
                         'first'=> '好腻害!你的朋友们已经帮你砍到底价了!',
                         'keyword1'=> $bargainInfo['title'],

+ 4 - 0
app/api/controller/order/StoreOrderController.php

@@ -164,6 +164,8 @@ class StoreOrderController
         $orderId = $order['order_id'];
         $info = compact('orderId', 'key');
         if ($orderId) {
+            event('OrderCreated', [$order]);
+
             switch ($payType) {
                 case "weixin":
                     $orderInfo = StoreOrder::where('order_id', $orderId)->find();
@@ -250,6 +252,7 @@ class StoreOrderController
             if(!$v) return app('json')->fail('再来一单失败,请重新下单!');
             $cateId[] = $v['id'];
         }
+        event('OrderCreateAgain', implode(',',$cateId));
         return app('json')->successful('ok',['cateId'=>implode(',',$cateId)]);
     }
 
@@ -488,6 +491,7 @@ class StoreOrderController
             return app('json')->fail($e->getMessage());
         }
         StoreProductReply::commitTrans();
+        event('UserCommented', $res);
         return app('json')->successful();
     }
 

+ 1 - 1
app/api/controller/store/CategoryController.php

@@ -9,7 +9,7 @@ class CategoryController
 {
     public function category(Request $request)
     {
-        $cateogry = StoreCategory::with('children')->where('pid',0)->select();
+        $cateogry = StoreCategory::with('children')->where('is_show',1)->where('pid',0)->select();
         return app('json')->success($cateogry->hidden(['add_time','is_show','sort','children.sort','children.add_time','children.pid','children.is_show'])->toArray());
     }
 }

+ 2 - 2
app/api/controller/store/StoreProductController.php

@@ -81,10 +81,10 @@ class StoreProductController
                     $res = \app\models\routine\RoutineCode::getPageCode('pages/goods_details/index',$data,280);
                     if(!$res) return app('json')->fail('二维码生成失败');
                     $imageInfo = \crmeb\services\UploadService::imageStream($name,$res,'routine/product');
-                    if(!is_array($imageInfo)) return app('json')->fail($imageInfo);
+                    if(is_string($imageInfo)) return app('json')->fail($imageInfo);
                     if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']);
                     else $remoteImage = UtilService::remoteImage($imageInfo['dir']);
-                    if(!$remoteImage['status']) return app('json')->fail('小程序二维码未能生成',$remoteImage['msg']);
+                    if(!$remoteImage['status']) return app('json')->fail('小程序二维码未能生成');
                     SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2);
                     $url = $imageInfo['dir'];
                 }else $url = $imageInfo['att_dir'];

+ 1 - 2
app/common.php

@@ -110,10 +110,9 @@ if (!function_exists('make_path')) {
                 break;
         }
         try{
-            if (is_dir(app()->getAppPath().$path) == true || mkdir(app()->getAppPath().$path, 0777, true) == true) {
+            if (is_dir(app()->getRootPath().'public'.DS.'uploads'.$path) == true || mkdir(app()->getRootPath().'public'.DS.'uploads'.$path, 0777, true) == true) {
                 return trim(str_replace(DS, '/',$path),'.');
             }else return '';
-
         }catch (\Exception $e){
             return '无法创建文件夹,请检查您的上传目录权限:' . app()->getRootPath() . 'public' . DS . 'uploads' . DS. 'attach' . DS;
         }

+ 8 - 0
app/event.php

@@ -47,6 +47,14 @@ return [
         'WechatOauthAfter' => [], // UserSubscribe 微信授权成功后  wap模块 WapBasic控制器
         'InitLogin' => [], // UserSubscribe 微信授权成功后  ebapi模块 Basic控制器
         'UserLevelAfter' => [], // UserSubscribe 检查是否能成为会员  models模块 user.UserSign Model  store.StoreOrder Model user.UserBill Model
+        'OrderCreated' => [], //用户订单创建成功
+        'OrderPaySuccess' => [], //用户订单支付成功
+        'OrderCreateAgain' => [], //用户再次下单
+        'UserOrderRemoved' => [], //用户删除订单
+        'UserOrderTake' => [], //用户确认收货
+        'UserCommented' => [], //用户评价商品
+        'RechargeSuccess' => [], //用户充值成功后
+        'ImportNowMoney' => [], //用户佣金转成余额成功后
     ],
 
     'subscribe' => [

+ 4 - 1
app/models/store/StoreOrder.php

@@ -601,7 +601,7 @@ class StoreOrder extends BaseModel
                     'keyword1'=>$orderId,
                     'keyword2'=>$order['pay_price'],
                     'remark'=>'点击查看订单详情'
-                ],Route::buildUrl('order/detail/'.$orderId,[],true,true));
+                ],Route::buildUrl('order/detail/'.$orderId)->suffix('')->domain(true)->build());
                 CustomerService::sendOrderPaySuccessCustomerService($order, 1);
                 WechatTemplateService::sendAdminNoticeTemplate([
                     'first'=>"亲,您有一个新订单 \n订单号:{$order['order_id']}",
@@ -618,6 +618,7 @@ class StoreOrder extends BaseModel
         }catch (\Exception $e){}
         $user = User::where('uid', $order['uid'])->find()->toArray();
         event('UserLevelAfter', [$user]);
+        event('OrderPaySuccess', [$order]);
         $res = $res1 && $resPink;
         return false !== $res;
     }
@@ -742,6 +743,7 @@ class StoreOrder extends BaseModel
             if ($order['_status']['_type'] == 0 || $order['_status']['_type'] == -2) {
                 event('StoreOrderRegressionAllAfter', [$order]);
             }
+            event('UserOrderRemoved', $uni);
             return true;
         } else
             return self::setErrorInfo('订单删除失败!');
@@ -769,6 +771,7 @@ class StoreOrder extends BaseModel
                 return self::setErrorInfo($e->getMessage());
             }
             self::commitTrans();
+            event('UserOrderTake', $uni);
             return true;
         } else {
             self::rollbackTrans();

+ 1 - 1
app/models/store/StoreProduct.php

@@ -213,7 +213,7 @@ class StoreProduct extends BaseModel
     public static function setLevelPrice($list, $uid, $isSingle = false)
     {
         if (is_object($list)) $list = count($list) ? $list->toArray() : [];
-        if (!SystemConfigService::get('vip_open') || !$uid) {
+        if (!SystemConfigService::get('vip_open')) {
             if (is_array($list)) return $list;
             return $isSingle ? $list : 0;
         }

+ 1 - 1
app/models/system/SystemUserLevel.php

@@ -104,7 +104,7 @@ class SystemUserLevel extends BaseModel
             if($isArray) $item['task_list'] = SystemUserTask::getTashList($item['id']);
         }
         foreach ($list as &$item){
-            if($grade < $item['grade']) $item['is_clear']=true;
+            if($grade <= $item['grade']) $item['is_clear']=true;
             else $item['is_clear']=false;
         }
         return $list;

+ 5 - 4
app/models/user/User.php

@@ -108,7 +108,7 @@ class User extends BaseModel
             //TODO 获取后台分销类型
             $storeBrokerageStatus = SystemConfigService::get('store_brokerage_statu');
             $storeBrokerageStatus = $storeBrokerageStatus ? $storeBrokerageStatus : 1;
-            if(isset($wechatUser['code']) && $wechatUser['code']){
+            if(isset($wechatUser['code']) && $wechatUser['code'] && $wechatUser['code'] != $uid){
                 if($storeBrokerageStatus == 1){
                     $spreadCount = self::where('uid',$wechatUser['code'])->count();
                     if($spreadCount){
@@ -144,6 +144,7 @@ class User extends BaseModel
         if($userInfo->spread_uid) return true;
         //没有推广编号直接返回
         if(!$spread)  return true;
+        if($spread == $uid) return true;
         //TODO 获取后台分销类型
         $storeBrokerageStatus = SystemConfigService::get('store_brokerage_statu');
         $storeBrokerageStatus = $storeBrokerageStatus ? $storeBrokerageStatus : 1;
@@ -292,10 +293,10 @@ class User extends BaseModel
         $res1 = UserBill::income('获得推广佣金',$userInfo['spread_uid'],'now_money','brokerage',$brokeragePrice,$orderInfo['id'],$balance,$mark);
         //TODO 添加用户余额
         $res2 = self::bcInc($userInfo['spread_uid'],'brokerage_price',$brokeragePrice,'uid');
-        $res = $res1 && $res2;
-        self::checkTrans($res);
         //TODO 一级返佣成功 跳转二级返佣
-        if($res) return self::backOrderBrokerageTwo($orderInfo);
+        $res = $res1 && $res2 && self::backOrderBrokerageTwo($orderInfo);
+        self::checkTrans($res);
+//        if($res) return self::backOrderBrokerageTwo($orderInfo);
         return $res;
     }
 

+ 1 - 1
app/models/user/UserExtract.php

@@ -75,7 +75,7 @@ class UserExtract extends BaseModel
             'status' => self::AUDIT_STATUS
         ];
         if(isset($data['name']) && strlen(trim($data['name']))) $insertData['real_name'] = $data['name'];
-        else return self::setErrorInfo('请输入姓名');
+        else $insertData['real_name'] = $userInfo['nickname'];
         if(isset($data['cardnum'])) $insertData['bank_code'] = $data['cardnum'];
         else $insertData['bank_code'] = '';
         if(isset($data['bankname'])) $insertData['bank_address']=$data['bankname'];

+ 4 - 0
app/models/user/UserRecharge.php

@@ -95,6 +95,7 @@ class UserRecharge extends BaseModel
         $res3 = User::edit(['now_money'=>bcadd($user['now_money'],$order['price'],2)],$order['uid'],'uid');
         $res = $res1 && $res2 && $res3;
         self::checkTrans($res);
+        event('RechargeSuccess', [$order]);
         return $res;
     }
 
@@ -113,6 +114,9 @@ class UserRecharge extends BaseModel
             $res2 = UserBill::expend('用户佣金转入余额',$uid,'now_money','recharge',$price,0,$user['now_money'],'成功转入余额'.floatval($price).'元');
             $res = $res2 && $res1 && $res3;
             self::checkTrans($res);
+            if($res){
+                event('ImportNowMoney', [$uid, $price]);
+            }
             return $res;
         }catch (\Exception $e){
             self::rollbackTrans();

+ 1 - 1
app/models/user/WechatUser.php

@@ -113,7 +113,7 @@ class WechatUser extends BaseModel
         }else{
             $routineInfo['add_time'] = time();//用户添加时间
             $routineInfo = self::create($routineInfo);
-            $res = User::setRoutineUser($routineInfo);
+            $res = User::setRoutineUser($routineInfo,$spid);
             $uid = $res->uid;
         }
         $data['page'] = $page;

+ 1 - 1
crmeb/services/HttpService.php

@@ -77,7 +77,7 @@ class HttpService
         return (intval($status["http_code"]) === 200) ? $content : false;
     }
 
-    public static function postRequest($url, $data = array(), $header = false, $timeout = 10)
+    public static function postRequest($url, array $data = array(), $header = false, $timeout = 10)
     {
         return self::request($url, 'post', $data, $header, $timeout);
     }

+ 2 - 2
crmeb/services/SMSService.php

@@ -18,12 +18,12 @@ class SMSService
     public static $status;
 
     // 短信请求地址
-    private static $SMSUrl = 'http://sms.crmeb.net/api/';
+    private static $SMSUrl = 'https://sms.crmeb.net/api/';
 
     //短信支付回调地址
     private static $payNotify;
 
-    const VERIFICATION_CODE = 518047;
+    const VERIFICATION_CODE = 518076;
 
     public function __construct()
     {

+ 2 - 2
crmeb/services/UploadService.php

@@ -269,10 +269,10 @@ class UploadService
                 $info['image_type'] = 3;
                 break;
             case 4 :
-                $serverImageInfo = COS::uploadImageStream($key, $content);
+                list($imageUrl,$serverImageInfo) = COS::uploadImageStream($key, $content);
                 if (!is_array($serverImageInfo) && !is_object($serverImageInfo)) return $serverImageInfo;
                 if (is_object($serverImageInfo)) $serverImageInfo = $serverImageInfo->toArray();
-                $serverImageInfo['ObjectURL'] = UtilService::setHttpType($serverImageInfo['ObjectURL']);
+                $serverImageInfo['ObjectURL'] = $imageUrl;
                 $info['code'] = 200;
                 $info['name'] = substr(strrchr($serverImageInfo['ObjectURL'], '/'), 1);
                 $info['dir'] = $serverImageInfo['ObjectURL'];

+ 26 - 21
crmeb/services/UtilService.php

@@ -572,14 +572,13 @@ class UtilService
         $uploadType = SystemConfigService::get('upload_type');
         //TODO 没有选择默认使用本地上传
         if (!$uploadType) $uploadType = 1;
-        $siteUrl = SystemConfigService::get('site_url');
+        $siteUrl = SystemConfigService::get('site_url') ?: '.';
         $info = [];
         $outfile = Config::get('qrcode.cache_dir');
 
         $code = new QRcode();
         $wapCodePath = $code->png($url, $outfile.'/'.$name)->getPath(); //获取二维码生成的地址
-        if($uploadType == 1)  $content = file_get_contents('.'.$wapCodePath);
-        else  $content = file_get_contents($wapCodePath);
+        $content = file_get_contents('.'.$wapCodePath);
         switch ($uploadType) {
             case 1 :
                 $info["code"] = 200;
@@ -624,10 +623,10 @@ class UtilService
                 $info['image_type'] = 3;
                 break;
             case 4 :
-                $serverImageInfo = COS::uploadImageStream($name, $content);
+                list($imageUrl,$serverImageInfo) = COS::uploadImageStream($name, $content);
                 if (!is_array($serverImageInfo) && !is_object($serverImageInfo)) return $serverImageInfo;
                 if (is_object($serverImageInfo)) $serverImageInfo = $serverImageInfo->toArray();
-                $serverImageInfo['ObjectURL'] = UtilService::setHttpType($serverImageInfo['ObjectURL']);
+                $serverImageInfo['ObjectURL'] = $imageUrl;
                 $info['code'] = 200;
                 $info['name'] = substr(strrchr($serverImageInfo['ObjectURL'], '/'), 1);
                 $info['dir'] = $serverImageInfo['ObjectURL'];
@@ -649,22 +648,28 @@ class UtilService
      * @param string $avatar
      * @return bool|string
      */
-    public static function setImageBase64($avatar = ''){
-        $header = array(
-            'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0',
-            'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
-            'Accept-Encoding: gzip, deflate',);
-        $curl = curl_init();
-        curl_setopt($curl, CURLOPT_URL, $avatar);
-        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
-        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
-        curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
-        curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
-        $data = curl_exec($curl);
-        $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
-        curl_close($curl);
-        if ($code == 200)  return "data:image/jpeg;base64," . base64_encode($data);
-        else return false;
+    public static function setImageBase64($avatar = '',$timeout=15){
+        try{
+            $header = array(
+                'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0',
+                'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
+                'Accept-Encoding: gzip, deflate',);
+            $curl = curl_init();
+            curl_setopt($curl, CURLOPT_URL, $avatar);
+            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+            curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
+            curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
+            curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
+            curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
+            $data = curl_exec($curl);
+            $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+            curl_close($curl);
+            if ($code == 200)  return "data:image/jpeg;base64," . base64_encode($data);
+            else return false;
+        }catch (\Exception $e){
+            return false;
+        }
+
     }
 
 

+ 2 - 2
crmeb/services/WechatService.php

@@ -167,7 +167,7 @@ class WechatService
                     break;
             }
             
-            return $response;
+            return $response ?? false;
         });
     }
 
@@ -436,7 +436,6 @@ class WechatService
     {
         self::paymentService()->handleNotify(function($notify, $successful){
             if($successful && isset($notify->out_trade_no)){
-                WechatMessage::setOnceMessage($notify,$notify->openid,'payment_success',$notify->out_trade_no);
                 if(isset($notify->attach) && $notify->attach){
                     if(strtolower($notify->attach) == 'product'){//TODO  商品订单支付成功后
                         try{
@@ -454,6 +453,7 @@ class WechatService
                         }
                     }
                 }
+                WechatMessage::setOnceMessage($notify,$notify->openid,'payment_success',$notify->out_trade_no);
                 return false;
             }
         });

+ 6 - 6
crmeb/services/storage/COS.php

@@ -4,7 +4,7 @@ namespace crmeb\services\storage;
 use crmeb\services\SystemConfigService;
 use Guzzle\Http\EntityBody;
 use Qcloud\Cos\Client;
-use think\Cache;
+use think\facade\Cache;
 
 /**
  * TODO 腾讯云COS文件上传
@@ -76,7 +76,7 @@ class COS
         $request = app('request');
         $file = $request->file($filename);
         $filePath = $file->getRealPath();
-        $ext = pathinfo($file->getInfo('name'), PATHINFO_EXTENSION);
+        $ext = $file->getOriginalExtension();
         $key = substr(md5($file->getRealPath()) , 0, 5). date('YmdHis') . rand(0, 9999) . '.' . $ext;
         try {
             self::autoInfo();
@@ -86,7 +86,7 @@ class COS
                 'Body' => fopen($filePath, 'rb')
             ])];
         } catch (\Exception $e) {
-            return $e->getMessage();
+            return [false,$e->getMessage()];
         }
     }
 
@@ -99,13 +99,13 @@ class COS
     public static function uploadImageStream($key, $content){
         try {
             self::autoInfo();
-            return self::$auth->putObject([
+            return [self::$uploadUrl.$key,self::$auth->putObject([
                 'Bucket' => self::$storageName,
                 'Key' => $key,
                 'Body' => $content
-            ]);
+            ])];
         } catch (\Exception $e) {
-            return $e->getMessage();
+            return [false,$e->getMessage()];
         }
     }
 

+ 1 - 1
crmeb/services/storage/OSS.php

@@ -65,7 +65,7 @@ class OSS
         $request = app('request');
         $file = $request->file($filename);
         $filePath = $file->getRealPath();
-        $ext = pathinfo($file->getInfo('name'), PATHINFO_EXTENSION);
+        $ext = $file->getOriginalExtension();
         $key = substr(md5($file->getRealPath()) , 0, 5). date('YmdHis') . rand(0, 9999) . '.' . $ext;
         try{
             self::autoInfo();

+ 2 - 2
crmeb/services/storage/Qiniu.php

@@ -6,7 +6,7 @@ use Qiniu\Auth;
 use Qiniu\Storage\BucketManager;
 use Qiniu\Storage\UploadManager;
 use Qiniu\Config;
-use think\Cache;
+use think\facade\Cache;
 
 
 /**
@@ -78,7 +78,7 @@ class Qiniu
         $request = app('request');
         $file = $request->file($filename);
         $filePath = $file->getRealPath();
-        $ext = pathinfo($file->getInfo('name'), PATHINFO_EXTENSION);
+        $ext = $file->getOriginalExtension();
         $key = substr(md5($file->getRealPath()) , 0, 5). date('YmdHis') . rand(0, 9999) . '.' . $ext;
         $token = self::autoInfo()->uploadToken(self::$storageName);
         try{

+ 1 - 1
crmeb/traits/ModelTrait.php

@@ -234,7 +234,7 @@ trait ModelTrait
                 if(strstr($where[$data],$field)!==false){
                     list($startTime, $endTime) = explode($field, $where[$data]);
                     $model = $model->where($prefix, '>', strtotime($startTime));
-                    $model = $model->where($prefix, '<', strtotime($endTime));
+                    $model = $model->where($prefix, '<', bcadd(strtotime($endTime),86400,0));
                 }
                 break;
         }

+ 1 - 1
route/api/route.php

@@ -186,7 +186,7 @@ Route::group(function () {
     //小程序登陆
     Route::post('wechat/mp_auth', 'wechat.AuthController/mp_auth')->name('mpAuth');//小程序登陆
     Route::get('wechat/get_logo', 'wechat.AuthController/get_logo')->name('getLogo');//小程序登陆授权展示logo
-    Route::post('wechat/set_form_id', 'wechat.AuthController/set_form_id')->name('setFormId');//小程序登陆授权展示logo
+    Route::post('wechat/set_form_id', 'wechat.AuthController/set_form_id')->name('setFormId');//小程序登陆收集form id
 
     //物流公司
     Route::get('logistics', 'PublicController/logistics')->name('logistics');//物流公司列表